diff --git a/CMakeLists.txt b/CMakeLists.txt index 43636740e91..a299470b172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,7 +195,6 @@ option(WITH_IMAGE_FRAMESERVER "Enable image FrameServer Support for rendering" # Audio/Video format support option(WITH_CODEC_FFMPEG "Enable FFMPeg Support (http://ffmpeg.org)" OFF) -unset(PLATFORM_DEFAULT) option(WITH_CODEC_SNDFILE "Enable libsndfile Support (http://www.mega-nerd.com/libsndfile)" OFF) if(APPLE OR (WIN32 AND NOT UNIX)) @@ -372,7 +371,7 @@ if(MINGW) "line if youre a developer who wants to add support.") endif() - if((WITH_MINGW64) AND (WITH_OPENCOLLADA OR WITH_CODEC_FFMPEG)) + if((WITH_MINGW64) AND (WITH_OPENCOLLADA)) message(FATAL_ERROR "MINGW64 still doesn't support: WITH_OPENCOLLADA/WITH_CODEC_FFMPEG") endif() endif() @@ -1089,7 +1088,11 @@ elseif(WIN32) if(WITH_CODEC_FFMPEG) set(FFMPEG ${LIBDIR}/ffmpeg) set(FFMPEG_INCLUDE_DIRS ${FFMPEG}/include ${FFMPEG}/include) - set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2) + if(WITH_MINGW64) + set(FFMPEG_LIBRARIES avcodec.dll avformat.dll avdevice.dll avutil.dll swscale.dll swresample.dll) + else() + set(FFMPEG_LIBRARIES avcodec-53 avformat-53 avdevice-53 avutil-51 swscale-2) + endif() set(FFMPEG_LIBPATH ${FFMPEG}/lib) endif() @@ -1641,6 +1644,7 @@ if(WITH_PYTHON) PATH_SUFFIXES site-packages dist-packages + NO_DEFAULT_PATH ) if(NOT EXISTS "${PYTHON_NUMPY_PATH}") diff --git a/build_files/scons/config/win64-mingw-config.py b/build_files/scons/config/win64-mingw-config.py index 055b0c7b9fd..541574e0f63 100644 --- a/build_files/scons/config/win64-mingw-config.py +++ b/build_files/scons/config/win64-mingw-config.py @@ -16,11 +16,11 @@ BF_OPENAL_INC = '${BF_OPENAL}/include' BF_OPENAL_LIB = 'wrap_oal' BF_OPENAL_LIBPATH = '${BF_OPENAL}/lib' -WITH_BF_FFMPEG = False # TODO: FFmpeg gives linking errors, need to compile with MinGW-w64? -BF_FFMPEG_LIB = 'avformat-53 avcodec-53 avdevice-53 avutil-51 swscale-2' +WITH_BF_FFMPEG = True +BF_FFMPEG_LIB = 'avformat.dll avcodec.dll avdevice.dll avutil.dll swscale.dll swresample.dll' BF_FFMPEG_LIBPATH = LIBDIR + '/ffmpeg/lib' BF_FFMPEG_INC = LIBDIR + '/ffmpeg/include' -BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll' +BF_FFMPEG_DLL = '${BF_FFMPEG_LIBPATH}/avformat-53.dll ${BF_FFMPEG_LIBPATH}/avcodec-53.dll ${BF_FFMPEG_LIBPATH}/avdevice-53.dll ${BF_FFMPEG_LIBPATH}/avutil-51.dll ${BF_FFMPEG_LIBPATH}/swscale-2.dll ${BF_FFMPEG_LIBPATH}/swresample-0.dll ${BF_FFMPEG_LIBPATH}/xvidcore.dll' WITH_BF_JACK = False BF_JACK = LIBDIR + '/jack' @@ -137,14 +137,14 @@ BF_OPENGL_LIB_STATIC = [ '${BF_OPENGL}/lib/libGL.a', '${BF_OPENGL}/lib/libGLU.a' '${BF_OPENGL}/lib/libXmu.a', '${BF_OPENGL}/lib/libXext.a', '${BF_OPENGL}/lib/libX11.a', '${BF_OPENGL}/lib/libXi.a' ] -WITH_BF_COLLADA = False # TODO: Compile Collada with MinGW-w64 +WITH_BF_COLLADA = True BF_COLLADA = '#source/blender/collada' BF_COLLADA_INC = '${BF_COLLADA}' BF_COLLADA_LIB = 'bf_collada' BF_OPENCOLLADA = LIBDIR + '/opencollada' BF_OPENCOLLADA_INC = '${BF_OPENCOLLADA}/include' -BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver expat pcre buffer ftoa' +BF_OPENCOLLADA_LIB = 'OpenCOLLADAStreamWriter OpenCOLLADASaxFrameworkLoader OpenCOLLADAFramework OpenCOLLADABaseUtils GeneratedSaxParser UTF MathMLSolver pcre buffer ftoa xml' BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib' #Cycles diff --git a/extern/Eigen3/Eigen/Core b/extern/Eigen3/Eigen/Core index 6e855427c33..a5025e37ead 100644 --- a/extern/Eigen3/Eigen/Core +++ b/extern/Eigen3/Eigen/Core @@ -167,7 +167,7 @@ #include #endif -#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_NO_EXCEPTIONS) +#if defined(_CPPUNWIND) || defined(__EXCEPTIONS) #define EIGEN_EXCEPTIONS #endif diff --git a/extern/Eigen3/Eigen/SVD b/extern/Eigen3/Eigen/SVD index d24471fd724..7c987a9dd36 100644 --- a/extern/Eigen3/Eigen/SVD +++ b/extern/Eigen3/Eigen/SVD @@ -13,9 +13,9 @@ namespace Eigen { * * * - * This module provides SVD decomposition for (currently) real matrices. + * This module provides SVD decomposition for matrices (both real and complex). * This decomposition is accessible via the following MatrixBase method: - * - MatrixBase::svd() + * - MatrixBase::jacobiSvd() * * \code * #include diff --git a/extern/Eigen3/Eigen/src/Cholesky/LDLT.h b/extern/Eigen3/Eigen/src/Cholesky/LDLT.h index f47b2ea5669..a19e947a4c6 100644 --- a/extern/Eigen3/Eigen/src/Cholesky/LDLT.h +++ b/extern/Eigen3/Eigen/src/Cholesky/LDLT.h @@ -331,16 +331,16 @@ template<> struct ldlt_inplace template struct LDLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m; } inline static MatrixU getU(const MatrixType& m) { return m.adjoint(); } }; template struct LDLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m.adjoint(); } inline static MatrixU getU(const MatrixType& m) { return m; } }; diff --git a/extern/Eigen3/Eigen/src/Cholesky/LLT.h b/extern/Eigen3/Eigen/src/Cholesky/LLT.h index a4ee5b11cb9..3bb76b5787f 100644 --- a/extern/Eigen3/Eigen/src/Cholesky/LLT.h +++ b/extern/Eigen3/Eigen/src/Cholesky/LLT.h @@ -274,8 +274,8 @@ template<> struct llt_inplace template struct LLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m; } inline static MatrixU getU(const MatrixType& m) { return m.adjoint(); } static bool inplace_decomposition(MatrixType& m) @@ -284,8 +284,8 @@ template struct LLT_Traits template struct LLT_Traits { - typedef TriangularView MatrixL; - typedef TriangularView MatrixU; + typedef const TriangularView MatrixL; + typedef const TriangularView MatrixU; inline static MatrixL getL(const MatrixType& m) { return m.adjoint(); } inline static MatrixU getU(const MatrixType& m) { return m; } static bool inplace_decomposition(MatrixType& m) diff --git a/extern/Eigen3/Eigen/src/Core/Array.h b/extern/Eigen3/Eigen/src/Core/Array.h index a3a2167ad3e..a11fb1b53d5 100644 --- a/extern/Eigen3/Eigen/src/Core/Array.h +++ b/extern/Eigen3/Eigen/src/Core/Array.h @@ -68,10 +68,8 @@ class Array friend struct internal::conservative_resize_like_impl; using Base::m_storage; + public: - enum { NeedsToAlign = (!(Options&DontAlign)) - && SizeAtCompileTime!=Dynamic && ((static_cast(sizeof(Scalar))*SizeAtCompileTime)%16)==0 }; - EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) using Base::base; using Base::coeff; diff --git a/extern/Eigen3/Eigen/src/Core/Block.h b/extern/Eigen3/Eigen/src/Core/Block.h index 2b251bc2ca9..d470bc13400 100644 --- a/extern/Eigen3/Eigen/src/Core/Block.h +++ b/extern/Eigen3/Eigen/src/Core/Block.h @@ -94,7 +94,7 @@ struct traits MaskPacketAccessBit = (InnerSize == Dynamic || (InnerSize % packet_traits::size) == 0) && (InnerStrideAtCompileTime == 1) ? PacketAccessBit : 0, - MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && ((OuterStrideAtCompileTime % packet_traits::size) == 0)) ? AlignedBit : 0, + MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % 16) == 0)) ? AlignedBit : 0, FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, FlagsLvalueBit = is_lvalue::value ? LvalueBit : 0, FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, @@ -342,7 +342,7 @@ class Block } const typename XprType::Nested m_xpr; - int m_outerStride; + Index m_outerStride; }; diff --git a/extern/Eigen3/Eigen/src/Core/DenseBase.h b/extern/Eigen3/Eigen/src/Core/DenseBase.h index 838fa40307a..920904f243a 100644 --- a/extern/Eigen3/Eigen/src/Core/DenseBase.h +++ b/extern/Eigen3/Eigen/src/Core/DenseBase.h @@ -169,8 +169,8 @@ template class DenseBase IsRowMajor = int(Flags) & RowMajorBit, /**< True if this expression has row-major storage order. */ - InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? SizeAtCompileTime - : int(IsRowMajor) ? ColsAtCompileTime : RowsAtCompileTime, + InnerSizeAtCompileTime = int(IsVectorAtCompileTime) ? int(SizeAtCompileTime) + : int(IsRowMajor) ? int(ColsAtCompileTime) : int(RowsAtCompileTime), CoeffReadCost = internal::traits::CoeffReadCost, /**< This is a rough measure of how expensive it is to read one coefficient from diff --git a/extern/Eigen3/Eigen/src/Core/Map.h b/extern/Eigen3/Eigen/src/Core/Map.h index dd0673609c5..2bf80b3af3d 100644 --- a/extern/Eigen3/Eigen/src/Core/Map.h +++ b/extern/Eigen3/Eigen/src/Core/Map.h @@ -102,7 +102,7 @@ struct traits > || HasNoOuterStride || ( OuterStrideAtCompileTime!=Dynamic && ((static_cast(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ), - Flags0 = TraitsBase::Flags, + Flags0 = TraitsBase::Flags & (~NestByRefBit), Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit), Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime)) ? int(Flags1) : int(Flags1 & ~LinearAccessBit), @@ -120,7 +120,6 @@ template class Ma public: typedef MapBase Base; - EIGEN_DENSE_PUBLIC_INTERFACE(Map) typedef typename Base::PointerType PointerType; @@ -181,7 +180,6 @@ template class Ma PlainObjectType::Base::_check_template_params(); } - EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map) protected: diff --git a/extern/Eigen3/Eigen/src/Core/MapBase.h b/extern/Eigen3/Eigen/src/Core/MapBase.h index c23bcbfdcca..9426e2d24dd 100644 --- a/extern/Eigen3/Eigen/src/Core/MapBase.h +++ b/extern/Eigen3/Eigen/src/Core/MapBase.h @@ -170,8 +170,8 @@ template class MapBase EIGEN_STATIC_ASSERT(EIGEN_IMPLIES(internal::traits::Flags&PacketAccessBit, internal::inner_stride_at_compile_time::ret==1), PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1); - eigen_assert(EIGEN_IMPLIES(internal::traits::Flags&AlignedBit, (size_t(m_data) % (sizeof(Scalar)*internal::packet_traits::size)) == 0) - && "data is not aligned"); + eigen_assert(EIGEN_IMPLIES(internal::traits::Flags&AlignedBit, (size_t(m_data) % 16) == 0) + && "data is not aligned"); } PointerType m_data; diff --git a/extern/Eigen3/Eigen/src/Core/Matrix.h b/extern/Eigen3/Eigen/src/Core/Matrix.h index 44de22cb4d5..982c9256af0 100644 --- a/extern/Eigen3/Eigen/src/Core/Matrix.h +++ b/extern/Eigen3/Eigen/src/Core/Matrix.h @@ -153,10 +153,6 @@ class Matrix typedef typename Base::PlainObject PlainObject; - enum { NeedsToAlign = (!(Options&DontAlign)) - && SizeAtCompileTime!=Dynamic && ((static_cast(sizeof(Scalar))*SizeAtCompileTime)%16)==0 }; - EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) - using Base::base; using Base::coeffRef; diff --git a/extern/Eigen3/Eigen/src/Core/MatrixBase.h b/extern/Eigen3/Eigen/src/Core/MatrixBase.h index db156f6e9d0..62877bce09e 100644 --- a/extern/Eigen3/Eigen/src/Core/MatrixBase.h +++ b/extern/Eigen3/Eigen/src/Core/MatrixBase.h @@ -250,7 +250,8 @@ template class MatrixBase // huuuge hack. make Eigen2's matrix.part() work in eigen3. Problem: Diagonal is now a class template instead // of an integer constant. Solution: overload the part() method template wrt template parameters list. - template class U> + // Note: replacing next line by "template class U>" produces a mysterious error C2082 in MSVC. + template class U> const DiagonalWrapper part() const { return diagonal().asDiagonal(); } #endif // EIGEN2_SUPPORT diff --git a/extern/Eigen3/Eigen/src/Core/PlainObjectBase.h b/extern/Eigen3/Eigen/src/Core/PlainObjectBase.h index c70db92479a..612254e9da9 100644 --- a/extern/Eigen3/Eigen/src/Core/PlainObjectBase.h +++ b/extern/Eigen3/Eigen/src/Core/PlainObjectBase.h @@ -34,6 +34,19 @@ namespace internal { +template +EIGEN_ALWAYS_INLINE void check_rows_cols_for_overflow(Index rows, Index cols) +{ + // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242 + // we assume Index is signed + Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed + bool error = (rows < 0 || cols < 0) ? true + : (rows == 0 || cols == 0) ? false + : (rows > max_index / cols); + if (error) + throw_std_bad_alloc(); +} + template (Derived::IsVectorAtCompileTime)> struct conservative_resize_like_impl; template struct matrix_swap_impl; @@ -84,14 +97,12 @@ class PlainObjectBase : public internal::dense_xpr_base::type template struct StridedConstMapType { typedef Eigen::Map type; }; template struct StridedAlignedMapType { typedef Eigen::Map type; }; template struct StridedConstAlignedMapType { typedef Eigen::Map type; }; - protected: DenseStorage m_storage; public: - enum { NeedsToAlign = (!(Options&DontAlign)) - && SizeAtCompileTime!=Dynamic && ((static_cast(sizeof(Scalar))*SizeAtCompileTime)%16)==0 }; + enum { NeedsToAlign = SizeAtCompileTime != Dynamic && (internal::traits::Flags & AlignedBit) != 0 }; EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign) Base& base() { return *static_cast(this); } @@ -200,11 +211,13 @@ class PlainObjectBase : public internal::dense_xpr_base::type EIGEN_STRONG_INLINE void resize(Index rows, Index cols) { #ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO + internal::check_rows_cols_for_overflow(rows, cols); Index size = rows*cols; bool size_changed = size != this->size(); m_storage.resize(size, rows, cols); if(size_changed) EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED #else + internal::check_rows_cols_for_overflow(rows, cols); m_storage.resize(rows*cols, rows, cols); #endif } @@ -273,6 +286,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type EIGEN_STRONG_INLINE void resizeLike(const EigenBase& _other) { const OtherDerived& other = _other.derived(); + internal::check_rows_cols_for_overflow(other.rows(), other.cols()); const Index othersize = other.rows()*other.cols(); if(RowsAtCompileTime == 1) { @@ -417,6 +431,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type : m_storage(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) { _check_template_params(); + internal::check_rows_cols_for_overflow(other.derived().rows(), other.derived().cols()); Base::operator=(other.derived()); } @@ -581,6 +596,7 @@ class PlainObjectBase : public internal::dense_xpr_base::type { eigen_assert(rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)); + internal::check_rows_cols_for_overflow(rows, cols); m_storage.resize(rows*cols,rows,cols); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED } @@ -638,6 +654,7 @@ struct internal::conservative_resize_like_impl if ( ( Derived::IsRowMajor && _this.cols() == cols) || // row-major and we change only the number of rows (!Derived::IsRowMajor && _this.rows() == rows) ) // column-major and we change only the number of columns { + internal::check_rows_cols_for_overflow(rows, cols); _this.derived().m_storage.conservativeResize(rows*cols,rows,cols); } else diff --git a/extern/Eigen3/Eigen/src/Core/ProductBase.h b/extern/Eigen3/Eigen/src/Core/ProductBase.h index 3bd3487d6a2..91975880fdc 100644 --- a/extern/Eigen3/Eigen/src/Core/ProductBase.h +++ b/extern/Eigen3/Eigen/src/Core/ProductBase.h @@ -152,7 +152,8 @@ class ProductBase : public MatrixBase #else EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1); - return derived().coeff(row,col); + Matrix result = *this; + return result.coeff(row,col); #endif } @@ -160,7 +161,8 @@ class ProductBase : public MatrixBase { EIGEN_STATIC_ASSERT_SIZE_1x1(Derived) eigen_assert(this->rows() == 1 && this->cols() == 1); - return derived().coeff(i); + Matrix result = *this; + return result.coeff(i); } const Scalar& coeffRef(Index row, Index col) const @@ -256,16 +258,16 @@ class ScaledProduct : Base(prod.lhs(),prod.rhs()), m_prod(prod), m_alpha(x) {} template - inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst,m_alpha); } + inline void evalTo(Dest& dst) const { dst.setZero(); scaleAndAddTo(dst, Scalar(1)); } template - inline void addTo(Dest& dst) const { scaleAndAddTo(dst,m_alpha); } + inline void addTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(1)); } template - inline void subTo(Dest& dst) const { scaleAndAddTo(dst,-m_alpha); } + inline void subTo(Dest& dst) const { scaleAndAddTo(dst, Scalar(-1)); } template - inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { m_prod.derived().scaleAndAddTo(dst,alpha); } + inline void scaleAndAddTo(Dest& dst,Scalar alpha) const { m_prod.derived().scaleAndAddTo(dst,alpha * m_alpha); } const Scalar& alpha() const { return m_alpha; } diff --git a/extern/Eigen3/Eigen/src/Core/Replicate.h b/extern/Eigen3/Eigen/src/Core/Replicate.h index d2f9712db0f..4c171f8d580 100644 --- a/extern/Eigen3/Eigen/src/Core/Replicate.h +++ b/extern/Eigen3/Eigen/src/Core/Replicate.h @@ -48,7 +48,10 @@ struct traits > typedef typename MatrixType::Scalar Scalar; typedef typename traits::StorageKind StorageKind; typedef typename traits::XprKind XprKind; - typedef typename nested::type MatrixTypeNested; + enum { + Factor = (RowFactor==Dynamic || ColFactor==Dynamic) ? Dynamic : RowFactor*ColFactor + }; + typedef typename nested::type MatrixTypeNested; typedef typename remove_reference::type _MatrixTypeNested; enum { RowsAtCompileTime = RowFactor==Dynamic || int(MatrixType::RowsAtCompileTime)==Dynamic @@ -72,6 +75,8 @@ struct traits > template class Replicate : public internal::dense_xpr_base< Replicate >::type { + typedef typename internal::traits::MatrixTypeNested MatrixTypeNested; + typedef typename internal::traits::_MatrixTypeNested _MatrixTypeNested; public: typedef typename internal::dense_xpr_base::type Base; @@ -124,7 +129,7 @@ template class Replicate protected: - const typename MatrixType::Nested m_matrix; + const MatrixTypeNested m_matrix; const internal::variable_if_dynamic m_rowFactor; const internal::variable_if_dynamic m_colFactor; }; diff --git a/extern/Eigen3/Eigen/src/Core/SolveTriangular.h b/extern/Eigen3/Eigen/src/Core/SolveTriangular.h index 71e129c7f12..a23014a343f 100644 --- a/extern/Eigen3/Eigen/src/Core/SolveTriangular.h +++ b/extern/Eigen3/Eigen/src/Core/SolveTriangular.h @@ -180,7 +180,7 @@ void TriangularView::solveInPlace(const MatrixBase::Flags & RowMajorBit && OtherDerived::IsVectorAtCompileTime }; typedef typename internal::conditional(X) +#if defined(__llvm__) && !defined(__clang__) + //Special treatment for Apple's llvm-gcc, its NEON packet types are unions + #define EIGEN_INIT_NEON_PACKET2(X, Y) {{X, Y}} + #define EIGEN_INIT_NEON_PACKET4(X, Y, Z, W) {{X, Y, Z, W}} +#else + //Default initializer for packets + #define EIGEN_INIT_NEON_PACKET2(X, Y) {X, Y} + #define EIGEN_INIT_NEON_PACKET4(X, Y, Z, W) {X, Y, Z, W} +#endif + #ifndef __pld #define __pld(x) asm volatile ( " pld [%[addr]]\n" :: [addr] "r" (x) : "cc" ); #endif @@ -84,7 +94,7 @@ template<> struct packet_traits : default_packet_traits }; }; -#if EIGEN_GNUC_AT_MOST(4,4) +#if EIGEN_GNUC_AT_MOST(4,4) && !defined(__llvm__) // workaround gcc 4.2, 4.3 and 4.4 compilatin issue EIGEN_STRONG_INLINE float32x4_t vld1q_f32(const float* x) { return ::vld1q_f32((const float32_t*)x); } EIGEN_STRONG_INLINE float32x2_t vld1_f32 (const float* x) { return ::vld1_f32 ((const float32_t*)x); } @@ -100,12 +110,12 @@ template<> EIGEN_STRONG_INLINE Packet4i pset1(const int& from) { template<> EIGEN_STRONG_INLINE Packet4f plset(const float& a) { - Packet4f countdown = { 0, 1, 2, 3 }; + Packet4f countdown = EIGEN_INIT_NEON_PACKET4(0, 1, 2, 3); return vaddq_f32(pset1(a), countdown); } template<> EIGEN_STRONG_INLINE Packet4i plset(const int& a) { - Packet4i countdown = { 0, 1, 2, 3 }; + Packet4i countdown = EIGEN_INIT_NEON_PACKET4(0, 1, 2, 3); return vaddq_s32(pset1(a), countdown); } @@ -395,25 +405,29 @@ template<> EIGEN_STRONG_INLINE int predux_max(const Packet4i& a) return s[0]; } -template -struct palign_impl -{ - EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second) - { - if (Offset!=0) - first = vextq_f32(first, second, Offset); - } -}; +// this PALIGN_NEON business is to work around a bug in LLVM Clang 3.0 causing incorrect compilation errors, +// see bug 347 and this LLVM bug: http://llvm.org/bugs/show_bug.cgi?id=11074 +#define PALIGN_NEON(Offset,Type,Command) \ +template<>\ +struct palign_impl\ +{\ + EIGEN_STRONG_INLINE static void run(Type& first, const Type& second)\ + {\ + if (Offset!=0)\ + first = Command(first, second, Offset);\ + }\ +};\ -template -struct palign_impl -{ - EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second) - { - if (Offset!=0) - first = vextq_s32(first, second, Offset); - } -}; +PALIGN_NEON(0,Packet4f,vextq_f32) +PALIGN_NEON(1,Packet4f,vextq_f32) +PALIGN_NEON(2,Packet4f,vextq_f32) +PALIGN_NEON(3,Packet4f,vextq_f32) +PALIGN_NEON(0,Packet4i,vextq_s32) +PALIGN_NEON(1,Packet4i,vextq_s32) +PALIGN_NEON(2,Packet4i,vextq_s32) +PALIGN_NEON(3,Packet4i,vextq_s32) + +#undef PALIGN_NEON } // end namespace internal diff --git a/extern/Eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/extern/Eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 6f3f2717007..cd1c37c780e 100644 --- a/extern/Eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/extern/Eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -30,19 +30,16 @@ namespace internal { template class gebp_traits; +inline std::ptrdiff_t manage_caching_sizes_second_if_negative(std::ptrdiff_t a, std::ptrdiff_t b) +{ + return a<=0 ? b : a; +} + /** \internal */ inline void manage_caching_sizes(Action action, std::ptrdiff_t* l1=0, std::ptrdiff_t* l2=0) { - static std::ptrdiff_t m_l1CacheSize = 0; - static std::ptrdiff_t m_l2CacheSize = 0; - if(m_l1CacheSize==0) - { - m_l1CacheSize = queryL1CacheSize(); - m_l2CacheSize = queryTopLevelCacheSize(); - - if(m_l1CacheSize<=0) m_l1CacheSize = 8 * 1024; - if(m_l2CacheSize<=0) m_l2CacheSize = 1 * 1024 * 1024; - } + static std::ptrdiff_t m_l1CacheSize = manage_caching_sizes_second_if_negative(queryL1CacheSize(),8 * 1024); + static std::ptrdiff_t m_l2CacheSize = manage_caching_sizes_second_if_negative(queryTopLevelCacheSize(),1*1024*1024); if(action==SetAction) { @@ -118,14 +115,14 @@ inline void computeProductBlockingSizes(std::ptrdiff_t& k, std::ptrdiff_t& m, st // FIXME (a bit overkill maybe ?) template struct gebp_madd_selector { - EIGEN_STRONG_INLINE EIGEN_ALWAYS_INLINE_ATTRIB static void run(const CJ& cj, A& a, B& b, C& c, T& /*t*/) + EIGEN_ALWAYS_INLINE static void run(const CJ& cj, A& a, B& b, C& c, T& /*t*/) { c = cj.pmadd(a,b,c); } }; template struct gebp_madd_selector { - EIGEN_STRONG_INLINE EIGEN_ALWAYS_INLINE_ATTRIB static void run(const CJ& cj, T& a, T& b, T& c, T& t) + EIGEN_ALWAYS_INLINE static void run(const CJ& cj, T& a, T& b, T& c, T& t) { t = b; t = cj.pmul(a,t); c = padd(c,t); } diff --git a/extern/Eigen3/Eigen/src/Core/util/Macros.h b/extern/Eigen3/Eigen/src/Core/util/Macros.h index 6c3f1e421f0..b7c2b79af92 100644 --- a/extern/Eigen3/Eigen/src/Core/util/Macros.h +++ b/extern/Eigen3/Eigen/src/Core/util/Macros.h @@ -1,3 +1,4 @@ + // This file is part of Eigen, a lightweight C++ template library // for linear algebra. // @@ -28,7 +29,7 @@ #define EIGEN_WORLD_VERSION 3 #define EIGEN_MAJOR_VERSION 0 -#define EIGEN_MINOR_VERSION 2 +#define EIGEN_MINOR_VERSION 5 #define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \ (EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \ @@ -45,7 +46,7 @@ #define EIGEN_GNUC_AT_MOST(x,y) 0 #endif -#if EIGEN_GNUC_AT_MOST(4,3) +#if EIGEN_GNUC_AT_MOST(4,3) && !defined(__clang__) // see bug 89 #define EIGEN_SAFE_TO_USE_STANDARD_ASSERT_MACRO 0 #else @@ -130,31 +131,34 @@ #define EIGEN_MAKESTRING2(a) #a #define EIGEN_MAKESTRING(a) EIGEN_MAKESTRING2(a) -// EIGEN_ALWAYS_INLINE_ATTRIB should be use in the declaration of function -// which should be inlined even in debug mode. -// FIXME with the always_inline attribute, -// gcc 3.4.x reports the following compilation error: -// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval Eigen::MatrixBase::eval() const' -// : function body not available -#if EIGEN_GNUC_AT_LEAST(4,0) -#define EIGEN_ALWAYS_INLINE_ATTRIB __attribute__((always_inline)) -#else -#define EIGEN_ALWAYS_INLINE_ATTRIB -#endif - #if EIGEN_GNUC_AT_LEAST(4,1) && !defined(__clang__) && !defined(__INTEL_COMPILER) #define EIGEN_FLATTEN_ATTRIB __attribute__((flatten)) #else #define EIGEN_FLATTEN_ATTRIB #endif -// EIGEN_FORCE_INLINE means "inline as much as possible" +// EIGEN_STRONG_INLINE is a stronger version of the inline, using __forceinline on MSVC, +// but it still doesn't use GCC's always_inline. This is useful in (common) situations where MSVC needs forceinline +// but GCC is still doing fine with just inline. #if (defined _MSC_VER) || (defined __INTEL_COMPILER) #define EIGEN_STRONG_INLINE __forceinline #else #define EIGEN_STRONG_INLINE inline #endif +// EIGEN_ALWAYS_INLINE is the stronget, it has the effect of making the function inline and adding every possible +// attribute to maximize inlining. This should only be used when really necessary: in particular, +// it uses __attribute__((always_inline)) on GCC, which most of the time is useless and can severely harm compile times. +// FIXME with the always_inline attribute, +// gcc 3.4.x reports the following compilation error: +// Eval.h:91: sorry, unimplemented: inlining failed in call to 'const Eigen::Eval Eigen::MatrixBase::eval() const' +// : function body not available +#if EIGEN_GNUC_AT_LEAST(4,0) +#define EIGEN_ALWAYS_INLINE __attribute__((always_inline)) inline +#else +#define EIGEN_ALWAYS_INLINE EIGEN_STRONG_INLINE +#endif + #if (defined __GNUC__) #define EIGEN_DONT_INLINE __attribute__((noinline)) #elif (defined _MSC_VER) @@ -249,7 +253,7 @@ #define EIGEN_UNUSED_VARIABLE(var) (void)var; #if (defined __GNUC__) -#define EIGEN_ASM_COMMENT(X) asm("#"X) +#define EIGEN_ASM_COMMENT(X) asm("#" X) #else #define EIGEN_ASM_COMMENT(X) #endif diff --git a/extern/Eigen3/Eigen/src/Core/util/Memory.h b/extern/Eigen3/Eigen/src/Core/util/Memory.h index a580b95ad0d..023716dc9e0 100644 --- a/extern/Eigen3/Eigen/src/Core/util/Memory.h +++ b/extern/Eigen3/Eigen/src/Core/util/Memory.h @@ -82,6 +82,16 @@ namespace internal { +inline void throw_std_bad_alloc() +{ + #ifdef EIGEN_EXCEPTIONS + throw std::bad_alloc(); + #else + std::size_t huge = -1; + new int[huge]; + #endif +} + /***************************************************************************** *** Implementation of handmade aligned functions *** *****************************************************************************/ @@ -192,7 +202,7 @@ inline void check_that_malloc_is_allowed() #endif /** \internal Allocates \a size bytes. The returned pointer is guaranteed to have 16 bytes alignment. - * On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown. + * On allocation error, the returned pointer is null, and std::bad_alloc is thrown. */ inline void* aligned_malloc(size_t size) { @@ -213,10 +223,9 @@ inline void* aligned_malloc(size_t size) result = handmade_aligned_malloc(size); #endif - #ifdef EIGEN_EXCEPTIONS - if(result == 0) - throw std::bad_alloc(); - #endif + if(!result && size) + throw_std_bad_alloc(); + return result; } @@ -241,7 +250,7 @@ inline void aligned_free(void *ptr) /** * \internal * \brief Reallocates an aligned block of memory. -* \throws std::bad_alloc if EIGEN_EXCEPTIONS are defined. +* \throws std::bad_alloc on allocation failure **/ inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) { @@ -269,10 +278,9 @@ inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) result = handmade_aligned_realloc(ptr,new_size,old_size); #endif -#ifdef EIGEN_EXCEPTIONS - if (result==0 && new_size!=0) - throw std::bad_alloc(); -#endif + if (!result && new_size) + throw_std_bad_alloc(); + return result; } @@ -281,7 +289,7 @@ inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size) *****************************************************************************/ /** \internal Allocates \a size bytes. If Align is true, then the returned ptr is 16-byte-aligned. - * On allocation error, the returned pointer is null, and if exceptions are enabled then a std::bad_alloc is thrown. + * On allocation error, the returned pointer is null, and a std::bad_alloc is thrown. */ template inline void* conditional_aligned_malloc(size_t size) { @@ -293,9 +301,8 @@ template<> inline void* conditional_aligned_malloc(size_t size) check_that_malloc_is_allowed(); void *result = std::malloc(size); - #ifdef EIGEN_EXCEPTIONS - if(!result) throw std::bad_alloc(); - #endif + if(!result && size) + throw_std_bad_alloc(); return result; } @@ -347,18 +354,27 @@ template inline void destruct_elements_of_array(T *ptr, size_t size) *** Implementation of aligned new/delete-like functions *** *****************************************************************************/ +template +EIGEN_ALWAYS_INLINE void check_size_for_overflow(size_t size) +{ + if(size > size_t(-1) / sizeof(T)) + throw_std_bad_alloc(); +} + /** \internal Allocates \a size objects of type T. The returned pointer is guaranteed to have 16 bytes alignment. - * On allocation error, the returned pointer is undefined, but if exceptions are enabled then a std::bad_alloc is thrown. + * On allocation error, the returned pointer is undefined, but a std::bad_alloc is thrown. * The default constructor of T is called. */ template inline T* aligned_new(size_t size) { + check_size_for_overflow(size); T *result = reinterpret_cast(aligned_malloc(sizeof(T)*size)); return construct_elements_of_array(result, size); } template inline T* conditional_aligned_new(size_t size) { + check_size_for_overflow(size); T *result = reinterpret_cast(conditional_aligned_malloc(sizeof(T)*size)); return construct_elements_of_array(result, size); } @@ -383,6 +399,8 @@ template inline void conditional_aligned_delete(T *ptr, template inline T* conditional_aligned_realloc_new(T* pts, size_t new_size, size_t old_size) { + check_size_for_overflow(new_size); + check_size_for_overflow(old_size); if(new_size < old_size) destruct_elements_of_array(pts+new_size, old_size-new_size); T *result = reinterpret_cast(conditional_aligned_realloc(reinterpret_cast(pts), sizeof(T)*new_size, sizeof(T)*old_size)); @@ -394,6 +412,7 @@ template inline T* conditional_aligned_realloc_new(T* pt template inline T* conditional_aligned_new_auto(size_t size) { + check_size_for_overflow(size); T *result = reinterpret_cast(conditional_aligned_malloc(sizeof(T)*size)); if(NumTraits::RequireInitialization) construct_elements_of_array(result, size); @@ -402,6 +421,8 @@ template inline T* conditional_aligned_new_auto(size_t s template inline T* conditional_aligned_realloc_new_auto(T* pts, size_t new_size, size_t old_size) { + check_size_for_overflow(new_size); + check_size_for_overflow(old_size); if(NumTraits::RequireInitialization && (new_size < old_size)) destruct_elements_of_array(pts+new_size, old_size-new_size); T *result = reinterpret_cast(conditional_aligned_realloc(reinterpret_cast(pts), sizeof(T)*new_size, sizeof(T)*old_size)); @@ -536,6 +557,7 @@ template class aligned_stack_memory_handler #endif #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \ + Eigen::internal::check_size_for_overflow(SIZE); \ TYPE* NAME = (BUFFER)!=0 ? (BUFFER) \ : reinterpret_cast( \ (sizeof(TYPE)*SIZE<=EIGEN_STACK_ALLOCATION_LIMIT) ? EIGEN_ALIGNED_ALLOCA(sizeof(TYPE)*SIZE) \ @@ -545,6 +567,7 @@ template class aligned_stack_memory_handler #else #define ei_declare_aligned_stack_constructed_variable(TYPE,NAME,SIZE,BUFFER) \ + Eigen::internal::check_size_for_overflow(SIZE); \ TYPE* NAME = (BUFFER)!=0 ? BUFFER : reinterpret_cast(Eigen::internal::aligned_malloc(sizeof(TYPE)*SIZE)); \ Eigen::internal::aligned_stack_memory_handler EIGEN_CAT(NAME,_stack_memory_destructor)((BUFFER)==0 ? NAME : 0,SIZE,true) @@ -669,6 +692,7 @@ public: pointer allocate( size_type num, const void* hint = 0 ) { EIGEN_UNUSED_VARIABLE(hint); + internal::check_size_for_overflow(num); return static_cast( internal::aligned_malloc( num * sizeof(T) ) ); } diff --git a/extern/Eigen3/Eigen/src/Core/util/XprHelper.h b/extern/Eigen3/Eigen/src/Core/util/XprHelper.h index 9047c5f8350..c2078f13786 100644 --- a/extern/Eigen3/Eigen/src/Core/util/XprHelper.h +++ b/extern/Eigen3/Eigen/src/Core/util/XprHelper.h @@ -125,10 +125,9 @@ class compute_matrix_flags aligned_bit = ( ((Options&DontAlign)==0) - && packet_traits::Vectorizable && ( #if EIGEN_ALIGN_STATICALLY - ((!is_dynamic_size_storage) && (((MaxCols*MaxRows) % packet_traits::size) == 0)) + ((!is_dynamic_size_storage) && (((MaxCols*MaxRows*int(sizeof(Scalar))) % 16) == 0)) #else 0 #endif diff --git a/extern/Eigen3/Eigen/src/Eigenvalues/EigenSolver.h b/extern/Eigen3/Eigen/src/Eigenvalues/EigenSolver.h index ac4c4242dd4..f57353c065f 100644 --- a/extern/Eigen3/Eigen/src/Eigenvalues/EigenSolver.h +++ b/extern/Eigen3/Eigen/src/Eigenvalues/EigenSolver.h @@ -291,7 +291,7 @@ template class EigenSolver ComputationInfo info() const { - eigen_assert(m_isInitialized && "ComplexEigenSolver is not initialized."); + eigen_assert(m_isInitialized && "EigenSolver is not initialized."); return m_realSchur.info(); } @@ -339,7 +339,7 @@ typename EigenSolver::EigenvectorsType EigenSolver::eige EigenvectorsType matV(n,n); for (Index j=0; j(); @@ -570,10 +570,13 @@ void EigenSolver::doComputeEigenvectors() } } + + // We handled a pair of complex conjugate eigenvalues, so need to skip them both + n--; } else { - eigen_assert("Internal bug in EigenSolver"); // this should not happen + eigen_assert(0 && "Internal bug in EigenSolver"); // this should not happen } } diff --git a/extern/Eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/extern/Eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h index 965dda88bda..ad107c63282 100644 --- a/extern/Eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h +++ b/extern/Eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h @@ -307,7 +307,8 @@ template class SelfAdjointEigenSolver /** \brief Maximum number of iterations. * - * Maximum number of iterations allowed for an eigenvalue to converge. + * The algorithm terminates if it does not converge within m_maxIterations * n iterations, where n + * denotes the size of the matrix. This value is currently set to 30 (copied from LAPACK). */ static const int m_maxIterations = 30; @@ -407,7 +408,7 @@ SelfAdjointEigenSolver& SelfAdjointEigenSolver Index end = n-1; Index start = 0; - Index iter = 0; // number of iterations we are working on one element + Index iter = 0; // total number of iterations while (end>0) { @@ -418,15 +419,14 @@ SelfAdjointEigenSolver& SelfAdjointEigenSolver // find the largest unreduced block while (end>0 && m_subdiag[end-1]==0) { - iter = 0; end--; } if (end<=0) break; - // if we spent too many iterations on the current element, we give up + // if we spent too many iterations, we give up iter++; - if(iter > m_maxIterations) break; + if(iter > m_maxIterations * n) break; start = end - 1; while (start>0 && m_subdiag[start-1]!=0) @@ -435,7 +435,7 @@ SelfAdjointEigenSolver& SelfAdjointEigenSolver internal::tridiagonal_qr_step(diag.data(), m_subdiag.data(), start, end, computeEigenvectors ? m_eivec.data() : (Scalar*)0, n); } - if (iter <= m_maxIterations) + if (iter <= m_maxIterations * n) m_info = Success; else m_info = NoConvergence; diff --git a/extern/Eigen3/Eigen/src/Geometry/Hyperplane.h b/extern/Eigen3/Eigen/src/Geometry/Hyperplane.h index eb0a5877168..d85d3e553f8 100644 --- a/extern/Eigen3/Eigen/src/Geometry/Hyperplane.h +++ b/extern/Eigen3/Eigen/src/Geometry/Hyperplane.h @@ -225,7 +225,7 @@ public: normal() = mat * normal(); else { - eigen_assert("invalid traits value in Hyperplane::transform()"); + eigen_assert(0 && "invalid traits value in Hyperplane::transform()"); } return *this; } diff --git a/extern/Eigen3/Eigen/src/Geometry/Quaternion.h b/extern/Eigen3/Eigen/src/Geometry/Quaternion.h index 2662d60fed1..9180db67d84 100644 --- a/extern/Eigen3/Eigen/src/Geometry/Quaternion.h +++ b/extern/Eigen3/Eigen/src/Geometry/Quaternion.h @@ -182,10 +182,9 @@ public: template inline typename internal::cast_return_type >::type cast() const { - return typename internal::cast_return_type >::type( - coeffs().template cast()); + return typename internal::cast_return_type >::type(derived()); } - + #ifdef EIGEN_QUATERNIONBASE_PLUGIN # include EIGEN_QUATERNIONBASE_PLUGIN #endif @@ -225,22 +224,25 @@ struct traits > typedef _Scalar Scalar; typedef Matrix<_Scalar,4,1,_Options> Coefficients; enum{ - IsAligned = bool(EIGEN_ALIGN) && ((int(_Options)&Aligned)==Aligned), + IsAligned = internal::traits::Flags & AlignedBit, Flags = IsAligned ? (AlignedBit | LvalueBit) : LvalueBit }; }; } template -class Quaternion : public QuaternionBase >{ +class Quaternion : public QuaternionBase > +{ typedef QuaternionBase > Base; + enum { IsAligned = internal::traits::IsAligned }; + public: typedef _Scalar Scalar; EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion) using Base::operator*=; - typedef typename internal::traits >::Coefficients Coefficients; + typedef typename internal::traits::Coefficients Coefficients; typedef typename Base::AngleAxisType AngleAxisType; /** Default constructor leaving the quaternion uninitialized. */ @@ -271,9 +273,16 @@ public: template explicit inline Quaternion(const MatrixBase& other) { *this = other; } + /** Explicit copy constructor with scalar conversion */ + template + explicit inline Quaternion(const Quaternion& other) + { m_coeffs = other.coeffs().template cast(); } + inline Coefficients& coeffs() { return m_coeffs;} inline const Coefficients& coeffs() const { return m_coeffs;} + EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(IsAligned) + protected: Coefficients m_coeffs; @@ -673,7 +682,7 @@ QuaternionBase::slerp(Scalar t, const QuaternionBase& oth Scalar scale0; Scalar scale1; - if (absD>=one) + if(absD>=one) { scale0 = Scalar(1) - t; scale1 = t; @@ -686,9 +695,8 @@ QuaternionBase::slerp(Scalar t, const QuaternionBase& oth scale0 = internal::sin( ( Scalar(1) - t ) * theta) / sinTheta; scale1 = internal::sin( ( t * theta) ) / sinTheta; - if (d<0) - scale1 = -scale1; } + if(d<0) scale1 = -scale1; return Quaternion(scale0 * coeffs() + scale1 * other.coeffs()); } diff --git a/extern/Eigen3/Eigen/src/Geometry/Rotation2D.h b/extern/Eigen3/Eigen/src/Geometry/Rotation2D.h index e1214bd3ebb..cf36da1c50c 100644 --- a/extern/Eigen3/Eigen/src/Geometry/Rotation2D.h +++ b/extern/Eigen3/Eigen/src/Geometry/Rotation2D.h @@ -89,7 +89,7 @@ public: /** Concatenates two rotations */ inline Rotation2D& operator*=(const Rotation2D& other) - { return m_angle += other.m_angle; return *this; } + { m_angle += other.m_angle; return *this; } /** Applies the rotation to a 2D vector */ Vector2 operator* (const Vector2& vec) const diff --git a/extern/Eigen3/Eigen/src/Geometry/Transform.h b/extern/Eigen3/Eigen/src/Geometry/Transform.h index 19d012572d4..a694673ebed 100644 --- a/extern/Eigen3/Eigen/src/Geometry/Transform.h +++ b/extern/Eigen3/Eigen/src/Geometry/Transform.h @@ -61,7 +61,7 @@ template< typename Lhs, typename Rhs, bool AnyProjective = transform_traits::IsProjective || - transform_traits::IsProjective> + transform_traits::IsProjective> struct transform_transform_product_impl; template< typename Other, @@ -1391,6 +1391,35 @@ struct transform_transform_product_impl } }; +template +struct transform_transform_product_impl,Transform,true > +{ + typedef Transform Lhs; + typedef Transform Rhs; + typedef Transform ResultType; + static ResultType run(const Lhs& lhs, const Rhs& rhs) + { + ResultType res; + res.matrix().template topRows() = lhs.matrix() * rhs.matrix(); + res.matrix().row(Dim) = rhs.matrix().row(Dim); + return res; + } +}; + +template +struct transform_transform_product_impl,Transform,true > +{ + typedef Transform Lhs; + typedef Transform Rhs; + typedef Transform ResultType; + static ResultType run(const Lhs& lhs, const Rhs& rhs) + { + ResultType res(lhs.matrix().template leftCols() * rhs.matrix()); + res.matrix().col(Dim) += lhs.matrix().col(Dim); + return res; + } +}; + } // end namespace internal #endif // EIGEN_TRANSFORM_H diff --git a/extern/Eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h b/extern/Eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h index cbe695c7259..2af32678d1c 100644 --- a/extern/Eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h +++ b/extern/Eigen3/Eigen/src/Geometry/arch/Geometry_SSE.h @@ -96,7 +96,7 @@ struct quat_product */ t1 = padd(pmul(a_ww, b_xy), pmul(a_yy, b_zw)); t2 = psub(pmul(a_zz, b_xy), pmul(a_xx, b_zw)); -#ifdef __SSE3__ +#ifdef EIGEN_VECTORIZE_SSE3 EIGEN_UNUSED_VARIABLE(mask) pstore(&res.x(), _mm_addsub_pd(t1, preverse(t2))); #else @@ -110,7 +110,7 @@ struct quat_product */ t1 = psub(pmul(a_ww, b_zw), pmul(a_yy, b_xy)); t2 = padd(pmul(a_zz, b_zw), pmul(a_xx, b_xy)); -#ifdef __SSE3__ +#ifdef EIGEN_VECTORIZE_SSE3 EIGEN_UNUSED_VARIABLE(mask) pstore(&res.z(), preverse(_mm_addsub_pd(preverse(t1), t2))); #else diff --git a/extern/Eigen3/Eigen/src/LU/FullPivLU.h b/extern/Eigen3/Eigen/src/LU/FullPivLU.h index 633fb23fdbe..46ae7d651c8 100644 --- a/extern/Eigen3/Eigen/src/LU/FullPivLU.h +++ b/extern/Eigen3/Eigen/src/LU/FullPivLU.h @@ -443,7 +443,6 @@ FullPivLU& FullPivLU::compute(const MatrixType& matrix) m_nonzero_pivots = size; // the generic case is that in which all pivots are nonzero (invertible case) m_maxpivot = RealScalar(0); - RealScalar cutoff(0); for(Index k = 0; k < size; ++k) { @@ -458,14 +457,7 @@ FullPivLU& FullPivLU::compute(const MatrixType& matrix) row_of_biggest_in_corner += k; // correct the values! since they were computed in the corner, col_of_biggest_in_corner += k; // need to add k to them. - // when k==0, biggest_in_corner is the biggest coeff absolute value in the original matrix - if(k == 0) cutoff = biggest_in_corner * NumTraits::epsilon(); - - // if the pivot (hence the corner) is "zero", terminate to avoid generating nan/inf values. - // Notice that using an exact comparison (biggest_in_corner==0) here, as Golub-van Loan do in - // their pseudo-code, results in numerical instability! The cutoff here has been validated - // by running the unit test 'lu' with many repetitions. - if(biggest_in_corner < cutoff) + if(biggest_in_corner==RealScalar(0)) { // before exiting, make sure to initialize the still uninitialized transpositions // in a sane state without destroying what we already have. diff --git a/extern/Eigen3/Eigen/src/LU/arch/Inverse_SSE.h b/extern/Eigen3/Eigen/src/LU/arch/Inverse_SSE.h index 176c349ce44..4c6153f0aff 100644 --- a/extern/Eigen3/Eigen/src/LU/arch/Inverse_SSE.h +++ b/extern/Eigen3/Eigen/src/LU/arch/Inverse_SSE.h @@ -55,7 +55,7 @@ struct compute_inverse_size4 static void run(const MatrixType& matrix, ResultType& result) { - EIGEN_ALIGN16 const int _Sign_PNNP[4] = { 0x00000000, 0x80000000, 0x80000000, 0x00000000 }; + EIGEN_ALIGN16 const unsigned int _Sign_PNNP[4] = { 0x00000000, 0x80000000, 0x80000000, 0x00000000 }; // Load the full matrix into registers __m128 _L1 = matrix.template packet( 0); diff --git a/extern/Eigen3/Eigen/src/SVD/JacobiSVD.h b/extern/Eigen3/Eigen/src/SVD/JacobiSVD.h index 5f61399988c..3c423095c31 100644 --- a/extern/Eigen3/Eigen/src/SVD/JacobiSVD.h +++ b/extern/Eigen3/Eigen/src/SVD/JacobiSVD.h @@ -590,6 +590,9 @@ JacobiSVD::compute(const MatrixType& matrix, unsig // only worsening the precision of U and V as we accumulate more rotations const RealScalar precision = RealScalar(2) * NumTraits::epsilon(); + // limit for very small denormal numbers to be considered zero in order to avoid infinite loops (see bug 286) + const RealScalar considerAsZero = RealScalar(2) * std::numeric_limits::denorm_min(); + /*** step 1. The R-SVD step: we use a QR decomposition to reduce to the case of a square matrix */ if(!internal::qr_preconditioner_impl::run(*this, matrix) @@ -617,10 +620,11 @@ JacobiSVD::compute(const MatrixType& matrix, unsig { // if this 2x2 sub-matrix is not diagonal already... // notice that this comparison will evaluate to false if any NaN is involved, ensuring that NaN's don't - // keep us iterating forever. + // keep us iterating forever. Similarly, small denormal numbers are considered zero. using std::max; - if((max)(internal::abs(m_workMatrix.coeff(p,q)),internal::abs(m_workMatrix.coeff(q,p))) - > (max)(internal::abs(m_workMatrix.coeff(p,p)),internal::abs(m_workMatrix.coeff(q,q)))*precision) + RealScalar threshold = (max)(considerAsZero, precision * (max)(internal::abs(m_workMatrix.coeff(p,p)), + internal::abs(m_workMatrix.coeff(q,q)))); + if((max)(internal::abs(m_workMatrix.coeff(p,q)),internal::abs(m_workMatrix.coeff(q,p))) > threshold) { finished = false; @@ -704,6 +708,13 @@ struct solve_retval, Rhs> }; } // end namespace internal +/** \svd_module + * + * \return the singular value decomposition of \c *this computed by two-sided + * Jacobi transformations. + * + * \sa class JacobiSVD + */ template JacobiSVD::PlainObject> MatrixBase::jacobiSvd(unsigned int computationOptions) const diff --git a/extern/Eigen3/Eigen/src/Sparse/TriangularSolver.h b/extern/Eigen3/Eigen/src/Sparse/TriangularSolver.h index 73468e0446c..62bb8bb44c9 100644 --- a/extern/Eigen3/Eigen/src/Sparse/TriangularSolver.h +++ b/extern/Eigen3/Eigen/src/Sparse/TriangularSolver.h @@ -171,7 +171,7 @@ void SparseTriangularView::solveInPlace(MatrixBase::Flags & RowMajorBit }; @@ -298,7 +298,7 @@ void SparseTriangularView::solveInPlace(SparseMatrixBase::Flags & RowMajorBit }; diff --git a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h index 4fdac113378..ab745ca5ad6 100644 --- a/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h +++ b/extern/bullet2/src/BulletDynamics/ConstraintSolver/btGeneric6DofConstraint.h @@ -354,7 +354,7 @@ public: //! Calcs global transform of the offsets /*! - Calcs the global transform for the joint offset for body A an B, and also calcs the agle differences between the bodies. + Calcs the global transform for the joint offset for body A an B, and also calcs the angle differences between the bodies. \sa btGeneric6DofConstraint.getCalculatedTransformA , btGeneric6DofConstraint.getCalculatedTransformB, btGeneric6DofConstraint.calculateAngleInfo */ void calculateTransforms(const btTransform& transA,const btTransform& transB); diff --git a/extern/carve/CMakeLists.txt b/extern/carve/CMakeLists.txt index 660538998a1..3916047ff32 100644 --- a/extern/carve/CMakeLists.txt +++ b/extern/carve/CMakeLists.txt @@ -35,115 +35,115 @@ set(INC_SYS ) set(SRC - lib/intersection.cpp - lib/intersect.cpp - lib/triangulator.cpp + lib/aabb.cpp + lib/carve.cpp lib/convex_hull.cpp + lib/csg_collector.cpp + lib/csg.cpp + lib/edge.cpp + lib/face.cpp + lib/geom2d.cpp + lib/geom3d.cpp + lib/intersect_classify_edge.cpp + lib/intersect_classify_group.cpp + lib/intersect.cpp + lib/intersect_debug.cpp + lib/intersect_face_division.cpp + lib/intersect_group.cpp + lib/intersect_half_classify_group.cpp + lib/intersection.cpp + lib/math.cpp + lib/mesh.cpp + lib/octree.cpp + lib/pointset.cpp lib/polyhedron.cpp lib/polyline.cpp - lib/pointset.cpp - lib/geom2d.cpp - lib/math.cpp - lib/intersect_half_classify_group.cpp - lib/intersect_face_division.cpp lib/tag.cpp - lib/aabb.cpp - lib/intersect_classify_group.cpp - lib/mesh.cpp lib/timing.cpp - lib/geom3d.cpp - lib/intersect_group.cpp - lib/carve.cpp - lib/intersect_classify_edge.cpp - lib/csg.cpp - lib/face.cpp - lib/csg_collector.cpp - lib/intersect_debug.cpp - lib/edge.cpp - lib/octree.cpp + lib/triangulator.cpp - lib/intersect_debug.hpp lib/csg_collector.hpp lib/csg_data.hpp - lib/intersect_classify_common.hpp - lib/intersect_common.hpp lib/csg_detail.hpp + lib/intersect_classify_common.hpp lib/intersect_classify_common_impl.hpp + lib/intersect_common.hpp + lib/intersect_debug.hpp - include/carve/vertex_impl.hpp - include/carve/aabb_impl.hpp - include/carve/csg.hpp - include/carve/pointset_iter.hpp - include/carve/debug_hooks.hpp - include/carve/mesh.hpp - include/carve/triangulator_impl.hpp - include/carve/edge_decl.hpp - include/carve/collection/unordered.hpp - include/carve/collection/unordered/tr1_impl.hpp - include/carve/collection/unordered/fallback_impl.hpp - include/carve/collection/unordered/std_impl.hpp - include/carve/collection/unordered/vcpp_impl.hpp - include/carve/collection/unordered/libstdcpp_impl.hpp - include/carve/collection/unordered/boost_impl.hpp - include/carve/convex_hull.hpp - include/carve/geom.hpp - include/carve/collection_types.hpp - include/carve/cbrt.h - include/carve/util.hpp - include/carve/iobj.hpp - include/carve/polyline_decl.hpp - include/carve/polyline_impl.hpp - include/carve/win32.h - include/carve/edge_impl.hpp - include/carve/carve.hpp - include/carve/polyline.hpp - include/carve/face_decl.hpp - include/carve/matrix.hpp - include/carve/classification.hpp - include/carve/geom_impl.hpp - include/carve/faceloop.hpp - include/carve/mesh_ops.hpp - include/carve/tree.hpp - include/carve/geom2d.hpp - include/carve/face_impl.hpp - include/carve/polyhedron_decl.hpp - include/carve/interpolator.hpp - include/carve/poly_decl.hpp - include/carve/mesh_impl.hpp - include/carve/gnu_cxx.h - include/carve/mesh_simplify.hpp - include/carve/triangulator.hpp - include/carve/pointset_impl.hpp - include/carve/rtree.hpp - include/carve/math_constants.hpp - include/carve/vector.hpp - include/carve/octree_impl.hpp - include/carve/pointset.hpp - include/carve/math.hpp - include/carve/intersection.hpp - include/carve/colour.hpp - include/carve/kd_node.hpp - include/carve/input.hpp - include/carve/geom3d.hpp - include/carve/exact.hpp - include/carve/rescale.hpp - include/carve/polyhedron_base.hpp - include/carve/heap.hpp - include/carve/spacetree.hpp - include/carve/polyhedron_impl.hpp - include/carve/vcpp_config.h include/carve/aabb.hpp - include/carve/polyline_iter.hpp - include/carve/djset.hpp - include/carve/vertex_decl.hpp - include/carve/csg_triangulator.hpp - include/carve/poly.hpp - include/carve/timing.hpp - include/carve/octree_decl.hpp - include/carve/pointset_decl.hpp - include/carve/tag.hpp + include/carve/aabb_impl.hpp + include/carve/carve.hpp + include/carve/cbrt.h + include/carve/classification.hpp include/carve/collection.hpp + include/carve/collection_types.hpp + include/carve/collection/unordered/boost_impl.hpp + include/carve/collection/unordered/fallback_impl.hpp + include/carve/collection/unordered.hpp + include/carve/collection/unordered/libstdcpp_impl.hpp + include/carve/collection/unordered/std_impl.hpp + include/carve/collection/unordered/tr1_impl.hpp + include/carve/collection/unordered/vcpp_impl.hpp + include/carve/colour.hpp + include/carve/convex_hull.hpp + include/carve/csg.hpp + include/carve/csg_triangulator.hpp + include/carve/debug_hooks.hpp + include/carve/djset.hpp + include/carve/edge_decl.hpp + include/carve/edge_impl.hpp + include/carve/exact.hpp + include/carve/face_decl.hpp + include/carve/face_impl.hpp + include/carve/faceloop.hpp + include/carve/geom2d.hpp + include/carve/geom3d.hpp + include/carve/geom.hpp + include/carve/geom_impl.hpp + include/carve/gnu_cxx.h + include/carve/heap.hpp + include/carve/input.hpp + include/carve/interpolator.hpp + include/carve/intersection.hpp + include/carve/iobj.hpp + include/carve/kd_node.hpp + include/carve/math_constants.hpp + include/carve/math.hpp + include/carve/matrix.hpp + include/carve/mesh.hpp + include/carve/mesh_impl.hpp + include/carve/mesh_ops.hpp + include/carve/mesh_simplify.hpp + include/carve/octree_decl.hpp + include/carve/octree_impl.hpp + include/carve/pointset_decl.hpp + include/carve/pointset.hpp + include/carve/pointset_impl.hpp + include/carve/pointset_iter.hpp + include/carve/poly_decl.hpp + include/carve/polyhedron_base.hpp + include/carve/polyhedron_decl.hpp + include/carve/polyhedron_impl.hpp + include/carve/poly.hpp include/carve/poly_impl.hpp + include/carve/polyline_decl.hpp + include/carve/polyline.hpp + include/carve/polyline_impl.hpp + include/carve/polyline_iter.hpp + include/carve/rescale.hpp + include/carve/rtree.hpp + include/carve/spacetree.hpp + include/carve/tag.hpp + include/carve/timing.hpp + include/carve/tree.hpp + include/carve/triangulator.hpp + include/carve/triangulator_impl.hpp + include/carve/util.hpp + include/carve/vcpp_config.h + include/carve/vector.hpp + include/carve/vertex_decl.hpp + include/carve/vertex_impl.hpp + include/carve/win32.h ) if(WITH_BOOST) diff --git a/extern/carve/bundle.sh b/extern/carve/bundle.sh index 881367fe687..63d32a5993d 100755 --- a/extern/carve/bundle.sh +++ b/extern/carve/bundle.sh @@ -1,7 +1,9 @@ #!/bin/sh -if [ -d ./.svn ]; then - echo "This script is supposed to work only when using git-svn" +if [ "x$1" = "x--i-really-know-what-im-doing" ] ; then + echo Proceeding as requested by command line ... +else + echo "*** Please run again with --i-really-know-what-im-doing ..." exit 1 fi @@ -14,8 +16,8 @@ for p in `cat ./patches/series`; do cat ./patches/$p | patch -d $tmp/carve -p1 done -rm -rf include -rm -rf lib +find include -type f -not -iwholename '*.svn*' -exec rm -rf {} \; +find lib -type f -not -iwholename '*.svn*' -exec rm -rf {} \; cat "files.txt" | while read f; do mkdir -p `dirname $f` @@ -24,9 +26,9 @@ done rm -rf $tmp -sources=`find ./lib -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/'` -headers=`find ./lib -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/'` -includes=`find ./include -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/'` +sources=`find ./lib -type f -iname '*.cc' -or -iname '*.cpp' -or -iname '*.c' | sed -r 's/^\.\//\t/' | sort -d` +headers=`find ./lib -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/' | sort -d` +includes=`find ./include -type f -iname '*.h' -or -iname '*.hpp' | sed -r 's/^\.\//\t/' | sort -d` mkdir -p include/carve/external/boost cp patches/files/random.hpp include/carve/external/boost/random.hpp diff --git a/extern/carve/lib/intersect.cpp b/extern/carve/lib/intersect.cpp index 35166a6411e..2063164de08 100644 --- a/extern/carve/lib/intersect.cpp +++ b/extern/carve/lib/intersect.cpp @@ -647,12 +647,9 @@ void carve::csg::CSG::_generateVertexEdgeIntersections(carve::mesh::MeshSet<3>:: return; } - if (std::min(eb->v1()->v.x, eb->v2()->v.x) - carve::EPSILON > va->v.x || - std::max(eb->v1()->v.x, eb->v2()->v.x) + carve::EPSILON < va->v.x || - std::min(eb->v1()->v.y, eb->v2()->v.y) - carve::EPSILON > va->v.y || - std::max(eb->v1()->v.y, eb->v2()->v.y) + carve::EPSILON < va->v.y || - std::min(eb->v1()->v.z, eb->v2()->v.z) - carve::EPSILON > va->v.z || - std::max(eb->v1()->v.z, eb->v2()->v.z) + carve::EPSILON < va->v.z) { + carve::geom::aabb<3> eb_aabb; + eb_aabb.fit(eb->v1()->v, eb->v2()->v); + if (eb_aabb.maxAxisSeparation(va->v) > carve::EPSILON) { return; } diff --git a/extern/libmv/ChangeLog b/extern/libmv/ChangeLog index 7248e4c9cd9..02b79c93ec2 100644 --- a/extern/libmv/ChangeLog +++ b/extern/libmv/ChangeLog @@ -1,3 +1,54 @@ +commit b813dbe3f46bbbc7e73ac791d4665622e4fc7ba5 +Author: Sergey Sharybin +Date: Wed May 9 19:01:10 2012 +0600 + + Modal solver: Detect rigid transformation between initial frame and current + instead of detecting it between two neighbour frames. + + This prevents accumulation of error and seems to be working better in footages i've tested. + +commit 9254621c76daaf239ec1f535e197ca792eea97b6 +Author: Sergey Sharybin +Date: Wed May 9 18:57:00 2012 +0600 + + Backport changes made by Keir in Blender: + + - Enhance logging in libmv's trackers. + - Cleanups in brute_region_tracker.cc. + +commit d9c56b9d3c63f886d83129ca0ebed1e76d9c93d7 +Author: Sergey Sharybin +Date: Fri Apr 27 16:20:41 2012 +0600 + + Fixes for MinGW64 support by Caleb Joseph with slight modifications by Antony Riakiotakis + + - Functions snprintf and sincos shouldn't be redefined for MinGW64 + - Type pid_t shouldn't be re-defined for MinGW64 + +commit e1902b6938676011607ac99986b8b140bdbf090e +Author: Sergey Sharybin +Date: Fri Apr 27 16:04:19 2012 +0600 + + Fixes for Qt calibration tool + + - Passing directory with images via command line argument now isn't + required -- it there's no such directory specified standard open + dialog might be used for this (before application used to abort + due to accessing to non-existing list element). + - Conversion of source images to grayscale now happens correct. + It was needed to build grayscale palette for 8bit indexed buffer. + +commit 05f1a0a78ad8ff6646d1e8da97e6f7575b891536 +Author: Sergey Sharybin +Date: Sat Apr 14 17:21:29 2012 +0600 + + Make QtTracker compilable again porting it to recent API change and code cleanup: + + - It was using SAD tracker with own API, now it's using standard RegionTracker API + which should make it easier to switch between different trackers. + - Restored LaplaceFilter from old SAD module which convolves images with the + discrete laplacian operator. + commit a44312a7beb2963b8e3bf8015c516d2eff40cc3d Author: Sergey Sharybin Date: Thu Apr 12 13:56:02 2012 +0600 @@ -503,33 +554,3 @@ Author: Matthias Fauconneau Date: Fri Aug 19 18:37:48 2011 +0200 Fix CMake build. - -commit 2ac7281ff6b9545b425dd84fb03bf9c5c98b4de2 -Author: Matthias Fauconneau -Date: Fri Aug 19 17:34:45 2011 +0200 - - Avoid symbol shadowing. - -commit 2a7c3de4acc60e0433b4952f69e30528dbafe0d2 -Author: Matthias Fauconneau -Date: Fri Aug 19 17:22:47 2011 +0200 - - Better dragging behavior when hitting borders. - -commit a14eb3953c9521b2e08ff9ddd45b33ff1f8aeafb -Author: Matthias Fauconneau -Date: Fri Aug 19 17:12:12 2011 +0200 - - Update marker preview to new affine tracking. - -commit 5299ea67043459eda147950e589c2d327a8fbced -Author: Matthias Fauconneau -Date: Fri Aug 19 16:05:54 2011 +0200 - - sqrt takes double precision. - -commit 9f9221ce151d788c49b48f6f293ab2e2f8813978 -Author: Matthias Fauconneau -Date: Fri Aug 19 16:04:37 2011 +0200 - - MSVC compatibility: heap allocate pattern, explicit float cast. diff --git a/extern/libmv/bundle.sh b/extern/libmv/bundle.sh index 30d08cd680a..3f58097b881 100755 --- a/extern/libmv/bundle.sh +++ b/extern/libmv/bundle.sh @@ -1,14 +1,16 @@ #!/bin/sh +if [ "x$1" = "x--i-really-know-what-im-doing" ] ; then + echo Proceeding as requested by command line ... +else + echo "*** Please run again with --i-really-know-what-im-doing ..." + exit 1 +fi + #BRANCH="keir" #BRANCH="Matthias-Fauconneau" BRANCH="Nazg-Gul" -if [ -d ./.svn ]; then - echo "This script is supposed to work only when using git-svn" - exit 1 -fi - repo="git://github.com/${BRANCH}/libmv.git" tmp=`mktemp -d` @@ -22,8 +24,8 @@ for p in `cat ./patches/series`; do cat ./patches/$p | patch -d $tmp/libmv -p1 done -rm -rf libmv -rm -rf third_party +find libmv -type f -not -iwholename '*.svn*' -exec rm -rf {} \; +find third_party -type f -not -iwholename '*.svn*' -exec rm -rf {} \; cat "files.txt" | while read f; do mkdir -p `dirname $f` diff --git a/extern/libmv/libmv/image/convolve.cc b/extern/libmv/libmv/image/convolve.cc index be73a1a3263..63ff7d6d8ff 100644 --- a/extern/libmv/libmv/image/convolve.cc +++ b/extern/libmv/libmv/image/convolve.cc @@ -302,4 +302,18 @@ void BoxFilter(const Array3Df &in, BoxFilterVertical(tmp, box_width, out); } +void LaplaceFilter(unsigned char* src, unsigned char* dst, int width, int height, int strength) { + for(int y=1; y 255) d=255; + dst[y*width+x] = d; + } +} + } // namespace libmv diff --git a/extern/libmv/libmv/image/convolve.h b/extern/libmv/libmv/image/convolve.h index c6c995fd674..a005dc31f10 100644 --- a/extern/libmv/libmv/image/convolve.h +++ b/extern/libmv/libmv/image/convolve.h @@ -87,6 +87,16 @@ void BoxFilter(const FloatImage &in, int box_width, FloatImage *out); +/*! + Convolve \a src into \a dst with the discrete laplacian operator. + + \a src and \a dst should be \a width x \a height images. + \a strength is an interpolation coefficient (0-256) between original image and the laplacian. + + \note Make sure the search region is filtered with the same strength as the pattern. +*/ +void LaplaceFilter(unsigned char* src, unsigned char* dst, int width, int height, int strength); + } // namespace libmv #endif // LIBMV_IMAGE_CONVOLVE_H_ diff --git a/extern/libmv/libmv/image/correlation.h b/extern/libmv/libmv/image/correlation.h index 9d6aceecceb..ba64951a167 100644 --- a/extern/libmv/libmv/image/correlation.h +++ b/extern/libmv/libmv/image/correlation.h @@ -21,6 +21,7 @@ #ifndef LIBMV_IMAGE_CORRELATION_H #define LIBMV_IMAGE_CORRELATION_H +#include "libmv/logging/logging.h" #include "libmv/image/image.h" namespace libmv { @@ -28,7 +29,8 @@ namespace libmv { inline double PearsonProductMomentCorrelation(Array3Df image_and_gradient1_sampled, Array3Df image_and_gradient2_sampled, int width) { - double sX=0,sY=0,sXX=0,sYY=0,sXY=0; + double sX = 0, sY = 0, sXX = 0, sYY = 0, sXY = 0; + for (int r = 0; r < width; ++r) { for (int c = 0; c < width; ++c) { double x = image_and_gradient1_sampled(r, c, 0); @@ -40,9 +42,23 @@ inline double PearsonProductMomentCorrelation(Array3Df image_and_gradient1_sampl sXY += x*y; } } - double N = width*width; - sX /= N, sY /= N, sXX /= N, sYY /= N, sXY /= N; - double correlation = (sXY-sX*sY)/sqrt(double((sXX-sX*sX)*(sYY-sY*sY))); + + // Normalize. + double N = width * width; + sX /= N; + sY /= N; + sXX /= N; + sYY /= N; + sXY /= N; + + double var_x = sXX - sX*sX; + double var_y = sYY - sY*sY; + double covariance_xy = sXY - sX*sY; + + double correlation = covariance_xy / sqrt(var_x * var_y); + LG << "Covariance xy: " << covariance_xy + << ", var 1: " << var_x << ", var 2: " << var_y + << ", correlation: " << correlation; return correlation; } diff --git a/extern/libmv/libmv/image/sample.h b/extern/libmv/libmv/image/sample.h index ea86edf117d..e842747e6d4 100644 --- a/extern/libmv/libmv/image/sample.h +++ b/extern/libmv/libmv/image/sample.h @@ -95,7 +95,6 @@ inline void DownsampleChannelsBy2(const Array3Df &in, Array3Df *out) { } } } - } // Sample a region centered at x,y in image with size extending by half_width diff --git a/extern/libmv/libmv/tracking/brute_region_tracker.cc b/extern/libmv/libmv/tracking/brute_region_tracker.cc index af7f673472e..ef36dffb56d 100644 --- a/extern/libmv/libmv/tracking/brute_region_tracker.cc +++ b/extern/libmv/libmv/tracking/brute_region_tracker.cc @@ -310,7 +310,7 @@ bool BruteRegionTracker::Track(const FloatImage &image1, FloatArrayToByteArrayWithPadding(image_and_gradient2, &search_area, &search_area_stride); // Try all possible locations inside the search area. Yes, everywhere. - int best_i, best_j, best_sad = INT_MAX; + int best_i = -1, best_j = -1, best_sad = INT_MAX; for (int i = 0; i < image2.Height() - pattern_width; ++i) { for (int j = 0; j < image2.Width() - pattern_width; ++j) { int sad = SumOfAbsoluteDifferencesContiguousImage(pattern, @@ -327,38 +327,51 @@ bool BruteRegionTracker::Track(const FloatImage &image1, } } + CHECK_NE(best_i, -1); + CHECK_NE(best_j, -1); + aligned_free(pattern); aligned_free(search_area); - if (best_sad != INT_MAX) { - *x2 = best_j + half_window_size; - *y2 = best_i + half_window_size; + if (best_sad == INT_MAX) { + LG << "Hit INT_MAX in SAD; failing."; + return false; + } - if (minimum_correlation > 0) { - Array3Df image_and_gradient1_sampled, image_and_gradient2_sampled; + *x2 = best_j + half_window_size; + *y2 = best_i + half_window_size; - SamplePattern(image_and_gradient1, x1, y1, half_window_size, 3, - &image_and_gradient1_sampled); - SamplePattern(image_and_gradient2, *x2, *y2, half_window_size, 3, - &image_and_gradient2_sampled); - - // Compute the Pearson product-moment correlation coefficient to check - // for sanity. - double correlation = PearsonProductMomentCorrelation(image_and_gradient1_sampled, - image_and_gradient2_sampled, - pattern_width); - LG << "Final correlation: " << correlation; - - if (correlation < minimum_correlation) { - LG << "Correlation " << correlation << " greater than " - << minimum_correlation << "; bailing."; - return false; - } - } + // Calculate the shift done by the fine tracker. + double dx2 = *x2 - x1; + double dy2 = *y2 - y1; + double fine_shift = sqrt(dx2 * dx2 + dy2 * dy2); + LG << "Brute shift: dx=" << dx2 << " dy=" << dy2 << ", d=" << fine_shift; + if (minimum_correlation <= 0) { + // No correlation checking requested; nothing else to do. + LG << "No correlation checking; returning success. best_sad: " << best_sad; return true; } - return false; + + Array3Df image_and_gradient1_sampled, image_and_gradient2_sampled; + SamplePattern(image_and_gradient1, x1, y1, half_window_size, 3, + &image_and_gradient1_sampled); + SamplePattern(image_and_gradient2, *x2, *y2, half_window_size, 3, + &image_and_gradient2_sampled); + + // Compute the Pearson product-moment correlation coefficient to check + // for sanity. + double correlation = PearsonProductMomentCorrelation(image_and_gradient1_sampled, + image_and_gradient2_sampled, + pattern_width); + LG << "Final correlation: " << correlation; + + if (correlation < minimum_correlation) { + LG << "Correlation " << correlation << " greater than " + << minimum_correlation << "; bailing."; + return false; + } + return true; } } // namespace libmv diff --git a/extern/libmv/libmv/tracking/esm_region_tracker.cc b/extern/libmv/libmv/tracking/esm_region_tracker.cc index e0b85f19943..221fa4d081b 100644 --- a/extern/libmv/libmv/tracking/esm_region_tracker.cc +++ b/extern/libmv/libmv/tracking/esm_region_tracker.cc @@ -41,6 +41,7 @@ static bool RegionIsInBounds(const FloatImage &image1, int min_y = floor(y) - half_window_size - 1; if (min_x < 0.0 || min_y < 0.0) { + LG << "Out of bounds; min_x: " << min_x << ", min_y: " << min_y; return false; } @@ -49,6 +50,9 @@ static bool RegionIsInBounds(const FloatImage &image1, int max_y = ceil(y) + half_window_size + 1; if (max_x > image1.cols() || max_y > image1.rows()) { + LG << "Out of bounds; max_x: " << max_x << ", max_y: " << max_y + << ", image1.cols(): " << image1.cols() + << ", image1.rows(): " << image1.rows(); return false; } @@ -56,24 +60,6 @@ static bool RegionIsInBounds(const FloatImage &image1, return true; } -// Estimate "reasonable" error by computing autocorrelation for a small shift. -// TODO(keir): Add a facility for -static double EstimateReasonableError(const FloatImage &image, - double x, double y, - int half_width) { - double error = 0.0; - for (int r = -half_width; r <= half_width; ++r) { - for (int c = -half_width; c <= half_width; ++c) { - double s = SampleLinear(image, y + r, x + c, 0); - double e1 = SampleLinear(image, y + r + 0.5, x + c, 0) - s; - double e2 = SampleLinear(image, y + r, x + c + 0.5, 0) - s; - error += e1*e1 + e2*e2; - } - } - // XXX hack - return error / 2.0 * 16.0; -} - // This is implemented from "Lukas and Kanade 20 years on: Part 1. Page 42, // figure 14: the Levenberg-Marquardt-Inverse Compositional Algorithm". bool EsmRegionTracker::Track(const FloatImage &image1, @@ -107,9 +93,6 @@ bool EsmRegionTracker::Track(const FloatImage &image1, // // Ignored for my "normal" LM loop. - double reasonable_error = - EstimateReasonableError(image1, x1, y1, half_window_size); - // Step 1: Warp I with W(x, p) to compute I(W(x; p). // // Use two images for accepting / rejecting updates. @@ -228,7 +211,7 @@ bool EsmRegionTracker::Track(const FloatImage &image1, new_error += e*e; } } - //LG << "Old error: " << error << ", new error: " << new_error; + LG << "Old error: " << error << ", new error: " << new_error; double rho = (error - new_error) / (d.transpose() * (mu * d + z)); @@ -253,6 +236,7 @@ bool EsmRegionTracker::Track(const FloatImage &image1, mu *= std::max(1/3., 1 - pow(2*rho - 1, 3)); nu = M_E; // See above for why to use e. + LG << "Error decreased, so accept update."; } // If the step was accepted, then check for termination. @@ -264,13 +248,15 @@ bool EsmRegionTracker::Track(const FloatImage &image1, width); LG << "Final correlation: " << correlation; - if (correlation < minimum_correlation) { - LG << "Correlation " << correlation << " greater than " - << minimum_correlation << "; bailing."; - return false; + // Note: Do the comparison here to handle nan's correctly (since all + // comparisons with nan are false). + if (minimum_correlation < correlation) { + LG << "Successful track in " << (i + 1) << " iterations."; + return true; } - LG << "Successful track in " << (i + 1) << " iterations."; - return true; + LG << "Correlation " << correlation << " greater than " + << minimum_correlation << " or is nan; bailing."; + return false; } } // Getting here means we hit max iterations, so tracking failed. diff --git a/extern/libmv/patches/mingw_w64_support.patch b/extern/libmv/patches/mingw_w64_support.patch deleted file mode 100644 index 360287e81c2..00000000000 --- a/extern/libmv/patches/mingw_w64_support.patch +++ /dev/null @@ -1,58 +0,0 @@ -Index: bundle.sh -=================================================================== ---- bundle.sh (revision 45912) -+++ bundle.sh (working copy) -@@ -248,7 +248,7 @@ - incs += ' ' + env['BF_PNG_INC'] - incs += ' ' + env['BF_ZLIB_INC'] - --if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc'): -+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'): - incs += ' ./third_party/glog/src/windows ./third_party/glog/src/windows/glog' - if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'): - incs += ' ./third_party/msinttypes' -Index: libmv/numeric/numeric.h -=================================================================== ---- libmv/numeric/numeric.h (revision 45912) -+++ libmv/numeric/numeric.h (working copy) -@@ -33,7 +33,7 @@ - #include - #include - --#if _WIN32 || __APPLE__ || __FreeBSD__ -+#if (defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__)) && !defined(__MINGW64__) - void static sincos (double x, double *sinx, double *cosx) { - *sinx = sin(x); - *cosx = cos(x); -Index: third_party/glog/src/windows/port.cc -=================================================================== ---- third_party/glog/src/windows/port.cc (revision 45912) -+++ third_party/glog/src/windows/port.cc (working copy) -@@ -55,6 +55,8 @@ - return _vsnprintf(str, size-1, format, ap); - } - -+// MinGW64 defines -+#ifndef __MINGW64__ - int snprintf(char *str, size_t size, const char *format, ...) { - va_list ap; - va_start(ap, format); -@@ -62,3 +64,4 @@ - va_end(ap); - return r; - } -+#endif -Index: third_party/glog/src/windows/port.h -=================================================================== ---- third_party/glog/src/windows/port.h (revision 45912) -+++ third_party/glog/src/windows/port.h (working copy) -@@ -120,7 +120,9 @@ - #define DEFAULT_TEMPLATE_ROOTDIR ".." - - // ----------------------------------- SYSTEM/PROCESS -+#ifndef __MINGW64__ - typedef int pid_t; -+#endif - #define getpid _getpid - - // ----------------------------------- THREADS diff --git a/intern/SConscript b/intern/SConscript index b6305f7dbab..a1e7f840800 100644 --- a/intern/SConscript +++ b/intern/SConscript @@ -16,25 +16,16 @@ SConscript(['audaspace/SConscript', 'mikktspace/SConscript', 'smoke/SConscript']) -# NEW_CSG was intended for intern/csg, but -# getting it to compile is difficult -# intern/bsp has been used anyway, so -# perhaps get rid of intern/csg? -NEW_CSG = 'false' - if env ['WITH_BF_REMESH']: SConscript(['dualcon/SConscript']) if env['WITH_BF_FLUID']: SConscript(['elbeem/SConscript']) - + if env['WITH_BF_CYCLES']: SConscript(['cycles/SConscript']) -if NEW_CSG == 'false': - SConscript(['bsp/SConscript']) -else: - SConscript(['csg/SConscript']) +SConscript(['bsp/SConscript']) if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-mingw', 'linuxcross', 'win64-vc'): SConscript(['utfconv/SConscript']) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index fb066a3a939..3ade04c4658 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -293,7 +293,7 @@ class CyclesCameraSettings(bpy.types.PropertyGroup): ) cls.fisheye_lens = FloatProperty( name="Fisheye Lens", - description="Lens focal length (mm))", + description="Lens focal length (mm)", min=0.01, soft_max=15.0, max=100.0, default=10.5, ) diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 867cc71bf47..d7003729c46 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -202,7 +202,7 @@ Mesh *BlenderSync::sync_mesh(BL::Object b_ob, bool object_updated) { /* test if we can instance or if the object is modified */ BL::ID b_ob_data = b_ob.data(); - BL::ID key = (object_is_modified(b_ob))? b_ob: b_ob_data; + BL::ID key = (BKE_object_is_modified(b_ob))? b_ob: b_ob_data; BL::Material material_override = render_layer.material_override; /* find shader indices */ @@ -309,7 +309,7 @@ void BlenderSync::sync_mesh_motion(BL::Object b_ob, Mesh *mesh, int motion) /* skip objects without deforming modifiers. this is not a totally reliable, * would need a more extensive check to see which objects are animated */ - if(!size || !ccl::object_is_deform_modified(b_ob, b_scene, preview)) + if(!size || !ccl::BKE_object_is_deform_modified(b_ob, b_scene, preview)) return; /* get derived mesh */ diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index bbf48050222..641aa88d6ef 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -34,10 +34,10 @@ CCL_NAMESPACE_BEGIN /* Utilities */ -bool BlenderSync::object_is_modified(BL::Object b_ob) +bool BlenderSync::BKE_object_is_modified(BL::Object b_ob) { /* test if we can instance or if the object is modified */ - if(ccl::object_is_modified(b_ob, b_scene, preview)) { + if(ccl::BKE_object_is_modified(b_ob, b_scene, preview)) { /* modifiers */ return true; } @@ -286,7 +286,7 @@ void BlenderSync::sync_objects(BL::SpaceView3D b_v3d, int motion) BL::Scene::objects_iterator b_ob; for(b_scene.objects.begin(b_ob); b_ob != b_scene.objects.end(); ++b_ob) { - bool hide = (b_v3d)? b_ob->hide(): b_ob->hide_render(); + bool hide = (render_layer.use_viewport_visibility)? b_ob->hide(): b_ob->hide_render(); uint ob_layer = get_layer(b_ob->layers()); if(!hide && (ob_layer & scene_layer)) { diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 52d97753db3..b33de789631 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -97,6 +97,13 @@ static void get_tex_mapping(TextureMapping *mapping, BL::ShaderNodeMapping b_map mapping->translation = get_float3(b_mapping.translation()); mapping->rotation = get_float3(b_mapping.rotation()); mapping->scale = get_float3(b_mapping.scale()); + + mapping->use_minmax = b_mapping.use_min() || b_mapping.use_max(); + + if(b_mapping.use_min()) + mapping->min = get_float3(b_mapping.min()); + if(b_mapping.use_max()) + mapping->max = get_float3(b_mapping.max()); } static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::ShaderNode b_node) @@ -323,6 +330,10 @@ static ShaderNode *add_node(BL::BlendData b_data, ShaderGraph *graph, BL::Shader node = new LightPathNode(); break; } + case BL::ShaderNode::type_LIGHT_FALLOFF: { + node = new LightFalloffNode(); + break; + } case BL::ShaderNode::type_TEX_IMAGE: { BL::ShaderNodeTexImage b_image_node(b_node); BL::Image b_image(b_image_node.image()); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index 24cf10bc028..c0b6e210bb1 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -87,7 +87,7 @@ bool BlenderSync::sync_recalc() if(object_is_mesh(*b_ob)) { if(b_ob->is_updated_data() || b_ob->data().is_updated()) { - BL::ID key = object_is_modified(*b_ob)? *b_ob: b_ob->data(); + BL::ID key = BKE_object_is_modified(*b_ob)? *b_ob: b_ob->data(); mesh_map.set_recalc(key); } } @@ -215,6 +215,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) render_layer.holdout_layer = 0; render_layer.material_override = PointerRNA_NULL; render_layer.use_background = true; + render_layer.use_viewport_visibility = true; render_layer.samples = 0; return; } @@ -234,6 +235,7 @@ void BlenderSync::sync_render_layers(BL::SpaceView3D b_v3d, const char *layer) render_layer.layer |= render_layer.holdout_layer; render_layer.material_override = b_rlay->material_override(); render_layer.use_background = b_rlay->use_sky(); + render_layer.use_viewport_visibility = false; render_layer.samples = b_rlay->samples(); } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index d6a7218f74f..10afd468850 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -88,7 +88,7 @@ private: /* util */ void find_shader(BL::ID id, vector& used_shaders, int default_shader); - bool object_is_modified(BL::Object b_ob); + bool BKE_object_is_modified(BL::Object b_ob); bool object_is_mesh(BL::Object b_ob); bool object_is_light(BL::Object b_ob); @@ -113,6 +113,7 @@ private: : scene_layer(0), layer(0), holdout_layer(0), material_override(PointerRNA_NULL), use_background(true), + use_viewport_visibility(false), samples(0) {} @@ -122,6 +123,7 @@ private: uint holdout_layer; BL::Material material_override; bool use_background; + bool use_viewport_visibility; int samples; } render_layer; }; diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 9184e14bc76..b01fa81ee40 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -91,12 +91,12 @@ static inline void object_free_duplilist(BL::Object self) rna_Object_free_duplilist(self.ptr.data, NULL); } -static inline bool object_is_modified(BL::Object self, BL::Scene scene, bool preview) +static inline bool BKE_object_is_modified(BL::Object self, BL::Scene scene, bool preview) { return rna_Object_is_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false; } -static inline bool object_is_deform_modified(BL::Object self, BL::Scene scene, bool preview) +static inline bool BKE_object_is_deform_modified(BL::Object self, BL::Scene scene, bool preview) { return rna_Object_is_deform_modified(self.ptr.data, scene.ptr.data, (preview)? (1<<0): (1<<1))? true: false; } diff --git a/intern/cycles/bvh/bvh_build.cpp b/intern/cycles/bvh/bvh_build.cpp index d865426304a..28237aea611 100644 --- a/intern/cycles/bvh/bvh_build.cpp +++ b/intern/cycles/bvh/bvh_build.cpp @@ -36,12 +36,12 @@ CCL_NAMESPACE_BEGIN class BVHBuildTask : public Task { public: - BVHBuildTask(InnerNode *node_, int child_, BVHObjectBinning& range_, int level_) - : node(node_), child(child_), level(level_), range(range_) {} + BVHBuildTask(BVHBuild *build, InnerNode *node, int child, BVHObjectBinning& range_, int level) + : range(range_) + { + run = function_bind(&BVHBuild::thread_build_node, build, node, child, &range, level); + } - InnerNode *node; - int child; - int level; BVHObjectBinning range; }; @@ -55,8 +55,7 @@ BVHBuild::BVHBuild(const vector& objects_, prim_object(prim_object_), params(params_), progress(progress_), - progress_start_time(0.0), - task_pool(function_bind(&BVHBuild::thread_build_node, this, _1, _2)) + progress_start_time(0.0) { spatial_min_overlap = 0.0f; } @@ -177,7 +176,7 @@ BVHNode* BVHBuild::run() /* multithreaded binning build */ BVHObjectBinning rootbin(root, (references.size())? &references[0]: NULL); rootnode = build_node(rootbin, 0); - task_pool.wait(); + task_pool.wait_work(); } /* delete if we cancelled */ @@ -210,25 +209,24 @@ void BVHBuild::progress_update() progress_start_time = time_dt(); } -void BVHBuild::thread_build_node(Task *task_, int thread_id) +void BVHBuild::thread_build_node(InnerNode *inner, int child, BVHObjectBinning *range, int level) { if(progress.get_cancel()) return; /* build nodes */ - BVHBuildTask *task = (BVHBuildTask*)task_; - BVHNode *node = build_node(task->range, task->level); + BVHNode *node = build_node(*range, level); /* set child in inner node */ - task->node->children[task->child] = node; + inner->children[child] = node; /* update progress */ - if(task->range.size() < THREAD_TASK_SIZE) { + if(range->size() < THREAD_TASK_SIZE) { /*rotate(node, INT_MAX, 5);*/ thread_scoped_lock lock(build_mutex); - progress_count += task->range.size(); + progress_count += range->size(); progress_update(); } } @@ -262,8 +260,8 @@ BVHNode* BVHBuild::build_node(const BVHObjectBinning& range, int level) /* threaded build */ inner = new InnerNode(range.bounds()); - task_pool.push(new BVHBuildTask(inner, 0, left, level + 1), true); - task_pool.push(new BVHBuildTask(inner, 1, right, level + 1), true); + task_pool.push(new BVHBuildTask(this, inner, 0, left, level + 1), true); + task_pool.push(new BVHBuildTask(this, inner, 1, right, level + 1), true); } return inner; diff --git a/intern/cycles/bvh/bvh_build.h b/intern/cycles/bvh/bvh_build.h index 84e14632b4b..44ef918b326 100644 --- a/intern/cycles/bvh/bvh_build.h +++ b/intern/cycles/bvh/bvh_build.h @@ -29,7 +29,9 @@ CCL_NAMESPACE_BEGIN +class BVHBuildTask; class BVHParams; +class InnerNode; class Mesh; class Object; class Progress; @@ -54,6 +56,7 @@ protected: friend class BVHMixedSplit; friend class BVHObjectSplit; friend class BVHSpatialSplit; + friend class BVHBuildTask; /* adding references */ void add_reference_mesh(BoundBox& root, BoundBox& center, Mesh *mesh, int i); @@ -68,7 +71,7 @@ protected: /* threads */ enum { THREAD_TASK_SIZE = 4096 }; - void thread_build_node(Task *task_, int thread_id); + void thread_build_node(InnerNode *node, int child, BVHObjectBinning *range, int level); thread_mutex build_mutex; /* progress */ diff --git a/intern/cycles/device/device_cpu.cpp b/intern/cycles/device/device_cpu.cpp index ec84047c44f..07988d32aff 100644 --- a/intern/cycles/device/device_cpu.cpp +++ b/intern/cycles/device/device_cpu.cpp @@ -44,7 +44,6 @@ public: KernelGlobals *kg; CPUDevice(int threads_num) - : task_pool(function_bind(&CPUDevice::thread_run, this, _1, _2)) { kg = kernel_globals_create(); @@ -113,10 +112,8 @@ public: #endif } - void thread_run(Task *task_, int thread_id) + void thread_run(DeviceTask *task) { - DeviceTask *task = (DeviceTask*)task_; - if(task->type == DeviceTask::PATH_TRACE) thread_path_trace(*task); else if(task->type == DeviceTask::TONEMAP) @@ -125,6 +122,15 @@ public: thread_shader(*task); } + class CPUDeviceTask : public DeviceTask { + public: + CPUDeviceTask(CPUDevice *device, DeviceTask& task) + : DeviceTask(task) + { + run = function_bind(&CPUDevice::thread_run, device, this); + } + }; + void thread_path_trace(DeviceTask& task) { if(task_pool.cancelled()) @@ -226,12 +232,12 @@ public: task.split(tasks, TaskScheduler::num_threads()*10); foreach(DeviceTask& task, tasks) - task_pool.push(new DeviceTask(task)); + task_pool.push(new CPUDeviceTask(this, task)); } void task_wait() { - task_pool.wait(); + task_pool.wait_work(); } void task_cancel() diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index e9820010b63..d165716aaca 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -33,6 +33,7 @@ set(SRC_HEADERS kernel_object.h kernel_passes.h kernel_path.h + kernel_projection.h kernel_qbvh.h kernel_random.h kernel_shader.h diff --git a/intern/cycles/kernel/kernel_camera.h b/intern/cycles/kernel/kernel_camera.h index 6d49fd96dd7..e1b474d8537 100644 --- a/intern/cycles/kernel/kernel_camera.h +++ b/intern/cycles/kernel/kernel_camera.h @@ -134,22 +134,6 @@ __device void camera_sample_orthographic(KernelGlobals *kg, float raster_x, floa /* Panorama Camera */ -__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v, Ray *ray) -{ - switch (kernel_data.cam.panorama_type) { - case PANORAMA_EQUIRECTANGULAR: - return equirectangular_to_direction(u, v); - break; - case PANORAMA_FISHEYE_EQUIDISTANT: - return fisheye_to_direction(u, v, kernel_data.cam.fisheye_fov, ray); - break; - case PANORAMA_FISHEYE_EQUISOLID: - default: - return fisheye_equisolid_to_direction(u, v, kernel_data.cam.fisheye_lens, kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight, ray); - break; - } -} - __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, Ray *ray) { Transform rastertocamera = kernel_data.cam.rastertocamera; @@ -165,7 +149,13 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra ray->t = FLT_MAX; #endif - ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray); + ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y); + + /* indicates ray should not receive any light, outside of the lens */ + if(len_squared(ray->D) == 0.0f) { + ray->t = 0.0f; + return; + } /* transform ray from camera to world */ Transform cameratoworld = kernel_data.cam.cameratoworld; @@ -185,10 +175,10 @@ __device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float ra ray->dP.dy = make_float3(0.0f, 0.0f, 0.0f); Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f)); - ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray))) - ray->D; + ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D; Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f)); - ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y, ray))) - ray->D; + ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D; #endif } diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h index c2cf293cab3..cd9557bd0bf 100644 --- a/intern/cycles/kernel/kernel_light.h +++ b/intern/cycles/kernel/kernel_light.h @@ -268,7 +268,7 @@ __device void triangle_light_sample(KernelGlobals *kg, int prim, int object, Transform itfm = object_fetch_transform(kg, ls->object, time, OBJECT_INVERSE_TRANSFORM); ls->P = transform_point(&tfm, ls->P); - ls->Ng = transform_direction_transposed(&itfm, ls->Ng); + ls->Ng = normalize(transform_direction_transposed(&itfm, ls->Ng)); } #endif } diff --git a/intern/cycles/kernel/kernel_montecarlo.h b/intern/cycles/kernel/kernel_montecarlo.h index ba24c2ea402..bdd147f83d3 100644 --- a/intern/cycles/kernel/kernel_montecarlo.h +++ b/intern/cycles/kernel/kernel_montecarlo.h @@ -91,8 +91,8 @@ __device_inline void sample_uniform_hemisphere(const float3 N, float3 *omega_in, float *pdf) { float z = randu; - float r = sqrtf(max(0.f, 1.f - z*z)); - float phi = 2.f * M_PI_F * randv; + float r = sqrtf(max(0.0f, 1.0f - z*z)); + float phi = 2.0f * M_PI_F * randv; float x = r * cosf(phi); float y = r * sinf(phi); @@ -185,128 +185,6 @@ __device float2 regular_polygon_sample(float corners, float rotation, float u, f return make_float2(cr*p.x - sr*p.y, sr*p.x + cr*p.y); } -/* Spherical coordinates <-> Cartesian direction */ - -__device float2 direction_to_spherical(float3 dir) -{ - float theta = acosf(dir.z); - float phi = atan2f(dir.x, dir.y); - - return make_float2(theta, phi); -} - -__device float3 spherical_to_direction(float theta, float phi) -{ - return make_float3( - sinf(theta)*cosf(phi), - sinf(theta)*sinf(phi), - cosf(theta)); -} - -/* Equirectangular coordinates <-> Cartesian direction */ - -__device float2 direction_to_equirectangular(float3 dir) -{ - float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; - float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; - - return make_float2(u, v); -} - -__device float3 equirectangular_to_direction(float u, float v) -{ - float phi = M_PI_F*(1.0f - 2.0f*u); - float theta = M_PI_F*(1.0f - v); - - return make_float3( - sin(theta)*cos(phi), - sin(theta)*sin(phi), - cos(theta)); -} - -/* Fisheye <- Cartesian direction */ - -__device float3 fisheye_to_direction(float u, float v, float fov, Ray *ray) -{ - u = (u - 0.5f) * 2.f; - v = (v - 0.5f) * 2.f; - - float r = sqrt(u*u + v*v); - - if (r > 1.0) { - ray->t = 0.f; - return make_float3(0.f,0.f,0.f); - } - - float phi = acosf((r!=0.f)?u/r:0.f); - float theta = asinf(r) * (fov / M_PI_F); - - if (v < 0.f) phi = -phi; - - return make_float3( - cosf(theta), - -cosf(phi)*sinf(theta), - sinf(phi)*sinf(theta) - ); -} - -__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height, Ray *ray) -{ - u = (u - 0.5f) * width; - v = (v - 0.5f) * height; - - float rmax = 2.f * lens * sinf(fov * 0.25f); - float r = sqrt(u*u + v*v); - - if (r > rmax) { - ray->t = 0.f; - return make_float3(0.f,0.f,0.f); - } - - float phi = acosf((r!=0.f)?u/r:0.f); - float theta = 2.f * asinf(r/(2.f * lens)); - - if (v < 0.f) phi = -phi; - - return make_float3( - cosf(theta), - -cosf(phi)*sinf(theta), - sinf(phi)*sinf(theta) - ); -} - -/* Mirror Ball <-> Cartesion direction */ - -__device float3 mirrorball_to_direction(float u, float v) -{ - /* point on sphere */ - float3 dir; - - dir.x = 2.0f*u - 1.0f; - dir.z = 2.0f*v - 1.0f; - dir.y = -sqrt(max(1.0f - dir.x*dir.x - dir.z*dir.z, 0.0f)); - - /* reflection */ - float3 I = make_float3(0.0f, -1.0f, 0.0f); - - return 2.0f*dot(dir, I)*dir - I; -} - -__device float2 direction_to_mirrorball(float3 dir) -{ - /* inverse of mirrorball_to_direction */ - dir.y -= 1.0f; - - float div = 2.0f*sqrt(max(-0.5f*dir.y, 0.0f)); - if(div > 0.0f) - dir /= div; - - float u = 0.5f*(dir.x + 1.0f); - float v = 0.5f*(dir.z + 1.0f); - - return make_float2(u, v); -} - CCL_NAMESPACE_END #endif /* __KERNEL_MONTECARLO_CL__ */ diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h index 4a3ef55e8cb..abe427d8345 100644 --- a/intern/cycles/kernel/kernel_object.h +++ b/intern/cycles/kernel/kernel_object.h @@ -77,6 +77,16 @@ __device_inline void object_position_transform(KernelGlobals *kg, ShaderData *sd #endif } +__device_inline void object_inverse_position_transform(KernelGlobals *kg, ShaderData *sd, float3 *P) +{ +#ifdef __MOTION__ + *P = transform_point(&sd->ob_itfm, *P); +#else + Transform tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_INVERSE_TRANSFORM); + *P = transform_point(&tfm, *P); +#endif +} + __device_inline void object_inverse_normal_transform(KernelGlobals *kg, ShaderData *sd, float3 *N) { #ifdef __MOTION__ diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index d53951a1f34..e0e17ee57dc 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -18,6 +18,7 @@ #include "kernel_differential.h" #include "kernel_montecarlo.h" +#include "kernel_projection.h" #include "kernel_object.h" #include "kernel_triangle.h" #ifdef __QBVH__ diff --git a/intern/cycles/kernel/kernel_projection.h b/intern/cycles/kernel/kernel_projection.h new file mode 100644 index 00000000000..a5735920cd9 --- /dev/null +++ b/intern/cycles/kernel/kernel_projection.h @@ -0,0 +1,210 @@ +/* + * Parts adapted from Open Shading Language with this license: + * + * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al. + * All Rights Reserved. + * + * Modifications Copyright 2011, Blender Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Sony Pictures Imageworks nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef __KERNEL_PROJECTION_CL__ +#define __KERNEL_PROJECTION_CL__ + +CCL_NAMESPACE_BEGIN + +/* Spherical coordinates <-> Cartesian direction */ + +__device float2 direction_to_spherical(float3 dir) +{ + float theta = acosf(dir.z); + float phi = atan2f(dir.x, dir.y); + + return make_float2(theta, phi); +} + +__device float3 spherical_to_direction(float theta, float phi) +{ + return make_float3( + sinf(theta)*cosf(phi), + sinf(theta)*sinf(phi), + cosf(theta)); +} + +/* Equirectangular coordinates <-> Cartesian direction */ + +__device float2 direction_to_equirectangular(float3 dir) +{ + float u = -atan2f(dir.y, dir.x)/(2.0f*M_PI_F) + 0.5f; + float v = atan2f(dir.z, hypotf(dir.x, dir.y))/M_PI_F + 0.5f; + + return make_float2(u, v); +} + +__device float3 equirectangular_to_direction(float u, float v) +{ + float phi = M_PI_F*(1.0f - 2.0f*u); + float theta = M_PI_F*(1.0f - v); + + return make_float3( + sin(theta)*cos(phi), + sin(theta)*sin(phi), + cos(theta)); +} + +/* Fisheye <-> Cartesian direction */ + +__device float2 direction_to_fisheye(float3 dir, float fov) +{ + float r = atan2f(sqrt(dir.y*dir.y + dir.z*dir.z), dir.x) / fov; + float phi = atan2(dir.z, dir.y); + + float u = r * cos(phi) + 0.5f; + float v = r * sin(phi) + 0.5f; + + return make_float2(u, v); +} + +__device float3 fisheye_to_direction(float u, float v, float fov) +{ + u = (u - 0.5f) * 2.0f; + v = (v - 0.5f) * 2.0f; + + float r = sqrt(u*u + v*v); + + if(r > 1.0f) + return make_float3(0.0f, 0.0f, 0.0f); + + float phi = acosf((r != 0.0f)? u/r: 0.0f); + float theta = asinf(r) * (fov / M_PI_F); + + if(v < 0.0f) phi = -phi; + + return make_float3( + cosf(theta), + -cosf(phi)*sinf(theta), + sinf(phi)*sinf(theta) + ); +} + +__device float2 direction_to_fisheye_equisolid(float3 dir, float lens, float width, float height) +{ + float theta = acosf(dir.x); + float r = 2.0f * lens * sinf(theta * 0.5f); + float phi = atan2f(dir.z, dir.y); + + float u = r * cosf(phi) / width + 0.5f; + float v = r * sinf(phi) / height + 0.5f; + + return make_float2(u, v); +} + +__device float3 fisheye_equisolid_to_direction(float u, float v, float lens, float fov, float width, float height) +{ + u = (u - 0.5f) * width; + v = (v - 0.5f) * height; + + float rmax = 2.0f * lens * sinf(fov * 0.25f); + float r = sqrt(u*u + v*v); + + if(r > rmax) + return make_float3(0.0f, 0.0f, 0.0f); + + float phi = acosf((r != 0.0f)? u/r: 0.0f); + float theta = 2.0f * asinf(r/(2.0f * lens)); + + if(v < 0.0f) phi = -phi; + + return make_float3( + cosf(theta), + -cosf(phi)*sinf(theta), + sinf(phi)*sinf(theta) + ); +} + +/* Mirror Ball <-> Cartesion direction */ + +__device float3 mirrorball_to_direction(float u, float v) +{ + /* point on sphere */ + float3 dir; + + dir.x = 2.0f*u - 1.0f; + dir.z = 2.0f*v - 1.0f; + dir.y = -sqrt(max(1.0f - dir.x*dir.x - dir.z*dir.z, 0.0f)); + + /* reflection */ + float3 I = make_float3(0.0f, -1.0f, 0.0f); + + return 2.0f*dot(dir, I)*dir - I; +} + +__device float2 direction_to_mirrorball(float3 dir) +{ + /* inverse of mirrorball_to_direction */ + dir.y -= 1.0f; + + float div = 2.0f*sqrt(max(-0.5f*dir.y, 0.0f)); + if(div > 0.0f) + dir /= div; + + float u = 0.5f*(dir.x + 1.0f); + float v = 0.5f*(dir.z + 1.0f); + + return make_float2(u, v); +} + +__device float3 panorama_to_direction(KernelGlobals *kg, float u, float v) +{ + switch(kernel_data.cam.panorama_type) { + case PANORAMA_EQUIRECTANGULAR: + return equirectangular_to_direction(u, v); + case PANORAMA_FISHEYE_EQUIDISTANT: + return fisheye_to_direction(u, v, kernel_data.cam.fisheye_fov); + case PANORAMA_FISHEYE_EQUISOLID: + default: + return fisheye_equisolid_to_direction(u, v, kernel_data.cam.fisheye_lens, + kernel_data.cam.fisheye_fov, kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight); + } +} + +__device float2 direction_to_panorama(KernelGlobals *kg, float3 dir) +{ + switch(kernel_data.cam.panorama_type) { + case PANORAMA_EQUIRECTANGULAR: + return direction_to_equirectangular(dir); + case PANORAMA_FISHEYE_EQUIDISTANT: + return direction_to_fisheye(dir, kernel_data.cam.fisheye_fov); + case PANORAMA_FISHEYE_EQUISOLID: + default: + return direction_to_fisheye_equisolid(dir, kernel_data.cam.fisheye_lens, + kernel_data.cam.sensorwidth, kernel_data.cam.sensorheight); + } +} + +CCL_NAMESPACE_END + +#endif /* __KERNEL_PROJECTION_CL__ */ + diff --git a/intern/cycles/kernel/kernel_triangle.h b/intern/cycles/kernel/kernel_triangle.h index 1b3956c1dd4..674c3b52539 100644 --- a/intern/cycles/kernel/kernel_triangle.h +++ b/intern/cycles/kernel/kernel_triangle.h @@ -217,15 +217,42 @@ __device float4 triangle_motion_vector(KernelGlobals *kg, ShaderData *sd) tfm = object_fetch_transform(kg, sd->object, TIME_INVALID, OBJECT_TRANSFORM_MOTION_POST); motion_post = transform_point(&tfm, motion_post); - /* camera motion */ - tfm = kernel_data.cam.worldtoraster; - float3 P = transform_perspective(&tfm, sd->P); + float3 P; - tfm = kernel_data.cam.motion.pre; - motion_pre = transform_perspective(&tfm, motion_pre) - P; + /* camera motion, for perspective/orthographic motion.pre/post will be a + world-to-raster matrix, for panorama it's world-to-camera */ + if (kernel_data.cam.type != CAMERA_PANORAMA) { + tfm = kernel_data.cam.worldtoraster; + P = transform_perspective(&tfm, sd->P); - tfm = kernel_data.cam.motion.post; - motion_post = P - transform_perspective(&tfm, motion_post); + tfm = kernel_data.cam.motion.pre; + motion_pre = transform_perspective(&tfm, motion_pre); + + tfm = kernel_data.cam.motion.post; + motion_post = transform_perspective(&tfm, motion_post); + } + else { + tfm = kernel_data.cam.worldtocamera; + P = normalize(transform_point(&tfm, sd->P)); + P = float2_to_float3(direction_to_panorama(kg, P)); + P.x *= kernel_data.cam.width; + P.y *= kernel_data.cam.height; + + tfm = kernel_data.cam.motion.pre; + motion_pre = normalize(transform_point(&tfm, motion_pre)); + motion_pre = float2_to_float3(direction_to_panorama(kg, motion_pre)); + motion_pre.x *= kernel_data.cam.width; + motion_pre.y *= kernel_data.cam.height; + + tfm = kernel_data.cam.motion.post; + motion_post = normalize(transform_point(&tfm, motion_post)); + motion_post = float2_to_float3(direction_to_panorama(kg, motion_post)); + motion_post.x *= kernel_data.cam.width; + motion_post.y *= kernel_data.cam.height; + } + + motion_pre = motion_pre - P; + motion_post = P - motion_post; return make_float4(motion_pre.x, motion_pre.y, motion_post.x, motion_post.y); } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 25ff7f73888..edca9f8d34d 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -173,25 +173,25 @@ typedef enum PassType { PASS_NONE = 0, PASS_COMBINED = 1, PASS_DEPTH = 2, - PASS_NORMAL = 8, - PASS_UV = 16, - PASS_OBJECT_ID = 32, - PASS_MATERIAL_ID = 64, - PASS_DIFFUSE_COLOR = 128, - PASS_GLOSSY_COLOR = 256, - PASS_TRANSMISSION_COLOR = 512, - PASS_DIFFUSE_INDIRECT = 1024, - PASS_GLOSSY_INDIRECT = 2048, - PASS_TRANSMISSION_INDIRECT = 4096, - PASS_DIFFUSE_DIRECT = 8192, - PASS_GLOSSY_DIRECT = 16384, - PASS_TRANSMISSION_DIRECT = 32768, - PASS_EMISSION = 65536, - PASS_BACKGROUND = 131072, - PASS_AO = 262144, - PASS_SHADOW = 524288, - PASS_MOTION = 1048576, - PASS_MOTION_WEIGHT = 2097152 + PASS_NORMAL = 4, + PASS_UV = 8, + PASS_OBJECT_ID = 16, + PASS_MATERIAL_ID = 32, + PASS_DIFFUSE_COLOR = 64, + PASS_GLOSSY_COLOR = 128, + PASS_TRANSMISSION_COLOR = 256, + PASS_DIFFUSE_INDIRECT = 512, + PASS_GLOSSY_INDIRECT = 1024, + PASS_TRANSMISSION_INDIRECT = 2048, + PASS_DIFFUSE_DIRECT = 4096, + PASS_GLOSSY_DIRECT = 8192, + PASS_TRANSMISSION_DIRECT = 16384, + PASS_EMISSION = 32768, + PASS_BACKGROUND = 65536, + PASS_AO = 131072, + PASS_SHADOW = 262144, + PASS_MOTION = 524288, + PASS_MOTION_WEIGHT = 1048576 } PassType; #define PASS_ALL (~0) @@ -491,7 +491,9 @@ typedef struct KernelCamera { /* sensor size */ float sensorwidth; float sensorheight; - int pad1, pad2; + + /* render size */ + float width, height; /* more matrices */ Transform screentoworld; diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h index 50181c0cf2c..5f4d7bbd0c4 100644 --- a/intern/cycles/kernel/svm/svm.h +++ b/intern/cycles/kernel/svm/svm.h @@ -326,6 +326,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT case NODE_MAPPING: svm_node_mapping(kg, sd, stack, node.y, node.z, &offset); break; + case NODE_MIN_MAX: + svm_node_min_max(kg, sd, stack, node.y, node.z, &offset); + break; case NODE_TEX_COORD: svm_node_tex_coord(kg, sd, stack, node.y, node.z); break; @@ -344,6 +347,9 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT case NODE_RGB_CURVES: svm_node_rgb_curves(kg, sd, stack, node, &offset); break; + case NODE_LIGHT_FALLOFF: + svm_node_light_falloff(sd, stack, node); + break; case NODE_END: default: #ifndef __MULTI_CLOSURE__ diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h index ebbcb5be61f..b29dc9cbd45 100644 --- a/intern/cycles/kernel/svm/svm_light_path.h +++ b/intern/cycles/kernel/svm/svm_light_path.h @@ -39,5 +39,32 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint stack_store_float(stack, out_offset, info); } +/* Light Falloff Node */ + +__device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node) +{ + uint strength_offset, out_offset, smooth_offset; + + decode_node_uchar4(node.z, &strength_offset, &smooth_offset, &out_offset, NULL); + + float strength = stack_load_float(stack, strength_offset); + uint type = node.y; + + switch(type) { + case NODE_LIGHT_FALLOFF_QUADRATIC: break; + case NODE_LIGHT_FALLOFF_LINEAR: strength *= sd->ray_length; break; + case NODE_LIGHT_FALLOFF_CONSTANT: strength *= sd->ray_length*sd->ray_length; break; + } + + float smooth = stack_load_float(stack, smooth_offset); + + if(smooth > 0.0f) { + float squared = sd->ray_length*sd->ray_length; + strength *= squared/(smooth + squared); + } + + stack_store_float(stack, out_offset, strength); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_mapping.h b/intern/cycles/kernel/svm/svm_mapping.h index 6dc74aece08..96645ac97db 100644 --- a/intern/cycles/kernel/svm/svm_mapping.h +++ b/intern/cycles/kernel/svm/svm_mapping.h @@ -34,5 +34,16 @@ __device void svm_node_mapping(KernelGlobals *kg, ShaderData *sd, float *stack, stack_store_float3(stack, out_offset, r); } +__device void svm_node_min_max(KernelGlobals *kg, ShaderData *sd, float *stack, uint vec_offset, uint out_offset, int *offset) +{ + float3 v = stack_load_float3(stack, vec_offset); + + float3 mn = float4_to_float3(read_node_float(kg, offset)); + float3 mx = float4_to_float3(read_node_float(kg, offset)); + + float3 r = min(max(mn, v), mx); + stack_store_float3(stack, out_offset, r); +} + CCL_NAMESPACE_END diff --git a/intern/cycles/kernel/svm/svm_tex_coord.h b/intern/cycles/kernel/svm/svm_tex_coord.h index 3b73cac5430..aa924bcc38b 100644 --- a/intern/cycles/kernel/svm/svm_tex_coord.h +++ b/intern/cycles/kernel/svm/svm_tex_coord.h @@ -20,12 +20,35 @@ CCL_NAMESPACE_BEGIN /* Texture Coordinate Node */ -__device float3 svm_background_offset(KernelGlobals *kg) +__device_inline float3 svm_background_offset(KernelGlobals *kg) { Transform cameratoworld = kernel_data.cam.cameratoworld; return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); } +__device_inline float3 svm_world_to_ndc(KernelGlobals *kg, ShaderData *sd, float3 P) +{ + if(kernel_data.cam.type != CAMERA_PANORAMA) { + if(sd->object != ~0) + P += svm_background_offset(kg); + + Transform tfm = kernel_data.cam.worldtondc; + return transform_perspective(&tfm, P); + } + else { + Transform tfm = kernel_data.cam.worldtocamera; + + if(sd->object != ~0) + P = normalize(transform_point(&tfm, P)); + else + P = normalize(transform_direction(&tfm, P)); + + float2 uv = direction_to_panorama(kg, P);; + + return make_float3(uv.x, uv.y, 0.0f); + } +} + __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint out_offset) { float3 data; @@ -34,7 +57,7 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack case NODE_TEXCO_OBJECT: { if(sd->object != ~0) { data = sd->P; - object_position_transform(kg, sd, &data); + object_inverse_position_transform(kg, sd, &data); } else data = sd->P; @@ -59,12 +82,7 @@ __device void svm_node_tex_coord(KernelGlobals *kg, ShaderData *sd, float *stack break; } case NODE_TEXCO_WINDOW: { - Transform tfm = kernel_data.cam.worldtondc; - - if(sd->object != ~0) - data = transform_perspective(&tfm, sd->P); - else - data = transform_perspective(&tfm, sd->P + svm_background_offset(kg)); + data = svm_world_to_ndc(kg, sd, sd->P); break; } case NODE_TEXCO_REFLECTION: { @@ -88,7 +106,7 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, floa case NODE_TEXCO_OBJECT: { if(sd->object != ~0) { data = sd->P + sd->dP.dx; - object_position_transform(kg, sd, &data); + object_inverse_position_transform(kg, sd, &data); } else data = sd->P + sd->dP.dx; @@ -113,12 +131,7 @@ __device void svm_node_tex_coord_bump_dx(KernelGlobals *kg, ShaderData *sd, floa break; } case NODE_TEXCO_WINDOW: { - Transform tfm = kernel_data.cam.worldtondc; - - if(sd->object != ~0) - data = transform_perspective(&tfm, sd->P + sd->dP.dx); - else - data = transform_perspective(&tfm, sd->P + sd->dP.dx + svm_background_offset(kg)); + data = svm_world_to_ndc(kg, sd, sd->P + sd->dP.dx); break; } case NODE_TEXCO_REFLECTION: { @@ -145,7 +158,7 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa case NODE_TEXCO_OBJECT: { if(sd->object != ~0) { data = sd->P + sd->dP.dy; - object_position_transform(kg, sd, &data); + object_inverse_position_transform(kg, sd, &data); } else data = sd->P + sd->dP.dy; @@ -170,12 +183,7 @@ __device void svm_node_tex_coord_bump_dy(KernelGlobals *kg, ShaderData *sd, floa break; } case NODE_TEXCO_WINDOW: { - Transform tfm = kernel_data.cam.worldtondc; - - if(sd->object != ~0) - data = transform_perspective(&tfm, sd->P + sd->dP.dy); - else - data = transform_perspective(&tfm, sd->P + sd->dP.dy + svm_background_offset(kg)); + data = svm_world_to_ndc(kg, sd, sd->P + sd->dP.dy); break; } case NODE_TEXCO_REFLECTION: { diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h index 8037c3964a9..867709f29e0 100644 --- a/intern/cycles/kernel/svm/svm_types.h +++ b/intern/cycles/kernel/svm/svm_types.h @@ -90,7 +90,9 @@ typedef enum NodeType { NODE_TEX_CHECKER = 5700, NODE_BRIGHTCONTRAST = 5800, NODE_RGB_RAMP = 5900, - NODE_RGB_CURVES = 6000 + NODE_RGB_CURVES = 6000, + NODE_MIN_MAX = 6100, + NODE_LIGHT_FALLOFF = 6200 } NodeType; typedef enum NodeAttributeType { @@ -119,6 +121,12 @@ typedef enum NodeLightPath { NODE_LP_ray_length } NodeLightPath; +typedef enum NodeLightFalloff { + NODE_LIGHT_FALLOFF_QUADRATIC, + NODE_LIGHT_FALLOFF_LINEAR, + NODE_LIGHT_FALLOFF_CONSTANT +} NodeLightFalloff; + typedef enum NodeTexCoord { NODE_TEXCO_NORMAL, NODE_TEXCO_OBJECT, diff --git a/intern/cycles/render/camera.cpp b/intern/cycles/render/camera.cpp index 95405519cc0..3ecffab7cbc 100644 --- a/intern/cycles/render/camera.cpp +++ b/intern/cycles/render/camera.cpp @@ -158,13 +158,25 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) kcam->have_motion = 0; if(need_motion == Scene::MOTION_PASS) { - if(use_motion) { - kcam->motion.pre = transform_inverse(motion.pre * rastertocamera); - kcam->motion.post = transform_inverse(motion.post * rastertocamera); + if(type == CAMERA_PANORAMA) { + if(use_motion) { + kcam->motion.pre = transform_inverse(motion.pre); + kcam->motion.post = transform_inverse(motion.post); + } + else { + kcam->motion.pre = kcam->worldtocamera; + kcam->motion.post = kcam->worldtocamera; + } } else { - kcam->motion.pre = worldtoraster; - kcam->motion.post = worldtoraster; + if(use_motion) { + kcam->motion.pre = transform_inverse(motion.pre * rastertocamera); + kcam->motion.post = transform_inverse(motion.post * rastertocamera); + } + else { + kcam->motion.pre = worldtoraster; + kcam->motion.post = worldtoraster; + } } } else if(need_motion == Scene::MOTION_BLUR) { @@ -196,6 +208,10 @@ void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene) kcam->sensorwidth = sensorwidth; kcam->sensorheight = sensorheight; + /* render size */ + kcam->width = width; + kcam->height = height; + /* store differentials */ kcam->dx = float3_to_float4(dx); kcam->dy = float3_to_float4(dy); diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 78b8f06c7b4..b9e02467450 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -60,19 +60,13 @@ static bool is_float_image(const string& filename) if(in->open(filename, spec)) { /* check the main format, and channel formats; - if any are non-integer, we'll need a float texture slot */ - if(spec.format == TypeDesc::HALF || - spec.format == TypeDesc::FLOAT || - spec.format == TypeDesc::DOUBLE) { + if any take up more than one byte, we'll need a float texture slot */ + if(spec.format.basesize() > 1) is_float = true; - } for(size_t channel = 0; channel < spec.channelformats.size(); channel++) { - if(spec.channelformats[channel] == TypeDesc::HALF || - spec.channelformats[channel] == TypeDesc::FLOAT || - spec.channelformats[channel] == TypeDesc::DOUBLE) { + if(spec.channelformats[channel].basesize() > 1) is_float = true; - } } in->close(); @@ -324,8 +318,10 @@ bool ImageManager::file_load_float_image(Image *img, device_vector& tex_ return true; } -void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot) +void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progress) { + if(progress->get_cancel()) + return; if(osl_texture_system) return; @@ -342,6 +338,9 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl } if(is_float) { + string filename = path_filename(float_images[slot - TEX_IMAGE_FLOAT_START]->filename); + progress->set_status("Updating Images", "Loading " + filename); + device_vector& tex_img = dscene->tex_float_image[slot - TEX_IMAGE_FLOAT_START]; if(tex_img.device_pointer) @@ -365,6 +364,9 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl device->tex_alloc(name.c_str(), tex_img, true, true); } else { + string filename = path_filename(images[slot]->filename); + progress->set_status("Updating Images", "Loading " + filename); + device_vector& tex_img = dscene->tex_image[slot]; if(tex_img.device_pointer) @@ -387,6 +389,8 @@ void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int sl device->tex_alloc(name.c_str(), tex_img, true, true); } + + img->need_load = false; } void ImageManager::device_free_image(Device *device, DeviceScene *dscene, int slot) @@ -431,39 +435,37 @@ void ImageManager::device_update(Device *device, DeviceScene *dscene, Progress& { if(!need_update) return; + + TaskPool pool; for(size_t slot = 0; slot < images.size(); slot++) { - if(images[slot]) { - if(images[slot]->users == 0) { - device_free_image(device, dscene, slot); - } - else if(images[slot]->need_load) { - string name = path_filename(images[slot]->filename); - progress.set_status("Updating Images", "Loading " + name); - device_load_image(device, dscene, slot); - images[slot]->need_load = false; - } + if(!images[slot]) + continue; - if(progress.get_cancel()) return; + if(images[slot]->users == 0) { + device_free_image(device, dscene, slot); + } + else if(images[slot]->need_load) { + if(!osl_texture_system) + pool.push(function_bind(&ImageManager::device_load_image, this, device, dscene, slot, &progress)); } } for(size_t slot = 0; slot < float_images.size(); slot++) { - if(float_images[slot]) { - if(float_images[slot]->users == 0) { - device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START); - } - else if(float_images[slot]->need_load) { - string name = path_filename(float_images[slot]->filename); - progress.set_status("Updating Images", "Loading " + name); - device_load_image(device, dscene, slot + TEX_IMAGE_FLOAT_START); - float_images[slot]->need_load = false; - } + if(!float_images[slot]) + continue; - if(progress.get_cancel()) return; + if(float_images[slot]->users == 0) { + device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START); + } + else if(float_images[slot]->need_load) { + if(!osl_texture_system) + pool.push(function_bind(&ImageManager::device_load_image, this, device, dscene, slot + TEX_IMAGE_FLOAT_START, &progress)); } } + pool.wait_work(); + need_update = false; } diff --git a/intern/cycles/render/image.h b/intern/cycles/render/image.h index d789e6885e3..cc01b4a8e4c 100644 --- a/intern/cycles/render/image.h +++ b/intern/cycles/render/image.h @@ -65,7 +65,7 @@ private: bool file_load_image(Image *img, device_vector& tex_img); bool file_load_float_image(Image *img, device_vector& tex_img); - void device_load_image(Device *device, DeviceScene *dscene, int slot); + void device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progess); void device_free_image(Device *device, DeviceScene *dscene, int slot); }; diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 316e5cec9aa..267cb8e6d3a 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -26,8 +26,6 @@ #include "util_foreach.h" #include "util_progress.h" -#include "kernel_montecarlo.h" - CCL_NAMESPACE_BEGIN static void dump_background_pixels(Device *device, DeviceScene *dscene, int res, vector& pixels) diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp index 5d96611ff26..0422f97a706 100644 --- a/intern/cycles/render/mesh.cpp +++ b/intern/cycles/render/mesh.cpp @@ -242,31 +242,47 @@ void Mesh::pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset) } } -void Mesh::compute_bvh(SceneParams *params, Progress& progress) +void Mesh::compute_bvh(SceneParams *params, Progress *progress, int n, int total) { - Object object; - object.mesh = this; + if(progress->get_cancel()) + return; - vector objects; - objects.push_back(&object); + compute_bounds(); - if(bvh && !need_update_rebuild) { - progress.set_substatus("Refitting BVH"); - bvh->objects = objects; - bvh->refit(progress); + if(!transform_applied) { + string msg = "Updating Mesh BVH "; + if(name == "") + msg += string_printf("%u/%u", (uint)(n+1), (uint)total); + else + msg += string_printf("%s %u/%u", name.c_str(), (uint)(n+1), (uint)total); + + Object object; + object.mesh = this; + + vector objects; + objects.push_back(&object); + + if(bvh && !need_update_rebuild) { + progress->set_status(msg, "Refitting BVH"); + bvh->objects = objects; + bvh->refit(*progress); + } + else { + progress->set_status(msg, "Building BVH"); + + BVHParams bparams; + bparams.use_cache = params->use_bvh_cache; + bparams.use_spatial_split = params->use_bvh_spatial_split; + bparams.use_qbvh = params->use_qbvh; + + delete bvh; + bvh = BVH::create(bparams, objects); + bvh->build(*progress); + } } - else { - progress.set_substatus("Building BVH"); - BVHParams bparams; - bparams.use_cache = params->use_bvh_cache; - bparams.use_spatial_split = params->use_bvh_spatial_split; - bparams.use_qbvh = params->use_qbvh; - - delete bvh; - bvh = BVH::create(bparams, objects); - bvh->build(progress); - } + need_update = false; + need_update_rebuild = false; } void Mesh::tag_update(Scene *scene, bool rebuild) @@ -686,35 +702,22 @@ void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scen } /* update bvh */ - size_t i = 0, num_instance_bvh = 0; + size_t i = 0, num_bvh = 0; foreach(Mesh *mesh, scene->meshes) if(mesh->need_update && !mesh->transform_applied) - num_instance_bvh++; + num_bvh++; + + TaskPool pool; foreach(Mesh *mesh, scene->meshes) { if(mesh->need_update) { - mesh->compute_bounds(); - - if(!mesh->transform_applied) { - string msg = "Updating Mesh BVH "; - if(mesh->name == "") - msg += string_printf("%u/%u", (uint)(i+1), (uint)num_instance_bvh); - else - msg += string_printf("%s %u/%u", mesh->name.c_str(), (uint)(i+1), (uint)num_instance_bvh); - progress.set_status(msg, "Building BVH"); - - mesh->compute_bvh(&scene->params, progress); - - i++; - } - - if(progress.get_cancel()) return; - - mesh->need_update = false; - mesh->need_update_rebuild = false; + pool.push(function_bind(&Mesh::compute_bvh, mesh, &scene->params, &progress, i, num_bvh)); + i++; } } + + pool.wait_work(); foreach(Shader *shader, scene->shaders) shader->need_update_attributes = false; diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h index 047a2d2624d..637143f5adf 100644 --- a/intern/cycles/render/mesh.h +++ b/intern/cycles/render/mesh.h @@ -96,7 +96,7 @@ public: void pack_normals(Scene *scene, float4 *normal, float4 *vnormal); void pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset); - void compute_bvh(SceneParams *params, Progress& progress); + void compute_bvh(SceneParams *params, Progress *progress, int n, int total); bool need_attribute(Scene *scene, AttributeStandard std); bool need_attribute(Scene *scene, ustring name); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index fd26c552f21..57fe2fb01b7 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -33,6 +33,11 @@ TextureMapping::TextureMapping() rotation = make_float3(0.0f, 0.0f, 0.0f); scale = make_float3(1.0f, 1.0f, 1.0f); + min = make_float3(-FLT_MAX, -FLT_MAX, -FLT_MAX); + max = make_float3(FLT_MAX, FLT_MAX, FLT_MAX); + + use_minmax = false; + x_mapping = X; y_mapping = Y; z_mapping = Z; @@ -69,6 +74,8 @@ bool TextureMapping::skip() if(x_mapping != X || y_mapping != Y || z_mapping != Z) return false; + if(use_minmax) + return false; return true; } @@ -85,6 +92,12 @@ void TextureMapping::compile(SVMCompiler& compiler, int offset_in, int offset_ou compiler.add_node(tfm.y); compiler.add_node(tfm.z); compiler.add_node(tfm.w); + + if(use_minmax) { + compiler.add_node(NODE_MIN_MAX, offset_out, offset_out); + compiler.add_node(float3_to_float4(min)); + compiler.add_node(float3_to_float4(max)); + } } /* Image Texture */ @@ -1686,6 +1699,53 @@ void LightPathNode::compile(OSLCompiler& compiler) compiler.add(this, "node_light_path"); } +/* Light Path */ + +LightFalloffNode::LightFalloffNode() +: ShaderNode("light_path") +{ + add_input("Strength", SHADER_SOCKET_FLOAT, 100.0f); + add_input("Smooth", SHADER_SOCKET_FLOAT, 0.0f); + add_output("Quadratic", SHADER_SOCKET_FLOAT); + add_output("Linear", SHADER_SOCKET_FLOAT); + add_output("Constant", SHADER_SOCKET_FLOAT); +} + +void LightFalloffNode::compile(SVMCompiler& compiler) +{ + ShaderInput *strength_in = input("Strength"); + ShaderInput *smooth_in = input("Smooth"); + + compiler.stack_assign(strength_in); + compiler.stack_assign(smooth_in); + + ShaderOutput *out = output("Quadratic"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_QUADRATIC, + compiler.encode_uchar4(strength_in->stack_offset, smooth_in->stack_offset, out->stack_offset)); + } + + out = output("Linear"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_LINEAR, + compiler.encode_uchar4(strength_in->stack_offset, smooth_in->stack_offset, out->stack_offset)); + } + + out = output("Constant"); + if(!out->links.empty()) { + compiler.stack_assign(out); + compiler.add_node(NODE_LIGHT_FALLOFF, NODE_LIGHT_FALLOFF_CONSTANT, + compiler.encode_uchar4(strength_in->stack_offset, smooth_in->stack_offset, out->stack_offset)); + } +} + +void LightFalloffNode::compile(OSLCompiler& compiler) +{ + compiler.add(this, "node_light_falloff"); +} + /* Value */ ValueNode::ValueNode() diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 364209f8c5e..ff9e3647d01 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -41,6 +41,9 @@ public: float3 rotation; float3 scale; + float3 min, max; + bool use_minmax; + enum Mapping { NONE=0, X=1, Y=2, Z=3 }; Mapping x_mapping, y_mapping, z_mapping; @@ -277,6 +280,11 @@ public: SHADER_NODE_CLASS(LightPathNode) }; +class LightFalloffNode : public ShaderNode { +public: + SHADER_NODE_CLASS(LightFalloffNode) +}; + class ValueNode : public ShaderNode { public: SHADER_NODE_CLASS(ValueNode) diff --git a/intern/cycles/util/util_math.h b/intern/cycles/util/util_math.h index 7b527241847..8c0e7105b22 100644 --- a/intern/cycles/util/util_math.h +++ b/intern/cycles/util/util_math.h @@ -507,6 +507,11 @@ __device_inline float3 fabs(float3 a) #endif +__device_inline float3 float2_to_float3(const float2 a) +{ + return make_float3(a.x, a.y, 0.0f); +} + __device_inline float3 float4_to_float3(const float4 a) { return make_float3(a.x, a.y, a.z); diff --git a/intern/cycles/util/util_progress.h b/intern/cycles/util/util_progress.h index 2cc2995bcfe..c63aa841c52 100644 --- a/intern/cycles/util/util_progress.h +++ b/intern/cycles/util/util_progress.h @@ -153,8 +153,10 @@ public: void set_update() { - if(update_cb) + if(update_cb) { + thread_scoped_lock lock(update_mutex); update_cb(); + } } void set_update_callback(boost::function function) @@ -164,6 +166,7 @@ public: protected: thread_mutex progress_mutex; + thread_mutex update_mutex; boost::function update_cb; boost::function cancel_cb; diff --git a/intern/cycles/util/util_task.cpp b/intern/cycles/util/util_task.cpp index 6da9a70ec0c..023630e8fae 100644 --- a/intern/cycles/util/util_task.cpp +++ b/intern/cycles/util/util_task.cpp @@ -25,14 +25,10 @@ CCL_NAMESPACE_BEGIN /* Task Pool */ -TaskPool::TaskPool(const TaskRunFunction& run_) +TaskPool::TaskPool() { num = 0; - num_done = 0; - do_cancel = false; - - run = run_; } TaskPool::~TaskPool() @@ -50,20 +46,73 @@ void TaskPool::push(Task *task, bool front) TaskScheduler::push(entry, front); } -void TaskPool::wait() +void TaskPool::push(const TaskRunFunction& run, bool front) { - thread_scoped_lock lock(done_mutex); + push(new Task(run), front); +} - while(num_done != num) - done_cond.wait(lock); +void TaskPool::wait_work() +{ + thread_scoped_lock num_lock(num_mutex); + + while(num != 0) { + num_lock.unlock(); + + thread_scoped_lock queue_lock(TaskScheduler::queue_mutex); + + /* find task from this pool. if we get a task from another pool, + * we can get into deadlock */ + TaskScheduler::Entry work_entry; + bool found_entry = false; + list::iterator it; + + for(it = TaskScheduler::queue.begin(); it != TaskScheduler::queue.end(); it++) { + TaskScheduler::Entry& entry = *it; + + if(entry.pool == this) { + work_entry = entry; + found_entry = true; + TaskScheduler::queue.erase(it); + break; + } + } + + queue_lock.unlock(); + + /* if found task, do it, otherwise wait until other tasks are done */ + if(found_entry) { + /* run task */ + work_entry.task->run(); + + /* delete task */ + delete work_entry.task; + + /* notify pool task was done */ + num_decrease(1); + } + + num_lock.lock(); + if(num == 0) + break; + + if(!found_entry) + num_cond.wait(num_lock); + } } void TaskPool::cancel() { - TaskScheduler::clear(this); - do_cancel = true; - wait(); + + TaskScheduler::clear(this); + + { + thread_scoped_lock num_lock(num_mutex); + + while(num) + num_cond.wait(num_lock); + } + do_cancel = false; } @@ -71,7 +120,7 @@ void TaskPool::stop() { TaskScheduler::clear(this); - assert(num_done == num); + assert(num == 0); } bool TaskPool::cancelled() @@ -79,14 +128,23 @@ bool TaskPool::cancelled() return do_cancel; } -void TaskPool::done_increase(int done) +void TaskPool::num_decrease(int done) { - done_mutex.lock(); - num_done += done; - done_mutex.unlock(); + num_mutex.lock(); + num -= done; - assert(num_done <= num); - done_cond.notify_all(); + assert(num >= 0); + if(num == 0) + num_cond.notify_all(); + + num_mutex.unlock(); +} + +void TaskPool::num_increase() +{ + thread_scoped_lock num_lock(num_mutex); + num++; + num_cond.notify_all(); } /* Task Scheduler */ @@ -94,6 +152,7 @@ void TaskPool::done_increase(int done) thread_mutex TaskScheduler::mutex; int TaskScheduler::users = 0; vector TaskScheduler::threads; +vector TaskScheduler::thread_level; volatile bool TaskScheduler::do_exit = false; list TaskScheduler::queue; @@ -114,9 +173,12 @@ void TaskScheduler::init(int num_threads) num_threads = system_cpu_thread_count(); threads.resize(num_threads); + thread_level.resize(num_threads); - for(size_t i = 0; i < threads.size(); i++) + for(size_t i = 0; i < threads.size(); i++) { threads[i] = new thread(function_bind(&TaskScheduler::thread_run, i)); + thread_level[i] = 0; + } } users++; @@ -140,15 +202,16 @@ void TaskScheduler::exit() } threads.clear(); + thread_level.clear(); } } bool TaskScheduler::thread_wait_pop(Entry& entry) { - thread_scoped_lock lock(queue_mutex); + thread_scoped_lock queue_lock(queue_mutex); while(queue.empty() && !do_exit) - queue_cond.wait(lock); + queue_cond.wait(queue_lock); if(queue.empty()) { assert(do_exit); @@ -170,53 +233,56 @@ void TaskScheduler::thread_run(int thread_id) /* keep popping off tasks */ while(thread_wait_pop(entry)) { /* run task */ - entry.pool->run(entry.task, thread_id); + entry.task->run(); /* delete task */ delete entry.task; /* notify pool task was done */ - entry.pool->done_increase(1); + entry.pool->num_decrease(1); } } void TaskScheduler::push(Entry& entry, bool front) { + entry.pool->num_increase(); + /* 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(); + TaskScheduler::queue_mutex.unlock(); } void TaskScheduler::clear(TaskPool *pool) { - thread_scoped_lock lock(TaskScheduler::queue_mutex); + thread_scoped_lock queue_lock(TaskScheduler::queue_mutex); /* erase all tasks from this pool from the queue */ - list::iterator it = TaskScheduler::queue.begin(); + list::iterator it = queue.begin(); int done = 0; - while(it != TaskScheduler::queue.end()) { - TaskScheduler::Entry& entry = *it; + while(it != queue.end()) { + Entry& entry = *it; if(entry.pool == pool) { done++; delete entry.task; - it = TaskScheduler::queue.erase(it); + it = queue.erase(it); } else it++; } + queue_lock.unlock(); + /* notify done */ - pool->done_increase(done); + pool->num_decrease(done); } CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_task.h b/intern/cycles/util/util_task.h index acdb2cb50a2..401a503f540 100644 --- a/intern/cycles/util/util_task.h +++ b/intern/cycles/util/util_task.h @@ -29,7 +29,7 @@ class Task; class TaskPool; class TaskScheduler; -typedef boost::function TaskRunFunction; +typedef boost::function TaskRunFunction; /* Task * @@ -39,7 +39,11 @@ class Task { public: Task() {}; + Task(const TaskRunFunction& run_) : run(run_) {} + virtual ~Task() {} + + TaskRunFunction run; }; /* Task Pool @@ -54,12 +58,13 @@ public: class TaskPool { public: - TaskPool(const TaskRunFunction& run); + TaskPool(); ~TaskPool(); void push(Task *task, bool front = false); + void push(const TaskRunFunction& run, bool front = false); - void wait(); /* wait until all tasks are done */ + void wait_work(); /* work and wait until all tasks are done */ void cancel(); /* cancel all tasks, keep worker threads running */ void stop(); /* stop all worker threads */ @@ -68,14 +73,13 @@ public: protected: friend class TaskScheduler; - void done_increase(int done); + void num_decrease(int done); + void num_increase(); - TaskRunFunction run; + thread_mutex num_mutex; + thread_condition_variable num_cond; - thread_mutex done_mutex; - thread_condition_variable done_cond; - - volatile int num, num_done; + volatile int num; volatile bool do_cancel; }; @@ -103,6 +107,7 @@ protected: static thread_mutex mutex; static int users; static vector threads; + static vector thread_level; static volatile bool do_exit; static list queue; diff --git a/intern/cycles/util/util_transform.h b/intern/cycles/util/util_transform.h index 7136c185d04..e4897ee6787 100644 --- a/intern/cycles/util/util_transform.h +++ b/intern/cycles/util/util_transform.h @@ -253,7 +253,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) /* the epsilon here is quite arbitrary, but this function is only used for surface area and bump, where we except it to not be so sensitive */ Transform ttfm = transform_transpose(tfm); - float eps = 1e-7f; + float eps = 1e-6f; float sx = len_squared(float4_to_float3(tfm.x)); float sy = len_squared(float4_to_float3(tfm.y)); @@ -261,7 +261,7 @@ __device_inline bool transform_uniform_scale(const Transform& tfm, float& scale) float stx = len_squared(float4_to_float3(ttfm.x)); float sty = len_squared(float4_to_float3(ttfm.y)); float stz = len_squared(float4_to_float3(ttfm.z)); - + if(fabsf(sx - sy) < eps && fabsf(sx - sz) < eps && fabsf(sx - stx) < eps && fabsf(sx - sty) < eps && fabsf(sx - stz) < eps) { diff --git a/intern/dualcon/dualcon.h b/intern/dualcon/dualcon.h index 53135a7dcc1..1c3d31b6625 100644 --- a/intern/dualcon/dualcon.h +++ b/intern/dualcon/dualcon.h @@ -24,7 +24,7 @@ #define __DUALCON_H__ #ifdef __cplusplus -extern "C" { +extern "C" { #endif typedef float (*DualConCo)[3]; @@ -35,11 +35,11 @@ typedef struct DualConInput { DualConCo co; int co_stride; int totco; - + DualConFaces faces; int face_stride; int totface; - + float min[3], max[3]; } DualConInput; @@ -64,32 +64,32 @@ typedef enum { } DualConMode; /* Usage: - - The three callback arguments are used for creating the output - mesh. The alloc_output callback takes the total number of vertices - and faces (quads) that will be in the output. It should allocate - and return a structure to hold the output mesh. The add_vert and - add_quad callbacks will then be called for each new vertex and - quad, and the callback should add the new mesh elements to the - structure. -*/ + * + * The three callback arguments are used for creating the output + * mesh. The alloc_output callback takes the total number of vertices + * and faces (quads) that will be in the output. It should allocate + * and return a structure to hold the output mesh. The add_vert and + * add_quad callbacks will then be called for each new vertex and + * quad, and the callback should add the new mesh elements to the + * structure. + */ void *dualcon(const DualConInput *input_mesh, - /* callbacks for output */ - DualConAllocOutput alloc_output, - DualConAddVert add_vert, - DualConAddQuad add_quad, + /* callbacks for output */ + DualConAllocOutput alloc_output, + DualConAddVert add_vert, + DualConAddQuad add_quad, - /* flags and settings to control the remeshing - algorithm */ - DualConFlags flags, - DualConMode mode, - float threshold, - float hermite_num, - float scale, - int depth); + /* flags and settings to control the remeshing + * algorithm */ + DualConFlags flags, + DualConMode mode, + float threshold, + float hermite_num, + float scale, + int depth); #ifdef __cplusplus -} +} #endif #endif /* __DUALCON_H__ */ diff --git a/intern/dualcon/intern/GeoCommon.h b/intern/dualcon/intern/GeoCommon.h index 3b2789bec87..9f5a99e9e20 100644 --- a/intern/dualcon/intern/GeoCommon.h +++ b/intern/dualcon/intern/GeoCommon.h @@ -36,31 +36,26 @@ // 3d point with integer coordinates -typedef struct -{ +typedef struct { int x, y, z; } Point3i; -typedef struct -{ +typedef struct { Point3i begin; Point3i end; } BoundingBox; // triangle that points to three vertices -typedef struct -{ - float vt[3][3] ; +typedef struct { + float vt[3][3]; } Triangle; // 3d point with float coordinates -typedef struct -{ +typedef struct { float x, y, z; } Point3f; -typedef struct -{ +typedef struct { Point3f begin; Point3f end; } BoundingBoxf; diff --git a/intern/dualcon/intern/MemoryAllocator.h b/intern/dualcon/intern/MemoryAllocator.h index a1be0978409..b704542d27b 100644 --- a/intern/dualcon/intern/MemoryAllocator.h +++ b/intern/dualcon/intern/MemoryAllocator.h @@ -43,19 +43,19 @@ class VirtualMemoryAllocator { public: - virtual void * allocate( ) = 0 ; - virtual void deallocate( void * obj ) = 0 ; - virtual void destroy( ) = 0 ; - virtual void printInfo( ) = 0 ; +virtual void *allocate( ) = 0; +virtual void deallocate(void *obj) = 0; +virtual void destroy( ) = 0; +virtual void printInfo( ) = 0; - virtual int getAllocated( ) = 0 ; - virtual int getAll( ) = 0 ; - virtual int getBytes( ) = 0 ; +virtual int getAllocated( ) = 0; +virtual int getAll( ) = 0; +virtual int getBytes( ) = 0; }; /** * Dynamic memory allocator - allows allocation/deallocation - * + * * Note: there are 4 bytes overhead for each allocated yet unused object. */ template < int N > @@ -63,157 +63,157 @@ class MemoryAllocator : public VirtualMemoryAllocator { private: - /// Constants - int HEAP_UNIT, HEAP_MASK ; +/// Constants +int HEAP_UNIT, HEAP_MASK; - /// Data array - UCHAR ** data ; +/// Data array +UCHAR **data; - /// Allocation stack - UCHAR *** stack ; +/// Allocation stack +UCHAR ***stack; - /// Number of data blocks - int datablocknum ; +/// Number of data blocks +int datablocknum; - /// Number of stack blocks - int stackblocknum ; +/// Number of stack blocks +int stackblocknum; - /// Size of stack - int stacksize ; +/// Size of stack +int stacksize; - /// Number of available objects on stack - int available ; +/// Number of available objects on stack +int available; - /** - * Allocate a memory block - */ - void allocateDataBlock ( ) +/** + * Allocate a memory block + */ +void allocateDataBlock( ) +{ + // Allocate a data block + datablocknum += 1; + data = ( UCHAR ** )realloc(data, sizeof (UCHAR *) * datablocknum); + data[datablocknum - 1] = ( UCHAR * )malloc(HEAP_UNIT * N); + + // Update allocation stack + for (int i = 0; i < HEAP_UNIT; i++) { - // Allocate a data block - datablocknum += 1 ; - data = ( UCHAR ** )realloc( data, sizeof ( UCHAR * ) * datablocknum ) ; - data[ datablocknum - 1 ] = ( UCHAR * )malloc( HEAP_UNIT * N ) ; - - // Update allocation stack - for ( int i = 0 ; i < HEAP_UNIT ; i ++ ) - { - stack[ 0 ][ i ] = ( data[ datablocknum - 1 ] + i * N ) ; - } - available = HEAP_UNIT ; + stack[0][i] = (data[datablocknum - 1] + i * N); } + available = HEAP_UNIT; +} - /** - * Allocate a stack block, to store more deallocated objects - */ - void allocateStackBlock( ) - { - // Allocate a stack block - stackblocknum += 1 ; - stacksize += HEAP_UNIT ; - stack = ( UCHAR *** )realloc( stack, sizeof ( UCHAR ** ) * stackblocknum ) ; - stack[ stackblocknum - 1 ] = ( UCHAR ** )malloc( HEAP_UNIT * sizeof ( UCHAR * ) ) ; - } +/** + * Allocate a stack block, to store more deallocated objects + */ +void allocateStackBlock( ) +{ + // Allocate a stack block + stackblocknum += 1; + stacksize += HEAP_UNIT; + stack = ( UCHAR *** )realloc(stack, sizeof (UCHAR * *) * stackblocknum); + stack[stackblocknum - 1] = ( UCHAR ** )malloc(HEAP_UNIT * sizeof (UCHAR *) ); +} public: - /** - * Constructor - */ - MemoryAllocator( ) +/** + * Constructor + */ +MemoryAllocator( ) +{ + HEAP_UNIT = 1 << HEAP_BASE; + HEAP_MASK = (1 << HEAP_BASE) - 1; + + data = ( UCHAR ** )malloc(sizeof(UCHAR *) ); + data[0] = ( UCHAR * )malloc(HEAP_UNIT * N); + datablocknum = 1; + + stack = ( UCHAR *** )malloc(sizeof (UCHAR * *) ); + stack[0] = ( UCHAR ** )malloc(HEAP_UNIT * sizeof (UCHAR *) ); + stackblocknum = 1; + stacksize = HEAP_UNIT; + available = HEAP_UNIT; + + for (int i = 0; i < HEAP_UNIT; i++) { - HEAP_UNIT = 1 << HEAP_BASE ; - HEAP_MASK = ( 1 << HEAP_BASE ) - 1 ; + stack[0][i] = (data[0] + i * N); + } +} - data = ( UCHAR ** )malloc( sizeof( UCHAR * ) ) ; - data[ 0 ] = ( UCHAR * )malloc( HEAP_UNIT * N ) ; - datablocknum = 1 ; +/** + * Destructor + */ +void destroy( ) +{ + int i; + for (i = 0; i < datablocknum; i++) + { + free(data[i]); + } + for (i = 0; i < stackblocknum; i++) + { + free(stack[i]); + } + free(data); + free(stack); +} - stack = ( UCHAR *** )malloc( sizeof ( UCHAR ** ) ) ; - stack[ 0 ] = ( UCHAR ** )malloc( HEAP_UNIT * sizeof ( UCHAR * ) ) ; - stackblocknum = 1 ; - stacksize = HEAP_UNIT ; - available = HEAP_UNIT ; - - for ( int i = 0 ; i < HEAP_UNIT ; i ++ ) - { - stack[ 0 ][ i ] = ( data[ 0 ] + i * N ) ; - } +/** + * Allocation method + */ +void *allocate( ) +{ + if (available == 0) + { + allocateDataBlock( ); } - /** - * Destructor - */ - void destroy( ) + // printf("Allocating %d\n", header[ allocated ]) ; + available--; + return (void *)stack[available >> HEAP_BASE][available & HEAP_MASK]; +} + +/** + * De-allocation method + */ +void deallocate(void *obj) +{ + if (available == stacksize) { - int i ; - for ( i = 0 ; i < datablocknum ; i ++ ) - { - free( data[ i ] ) ; - } - for ( i = 0 ; i < stackblocknum ; i ++ ) - { - free( stack[ i ] ) ; - } - free( data ) ; - free( stack ) ; + allocateStackBlock( ); } - /** - * Allocation method - */ - void * allocate ( ) - { - if ( available == 0 ) - { - allocateDataBlock ( ) ; - } + // printf("De-allocating %d\n", ( obj - data ) / N ) ; + stack[available >> HEAP_BASE][available & HEAP_MASK] = (UCHAR *)obj; + available++; + // printf("%d %d\n", allocated, header[ allocated ]) ; +} - // printf("Allocating %d\n", header[ allocated ]) ; - available -- ; - return (void*)stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] ; - } +/** + * Print information + */ +void printInfo( ) +{ + printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n", getBytes(), getAllocated(), getAll(), stacksize); +} - /** - * De-allocation method - */ - void deallocate ( void * obj ) - { - if ( available == stacksize ) - { - allocateStackBlock ( ) ; - } +/** + * Query methods + */ +int getAllocated( ) +{ + return HEAP_UNIT * datablocknum - available; +}; - // printf("De-allocating %d\n", ( obj - data ) / N ) ; - stack[ available >> HEAP_BASE ][ available & HEAP_MASK ] = (UCHAR*)obj ; - available ++ ; - // printf("%d %d\n", allocated, header[ allocated ]) ; - } +int getAll( ) +{ + return HEAP_UNIT * datablocknum; +}; - /** - * Print information - */ - void printInfo ( ) - { - printf("Bytes: %d Used: %d Allocated: %d Maxfree: %d\n", getBytes(), getAllocated(), getAll(), stacksize ) ; - } - - /** - * Query methods - */ - int getAllocated( ) - { - return HEAP_UNIT * datablocknum - available ; - }; - - int getAll( ) - { - return HEAP_UNIT * datablocknum ; - }; - - int getBytes( ) - { - return N ; - }; +int getBytes( ) +{ + return N; +}; }; #endif diff --git a/intern/dualcon/intern/ModelReader.h b/intern/dualcon/intern/ModelReader.h index e70a1586e03..993c5756531 100644 --- a/intern/dualcon/intern/ModelReader.h +++ b/intern/dualcon/intern/ModelReader.h @@ -33,31 +33,32 @@ class ModelReader { public: - /// Constructor - ModelReader(){} ; +/// Constructor +ModelReader(){ +}; - /// Get next triangle - virtual Triangle* getNextTriangle( ) = 0 ; - virtual int getNextTriangle( int t[3] ) = 0 ; +/// Get next triangle +virtual Triangle *getNextTriangle( ) = 0; +virtual int getNextTriangle(int t[3]) = 0; - /// Get bounding box - virtual float getBoundingBox ( float origin[3] ) = 0 ; +/// Get bounding box +virtual float getBoundingBox(float origin[3]) = 0; - /// Get number of triangles - virtual int getNumTriangles ( ) = 0 ; +/// Get number of triangles +virtual int getNumTriangles( ) = 0; - /// Get storage size - virtual int getMemory ( ) = 0 ; +/// Get storage size +virtual int getMemory( ) = 0; - /// Reset file reading location - virtual void reset( ) = 0 ; +/// Reset file reading location +virtual void reset( ) = 0; - /// For explicit vertex models - virtual int getNumVertices( ) = 0 ; +/// For explicit vertex models +virtual int getNumVertices( ) = 0; - virtual void getNextVertex( float v[3] ) = 0 ; +virtual void getNextVertex(float v[3]) = 0; - virtual void printInfo ( ) = 0 ; +virtual void printInfo( ) = 0; }; diff --git a/intern/dualcon/intern/Projections.cpp b/intern/dualcon/intern/Projections.cpp index 1f0831ce973..2a52cc9972a 100644 --- a/intern/dualcon/intern/Projections.cpp +++ b/intern/dualcon/intern/Projections.cpp @@ -37,18 +37,15 @@ const int vertmap[8][3] = { const int centmap[3][3][3][2] = { {{{0, 0}, {0, 1}, {1, 1}}, {{0, 2}, {0, 3}, {1, 3}}, - {{2, 2}, {2, 3}, {3, 3}} - }, - + {{2, 2}, {2, 3}, {3, 3}}}, + {{{0, 4}, {0, 5}, {1, 5}}, {{0, 6}, {0, 7}, {1, 7}}, - {{2, 6}, {2, 7}, {3, 7}} - }, - + {{2, 6}, {2, 7}, {3, 7}}}, + {{{4, 4}, {4, 5}, {5, 5}}, {{4, 6}, {4, 7}, {5, 7}}, - {{6, 6}, {6, 7}, {7, 7}} - } + {{6, 6}, {6, 7}, {7, 7}}} }; const int edgemap[12][2] = { @@ -74,3 +71,308 @@ const int facemap[6][4] = { {0, 2, 4, 6}, {1, 3, 5, 7} }; + +/** + * Method to perform cross-product + */ +static void crossProduct(int64_t res[3], const int64_t a[3], const int64_t b[3]) +{ + res[0] = a[1] * b[2] - a[2] * b[1]; + res[1] = a[2] * b[0] - a[0] * b[2]; + res[2] = a[0] * b[1] - a[1] * b[0]; +} + +static void crossProduct(double res[3], const double a[3], const double b[3]) +{ + res[0] = a[1] * b[2] - a[2] * b[1]; + res[1] = a[2] * b[0] - a[0] * b[2]; + res[2] = a[0] * b[1] - a[1] * b[0]; +} + +/** + * Method to perform dot product + */ +int64_t dotProduct(const int64_t a[3], const int64_t b[3]) +{ + return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; +} + +void normalize(double a[3]) +{ + double mag = a[0] * a[0] + a[1] * a[1] + a[2] * a[2]; + if (mag > 0) { + mag = sqrt(mag); + a[0] /= mag; + a[1] /= mag; + a[2] /= mag; + } +} + +/* Create projection axes for cube+triangle intersection testing. + * 0, 1, 2: cube face normals + * + * 3: triangle normal + * + * 4, 5, 6, + * 7, 8, 9, + * 10, 11, 12: cross of each triangle edge vector with each cube + * face normal + */ +static void create_projection_axes(int64_t axes[NUM_AXES][3], const int64_t tri[3][3]) +{ + /* Cube face normals */ + axes[0][0] = 1; + axes[0][1] = 0; + axes[0][2] = 0; + axes[1][0] = 0; + axes[1][1] = 1; + axes[1][2] = 0; + axes[2][0] = 0; + axes[2][1] = 0; + axes[2][2] = 1; + + /* Get triangle edge vectors */ + int64_t tri_edges[3][3]; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) + tri_edges[i][j] = tri[(i + 1) % 3][j] - tri[i][j]; + } + + /* Triangle normal */ + crossProduct(axes[3], tri_edges[0], tri_edges[1]); + + // Face edges and triangle edges + int ct = 4; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + crossProduct(axes[ct], axes[j], tri_edges[i]); + ct++; + } + } +} + +/** + * Construction from a cube (axes aligned) and triangle + */ +CubeTriangleIsect::CubeTriangleIsect(int64_t cube[2][3], int64_t tri[3][3], int64_t error, int triind) +{ + int i; + inherit = new TriangleProjection; + inherit->index = triind; + + int64_t axes[NUM_AXES][3]; + create_projection_axes(axes, tri); + + /* Normalize face normal and store */ + double dedge1[] = {(double)tri[1][0] - (double)tri[0][0], + (double)tri[1][1] - (double)tri[0][1], + (double)tri[1][2] - (double)tri[0][2]}; + double dedge2[] = {(double)tri[2][0] - (double)tri[1][0], + (double)tri[2][1] - (double)tri[1][1], + (double)tri[2][2] - (double)tri[1][2]}; + crossProduct(inherit->norm, dedge1, dedge2); + normalize(inherit->norm); + + int64_t cubeedge[3][3]; + for (i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + cubeedge[i][j] = 0; + } + cubeedge[i][i] = cube[1][i] - cube[0][i]; + } + + /* Project the cube on to each axis */ + for (int axis = 0; axis < NUM_AXES; axis++) { + CubeProjection &cube_proj = cubeProj[axis]; + + /* Origin */ + cube_proj.origin = dotProduct(axes[axis], cube[0]); + + /* 3 direction vectors */ + for (i = 0; i < 3; i++) + cube_proj.edges[i] = dotProduct(axes[axis], cubeedge[i]); + + /* Offsets of 2 ends of cube projection */ + int64_t max = 0; + int64_t min = 0; + for (i = 1; i < 8; i++) { + int64_t proj = (vertmap[i][0] * cube_proj.edges[0] + + vertmap[i][1] * cube_proj.edges[1] + + vertmap[i][2] * cube_proj.edges[2]); + if (proj > max) { + max = proj; + } + if (proj < min) { + min = proj; + } + } + cube_proj.min = min; + cube_proj.max = max; + + } + + /* Project the triangle on to each axis */ + for (int axis = 0; axis < NUM_AXES; axis++) { + const int64_t vts[3] = {dotProduct(axes[axis], tri[0]), + dotProduct(axes[axis], tri[1]), + dotProduct(axes[axis], tri[2])}; + + // Triangle + inherit->tri_proj[axis][0] = vts[0]; + inherit->tri_proj[axis][1] = vts[0]; + for (i = 1; i < 3; i++) { + if (vts[i] < inherit->tri_proj[axis][0]) + inherit->tri_proj[axis][0] = vts[i]; + + if (vts[i] > inherit->tri_proj[axis][1]) + inherit->tri_proj[axis][1] = vts[i]; + } + } +} + +/** + * Construction + * from a parent CubeTriangleIsect object and the index of the children + */ +CubeTriangleIsect::CubeTriangleIsect(CubeTriangleIsect *parent) +{ + // Copy inheritable projections + this->inherit = parent->inherit; + + // Shrink cube projections + for (int i = 0; i < NUM_AXES; i++) { + cubeProj[i].origin = parent->cubeProj[i].origin; + + for (int j = 0; j < 3; j++) + cubeProj[i].edges[j] = parent->cubeProj[i].edges[j] >> 1; + + cubeProj[i].min = parent->cubeProj[i].min >> 1; + cubeProj[i].max = parent->cubeProj[i].max >> 1; + } +} + +unsigned char CubeTriangleIsect::getBoxMask( ) +{ + int i, j, k; + int bmask[3][2] = {{0, 0}, {0, 0}, {0, 0}}; + unsigned char boxmask = 0; + int64_t child_len = cubeProj[0].edges[0] >> 1; + + for (i = 0; i < 3; i++) { + int64_t mid = cubeProj[i].origin + child_len; + + // Check bounding box + if (mid >= inherit->tri_proj[i][0]) { + bmask[i][0] = 1; + } + if (mid < inherit->tri_proj[i][1]) { + bmask[i][1] = 1; + } + + } + + // Fill in masks + int ct = 0; + for (i = 0; i < 2; i++) { + for (j = 0; j < 2; j++) { + for (k = 0; k < 2; k++) { + boxmask |= ( (bmask[0][i] & bmask[1][j] & bmask[2][k]) << ct); + ct++; + } + } + } + + // Return bounding box masks + return boxmask; +} + + +/** + * Shifting a cube to a new origin + */ +void CubeTriangleIsect::shift(int off[3]) +{ + for (int i = 0; i < NUM_AXES; i++) { + cubeProj[i].origin += (off[0] * cubeProj[i].edges[0] + + off[1] * cubeProj[i].edges[1] + + off[2] * cubeProj[i].edges[2]); + } +} + +/** + * Method to test intersection of the triangle and the cube + */ +int CubeTriangleIsect::isIntersecting() const +{ + for (int i = 0; i < NUM_AXES; i++) { + /* + int64_t proj0 = cubeProj[i][0] + + vertmap[inherit->cubeEnds[i][0]][0] * cubeProj[i][1] + + vertmap[inherit->cubeEnds[i][0]][1] * cubeProj[i][2] + + vertmap[inherit->cubeEnds[i][0]][2] * cubeProj[i][3] ; + int64_t proj1 = cubeProj[i][0] + + vertmap[inherit->cubeEnds[i][1]][0] * cubeProj[i][1] + + vertmap[inherit->cubeEnds[i][1]][1] * cubeProj[i][2] + + vertmap[inherit->cubeEnds[i][1]][2] * cubeProj[i][3] ; + */ + + int64_t proj0 = cubeProj[i].origin + cubeProj[i].min; + int64_t proj1 = cubeProj[i].origin + cubeProj[i].max; + + if (proj0 > inherit->tri_proj[i][1] || + proj1 < inherit->tri_proj[i][0]) { + return 0; + } + } + + return 1; +} + +int CubeTriangleIsect::isIntersectingPrimary(int edgeInd) const +{ + for (int i = 0; i < NUM_AXES; i++) { + + int64_t proj0 = cubeProj[i].origin; + int64_t proj1 = cubeProj[i].origin + cubeProj[i].edges[edgeInd]; + + if (proj0 < proj1) { + if (proj0 > inherit->tri_proj[i][1] || + proj1 < inherit->tri_proj[i][0]) { + return 0; + } + } + else { + if (proj1 > inherit->tri_proj[i][1] || + proj0 < inherit->tri_proj[i][0]) { + return 0; + } + } + + } + + // printf( "Intersecting: %d %d\n", edgemap[edgeInd][0], edgemap[edgeInd][1] ) ; + return 1; +} + +float CubeTriangleIsect::getIntersectionPrimary(int edgeInd) const +{ + int i = 3; + + + int64_t proj0 = cubeProj[i].origin; + int64_t proj1 = cubeProj[i].origin + cubeProj[i].edges[edgeInd]; + int64_t proj2 = inherit->tri_proj[i][1]; + int64_t d = proj1 - proj0; + double alpha; + + if (d == 0) + alpha = 0.5; + else { + alpha = (double)((proj2 - proj0)) / (double)d; + + if (alpha < 0 || alpha > 1) + alpha = 0.5; + } + + return (float)alpha; +} diff --git a/intern/dualcon/intern/Projections.h b/intern/dualcon/intern/Projections.h index 18533b218ff..2cc3320f8e4 100644 --- a/intern/dualcon/intern/Projections.h +++ b/intern/dualcon/intern/Projections.h @@ -32,815 +32,99 @@ #if defined(_WIN32) && !defined(__MINGW32__) #define isnan(n) _isnan(n) #define LONG __int64 +#define int64_t __int64 #else #include -#define LONG int64_t #endif -#define UCHAR unsigned char /** - * Structures and classes for computing projections of triangles - * onto separating axes during scan conversion - * - * @author Tao Ju - */ - +* Structures and classes for computing projections of triangles onto +* separating axes during scan conversion +* +* @author Tao Ju +*/ extern const int vertmap[8][3]; extern const int centmap[3][3][3][2]; extern const int edgemap[12][2]; extern const int facemap[6][4]; +/* Axes: + * 0, 1, 2: cube face normals + * + * 3: triangle normal + * + * 4, 5, 6, + * 7, 8, 9, + * 10, 11, 12: cross of each triangle edge vector with each cube + * face normal + */ +#define NUM_AXES 13 + /** * Structure for the projections inheritable from parent */ -struct InheritableProjections -{ - /// Projections of triangle - LONG trigProj[13][2] ; - - /// Projections of triangle vertices on primary axes - LONG trigVertProj[13][3] ; - - /// Projections of triangle edges - LONG trigEdgeProj[13][3][2] ; +struct TriangleProjection { + /// Projections of triangle (min and max) + int64_t tri_proj[NUM_AXES][2]; /// Normal of the triangle - double norm[3] ; - double normA, normB ; + double norm[3]; - /// End points along each axis - //int cubeEnds[13][2] ; - - /// Error range on each axis - /// LONG errorProj[13]; - -#ifdef CONTAINS_INDEX /// Index of polygon - int index ; -#endif + int index; +}; + +/* This is a projection for the cube against a single projection + axis, see CubeTriangleIsect.cubeProj */ +struct CubeProjection { + int64_t origin; + int64_t edges[3]; + int64_t min, max; }; /** * Class for projections of cube / triangle vertices on the separating axes */ -class Projections +class CubeTriangleIsect { public: /// Inheritable portion - InheritableProjections* inherit ; + TriangleProjection *inherit; /// Projections of the cube vertices - LONG cubeProj[13][6] ; + CubeProjection cubeProj[NUM_AXES]; public: - - Projections( ) - { - } - - /** - * Construction - * from a cube (axes aligned) and triangle - */ - Projections( LONG cube[2][3], LONG trig[3][3], LONG error, int triind ) - { - int i, j ; - inherit = new InheritableProjections ; -#ifdef CONTAINS_INDEX - inherit->index = triind ; -#endif - /// Create axes - LONG axes[13][3] ; - - // Cube faces - axes[0][0] = 1 ; - axes[0][1] = 0 ; - axes[0][2] = 0 ; - - axes[1][0] = 0 ; - axes[1][1] = 1 ; - axes[1][2] = 0 ; - - axes[2][0] = 0 ; - axes[2][1] = 0 ; - axes[2][2] = 1 ; - - // Triangle face - LONG trigedge[3][3] ; - for ( i = 0 ; i < 3 ; i ++ ) - { - for ( j = 0 ; j < 3 ; j ++ ) - { - trigedge[i][j] = trig[(i+1)%3][j] - trig[i][j] ; - } - } - crossProduct( trigedge[0], trigedge[1], axes[3] ) ; - - /// Normalize face normal and store - double dedge1[] = { (double) trig[1][0] - (double) trig[0][0], - (double) trig[1][1] - (double) trig[0][1], - (double) trig[1][2] - (double) trig[0][2] } ; - double dedge2[] = { (double) trig[2][0] - (double) trig[1][0], - (double) trig[2][1] - (double) trig[1][1], - (double) trig[2][2] - (double) trig[1][2] } ; - crossProduct( dedge1, dedge2, inherit->norm ) ; - normalize( inherit->norm ) ; -// inherit->normA = norm[ 0 ] ; -// inherit->normB = norm[ 2 ] > 0 ? norm[ 1 ] : 2 + norm[ 1 ] ; - - // Face edges and triangle edges - int ct = 4 ; - for ( i = 0 ; i < 3 ; i ++ ) - for ( j = 0 ; j < 3 ; j ++ ) - { - crossProduct( axes[j], trigedge[i], axes[ct] ) ; - ct ++ ; - } - - /// Generate projections - LONG cubeedge[3][3] ; - for ( i = 0 ; i < 3 ; i ++ ) - { - for ( j = 0 ; j < 3 ; j ++ ) - { - cubeedge[i][j] = 0 ; - } - cubeedge[i][i] = cube[1][i] - cube[0][i] ; - } - - for ( j = 0 ; j < 13 ; j ++ ) - { - // Origin - cubeProj[j][0] = dotProduct( axes[j], cube[0] ) ; - - // 3 direction vectors - for ( i = 1 ; i < 4 ; i ++ ) - { - cubeProj[j][i] = dotProduct( axes[j], cubeedge[i-1] ) ; - } - - // Offsets of 2 ends of cube projection - LONG max = 0 ; - LONG min = 0 ; - for ( i = 1 ; i < 8 ; i ++ ) - { - LONG proj = vertmap[i][0] * cubeProj[j][1] + vertmap[i][1] * cubeProj[j][2] + vertmap[i][2] * cubeProj[j][3] ; - if ( proj > max ) - { - max = proj ; - } - if ( proj < min ) - { - min = proj ; - } - } - cubeProj[j][4] = min ; - cubeProj[j][5] = max ; - - } - - for ( j = 0 ; j < 13 ; j ++ ) - { - LONG vts[3] = { dotProduct( axes[j], trig[0] ), - dotProduct( axes[j], trig[1] ), - dotProduct( axes[j], trig[2] ) } ; - - // Vertex - inherit->trigVertProj[j][0] = vts[0] ; - inherit->trigVertProj[j][1] = vts[1] ; - inherit->trigVertProj[j][2] = vts[2] ; - - // Edge - for ( i = 0 ; i < 3 ; i ++ ) - { - if ( vts[i] < vts[(i+1) % 3] ) - { - inherit->trigEdgeProj[j][i][0] = vts[i] ; - inherit->trigEdgeProj[j][i][1] = vts[(i+1) % 3] ; - } - else - { - inherit->trigEdgeProj[j][i][1] = vts[i] ; - inherit->trigEdgeProj[j][i][0] = vts[(i+1) % 3] ; - } - } - - // Triangle - inherit->trigProj[j][0] = vts[0] ; - inherit->trigProj[j][1] = vts[0] ; - for ( i = 1 ; i < 3 ; i ++ ) - { - if ( vts[i] < inherit->trigProj[j][0] ) - { - inherit->trigProj[j][0] = vts[i] ; - } - if ( vts[i] > inherit->trigProj[j][1] ) - { - inherit->trigProj[j][1] = vts[i] ; - } - } - } - - } + CubeTriangleIsect() {} /** - * Construction - * from a parent Projections object and the index of the children + * Construction from a cube (axes aligned) and triangle */ - Projections ( Projections* parent ) - { - // Copy inheritable projections - this->inherit = parent->inherit ; - - // Shrink cube projections - for ( int i = 0 ; i < 13 ; i ++ ) - { - cubeProj[i][0] = parent->cubeProj[i][0] ; - for ( int j = 1 ; j < 6 ; j ++ ) - { - cubeProj[i][j] = parent->cubeProj[i][j] >> 1 ; - } - } - }; - - Projections ( Projections* parent, int box[3], int depth ) - { - int mask = ( 1 << depth ) - 1 ; - int nbox[3] = { box[0] & mask, box[1] & mask, box[2] & mask } ; - - // Copy inheritable projections - this->inherit = parent->inherit ; - - // Shrink cube projections - for ( int i = 0 ; i < 13 ; i ++ ) - { - for ( int j = 1 ; j < 6 ; j ++ ) - { - cubeProj[i][j] = parent->cubeProj[i][j] >> depth ; - } - - cubeProj[i][0] = parent->cubeProj[i][0] + nbox[0] * cubeProj[i][1] + nbox[1] * cubeProj[i][2] + nbox[2] * cubeProj[i][3] ; - } - }; - + CubeTriangleIsect(int64_t cube[2][3], int64_t trig[3][3], int64_t error, int triind); + /** - * Testing intersection based on vertex/edge masks + * Construction from a parent CubeTriangleIsect object and the index of + * the children */ - int getIntersectionMasks( UCHAR cedgemask, UCHAR& edgemask ) - { - int i, j ; - edgemask = cedgemask ; - - // Pre-processing - /* - if ( cvertmask & 1 ) - { - edgemask |= 5 ; - } - if ( cvertmask & 2 ) - { - edgemask |= 3 ; - } - if ( cvertmask & 4 ) - { - edgemask |= 6 ; - } - - */ - - // Test axes for edge intersection - UCHAR bit = 1 ; - for ( j = 0 ; j < 3 ; j ++ ) - { - if ( edgemask & bit ) - { - for ( i = 0 ; i < 13 ; i ++ ) - { - LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ; - LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ; - - if ( proj0 > inherit->trigEdgeProj[i][j][1] || - proj1 < inherit->trigEdgeProj[i][j][0] ) - { - edgemask &= ( ~ bit ) ; - break ; - } - } - } - bit <<= 1 ; - } - - /* - if ( edgemask != 0 ) - { - printf("%d %d\n", cedgemask, edgemask) ; - } - */ - - // Test axes for triangle intersection - if ( edgemask ) - { - return 1 ; - } - - for ( i = 3 ; i < 13 ; i ++ ) - { - LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ; - LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ; - - if ( proj0 > inherit->trigProj[i][1] || - proj1 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - - return 1 ; - } - - /** - * Retrieving children masks using PRIMARY AXES - */ - UCHAR getChildrenMasks( UCHAR cvertmask, UCHAR vertmask[8] ) - { - int i, j, k ; - int bmask[3][2] = {{0,0},{0,0},{0,0}} ; - int vmask[3][3][2] = {{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}},{{0,0},{0,0},{0,0}}} ; - UCHAR boxmask = 0 ; - LONG len = cubeProj[0][1] >> 1 ; - - for ( i = 0 ; i < 3 ; i ++ ) - { - LONG mid = cubeProj[i][0] + len ; - - // Check bounding box - if ( mid >= inherit->trigProj[i][0] ) - { - bmask[i][0] = 1 ; - } - if ( mid <= inherit->trigProj[i][1] ) - { - bmask[i][1] = 1 ; - } - - // Check vertex mask - if ( cvertmask ) - { - for ( j = 0 ; j < 3 ; j ++ ) - { - if ( cvertmask & ( 1 << j ) ) - { - // Only check if it's contained this node - if ( mid >= inherit->trigVertProj[i][j] ) - { - vmask[i][j][0] = 1 ; - } - if ( mid <= inherit->trigVertProj[i][j] ) - { - vmask[i][j][1] = 1 ; - } - } - } - } - - /* - // Check edge mask - if ( cedgemask ) - { - for ( j = 0 ; j < 3 ; j ++ ) - { - if ( cedgemask & ( 1 << j ) ) - { - // Only check if it's contained this node - if ( mid >= inherit->trigEdgeProj[i][j][0] ) - { - emask[i][j][0] = 1 ; - } - if ( mid <= inherit->trigEdgeProj[i][j][1] ) - { - emask[i][j][1] = 1 ; - } - } - } - } - */ - - } - - // Fill in masks - int ct = 0 ; - for ( i = 0 ; i < 2 ; i ++ ) - for ( j = 0 ; j < 2 ; j ++ ) - for ( k = 0 ; k < 2 ; k ++ ) - { - boxmask |= ( ( bmask[0][i] & bmask[1][j] & bmask[2][k] ) << ct ) ; - vertmask[ct] = (( vmask[0][0][i] & vmask[1][0][j] & vmask[2][0][k] ) | - (( vmask[0][1][i] & vmask[1][1][j] & vmask[2][1][k] ) << 1 ) | - (( vmask[0][2][i] & vmask[1][2][j] & vmask[2][2][k] ) << 2 ) ) ; - /* - edgemask[ct] = (( emask[0][0][i] & emask[1][0][j] & emask[2][0][k] ) | - (( emask[0][1][i] & emask[1][1][j] & emask[2][1][k] ) << 1 ) | - (( emask[0][2][i] & emask[1][2][j] & emask[2][2][k] ) << 2 ) ) ; - edgemask[ct] = cedgemask ; - */ - ct ++ ; - } - - // Return bounding box masks - return boxmask ; - } - - UCHAR getBoxMask( ) - { - int i, j, k ; - int bmask[3][2] = {{0,0},{0,0},{0,0}} ; - UCHAR boxmask = 0 ; - LONG len = cubeProj[0][1] >> 1 ; - - for ( i = 0 ; i < 3 ; i ++ ) - { - LONG mid = cubeProj[i][0] + len ; - - // Check bounding box - if ( mid >= inherit->trigProj[i][0] ) - { - bmask[i][0] = 1 ; - } - if ( mid <= inherit->trigProj[i][1] ) - { - bmask[i][1] = 1 ; - } - - } - - // Fill in masks - int ct = 0 ; - for ( i = 0 ; i < 2 ; i ++ ) - for ( j = 0 ; j < 2 ; j ++ ) - for ( k = 0 ; k < 2 ; k ++ ) - { - boxmask |= ( ( bmask[0][i] & bmask[1][j] & bmask[2][k] ) << ct ) ; - ct ++ ; - } - - // Return bounding box masks - return boxmask ; - } - - - /** - * Get projections for sub-cubes (simple axes) - */ - void getSubProjectionsSimple( Projections* p[8] ) - { - // Process the axes cooresponding to the triangle's normal - int ind = 3 ; - LONG len = cubeProj[ 0 ][ 1 ] >> 1 ; - LONG trigproj[3] = { cubeProj[ ind ][ 1 ] >> 1, cubeProj[ ind ][ 2 ] >> 1, cubeProj[ ind ][ 3 ] >> 1 } ; - - int ct = 0 ; - for ( int i = 0 ; i < 2 ; i ++ ) - for ( int j = 0 ; j < 2 ; j ++ ) - for ( int k = 0 ; k < 2 ; k ++ ) - { - p[ct] = new Projections( ) ; - p[ct]->inherit = inherit ; - - p[ct]->cubeProj[ 0 ][ 0 ] = cubeProj[ 0 ][ 0 ] + i * len ; - p[ct]->cubeProj[ 1 ][ 0 ] = cubeProj[ 1 ][ 0 ] + j * len ; - p[ct]->cubeProj[ 2 ][ 0 ] = cubeProj[ 2 ][ 0 ] + k * len ; - p[ct]->cubeProj[ 0 ][ 1 ] = len ; - - for ( int m = 1 ; m < 4 ; m ++ ) - { - p[ct]->cubeProj[ ind ][ m ] = trigproj[ m - 1 ] ; - } - p[ct]->cubeProj[ ind ][ 0 ] = cubeProj[ ind ][0] + i * trigproj[0] + j * trigproj[1] + k * trigproj[2] ; - - ct ++ ; - } - } + CubeTriangleIsect(CubeTriangleIsect *parent); + + unsigned char getBoxMask( ); /** * Shifting a cube to a new origin */ - void shift ( int off[3] ) - { - for ( int i = 0 ; i < 13 ; i ++ ) - { - cubeProj[i][0] += off[0] * cubeProj[i][1] + off[1] * cubeProj[i][2] + off[2] * cubeProj[i][3] ; - } - } - - void shiftNoPrimary ( int off[3] ) - { - for ( int i = 3 ; i < 13 ; i ++ ) - { - cubeProj[i][0] += off[0] * cubeProj[i][1] + off[1] * cubeProj[i][2] + off[2] * cubeProj[i][3] ; - } - } + void shift(int off[3]); /** * Method to test intersection of the triangle and the cube */ - int isIntersecting ( ) - { - for ( int i = 0 ; i < 13 ; i ++ ) - { - /* - LONG proj0 = cubeProj[i][0] + - vertmap[inherit->cubeEnds[i][0]][0] * cubeProj[i][1] + - vertmap[inherit->cubeEnds[i][0]][1] * cubeProj[i][2] + - vertmap[inherit->cubeEnds[i][0]][2] * cubeProj[i][3] ; - LONG proj1 = cubeProj[i][0] + - vertmap[inherit->cubeEnds[i][1]][0] * cubeProj[i][1] + - vertmap[inherit->cubeEnds[i][1]][1] * cubeProj[i][2] + - vertmap[inherit->cubeEnds[i][1]][2] * cubeProj[i][3] ; - */ + int isIntersecting() const; - LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ; - LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ; - - if ( proj0 > inherit->trigProj[i][1] || - proj1 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - - return 1 ; - }; - - int isIntersectingNoPrimary ( ) - { - for ( int i = 3 ; i < 13 ; i ++ ) - { - /* - LONG proj0 = cubeProj[i][0] + - vertmap[inherit->cubeEnds[i][0]][0] * cubeProj[i][1] + - vertmap[inherit->cubeEnds[i][0]][1] * cubeProj[i][2] + - vertmap[inherit->cubeEnds[i][0]][2] * cubeProj[i][3] ; - LONG proj1 = cubeProj[i][0] + - vertmap[inherit->cubeEnds[i][1]][0] * cubeProj[i][1] + - vertmap[inherit->cubeEnds[i][1]][1] * cubeProj[i][2] + - vertmap[inherit->cubeEnds[i][1]][2] * cubeProj[i][3] ; - */ - - LONG proj0 = cubeProj[i][0] + cubeProj[i][4] ; - LONG proj1 = cubeProj[i][0] + cubeProj[i][5] ; - - if ( proj0 > inherit->trigProj[i][1] || - proj1 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - - return 1 ; - }; - - /** - * Method to test intersection of the triangle and one edge - */ - int isIntersecting ( int edgeInd ) - { - for ( int i = 0 ; i < 13 ; i ++ ) - { - - LONG proj0 = cubeProj[i][0] + - vertmap[edgemap[edgeInd][0]][0] * cubeProj[i][1] + - vertmap[edgemap[edgeInd][0]][1] * cubeProj[i][2] + - vertmap[edgemap[edgeInd][0]][2] * cubeProj[i][3] ; - LONG proj1 = cubeProj[i][0] + - vertmap[edgemap[edgeInd][1]][0] * cubeProj[i][1] + - vertmap[edgemap[edgeInd][1]][1] * cubeProj[i][2] + - vertmap[edgemap[edgeInd][1]][2] * cubeProj[i][3] ; - - - if ( proj0 < proj1 ) - { - if ( proj0 > inherit->trigProj[i][1] || - proj1 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - else - { - if ( proj1 > inherit->trigProj[i][1] || - proj0 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - } - - // printf( "Intersecting: %d %d\n", edgemap[edgeInd][0], edgemap[edgeInd][1] ) ; - return 1 ; - }; - - /** - * Method to test intersection of one triangle edge and one cube face - */ - int isIntersecting ( int edgeInd, int faceInd ) - { - for ( int i = 0 ; i < 13 ; i ++ ) - { - LONG trigproj0 = inherit->trigVertProj[i][edgeInd] ; - LONG trigproj1 = inherit->trigVertProj[i][(edgeInd+1)%3] ; - - if ( trigproj0 < trigproj1 ) - { - int t1 = 1 , t2 = 1 ; - for ( int j = 0 ; j < 4 ; j ++ ) - { - LONG proj = cubeProj[i][0] + - vertmap[facemap[faceInd][j]][0] * cubeProj[i][1] + - vertmap[facemap[faceInd][j]][1] * cubeProj[i][2] + - vertmap[facemap[faceInd][j]][2] * cubeProj[i][3] ; - if ( proj >= trigproj0 ) - { - t1 = 0 ; - } - if ( proj <= trigproj1 ) - { - t2 = 0 ; - } - } - if ( t1 || t2 ) - { - return 0 ; - } - } - else - { - int t1 = 1 , t2 = 1 ; - for ( int j = 0 ; j < 4 ; j ++ ) - { - LONG proj = cubeProj[i][0] + - vertmap[facemap[faceInd][j]][0] * cubeProj[i][1] + - vertmap[facemap[faceInd][j]][1] * cubeProj[i][2] + - vertmap[facemap[faceInd][j]][2] * cubeProj[i][3] ; - if ( proj >= trigproj1 ) - { - t1 = 0 ; - } - if ( proj <= trigproj0 ) - { - t2 = 0 ; - } - } - if ( t1 || t2 ) - { - return 0 ; - } - } - } - - return 1 ; - }; - - - int isIntersectingPrimary ( int edgeInd ) - { - for ( int i = 0 ; i < 13 ; i ++ ) - { - - LONG proj0 = cubeProj[i][0] ; - LONG proj1 = cubeProj[i][0] + cubeProj[i][edgeInd + 1] ; - - if ( proj0 < proj1 ) - { - if ( proj0 > inherit->trigProj[i][1] || - proj1 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - else - { - if ( proj1 > inherit->trigProj[i][1] || - proj0 < inherit->trigProj[i][0] ) - { - return 0 ; - } - } - - } - - // printf( "Intersecting: %d %d\n", edgemap[edgeInd][0], edgemap[edgeInd][1] ) ; - return 1 ; - }; - - double getIntersection ( int edgeInd ) - { - int i = 3 ; - - LONG proj0 = cubeProj[i][0] + - vertmap[edgemap[edgeInd][0]][0] * cubeProj[i][1] + - vertmap[edgemap[edgeInd][0]][1] * cubeProj[i][2] + - vertmap[edgemap[edgeInd][0]][2] * cubeProj[i][3] ; - LONG proj1 = cubeProj[i][0] + - vertmap[edgemap[edgeInd][1]][0] * cubeProj[i][1] + - vertmap[edgemap[edgeInd][1]][1] * cubeProj[i][2] + - vertmap[edgemap[edgeInd][1]][2] * cubeProj[i][3] ; - LONG proj2 = inherit->trigProj[i][1] ; - - /* - if ( proj0 < proj1 ) - { - if ( proj2 < proj0 || proj2 > proj1 ) - { - return -1 ; - } - } - else - { - if ( proj2 < proj1 || proj2 > proj0 ) - { - return -1 ; - } - } - */ - - double alpha = (double)( proj2 - proj0 ) / (double)( proj1 - proj0 ) ; - /* - if ( alpha < 0 ) - { - alpha = 0.5 ; - } - else if ( alpha > 1 ) - { - alpha = 0.5 ; - } - */ - - return alpha ; - }; - - float getIntersectionPrimary ( int edgeInd ) - { - int i = 3 ; - - - LONG proj0 = cubeProj[i][0] ; - LONG proj1 = cubeProj[i][0] + cubeProj[i][edgeInd + 1] ; - LONG proj2 = inherit->trigProj[i][1] ; - - // double alpha = (double)( ( proj2 - proj0 ) * cubeProj[edgeInd][edgeInd + 1] ) / (double)( proj1 - proj0 ) ; - double alpha = (double)( ( proj2 - proj0 ) ) / (double)( proj1 - proj0 ) ; - - if ( alpha < 0 ) - { - alpha = 0.5 ; - } - else if ( alpha > 1 ) - { - alpha = 0.5 ; - } - - - return (float)alpha ; - }; - - /** - * Method to perform cross-product - */ - void crossProduct ( LONG a[3], LONG b[3], LONG res[3] ) - { - res[0] = a[1] * b[2] - a[2] * b[1] ; - res[1] = a[2] * b[0] - a[0] * b[2] ; - res[2] = a[0] * b[1] - a[1] * b[0] ; - } - void crossProduct ( double a[3], double b[3], double res[3] ) - { - res[0] = a[1] * b[2] - a[2] * b[1] ; - res[1] = a[2] * b[0] - a[0] * b[2] ; - res[2] = a[0] * b[1] - a[1] * b[0] ; - } - - /** - * Method to perform dot product - */ - LONG dotProduct ( LONG a[3], LONG b[3] ) - { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] ; - } - - void normalize( double a[3] ) - { - double mag = a[0] * a[0] + a[1] * a[1] + a[2] * a[2] ; - if ( mag > 0 ) - { - mag = sqrt( mag ) ; - a[0] /= mag ; - a[1] /= mag ; - a[2] /= mag ; - } - } + int isIntersectingPrimary(int edgeInd) const; + float getIntersectionPrimary(int edgeInd) const; }; #endif diff --git a/intern/dualcon/intern/Queue.h b/intern/dualcon/intern/Queue.h index 61d7e2af2e8..a2b5b46c72c 100644 --- a/intern/dualcon/intern/Queue.h +++ b/intern/dualcon/intern/Queue.h @@ -23,83 +23,81 @@ #ifndef QUEUE_H #define QUEUE_H -struct gridQueueEle -{ +struct gridQueueEle { int x, y, z; - UCHAR dir ; - gridQueueEle* next ; + UCHAR dir; + gridQueueEle *next; }; class GridQueue { - gridQueueEle* head ; - gridQueueEle* tail ; - int numEles ; +gridQueueEle *head; +gridQueueEle *tail; +int numEles; public: - GridQueue( ) +GridQueue( ) +{ + head = NULL; + tail = NULL; + numEles = 0; +} + +gridQueueEle *getHead( ) +{ + return head; +} + +int getNumElements( ) +{ + return numEles; +} + + +void pushQueue(int st[3], int dir) +{ + gridQueueEle *ele = new gridQueueEle; + ele->x = st[0]; + ele->y = st[1]; + ele->z = st[2]; + ele->dir = (UCHAR) dir; + ele->next = NULL; + if (head == NULL) { - head = NULL ; - tail = NULL ; - numEles = 0 ; + head = ele; + } + else { + tail->next = ele; + } + tail = ele; + numEles++; +} + +int popQueue(int st[3], int& dir) +{ + if (head == NULL) + { + return 0; } - gridQueueEle* getHead( ) + st[0] = head->x; + st[1] = head->y; + st[2] = head->z; + dir = (int) (head->dir); + + gridQueueEle *temp = head; + head = head->next; + delete temp; + + if (head == NULL) { - return head ; + tail = NULL; } + numEles--; - int getNumElements( ) - { - return numEles ; - } - - - void pushQueue( int st[3], int dir ) - { - gridQueueEle* ele = new gridQueueEle ; - ele->x = st[0] ; - ele->y = st[1] ; - ele->z = st[2] ; - ele->dir = (UCHAR) dir ; - ele->next = NULL ; - if ( head == NULL ) - { - head = ele ; - } - else - { - tail->next = ele ; - } - tail = ele ; - numEles ++ ; - } - - int popQueue( int st[3], int& dir ) - { - if ( head == NULL ) - { - return 0 ; - } - - st[0] = head->x ; - st[1] = head->y ; - st[2] = head->z ; - dir = (int) (head->dir) ; - - gridQueueEle* temp = head ; - head = head->next ; - delete temp ; - - if ( head == NULL ) - { - tail = NULL ; - } - numEles -- ; - - return 1 ; - } + return 1; +} }; diff --git a/intern/dualcon/intern/cubes.h b/intern/dualcon/intern/cubes.h index 0cdd791a649..8b5125e261a 100644 --- a/intern/dualcon/intern/cubes.h +++ b/intern/dualcon/intern/cubes.h @@ -29,18 +29,18 @@ class Cubes { public: - /// Get number of triangles - int getNumTriangle(int mask) - { - return marching_cubes_numtri[mask]; - } +/// Get number of triangles +int getNumTriangle(int mask) +{ + return marching_cubes_numtri[mask]; +} - /// Get a triangle - void getTriangle(int mask, int index, int indices[3] ) - { - for(int i = 0; i < 3; i++) - indices[i] = marching_cubes_tris[mask][index][i]; - } +/// Get a triangle +void getTriangle(int mask, int index, int indices[3]) +{ + for (int i = 0; i < 3; i++) + indices[i] = marching_cubes_tris[mask][index][i]; +} }; #endif diff --git a/intern/dualcon/intern/dualcon_c_api.cpp b/intern/dualcon/intern/dualcon_c_api.cpp index af5ada71146..894ab6b0873 100644 --- a/intern/dualcon/intern/dualcon_c_api.cpp +++ b/intern/dualcon/intern/dualcon_c_api.cpp @@ -40,166 +40,169 @@ void veccopy(float dst[3], const float src[3]) } #define GET_FACE(_mesh, _n) \ - (*(DualConFaces)(((char*)(_mesh)->faces) + ((_n) * (_mesh)->face_stride))) + (*(DualConFaces)(((char *)(_mesh)->faces) + ((_n) * (_mesh)->face_stride))) #define GET_CO(_mesh, _n) \ - (*(DualConCo)(((char*)(_mesh)->co) + ((_n) * (_mesh)->co_stride))) + (*(DualConCo)(((char *)(_mesh)->co) + ((_n) * (_mesh)->co_stride))) class DualConInputReader : public ModelReader { private: - const DualConInput *input_mesh; - int tottri, curface, offset; - float min[3], max[3], maxsize; - float scale; +const DualConInput *input_mesh; +int tottri, curface, offset; +float min[3], max[3], maxsize; +float scale; public: - DualConInputReader(const DualConInput *mesh, float _scale) +DualConInputReader(const DualConInput *mesh, float _scale) : input_mesh(mesh), scale(_scale) - { - reset(); +{ + reset(); +} + +void reset() +{ + tottri = 0; + curface = 0; + offset = 0; + maxsize = 0; + + /* initialize tottri */ + for (int i = 0; i < input_mesh->totface; i++) + tottri += GET_FACE(input_mesh, i)[3] ? 2 : 1; + + veccopy(min, input_mesh->min); + veccopy(max, input_mesh->max); + + /* initialize maxsize */ + for (int i = 0; i < 3; i++) { + float d = max[i] - min[i]; + if (d > maxsize) + maxsize = d; } - void reset() + /* redo the bounds */ + for (int i = 0; i < 3; i++) { - tottri = 0; - curface = 0; + min[i] = (max[i] + min[i]) / 2 - maxsize / 2; + max[i] = (max[i] + min[i]) / 2 + maxsize / 2; + } + + for (int i = 0; i < 3; i++) + min[i] -= maxsize * (1 / scale - 1) / 2; + maxsize *= 1 / scale; +} + +Triangle *getNextTriangle() +{ + if (curface == input_mesh->totface) + return 0; + + Triangle *t = new Triangle(); + + unsigned int *f = GET_FACE(input_mesh, curface); + if (offset == 0) { + veccopy(t->vt[0], GET_CO(input_mesh, f[0])); + veccopy(t->vt[1], GET_CO(input_mesh, f[1])); + veccopy(t->vt[2], GET_CO(input_mesh, f[2])); + } + else { + veccopy(t->vt[0], GET_CO(input_mesh, f[2])); + veccopy(t->vt[1], GET_CO(input_mesh, f[3])); + veccopy(t->vt[2], GET_CO(input_mesh, f[0])); + } + + if (offset == 0 && f[3]) + offset++; + else { offset = 0; - maxsize = 0; - - /* initialize tottri */ - for(int i = 0; i < input_mesh->totface; i++) - tottri += GET_FACE(input_mesh, i)[3] ? 2 : 1; - - veccopy(min, input_mesh->min); - veccopy(max, input_mesh->max); - - /* initialize maxsize */ - for(int i = 0; i < 3; i++) { - float d = max[i] - min[i]; - if(d > maxsize) - maxsize = d; - } - - /* redo the bounds */ - for(int i = 0; i < 3; i++) - { - min[i] = (max[i] + min[i]) / 2 - maxsize / 2; - max[i] = (max[i] + min[i]) / 2 + maxsize / 2; - } - - for(int i = 0; i < 3; i++) - min[i] -= maxsize * (1 / scale - 1) / 2; - maxsize *= 1 / scale; + curface++; } - Triangle* getNextTriangle() - { - if(curface == input_mesh->totface) - return 0; - - Triangle* t = new Triangle(); - - unsigned int *f = GET_FACE(input_mesh, curface); - if(offset == 0) { - veccopy(t->vt[0], GET_CO(input_mesh, f[0])); - veccopy(t->vt[1], GET_CO(input_mesh, f[1])); - veccopy(t->vt[2], GET_CO(input_mesh, f[2])); + /* remove triangle if it contains invalid coords */ + for (int i = 0; i < 3; i++) { + const float *co = t->vt[i]; + if (isnan(co[0]) || isnan(co[1]) || isnan(co[2])) { + delete t; + return getNextTriangle(); } - else { - veccopy(t->vt[0], GET_CO(input_mesh, f[2])); - veccopy(t->vt[1], GET_CO(input_mesh, f[3])); - veccopy(t->vt[2], GET_CO(input_mesh, f[0])); - } - - if(offset == 0 && f[3]) - offset++; - else { - offset = 0; - curface++; - } - - /* remove triangle if it contains invalid coords */ - for(int i = 0; i < 3; i++) { - const float *co = t->vt[i]; - if(isnan(co[0]) || isnan(co[1]) || isnan(co[2])) { - delete t; - return getNextTriangle(); - } - } - - return t; } - int getNextTriangle(int t[3]) - { - if(curface == input_mesh->totface) - return 0; - - unsigned int *f = GET_FACE(input_mesh, curface); - if(offset == 0) { - t[0] = f[0]; - t[1] = f[1]; - t[2] = f[2]; - } - else { - t[0] = f[2]; - t[1] = f[3]; - t[2] = f[0]; - } + return t; +} - if(offset == 0 && f[3]) - offset++; - else { - offset = 0; - curface++; - } +int getNextTriangle(int t[3]) +{ + if (curface == input_mesh->totface) + return 0; - return 1; + unsigned int *f = GET_FACE(input_mesh, curface); + if (offset == 0) { + t[0] = f[0]; + t[1] = f[1]; + t[2] = f[2]; + } + else { + t[0] = f[2]; + t[1] = f[3]; + t[2] = f[0]; } - int getNumTriangles() - { - return tottri; + if (offset == 0 && f[3]) + offset++; + else { + offset = 0; + curface++; } - int getNumVertices() - { - return input_mesh->totco; - } + return 1; +} - float getBoundingBox(float origin[3]) - { - veccopy(origin, min); - return maxsize ; - } +int getNumTriangles() +{ + return tottri; +} - /* output */ - void getNextVertex(float v[3]) - { - /* not used */ - } +int getNumVertices() +{ + return input_mesh->totco; +} - /* stubs */ - void printInfo() {} - int getMemory() { return sizeof(DualConInputReader); } +float getBoundingBox(float origin[3]) +{ + veccopy(origin, min); + return maxsize; +} + +/* output */ +void getNextVertex(float v[3]) +{ + /* not used */ +} + +/* stubs */ +void printInfo() { +} +int getMemory() { + return sizeof(DualConInputReader); +} }; void *dualcon(const DualConInput *input_mesh, - /* callbacks for output */ - DualConAllocOutput alloc_output, - DualConAddVert add_vert, - DualConAddQuad add_quad, - - DualConFlags flags, - DualConMode mode, - float threshold, - float hermite_num, - float scale, - int depth) + /* callbacks for output */ + DualConAllocOutput alloc_output, + DualConAddVert add_vert, + DualConAddQuad add_quad, + + DualConFlags flags, + DualConMode mode, + float threshold, + float hermite_num, + float scale, + int depth) { DualConInputReader r(input_mesh, scale); Octree o(&r, alloc_output, add_vert, add_quad, - flags, mode, depth, threshold, hermite_num); + flags, mode, depth, threshold, hermite_num); o.scanConvert(); return o.getOutputMesh(); } diff --git a/intern/dualcon/intern/marching_cubes_table.cpp b/intern/dualcon/intern/marching_cubes_table.cpp index 4c78108deb5..012757e8a25 100644 --- a/intern/dualcon/intern/marching_cubes_table.cpp +++ b/intern/dualcon/intern/marching_cubes_table.cpp @@ -39,516 +39,516 @@ const int marching_cubes_numtri[TOTCONF] = { /* table of triangles in each configuration */ const int marching_cubes_tris[TOTCONF][MAX_TRIS][3] = { - {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,8}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,1,5}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,1}, {4,1,5}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,9,2}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,8,9}, {0,9,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,5,9}, {1,9,2}, {1,2,4}, {1,4,8}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,1,5}, {0,5,9}, {0,9,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,3,9}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,8,5}, {0,5,3}, {0,3,9}, {0,9,4}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,1,3}, {8,3,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,1}, {4,1,3}, {4,3,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,5,3}, {4,3,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,8,5}, {0,5,3}, {0,3,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,1}, {4,1,3}, {4,3,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,1,3}, {0,3,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,6,10}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,4,6}, {8,6,10}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,10,1}, {6,1,5}, {6,5,8}, {6,8,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,6,10}, {4,10,1}, {4,1,5}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,4}, {10,4,9}, {10,9,2}, {10,2,6}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,10,8}, {6,8,9}, {6,9,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {6,10,1}, {6,1,5}, {6,5,9}, {6,9,2}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,10,1}, {6,1,5}, {6,5,9}, {6,9,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,5}, {0,6,9}, {9,5,0}, {6,10,3}, {5,3,10}, - {3,9,6}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,5}, {10,5,3}, {9,4,6}, {6,10,3}, {6,3,9}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,3}, {9,8,0}, {9,0,6}, {6,10,3}, {6,3,9}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,6,10}, {4,10,1}, {4,1,3}, {4,3,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,4,5}, {3,2,6}, {3,6,10}, {10,0,5}, {10,5,3}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,10,8}, {6,8,5}, {6,5,3}, {6,3,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {6,10,1}, {6,1,3}, {6,3,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,10,1}, {6,1,3}, {6,3,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,7,1}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,10}, {4,10,7}, {4,7,1}, {4,1,8}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,10,7}, {8,7,5}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,10}, {4,10,7}, {4,7,5}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,2,4}, {10,4,1}, {7,2,10}, {1,9,7}, {1,4,9}, - {9,2,7}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,8,9}, {2,0,10}, {2,10,7}, {7,1,9}, {7,9,2}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {7,5,9}, {7,9,2}, {2,4,10}, {2,10,7}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,7}, {0,7,5}, {0,5,9}, {0,9,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,7,3}, {10,3,9}, {10,9,5}, {10,5,1}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {4,0,10}, {4,10,7}, {4,7,3}, {4,3,9}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,10,7}, {8,7,3}, {8,3,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,10}, {4,10,7}, {4,7,3}, {4,3,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,5,1}, {4,1,10}, {7,3,2}, {2,4,10}, {2,10,7}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {0,10,7}, {0,7,3}, {0,3,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {4,10,7}, {4,7,3}, {4,3,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,7}, {0,7,3}, {0,3,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,6,7}, {0,7,1}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,4,6}, {8,6,7}, {8,7,1}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,6}, {8,6,7}, {8,7,5}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,6,7}, {4,7,5}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,0,4}, {1,4,9}, {2,6,7}, {7,1,9}, {7,9,2}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,7,1}, {6,1,8}, {6,8,9}, {6,9,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {6,7,5}, {6,5,9}, {6,9,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,7,5}, {6,5,9}, {6,9,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,0}, {6,7,3}, {6,3,9}, {9,5,0}, {9,0,6}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {4,6,7}, {4,7,3}, {4,3,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,6}, {8,6,7}, {8,7,3}, {8,3,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,6,7}, {4,7,3}, {4,3,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,4,5}, {0,5,1}, {6,7,3}, {6,3,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {6,7,3}, {6,3,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {6,7,3}, {6,3,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,7,3}, {6,3,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,2,11}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,4,2}, {8,2,11}, {8,11,6}, {8,6,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,1,6}, {6,1,11}, {11,1,5}, {2,11,5}, {2,5,8}, - {6,2,8}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {5,4,2}, {5,2,11}, {11,6,1}, {11,1,5}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,9}, {6,9,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,8}, {6,8,9}, {6,9,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,8}, {6,8,1}, {5,9,11}, {11,6,1}, {11,1,5}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {6,1,5}, {6,5,9}, {6,9,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,2,9}, {6,9,5}, {6,5,3}, {6,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,2,9}, {6,0,8}, {6,8,5}, {6,5,3}, {6,3,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{2,9,8}, {1,3,11}, {1,11,6}, {6,2,8}, {6,8,1}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,2,9}, {6,0,1}, {6,1,3}, {6,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,5}, {6,5,3}, {6,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,8}, {6,8,5}, {6,5,3}, {6,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,8}, {6,8,1}, {6,1,3}, {6,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {6,1,3}, {6,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,2}, {10,2,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,4}, {10,4,2}, {10,2,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,2}, {11,10,1}, {11,1,5}, {5,8,2}, {5,2,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,5}, {10,5,4}, {10,4,2}, {10,2,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,4}, {10,4,9}, {10,9,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,9}, {10,9,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {10,1,5}, {10,5,9}, {10,9,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,5}, {10,5,9}, {10,9,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,2,9}, {0,9,5}, {3,11,10}, {10,0,5}, {10,5,3}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,2,9}, {10,8,5}, {10,5,3}, {10,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,2}, {8,2,9}, {10,1,3}, {10,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,2,9}, {10,1,3}, {10,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,4}, {10,4,5}, {10,5,3}, {10,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,5}, {10,5,3}, {10,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {10,1,3}, {10,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,3}, {10,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,10,6}, {1,6,2}, {1,2,11}, {1,11,7}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {7,1,8}, {7,8,4}, {7,4,2}, {7,2,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,10,6}, {8,6,2}, {11,7,5}, {5,8,2}, {5,2,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {7,5,4}, {7,4,2}, {7,2,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,6,4}, {9,11,7}, {9,7,1}, {1,10,4}, {1,4,9}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {7,1,8}, {7,8,9}, {7,9,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {4,10,6}, {7,5,9}, {7,9,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {7,5,9}, {7,9,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,10}, {5,10,6}, {5,6,2}, {5,2,9}, {7,3,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {8,5,1}, {4,2,9}, {7,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,10,6}, {8,6,2}, {8,2,9}, {7,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {4,2,9}, {7,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,6,4}, {10,4,5}, {10,5,1}, {7,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {8,5,1}, {7,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {4,10,6}, {7,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,1,0}, {7,0,2}, {7,2,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,1,8}, {7,8,4}, {7,4,2}, {7,2,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,5,8}, {7,8,0}, {7,0,2}, {7,2,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,5,4}, {7,4,2}, {7,2,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,1,0}, {7,0,4}, {7,4,9}, {7,9,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,1,8}, {7,8,9}, {7,9,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {7,5,9}, {7,9,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,5,9}, {7,9,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,0}, {5,0,2}, {5,2,9}, {7,3,11}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {4,2,9}, {7,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,2}, {8,2,9}, {7,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,2,9}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,4,5}, {0,5,1}, {7,3,11}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {7,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,3,11}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,11,3}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,11,0}, {7,0,8}, {0,11,4}, {8,3,7}, {11,3,4}, - {3,8,4}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,1,7}, {8,7,11}, {8,11,3}, {8,3,5}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,1,7}, {0,7,11}, {3,5,4}, {4,0,11}, {4,11,3}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,9,3}, {4,3,7}, {4,7,11}, {4,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,9,3}, {8,3,7}, {11,2,0}, {0,8,7}, {0,7,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,9,3}, {4,8,1}, {4,1,7}, {4,7,11}, {4,11,2}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,9,3}, {0,1,7}, {0,7,11}, {0,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,7,11}, {5,11,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,7}, {11,9,4}, {11,4,0}, {0,8,7}, {0,7,11}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,1,7}, {8,7,11}, {8,11,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,1}, {4,1,7}, {4,7,11}, {4,11,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,5,7}, {4,7,11}, {4,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,8,5}, {0,5,7}, {0,7,11}, {0,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,1}, {4,1,7}, {4,7,11}, {4,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,1,7}, {0,7,11}, {0,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,6,11}, {0,11,3}, {0,3,7}, {0,7,10}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,8}, {4,6,11}, {4,11,3}, {3,7,8}, {3,8,4}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {5,8,0}, {5,0,6}, {5,6,11}, {5,11,3}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {5,4,6}, {5,6,11}, {5,11,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,0}, {7,0,4}, {7,4,9}, {7,9,3}, {6,11,2}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,8}, {7,8,9}, {7,9,3}, {6,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {10,1,7}, {5,9,3}, {6,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {5,9,3}, {6,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,7,10}, {5,10,0}, {6,11,9}, {9,5,0}, {9,0,6}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,5}, {10,5,7}, {4,6,11}, {4,11,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {8,0,6}, {8,6,11}, {8,11,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {4,6,11}, {4,11,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,4}, {10,4,5}, {10,5,7}, {6,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,5}, {10,5,7}, {6,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {10,1,7}, {6,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,10,11}, {1,11,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,11}, {3,1,8}, {3,8,4}, {4,0,11}, {4,11,3}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,8,10}, {5,10,11}, {5,11,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,4,0}, {5,0,10}, {5,10,11}, {5,11,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{9,3,1}, {10,11,2}, {10,2,4}, {4,9,1}, {4,1,10}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,8,9}, {1,9,3}, {0,10,11}, {0,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,9,3}, {4,8,10}, {4,10,11}, {4,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,9,3}, {0,10,11}, {0,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,10}, {5,10,11}, {5,11,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {4,0,10}, {4,10,11}, {4,11,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,10,11}, {8,11,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,0,10}, {4,10,11}, {4,11,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,5,1}, {4,1,10}, {4,10,11}, {4,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {0,10,11}, {0,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {4,10,11}, {4,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,11}, {0,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,0,6}, {1,6,11}, {1,11,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,8,4}, {1,4,6}, {1,6,11}, {1,11,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,8,0}, {5,0,6}, {5,6,11}, {5,11,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,4,6}, {5,6,11}, {5,11,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,0,4}, {1,4,9}, {1,9,3}, {6,11,2}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,8,9}, {1,9,3}, {6,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {5,9,3}, {6,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,9,3}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,0}, {5,0,6}, {5,6,11}, {5,11,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {4,6,11}, {4,11,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,6}, {8,6,11}, {8,11,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,6,11}, {4,11,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,4,5}, {0,5,1}, {6,11,2}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {6,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,11,2}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,6,2}, {7,2,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,6,0}, {7,0,8}, {4,2,3}, {3,7,8}, {3,8,4}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,7,6}, {2,3,5}, {2,5,8}, {8,1,6}, {8,6,2}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {6,1,7}, {5,4,2}, {5,2,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,6,4}, {7,4,9}, {7,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,6,0}, {7,0,8}, {7,8,9}, {7,9,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,8}, {6,8,1}, {6,1,7}, {5,9,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {6,1,7}, {5,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,7,6}, {5,6,2}, {5,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,8}, {6,8,5}, {6,5,7}, {4,2,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,1,7}, {8,7,6}, {8,6,2}, {8,2,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {6,1,7}, {4,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,5}, {6,5,7}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,8}, {6,8,5}, {6,5,7}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,4,8}, {6,8,1}, {6,1,7}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{6,0,1}, {6,1,7}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,0}, {7,0,2}, {7,2,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,8}, {7,8,4}, {7,4,2}, {7,2,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {5,8,0}, {5,0,2}, {5,2,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {5,4,2}, {5,2,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,0}, {7,0,4}, {7,4,9}, {7,9,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{7,10,8}, {7,8,9}, {7,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {10,1,7}, {5,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {5,9,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,7,10}, {5,10,0}, {5,0,2}, {5,2,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,5}, {10,5,7}, {4,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {8,0,2}, {8,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {4,2,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,0,4}, {10,4,5}, {10,5,7}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,8,5}, {10,5,7}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {10,1,7}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,1,7}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,10,6}, {1,6,2}, {1,2,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {1,8,4}, {1,4,2}, {1,2,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,8,10}, {5,10,6}, {5,6,2}, {5,2,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {5,4,2}, {5,2,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,10,6}, {1,6,4}, {1,4,9}, {1,9,3}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {1,8,9}, {1,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {4,10,6}, {5,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {5,9,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,10}, {5,10,6}, {5,6,2}, {5,2,9}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {8,5,1}, {4,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,10,6}, {8,6,2}, {8,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {4,2,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{10,6,4}, {10,4,5}, {10,5,1}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {8,5,1}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,10}, {4,10,6}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,10,6}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,0,2}, {1,2,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,8,4}, {1,4,2}, {1,2,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,8,0}, {5,0,2}, {5,2,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,4,2}, {5,2,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,0,4}, {1,4,9}, {1,9,3}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{1,8,9}, {1,9,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {5,9,3}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,9,3}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{5,1,0}, {5,0,2}, {5,2,9}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {4,2,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,0,2}, {8,2,9}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,2,9}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,4,5}, {0,5,1}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{8,5,1}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{4,8,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}}, - {{0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, - {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}} + {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 8}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 1, 5}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 1}, {4, 1, 5}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 9, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 8, 9}, {0, 9, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 5, 9}, {1, 9, 2}, {1, 2, 4}, {1, 4, 8}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 1, 5}, {0, 5, 9}, {0, 9, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 3, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 8, 5}, {0, 5, 3}, {0, 3, 9}, {0, 9, 4}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 1, 3}, {8, 3, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 1}, {4, 1, 3}, {4, 3, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 5, 3}, {4, 3, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 8, 5}, {0, 5, 3}, {0, 3, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 1}, {4, 1, 3}, {4, 3, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 1, 3}, {0, 3, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 6, 10}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 4, 6}, {8, 6, 10}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 10, 1}, {6, 1, 5}, {6, 5, 8}, {6, 8, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 6, 10}, {4, 10, 1}, {4, 1, 5}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 4}, {10, 4, 9}, {10, 9, 2}, {10, 2, 6}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 10, 8}, {6, 8, 9}, {6, 9, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {6, 10, 1}, {6, 1, 5}, {6, 5, 9}, {6, 9, 2}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 10, 1}, {6, 1, 5}, {6, 5, 9}, {6, 9, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 5}, {0, 6, 9}, {9, 5, 0}, {6, 10, 3}, {5, 3, 10}, + {3, 9, 6}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 5}, {10, 5, 3}, {9, 4, 6}, {6, 10, 3}, {6, 3, 9}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 3}, {9, 8, 0}, {9, 0, 6}, {6, 10, 3}, {6, 3, 9}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 6, 10}, {4, 10, 1}, {4, 1, 3}, {4, 3, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 4, 5}, {3, 2, 6}, {3, 6, 10}, {10, 0, 5}, {10, 5, 3}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 10, 8}, {6, 8, 5}, {6, 5, 3}, {6, 3, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {6, 10, 1}, {6, 1, 3}, {6, 3, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 10, 1}, {6, 1, 3}, {6, 3, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 7, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 10}, {4, 10, 7}, {4, 7, 1}, {4, 1, 8}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 10, 7}, {8, 7, 5}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 10}, {4, 10, 7}, {4, 7, 5}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 2, 4}, {10, 4, 1}, {7, 2, 10}, {1, 9, 7}, {1, 4, 9}, + {9, 2, 7}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 8, 9}, {2, 0, 10}, {2, 10, 7}, {7, 1, 9}, {7, 9, 2}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {7, 5, 9}, {7, 9, 2}, {2, 4, 10}, {2, 10, 7}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 7}, {0, 7, 5}, {0, 5, 9}, {0, 9, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 7, 3}, {10, 3, 9}, {10, 9, 5}, {10, 5, 1}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {4, 0, 10}, {4, 10, 7}, {4, 7, 3}, {4, 3, 9}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 10, 7}, {8, 7, 3}, {8, 3, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 10}, {4, 10, 7}, {4, 7, 3}, {4, 3, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 5, 1}, {4, 1, 10}, {7, 3, 2}, {2, 4, 10}, {2, 10, 7}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {0, 10, 7}, {0, 7, 3}, {0, 3, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {4, 10, 7}, {4, 7, 3}, {4, 3, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 7}, {0, 7, 3}, {0, 3, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 6, 7}, {0, 7, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 4, 6}, {8, 6, 7}, {8, 7, 1}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 6}, {8, 6, 7}, {8, 7, 5}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 6, 7}, {4, 7, 5}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 0, 4}, {1, 4, 9}, {2, 6, 7}, {7, 1, 9}, {7, 9, 2}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 7, 1}, {6, 1, 8}, {6, 8, 9}, {6, 9, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {6, 7, 5}, {6, 5, 9}, {6, 9, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 7, 5}, {6, 5, 9}, {6, 9, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 0}, {6, 7, 3}, {6, 3, 9}, {9, 5, 0}, {9, 0, 6}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {4, 6, 7}, {4, 7, 3}, {4, 3, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 6}, {8, 6, 7}, {8, 7, 3}, {8, 3, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 6, 7}, {4, 7, 3}, {4, 3, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 4, 5}, {0, 5, 1}, {6, 7, 3}, {6, 3, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {6, 7, 3}, {6, 3, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {6, 7, 3}, {6, 3, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 7, 3}, {6, 3, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 2, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 4, 2}, {8, 2, 11}, {8, 11, 6}, {8, 6, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 1, 6}, {6, 1, 11}, {11, 1, 5}, {2, 11, 5}, {2, 5, 8}, + {6, 2, 8}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {5, 4, 2}, {5, 2, 11}, {11, 6, 1}, {11, 1, 5}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 9}, {6, 9, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 8}, {6, 8, 9}, {6, 9, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 8}, {6, 8, 1}, {5, 9, 11}, {11, 6, 1}, {11, 1, 5}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {6, 1, 5}, {6, 5, 9}, {6, 9, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 2, 9}, {6, 9, 5}, {6, 5, 3}, {6, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 2, 9}, {6, 0, 8}, {6, 8, 5}, {6, 5, 3}, {6, 3, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{2, 9, 8}, {1, 3, 11}, {1, 11, 6}, {6, 2, 8}, {6, 8, 1}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 2, 9}, {6, 0, 1}, {6, 1, 3}, {6, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 5}, {6, 5, 3}, {6, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 8}, {6, 8, 5}, {6, 5, 3}, {6, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 8}, {6, 8, 1}, {6, 1, 3}, {6, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {6, 1, 3}, {6, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 2}, {10, 2, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 4}, {10, 4, 2}, {10, 2, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 2}, {11, 10, 1}, {11, 1, 5}, {5, 8, 2}, {5, 2, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 5}, {10, 5, 4}, {10, 4, 2}, {10, 2, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 4}, {10, 4, 9}, {10, 9, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 9}, {10, 9, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {10, 1, 5}, {10, 5, 9}, {10, 9, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 5}, {10, 5, 9}, {10, 9, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 2, 9}, {0, 9, 5}, {3, 11, 10}, {10, 0, 5}, {10, 5, 3}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 2, 9}, {10, 8, 5}, {10, 5, 3}, {10, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 2}, {8, 2, 9}, {10, 1, 3}, {10, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 2, 9}, {10, 1, 3}, {10, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 4}, {10, 4, 5}, {10, 5, 3}, {10, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 5}, {10, 5, 3}, {10, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {10, 1, 3}, {10, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 3}, {10, 3, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 10, 6}, {1, 6, 2}, {1, 2, 11}, {1, 11, 7}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {7, 1, 8}, {7, 8, 4}, {7, 4, 2}, {7, 2, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 10, 6}, {8, 6, 2}, {11, 7, 5}, {5, 8, 2}, {5, 2, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {7, 5, 4}, {7, 4, 2}, {7, 2, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 6, 4}, {9, 11, 7}, {9, 7, 1}, {1, 10, 4}, {1, 4, 9}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {7, 1, 8}, {7, 8, 9}, {7, 9, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {4, 10, 6}, {7, 5, 9}, {7, 9, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {7, 5, 9}, {7, 9, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 10}, {5, 10, 6}, {5, 6, 2}, {5, 2, 9}, {7, 3, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {8, 5, 1}, {4, 2, 9}, {7, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 10, 6}, {8, 6, 2}, {8, 2, 9}, {7, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {4, 2, 9}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 6, 4}, {10, 4, 5}, {10, 5, 1}, {7, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {8, 5, 1}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {4, 10, 6}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 1, 0}, {7, 0, 2}, {7, 2, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 1, 8}, {7, 8, 4}, {7, 4, 2}, {7, 2, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 5, 8}, {7, 8, 0}, {7, 0, 2}, {7, 2, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 5, 4}, {7, 4, 2}, {7, 2, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 1, 0}, {7, 0, 4}, {7, 4, 9}, {7, 9, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 1, 8}, {7, 8, 9}, {7, 9, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {7, 5, 9}, {7, 9, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 5, 9}, {7, 9, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 0}, {5, 0, 2}, {5, 2, 9}, {7, 3, 11}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {4, 2, 9}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 2}, {8, 2, 9}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 2, 9}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 4, 5}, {0, 5, 1}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {7, 3, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 3, 11}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 11, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 11, 0}, {7, 0, 8}, {0, 11, 4}, {8, 3, 7}, {11, 3, 4}, + {3, 8, 4}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 1, 7}, {8, 7, 11}, {8, 11, 3}, {8, 3, 5}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 1, 7}, {0, 7, 11}, {3, 5, 4}, {4, 0, 11}, {4, 11, 3}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 9, 3}, {4, 3, 7}, {4, 7, 11}, {4, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 9, 3}, {8, 3, 7}, {11, 2, 0}, {0, 8, 7}, {0, 7, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 9, 3}, {4, 8, 1}, {4, 1, 7}, {4, 7, 11}, {4, 11, 2}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 9, 3}, {0, 1, 7}, {0, 7, 11}, {0, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 7, 11}, {5, 11, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 7}, {11, 9, 4}, {11, 4, 0}, {0, 8, 7}, {0, 7, 11}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 1, 7}, {8, 7, 11}, {8, 11, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 1}, {4, 1, 7}, {4, 7, 11}, {4, 11, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 5, 7}, {4, 7, 11}, {4, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 8, 5}, {0, 5, 7}, {0, 7, 11}, {0, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 1}, {4, 1, 7}, {4, 7, 11}, {4, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 1, 7}, {0, 7, 11}, {0, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 6, 11}, {0, 11, 3}, {0, 3, 7}, {0, 7, 10}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 8}, {4, 6, 11}, {4, 11, 3}, {3, 7, 8}, {3, 8, 4}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {5, 8, 0}, {5, 0, 6}, {5, 6, 11}, {5, 11, 3}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {5, 4, 6}, {5, 6, 11}, {5, 11, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 0}, {7, 0, 4}, {7, 4, 9}, {7, 9, 3}, {6, 11, 2}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 8}, {7, 8, 9}, {7, 9, 3}, {6, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {10, 1, 7}, {5, 9, 3}, {6, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {5, 9, 3}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 7, 10}, {5, 10, 0}, {6, 11, 9}, {9, 5, 0}, {9, 0, 6}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 5}, {10, 5, 7}, {4, 6, 11}, {4, 11, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {8, 0, 6}, {8, 6, 11}, {8, 11, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {4, 6, 11}, {4, 11, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 4}, {10, 4, 5}, {10, 5, 7}, {6, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 5}, {10, 5, 7}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {10, 1, 7}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 10, 11}, {1, 11, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 11}, {3, 1, 8}, {3, 8, 4}, {4, 0, 11}, {4, 11, 3}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 8, 10}, {5, 10, 11}, {5, 11, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 4, 0}, {5, 0, 10}, {5, 10, 11}, {5, 11, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{9, 3, 1}, {10, 11, 2}, {10, 2, 4}, {4, 9, 1}, {4, 1, 10}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 8, 9}, {1, 9, 3}, {0, 10, 11}, {0, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 9, 3}, {4, 8, 10}, {4, 10, 11}, {4, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 9, 3}, {0, 10, 11}, {0, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 10}, {5, 10, 11}, {5, 11, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {4, 0, 10}, {4, 10, 11}, {4, 11, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 10, 11}, {8, 11, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 0, 10}, {4, 10, 11}, {4, 11, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 5, 1}, {4, 1, 10}, {4, 10, 11}, {4, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {0, 10, 11}, {0, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {4, 10, 11}, {4, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 11}, {0, 11, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 0, 6}, {1, 6, 11}, {1, 11, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 8, 4}, {1, 4, 6}, {1, 6, 11}, {1, 11, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 8, 0}, {5, 0, 6}, {5, 6, 11}, {5, 11, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 4, 6}, {5, 6, 11}, {5, 11, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 0, 4}, {1, 4, 9}, {1, 9, 3}, {6, 11, 2}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 8, 9}, {1, 9, 3}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {5, 9, 3}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 9, 3}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 0}, {5, 0, 6}, {5, 6, 11}, {5, 11, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {4, 6, 11}, {4, 11, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 6}, {8, 6, 11}, {8, 11, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 6, 11}, {4, 11, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 4, 5}, {0, 5, 1}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {6, 11, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 11, 2}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 6, 2}, {7, 2, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 6, 0}, {7, 0, 8}, {4, 2, 3}, {3, 7, 8}, {3, 8, 4}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 7, 6}, {2, 3, 5}, {2, 5, 8}, {8, 1, 6}, {8, 6, 2}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {6, 1, 7}, {5, 4, 2}, {5, 2, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 6, 4}, {7, 4, 9}, {7, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 6, 0}, {7, 0, 8}, {7, 8, 9}, {7, 9, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 8}, {6, 8, 1}, {6, 1, 7}, {5, 9, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {6, 1, 7}, {5, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 7, 6}, {5, 6, 2}, {5, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 8}, {6, 8, 5}, {6, 5, 7}, {4, 2, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 1, 7}, {8, 7, 6}, {8, 6, 2}, {8, 2, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {6, 1, 7}, {4, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 5}, {6, 5, 7}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 8}, {6, 8, 5}, {6, 5, 7}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 4, 8}, {6, 8, 1}, {6, 1, 7}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{6, 0, 1}, {6, 1, 7}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 0}, {7, 0, 2}, {7, 2, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 8}, {7, 8, 4}, {7, 4, 2}, {7, 2, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {5, 8, 0}, {5, 0, 2}, {5, 2, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {5, 4, 2}, {5, 2, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 0}, {7, 0, 4}, {7, 4, 9}, {7, 9, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{7, 10, 8}, {7, 8, 9}, {7, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {10, 1, 7}, {5, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {5, 9, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 7, 10}, {5, 10, 0}, {5, 0, 2}, {5, 2, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 5}, {10, 5, 7}, {4, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {8, 0, 2}, {8, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {4, 2, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 0, 4}, {10, 4, 5}, {10, 5, 7}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 8, 5}, {10, 5, 7}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {10, 1, 7}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 1, 7}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 10, 6}, {1, 6, 2}, {1, 2, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {1, 8, 4}, {1, 4, 2}, {1, 2, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 8, 10}, {5, 10, 6}, {5, 6, 2}, {5, 2, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {5, 4, 2}, {5, 2, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 10, 6}, {1, 6, 4}, {1, 4, 9}, {1, 9, 3}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {1, 8, 9}, {1, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {4, 10, 6}, {5, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {5, 9, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 10}, {5, 10, 6}, {5, 6, 2}, {5, 2, 9}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {8, 5, 1}, {4, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 10, 6}, {8, 6, 2}, {8, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {4, 2, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{10, 6, 4}, {10, 4, 5}, {10, 5, 1}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {8, 5, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 10}, {4, 10, 6}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 10, 6}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 0, 2}, {1, 2, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 8, 4}, {1, 4, 2}, {1, 2, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 8, 0}, {5, 0, 2}, {5, 2, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 4, 2}, {5, 2, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 0, 4}, {1, 4, 9}, {1, 9, 3}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{1, 8, 9}, {1, 9, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {5, 9, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 9, 3}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{5, 1, 0}, {5, 0, 2}, {5, 2, 9}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {4, 2, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 0, 2}, {8, 2, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 2, 9}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 4, 5}, {0, 5, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{8, 5, 1}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{4, 8, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}}, + {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, + {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}} }; diff --git a/intern/dualcon/intern/octree.cpp b/intern/dualcon/intern/octree.cpp index 38b130f979b..1ad502b018d 100644 --- a/intern/dualcon/intern/octree.cpp +++ b/intern/dualcon/intern/octree.cpp @@ -39,38 +39,38 @@ #define dc_printf printf #else /* disable debug printfs */ -#define dc_printf(...) do {} while(0) +#define dc_printf(...) do {} while (0) #endif -Octree::Octree(ModelReader* mr, - DualConAllocOutput alloc_output_func, - DualConAddVert add_vert_func, - DualConAddQuad add_quad_func, - DualConFlags flags, DualConMode dualcon_mode, int depth, - float threshold, float sharpness) +Octree::Octree(ModelReader *mr, + DualConAllocOutput alloc_output_func, + DualConAddVert add_vert_func, + DualConAddQuad add_quad_func, + DualConFlags flags, DualConMode dualcon_mode, int depth, + float threshold, float sharpness) : use_flood_fill(flags & DUALCON_FLOOD_FILL), - /* note on `use_manifold': - - After playing around with this option, the only case I could - find where this option gives different results is on - relatively thin corners. Sometimes along these corners two - vertices from seperate sides will be placed in the same - position, so hole gets filled with a 5-sided face, where two - of those vertices are in the same 3D location. If - `use_manifold' is disabled, then the modifier doesn't - generate two separate vertices so the results end up as all - quads. + /* note on `use_manifold': - Since the results are just as good with all quads, there - doesn't seem any reason to allow this to be toggled in - Blender. -nicholasbishop - */ - use_manifold(false), - hermite_num(sharpness), - mode(dualcon_mode), - alloc_output(alloc_output_func), - add_vert(add_vert_func), - add_quad(add_quad_func) + After playing around with this option, the only case I could + find where this option gives different results is on + relatively thin corners. Sometimes along these corners two + vertices from seperate sides will be placed in the same + position, so hole gets filled with a 5-sided face, where two + of those vertices are in the same 3D location. If + `use_manifold' is disabled, then the modifier doesn't + generate two separate vertices so the results end up as all + quads. + + Since the results are just as good with all quads, there + doesn't seem any reason to allow this to be toggled in + Blender. -nicholasbishop + */ + use_manifold(false), + hermite_num(sharpness), + mode(dualcon_mode), + alloc_output(alloc_output_func), + add_vert(add_vert_func), + add_quad(add_quad_func) { thresh = threshold; reader = mr; @@ -78,8 +78,8 @@ Octree::Octree(ModelReader* mr, range = reader->getBoundingBox(origin); nodeCount = nodeSpace = 0; maxDepth = depth; - mindimen =(dimen >> maxDepth); - minshift =(GRID_DIMENSION - maxDepth); + mindimen = (dimen >> maxDepth); + minshift = (GRID_DIMENSION - maxDepth); buildTable(); maxTrianglePerCell = 0; @@ -90,7 +90,7 @@ Octree::Octree(ModelReader* mr, dc_printf("Initialize memory...\n"); #endif initMemory(); - root = (Node*)createInternal(0); + root = (Node *)createInternal(0); // Read MC table #ifdef IN_VERBOSE_MODE @@ -112,15 +112,15 @@ void Octree::scanConvert() clock_t start, finish; start = clock(); #endif - - addTrian(); + + addAllTriangles(); resetMinimalEdges(); preparePrimalEdgesMask(&root->internal); #if DC_DEBUG finish = clock(); - dc_printf("Time taken: %f seconds \n", - (double)(finish - start) / CLOCKS_PER_SEC); + dc_printf("Time taken: %f seconds \n", + (double)(finish - start) / CLOCKS_PER_SEC); #endif // Generate signs @@ -132,18 +132,18 @@ void Octree::scanConvert() trace(); #if DC_DEBUG finish = clock(); - dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); + dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); #ifdef IN_VERBOSE_MODE - dc_printf("Holes: %d Average Length: %f Max Length: %d \n", numRings,(float)totRingLengths /(float) numRings, maxRingLength); + dc_printf("Holes: %d Average Length: %f Max Length: %d \n", numRings, (float)totRingLengths / (float) numRings, maxRingLength); #endif #endif - + // Check again int tnumRings = numRings; trace(); #ifdef IN_VERBOSE_MODE dc_printf("Holes after patching: %d \n", numRings); -#endif +#endif numRings = tnumRings; #if DC_DEBUG @@ -153,22 +153,22 @@ void Octree::scanConvert() buildSigns(); #if DC_DEBUG finish = clock(); - dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); + dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); #endif - if(use_flood_fill) { + if (use_flood_fill) { /* - start = clock(); - floodFill(); - // Check again - tnumRings = numRings; - trace(); - dc_printf("Holes after filling: %d \n", numRings); - numRings = tnumRings; - buildSigns(); - finish = clock(); - dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); - */ + start = clock(); + floodFill(); + // Check again + tnumRings = numRings; + trace(); + dc_printf("Holes after filling: %d \n", numRings); + numRings = tnumRings; + buildSigns(); + finish = clock(); + dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); + */ #if DC_DEBUG start = clock(); dc_printf("Removing components...\n"); @@ -179,7 +179,7 @@ void Octree::scanConvert() // floodFill(); #if DC_DEBUG finish = clock(); - dc_printf("Time taken: %f seconds \n",(double)(finish - start) / CLOCKS_PER_SEC); + dc_printf("Time taken: %f seconds \n", (double)(finish - start) / CLOCKS_PER_SEC); #endif } @@ -202,31 +202,29 @@ void Octree::scanConvert() void Octree::initMemory() { leafalloc[0] = new MemoryAllocator(); - leafalloc[1] = new MemoryAllocator(); - leafalloc[2] = new MemoryAllocator(); - leafalloc[3] = new MemoryAllocator(); + leafalloc[1] = new MemoryAllocator(); + leafalloc[2] = new MemoryAllocator(); + leafalloc[3] = new MemoryAllocator(); alloc[0] = new MemoryAllocator(); - alloc[1] = new MemoryAllocator(); - alloc[2] = new MemoryAllocator(); - alloc[3] = new MemoryAllocator(); - alloc[4] = new MemoryAllocator(); - alloc[5] = new MemoryAllocator(); - alloc[6] = new MemoryAllocator(); - alloc[7] = new MemoryAllocator(); - alloc[8] = new MemoryAllocator(); + alloc[1] = new MemoryAllocator(); + alloc[2] = new MemoryAllocator(); + alloc[3] = new MemoryAllocator(); + alloc[4] = new MemoryAllocator(); + alloc[5] = new MemoryAllocator(); + alloc[6] = new MemoryAllocator(); + alloc[7] = new MemoryAllocator(); + alloc[8] = new MemoryAllocator(); } void Octree::freeMemory() { - for(int i = 0; i < 9; i ++) - { + for (int i = 0; i < 9; i++) { alloc[i]->destroy(); delete alloc[i]; } - for(int i = 0; i < 4; i ++) - { + for (int i = 0; i < 4; i++) { leafalloc[i]->destroy(); delete leafalloc[i]; } @@ -236,22 +234,20 @@ void Octree::printMemUsage() { int totalbytes = 0; dc_printf("********* Internal nodes: \n"); - for(int i = 0; i < 9; i ++) - { + for (int i = 0; i < 9; i++) { alloc[i]->printInfo(); totalbytes += alloc[i]->getAll() * alloc[i]->getBytes(); } dc_printf("********* Leaf nodes: \n"); int totalLeafs = 0; - for(int i = 0; i < 4; i ++) - { + for (int i = 0; i < 4; i++) { leafalloc[i]->printInfo(); totalbytes += leafalloc[i]->getAll() * leafalloc[i]->getBytes(); totalLeafs += leafalloc[i]->getAllocated(); } - + dc_printf("Total allocated bytes on disk: %d \n", totalbytes); dc_printf("Total leaf nodes: %d\n", totalLeafs); } @@ -261,11 +257,11 @@ void Octree::resetMinimalEdges() cellProcParity(root, 0, maxDepth); } -void Octree::addTrian() +void Octree::addAllTriangles() { - Triangle* trian; + Triangle *trian; int count = 0; - + #if DC_DEBUG int total = reader->getNumTriangles(); int unitcount = 1000; @@ -274,196 +270,173 @@ void Octree::addTrian() srand(0); - while((trian = reader->getNextTriangle()) != NULL) - { + while ((trian = reader->getNextTriangle()) != NULL) { // Drop triangles { - addTrian(trian, count); + addTriangle(trian, count); } delete trian; - count ++; + count++; #if DC_DEBUG - if(count % unitcount == 0) - { + if (count % unitcount == 0) { putchar(13); - switch((count / unitcount) % 4) - { - case 0 : dc_printf("-"); - break; - case 1 : dc_printf("/"); - break; - case 2 : dc_printf("|"); - break; - case 3 : dc_printf("\\"); - break; + switch ((count / unitcount) % 4) { + case 0: dc_printf("-"); + break; + case 1: dc_printf("/"); + break; + case 2: dc_printf("|"); + break; + case 3: dc_printf("\\"); + break; } - float percent =(float) count / total; - + float percent = (float) count / total; + /* - int totbars = 50; - int bars =(int)(percent * totbars); - for(int i = 0; i < bars; i ++) - { - putchar(219); - } - for(i = bars; i < totbars; i ++) - { - putchar(176); - } - */ + int totbars = 50; + int bars =(int)(percent * totbars); + for(int i = 0; i < bars; i ++) { + putchar(219); + } + for(i = bars; i < totbars; i ++) { + putchar(176); + } + */ dc_printf(" %d triangles: ", count); dc_printf(" %f%% complete.", 100 * percent); } #endif - + } putchar(13); } -void Octree::addTrian(Triangle* trian, int triind) +/* Prepare a triangle for insertion into the octree; call the other + addTriangle() to (recursively) build the octree */ +void Octree::addTriangle(Triangle *trian, int triind) { int i, j; - // Blowing up the triangle to the grid - float mid[3] = {0, 0, 0}; - for(i = 0; i < 3; i ++) - for(j = 0; j < 3; j ++) - { - trian->vt[i][j] = dimen *(trian->vt[i][j] - origin[j]) / range; - mid[j] += trian->vt[i][j] / 3; - } + /* Project the triangle's coordinates into the grid */ + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) + trian->vt[i][j] = dimen * (trian->vt[i][j] - origin[j]) / range; + } + + /* Generate projections */ + int64_t cube[2][3] = {{0, 0, 0}, {dimen, dimen, dimen}}; + int64_t trig[3][3]; + for (i = 0; i < 3; i++) { + for (j = 0; j < 3; j++) + trig[i][j] = (int64_t)(trian->vt[i][j]); + } + + /* Add triangle to the octree */ + int64_t errorvec = (int64_t)(0); + CubeTriangleIsect *proj = new CubeTriangleIsect(cube, trig, errorvec, triind); + root = (Node *)addTriangle(&root->internal, proj, maxDepth); - // Generate projections - LONG cube[2][3] = {{0, 0, 0}, {dimen, dimen, dimen}}; - LONG trig[3][3]; - - for(i = 0; i < 3; i ++) - for( j = 0; j < 3; j ++) - { - trig[i][j] =(LONG)(trian->vt[i][j]); - // Perturb end points, if set so - } - - // Add to the octree - // int start[3] = {0, 0, 0}; - LONG errorvec =(LONG)(0); - Projections* proj = new Projections(cube, trig, errorvec, triind); - root = (Node*)addTrian(&root->internal, proj, maxDepth); - delete proj->inherit; delete proj; } +void print_depth(int height, int maxDepth) +{ + for (int i = 0; i < maxDepth - height; i++) + printf(" "); +} -InternalNode* Octree::addTrian(InternalNode* node, Projections* p, int height) +InternalNode *Octree::addTriangle(InternalNode *node, CubeTriangleIsect *p, int height) { int i; - int vertdiff[8][3] = {{0,0,0},{0,0,1},{0,1,-1},{0,0,1},{1,-1,-1},{0,0,1},{0,1,-1},{0,0,1}}; - UCHAR boxmask = p->getBoxMask(); - Projections* subp = new Projections(p); + const int vertdiff[8][3] = { + {0, 0, 0}, + {0, 0, 1}, + {0, 1, -1}, + {0, 0, 1}, + {1, -1, -1}, + {0, 0, 1}, + {0, 1, -1}, + {0, 0, 1}}; + unsigned char boxmask = p->getBoxMask(); + CubeTriangleIsect *subp = new CubeTriangleIsect(p); int count = 0; - int tempdiff[3] = {0,0,0}; - for(i = 0; i < 8; i ++) - { + int tempdiff[3] = {0, 0, 0}; + + /* Check triangle against each of the input node's children */ + for (i = 0; i < 8; i++) { tempdiff[0] += vertdiff[i][0]; tempdiff[1] += vertdiff[i][1]; tempdiff[2] += vertdiff[i][2]; /* Quick pruning using bounding box */ - if(boxmask &(1 << i)) - { + if (boxmask & (1 << i)) { subp->shift(tempdiff); tempdiff[0] = tempdiff[1] = tempdiff[2] = 0; /* Pruning using intersection test */ - if(subp->isIntersecting()) - // if(subp->getIntersectionMasks(cedgemask, edgemask)) - { - if(! hasChild(node, i)) - { - if(height == 1) - { + if (subp->isIntersecting()) { + if (!hasChild(node, i)) { + if (height == 1) node = addLeafChild(node, i, count, createLeaf(0)); - } else - { node = addInternalChild(node, i, count, createInternal(0)); - } - } - Node* chd = getChild(node, count); - - if(! isLeaf(node, i)) - { - // setChild(node, count, addTrian(chd, subp, height - 1, vertmask[i], edgemask)); - setChild(node, count, (Node*)addTrian(&chd->internal, subp, height - 1)); } + Node *chd = getChild(node, count); + + if (node->is_child_leaf(i)) + setChild(node, count, (Node *)updateCell(&chd->leaf, subp)); else - { - setChild(node, count, (Node*)updateCell(&chd->leaf, subp)); - } + setChild(node, count, (Node *)addTriangle(&chd->internal, subp, height - 1)); } } - if(hasChild(node, i)) - { - count ++; - } + if (hasChild(node, i)) + count++; } delete subp; - + return node; } -LeafNode* Octree::updateCell(LeafNode* node, Projections* p) +LeafNode *Octree::updateCell(LeafNode *node, CubeTriangleIsect *p) { int i; // Edge connectivity - int mask[3] = {0, 4, 8 }; + int mask[3] = {0, 4, 8 }; int oldc = 0, newc = 0; float offs[3]; float a[3], b[3], c[3]; - for(i = 0; i < 3; i ++) - { - if(! getEdgeParity(node, mask[i])) - { - if(p->isIntersectingPrimary(i)) - { + for (i = 0; i < 3; i++) { + if (!getEdgeParity(node, mask[i])) { + if (p->isIntersectingPrimary(i)) { // actualQuads ++; setEdge(node, mask[i]); offs[newc] = p->getIntersectionPrimary(i); - a[newc] =(float) p->inherit->norm[0]; - b[newc] =(float) p->inherit->norm[1]; - c[newc] =(float) p->inherit->norm[2]; - newc ++; + a[newc] = (float) p->inherit->norm[0]; + b[newc] = (float) p->inherit->norm[1]; + c[newc] = (float) p->inherit->norm[2]; + newc++; } } - else - { + else { offs[newc] = getEdgeOffsetNormal(node, oldc, a[newc], b[newc], c[newc]); -// if(p->isIntersectingPrimary(i)) - { - // dc_printf("Multiple intersections!\n"); - -// setPatchEdge(node, i); - } - - oldc ++; - newc ++; + oldc++; + newc++; } } - if(newc > oldc) - { + if (newc > oldc) { // New offsets added, update this node node = updateEdgeOffsetsNormals(node, oldc, newc, offs, a, b, c); } @@ -471,45 +444,42 @@ LeafNode* Octree::updateCell(LeafNode* node, Projections* p) return node; } -void Octree::preparePrimalEdgesMask(InternalNode* node) +void Octree::preparePrimalEdgesMask(InternalNode *node) { int count = 0; - for(int i = 0; i < 8; i ++) - { - if(hasChild(node, i)) - { - if(isLeaf(node, i)) + for (int i = 0; i < 8; i++) { + if (hasChild(node, i)) { + if (node->is_child_leaf(i)) createPrimalEdgesMask(&getChild(node, count)->leaf); else preparePrimalEdgesMask(&getChild(node, count)->internal); - count ++; + count++; } } } void Octree::trace() { - int st[3] = {0, 0, 0,}; + int st[3] = {0, 0, 0, }; numRings = 0; totRingLengths = 0; maxRingLength = 0; - PathList* chdpath = NULL; + PathList *chdpath = NULL; root = trace(root, st, dimen, maxDepth, chdpath); - if(chdpath != NULL) - { - dc_printf("there are incomplete rings.\n"); + if (chdpath != NULL) { + dc_printf("there are incomplete rings.\n"); printPaths(chdpath); }; } -Node* Octree::trace(Node* newnode, int* st, int len, int depth, PathList*& paths) +Node *Octree::trace(Node *newnode, int *st, int len, int depth, PathList *& paths) { len >>= 1; - PathList* chdpaths[8]; - Node* chd[8]; + PathList *chdpaths[8]; + Node *chd[8]; int nst[8][3]; int i, j; @@ -518,55 +488,48 @@ Node* Octree::trace(Node* newnode, int* st, int len, int depth, PathList*& paths fillChildren(&newnode->internal, chd, chdleaf); // int count = 0; - for(i = 0; i < 8; i ++) - { - for(j = 0; j < 3; j ++) - { + for (i = 0; i < 8; i++) { + for (j = 0; j < 3; j++) { nst[i][j] = st[j] + len * vertmap[i][j]; } - if(chd[i] == NULL || isLeaf(&newnode->internal, i)) - { + if (chd[i] == NULL || newnode->internal.is_child_leaf(i)) { chdpaths[i] = NULL; } - else - { + else { trace(chd[i], nst[i], len, depth - 1, chdpaths[i]); } } // Get connectors on the faces - PathList* conn[12]; - Node* nf[2]; + PathList *conn[12]; + Node *nf[2]; int lf[2]; int df[2] = {depth - 1, depth - 1}; - int* nstf[2]; + int *nstf[2]; fillChildren(&newnode->internal, chd, chdleaf); - for(i = 0; i < 12; i ++) - { + for (i = 0; i < 12; i++) { int c[2] = {cellProcFaceMask[i][0], cellProcFaceMask[i][1]}; - - for(int j = 0; j < 2; j ++) - { + + for (int j = 0; j < 2; j++) { lf[j] = chdleaf[c[j]]; nf[j] = chd[c[j]]; nstf[j] = nst[c[j]]; } conn[i] = NULL; - - findPaths((Node**)nf, lf, df, nstf, depth - 1, cellProcFaceMask[i][2], conn[i]); - //if(conn[i]) - //{ + findPaths((Node **)nf, lf, df, nstf, depth - 1, cellProcFaceMask[i][2], conn[i]); + + //if(conn[i]) { // printPath(conn[i]); //} } - + // Connect paths - PathList* rings = NULL; + PathList *rings = NULL; combinePaths(chdpaths[0], chdpaths[1], conn[8], rings); combinePaths(chdpaths[2], chdpaths[3], conn[9], rings); combinePaths(chdpaths[4], chdpaths[5], conn[10], rings); @@ -585,25 +548,22 @@ Node* Octree::trace(Node* newnode, int* st, int len, int depth, PathList*& paths // By now, only chdpaths[0] and rings have contents // Process rings - if(rings) - { + if (rings) { // printPath(rings); /* Let's count first */ - PathList* trings = rings; - while(trings) - { - numRings ++; + PathList *trings = rings; + while (trings) { + numRings++; totRingLengths += trings->length; - if(trings->length > maxRingLength) - { + if (trings->length > maxRingLength) { maxRingLength = trings->length; } trings = trings->next; } // printPath(rings); - newnode = patch(newnode, st,(len << 1), rings); + newnode = patch(newnode, st, (len << 1), rings); } // Return incomplete paths @@ -611,34 +571,28 @@ Node* Octree::trace(Node* newnode, int* st, int len, int depth, PathList*& paths return newnode; } -void Octree::findPaths(Node* node[2], int leaf[2], int depth[2], int* st[2], int maxdep, int dir, PathList*& paths) +void Octree::findPaths(Node *node[2], int leaf[2], int depth[2], int *st[2], int maxdep, int dir, PathList *& paths) { - if(!(node[0] && node[1])) - { + if (!(node[0] && node[1])) { return; } - if(!(leaf[0] && leaf[1])) - { + if (!(leaf[0] && leaf[1])) { // Not at the bottom, recur // Fill children nodes int i, j; - Node* chd[2][8]; + Node *chd[2][8]; int chdleaf[2][8]; int nst[2][8][3]; - for(j = 0; j < 2; j ++) - { - if(! leaf[j]) - { + for (j = 0; j < 2; j++) { + if (!leaf[j]) { fillChildren(&node[j]->internal, chd[j], chdleaf[j]); - int len =(dimen >>(maxDepth - depth[j] + 1)); - for(i = 0; i < 8; i ++) - { - for(int k = 0; k < 3; k ++) - { + int len = (dimen >> (maxDepth - depth[j] + 1)); + for (i = 0; i < 8; i++) { + for (int k = 0; k < 3; k++) { nst[j][i][k] = st[j][k] + len * vertmap[i][k]; } } @@ -647,24 +601,20 @@ void Octree::findPaths(Node* node[2], int leaf[2], int depth[2], int* st[2], int } // 4 face calls - Node* nf[2]; + Node *nf[2]; int df[2]; int lf[2]; - int* nstf[2]; - for(i = 0; i < 4; i ++) - { + int *nstf[2]; + for (i = 0; i < 4; i++) { int c[2] = {faceProcFaceMask[dir][i][0], faceProcFaceMask[dir][i][1]}; - for(int j = 0; j < 2; j ++) - { - if(leaf[j]) - { + for (int j = 0; j < 2; j++) { + if (leaf[j]) { lf[j] = leaf[j]; nf[j] = node[j]; df[j] = depth[j]; nstf[j] = st[j]; } - else - { + else { lf[j] = chdleaf[j][c[j]]; nf[j] = chd[j][c[j]]; df[j] = depth[j] - 1; @@ -675,16 +625,14 @@ void Octree::findPaths(Node* node[2], int leaf[2], int depth[2], int* st[2], int } } - else - { + else { // At the bottom, check this face - int ind =(depth[0] == maxdep ? 0 : 1); - int fcind = 2 * dir +(1 - ind); - if(getFaceParity((LeafNode*)node[ind], fcind)) - { + int ind = (depth[0] == maxdep ? 0 : 1); + int fcind = 2 * dir + (1 - ind); + if (getFaceParity((LeafNode *)node[ind], fcind)) { // Add into path - PathElement* ele1 = new PathElement; - PathElement* ele2 = new PathElement; + PathElement *ele1 = new PathElement; + PathElement *ele2 = new PathElement; ele1->pos[0] = st[0][0]; ele1->pos[1] = st[0][1]; @@ -697,7 +645,7 @@ void Octree::findPaths(Node* node[2], int leaf[2], int depth[2], int* st[2], int ele1->next = ele2; ele2->next = NULL; - PathList* lst = new PathList; + PathList *lst = new PathList; lst->head = ele1; lst->tail = ele2; lst->length = 2; @@ -710,28 +658,25 @@ void Octree::findPaths(Node* node[2], int leaf[2], int depth[2], int* st[2], int } -void Octree::combinePaths(PathList*& list1, PathList* list2, PathList* paths, PathList*& rings) +void Octree::combinePaths(PathList *& list1, PathList *list2, PathList *paths, PathList *& rings) { // Make new list of paths - PathList* nlist = NULL; + PathList *nlist = NULL; // Search for each connectors in paths - PathList* tpaths = paths; - PathList* tlist, * pre; - while(tpaths) - { - PathList* singlist = tpaths; - PathList* templist; + PathList *tpaths = paths; + PathList *tlist, *pre; + while (tpaths) { + PathList *singlist = tpaths; + PathList *templist; tpaths = tpaths->next; singlist->next = NULL; // Look for hookup in list1 tlist = list1; pre = NULL; - while(tlist) - { - if((templist = combineSinglePath(list1, pre, tlist, singlist, NULL, singlist)) != NULL) - { + while (tlist) { + if ((templist = combineSinglePath(list1, pre, tlist, singlist, NULL, singlist)) != NULL) { singlist = templist; continue; } @@ -742,10 +687,8 @@ void Octree::combinePaths(PathList*& list1, PathList* list2, PathList* paths, Pa // Look for hookup in list2 tlist = list2; pre = NULL; - while(tlist) - { - if((templist = combineSinglePath(list2, pre, tlist, singlist, NULL, singlist)) != NULL) - { + while (tlist) { + if ((templist = combineSinglePath(list2, pre, tlist, singlist, NULL, singlist)) != NULL) { singlist = templist; continue; } @@ -756,10 +699,8 @@ void Octree::combinePaths(PathList*& list1, PathList* list2, PathList* paths, Pa // Look for hookup in nlist tlist = nlist; pre = NULL; - while(tlist) - { - if((templist = combineSinglePath(nlist, pre, tlist, singlist, NULL, singlist)) != NULL) - { + while (tlist) { + if ((templist = combineSinglePath(nlist, pre, tlist, singlist, NULL, singlist)) != NULL) { singlist = templist; continue; } @@ -768,71 +709,60 @@ void Octree::combinePaths(PathList*& list1, PathList* list2, PathList* paths, Pa } // Add to nlist or rings - if(isEqual(singlist->head, singlist->tail)) - { - PathElement* temp = singlist->head; + if (isEqual(singlist->head, singlist->tail)) { + PathElement *temp = singlist->head; singlist->head = temp->next; delete temp; - singlist->length --; + singlist->length--; singlist->tail->next = singlist->head; singlist->next = rings; rings = singlist; } - else - { + else { singlist->next = nlist; nlist = singlist; } } - // Append list2 and nlist to the end of list1 + // Append list2 and nlist to the end of list1 tlist = list1; - if(tlist != NULL) - { - while(tlist->next != NULL) - { + if (tlist != NULL) { + while (tlist->next != NULL) { tlist = tlist->next; } tlist->next = list2; } - else - { + else { tlist = list2; list1 = list2; } - if(tlist != NULL) - { - while(tlist->next != NULL) - { + if (tlist != NULL) { + while (tlist->next != NULL) { tlist = tlist->next; } tlist->next = nlist; } - else - { + else { tlist = nlist; list1 = nlist; } } -PathList* Octree::combineSinglePath(PathList*& head1, PathList* pre1, PathList*& list1, PathList*& head2, PathList* pre2, PathList*& list2) +PathList *Octree::combineSinglePath(PathList *& head1, PathList *pre1, PathList *& list1, PathList *& head2, PathList *pre2, PathList *& list2) { - if(isEqual(list1->head, list2->head) || isEqual(list1->tail, list2->tail)) - { + if (isEqual(list1->head, list2->head) || isEqual(list1->tail, list2->tail)) { // Reverse the list - if(list1->length < list2->length) - { + if (list1->length < list2->length) { // Reverse list1 - PathElement* prev = list1->head; - PathElement* next = prev->next; + PathElement *prev = list1->head; + PathElement *next = prev->next; prev->next = NULL; - while(next != NULL) - { - PathElement* tnext = next->next; + while (next != NULL) { + PathElement *tnext = next->next; next->next = prev; prev = next; @@ -842,15 +772,13 @@ PathList* Octree::combineSinglePath(PathList*& head1, PathList* pre1, PathList*& list1->tail = list1->head; list1->head = prev; } - else - { + else { // Reverse list2 - PathElement* prev = list2->head; - PathElement* next = prev->next; + PathElement *prev = list2->head; + PathElement *next = prev->next; prev->next = NULL; - while(next != NULL) - { - PathElement* tnext = next->next; + while (next != NULL) { + PathElement *tnext = next->next; next->next = prev; prev = next; @@ -860,17 +788,16 @@ PathList* Octree::combineSinglePath(PathList*& head1, PathList* pre1, PathList*& list2->tail = list2->head; list2->head = prev; } - } - - if(isEqual(list1->head, list2->tail)) - { + } + + if (isEqual(list1->head, list2->tail)) { // Easy case - PathElement* temp = list1->head->next; + PathElement *temp = list1->head->next; delete list1->head; list2->tail->next = temp; - PathList* nlist = new PathList; + PathList *nlist = new PathList; nlist->length = list1->length + list2->length - 1; nlist->head = list2->head; nlist->tail = list1->tail; @@ -880,15 +807,14 @@ PathList* Octree::combineSinglePath(PathList*& head1, PathList* pre1, PathList*& deletePath(head2, pre2, list2); return nlist; - } - else if(isEqual(list1->tail, list2->head)) - { + } + else if (isEqual(list1->tail, list2->head)) { // Easy case - PathElement* temp = list2->head->next; + PathElement *temp = list2->head->next; delete list2->head; list1->tail->next = temp; - PathList* nlist = new PathList; + PathList *nlist = new PathList; nlist->length = list1->length + list2->length - 1; nlist->head = list1->head; nlist->tail = list2->tail; @@ -903,173 +829,158 @@ PathList* Octree::combineSinglePath(PathList*& head1, PathList* pre1, PathList*& return NULL; } -void Octree::deletePath(PathList*& head, PathList* pre, PathList*& curr) +void Octree::deletePath(PathList *& head, PathList *pre, PathList *& curr) { - PathList* temp = curr; + PathList *temp = curr; curr = temp->next; delete temp; - if(pre == NULL) - { + if (pre == NULL) { head = curr; } - else - { + else { pre->next = curr; } } -void Octree::printElement(PathElement* ele) +void Octree::printElement(PathElement *ele) { - if(ele != NULL) - { + if (ele != NULL) { dc_printf("(%d %d %d)", ele->pos[0], ele->pos[1], ele->pos[2]); } } -void Octree::printPath(PathList* path) +void Octree::printPath(PathList *path) { - PathElement* n = path->head; + PathElement *n = path->head; int same = 0; #if DC_DEBUG - int len =(dimen >> maxDepth); + int len = (dimen >> maxDepth); #endif - while(n &&(same == 0 || n != path->head)) - { - same ++; + while (n && (same == 0 || n != path->head)) { + same++; dc_printf("(%d %d %d)", n->pos[0] / len, n->pos[1] / len, n->pos[2] / len); n = n->next; } - if(n == path->head) - { + if (n == path->head) { dc_printf(" Ring!\n"); } - else - { + else { dc_printf(" %p end!\n", n); } } -void Octree::printPath(PathElement* path) +void Octree::printPath(PathElement *path) { PathElement *n = path; int same = 0; #if DC_DEBUG - int len =(dimen >> maxDepth); + int len = (dimen >> maxDepth); #endif - while(n &&(same == 0 || n != path)) - { - same ++; + while (n && (same == 0 || n != path)) { + same++; dc_printf("(%d %d %d)", n->pos[0] / len, n->pos[1] / len, n->pos[2] / len); n = n->next; } - if(n == path) - { + if (n == path) { dc_printf(" Ring!\n"); } - else - { + else { dc_printf(" %p end!\n", n); } } -void Octree::printPaths(PathList* path) +void Octree::printPaths(PathList *path) { - PathList* iter = path; + PathList *iter = path; int i = 0; - while(iter != NULL) - { + while (iter != NULL) { dc_printf("Path %d:\n", i); printPath(iter); iter = iter->next; - i ++; + i++; } } -Node* Octree::patch(Node* newnode, int st[3], int len, PathList* rings) +Node *Octree::patch(Node *newnode, int st[3], int len, PathList *rings) { #ifdef IN_DEBUG_MODE dc_printf("Call to PATCH with rings: \n"); printPaths(rings); #endif - /* Do nothing but couting - PathList* tlist = rings; - PathList* ttlist; - PathElement* telem, * ttelem; - while(tlist!= NULL) - { - // printPath(tlist); - numRings ++; - totRingLengths += tlist->length; - if(tlist->length > maxRingLength) - { - maxRingLength = tlist->length; - } - ttlist = tlist; - tlist = tlist->next; - } - return node; - */ - + /* Do nothing but couting + PathList* tlist = rings; + PathList* ttlist; + PathElement* telem, * ttelem; + while(tlist!= NULL) { + // printPath(tlist); + numRings ++; + totRingLengths += tlist->length; + if(tlist->length > maxRingLength) { + maxRingLength = tlist->length; + } + ttlist = tlist; + tlist = tlist->next; + } + return node; + */ + /* Pass onto separate calls in each direction */ - if(len == mindimen) - { + if (len == mindimen) { dc_printf("Error! should have no list by now.\n"); exit(0); } - + // YZ plane - PathList* xlists[2]; + PathList *xlists[2]; newnode = patchSplit(newnode, st, len, rings, 0, xlists[0], xlists[1]); - + // XZ plane - PathList* ylists[4]; + PathList *ylists[4]; newnode = patchSplit(newnode, st, len, xlists[0], 1, ylists[0], ylists[1]); newnode = patchSplit(newnode, st, len, xlists[1], 1, ylists[2], ylists[3]); - + // XY plane - PathList* zlists[8]; + PathList *zlists[8]; newnode = patchSplit(newnode, st, len, ylists[0], 2, zlists[0], zlists[1]); newnode = patchSplit(newnode, st, len, ylists[1], 2, zlists[2], zlists[3]); newnode = patchSplit(newnode, st, len, ylists[2], 2, zlists[4], zlists[5]); newnode = patchSplit(newnode, st, len, ylists[3], 2, zlists[6], zlists[7]); - + // Recur len >>= 1; int count = 0; - for(int i = 0; i < 8; i ++) - { - if(zlists[i] != NULL) - { + for (int i = 0; i < 8; i++) { + if (zlists[i] != NULL) { int nori[3] = { - st[0] + len * vertmap[i][0] , - st[1] + len * vertmap[i][1] , - st[2] + len * vertmap[i][2]}; - patch(getChild(&newnode->internal , count), nori, len, zlists[i]); + st[0] + len * vertmap[i][0], + st[1] + len * vertmap[i][1], + st[2] + len * vertmap[i][2] + }; + patch(getChild(&newnode->internal, count), nori, len, zlists[i]); } - if(hasChild(&newnode->internal, i)) - { - count ++; + if (hasChild(&newnode->internal, i)) { + count++; } } #ifdef IN_DEBUG_MODE dc_printf("Return from PATCH\n"); #endif return newnode; - + } -Node* Octree::patchSplit(Node* newnode, int st[3], int len, PathList* rings, - int dir, PathList*& nrings1, PathList*& nrings2) +Node *Octree::patchSplit(Node *newnode, int st[3], int len, PathList *rings, + int dir, PathList *& nrings1, PathList *& nrings2) { #ifdef IN_DEBUG_MODE dc_printf("Call to PATCHSPLIT with direction %d and rings: \n", dir); @@ -1078,12 +989,11 @@ Node* Octree::patchSplit(Node* newnode, int st[3], int len, PathList* rings, nrings1 = NULL; nrings2 = NULL; - PathList* tmp; - while(rings != NULL) - { + PathList *tmp; + while (rings != NULL) { // Process this ring newnode = patchSplitSingle(newnode, st, len, rings->head, dir, nrings1, nrings2); - + // Delete this ring from the group tmp = rings; rings = rings->next; @@ -1101,91 +1011,78 @@ Node* Octree::patchSplit(Node* newnode, int st[3], int len, PathList* rings, return newnode; } -Node* Octree::patchSplitSingle(Node* newnode, int st[3], int len, PathElement* head, int dir, PathList*& nrings1, PathList*& nrings2) +Node *Octree::patchSplitSingle(Node *newnode, int st[3], int len, PathElement *head, int dir, PathList *& nrings1, PathList *& nrings2) { #ifdef IN_DEBUG_MODE dc_printf("Call to PATCHSPLITSINGLE with direction %d and path: \n", dir); printPath(head); #endif - if(head == NULL) - { + if (head == NULL) { #ifdef IN_DEBUG_MODE dc_printf("Return from PATCHSPLITSINGLE with head==NULL.\n"); #endif return newnode; } - else - { + else { // printPath(head); } - + // Walk along the ring to find pair of intersections - PathElement* pre1 = NULL; - PathElement* pre2 = NULL; - int side = findPair(head, st[dir] + len / 2 , dir, pre1, pre2); - + PathElement *pre1 = NULL; + PathElement *pre2 = NULL; + int side = findPair(head, st[dir] + len / 2, dir, pre1, pre2); + /* - if(pre1 == pre2) - { - int edgelen =(dimen >> maxDepth); - dc_printf("Location: %d %d %d Direction: %d Reso: %d\n", st[0]/edgelen, st[1]/edgelen, st[2]/edgelen, dir, len/edgelen); - printPath(head); - exit(0); - } - */ - - if(side) - { + if(pre1 == pre2) { + int edgelen =(dimen >> maxDepth); + dc_printf("Location: %d %d %d Direction: %d Reso: %d\n", st[0]/edgelen, st[1]/edgelen, st[2]/edgelen, dir, len/edgelen); + printPath(head); + exit(0); + } + */ + + if (side) { // Entirely on one side - PathList* nring = new PathList(); + PathList *nring = new PathList(); nring->head = head; - - if(side == -1) - { + + if (side == -1) { nring->next = nrings1; nrings1 = nring; } - else - { + else { nring->next = nrings2; nrings2 = nring; } } - else - { + else { // Break into two parts - PathElement* nxt1 = pre1->next; - PathElement* nxt2 = pre2->next; + PathElement *nxt1 = pre1->next; + PathElement *nxt2 = pre2->next; pre1->next = nxt2; pre2->next = nxt1; newnode = connectFace(newnode, st, len, dir, pre1, pre2); - - if(isEqual(pre1, pre1->next)) - { - if(pre1 == pre1->next) - { + + if (isEqual(pre1, pre1->next)) { + if (pre1 == pre1->next) { delete pre1; pre1 = NULL; } - else - { - PathElement* temp = pre1->next; + else { + PathElement *temp = pre1->next; pre1->next = temp->next; delete temp; } } - if(isEqual(pre2, pre2->next)) - { - if(pre2 == pre2->next) - { + if (isEqual(pre2, pre2->next)) { + if (pre2 == pre2->next) { delete pre2; pre2 = NULL; } - else - { - PathElement* temp = pre2->next; + else { + PathElement *temp = pre2->next; pre2->next = temp->next; delete temp; } @@ -1193,11 +1090,11 @@ Node* Octree::patchSplitSingle(Node* newnode, int st[3], int len, PathElement* h compressRing(pre1); compressRing(pre2); - + // Recur newnode = patchSplitSingle(newnode, st, len, pre1, dir, nrings1, nrings2); newnode = patchSplitSingle(newnode, st, len, pre2, dir, nrings1, nrings2); - + } #ifdef IN_DEBUG_MODE @@ -1211,8 +1108,8 @@ Node* Octree::patchSplitSingle(Node* newnode, int st[3], int len, PathElement* h return newnode; } -Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, - PathElement* f1, PathElement* f2) +Node *Octree::connectFace(Node *newnode, int st[3], int len, int dir, + PathElement *f1, PathElement *f2) { #ifdef IN_DEBUG_MODE dc_printf("Call to CONNECTFACE with direction %d and length %d path: \n", dir, len); @@ -1224,45 +1121,43 @@ Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, // checkPath(f2); #endif - // Setup 2D + // Setup 2D int pos = st[dir] + len / 2; - int xdir =(dir + 1) % 3; - int ydir =(dir + 2) % 3; - + int xdir = (dir + 1) % 3; + int ydir = (dir + 2) % 3; + // Use existing intersections on f1 and f2 int x1, y1, x2, y2; float p1, q1, p2, q2; getFacePoint(f2->next, dir, x1, y1, p1, q1); getFacePoint(f2, dir, x2, y2, p2, q2); - + float dx = x2 + p2 - x1 - p1; float dy = y2 + q2 - y1 - q1; - + // Do adapted Bresenham line drawing float rx = p1, ry = q1; - int incx = 1, incy = 1; + int incx = 1, incy = 1; int lx = x1, ly = y1; int hx = x2, hy = y2; int choice; - if(x2 < x1) - { + if (x2 < x1) { incx = -1; rx = 1 - rx; lx = x2; hx = x1; } - if(y2 < y1) - { + if (y2 < y1) { incy = -1; ry = 1 - ry; ly = y2; hy = y1; } - + float sx = dx * incx; float sy = dy * incy; - + int ori[3]; ori[dir] = pos / mindimen; ori[xdir] = x1; @@ -1271,89 +1166,78 @@ Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, int inc; float alpha; - PathElement* curEleN = f1; - PathElement* curEleP = f2->next; + PathElement *curEleN = f1; + PathElement *curEleP = f2->next; Node *nodeN = NULL, *nodeP = NULL; LeafNode *curN = locateLeaf(&newnode->internal, len, f1->pos); LeafNode *curP = locateLeaf(&newnode->internal, len, f2->next->pos); - if(curN == NULL || curP == NULL) - { + if (curN == NULL || curP == NULL) { exit(0); } int stN[3], stP[3]; int lenN, lenP; - + /* Unused code, leaving for posterity - float stpt[3], edpt[3]; - stpt[dir] = edpt[dir] =(float) pos; - stpt[xdir] =(x1 + p1) * mindimen; - stpt[ydir] =(y1 + q1) * mindimen; - edpt[xdir] =(x2 + p2) * mindimen; - edpt[ydir] =(y2 + q2) * mindimen; - */ - while(ori[xdir] != x2 || ori[ydir] != y2) - { + float stpt[3], edpt[3]; + stpt[dir] = edpt[dir] =(float) pos; + stpt[xdir] =(x1 + p1) * mindimen; + stpt[ydir] =(y1 + q1) * mindimen; + edpt[xdir] =(x2 + p2) * mindimen; + edpt[ydir] =(y2 + q2) * mindimen; + */ + while (ori[xdir] != x2 || ori[ydir] != y2) { int next; - if(sy *(1 - rx) > sx *(1 - ry)) - { - choice = 1; + if (sy * (1 - rx) > sx * (1 - ry)) { + choice = 1; next = ori[ydir] + incy; - if(next < ly || next > hy) - { + if (next < ly || next > hy) { choice = 4; next = ori[xdir] + incx; } } - else - { + else { choice = 2; next = ori[xdir] + incx; - if(next < lx || next > hx) - { + if (next < lx || next > hx) { choice = 3; next = ori[ydir] + incy; } } - - if(choice & 1) - { + + if (choice & 1) { ori[ydir] = next; - if(choice == 1) - { - rx +=(sy == 0 ? 0 :(1 - ry) * sx / sy ); + if (choice == 1) { + rx += (sy == 0 ? 0 : (1 - ry) * sx / sy); ry = 0; } - + walkdir = 2; inc = incy; alpha = x2 < x1 ? 1 - rx : rx; } - else - { + else { ori[xdir] = next; - if(choice == 2) - { - ry +=(sx == 0 ? 0 :(1 - rx) * sy / sx); - rx = 0; + if (choice == 2) { + ry += (sx == 0 ? 0 : (1 - rx) * sy / sx); + rx = 0; } - + walkdir = 1; inc = incx; alpha = y2 < y1 ? 1 - ry : ry; } - + // Get the exact location of the marcher int nori[3] = {ori[0] * mindimen, ori[1] * mindimen, ori[2] * mindimen}; - float spt[3] = {(float) nori[0],(float) nori[1],(float) nori[2]}; - spt[(dir +(3 - walkdir)) % 3] += alpha * mindimen; - if(inc < 0) - { + float spt[3] = {(float) nori[0], (float) nori[1], (float) nori[2]}; + spt[(dir + (3 - walkdir)) % 3] += alpha * mindimen; + if (inc < 0) { spt[(dir + walkdir) % 3] += mindimen; } - + // dc_printf("new x,y: %d %d\n", ori[xdir] / edgelen, ori[ydir] / edgelen); // dc_printf("nori: %d %d %d alpha: %f walkdir: %d\n", nori[0], nori[1], nori[2], alpha, walkdir); // dc_printf("%f %f %f\n", spt[0], spt[1], spt[2]); @@ -1366,11 +1250,9 @@ Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, int flag = 0; // Add the cells to the rings and fill in the patch - PathElement* newEleN; - if(curEleN->pos[0] != stN[0] || curEleN->pos[1] != stN[1] || curEleN->pos[2] != stN[2]) - { - if(curEleN->next->pos[0] != stN[0] || curEleN->next->pos[1] != stN[1] || curEleN->next->pos[2] != stN[2]) - { + PathElement *newEleN; + if (curEleN->pos[0] != stN[0] || curEleN->pos[1] != stN[1] || curEleN->pos[2] != stN[2]) { + if (curEleN->next->pos[0] != stN[0] || curEleN->next->pos[1] != stN[1] || curEleN->next->pos[2] != stN[2]) { newEleN = new PathElement; newEleN->next = curEleN->next; newEleN->pos[0] = stN[0]; @@ -1379,23 +1261,20 @@ Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, curEleN->next = newEleN; } - else - { + else { newEleN = curEleN->next; } curN = patchAdjacent(&newnode->internal, len, curEleN->pos, curN, - newEleN->pos, (LeafNode*)nodeN, walkdir, - inc, dir, 1, alpha); + newEleN->pos, (LeafNode *)nodeN, walkdir, + inc, dir, 1, alpha); curEleN = newEleN; - flag ++; + flag++; } - PathElement* newEleP; - if(curEleP->pos[0] != stP[0] || curEleP->pos[1] != stP[1] || curEleP->pos[2] != stP[2]) - { - if(f2->pos[0] != stP[0] || f2->pos[1] != stP[1] || f2->pos[2] != stP[2]) - { + PathElement *newEleP; + if (curEleP->pos[0] != stP[0] || curEleP->pos[1] != stP[1] || curEleP->pos[2] != stP[2]) { + if (f2->pos[0] != stP[0] || f2->pos[1] != stP[1] || f2->pos[2] != stP[2]) { newEleP = new PathElement; newEleP->next = curEleP; newEleP->pos[0] = stP[0]; @@ -1404,27 +1283,25 @@ Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, f2->next = newEleP; } - else - { + else { newEleP = f2; } curP = patchAdjacent(&newnode->internal, len, curEleP->pos, curP, - newEleP->pos, (LeafNode*)nodeP, walkdir, - inc, dir, 0, alpha); + newEleP->pos, (LeafNode *)nodeP, walkdir, + inc, dir, 0, alpha); curEleP = newEleP; - flag ++; + flag++; } - + /* - if(flag == 0) - { - dc_printf("error: non-synchronized patching! at \n"); - } - */ + if(flag == 0) { + dc_printf("error: non-synchronized patching! at \n"); + } + */ } #ifdef IN_DEBUG_MODE @@ -1441,10 +1318,10 @@ Node* Octree::connectFace(Node* newnode, int st[3], int len, int dir, return newnode; } -LeafNode* Octree::patchAdjacent(InternalNode* node, int len, int st1[3], - LeafNode* leaf1, int st2[3], LeafNode* leaf2, - int walkdir, int inc, int dir, int side, - float alpha) +LeafNode *Octree::patchAdjacent(InternalNode *node, int len, int st1[3], + LeafNode *leaf1, int st2[3], LeafNode *leaf2, + int walkdir, int inc, int dir, int side, + float alpha) { #ifdef IN_DEBUG_MODE dc_printf("Before patching.\n"); @@ -1454,29 +1331,28 @@ LeafNode* Octree::patchAdjacent(InternalNode* node, int len, int st1[3], #endif // Get edge index on each leaf - int edgedir =(dir +(3 - walkdir)) % 3; - int incdir =(dir + walkdir) % 3; - int ind1 =(edgedir == 1 ?(dir + 3 - edgedir) % 3 - 1 : 2 -(dir + 3 - edgedir) % 3); - int ind2 =(edgedir == 1 ?(incdir + 3 - edgedir) % 3 - 1 : 2 -(incdir + 3 - edgedir) % 3); + int edgedir = (dir + (3 - walkdir)) % 3; + int incdir = (dir + walkdir) % 3; + int ind1 = (edgedir == 1 ? (dir + 3 - edgedir) % 3 - 1 : 2 - (dir + 3 - edgedir) % 3); + int ind2 = (edgedir == 1 ? (incdir + 3 - edgedir) % 3 - 1 : 2 - (incdir + 3 - edgedir) % 3); - int eind1 =((edgedir << 2) |(side << ind1) |((inc > 0 ? 1 : 0) << ind2)); - int eind2 =((edgedir << 2) |(side << ind1) |((inc > 0 ? 0 : 1) << ind2)); + int eind1 = ((edgedir << 2) | (side << ind1) | ((inc > 0 ? 1 : 0) << ind2)); + int eind2 = ((edgedir << 2) | (side << ind1) | ((inc > 0 ? 0 : 1) << ind2)); #ifdef IN_DEBUG_MODE dc_printf("Index 1: %d Alpha 1: %f Index 2: %d Alpha 2: %f\n", eind1, alpha, eind2, alpha); /* - if(alpha < 0 || alpha > 1) - { - dc_printf("Index 1: %d Alpha 1: %f Index 2: %d Alpha 2: %f\n", eind1, alpha, eind2, alpha); - printInfo(st1); - printInfo(st2); - } - */ + if(alpha < 0 || alpha > 1) { + dc_printf("Index 1: %d Alpha 1: %f Index 2: %d Alpha 2: %f\n", eind1, alpha, eind2, alpha); + printInfo(st1); + printInfo(st2); + } + */ #endif // Flip edge parity - LeafNode* nleaf1 = flipEdge(leaf1, eind1, alpha); - LeafNode* nleaf2 = flipEdge(leaf2, eind2, alpha); + LeafNode *nleaf1 = flipEdge(leaf1, eind1, alpha); + LeafNode *nleaf2 = flipEdge(leaf2, eind2, alpha); // Update parent link updateParent(node, len, st1, nleaf1); @@ -1485,13 +1361,13 @@ LeafNode* Octree::patchAdjacent(InternalNode* node, int len, int st1[3], // updateParent(nleaf2, mindimen, st2); /* - float m[3]; - dc_printf("Adding new point: %f %f %f\n", spt[0], spt[1], spt[2]); - getMinimizer(leaf1, m); - dc_printf("Cell %d now has minimizer %f %f %f\n", leaf1, m[0], m[1], m[2]); - getMinimizer(leaf2, m); - dc_printf("Cell %d now has minimizer %f %f %f\n", leaf2, m[0], m[1], m[2]); - */ + float m[3]; + dc_printf("Adding new point: %f %f %f\n", spt[0], spt[1], spt[2]); + getMinimizer(leaf1, m); + dc_printf("Cell %d now has minimizer %f %f %f\n", leaf1, m[0], m[1], m[2]); + getMinimizer(leaf2, m); + dc_printf("Cell %d now has minimizer %f %f %f\n", leaf2, m[0], m[1], m[2]); + */ #ifdef IN_DEBUG_MODE dc_printf("After patching.\n"); @@ -1501,7 +1377,7 @@ LeafNode* Octree::patchAdjacent(InternalNode* node, int len, int st1[3], return nleaf2; } -Node* Octree::locateCell(InternalNode* node, int st[3], int len, int ori[3], int dir, int side, Node*& rleaf, int rst[3], int& rlen) +Node *Octree::locateCell(InternalNode *node, int st[3], int len, int ori[3], int dir, int side, Node *& rleaf, int rst[3], int& rlen) { #ifdef IN_DEBUG_MODE // dc_printf("Call to LOCATECELL with node "); @@ -1511,16 +1387,13 @@ Node* Octree::locateCell(InternalNode* node, int st[3], int len, int ori[3], int int i; len >>= 1; int ind = 0; - for(i = 0; i < 3; i ++) - { + for (i = 0; i < 3; i++) { ind <<= 1; - if(i == dir && side == 1) - { - ind |=(ori[i] <=(st[i] + len) ? 0 : 1); + if (i == dir && side == 1) { + ind |= (ori[i] <= (st[i] + len) ? 0 : 1); } - else - { - ind |=(ori[i] <(st[i] + len) ? 0 : 1); + else { + ind |= (ori[i] < (st[i] + len) ? 0 : 1); } } @@ -1532,86 +1405,74 @@ Node* Octree::locateCell(InternalNode* node, int st[3], int len, int ori[3], int rst[0] = st[0] + vertmap[ind][0] * len; rst[1] = st[1] + vertmap[ind][1] * len; rst[2] = st[2] + vertmap[ind][2] * len; - - if(hasChild(node, ind)) - { + + if (hasChild(node, ind)) { int count = getChildCount(node, ind); - Node* chd = getChild(node, count); - if(isLeaf(node, ind)) - { + Node *chd = getChild(node, count); + if (node->is_child_leaf(ind)) { rleaf = chd; rlen = len; } - else - { + else { // Recur setChild(node, count, locateCell(&chd->internal, rst, len, ori, dir, side, rleaf, rst, rlen)); } } - else - { + else { // Create a new child here - if(len == mindimen) - { - LeafNode* chd = createLeaf(0); - node = addChild(node, ind, (Node*)chd, 1); - rleaf = (Node*)chd; + if (len == mindimen) { + LeafNode *chd = createLeaf(0); + node = addChild(node, ind, (Node *)chd, 1); + rleaf = (Node *)chd; rlen = len; } - else - { + else { // Subdivide the empty cube - InternalNode* chd = createInternal(0); + InternalNode *chd = createInternal(0); node = addChild(node, ind, - locateCell(chd, rst, len, ori, dir, side, rleaf, rst, rlen), 0); + locateCell(chd, rst, len, ori, dir, side, rleaf, rst, rlen), 0); } } - + #ifdef IN_DEBUG_MODE // dc_printf("Return from LOCATECELL with node "); // printNode(newnode); #endif - return (Node*)node; + return (Node *)node; } -void Octree::checkElement(PathElement* ele) +void Octree::checkElement(PathElement *ele) { /* - if(ele != NULL && locateLeafCheck(ele->pos) != ele->node) - { - dc_printf("Screwed! at pos: %d %d %d\n", ele->pos[0]>>minshift, ele->pos[1]>>minshift, ele->pos[2]>>minshift); - exit(0); - } - */ + if(ele != NULL && locateLeafCheck(ele->pos) != ele->node) { + dc_printf("Screwed! at pos: %d %d %d\n", ele->pos[0]>>minshift, ele->pos[1]>>minshift, ele->pos[2]>>minshift); + exit(0); + } + */ } -void Octree::checkPath(PathElement* path) +void Octree::checkPath(PathElement *path) { PathElement *n = path; int same = 0; - while(n &&(same == 0 || n != path)) - { - same ++; + while (n && (same == 0 || n != path)) { + same++; checkElement(n); n = n->next; } } -void Octree::testFacePoint(PathElement* e1, PathElement* e2) +void Octree::testFacePoint(PathElement *e1, PathElement *e2) { int i; - PathElement * e = NULL; - for(i = 0; i < 3; i ++) - { - if(e1->pos[i] != e2->pos[i]) - { - if(e1->pos[i] < e2->pos[i]) - { + PathElement *e = NULL; + for (i = 0; i < 3; i++) { + if (e1->pos[i] != e2->pos[i]) { + if (e1->pos[i] < e2->pos[i]) { e = e2; } - else - { + else { e = e1; } break; @@ -1624,56 +1485,50 @@ void Octree::testFacePoint(PathElement* e1, PathElement* e2) getFacePoint(e, i, x, y, p, q); } -void Octree::getFacePoint(PathElement* leaf, int dir, int& x, int& y, float& p, float& q) +void Octree::getFacePoint(PathElement *leaf, int dir, int& x, int& y, float& p, float& q) { // Find average intersections float avg[3] = {0, 0, 0}; float off[3]; int num = 0, num2 = 0; - LeafNode* leafnode = locateLeaf(leaf->pos); - for(int i = 0; i < 4; i ++) - { + LeafNode *leafnode = locateLeaf(leaf->pos); + for (int i = 0; i < 4; i++) { int edgeind = faceMap[dir * 2][i]; int nst[3]; - for(int j = 0; j < 3; j ++) - { + for (int j = 0; j < 3; j++) { nst[j] = leaf->pos[j] + mindimen * vertmap[edgemap[edgeind][0]][j]; } - if(getEdgeIntersectionByIndex(nst, edgeind / 4, off, 1)) - { + if (getEdgeIntersectionByIndex(nst, edgeind / 4, off, 1)) { avg[0] += off[0]; avg[1] += off[1]; avg[2] += off[2]; - num ++; + num++; } - if(getEdgeParity(leafnode, edgeind)) - { - num2 ++; + if (getEdgeParity(leafnode, edgeind)) { + num2++; } } - if(num == 0) - { - dc_printf("Wrong! dir: %d pos: %d %d %d num: %d\n", dir, leaf->pos[0]>>minshift, leaf->pos[1]>>minshift, leaf->pos[2]>>minshift, num2); - avg[0] =(float) leaf->pos[0]; - avg[1] =(float) leaf->pos[1]; - avg[2] =(float) leaf->pos[2]; + if (num == 0) { + dc_printf("Wrong! dir: %d pos: %d %d %d num: %d\n", dir, leaf->pos[0] >> minshift, leaf->pos[1] >> minshift, leaf->pos[2] >> minshift, num2); + avg[0] = (float) leaf->pos[0]; + avg[1] = (float) leaf->pos[1]; + avg[2] = (float) leaf->pos[2]; } - else - { - + else { + avg[0] /= num; avg[1] /= num; avg[2] /= num; - + //avg[0] =(float) leaf->pos[0]; //avg[1] =(float) leaf->pos[1]; //avg[2] =(float) leaf->pos[2]; } - - int xdir =(dir + 1) % 3; - int ydir =(dir + 2) % 3; + + int xdir = (dir + 1) % 3; + int ydir = (dir + 2) % 3; float xf = avg[xdir]; float yf = avg[ydir]; @@ -1682,42 +1537,40 @@ void Octree::getFacePoint(PathElement* leaf, int dir, int& x, int& y, float& p, // Is it outside? // PathElement* leaf = leaf1->len < leaf2->len ? leaf1 : leaf2; /* - float* m =(leaf == leaf1 ? m1 : m2); - if(xf < leaf->pos[xdir] || - yf < leaf->pos[ydir] || - xf > leaf->pos[xdir] + leaf->len || - yf > leaf->pos[ydir] + leaf->len) - { - dc_printf("Outside cube(%d %d %d), %d : %d %d %f %f\n", leaf->pos[0], leaf->pos[1], leaf->pos[2], leaf->len, - pos, dir, xf, yf); + float* m =(leaf == leaf1 ? m1 : m2); + if(xf < leaf->pos[xdir] || + yf < leaf->pos[ydir] || + xf > leaf->pos[xdir] + leaf->len || + yf > leaf->pos[ydir] + leaf->len) { + dc_printf("Outside cube(%d %d %d), %d : %d %d %f %f\n", leaf->pos[0], leaf->pos[1], leaf->pos[2], leaf->len, + pos, dir, xf, yf); - // For now, snap to cell - xf = m[xdir]; - yf = m[ydir]; - } - */ + // For now, snap to cell + xf = m[xdir]; + yf = m[ydir]; + } + */ /* - if(alpha < 0 || alpha > 1 || - xf < leaf->pos[xdir] || xf > leaf->pos[xdir] + leaf->len || - yf < leaf->pos[ydir] || yf > leaf->pos[ydir] + leaf->len) - { - dc_printf("Alpha: %f Address: %d and %d\n", alpha, leaf1->node, leaf2->node); - dc_printf("GETFACEPOINT result:(%d %d %d) %d min:(%f %f %f);(%d %d %d) %d min:(%f %f %f).\n", - leaf1->pos[0], leaf1->pos[1], leaf1->pos[2], leaf1->len, m1[0], m1[1], m1[2], - leaf2->pos[0], leaf2->pos[1], leaf2->pos[2], leaf2->len, m2[0], m2[1], m2[2]); - dc_printf("Face point at dir %d pos %d: %f %f\n", dir, pos, xf, yf); - } - */ + if(alpha < 0 || alpha > 1 || + xf < leaf->pos[xdir] || xf > leaf->pos[xdir] + leaf->len || + yf < leaf->pos[ydir] || yf > leaf->pos[ydir] + leaf->len) { + dc_printf("Alpha: %f Address: %d and %d\n", alpha, leaf1->node, leaf2->node); + dc_printf("GETFACEPOINT result:(%d %d %d) %d min:(%f %f %f);(%d %d %d) %d min:(%f %f %f).\n", + leaf1->pos[0], leaf1->pos[1], leaf1->pos[2], leaf1->len, m1[0], m1[1], m1[2], + leaf2->pos[0], leaf2->pos[1], leaf2->pos[2], leaf2->len, m2[0], m2[1], m2[2]); + dc_printf("Face point at dir %d pos %d: %f %f\n", dir, pos, xf, yf); + } + */ #endif - + // Get the integer and float part - x =((leaf->pos[xdir]) >> minshift); - y =((leaf->pos[ydir]) >> minshift); + x = ((leaf->pos[xdir]) >> minshift); + y = ((leaf->pos[ydir]) >> minshift); - p =(xf - leaf->pos[xdir]) / mindimen; - q =(yf - leaf->pos[ydir]) / mindimen; + p = (xf - leaf->pos[xdir]) / mindimen; + q = (yf - leaf->pos[ydir]) / mindimen; #ifdef IN_DEBUG_MODE @@ -1725,41 +1578,37 @@ void Octree::getFacePoint(PathElement* leaf, int dir, int& x, int& y, float& p, #endif } -int Octree::findPair(PathElement* head, int pos, int dir, PathElement*& pre1, PathElement*& pre2) +int Octree::findPair(PathElement *head, int pos, int dir, PathElement *& pre1, PathElement *& pre2) { int side = getSide(head, pos, dir); - PathElement* cur = head; - PathElement* anchor; - PathElement* ppre1, *ppre2; - + PathElement *cur = head; + PathElement *anchor; + PathElement *ppre1, *ppre2; + // Start from this face, find a pair anchor = cur; ppre1 = cur; cur = cur->next; - while(cur != anchor &&(getSide(cur, pos, dir) == side)) - { + while (cur != anchor && (getSide(cur, pos, dir) == side)) { ppre1 = cur; cur = cur->next; } - if(cur == anchor) - { + if (cur == anchor) { // No pair found return side; } - + side = getSide(cur, pos, dir); ppre2 = cur; cur = cur->next; - while(getSide(cur, pos, dir) == side) - { + while (getSide(cur, pos, dir) == side) { ppre2 = cur; cur = cur->next; } - - + + // Switch pre1 and pre2 if we start from the higher side - if(side == -1) - { + if (side == -1) { cur = ppre1; ppre1 = ppre2; ppre2 = cur; @@ -1767,24 +1616,23 @@ int Octree::findPair(PathElement* head, int pos, int dir, PathElement*& pre1, Pa pre1 = ppre1; pre2 = ppre2; - + return 0; } -int Octree::getSide(PathElement* e, int pos, int dir) +int Octree::getSide(PathElement *e, int pos, int dir) { return (e->pos[dir] < pos ? -1 : 1); } -int Octree::isEqual(PathElement* e1, PathElement* e2) +int Octree::isEqual(PathElement *e1, PathElement *e2) { return (e1->pos[0] == e2->pos[0] && e1->pos[1] == e2->pos[1] && e1->pos[2] == e2->pos[2]); } -void Octree::compressRing(PathElement*& ring) +void Octree::compressRing(PathElement *& ring) { - if(ring == NULL) - { + if (ring == NULL) { return; } #ifdef IN_DEBUG_MODE @@ -1792,26 +1640,22 @@ void Octree::compressRing(PathElement*& ring) printPath(ring); #endif - PathElement* cur = ring->next->next; - PathElement* pre = ring->next; - PathElement* prepre = ring; - PathElement* anchor = prepre; - - do - { - while(isEqual(cur, prepre)) - { + PathElement *cur = ring->next->next; + PathElement *pre = ring->next; + PathElement *prepre = ring; + PathElement *anchor = prepre; + + do { + while (isEqual(cur, prepre)) { // Delete - if(cur == prepre) - { + if (cur == prepre) { // The ring has shrinked to a point delete pre; delete cur; anchor = NULL; break; } - else - { + else { prepre->next = cur->next; delete pre; delete cur; @@ -1820,17 +1664,16 @@ void Octree::compressRing(PathElement*& ring) anchor = prepre; } } - - if(anchor == NULL) - { + + if (anchor == NULL) { break; } - + prepre = pre; pre = cur; cur = cur->next; - } while(prepre != anchor); - + } while (prepre != anchor); + ring = anchor; #ifdef IN_DEBUG_MODE @@ -1845,18 +1688,14 @@ void Octree::buildSigns() // dc_printf("Building up look up table...\n"); int size = 1 << 12; unsigned char table[1 << 12]; - for(int i = 0; i < size; i ++) - { + for (int i = 0; i < size; i++) { table[i] = 0; } - for(int i = 0; i < 256; i ++) - { + for (int i = 0; i < 256; i++) { int ind = 0; - for(int j = 11; j >= 0; j --) - { + for (int j = 11; j >= 0; j--) { ind <<= 1; - if(((i >> edgemap[j][0]) & 1) ^((i >> edgemap[j][1]) & 1)) - { + if (((i >> edgemap[j][0]) & 1) ^ ((i >> edgemap[j][1]) & 1)) { ind |= 1; } } @@ -1870,21 +1709,18 @@ void Octree::buildSigns() buildSigns(table, root, 0, sg, cube); } -void Octree::buildSigns(unsigned char table[], Node* node, int isLeaf, int sg, int rvalue[8]) +void Octree::buildSigns(unsigned char table[], Node *node, int isLeaf, int sg, int rvalue[8]) { - if(node == NULL) - { - for(int i = 0; i < 8; i ++) - { + if (node == NULL) { + for (int i = 0; i < 8; i++) { rvalue[i] = sg; } return; } - if(isLeaf == 0) - { + if (isLeaf == 0) { // Internal node - Node* chd[8]; + Node *chd[8]; int leaf[8]; fillChildren(&node->internal, chd, leaf); @@ -1895,20 +1731,17 @@ void Octree::buildSigns(unsigned char table[], Node* node, int isLeaf, int sg, i // Get the rest int cube[8]; - for(int i = 1; i < 8; i ++) - { + for (int i = 1; i < 8; i++) { buildSigns(table, chd[i], leaf[i], oris[i], cube); rvalue[i] = cube[i]; } } - else - { + else { // Leaf node generateSigns(&node->leaf, table, sg); - for(int i = 0; i < 8; i ++) - { + for (int i = 0; i < 8; i++) { rvalue[i] = getSign(&node->leaf, i); } } @@ -1935,50 +1768,45 @@ void Octree::floodFill() } -void Octree::clearProcessBits(Node* node, int height) +void Octree::clearProcessBits(Node *node, int height) { int i; - if(height == 0) - { - // Leaf cell, - for(i = 0; i < 12; i ++) - { + if (height == 0) { + // Leaf cell, + for (i = 0; i < 12; i++) { setOutProcess(&node->leaf, i); } } - else - { + else { // Internal cell, recur int count = 0; - for(i = 0; i < 8; i ++) - { - if(hasChild(&node->internal, i)) - { + for (i = 0; i < 8; i++) { + if (hasChild(&node->internal, i)) { clearProcessBits(getChild(&node->internal, count), height - 1); - count ++; + count++; } } - } + } } -int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int threshold) +int Octree::floodFill(LeafNode *leaf, int st[3], int len, int height, int threshold) { int i, j; int maxtotal = 0; - // Leaf cell, + // Leaf cell, int par, inp; // Test if the leaf has intersection edges - for(i = 0; i < 12; i ++) { + for (i = 0; i < 12; i++) { par = getEdgeParity(leaf, i); inp = isInProcess(leaf, i); - if(par == 1 && inp == 0) { + if (par == 1 && inp == 0) { // Intersection edge, hasn't been processed // Let's start filling - GridQueue* queue = new GridQueue(); + GridQueue *queue = new GridQueue(); int total = 1; // Set to in process @@ -1994,7 +1822,7 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh // Queue processing int nst[3], dir; - while(queue->popQueue(nst, dir) == 1) { + while (queue->popQueue(nst, dir) == 1) { // dc_printf("nst: %d %d %d, dir: %d\n", nst[0]/mindimen, nst[1]/mindimen, nst[2]/mindimen, dir); // locations int stMask[3][3] = { @@ -2003,14 +1831,14 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh {0 - len, 0 - len, 0} }; int cst[2][3]; - for(j = 0; j < 3; j ++) { + for (j = 0; j < 3; j++) { cst[0][j] = nst[j]; cst[1][j] = nst[j] + stMask[dir][j]; } - // cells - LeafNode* cs[2]; - for(j = 0; j < 2; j ++) { + // cells + LeafNode *cs[2]; + for (j = 0; j < 2; j++) { cs[j] = locateLeaf(cst[j]); } @@ -2018,37 +1846,37 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh int s = getSign(cs[0], 0); // Masks - int fcCells[4] = {1,0,1,0}; + int fcCells[4] = {1, 0, 1, 0}; int fcEdges[3][4][3] = { - {{9,2,11},{8,1,10},{5,1,7},{4,2,6}}, - {{10,6,11},{8,5,9},{1,5,3},{0,6,2}}, - {{6,10,7},{4,9,5},{2,9,3},{0,10,1}} + {{9, 2, 11}, {8, 1, 10}, {5, 1, 7}, {4, 2, 6}}, + {{10, 6, 11}, {8, 5, 9}, {1, 5, 3}, {0, 6, 2}}, + {{6, 10, 7}, {4, 9, 5}, {2, 9, 3}, {0, 10, 1}} }; // Search for neighboring connected intersection edges - for(int find = 0; find < 4; find ++) { + for (int find = 0; find < 4; find++) { int cind = fcCells[find]; int eind, edge; - if(s == 0) { + if (s == 0) { // Original order - for(eind = 0; eind < 3; eind ++) { + for (eind = 0; eind < 3; eind++) { edge = fcEdges[dir][find][eind]; - if(getEdgeParity(cs[cind], edge) == 1) { + if (getEdgeParity(cs[cind], edge) == 1) { break; } } } else { // Inverse order - for(eind = 2; eind >= 0; eind --) { + for (eind = 2; eind >= 0; eind--) { edge = fcEdges[dir][find][eind]; - if(getEdgeParity(cs[cind], edge) == 1) { + if (getEdgeParity(cs[cind], edge) == 1) { break; } } } - - if(eind == 3 || eind == -1) { + + if (eind == 3 || eind == -1) { dc_printf("Wrong! this is not a consistent sign. %d\n", eind); } else { @@ -2057,12 +1885,12 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh est[1] = cst[cind][1] + vertmap[edgemap[edge][0]][1] * len; est[2] = cst[cind][2] + vertmap[edgemap[edge][0]][2] * len; int edir = edge / 4; - - if(isInProcess(cs[cind], edge) == 0) { + + if (isInProcess(cs[cind], edge) == 0) { setInProcessAll(est, edir); queue->pushQueue(est, edir); // dc_printf("Pushed: est: %d %d %d, edir: %d\n", est[0]/len, est[1]/len, est[2]/len, edir); - total ++; + total++; } } } @@ -2070,16 +1898,16 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh dc_printf("Size of component: %d ", total); - if(threshold == 0) { + if (threshold == 0) { // Measuring stage - if(total > maxtotal) { + if (total > maxtotal) { maxtotal = total; } dc_printf(".\n"); continue; } - - if(total >= threshold) { + + if (total >= threshold) { dc_printf("Maintained.\n"); continue; } @@ -2095,7 +1923,7 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh queue->pushQueue(mst, mdir); // Queue processing - while(queue->popQueue(nst, dir) == 1) { + while (queue->popQueue(nst, dir) == 1) { // dc_printf("nst: %d %d %d, dir: %d\n", nst[0]/mindimen, nst[1]/mindimen, nst[2]/mindimen, dir); // locations int stMask[3][3] = { @@ -2104,51 +1932,51 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh {0 - len, 0 - len, 0} }; int cst[2][3]; - for(j = 0; j < 3; j ++) { + for (j = 0; j < 3; j++) { cst[0][j] = nst[j]; cst[1][j] = nst[j] + stMask[dir][j]; } - // cells - LeafNode* cs[2]; - for(j = 0; j < 2; j ++) + // cells + LeafNode *cs[2]; + for (j = 0; j < 2; j++) cs[j] = locateLeaf(cst[j]); // Middle sign int s = getSign(cs[0], 0); // Masks - int fcCells[4] = {1,0,1,0}; + int fcCells[4] = {1, 0, 1, 0}; int fcEdges[3][4][3] = { - {{9,2,11},{8,1,10},{5,1,7},{4,2,6}}, - {{10,6,11},{8,5,9},{1,5,3},{0,6,2}}, - {{6,10,7},{4,9,5},{2,9,3},{0,10,1}} + {{9, 2, 11}, {8, 1, 10}, {5, 1, 7}, {4, 2, 6}}, + {{10, 6, 11}, {8, 5, 9}, {1, 5, 3}, {0, 6, 2}}, + {{6, 10, 7}, {4, 9, 5}, {2, 9, 3}, {0, 10, 1}} }; // Search for neighboring connected intersection edges - for(int find = 0; find < 4; find ++) { + for (int find = 0; find < 4; find++) { int cind = fcCells[find]; int eind, edge; - if(s == 0) { + if (s == 0) { // Original order - for(eind = 0; eind < 3; eind ++) { + for (eind = 0; eind < 3; eind++) { edge = fcEdges[dir][find][eind]; - if(isInProcess(cs[cind], edge) == 1) { + if (isInProcess(cs[cind], edge) == 1) { break; } } } else { // Inverse order - for(eind = 2; eind >= 0; eind --) { + for (eind = 2; eind >= 0; eind--) { edge = fcEdges[dir][find][eind]; - if(isInProcess(cs[cind], edge) == 1) { + if (isInProcess(cs[cind], edge) == 1) { break; } } } - - if(eind == 3 || eind == -1) { + + if (eind == 3 || eind == -1) { dc_printf("Wrong! this is not a consistent sign. %d\n", eind); } else { @@ -2157,12 +1985,12 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh est[1] = cst[cind][1] + vertmap[edgemap[edge][0]][1] * len; est[2] = cst[cind][2] + vertmap[edgemap[edge][0]][2] * len; int edir = edge / 4; - - if(getEdgeParity(cs[cind], edge) == 1) { + + if (getEdgeParity(cs[cind], edge) == 1) { flipParityAll(est, edir); queue->pushQueue(est, edir); // dc_printf("Pushed: est: %d %d %d, edir: %d\n", est[0]/len, est[1]/len, est[2]/len, edir); - total ++; + total++; } } } @@ -2173,35 +2001,30 @@ int Octree::floodFill(LeafNode* leaf, int st[3], int len, int height, int thresh return maxtotal; } -int Octree::floodFill(Node* node, int st[3], int len, int height, int threshold) +int Octree::floodFill(Node *node, int st[3], int len, int height, int threshold) { int i; int maxtotal = 0; - if(height == 0) - { + if (height == 0) { maxtotal = floodFill(&node->leaf, st, len, height, threshold); } - else - { + else { // Internal cell, recur int count = 0; len >>= 1; - for(i = 0; i < 8; i ++) - { - if(hasChild((InternalNode*)node, i)) - { + for (i = 0; i < 8; i++) { + if (hasChild((InternalNode *)node, i)) { int nst[3]; nst[0] = st[0] + vertmap[i][0] * len; nst[1] = st[1] + vertmap[i][1] * len; nst[2] = st[2] + vertmap[i][2] * len; - - int d = floodFill(getChild((InternalNode*)node, count), nst, len, height - 1, threshold); - if(d > maxtotal) - { + + int d = floodFill(getChild((InternalNode *)node, count), nst, len, height - 1, threshold); + if (d > maxtotal) { maxtotal = d; } - count ++; + count++; } } } @@ -2220,7 +2043,7 @@ void Octree::writeOut() countIntersection(root, maxDepth, numQuads, numVertices, numEdges); dc_printf("Vertices counted: %d Polys counted: %d \n", numVertices, numQuads); - output_mesh = alloc_output(numVertices, numQuads); + output_mesh = alloc_output(numVertices, numQuads); int offset = 0; int st[3] = {0, 0, 0}; @@ -2234,39 +2057,32 @@ void Octree::writeOut() dc_printf("Vertices written: %d Quads written: %d \n", offset, actualQuads); } -void Octree::countIntersection(Node* node, int height, int& nedge, int& ncell, int& nface) +void Octree::countIntersection(Node *node, int height, int& nedge, int& ncell, int& nface) { - if(height > 0) - { + if (height > 0) { int total = getNumChildren(&node->internal); - for(int i = 0; i < total; i ++) - { + for (int i = 0; i < total; i++) { countIntersection(getChild(&node->internal, i), height - 1, nedge, ncell, nface); } } - else - { + else { nedge += getNumEdges2(&node->leaf); int smask = getSignMask(&node->leaf); - - if(use_manifold) - { + + if (use_manifold) { int comps = manifold_table[smask].comps; ncell += comps; } else { - if(smask > 0 && smask < 255) - { - ncell ++; + if (smask > 0 && smask < 255) { + ncell++; } } - - for(int i = 0; i < 3; i ++) - { - if(getFaceEdgeNum(&node->leaf, i * 2)) - { - nface ++; + + for (int i = 0; i < 3; i++) { + if (getFaceEdgeNum(&node->leaf, i * 2)) { + nface++; } } } @@ -2275,92 +2091,89 @@ void Octree::countIntersection(Node* node, int height, int& nedge, int& ncell, i /* from http://eigen.tuxfamily.org/bz/show_bug.cgi?id=257 */ template void pseudoInverse(const _Matrix_Type_ &a, - _Matrix_Type_ &result, - double epsilon = std::numeric_limits::epsilon()) + _Matrix_Type_ &result, + double epsilon = std::numeric_limits::epsilon()) { Eigen::JacobiSVD< _Matrix_Type_ > svd = a.jacobiSvd(Eigen::ComputeFullU | - Eigen::ComputeFullV); + Eigen::ComputeFullV); typename _Matrix_Type_::Scalar tolerance = epsilon * std::max(a.cols(), - a.rows()) * - svd.singularValues().array().abs().maxCoeff(); + a.rows()) * + svd.singularValues().array().abs().maxCoeff(); result = svd.matrixV() * - _Matrix_Type_((svd.singularValues().array().abs() > - tolerance).select(svd.singularValues(). - array().inverse(), 0)).asDiagonal() * - svd.matrixU().adjoint(); + _Matrix_Type_((svd.singularValues().array().abs() > + tolerance).select(svd.singularValues(). + array().inverse(), 0)).asDiagonal() * + svd.matrixU().adjoint(); } void solve_least_squares(const float halfA[], const float b[], - const float midpoint[], float rvalue[]) + const float midpoint[], float rvalue[]) { /* calculate pseudo-inverse */ Eigen::MatrixXf A(3, 3), pinv(3, 3); A << halfA[0], halfA[1], halfA[2], - halfA[1], halfA[3], halfA[4], - halfA[2], halfA[4], halfA[5]; + halfA[1], halfA[3], halfA[4], + halfA[2], halfA[4], halfA[5]; pseudoInverse(A, pinv); Eigen::Vector3f b2(b), mp(midpoint), result; b2 = b2 + A * -mp; result = pinv * b2 + mp; - for(int i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) rvalue[i] = result(i); } void minimize(float rvalue[3], float mp[3], const float pts[12][3], - const float norms[12][3], const int parity[12]) + const float norms[12][3], const int parity[12]) { float ata[6] = {0, 0, 0, 0, 0, 0}; float atb[3] = {0, 0, 0}; int ec = 0; - - for(int i = 0; i < 12; i ++) - { + + for (int i = 0; i < 12; i++) { // if(getEdgeParity(leaf, i)) - if(parity[i]) - { - const float* norm = norms[i]; - const float* p = pts[i]; + if (parity[i]) { + const float *norm = norms[i]; + const float *p = pts[i]; // QEF - ata[0] +=(float)(norm[0] * norm[0]); - ata[1] +=(float)(norm[0] * norm[1]); - ata[2] +=(float)(norm[0] * norm[2]); - ata[3] +=(float)(norm[1] * norm[1]); - ata[4] +=(float)(norm[1] * norm[2]); - ata[5] +=(float)(norm[2] * norm[2]); - + ata[0] += (float)(norm[0] * norm[0]); + ata[1] += (float)(norm[0] * norm[1]); + ata[2] += (float)(norm[0] * norm[2]); + ata[3] += (float)(norm[1] * norm[1]); + ata[4] += (float)(norm[1] * norm[2]); + ata[5] += (float)(norm[2] * norm[2]); + double pn = p[0] * norm[0] + p[1] * norm[1] + p[2] * norm[2]; - - atb[0] +=(float)(norm[0] * pn); - atb[1] +=(float)(norm[1] * pn); - atb[2] +=(float)(norm[2] * pn); + + atb[0] += (float)(norm[0] * pn); + atb[1] += (float)(norm[1] * pn); + atb[2] += (float)(norm[2] * pn); // Minimizer mp[0] += p[0]; mp[1] += p[1]; mp[2] += p[2]; - - ec ++; + + ec++; } } - if(ec == 0) - { + if (ec == 0) { return; } mp[0] /= ec; mp[1] /= ec; mp[2] /= ec; - + // Solve least squares solve_least_squares(ata, atb, mp, rvalue); } -void Octree::computeMinimizer(LeafNode* leaf, int st[3], int len, float rvalue[3]) +void Octree::computeMinimizer(LeafNode *leaf, int st[3], int len, float rvalue[3]) { // First, gather all edge intersections float pts[12][3], norms[12][3]; @@ -2370,19 +2183,18 @@ void Octree::computeMinimizer(LeafNode* leaf, int st[3], int len, float rvalue[3 // Next, construct QEF and minimizer float mp[3] = {0, 0, 0}; minimize(rvalue, mp, pts, norms, parity); - + /* Restraining the location of the minimizer */ float nh1 = hermite_num * len; - float nh2 =(1 + hermite_num) * len; - if((mode == DUALCON_MASS_POINT || mode == DUALCON_CENTROID) || - (rvalue[0] < st[0] - nh1 || rvalue[1] < st[1] - nh1 || rvalue[2] < st[2] - nh1 || - rvalue[0] > st[0] + nh2 || rvalue[1] > st[1] + nh2 || rvalue[2] > st[2] + nh2)) - { - if(mode == DUALCON_CENTROID) { + float nh2 = (1 + hermite_num) * len; + if ((mode == DUALCON_MASS_POINT || mode == DUALCON_CENTROID) || + (rvalue[0] < st[0] - nh1 || rvalue[1] < st[1] - nh1 || rvalue[2] < st[2] - nh1 || + rvalue[0] > st[0] + nh2 || rvalue[1] > st[1] + nh2 || rvalue[2] > st[2] + nh2)) { + if (mode == DUALCON_CENTROID) { // Use centroids - rvalue[0] =(float) st[0] + len / 2; - rvalue[1] =(float) st[1] + len / 2; - rvalue[2] =(float) st[2] + len / 2; + rvalue[0] = (float) st[0] + len / 2; + rvalue[1] = (float) st[1] + len / 2; + rvalue[2] = (float) st[2] + len / 2; } else { // Use mass point instead @@ -2393,120 +2205,96 @@ void Octree::computeMinimizer(LeafNode* leaf, int st[3], int len, float rvalue[3 } } -void Octree::generateMinimizer(Node* node, int st[3], int len, int height, int& offset) +void Octree::generateMinimizer(Node *node, int st[3], int len, int height, int& offset) { int i, j; - if(height == 0) - { + if (height == 0) { // Leaf cell, generate // First, find minimizer float rvalue[3]; - rvalue[0] =(float) st[0] + len / 2; - rvalue[1] =(float) st[1] + len / 2; - rvalue[2] =(float) st[2] + len / 2; + rvalue[0] = (float) st[0] + len / 2; + rvalue[1] = (float) st[1] + len / 2; + rvalue[2] = (float) st[2] + len / 2; computeMinimizer(&node->leaf, st, len, rvalue); // Update //float fnst[3]; - for(j = 0; j < 3; j ++) - { + for (j = 0; j < 3; j++) { rvalue[j] = rvalue[j] * range / dimen + origin[j]; //fnst[j] = st[j] * range / dimen + origin[j]; } int mult = 0, smask = getSignMask(&node->leaf); - - if(use_manifold) - { + + if (use_manifold) { mult = manifold_table[smask].comps; } - else - { - if(smask > 0 && smask < 255) - { + else { + if (smask > 0 && smask < 255) { mult = 1; } } - for(j = 0; j < mult; j ++) - { + for (j = 0; j < mult; j++) { add_vert(output_mesh, rvalue); } - + // Store the index setMinimizerIndex(&node->leaf, offset); offset += mult; } - else - { + else { // Internal cell, recur int count = 0; len >>= 1; - for(i = 0; i < 8; i ++) - { - if(hasChild(&node->internal, i)) - { + for (i = 0; i < 8; i++) { + if (hasChild(&node->internal, i)) { int nst[3]; nst[0] = st[0] + vertmap[i][0] * len; nst[1] = st[1] + vertmap[i][1] * len; nst[2] = st[2] + vertmap[i][2] * len; - + generateMinimizer(getChild(&node->internal, count), - nst, len, height - 1, offset); - count ++; + nst, len, height - 1, offset); + count++; } } } } -void Octree::processEdgeWrite(Node* node[4], int depth[4], int maxdep, int dir) +void Octree::processEdgeWrite(Node *node[4], int depth[4], int maxdep, int dir) { //int color = 0; int i = 3; { - if(getEdgeParity((LeafNode*)(node[i]), processEdgeMask[dir][i])) - { + if (getEdgeParity((LeafNode *)(node[i]), processEdgeMask[dir][i])) { int flip = 0; int edgeind = processEdgeMask[dir][i]; - if(getSign((LeafNode*)node[i], edgemap[edgeind][1]) > 0) - { + if (getSign((LeafNode *)node[i], edgemap[edgeind][1]) > 0) { flip = 1; } - + int num = 0; { int ind[8]; - if(use_manifold) - { - /* Deprecated - int ind[4] = { - getMinimizerIndex(node[0], processEdgeMask[dir][0]), - getMinimizerIndex(node[1], processEdgeMask[dir][1]), - getMinimizerIndex(node[3], processEdgeMask[dir][3]), - getMinimizerIndex(node[2], processEdgeMask[dir][2]) - }; - num = 4; - */ + if (use_manifold) { int vind[2]; - int seq[4] = {0,1,3,2}; - for(int k = 0; k < 4; k ++) - { - getMinimizerIndices((LeafNode*)(node[seq[k]]), processEdgeMask[dir][seq[k]], vind); - ind[num] = vind[0]; - num ++; - - if(vind[1] != -1) - { - ind[num] = vind[1]; - num ++; - if(flip == 0) - { - ind[num-1] = vind[0]; - ind[num-2] = vind[1]; + int seq[4] = {0, 1, 3, 2}; + for (int k = 0; k < 4; k++) { + getMinimizerIndices((LeafNode *)(node[seq[k]]), processEdgeMask[dir][seq[k]], vind); + ind[num] = vind[0]; + num++; + + if (vind[1] != -1) { + ind[num] = vind[1]; + num++; + if (flip == 0) { + ind[num - 1] = vind[0]; + ind[num - 2] = vind[1]; } } } @@ -2516,126 +2304,68 @@ void Octree::processEdgeWrite(Node* node[4], int depth[4], int maxdep, int dir) non-quads */ } else { - if(flip) { - ind[0] = getMinimizerIndex((LeafNode*)(node[2])); - ind[1] = getMinimizerIndex((LeafNode*)(node[3])); - ind[2] = getMinimizerIndex((LeafNode*)(node[1])); - ind[3] = getMinimizerIndex((LeafNode*)(node[0])); + if (flip) { + ind[0] = getMinimizerIndex((LeafNode *)(node[2])); + ind[1] = getMinimizerIndex((LeafNode *)(node[3])); + ind[2] = getMinimizerIndex((LeafNode *)(node[1])); + ind[3] = getMinimizerIndex((LeafNode *)(node[0])); } else { - ind[0] = getMinimizerIndex((LeafNode*)(node[0])); - ind[1] = getMinimizerIndex((LeafNode*)(node[1])); - ind[2] = getMinimizerIndex((LeafNode*)(node[3])); - ind[3] = getMinimizerIndex((LeafNode*)(node[2])); + ind[0] = getMinimizerIndex((LeafNode *)(node[0])); + ind[1] = getMinimizerIndex((LeafNode *)(node[1])); + ind[2] = getMinimizerIndex((LeafNode *)(node[3])); + ind[3] = getMinimizerIndex((LeafNode *)(node[2])); } - + add_quad(output_mesh, ind); } - /* - if(outType == 0) - { - // OFF - - num =(color ? -num : num); - - fprintf(fout, "%d ", num); - - if(flip) - { - for(int k = num - 1; k >= 0; k --) - { - fprintf(fout, "%d ", ind[k]); - } - } - else - { - for(int k = 0; k < num; k ++) - { - fprintf(fout, "%d ", ind[k]); - } - } - - fprintf(fout, "\n"); - - actualQuads ++; - } - else if(outType == 1) - { - // PLY - - if(flip) - { - int tind[8]; - for(int k = num - 1; k >= 0; k --) - { - tind[k] = ind[num-1-k]; - } - // PLYWriter::writeFace(fout, num, tind); - } - else - { - // PLYWriter::writeFace(fout, num, ind); - } - - actualQuads ++; - }*/ } return; } - else - { + else { return; } } } -void Octree::edgeProcContour(Node* node[4], int leaf[4], int depth[4], int maxdep, int dir) +void Octree::edgeProcContour(Node *node[4], int leaf[4], int depth[4], int maxdep, int dir) { - if(!(node[0] && node[1] && node[2] && node[3])) - { + if (!(node[0] && node[1] && node[2] && node[3])) { return; } - if(leaf[0] && leaf[1] && leaf[2] && leaf[3]) - { + if (leaf[0] && leaf[1] && leaf[2] && leaf[3]) { processEdgeWrite(node, depth, maxdep, dir); } - else - { + else { int i, j; - Node* chd[4][8]; - for(j = 0; j < 4; j ++) - { - for(i = 0; i < 8; i ++) - { + Node *chd[4][8]; + for (j = 0; j < 4; j++) { + for (i = 0; i < 8; i++) { chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, - getChildCount(&node[j]->internal, i)) : NULL; + getChild(&node[j]->internal, + getChildCount(&node[j]->internal, i)) : NULL; } } // 2 edge calls - Node* ne[4]; + Node *ne[4]; int le[4]; int de[4]; - for(i = 0; i < 2; i ++) - { - int c[4] = {edgeProcEdgeMask[dir][i][0], - edgeProcEdgeMask[dir][i][1], - edgeProcEdgeMask[dir][i][2], - edgeProcEdgeMask[dir][i][3]}; + for (i = 0; i < 2; i++) { + int c[4] = {edgeProcEdgeMask[dir][i][0], + edgeProcEdgeMask[dir][i][1], + edgeProcEdgeMask[dir][i][2], + edgeProcEdgeMask[dir][i][3]}; - for(int j = 0; j < 4; j ++) - { - if(leaf[j]) - { + for (int j = 0; j < 4; j++) { + if (leaf[j]) { le[j] = leaf[j]; ne[j] = node[j]; de[j] = depth[j]; } - else - { - le[j] = isLeaf(&node[j]->internal, c[j]); + else { + le[j] = node[j]->internal.is_child_leaf(c[j]); ne[j] = chd[j][c[j]]; de[j] = depth[j] - 1; } @@ -2647,46 +2377,38 @@ void Octree::edgeProcContour(Node* node[4], int leaf[4], int depth[4], int maxde } } -void Octree::faceProcContour(Node* node[2], int leaf[2], int depth[2], int maxdep, int dir) +void Octree::faceProcContour(Node *node[2], int leaf[2], int depth[2], int maxdep, int dir) { - if(!(node[0] && node[1])) - { + if (!(node[0] && node[1])) { return; } - if(!(leaf[0] && leaf[1])) - { + if (!(leaf[0] && leaf[1])) { int i, j; // Fill children nodes - Node* chd[2][8]; - for(j = 0; j < 2; j ++) - { - for(i = 0; i < 8; i ++) - { - chd[j][i] =((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, - getChildCount(&node[j]->internal, i)) : NULL; + Node *chd[2][8]; + for (j = 0; j < 2; j++) { + for (i = 0; i < 8; i++) { + chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? + getChild(&node[j]->internal, + getChildCount(&node[j]->internal, i)) : NULL; } } // 4 face calls - Node* nf[2]; + Node *nf[2]; int df[2]; int lf[2]; - for(i = 0; i < 4; i ++) - { + for (i = 0; i < 4; i++) { int c[2] = {faceProcFaceMask[dir][i][0], faceProcFaceMask[dir][i][1]}; - for(int j = 0; j < 2; j ++) - { - if(leaf[j]) - { + for (int j = 0; j < 2; j++) { + if (leaf[j]) { lf[j] = leaf[j]; nf[j] = node[j]; df[j] = depth[j]; } - else - { - lf[j] = isLeaf(&node[j]->internal, c[j]); + else { + lf[j] = node[j]->internal.is_child_leaf(c[j]); nf[j] = chd[j][c[j]]; df[j] = depth[j] - 1; } @@ -2696,27 +2418,23 @@ void Octree::faceProcContour(Node* node[2], int leaf[2], int depth[2], int maxde // 4 edge calls int orders[2][4] = {{0, 0, 1, 1}, {0, 1, 0, 1}}; - Node* ne[4]; + Node *ne[4]; int le[4]; int de[4]; - - for(i = 0; i < 4; i ++) - { - int c[4] = {faceProcEdgeMask[dir][i][1], faceProcEdgeMask[dir][i][2], - faceProcEdgeMask[dir][i][3], faceProcEdgeMask[dir][i][4]}; - int* order = orders[faceProcEdgeMask[dir][i][0]]; - for(int j = 0; j < 4; j ++) - { - if(leaf[order[j]]) - { + for (i = 0; i < 4; i++) { + int c[4] = {faceProcEdgeMask[dir][i][1], faceProcEdgeMask[dir][i][2], + faceProcEdgeMask[dir][i][3], faceProcEdgeMask[dir][i][4]}; + int *order = orders[faceProcEdgeMask[dir][i][0]]; + + for (int j = 0; j < 4; j++) { + if (leaf[order[j]]) { le[j] = leaf[order[j]]; ne[j] = node[order[j]]; de[j] = depth[order[j]]; } - else - { - le[j] = isLeaf(&node[order[j]]->internal, c[j]); + else { + le[j] = node[order[j]]->internal.is_child_leaf(c[j]); ne[j] = chd[order[j]][c[j]]; de[j] = depth[order[j]] - 1; } @@ -2728,42 +2446,37 @@ void Octree::faceProcContour(Node* node[2], int leaf[2], int depth[2], int maxde } -void Octree::cellProcContour(Node* node, int leaf, int depth) +void Octree::cellProcContour(Node *node, int leaf, int depth) { - if(node == NULL) - { + if (node == NULL) { return; } - if(! leaf) - { + if (!leaf) { int i; // Fill children nodes - Node* chd[8]; - for(i = 0; i < 8; i ++) - { - chd[i] =((!leaf) && hasChild(&node->internal, i)) ? - getChild(&node->internal, - getChildCount(&node->internal, i)) : NULL; + Node *chd[8]; + for (i = 0; i < 8; i++) { + chd[i] = ((!leaf) && hasChild(&node->internal, i)) ? + getChild(&node->internal, + getChildCount(&node->internal, i)) : NULL; } // 8 Cell calls - for(i = 0; i < 8; i ++) - { - cellProcContour(chd[i], isLeaf(&node->internal, i), depth - 1); + for (i = 0; i < 8; i++) { + cellProcContour(chd[i], node->internal.is_child_leaf(i), depth - 1); } // 12 face calls - Node* nf[2]; + Node *nf[2]; int lf[2]; int df[2] = {depth - 1, depth - 1}; - for(i = 0; i < 12; i ++) - { + for (i = 0; i < 12; i++) { int c[2] = {cellProcFaceMask[i][0], cellProcFaceMask[i][1]}; - lf[0] = isLeaf(&node->internal, c[0]); - lf[1] = isLeaf(&node->internal, c[1]); + lf[0] = node->internal.is_child_leaf(c[0]); + lf[1] = node->internal.is_child_leaf(c[1]); nf[0] = chd[c[0]]; nf[1] = chd[c[1]]; @@ -2772,98 +2485,83 @@ void Octree::cellProcContour(Node* node, int leaf, int depth) } // 6 edge calls - Node* ne[4]; + Node *ne[4]; int le[4]; int de[4] = {depth - 1, depth - 1, depth - 1, depth - 1}; - for(i = 0; i < 6; i ++) - { + for (i = 0; i < 6; i++) { int c[4] = {cellProcEdgeMask[i][0], cellProcEdgeMask[i][1], cellProcEdgeMask[i][2], cellProcEdgeMask[i][3]}; - for(int j = 0; j < 4; j ++) - { - le[j] = isLeaf(&node->internal, c[j]); + for (int j = 0; j < 4; j++) { + le[j] = node->internal.is_child_leaf(c[j]); ne[j] = chd[c[j]]; } edgeProcContour(ne, le, de, depth - 1, cellProcEdgeMask[i][4]); } } - + } -void Octree::processEdgeParity(LeafNode* node[4], int depth[4], int maxdep, int dir) +void Octree::processEdgeParity(LeafNode *node[4], int depth[4], int maxdep, int dir) { int con = 0; - for(int i = 0; i < 4; i ++) - { + for (int i = 0; i < 4; i++) { // Minimal cell // if(op == 0) { - if(getEdgeParity(node[i], processEdgeMask[dir][i])) - { + if (getEdgeParity(node[i], processEdgeMask[dir][i])) { con = 1; break; } } } - if(con == 1) - { - for(int i = 0; i < 4; i ++) - { + if (con == 1) { + for (int i = 0; i < 4; i++) { setEdge(node[i], processEdgeMask[dir][i]); } } - + } -void Octree::edgeProcParity(Node* node[4], int leaf[4], int depth[4], int maxdep, int dir) +void Octree::edgeProcParity(Node *node[4], int leaf[4], int depth[4], int maxdep, int dir) { - if(!(node[0] && node[1] && node[2] && node[3])) - { + if (!(node[0] && node[1] && node[2] && node[3])) { return; } - if(leaf[0] && leaf[1] && leaf[2] && leaf[3]) - { - processEdgeParity((LeafNode**)node, depth, maxdep, dir); + if (leaf[0] && leaf[1] && leaf[2] && leaf[3]) { + processEdgeParity((LeafNode **)node, depth, maxdep, dir); } - else - { + else { int i, j; - Node* chd[4][8]; - for(j = 0; j < 4; j ++) - { - for(i = 0; i < 8; i ++) - { - chd[j][i] =((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, getChildCount(&node[j]->internal, i)) : NULL; + Node *chd[4][8]; + for (j = 0; j < 4; j++) { + for (i = 0; i < 8; i++) { + chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? + getChild(&node[j]->internal, getChildCount(&node[j]->internal, i)) : NULL; } } // 2 edge calls - Node* ne[4]; + Node *ne[4]; int le[4]; int de[4]; - for(i = 0; i < 2; i ++) - { - int c[4] = {edgeProcEdgeMask[dir][i][0], - edgeProcEdgeMask[dir][i][1], - edgeProcEdgeMask[dir][i][2], - edgeProcEdgeMask[dir][i][3]}; + for (i = 0; i < 2; i++) { + int c[4] = {edgeProcEdgeMask[dir][i][0], + edgeProcEdgeMask[dir][i][1], + edgeProcEdgeMask[dir][i][2], + edgeProcEdgeMask[dir][i][3]}; // int allleaf = 1; - for(int j = 0; j < 4; j ++) - { + for (int j = 0; j < 4; j++) { - if(leaf[j]) - { + if (leaf[j]) { le[j] = leaf[j]; ne[j] = node[j]; de[j] = depth[j]; } - else - { - le[j] = isLeaf(&node[j]->internal, c[j]); + else { + le[j] = node[j]->internal.is_child_leaf(c[j]); ne[j] = chd[j][c[j]]; de[j] = depth[j] - 1; @@ -2877,46 +2575,38 @@ void Octree::edgeProcParity(Node* node[4], int leaf[4], int depth[4], int maxdep } } -void Octree::faceProcParity(Node* node[2], int leaf[2], int depth[2], int maxdep, int dir) +void Octree::faceProcParity(Node *node[2], int leaf[2], int depth[2], int maxdep, int dir) { - if(!(node[0] && node[1])) - { + if (!(node[0] && node[1])) { return; } - if(!(leaf[0] && leaf[1])) - { + if (!(leaf[0] && leaf[1])) { int i, j; // Fill children nodes - Node* chd[2][8]; - for(j = 0; j < 2; j ++) - { - for(i = 0; i < 8; i ++) - { - chd[j][i] =((!leaf[j]) && hasChild(&node[j]->internal, i)) ? - getChild(&node[j]->internal, - getChildCount(&node[j]->internal, i)) : NULL; + Node *chd[2][8]; + for (j = 0; j < 2; j++) { + for (i = 0; i < 8; i++) { + chd[j][i] = ((!leaf[j]) && hasChild(&node[j]->internal, i)) ? + getChild(&node[j]->internal, + getChildCount(&node[j]->internal, i)) : NULL; } } // 4 face calls - Node* nf[2]; + Node *nf[2]; int df[2]; int lf[2]; - for(i = 0; i < 4; i ++) - { + for (i = 0; i < 4; i++) { int c[2] = {faceProcFaceMask[dir][i][0], faceProcFaceMask[dir][i][1]}; - for(int j = 0; j < 2; j ++) - { - if(leaf[j]) - { + for (int j = 0; j < 2; j++) { + if (leaf[j]) { lf[j] = leaf[j]; nf[j] = node[j]; df[j] = depth[j]; } - else - { - lf[j] = isLeaf(&node[j]->internal, c[j]); + else { + lf[j] = node[j]->internal.is_child_leaf(c[j]); nf[j] = chd[j][c[j]]; df[j] = depth[j] - 1; } @@ -2926,27 +2616,23 @@ void Octree::faceProcParity(Node* node[2], int leaf[2], int depth[2], int maxdep // 4 edge calls int orders[2][4] = {{0, 0, 1, 1}, {0, 1, 0, 1}}; - Node* ne[4]; + Node *ne[4]; int le[4]; int de[4]; - - for(i = 0; i < 4; i ++) - { - int c[4] = {faceProcEdgeMask[dir][i][1], faceProcEdgeMask[dir][i][2], - faceProcEdgeMask[dir][i][3], faceProcEdgeMask[dir][i][4]}; - int* order = orders[faceProcEdgeMask[dir][i][0]]; - for(int j = 0; j < 4; j ++) - { - if(leaf[order[j]]) - { + for (i = 0; i < 4; i++) { + int c[4] = {faceProcEdgeMask[dir][i][1], faceProcEdgeMask[dir][i][2], + faceProcEdgeMask[dir][i][3], faceProcEdgeMask[dir][i][4]}; + int *order = orders[faceProcEdgeMask[dir][i][0]]; + + for (int j = 0; j < 4; j++) { + if (leaf[order[j]]) { le[j] = leaf[order[j]]; ne[j] = node[order[j]]; de[j] = depth[order[j]]; } - else - { - le[j] = isLeaf((InternalNode*)(node[order[j]]), c[j]); + else { + le[j] = node[order[j]]->internal.is_child_leaf(c[j]); ne[j] = chd[order[j]][c[j]]; de[j] = depth[order[j]] - 1; } @@ -2958,42 +2644,37 @@ void Octree::faceProcParity(Node* node[2], int leaf[2], int depth[2], int maxdep } -void Octree::cellProcParity(Node* node, int leaf, int depth) +void Octree::cellProcParity(Node *node, int leaf, int depth) { - if(node == NULL) - { + if (node == NULL) { return; } - if(! leaf) - { + if (!leaf) { int i; // Fill children nodes - Node* chd[8]; - for(i = 0; i < 8; i ++) - { - chd[i] =((!leaf) && hasChild((InternalNode*)node, i)) ? - getChild((InternalNode*)node, - getChildCount((InternalNode*)node, i)) : NULL; + Node *chd[8]; + for (i = 0; i < 8; i++) { + chd[i] = ((!leaf) && hasChild((InternalNode *)node, i)) ? + getChild((InternalNode *)node, + getChildCount((InternalNode *)node, i)) : NULL; } // 8 Cell calls - for(i = 0; i < 8; i ++) - { - cellProcParity(chd[i], isLeaf((InternalNode*)node, i), depth - 1); + for (i = 0; i < 8; i++) { + cellProcParity(chd[i], node->internal.is_child_leaf(i), depth - 1); } // 12 face calls - Node* nf[2]; + Node *nf[2]; int lf[2]; int df[2] = {depth - 1, depth - 1}; - for(i = 0; i < 12; i ++) - { + for (i = 0; i < 12; i++) { int c[2] = {cellProcFaceMask[i][0], cellProcFaceMask[i][1]}; - lf[0] = isLeaf((InternalNode*)node, c[0]); - lf[1] = isLeaf((InternalNode*)node, c[1]); + lf[0] = node->internal.is_child_leaf(c[0]); + lf[1] = node->internal.is_child_leaf(c[1]); nf[0] = chd[c[0]]; nf[1] = chd[c[1]]; @@ -3002,23 +2683,21 @@ void Octree::cellProcParity(Node* node, int leaf, int depth) } // 6 edge calls - Node* ne[4]; + Node *ne[4]; int le[4]; int de[4] = {depth - 1, depth - 1, depth - 1, depth - 1}; - for(i = 0; i < 6; i ++) - { + for (i = 0; i < 6; i++) { int c[4] = {cellProcEdgeMask[i][0], cellProcEdgeMask[i][1], cellProcEdgeMask[i][2], cellProcEdgeMask[i][3]}; - for(int j = 0; j < 4; j ++) - { - le[j] = isLeaf((InternalNode*)node, c[j]); + for (int j = 0; j < 4; j++) { + le[j] = node->internal.is_child_leaf(c[j]); ne[j] = chd[c[j]]; } edgeProcParity(ne, le, de, depth - 1, cellProcEdgeMask[i][4]); } } - + } /* definitions for global arrays */ diff --git a/intern/dualcon/intern/octree.h b/intern/dualcon/intern/octree.h index aac09549ee6..550d584baa7 100644 --- a/intern/dualcon/intern/octree.h +++ b/intern/dualcon/intern/octree.h @@ -37,7 +37,7 @@ #include "dualcon.h" /** - * Main class and structures for scan-convertion, sign-generation, + * Main class and structures for scan-convertion, sign-generation, * and surface reconstruction. * * @author Tao Ju @@ -65,6 +65,12 @@ struct InternalNode { /* Can have up to eight children */ Node *children[0]; + + /// Test if child is leaf + int is_child_leaf(int index) const + { + return (child_is_leaf >> index) & 1; + } }; @@ -90,7 +96,7 @@ struct LeafNode /* TODO: remove this attribute once everything is fixed */ { char signs; int minimizer_index; - + unsigned short flood_fill; float edge_intersections[0]; @@ -112,33 +118,31 @@ extern const int faceProcFaceMask[3][4][3]; extern const int edgeProcEdgeMask[3][2][5]; extern const int faceProcEdgeMask[3][4][6]; extern const int processEdgeMask[3][4]; -extern const int dirCell[3][4][3]; +extern const int dirCell[3][4][3]; extern const int dirEdge[3][4]; /** * Structures for detecting/patching open cycles on the dual surface */ -struct PathElement -{ +struct PathElement { // Origin int pos[3]; // link - PathElement* next; + PathElement *next; }; -struct PathList -{ +struct PathList { // Head - PathElement* head; - PathElement* tail; + PathElement *head; + PathElement *tail; // Length of the list int length; // Next list - PathList* next; + PathList *next; }; @@ -147,21 +151,21 @@ struct PathList */ class Octree { -public: + public: /* Public members */ /// Memory allocators - VirtualMemoryAllocator * alloc[9]; - VirtualMemoryAllocator * leafalloc[4]; + VirtualMemoryAllocator *alloc[9]; + VirtualMemoryAllocator *leafalloc[4]; /// Root node - Node* root; + Node *root; /// Model reader - ModelReader* reader; + ModelReader *reader; /// Marching cubes table - Cubes* cubes; + Cubes *cubes; /// Length of grid int dimen; @@ -169,7 +173,7 @@ public: /// Maximum depth int maxDepth; - + /// The lower corner of the bounding box and the size float origin[3]; float range; @@ -181,10 +185,10 @@ public: int actualQuads, actualVerts; - PathList* ringList; + PathList *ringList; int maxTrianglePerCell; - int outType; // 0 for OFF, 1 for PLY, 2 for VOL + int outType; // 0 for OFF, 1 for PLY, 2 for VOL // For flood filling int use_flood_fill; @@ -196,16 +200,16 @@ public: DualConMode mode; -public: + public: /** * Construtor */ - Octree(ModelReader* mr, - DualConAllocOutput alloc_output_func, - DualConAddVert add_vert_func, - DualConAddQuad add_quad_func, - DualConFlags flags, DualConMode mode, int depth, - float threshold, float hermite_num); + Octree(ModelReader *mr, + DualConAllocOutput alloc_output_func, + DualConAddVert add_vert_func, + DualConAddQuad add_quad_func, + DualConFlags flags, DualConMode mode, int depth, + float threshold, float hermite_num); /** * Destructor @@ -217,11 +221,13 @@ public: */ void scanConvert(); - void *getOutputMesh() { return output_mesh; } + void *getOutputMesh() { + return output_mesh; + } -private: + private: /* Helper functions */ - + /** * Initialize memory allocators */ @@ -243,23 +249,23 @@ private: */ void resetMinimalEdges(); - void cellProcParity(Node* node, int leaf, int depth); - void faceProcParity(Node* node[2], int leaf[2], int depth[2], int maxdep, int dir); - void edgeProcParity(Node* node[4], int leaf[4], int depth[4], int maxdep, int dir); + void cellProcParity(Node *node, int leaf, int depth); + void faceProcParity(Node * node[2], int leaf[2], int depth[2], int maxdep, int dir); + void edgeProcParity(Node * node[4], int leaf[4], int depth[4], int maxdep, int dir); - void processEdgeParity(LeafNode* node[4], int depths[4], int maxdep, int dir); + void processEdgeParity(LeafNode * node[4], int depths[4], int maxdep, int dir); /** * Add triangles to the tree */ - void addTrian(); - void addTrian(Triangle* trian, int triind); - InternalNode* addTrian(InternalNode* node, Projections* p, int height); + void addAllTriangles(); + void addTriangle(Triangle *trian, int triind); + InternalNode *addTriangle(InternalNode *node, CubeTriangleIsect *p, int height); /** * Method to update minimizer in a cell: update edge intersections instead */ - LeafNode* updateCell(LeafNode* node, Projections* p); + LeafNode *updateCell(LeafNode *node, CubeTriangleIsect *p); /* Routines to detect and patch holes */ int numRings; @@ -273,48 +279,48 @@ private: /** * Trace the given node, find patches and fill them in */ - Node* trace(Node* node, int* st, int len, int depth, PathList*& paths); + Node *trace(Node *node, int *st, int len, int depth, PathList *& paths); /** * Look for path on the face and add to paths */ - void findPaths(Node* node[2], int leaf[2], int depth[2], int* st[2], int maxdep, int dir, PathList*& paths); + void findPaths(Node * node[2], int leaf[2], int depth[2], int *st[2], int maxdep, int dir, PathList * &paths); /** - * Combine two list1 and list2 into list1 using connecting paths list3, + * Combine two list1 and list2 into list1 using connecting paths list3, * while closed paths are appended to rings */ - void combinePaths(PathList*& list1, PathList* list2, PathList* paths, PathList*& rings); + void combinePaths(PathList *& list1, PathList *list2, PathList *paths, PathList *& rings); /** * Helper function: combine current paths in list1 and list2 to a single path and append to list3 */ - PathList* combineSinglePath(PathList*& head1, PathList* pre1, PathList*& list1, PathList*& head2, PathList* pre2, PathList*& list2); - + PathList *combineSinglePath(PathList *& head1, PathList *pre1, PathList *& list1, PathList *& head2, PathList *pre2, PathList *& list2); + /** * Functions to patch rings in a node */ - Node* patch(Node* node, int st[3], int len, PathList* rings); - Node* patchSplit(Node* node, int st[3], int len, PathList* rings, int dir, PathList*& nrings1, PathList*& nrings2); - Node* patchSplitSingle(Node* node, int st[3], int len, PathElement* head, int dir, PathList*& nrings1, PathList*& nrings2); - Node* connectFace(Node* node, int st[3], int len, int dir, PathElement* f1, PathElement* f2); - Node* locateCell(InternalNode* node, int st[3], int len, int ori[3], int dir, int side, Node*& rleaf, int rst[3], int& rlen); - void compressRing(PathElement*& ring); - void getFacePoint(PathElement* leaf, int dir, int& x, int& y, float& p, float& q); - LeafNode* patchAdjacent(InternalNode* node, int len, int st1[3], LeafNode* leaf1, int st2[3], LeafNode* leaf2, int walkdir, int inc, int dir, int side, float alpha); - int findPair(PathElement* head, int pos, int dir, PathElement*& pre1, PathElement*& pre2); - int getSide(PathElement* e, int pos, int dir); - int isEqual(PathElement* e1, PathElement* e2) ; - void preparePrimalEdgesMask(InternalNode* node); - void testFacePoint(PathElement* e1, PathElement* e2); - + Node *patch(Node * node, int st[3], int len, PathList * rings); + Node *patchSplit(Node * node, int st[3], int len, PathList * rings, int dir, PathList * &nrings1, PathList * &nrings2); + Node *patchSplitSingle(Node * node, int st[3], int len, PathElement * head, int dir, PathList * &nrings1, PathList * &nrings2); + Node *connectFace(Node * node, int st[3], int len, int dir, PathElement * f1, PathElement * f2); + Node *locateCell(InternalNode * node, int st[3], int len, int ori[3], int dir, int side, Node * &rleaf, int rst[3], int& rlen); + void compressRing(PathElement *& ring); + void getFacePoint(PathElement *leaf, int dir, int& x, int& y, float& p, float& q); + LeafNode *patchAdjacent(InternalNode * node, int len, int st1[3], LeafNode * leaf1, int st2[3], LeafNode * leaf2, int walkdir, int inc, int dir, int side, float alpha); + int findPair(PathElement *head, int pos, int dir, PathElement *& pre1, PathElement *& pre2); + int getSide(PathElement *e, int pos, int dir); + int isEqual(PathElement *e1, PathElement *e2); + void preparePrimalEdgesMask(InternalNode *node); + void testFacePoint(PathElement *e1, PathElement *e2); + /** * Path-related functions */ - void deletePath(PathList*& head, PathList* pre, PathList*& curr); - void printPath(PathList* path); - void printPath(PathElement* path); - void printElement(PathElement* ele); - void printPaths(PathList* path); - void checkElement(PathElement* ele); - void checkPath(PathElement* path); + void deletePath(PathList *& head, PathList *pre, PathList *& curr); + void printPath(PathList *path); + void printPath(PathElement *path); + void printElement(PathElement *ele); + void printPaths(PathList *path); + void checkElement(PathElement *ele); + void checkPath(PathElement *path); /** @@ -322,40 +328,40 @@ private: *(after patching rings) */ void buildSigns(); - void buildSigns(unsigned char table[], Node* node, int isLeaf, int sg, int rvalue[8]); + void buildSigns(unsigned char table[], Node * node, int isLeaf, int sg, int rvalue[8]); /************************************************************************/ /* To remove disconnected components */ /************************************************************************/ void floodFill(); - void clearProcessBits(Node* node, int height); - int floodFill(LeafNode* leaf, int st[3], int len, int height, int threshold); - int floodFill(Node* node, int st[3], int len, int height, int threshold); + void clearProcessBits(Node *node, int height); + int floodFill(LeafNode * leaf, int st[3], int len, int height, int threshold); + int floodFill(Node * node, int st[3], int len, int height, int threshold); /** * Write out polygon file */ void writeOut(); - - void countIntersection(Node* node, int height, int& nedge, int& ncell, int& nface); - void generateMinimizer(Node* node, int st[3], int len, int height, int& offset); - void computeMinimizer(LeafNode* leaf, int st[3], int len, float rvalue[3]); + + void countIntersection(Node *node, int height, int& nedge, int& ncell, int& nface); + void generateMinimizer(Node * node, int st[3], int len, int height, int& offset); + void computeMinimizer(LeafNode * leaf, int st[3], int len, float rvalue[3]); /** * Traversal functions to generate polygon model * op: 0 for counting, 1 for writing OBJ, 2 for writing OFF, 3 for writing PLY */ - void cellProcContour(Node* node, int leaf, int depth); - void faceProcContour(Node* node[2], int leaf[2], int depth[2], int maxdep, int dir); - void edgeProcContour(Node* node[4], int leaf[4], int depth[4], int maxdep, int dir); - void processEdgeWrite(Node* node[4], int depths[4], int maxdep, int dir); + void cellProcContour(Node *node, int leaf, int depth); + void faceProcContour(Node * node[2], int leaf[2], int depth[2], int maxdep, int dir); + void edgeProcContour(Node * node[4], int leaf[4], int depth[4], int maxdep, int dir); + void processEdgeWrite(Node * node[4], int depths[4], int maxdep, int dir); /* output callbacks/data */ DualConAllocOutput alloc_output; DualConAddVert add_vert; DualConAddQuad add_quad; void *output_mesh; - -private: + + private: /************ Operators for all nodes ************/ /// Lookup table @@ -368,48 +374,40 @@ private: /// Build up lookup table void buildTable() { - for(int i = 0; i < 256; i ++) - { + for (int i = 0; i < 256; i++) { numChildrenTable[i] = 0; int count = 0; - for(int j = 0; j < 8; j ++) - { - numChildrenTable[i] +=((i >> j) & 1); + for (int j = 0; j < 8; j++) { + numChildrenTable[i] += ((i >> j) & 1); childrenCountTable[i][j] = count; childrenIndexTable[i][count] = j; - count +=((i >> j) & 1); + count += ((i >> j) & 1); } } - for(int i = 0; i < 8; i ++) - { + for (int i = 0; i < 8; i++) { numEdgeTable[i] = 0; int count = 0; - for(int j = 0; j < 3; j ++) - { - numEdgeTable[i] +=((i >> j) & 1); + for (int j = 0; j < 3; j++) { + numEdgeTable[i] += ((i >> j) & 1); edgeCountTable[i][j] = count; - count +=((i >> j) & 1); + count += ((i >> j) & 1); } } } - int getSign(Node* node, int height, int index) + int getSign(Node *node, int height, int index) { - if(height == 0) - { + if (height == 0) { return getSign(&node->leaf, index); } - else - { - if(hasChild(&node->internal, index)) - { + else { + if (hasChild(&node->internal, index)) { return getSign(getChild(&node->internal, getChildCount(&node->internal, index)), height - 1, index); } - else - { + else { return getSign(getChild(&node->internal, 0), height - 1, 7 - getChildIndex(&node->internal, 0)); @@ -421,33 +419,32 @@ private: void printInfo(int st[3]) { - printf("INFO AT: %d %d %d\n", st[0] >> minshift, st[1] >>minshift, st[2] >> minshift); - LeafNode* leaf = (LeafNode*)locateLeafCheck(st); - if(leaf) + printf("INFO AT: %d %d %d\n", st[0] >> minshift, st[1] >> minshift, st[2] >> minshift); + LeafNode *leaf = (LeafNode *)locateLeafCheck(st); + if (leaf) printInfo(leaf); else printf("Leaf not exists!\n"); } - void printInfo(const LeafNode* leaf) + void printInfo(const LeafNode *leaf) { /* - printf("Edge mask: "); - for(int i = 0; i < 12; i ++) - { - printf("%d ", getEdgeParity(leaf, i)); - } - printf("\n"); - printf("Stored edge mask: "); - for(i = 0; i < 3; i ++) - { - printf("%d ", getStoredEdgesParity(leaf, i)); - } - printf("\n"); + printf("Edge mask: "); + for(int i = 0; i < 12; i ++) + { + printf("%d ", getEdgeParity(leaf, i)); + } + printf("\n"); + printf("Stored edge mask: "); + for(i = 0; i < 3; i ++) + { + printf("%d ", getStoredEdgesParity(leaf, i)); + } + printf("\n"); */ printf("Sign mask: "); - for(int i = 0; i < 8; i ++) - { + for (int i = 0; i < 8; i++) { printf("%d ", getSign(leaf, i)); } printf("\n"); @@ -455,24 +452,24 @@ private: } /// Retrieve signs - int getSign(const LeafNode* leaf, int index) + int getSign(const LeafNode *leaf, int index) { - return ((leaf->signs >> index) & 1); + return ((leaf->signs >> index) & 1); } /// Set sign - void setSign(LeafNode* leaf, int index) + void setSign(LeafNode *leaf, int index) { leaf->signs |= (1 << index); } - void setSign(LeafNode* leaf, int index, int sign) + void setSign(LeafNode *leaf, int index, int sign) { leaf->signs &= (~(1 << index)); leaf->signs |= ((sign & 1) << index); } - int getSignMask(const LeafNode* leaf) + int getSignMask(const LeafNode *leaf) { return leaf->signs; } @@ -480,14 +477,13 @@ private: void setInProcessAll(int st[3], int dir) { int nst[3], eind; - for(int i = 0; i < 4; i ++) - { + for (int i = 0; i < 4; i++) { nst[0] = st[0] + dirCell[dir][i][0] * mindimen; nst[1] = st[1] + dirCell[dir][i][1] * mindimen; nst[2] = st[2] + dirCell[dir][i][2] * mindimen; eind = dirEdge[dir][i]; - LeafNode* cell = locateLeafCheck(nst); + LeafNode *cell = locateLeafCheck(nst); assert(cell); setInProcess(cell, eind); @@ -497,94 +493,92 @@ private: void flipParityAll(int st[3], int dir) { int nst[3], eind; - for(int i = 0; i < 4; i ++) - { + for (int i = 0; i < 4; i++) { nst[0] = st[0] + dirCell[dir][i][0] * mindimen; nst[1] = st[1] + dirCell[dir][i][1] * mindimen; nst[2] = st[2] + dirCell[dir][i][2] * mindimen; eind = dirEdge[dir][i]; - LeafNode* cell = locateLeaf(nst); + LeafNode *cell = locateLeaf(nst); flipEdge(cell, eind); } } - void setInProcess(LeafNode* leaf, int eind) + void setInProcess(LeafNode *leaf, int eind) { assert(eind >= 0 && eind <= 11); leaf->flood_fill |= (1 << eind); } - - void setOutProcess(LeafNode* leaf, int eind) + + void setOutProcess(LeafNode *leaf, int eind) { assert(eind >= 0 && eind <= 11); - + leaf->flood_fill &= ~(1 << eind); } - int isInProcess(LeafNode* leaf, int eind) + int isInProcess(LeafNode *leaf, int eind) { assert(eind >= 0 && eind <= 11); - + return (leaf->flood_fill >> eind) & 1; } /// Generate signs at the corners from the edge parity - void generateSigns(LeafNode* leaf, unsigned char table[], int start) + void generateSigns(LeafNode *leaf, unsigned char table[], int start) { - leaf->signs = table[leaf->edge_parity]; + leaf->signs = table[leaf->edge_parity]; - if((start ^ leaf->signs) & 1) - { + if ((start ^ leaf->signs) & 1) { leaf->signs = ~(leaf->signs); } } /// Get edge parity - int getEdgeParity(LeafNode* leaf, int index) + int getEdgeParity(LeafNode *leaf, int index) { assert(index >= 0 && index <= 11); - + return (leaf->edge_parity >> index) & 1; } /// Get edge parity on a face - int getFaceParity(LeafNode* leaf, int index) + int getFaceParity(LeafNode *leaf, int index) { - int a = getEdgeParity(leaf, faceMap[index][0]) + - getEdgeParity(leaf, faceMap[index][1]) + - getEdgeParity(leaf, faceMap[index][2]) + - getEdgeParity(leaf, faceMap[index][3]); + int a = getEdgeParity(leaf, faceMap[index][0]) + + getEdgeParity(leaf, faceMap[index][1]) + + getEdgeParity(leaf, faceMap[index][2]) + + getEdgeParity(leaf, faceMap[index][3]); return (a & 1); } - int getFaceEdgeNum(LeafNode* leaf, int index) + int getFaceEdgeNum(LeafNode *leaf, int index) { - int a = getEdgeParity(leaf, faceMap[index][0]) + - getEdgeParity(leaf, faceMap[index][1]) + - getEdgeParity(leaf, faceMap[index][2]) + - getEdgeParity(leaf, faceMap[index][3]); + int a = getEdgeParity(leaf, faceMap[index][0]) + + getEdgeParity(leaf, faceMap[index][1]) + + getEdgeParity(leaf, faceMap[index][2]) + + getEdgeParity(leaf, faceMap[index][3]); return a; } /// Set edge parity - void flipEdge(LeafNode* leaf, int index) + void flipEdge(LeafNode *leaf, int index) { assert(index >= 0 && index <= 11); leaf->edge_parity ^= (1 << index); } - + /// Set 1 - void setEdge(LeafNode* leaf, int index) + void setEdge(LeafNode *leaf, int index) { assert(index >= 0 && index <= 11); leaf->edge_parity |= (1 << index); } - + /// Set 0 - void resetEdge(LeafNode* leaf, int index) + void resetEdge(LeafNode *leaf, int index) { assert(index >= 0 && index <= 11); @@ -592,64 +586,57 @@ private: } /// Flipping with a new intersection offset - void createPrimalEdgesMask(LeafNode* leaf) + void createPrimalEdgesMask(LeafNode *leaf) { leaf->primary_edge_intersections = getPrimalEdgesMask2(leaf); } - void setStoredEdgesParity(LeafNode* leaf, int pindex) + void setStoredEdgesParity(LeafNode *leaf, int pindex) { assert(pindex <= 2 && pindex >= 0); - + leaf->primary_edge_intersections |= (1 << pindex); } - int getStoredEdgesParity(LeafNode* leaf, int pindex) + int getStoredEdgesParity(LeafNode *leaf, int pindex) { assert(pindex <= 2 && pindex >= 0); - + return (leaf->primary_edge_intersections >> pindex) & 1; } - LeafNode* flipEdge(LeafNode* leaf, int index, float alpha) + LeafNode *flipEdge(LeafNode *leaf, int index, float alpha) { flipEdge(leaf, index); - if((index & 3) == 0) - { + if ((index & 3) == 0) { int ind = index / 4; - if(getEdgeParity(leaf, index) && ! getStoredEdgesParity(leaf, ind)) - { + if (getEdgeParity(leaf, index) && !getStoredEdgesParity(leaf, ind)) { // Create a new node int num = getNumEdges(leaf) + 1; setStoredEdgesParity(leaf, ind); int count = getEdgeCount(leaf, ind); - LeafNode* nleaf = createLeaf(num); + LeafNode *nleaf = createLeaf(num); *nleaf = *leaf; setEdgeOffset(nleaf, alpha, count); - if(num > 1) - { + if (num > 1) { float *pts = leaf->edge_intersections; float *npts = nleaf->edge_intersections; - for(int i = 0; i < count; i ++) - { - for(int j = 0; j < EDGE_FLOATS; j ++) - { + for (int i = 0; i < count; i++) { + for (int j = 0; j < EDGE_FLOATS; j++) { npts[i * EDGE_FLOATS + j] = pts[i * EDGE_FLOATS + j]; } } - for(int i = count + 1; i < num; i ++) - { - for(int j = 0; j < EDGE_FLOATS; j ++) - { + for (int i = count + 1; i < num; i++) { + for (int j = 0; j < EDGE_FLOATS; j++) { npts[i * EDGE_FLOATS + j] = pts[(i - 1) * EDGE_FLOATS + j]; } } } - - removeLeaf(num-1, (LeafNode*)leaf); + + removeLeaf(num - 1, (LeafNode *)leaf); leaf = nleaf; } } @@ -658,69 +645,64 @@ private: } /// Update parent link - void updateParent(InternalNode* node, int len, int st[3], LeafNode* leaf) + void updateParent(InternalNode *node, int len, int st[3], LeafNode *leaf) { // First, locate the parent int count; - InternalNode* parent = locateParent(node, len, st, count); + InternalNode *parent = locateParent(node, len, st, count); // Update - setChild(parent, count, (Node*)leaf); + setChild(parent, count, (Node *)leaf); } - void updateParent(InternalNode* node, int len, int st[3]) + void updateParent(InternalNode *node, int len, int st[3]) { - if(len == dimen) - { - root = (Node*)node; + if (len == dimen) { + root = (Node *)node; return; } // First, locate the parent int count; - InternalNode* parent = locateParent(len, st, count); + InternalNode *parent = locateParent(len, st, count); // UPdate - setChild(parent, count, (Node*)node); + setChild(parent, count, (Node *)node); } /// Find edge intersection on a given edge int getEdgeIntersectionByIndex(int st[3], int index, float pt[3], int check) { // First, locat the leaf - LeafNode* leaf; - if(check) - { + LeafNode *leaf; + if (check) { leaf = locateLeafCheck(st); } - else - { + else { leaf = locateLeaf(st); } - if(leaf && getStoredEdgesParity(leaf, index)) - { + if (leaf && getStoredEdgesParity(leaf, index)) { float off = getEdgeOffset(leaf, getEdgeCount(leaf, index)); - pt[0] =(float) st[0]; - pt[1] =(float) st[1]; - pt[2] =(float) st[2]; + pt[0] = (float) st[0]; + pt[1] = (float) st[1]; + pt[2] = (float) st[2]; pt[index] += off * mindimen; return 1; } - else - { + else { return 0; } } /// Retrieve number of edges intersected - int getPrimalEdgesMask(LeafNode* leaf) + int getPrimalEdgesMask(LeafNode *leaf) { return leaf->primary_edge_intersections; } - int getPrimalEdgesMask2(LeafNode* leaf) + int getPrimalEdgesMask2(LeafNode *leaf) { return (((leaf->edge_parity & 0x1) >> 0) | ((leaf->edge_parity & 0x10) >> 3) | @@ -728,22 +710,22 @@ private: } /// Get the count for a primary edge - int getEdgeCount(LeafNode* leaf, int index) + int getEdgeCount(LeafNode *leaf, int index) { return edgeCountTable[getPrimalEdgesMask(leaf)][index]; } - int getNumEdges(LeafNode* leaf) + int getNumEdges(LeafNode *leaf) { return numEdgeTable[getPrimalEdgesMask(leaf)]; } - int getNumEdges2(LeafNode* leaf) + int getNumEdges2(LeafNode *leaf) { return numEdgeTable[getPrimalEdgesMask2(leaf)]; } /// Set edge intersection - void setEdgeOffset(LeafNode* leaf, float pt, int count) + void setEdgeOffset(LeafNode *leaf, float pt, int count) { float *pts = leaf->edge_intersections; pts[EDGE_FLOATS * count] = pt; @@ -753,26 +735,25 @@ private: } /// Set multiple edge intersections - void setEdgeOffsets(LeafNode* leaf, float pt[3], int len) + void setEdgeOffsets(LeafNode *leaf, float pt[3], int len) { - float * pts = leaf->edge_intersections; - for(int i = 0; i < len; i ++) - { + float *pts = leaf->edge_intersections; + for (int i = 0; i < len; i++) { pts[i] = pt[i]; } } /// Retrieve edge intersection - float getEdgeOffset(LeafNode* leaf, int count) + float getEdgeOffset(LeafNode *leaf, int count) { return leaf->edge_intersections[4 * count]; } /// Update method - LeafNode* updateEdgeOffsets(LeafNode* leaf, int oldlen, int newlen, float offs[3]) + LeafNode *updateEdgeOffsets(LeafNode *leaf, int oldlen, int newlen, float offs[3]) { // First, create a new leaf node - LeafNode* nleaf = createLeaf(newlen); + LeafNode *nleaf = createLeaf(newlen); *nleaf = *leaf; // Next, fill in the offsets @@ -785,52 +766,50 @@ private: } /// Set minimizer index - void setMinimizerIndex(LeafNode* leaf, int index) + void setMinimizerIndex(LeafNode *leaf, int index) { leaf->minimizer_index = index; } /// Get minimizer index - int getMinimizerIndex(LeafNode* leaf) + int getMinimizerIndex(LeafNode *leaf) { return leaf->minimizer_index; } - - int getMinimizerIndex(LeafNode* leaf, int eind) + + int getMinimizerIndex(LeafNode *leaf, int eind) { int add = manifold_table[getSignMask(leaf)].pairs[eind][0] - 1; assert(add >= 0); return leaf->minimizer_index + add; } - void getMinimizerIndices(LeafNode* leaf, int eind, int inds[2]) + void getMinimizerIndices(LeafNode *leaf, int eind, int inds[2]) { - const int* add = manifold_table[getSignMask(leaf)].pairs[eind]; + const int *add = manifold_table[getSignMask(leaf)].pairs[eind]; inds[0] = leaf->minimizer_index + add[0] - 1; - if(add[0] == add[1]) - { + if (add[0] == add[1]) { inds[1] = -1; } - else - { + else { inds[1] = leaf->minimizer_index + add[1] - 1; } } /// Set edge intersection - void setEdgeOffsetNormal(LeafNode* leaf, float pt, float a, float b, float c, int count) + void setEdgeOffsetNormal(LeafNode *leaf, float pt, float a, float b, float c, int count) { - float * pts = leaf->edge_intersections; + float *pts = leaf->edge_intersections; pts[4 * count] = pt; pts[4 * count + 1] = a; pts[4 * count + 2] = b; pts[4 * count + 3] = c; } - float getEdgeOffsetNormal(LeafNode* leaf, int count, float& a, float& b, float& c) + float getEdgeOffsetNormal(LeafNode *leaf, int count, float& a, float& b, float& c) { - float * pts = leaf->edge_intersections; + float *pts = leaf->edge_intersections; a = pts[4 * count + 1]; b = pts[4 * count + 2]; c = pts[4 * count + 3]; @@ -838,13 +817,13 @@ private: } /// Set multiple edge intersections - void setEdgeOffsetsNormals(LeafNode* leaf, float pt[], float a[], float b[], float c[], int len) + void setEdgeOffsetsNormals(LeafNode *leaf, const float pt[], + const float a[], const float b[], + const float c[], int len) { float *pts = leaf->edge_intersections; - for(int i = 0; i < len; i ++) - { - if(pt[i] > 1 || pt[i] < 0) - { + for (int i = 0; i < len; i++) { + if (pt[i] > 1 || pt[i] < 0) { printf("\noffset: %f\n", pt[i]); } pts[i * 4] = pt[i]; @@ -855,30 +834,30 @@ private: } /// Retrieve complete edge intersection - void getEdgeIntersectionByIndex(LeafNode* leaf, int index, int st[3], int len, float pt[3], float nm[3]) + void getEdgeIntersectionByIndex(LeafNode *leaf, int index, int st[3], int len, float pt[3], float nm[3]) { int count = getEdgeCount(leaf, index); float *pts = leaf->edge_intersections; - + float off = pts[4 * count]; - + pt[0] = (float) st[0]; pt[1] = (float) st[1]; pt[2] = (float) st[2]; - pt[index] +=(off * len); + pt[index] += (off * len); nm[0] = pts[4 * count + 1]; nm[1] = pts[4 * count + 2]; nm[2] = pts[4 * count + 3]; } - float getEdgeOffsetNormalByIndex(LeafNode* leaf, int index, float nm[3]) + float getEdgeOffsetNormalByIndex(LeafNode *leaf, int index, float nm[3]) { int count = getEdgeCount(leaf, index); float *pts = leaf->edge_intersections; - + float off = pts[4 * count]; - + nm[0] = pts[4 * count + 1]; nm[1] = pts[4 * count + 2]; nm[2] = pts[4 * count + 3]; @@ -886,63 +865,55 @@ private: return off; } - void fillEdgeIntersections(LeafNode* leaf, int st[3], int len, float pts[12][3], float norms[12][3]) + void fillEdgeIntersections(LeafNode *leaf, int st[3], int len, float pts[12][3], float norms[12][3]) { int i; // int stt[3] = {0, 0, 0}; // The three primal edges are easy int pmask[3] = {0, 4, 8}; - for(i = 0; i < 3; i ++) - { - if(getEdgeParity(leaf, pmask[i])) - { + for (i = 0; i < 3; i++) { + if (getEdgeParity(leaf, pmask[i])) { // getEdgeIntersectionByIndex(leaf, i, stt, 1, pts[pmask[i]], norms[pmask[i]]); getEdgeIntersectionByIndex(leaf, i, st, len, pts[pmask[i]], norms[pmask[i]]); } } - + // 3 face adjacent cubes - int fmask[3][2] = {{6,10},{2,9},{1,5}}; - int femask[3][2] = {{1,2},{0,2},{0,1}}; - for(i = 0; i < 3; i ++) - { + int fmask[3][2] = {{6, 10}, {2, 9}, {1, 5}}; + int femask[3][2] = {{1, 2}, {0, 2}, {0, 1}}; + for (i = 0; i < 3; i++) { int e1 = getEdgeParity(leaf, fmask[i][0]); int e2 = getEdgeParity(leaf, fmask[i][1]); - if(e1 || e2) - { + if (e1 || e2) { int nst[3] = {st[0], st[1], st[2]}; nst[i] += len; // int nstt[3] = {0, 0, 0}; // nstt[i] += 1; - LeafNode* node = locateLeaf(nst); - - if(e1) - { + LeafNode *node = locateLeaf(nst); + + if (e1) { // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]], norms[fmask[i][0]]); getEdgeIntersectionByIndex(node, femask[i][0], nst, len, pts[fmask[i][0]], norms[fmask[i][0]]); } - if(e2) - { + if (e2) { // getEdgeIntersectionByIndex(node, femask[i][1], nstt, 1, pts[fmask[i][1]], norms[fmask[i][1]]); getEdgeIntersectionByIndex(node, femask[i][1], nst, len, pts[fmask[i][1]], norms[fmask[i][1]]); } } } - + // 3 edge adjacent cubes int emask[3] = {3, 7, 11}; int eemask[3] = {0, 1, 2}; - for(i = 0; i < 3; i ++) - { - if(getEdgeParity(leaf, emask[i])) - { + for (i = 0; i < 3; i++) { + if (getEdgeParity(leaf, emask[i])) { int nst[3] = {st[0] + len, st[1] + len, st[2] + len}; nst[i] -= len; // int nstt[3] = {1, 1, 1}; // nstt[i] -= 1; - LeafNode* node = locateLeaf(nst); - + LeafNode *node = locateLeaf(nst); + // getEdgeIntersectionByIndex(node, eemask[i], nstt, 1, pts[emask[i]], norms[emask[i]]); getEdgeIntersectionByIndex(node, eemask[i], nst, len, pts[emask[i]], norms[emask[i]]); } @@ -950,80 +921,70 @@ private: } - void fillEdgeIntersections(LeafNode* leaf, int st[3], int len, float pts[12][3], float norms[12][3], int parity[12]) + void fillEdgeIntersections(LeafNode *leaf, int st[3], int len, float pts[12][3], float norms[12][3], int parity[12]) { int i; - for(i = 0; i < 12; i ++) - { + for (i = 0; i < 12; i++) { parity[i] = 0; } // int stt[3] = {0, 0, 0}; // The three primal edges are easy int pmask[3] = {0, 4, 8}; - for(i = 0; i < 3; i ++) - { - if(getStoredEdgesParity(leaf, i)) - { + for (i = 0; i < 3; i++) { + if (getStoredEdgesParity(leaf, i)) { // getEdgeIntersectionByIndex(leaf, i, stt, 1, pts[pmask[i]], norms[pmask[i]]); getEdgeIntersectionByIndex(leaf, i, st, len, pts[pmask[i]], norms[pmask[i]]); parity[pmask[i]] = 1; } } - + // 3 face adjacent cubes - int fmask[3][2] = {{6,10},{2,9},{1,5}}; - int femask[3][2] = {{1,2},{0,2},{0,1}}; - for(i = 0; i < 3; i ++) - { + int fmask[3][2] = {{6, 10}, {2, 9}, {1, 5}}; + int femask[3][2] = {{1, 2}, {0, 2}, {0, 1}}; + for (i = 0; i < 3; i++) { { int nst[3] = {st[0], st[1], st[2]}; nst[i] += len; // int nstt[3] = {0, 0, 0}; // nstt[i] += 1; - LeafNode* node = locateLeafCheck(nst); - if(node == NULL) - { + LeafNode *node = locateLeafCheck(nst); + if (node == NULL) { continue; } - + int e1 = getStoredEdgesParity(node, femask[i][0]); int e2 = getStoredEdgesParity(node, femask[i][1]); - - if(e1) - { + + if (e1) { // getEdgeIntersectionByIndex(node, femask[i][0], nstt, 1, pts[fmask[i][0]], norms[fmask[i][0]]); getEdgeIntersectionByIndex(node, femask[i][0], nst, len, pts[fmask[i][0]], norms[fmask[i][0]]); parity[fmask[i][0]] = 1; } - if(e2) - { + if (e2) { // getEdgeIntersectionByIndex(node, femask[i][1], nstt, 1, pts[fmask[i][1]], norms[fmask[i][1]]); getEdgeIntersectionByIndex(node, femask[i][1], nst, len, pts[fmask[i][1]], norms[fmask[i][1]]); parity[fmask[i][1]] = 1; } } } - + // 3 edge adjacent cubes int emask[3] = {3, 7, 11}; int eemask[3] = {0, 1, 2}; - for(i = 0; i < 3; i ++) - { -// if(getEdgeParity(leaf, emask[i])) + for (i = 0; i < 3; i++) { + // if(getEdgeParity(leaf, emask[i])) { int nst[3] = {st[0] + len, st[1] + len, st[2] + len}; nst[i] -= len; // int nstt[3] = {1, 1, 1}; // nstt[i] -= 1; - LeafNode* node = locateLeafCheck(nst); - if(node == NULL) - { + LeafNode *node = locateLeafCheck(nst); + if (node == NULL) { continue; } - - if(getStoredEdgesParity(node, eemask[i])) - { + + if (getStoredEdgesParity(node, eemask[i])) { // getEdgeIntersectionByIndex(node, eemask[i], nstt, 1, pts[emask[i]], norms[emask[i]]); getEdgeIntersectionByIndex(node, eemask[i], nst, len, pts[emask[i]], norms[emask[i]]); parity[emask[i]] = 1; @@ -1032,77 +993,67 @@ private: } } - void fillEdgeOffsetsNormals(LeafNode* leaf, int st[3], int len, float pts[12], float norms[12][3], int parity[12]) + void fillEdgeOffsetsNormals(LeafNode *leaf, int st[3], int len, float pts[12], float norms[12][3], int parity[12]) { int i; - for(i = 0; i < 12; i ++) - { + for (i = 0; i < 12; i++) { parity[i] = 0; } // int stt[3] = {0, 0, 0}; // The three primal edges are easy int pmask[3] = {0, 4, 8}; - for(i = 0; i < 3; i ++) - { - if(getStoredEdgesParity(leaf, i)) - { + for (i = 0; i < 3; i++) { + if (getStoredEdgesParity(leaf, i)) { pts[pmask[i]] = getEdgeOffsetNormalByIndex(leaf, i, norms[pmask[i]]); parity[pmask[i]] = 1; } } - + // 3 face adjacent cubes - int fmask[3][2] = {{6,10},{2,9},{1,5}}; - int femask[3][2] = {{1,2},{0,2},{0,1}}; - for(i = 0; i < 3; i ++) - { + int fmask[3][2] = {{6, 10}, {2, 9}, {1, 5}}; + int femask[3][2] = {{1, 2}, {0, 2}, {0, 1}}; + for (i = 0; i < 3; i++) { { int nst[3] = {st[0], st[1], st[2]}; nst[i] += len; // int nstt[3] = {0, 0, 0}; // nstt[i] += 1; - LeafNode* node = locateLeafCheck(nst); - if(node == NULL) - { + LeafNode *node = locateLeafCheck(nst); + if (node == NULL) { continue; } - + int e1 = getStoredEdgesParity(node, femask[i][0]); int e2 = getStoredEdgesParity(node, femask[i][1]); - - if(e1) - { + + if (e1) { pts[fmask[i][0]] = getEdgeOffsetNormalByIndex(node, femask[i][0], norms[fmask[i][0]]); parity[fmask[i][0]] = 1; } - if(e2) - { + if (e2) { pts[fmask[i][1]] = getEdgeOffsetNormalByIndex(node, femask[i][1], norms[fmask[i][1]]); parity[fmask[i][1]] = 1; } } } - + // 3 edge adjacent cubes int emask[3] = {3, 7, 11}; int eemask[3] = {0, 1, 2}; - for(i = 0; i < 3; i ++) - { -// if(getEdgeParity(leaf, emask[i])) + for (i = 0; i < 3; i++) { + // if(getEdgeParity(leaf, emask[i])) { int nst[3] = {st[0] + len, st[1] + len, st[2] + len}; nst[i] -= len; // int nstt[3] = {1, 1, 1}; // nstt[i] -= 1; - LeafNode* node = locateLeafCheck(nst); - if(node == NULL) - { + LeafNode *node = locateLeafCheck(nst); + if (node == NULL) { continue; } - - if(getStoredEdgesParity(node, eemask[i])) - { + + if (getStoredEdgesParity(node, eemask[i])) { pts[emask[i]] = getEdgeOffsetNormalByIndex(node, eemask[i], norms[emask[i]]); parity[emask[i]] = 1; } @@ -1112,10 +1063,10 @@ private: /// Update method - LeafNode* updateEdgeOffsetsNormals(LeafNode* leaf, int oldlen, int newlen, float offs[3], float a[3], float b[3], float c[3]) + LeafNode *updateEdgeOffsetsNormals(LeafNode *leaf, int oldlen, int newlen, float offs[3], float a[3], float b[3], float c[3]) { // First, create a new leaf node - LeafNode* nleaf = createLeaf(newlen); + LeafNode *nleaf = createLeaf(newlen); *nleaf = *leaf; // Next, fill in the offsets @@ -1129,30 +1080,28 @@ private: /// Locate a leaf /// WARNING: assuming this leaf already exists! - - LeafNode* locateLeaf(int st[3]) + + LeafNode *locateLeaf(int st[3]) { - Node* node = (Node*)root; - for(int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i --) - { - int index =(((st[0] >> i) & 1) << 2) | - (((st[1] >> i) & 1) << 1) | - (((st[2] >> i) & 1)); + Node *node = (Node *)root; + for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) { + int index = (((st[0] >> i) & 1) << 2) | + (((st[1] >> i) & 1) << 1) | + (((st[2] >> i) & 1)); node = getChild(&node->internal, getChildCount(&node->internal, index)); } return &node->leaf; } - - LeafNode* locateLeaf(InternalNode* parent, int len, int st[3]) + + LeafNode *locateLeaf(InternalNode *parent, int len, int st[3]) { - Node *node = (Node*)parent; + Node *node = (Node *)parent; int index; - for(int i = len / 2; i >= mindimen; i >>= 1) - { - index =(((st[0] & i) ? 4 : 0) | - ((st[1] & i) ? 2 : 0) | - ((st[2] & i) ? 1 : 0)); + for (int i = len / 2; i >= mindimen; i >>= 1) { + index = (((st[0] & i) ? 4 : 0) | + ((st[1] & i) ? 2 : 0) | + ((st[2] & i) ? 1 : 0)); node = getChild(&node->internal, getChildCount(&node->internal, index)); } @@ -1160,16 +1109,14 @@ private: return &node->leaf; } - LeafNode* locateLeafCheck(int st[3]) + LeafNode *locateLeafCheck(int st[3]) { - Node* node = (Node*)root; - for(int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i --) - { - int index =(((st[0] >> i) & 1) << 2) | - (((st[1] >> i) & 1) << 1) | - (((st[2] >> i) & 1)); - if(!hasChild(&node->internal, index)) - { + Node *node = (Node *)root; + for (int i = GRID_DIMENSION - 1; i > GRID_DIMENSION - maxDepth - 1; i--) { + int index = (((st[0] >> i) & 1) << 2) | + (((st[1] >> i) & 1) << 1) | + (((st[2] >> i) & 1)); + if (!hasChild(&node->internal, index)) { return NULL; } node = getChild(&node->internal, getChildCount(&node->internal, index)); @@ -1178,16 +1125,15 @@ private: return &node->leaf; } - InternalNode* locateParent(int len, int st[3], int& count) + InternalNode *locateParent(int len, int st[3], int& count) { - InternalNode* node = (InternalNode*)root; - InternalNode* pre = NULL; + InternalNode *node = (InternalNode *)root; + InternalNode *pre = NULL; int index = 0; - for(int i = dimen / 2; i >= len; i >>= 1) - { - index =(((st[0] & i) ? 4 : 0) | - ((st[1] & i) ? 2 : 0) | - ((st[2] & i) ? 1 : 0)); + for (int i = dimen / 2; i >= len; i >>= 1) { + index = (((st[0] & i) ? 4 : 0) | + ((st[1] & i) ? 2 : 0) | + ((st[2] & i) ? 1 : 0)); pre = node; node = &getChild(node, getChildCount(node, index))->internal; } @@ -1195,140 +1141,123 @@ private: count = getChildCount(pre, index); return pre; } - - InternalNode* locateParent(InternalNode* parent, int len, int st[3], int& count) + + InternalNode *locateParent(InternalNode *parent, int len, int st[3], int& count) { - InternalNode* node = parent; - InternalNode* pre = NULL; + InternalNode *node = parent; + InternalNode *pre = NULL; int index = 0; - for(int i = len / 2; i >= mindimen; i >>= 1) - { - index =(((st[0] & i) ? 4 : 0) | - ((st[1] & i) ? 2 : 0) | - ((st[2] & i) ? 1 : 0)); + for (int i = len / 2; i >= mindimen; i >>= 1) { + index = (((st[0] & i) ? 4 : 0) | + ((st[1] & i) ? 2 : 0) | + ((st[2] & i) ? 1 : 0)); pre = node; - node = (InternalNode*)getChild(node, getChildCount(node, index)); + node = (InternalNode *)getChild(node, getChildCount(node, index)); } count = getChildCount(pre, index); return pre; } - + /************ Operators for internal nodes ************/ /// If child index exists - int hasChild(InternalNode* node, int index) + int hasChild(InternalNode *node, int index) { return (node->has_child >> index) & 1; } - /// Test if child is leaf - int isLeaf(InternalNode* node, int index) - { - return (node->child_is_leaf >> index) & 1; - } - /// Get the pointer to child index - Node* getChild(InternalNode* node, int count) + Node *getChild(InternalNode *node, int count) { return node->children[count]; }; /// Get total number of children - int getNumChildren(InternalNode* node) + int getNumChildren(InternalNode *node) { return numChildrenTable[node->has_child]; } /// Get the count of children - int getChildCount(InternalNode* node, int index) + int getChildCount(InternalNode *node, int index) { return childrenCountTable[node->has_child][index]; } - int getChildIndex(InternalNode* node, int count) + int getChildIndex(InternalNode *node, int count) { return childrenIndexTable[node->has_child][count]; } - int* getChildCounts(InternalNode* node) + int *getChildCounts(InternalNode *node) { return childrenCountTable[node->has_child]; } /// Get all children - void fillChildren(InternalNode* node, Node* children[8], int leaf[8]) + void fillChildren(InternalNode *node, Node *children[8], int leaf[8]) { int count = 0; - for(int i = 0; i < 8; i ++) - { - leaf[i] = isLeaf(node, i); - if(hasChild(node, i)) - { + for (int i = 0; i < 8; i++) { + leaf[i] = node->is_child_leaf(i); + if (hasChild(node, i)) { children[i] = getChild(node, count); - count ++; + count++; } - else - { - children[i] = NULL; + else { + children[i] = NULL; leaf[i] = 0; } } } /// Sets the child pointer - void setChild(InternalNode* node, int count, Node* chd) + void setChild(InternalNode *node, int count, Node *chd) { node->children[count] = chd; } - void setInternalChild(InternalNode* node, int index, int count, InternalNode* chd) + void setInternalChild(InternalNode *node, int index, int count, InternalNode *chd) { - setChild(node, count, (Node*)chd); + setChild(node, count, (Node *)chd); node->has_child |= (1 << index); } - void setLeafChild(InternalNode* node, int index, int count, LeafNode* chd) + void setLeafChild(InternalNode *node, int index, int count, LeafNode *chd) { - setChild(node, count, (Node*)chd); - node->has_child |=(1 << index); + setChild(node, count, (Node *)chd); + node->has_child |= (1 << index); node->child_is_leaf |= (1 << index); } /// Add a kid to an existing internal node /// Fix me: can we do this without wasting memory ? /// Fixed: using variable memory - InternalNode* addChild(InternalNode* node, int index, Node* child, int aLeaf) + InternalNode *addChild(InternalNode *node, int index, Node *child, int aLeaf) { // Create new internal node int num = getNumChildren(node); - InternalNode* rnode = createInternal(num + 1); + InternalNode *rnode = createInternal(num + 1); // Establish children int i; int count1 = 0, count2 = 0; - for(i = 0; i < 8; i ++) - { - if(i == index) - { - if(aLeaf) - { + for (i = 0; i < 8; i++) { + if (i == index) { + if (aLeaf) { setLeafChild(rnode, i, count2, &child->leaf); } - else - { + else { setInternalChild(rnode, i, count2, &child->internal); } - count2 ++; + count2++; } - else if(hasChild(node, i)) - { - if(isLeaf(node, i)) - { + else if (hasChild(node, i)) { + if (node->is_child_leaf(i)) { setLeafChild(rnode, i, count2, &getChild(node, count1)->leaf); } - else - { + else { setInternalChild(rnode, i, count2, &getChild(node, count1)->internal); } - count1 ++; - count2 ++; + count1++; + count2++; } } @@ -1337,19 +1266,19 @@ private: } /// Allocate a node - InternalNode* createInternal(int length) + InternalNode *createInternal(int length) { - InternalNode* inode = (InternalNode*)alloc[length]->allocate(); + InternalNode *inode = (InternalNode *)alloc[length]->allocate(); inode->has_child = 0; inode->child_is_leaf = 0; return inode; } - - LeafNode* createLeaf(int length) + + LeafNode *createLeaf(int length) { assert(length <= 3); - LeafNode* lnode = (LeafNode*)leafalloc[length]->allocate(); + LeafNode *lnode = (LeafNode *)leafalloc[length]->allocate(); lnode->edge_parity = 0; lnode->primary_edge_intersections = 0; lnode->signs = 0; @@ -1357,73 +1286,65 @@ private: return lnode; } - void removeInternal(int num, InternalNode* node) + void removeInternal(int num, InternalNode *node) { alloc[num]->deallocate(node); } - void removeLeaf(int num, LeafNode* leaf) + void removeLeaf(int num, LeafNode *leaf) { assert(num >= 0 && num <= 3); leafalloc[num]->deallocate(leaf); } /// Add a leaf (by creating a new par node with the leaf added) - InternalNode* addLeafChild(InternalNode* par, int index, int count, - LeafNode* leaf) + InternalNode *addLeafChild(InternalNode *par, int index, int count, + LeafNode *leaf) { int num = getNumChildren(par) + 1; - InternalNode* npar = createInternal(num); + InternalNode *npar = createInternal(num); *npar = *par; - - if(num == 1) - { + + if (num == 1) { setLeafChild(npar, index, 0, leaf); } - else - { + else { int i; - for(i = 0; i < count; i ++) - { + for (i = 0; i < count; i++) { setChild(npar, i, getChild(par, i)); } setLeafChild(npar, index, count, leaf); - for(i = count + 1; i < num; i ++) - { + for (i = count + 1; i < num; i++) { setChild(npar, i, getChild(par, i - 1)); } } - - removeInternal(num-1, par); + + removeInternal(num - 1, par); return npar; } - InternalNode* addInternalChild(InternalNode* par, int index, int count, - InternalNode* node) + InternalNode *addInternalChild(InternalNode *par, int index, int count, + InternalNode *node) { int num = getNumChildren(par) + 1; - InternalNode* npar = createInternal(num); + InternalNode *npar = createInternal(num); *npar = *par; - - if(num == 1) - { + + if (num == 1) { setInternalChild(npar, index, 0, node); } - else - { + else { int i; - for(i = 0; i < count; i ++) - { + for (i = 0; i < count; i++) { setChild(npar, i, getChild(par, i)); } setInternalChild(npar, index, count, node); - for(i = count + 1; i < num; i ++) - { + for (i = count + 1; i < num; i++) { setChild(npar, i, getChild(par, i - 1)); } } - - removeInternal(num-1, par); + + removeInternal(num - 1, par); return npar; } }; diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt index 5c653ac92c0..eeb924d7bf0 100644 --- a/intern/ghost/CMakeLists.txt +++ b/intern/ghost/CMakeLists.txt @@ -165,9 +165,11 @@ if(WITH_HEADLESS OR WITH_GHOST_SDL) ) endif() - list(APPEND INC_SYS - ${SDL_INCLUDE_DIR} - ) + if(NOT WITH_HEADLESS) + list(APPEND INC_SYS + ${SDL_INCLUDE_DIR} + ) + endif() elseif(APPLE) if(WITH_COCOA) diff --git a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp index 1e78cafd4f6..565324ae211 100644 --- a/intern/ghost/intern/GHOST_NDOFManagerX11.cpp +++ b/intern/ghost/intern/GHOST_NDOFManagerX11.cpp @@ -37,6 +37,8 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys) setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */ if (spnav_open() != -1) { + m_available = true; + /* determine exactly which device (if any) is plugged in */ #define MAX_LINE_LENGTH 100 @@ -49,7 +51,6 @@ GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys) unsigned short vendor_id = 0, product_id = 0; if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2) if (setDevice(vendor_id, product_id)) { - m_available = true; break; /* stop looking once the first 3D mouse is found */ } } diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h index 2220955c270..ce7677aee7a 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.h +++ b/intern/ghost/intern/GHOST_SystemCocoa.h @@ -247,6 +247,7 @@ protected: * @return Indication whether the event was handled. */ GHOST_TSuccess handleTabletEvent(void *eventPtr, short eventType); + bool handleTabletEvent(void *eventPtr); /** * Handles a mouse event. diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm index 50d8cfd074b..6013f3519ec 100644 --- a/intern/ghost/intern/GHOST_SystemCocoa.mm +++ b/intern/ghost/intern/GHOST_SystemCocoa.mm @@ -1280,7 +1280,7 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest() GHOST_Window* window = (GHOST_Window*)m_windowManager->getActiveWindow(); //Discard quit event if we are in cursor grab sequence - if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal)) + if (window && window->getCursorGrabModeIsWarp()) return GHOST_kExitCancel; //Check open windows if some changes are not saved @@ -1329,7 +1329,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr) } //Discard event if we are in cursor grab sequence, it'll lead to "stuck cursor" situation if the alert panel is raised - if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal)) + if (window && window->getCursorGrabModeIsWarp()) return GHOST_kExitCancel; //Check open windows if some changes are not saved @@ -1421,6 +1421,23 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT return GHOST_kSuccess; } +bool GHOST_SystemCocoa::handleTabletEvent(void *eventPtr) +{ + NSEvent *event = (NSEvent *)eventPtr; + + switch ([event subtype]) { + case NX_SUBTYPE_TABLET_POINT: + handleTabletEvent(eventPtr, NSTabletPoint); + return true; + case NX_SUBTYPE_TABLET_PROXIMITY: + handleTabletEvent(eventPtr, NSTabletProximity); + return true; + default: + //No tablet event included : do nothing + return false; + } + +} GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) { @@ -1432,7 +1449,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) //printf("\nW failure for event 0x%x",[event type]); return GHOST_kFailure; } - + switch ([event type]) { case NSLeftMouseDown: @@ -1440,17 +1457,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSOtherMouseDown: pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - handleTabletEvent(eventPtr, NSTabletPoint); - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - handleTabletEvent(eventPtr, NSTabletProximity); - break; - default: - //No tablet event included : do nothing - break; - } + handleTabletEvent(event); break; case NSLeftMouseUp: @@ -1458,37 +1465,27 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) case NSOtherMouseUp: pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonUp, window, convertButton([event buttonNumber]))); //Handle tablet events combined with mouse events - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - handleTabletEvent(eventPtr, NSTabletPoint); - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - handleTabletEvent(eventPtr, NSTabletProximity); - break; - default: - //No tablet event included : do nothing - break; - } + handleTabletEvent(event); break; case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDragged: //Handle tablet events combined with mouse events - switch ([event subtype]) { - case NX_SUBTYPE_TABLET_POINT: - handleTabletEvent(eventPtr, NSTabletPoint); - break; - case NX_SUBTYPE_TABLET_PROXIMITY: - handleTabletEvent(eventPtr, NSTabletProximity); - break; - default: - //No tablet event included : do nothing - break; - } + handleTabletEvent(event); - case NSMouseMoved: - switch (window->getCursorGrabMode()) { + case NSMouseMoved: + { + GHOST_TGrabCursorMode grab_mode = window->getCursorGrabMode(); + + /* TODO: CHECK IF THIS IS A TABLET EVENT */ + bool is_tablet = false; + + if (is_tablet && window->getCursorGrabModeIsWarp()) { + grab_mode = GHOST_kGrabDisable; + } + + switch (grab_mode) { case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move { GHOST_TInt32 x_warp, y_warp, x_accum, y_accum, x, y; @@ -1563,7 +1560,8 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr) } break; } - break; + } + break; case NSScrollWheel: { diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp index 2d8cf13ac4f..9f2728a581f 100644 --- a/intern/ghost/intern/GHOST_SystemWin32.cpp +++ b/intern/ghost/intern/GHOST_SystemWin32.cpp @@ -649,8 +649,10 @@ GHOST_EventCursor* GHOST_SystemWin32::processCursorEvent(GHOST_TEventType type, system->getCursorPosition(x_screen, y_screen); - if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal) - { + /* TODO: CHECK IF THIS IS A TABLET EVENT */ + bool is_tablet = false; + + if (is_tablet == false && window->getCursorGrabModeIsWarp()) { GHOST_TInt32 x_new= x_screen; GHOST_TInt32 y_new= y_screen; GHOST_TInt32 x_accum, y_accum; diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp index 857d9e79e57..cabec06301a 100644 --- a/intern/ghost/intern/GHOST_SystemX11.cpp +++ b/intern/ghost/intern/GHOST_SystemX11.cpp @@ -471,9 +471,14 @@ GHOST_SystemX11::processEvent(XEvent *xe) case MotionNotify: { XMotionEvent &xme = xe->xmotion; - - if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal) - { + +#ifdef WITH_X11_XINPUT + bool is_tablet = window->GetXTablet().CommonData.Active != GHOST_kTabletModeNone; +#else + bool is_tablet = false; +#endif + + if (is_tablet == false && window->getCursorGrabModeIsWarp()) { GHOST_TInt32 x_new= xme.x_root; GHOST_TInt32 y_new= xme.y_root; GHOST_TInt32 x_accum, y_accum; diff --git a/intern/ghost/intern/GHOST_Window.h b/intern/ghost/intern/GHOST_Window.h index 323e0fa3418..23f1b044b60 100644 --- a/intern/ghost/intern/GHOST_Window.h +++ b/intern/ghost/intern/GHOST_Window.h @@ -161,6 +161,7 @@ public: */ inline virtual bool getCursorVisibility() const; inline virtual GHOST_TGrabCursorMode getCursorGrabMode() const; + inline virtual bool getCursorGrabModeIsWarp() const; inline virtual void getCursorGrabInitPos(GHOST_TInt32 &x, GHOST_TInt32 &y) const; inline virtual void getCursorGrabAccum(GHOST_TInt32 &x, GHOST_TInt32 &y) const; inline virtual void setCursorGrabAccum(GHOST_TInt32 x, GHOST_TInt32 y); @@ -362,6 +363,12 @@ inline GHOST_TGrabCursorMode GHOST_Window::getCursorGrabMode() const return m_cursorGrab; } +inline bool GHOST_Window::getCursorGrabModeIsWarp() const +{ + return (m_cursorGrab == GHOST_kGrabWrap) || + (m_cursorGrab == GHOST_kGrabHide); +} + inline void GHOST_Window::getCursorGrabInitPos(GHOST_TInt32 &x, GHOST_TInt32 &y) const { x = m_cursorGrabInitPos[0]; diff --git a/release/datafiles/brushicons/mask.png b/release/datafiles/brushicons/mask.png new file mode 100644 index 00000000000..e9e2fa66822 Binary files /dev/null and b/release/datafiles/brushicons/mask.png differ diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 91d8f1b3467..9ad9a7affc3 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -304,7 +304,7 @@ class EditBone(StructRNA, _GenericBone, metaclass=StructMetaPropGroup): Align this bone to another by moving its tail and settings its roll the length of the other bone is not used. """ - vec = other.vector.normalize() * self.length + vec = other.vector.normalized() * self.length self.tail = self.head + vec self.roll = other.roll diff --git a/release/scripts/startup/bl_ui/properties_animviz.py b/release/scripts/startup/bl_ui/properties_animviz.py index 3f25006766e..1f798f46590 100644 --- a/release/scripts/startup/bl_ui/properties_animviz.py +++ b/release/scripts/startup/bl_ui/properties_animviz.py @@ -65,12 +65,10 @@ class MotionPathButtonsPanel(): sub.prop(mpath, "frame_start", text="From") sub.prop(mpath, "frame_end", text="To") - sub = col.column() # align=True - sub.operator_context = 'EXEC_DEFAULT' if bones: - col.operator("pose.paths_calculate", text="Update", icon='BONE_DATA') + col.operator("pose.paths_update", text="Update Paths", icon='BONE_DATA') else: - col.operator("object.paths_calculate", text="Update", icon='OBJECT_DATA') + col.operator("object.paths_update", text="Update Paths", icon='OBJECT_DATA') else: col.label(text="Not available yet...", icon='ERROR') col.label(text="Calculate Paths first", icon='INFO') diff --git a/release/scripts/startup/bl_ui/properties_data_armature.py b/release/scripts/startup/bl_ui/properties_data_armature.py index 63dc64190bb..529d7c5f981 100644 --- a/release/scripts/startup/bl_ui/properties_data_armature.py +++ b/release/scripts/startup/bl_ui/properties_data_armature.py @@ -65,14 +65,10 @@ class DATA_PT_skeleton(ArmatureButtonsPanel, Panel): col.label(text="Protected Layers:") col.prop(arm, "layers_protected", text="") - layout.label(text="Deform:") - flow = layout.column_flow() - flow.prop(arm, "use_deform_vertex_groups", text="Vertex Groups") - flow.prop(arm, "use_deform_envelopes", text="Envelopes") - flow.prop(arm, "use_deform_preserve_volume", text="Quaternion") - if context.scene.render.engine == 'BLENDER_GAME': - layout.row().prop(arm, "deform_method", expand=True) + col = layout.column() + col.label(text="Deform:") + col.prop(arm, "deform_method", expand=True) class DATA_PT_display(ArmatureButtonsPanel, Panel): diff --git a/release/scripts/startup/bl_ui/space_console.py b/release/scripts/startup/bl_ui/space_console.py index a1818c395a2..fc1d8e2d4be 100644 --- a/release/scripts/startup/bl_ui/space_console.py +++ b/release/scripts/startup/bl_ui/space_console.py @@ -42,6 +42,7 @@ class CONSOLE_MT_console(Menu): layout = self.layout layout.operator("console.clear") + layout.operator("console.clear_line") layout.operator("console.copy") layout.operator("console.paste") layout.menu("CONSOLE_MT_language") diff --git a/release/scripts/startup/bl_ui/space_sequencer.py b/release/scripts/startup/bl_ui/space_sequencer.py index 43d675c1417..c155128c5d1 100644 --- a/release/scripts/startup/bl_ui/space_sequencer.py +++ b/release/scripts/startup/bl_ui/space_sequencer.py @@ -654,7 +654,7 @@ class SEQUENCER_PT_sound(SequencerButtonsPanel, Panel): row.prop(sound, "use_memory_cache") - layout.prop(strip, "waveform") + layout.prop(strip, "show_waveform") layout.prop(strip, "volume") layout.prop(strip, "pitch") layout.prop(strip, "pan") diff --git a/release/scripts/startup/bl_ui/space_text.py b/release/scripts/startup/bl_ui/space_text.py index dd752431df9..d1daa4a5554 100644 --- a/release/scripts/startup/bl_ui/space_text.py +++ b/release/scripts/startup/bl_ui/space_text.py @@ -277,8 +277,10 @@ class TEXT_MT_edit(Menu): layout.separator() - layout.operator("text.move_lines_up") - layout.operator("text.move_lines_down") + layout.operator("text.move_lines", + text="Move line(s) up").direction = 'UP' + layout.operator("text.move_lines", + text="Move line(s) down").direction = 'DOWN' layout.separator() diff --git a/release/scripts/startup/bl_ui/space_time.py b/release/scripts/startup/bl_ui/space_time.py index 7720fddb084..8fb587e2634 100644 --- a/release/scripts/startup/bl_ui/space_time.py +++ b/release/scripts/startup/bl_ui/space_time.py @@ -81,10 +81,12 @@ class TIME_HT_header(Header): row = layout.row(align=True) row.prop(toolsettings, "use_keyframe_insert_auto", text="", toggle=True) - row.prop(toolsettings, "use_keyframe_insert_keyingset", text="", toggle=True) - if screen.is_animation_playing and toolsettings.use_keyframe_insert_auto: - subsub = row.row() - subsub.prop(toolsettings, "use_record_with_nla", toggle=True) + if toolsettings.use_keyframe_insert_auto: + row.prop(toolsettings, "use_keyframe_insert_keyingset", text="", toggle=True) + + if screen.is_animation_playing: + subsub = row.row() + subsub.prop(toolsettings, "use_record_with_nla", toggle=True) row = layout.row(align=True) row.prop_search(scene.keying_sets_all, "active", scene, "keying_sets_all", text="") diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index 659ef2e7228..179a9d993d7 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -55,7 +55,7 @@ class VIEW3D_HT_header(Header): if mode_string in {'SCULPT', 'PAINT_VERTEX', 'PAINT_WEIGHT', 'PAINT_TEXTURE'}: sub.menu("VIEW3D_MT_brush") if mode_string == 'SCULPT': - sub.menu("VIEW3D_MT_hide") + sub.menu("VIEW3D_MT_hide_mask") else: sub.menu("VIEW3D_MT_object") @@ -135,7 +135,9 @@ class ShowHideMenu(): layout.operator("%s.hide" % self._operator_name, text="Hide Unselected").unselected = True -class VIEW3D_MT_transform(Menu): +# Standard transforms which apply to all cases +# NOTE: this doesn't seem to be able to be used directly +class VIEW3D_MT_transform_base(Menu): bl_label = "Transform" # TODO: get rid of the custom text strings? @@ -156,22 +158,38 @@ class VIEW3D_MT_transform(Menu): layout.operator("transform.warp", text="Warp") layout.operator("transform.push_pull", text="Push/Pull") + +# Generic transform menu - geometry types +class VIEW3D_MT_transform(VIEW3D_MT_transform_base): + def draw(self, context): + # base menu + VIEW3D_MT_transform_base.draw(self, context) + + # generic... + layout = self.layout layout.separator() layout.operator("transform.translate", text="Move Texture Space").texture_space = True layout.operator("transform.resize", text="Scale Texture Space").texture_space = True + +# Object-specific extensions to Transform menu +class VIEW3D_MT_transform_object(VIEW3D_MT_transform_base): + def draw(self, context): + # base menu + VIEW3D_MT_transform_base.draw(self, context) + + # object-specific option follow... + layout = self.layout layout.separator() - obj = context.object - if obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and obj.data.draw_type in {'BBONE', 'ENVELOPE'}: - layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE' - - if context.edit_object and context.edit_object.type == 'ARMATURE': - layout.operator("armature.align") - else: - layout.operator_context = 'EXEC_REGION_WIN' - layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working + layout.operator("transform.translate", text="Move Texture Space").texture_space = True + layout.operator("transform.resize", text="Scale Texture Space").texture_space = True + + layout.separator() + + layout.operator_context = 'EXEC_REGION_WIN' + layout.operator("transform.transform", text="Align to Transform Orientation").mode = 'ALIGN' # XXX see alignmenu() in edit.c of b2.4x to get this working layout.separator() @@ -191,6 +209,25 @@ class VIEW3D_MT_transform(Menu): layout.operator("object.anim_transforms_to_deltas") +# Armature EditMode extensions to Transform menu +class VIEW3D_MT_transform_armature(VIEW3D_MT_transform_base): + def draw(self, context): + # base menu + VIEW3D_MT_transform_base.draw(self, context) + + # armature specific extensions follow... + layout = self.layout + layout.separator() + + obj = context.object + if (obj.type == 'ARMATURE' and obj.mode in {'EDIT', 'POSE'} and + obj.data.draw_type in {'BBONE', 'ENVELOPE'}): + layout.operator("transform.transform", text="Scale Envelope/BBone").mode = 'BONE_SIZE' + + if context.edit_object and context.edit_object.type == 'ARMATURE': + layout.operator("armature.align") + + class VIEW3D_MT_mirror(Menu): bl_label = "Mirror" @@ -377,6 +414,11 @@ class VIEW3D_MT_view_align(Menu): layout.operator("view3d.view_selected") layout.operator("view3d.view_center_cursor") + layout.separator() + + layout.operator("view3d.view_lock_to_active") + layout.operator("view3d.view_lock_clear") + class VIEW3D_MT_view_align_selected(Menu): bl_label = "Align View to Selected" @@ -699,7 +741,7 @@ class VIEW3D_MT_object(Menu): layout.separator() - layout.menu("VIEW3D_MT_transform") + layout.menu("VIEW3D_MT_transform_object") layout.menu("VIEW3D_MT_mirror") layout.menu("VIEW3D_MT_object_clear") layout.menu("VIEW3D_MT_object_apply") @@ -1152,7 +1194,7 @@ class VIEW3D_MT_vertex_group(Menu): if ob.mode == 'EDIT' or (ob.mode == 'WEIGHT_PAINT' and ob.type == 'MESH' and ob.data.use_paint_mask_vertex): if ob.vertex_groups.active: layout.separator() - layout.operator("object.vertex_group_assign", text="Assign to Active Group") + layout.operator("object.vertex_group_assign", text="Assign to Active Group").new = False layout.operator("object.vertex_group_remove_from", text="Remove from Active Group").all = False layout.operator("object.vertex_group_remove_from", text="Remove from All").all = True layout.separator() @@ -1227,8 +1269,8 @@ class VIEW3D_MT_sculpt(Menu): layout.prop(sculpt, "use_deform_only") -class VIEW3D_MT_hide(Menu): - bl_label = "Hide" +class VIEW3D_MT_hide_mask(Menu): + bl_label = "Hide/Mask" def draw(self, context): layout = self.layout @@ -1244,6 +1286,23 @@ class VIEW3D_MT_hide(Menu): op = layout.operator("paint.hide_show", text="Show Bounding Box") op.action = 'SHOW' op.area = 'INSIDE' + + op = layout.operator("paint.hide_show", text="Hide Masked") + op.area = 'MASKED' + op.action = 'HIDE' + + layout.separator() + + op = layout.operator("paint.mask_flood_fill", text="Invert Mask") + op.mode = 'INVERT' + + op = layout.operator("paint.mask_flood_fill", text="Fill Mask") + op.mode = 'VALUE' + op.value = 1 + + op = layout.operator("paint.mask_flood_fill", text="Clear Mask") + op.mode = 'VALUE' + op.value = 0 # ********** Particle menu ********** @@ -1317,7 +1376,7 @@ class VIEW3D_MT_pose(Menu): layout.separator() - layout.menu("VIEW3D_MT_transform") + layout.menu("VIEW3D_MT_transform_armature") layout.menu("VIEW3D_MT_pose_transform") layout.menu("VIEW3D_MT_pose_apply") @@ -1496,6 +1555,24 @@ class VIEW3D_MT_pose_apply(Menu): layout.operator("pose.visual_transform_apply") +class VIEW3D_MT_pose_specials(Menu): + bl_label = "Specials" + + def draw(self, context): + layout = self.layout + layout.operator("pose.select_constraint_target") + layout.operator("pose.flip_names") + layout.operator("pose.paths_calculate") + layout.operator("pose.paths_clear") + layout.operator("pose.user_transforms_clear") + layout.operator("pose.user_transforms_clear", text="Clear User Transforms (All)").only_selected = False + layout.operator("pose.relax") + + layout.separator() + + layout.operator_menu_enum("pose.autoside_names", "axis") + + class BoneOptions: def draw(self, context): layout = self.layout @@ -1615,6 +1692,7 @@ class VIEW3D_MT_edit_mesh_specials(Menu): layout.operator("mesh.blend_from_shape") layout.operator("mesh.shape_propagate_to_all") layout.operator("mesh.select_vertex_path") + layout.operator("mesh.sort_elements") class VIEW3D_MT_edit_mesh_select_mode(Menu): @@ -1690,8 +1768,7 @@ class VIEW3D_MT_edit_mesh_vertices(Menu): layout.operator("mesh.vertices_smooth") layout.operator("mesh.remove_doubles") - layout.operator("mesh.vertices_sort") - layout.operator("mesh.vertices_randomize") + layout.operator("mesh.sort_elements", text="Sort Vertices").elements = {"VERT"} layout.operator("mesh.select_vertex_path") @@ -1741,6 +1818,7 @@ class VIEW3D_MT_edit_mesh_edges(Menu): layout.operator("mesh.bevel") layout.operator("mesh.edge_split") layout.operator("mesh.bridge_edge_loops") + layout.operator("mesh.sort_elements", text="Sort Edges").elements = {"EDGE"} layout.separator() @@ -1773,7 +1851,7 @@ class VIEW3D_MT_edit_mesh_faces(Menu): layout.operator("mesh.bevel") layout.operator("mesh.solidify") layout.operator("mesh.wireframe") - layout.operator("mesh.sort_faces") + layout.operator("mesh.sort_elements", text="Sort Faces").elements = {"FACE"} layout.separator() @@ -2082,7 +2160,7 @@ class VIEW3D_MT_edit_armature(Menu): edit_object = context.edit_object arm = edit_object.data - layout.menu("VIEW3D_MT_transform") + layout.menu("VIEW3D_MT_transform_armature") layout.menu("VIEW3D_MT_mirror") layout.menu("VIEW3D_MT_snap") layout.menu("VIEW3D_MT_edit_armature_roll") diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 503229f5593..31b6bf72f5d 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -145,10 +145,10 @@ class VIEW3D_PT_tools_meshedit(View3DPanel, Panel): row = col.row(align=True) props = row.operator("mesh.knife_tool", text="Knife") props.use_occlude_geometry = True - props.only_select = False + props.only_selected = False props = row.operator("mesh.knife_tool", text="Select") props.use_occlude_geometry = False - props.only_select = True + props.only_selected = True col = layout.column(align=True) col.label(text="Remove:") @@ -575,6 +575,9 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row.prop(brush, "sculpt_plane", text="") + if brush.sculpt_tool == 'MASK': + col.prop(brush, "mask_tool", text="") + # plane_offset, use_offset_pressure, use_plane_trim, plane_trim if capabilities.has_plane_offset: row = col.row(align=True) diff --git a/source/blender/avi/intern/avi.c b/source/blender/avi/intern/avi.c index 17c29e2a834..861e07f6eb3 100644 --- a/source/blender/avi/intern/avi.c +++ b/source/blender/avi/intern/avi.c @@ -51,7 +51,7 @@ #include "endian.h" -static int AVI_DEBUG=0; +static int AVI_DEBUG = 0; static char DEBUG_FCC[4]; #define DEBUG_PRINT(x) if (AVI_DEBUG) { printf("AVI DEBUG: " x); } (void)0 @@ -64,7 +64,7 @@ char *tcc_to_char(unsigned int tcc); /* implemetation */ -unsigned int GET_FCC (FILE *fp) +unsigned int GET_FCC(FILE *fp) { unsigned char tmp[4]; @@ -73,10 +73,10 @@ unsigned int GET_FCC (FILE *fp) tmp[2] = getc(fp); tmp[3] = getc(fp); - return FCC (tmp); + return FCC(tmp); } -unsigned int GET_TCC (FILE *fp) +unsigned int GET_TCC(FILE *fp) { char tmp[5]; @@ -85,25 +85,25 @@ unsigned int GET_TCC (FILE *fp) tmp[2] = 0; tmp[3] = 0; - return FCC (tmp); + return FCC(tmp); } char *fcc_to_char(unsigned int fcc) { - DEBUG_FCC[0]= (fcc)&127; - DEBUG_FCC[1]= (fcc>>8)&127; - DEBUG_FCC[2]= (fcc>>16)&127; - DEBUG_FCC[3]= (fcc>>24)&127; + DEBUG_FCC[0] = (fcc) & 127; + DEBUG_FCC[1] = (fcc >> 8) & 127; + DEBUG_FCC[2] = (fcc >> 16) & 127; + DEBUG_FCC[3] = (fcc >> 24) & 127; return DEBUG_FCC; } char *tcc_to_char(unsigned int tcc) { - DEBUG_FCC[0]= (tcc)&127; - DEBUG_FCC[1]= (tcc>>8)&127; - DEBUG_FCC[2]= 0; - DEBUG_FCC[3]= 0; + DEBUG_FCC[0] = (tcc) & 127; + DEBUG_FCC[1] = (tcc >> 8) & 127; + DEBUG_FCC[2] = 0; + DEBUG_FCC[3] = 0; return DEBUG_FCC; } @@ -115,7 +115,7 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num) if (movie == NULL) return -AVI_ERROR_OPTION; - for (cur_stream=0; cur_stream < movie->header->Streams; cur_stream++) { + for (cur_stream = 0; cur_stream < movie->header->Streams; cur_stream++) { if (movie->streams[cur_stream].sh.Type == avist_type) { if (stream_num == 0) return cur_stream; @@ -127,28 +127,28 @@ int AVI_get_stream(AviMovie *movie, int avist_type, int stream_num) return -AVI_ERROR_FOUND; } -static int fcc_get_stream (int fcc) +static int fcc_get_stream(int fcc) { char fccs[4]; fccs[0] = fcc; - fccs[1] = fcc>>8; - fccs[2] = fcc>>16; - fccs[3] = fcc>>24; + fccs[1] = fcc >> 8; + fccs[2] = fcc >> 16; + fccs[3] = fcc >> 24; - return 10*(fccs[0]-'0') + (fccs[1]-'0'); + return 10 * (fccs[0] - '0') + (fccs[1] - '0'); } -static int fcc_is_data (int fcc) +static int fcc_is_data(int fcc) { char fccs[4]; fccs[0] = fcc; - fccs[1] = fcc>>8; - fccs[2] = fcc>>16; - fccs[3] = fcc>>24; + fccs[1] = fcc >> 8; + fccs[2] = fcc >> 16; + fccs[3] = fcc >> 24; - if (!isdigit (fccs[0]) || !isdigit (fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) + if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) return 0; if (fccs[3] != 'b' && fccs[3] != 'c') return 0; @@ -166,34 +166,34 @@ AviError AVI_print_error(AviError in_error) error = in_error; switch (error) { - case AVI_ERROR_NONE: - break; - case AVI_ERROR_COMPRESSION: - printf ("AVI ERROR: compressed in an unsupported format\n"); - break; - case AVI_ERROR_OPEN: - printf ("AVI ERROR: could not open file\n"); - break; - case AVI_ERROR_READING: - printf ("AVI ERROR: could not read from file\n"); - break; - case AVI_ERROR_WRITING: - printf ("AVI ERROR: could not write to file\n"); - break; - case AVI_ERROR_FORMAT: - printf ("AVI ERROR: file is in an illegal or unrecognized format\n"); - break; - case AVI_ERROR_ALLOC: - printf ("AVI ERROR: error encountered while allocating memory\n"); - break; - case AVI_ERROR_OPTION: - printf ("AVI ERROR: program made illegal request\n"); - break; - case AVI_ERROR_FOUND: - printf ("AVI ERROR: movie did not contain expected item\n"); - break; - default: - break; + case AVI_ERROR_NONE: + break; + case AVI_ERROR_COMPRESSION: + printf("AVI ERROR: compressed in an unsupported format\n"); + break; + case AVI_ERROR_OPEN: + printf("AVI ERROR: could not open file\n"); + break; + case AVI_ERROR_READING: + printf("AVI ERROR: could not read from file\n"); + break; + case AVI_ERROR_WRITING: + printf("AVI ERROR: could not write to file\n"); + break; + case AVI_ERROR_FORMAT: + printf("AVI ERROR: file is in an illegal or unrecognized format\n"); + break; + case AVI_ERROR_ALLOC: + printf("AVI ERROR: error encountered while allocating memory\n"); + break; + case AVI_ERROR_OPTION: + printf("AVI ERROR: program made illegal request\n"); + break; + case AVI_ERROR_FOUND: + printf("AVI ERROR: movie did not contain expected item\n"); + break; + default: + break; } return in_error; @@ -201,7 +201,7 @@ AviError AVI_print_error(AviError in_error) #if 0 void AVI_set_debug(int mode) { - AVI_DEBUG= mode; + AVI_DEBUG = mode; } int AVI_is_avi(char *name) @@ -209,13 +209,13 @@ int AVI_is_avi(char *name) FILE *fp; int ret; - fp = fopen (name, "rb"); + fp = fopen(name, "rb"); if (fp == NULL) return 0; - if (GET_FCC (fp) != FCC("RIFF") || - !GET_FCC (fp) || - GET_FCC (fp) != FCC("AVI ")) { + if (GET_FCC(fp) != FCC("RIFF") || + !GET_FCC(fp) || + GET_FCC(fp) != FCC("AVI ")) { ret = 0; } else { @@ -230,7 +230,7 @@ int AVI_is_avi(char *name) int AVI_is_avi(const char *name) { int temp, fcca, j; - AviMovie movie= {NULL}; + AviMovie movie = {NULL}; AviMainHeader header; AviBitmapInfoHeader bheader; int movie_tracks = 0; @@ -238,26 +238,26 @@ int AVI_is_avi(const char *name) DEBUG_PRINT("opening movie\n"); movie.type = AVI_MOVIE_READ; - movie.fp = fopen (name, "rb"); + movie.fp = fopen(name, "rb"); movie.offset_table = NULL; if (movie.fp == NULL) return 0; - if (GET_FCC (movie.fp) != FCC("RIFF") || - !(movie.size = GET_FCC (movie.fp))) { + if (GET_FCC(movie.fp) != FCC("RIFF") || + !(movie.size = GET_FCC(movie.fp))) { fclose(movie.fp); return 0; } movie.header = &header; - if (GET_FCC (movie.fp) != FCC("AVI ") || - GET_FCC (movie.fp) != FCC("LIST") || - !GET_FCC (movie.fp) || - GET_FCC (movie.fp) != FCC("hdrl") || - (movie.header->fcc = GET_FCC (movie.fp)) != FCC("avih") || - !(movie.header->size = GET_FCC (movie.fp))) { + if (GET_FCC(movie.fp) != FCC("AVI ") || + GET_FCC(movie.fp) != FCC("LIST") || + !GET_FCC(movie.fp) || + GET_FCC(movie.fp) != FCC("hdrl") || + (movie.header->fcc = GET_FCC(movie.fp)) != FCC("avih") || + !(movie.header->size = GET_FCC(movie.fp))) { DEBUG_PRINT("bad initial header info\n"); fclose(movie.fp); return 0; @@ -278,7 +278,7 @@ int AVI_is_avi(const char *name) movie.header->Reserved[2] = GET_FCC(movie.fp); movie.header->Reserved[3] = GET_FCC(movie.fp); - fseek (movie.fp, movie.header->size-14*4, SEEK_CUR); + fseek(movie.fp, movie.header->size - 14 * 4, SEEK_CUR); if (movie.header->Streams < 1) { DEBUG_PRINT("streams less than 1\n"); @@ -286,15 +286,16 @@ int AVI_is_avi(const char *name) return 0; } - movie.streams = (AviStreamRec *) MEM_callocN (sizeof(AviStreamRec) * movie.header->Streams, "moviestreams"); + movie.streams = (AviStreamRec *) MEM_callocN(sizeof(AviStreamRec) * movie.header->Streams, "moviestreams"); - for (temp=0; temp < movie.header->Streams; temp++) { + for (temp = 0; temp < movie.header->Streams; temp++) { if (GET_FCC(movie.fp) != FCC("LIST") || - !GET_FCC (movie.fp) || - GET_FCC (movie.fp) != FCC ("strl") || - (movie.streams[temp].sh.fcc = GET_FCC (movie.fp)) != FCC ("strh") || - !(movie.streams[temp].sh.size = GET_FCC (movie.fp))) { + !GET_FCC(movie.fp) || + GET_FCC(movie.fp) != FCC("strl") || + (movie.streams[temp].sh.fcc = GET_FCC(movie.fp)) != FCC("strh") || + !(movie.streams[temp].sh.size = GET_FCC(movie.fp))) + { DEBUG_PRINT("bad stream header information\n"); MEM_freeN(movie.streams); @@ -302,20 +303,21 @@ int AVI_is_avi(const char *name) return 0; } - movie.streams[temp].sh.Type = GET_FCC (movie.fp); - movie.streams[temp].sh.Handler = GET_FCC (movie.fp); + movie.streams[temp].sh.Type = GET_FCC(movie.fp); + movie.streams[temp].sh.Handler = GET_FCC(movie.fp); fcca = movie.streams[temp].sh.Handler; if (movie.streams[temp].sh.Type == FCC("vids")) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0) { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { movie.streams[temp].format = AVI_FORMAT_AVI_RGB; } - else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) { + else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { movie.streams[temp].format = AVI_FORMAT_MJPEG; } else { @@ -326,67 +328,70 @@ int AVI_is_avi(const char *name) movie_tracks++; } - movie.streams[temp].sh.Flags = GET_FCC (movie.fp); - movie.streams[temp].sh.Priority = GET_TCC (movie.fp); - movie.streams[temp].sh.Language = GET_TCC (movie.fp); - movie.streams[temp].sh.InitialFrames = GET_FCC (movie.fp); - movie.streams[temp].sh.Scale = GET_FCC (movie.fp); - movie.streams[temp].sh.Rate = GET_FCC (movie.fp); - movie.streams[temp].sh.Start = GET_FCC (movie.fp); - movie.streams[temp].sh.Length = GET_FCC (movie.fp); - movie.streams[temp].sh.SuggestedBufferSize = GET_FCC (movie.fp); - movie.streams[temp].sh.Quality = GET_FCC (movie.fp); - movie.streams[temp].sh.SampleSize = GET_FCC (movie.fp); - movie.streams[temp].sh.left = GET_TCC (movie.fp); - movie.streams[temp].sh.top = GET_TCC (movie.fp); - movie.streams[temp].sh.right = GET_TCC (movie.fp); - movie.streams[temp].sh.bottom = GET_TCC (movie.fp); + movie.streams[temp].sh.Flags = GET_FCC(movie.fp); + movie.streams[temp].sh.Priority = GET_TCC(movie.fp); + movie.streams[temp].sh.Language = GET_TCC(movie.fp); + movie.streams[temp].sh.InitialFrames = GET_FCC(movie.fp); + movie.streams[temp].sh.Scale = GET_FCC(movie.fp); + movie.streams[temp].sh.Rate = GET_FCC(movie.fp); + movie.streams[temp].sh.Start = GET_FCC(movie.fp); + movie.streams[temp].sh.Length = GET_FCC(movie.fp); + movie.streams[temp].sh.SuggestedBufferSize = GET_FCC(movie.fp); + movie.streams[temp].sh.Quality = GET_FCC(movie.fp); + movie.streams[temp].sh.SampleSize = GET_FCC(movie.fp); + movie.streams[temp].sh.left = GET_TCC(movie.fp); + movie.streams[temp].sh.top = GET_TCC(movie.fp); + movie.streams[temp].sh.right = GET_TCC(movie.fp); + movie.streams[temp].sh.bottom = GET_TCC(movie.fp); - fseek (movie.fp, movie.streams[temp].sh.size-14*4, SEEK_CUR); + fseek(movie.fp, movie.streams[temp].sh.size - 14 * 4, SEEK_CUR); - if (GET_FCC (movie.fp) != FCC("strf")) { + if (GET_FCC(movie.fp) != FCC("strf")) { DEBUG_PRINT("no stream format information\n"); MEM_freeN(movie.streams); fclose(movie.fp); return 0; } - movie.streams[temp].sf_size= GET_FCC(movie.fp); + movie.streams[temp].sf_size = GET_FCC(movie.fp); if (movie.streams[temp].sh.Type == FCC("vids")) { j = movie.streams[temp].sf_size - (sizeof(AviBitmapInfoHeader) - 8); if (j >= 0) { AviBitmapInfoHeader *bi; - movie.streams[temp].sf= &bheader; - bi= (AviBitmapInfoHeader *) movie.streams[temp].sf; + movie.streams[temp].sf = &bheader; + bi = (AviBitmapInfoHeader *) movie.streams[temp].sf; - bi->fcc= FCC("strf"); - bi->size= movie.streams[temp].sf_size; - bi->Size= GET_FCC(movie.fp); - bi->Width= GET_FCC(movie.fp); - bi->Height= GET_FCC(movie.fp); - bi->Planes= GET_TCC(movie.fp); - bi->BitCount= GET_TCC(movie.fp); - bi->Compression= GET_FCC(movie.fp); - bi->SizeImage= GET_FCC(movie.fp); - bi->XPelsPerMeter= GET_FCC(movie.fp); - bi->YPelsPerMeter= GET_FCC(movie.fp); - bi->ClrUsed= GET_FCC(movie.fp); - bi->ClrImportant= GET_FCC(movie.fp); + bi->fcc = FCC("strf"); + bi->size = movie.streams[temp].sf_size; + bi->Size = GET_FCC(movie.fp); + bi->Width = GET_FCC(movie.fp); + bi->Height = GET_FCC(movie.fp); + bi->Planes = GET_TCC(movie.fp); + bi->BitCount = GET_TCC(movie.fp); + bi->Compression = GET_FCC(movie.fp); + bi->SizeImage = GET_FCC(movie.fp); + bi->XPelsPerMeter = GET_FCC(movie.fp); + bi->YPelsPerMeter = GET_FCC(movie.fp); + bi->ClrUsed = GET_FCC(movie.fp); + bi->ClrImportant = GET_FCC(movie.fp); fcca = bi->Compression; - if ( movie.streams[temp].format == - AVI_FORMAT_AVI_RGB) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0 ) { + if (movie.streams[temp].format == + AVI_FORMAT_AVI_RGB) { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { + /* pass */ } - else if ( fcca == FCC ("mjpg") || - fcca == FCC ("MJPG")) { - movie.streams[temp].format = AVI_FORMAT_MJPEG; + else if (fcca == FCC("mjpg") || + fcca == FCC("MJPG")) + { + movie.streams[temp].format = AVI_FORMAT_MJPEG; } else { MEM_freeN(movie.streams); @@ -396,14 +401,14 @@ int AVI_is_avi(const char *name) } } - if (j > 0) fseek (movie.fp, j, SEEK_CUR); + if (j > 0) fseek(movie.fp, j, SEEK_CUR); } - else fseek (movie.fp, movie.streams[temp].sf_size, SEEK_CUR); + else fseek(movie.fp, movie.streams[temp].sf_size, SEEK_CUR); /* Walk to the next LIST */ - while (GET_FCC (movie.fp) != FCC("LIST")) { - temp= GET_FCC (movie.fp); - if (temp<0 || ftell(movie.fp) > movie.size) { + while (GET_FCC(movie.fp) != FCC("LIST")) { + temp = GET_FCC(movie.fp); + if (temp < 0 || ftell(movie.fp) > movie.size) { DEBUG_PRINT("incorrect size in header or error in AVI\n"); MEM_freeN(movie.streams); @@ -433,26 +438,27 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) memset(movie, 0, sizeof(AviMovie)); movie->type = AVI_MOVIE_READ; - movie->fp = fopen (name, "rb"); + movie->fp = fopen(name, "rb"); movie->offset_table = NULL; if (movie->fp == NULL) return AVI_ERROR_OPEN; - if (GET_FCC (movie->fp) != FCC("RIFF") || - !(movie->size = GET_FCC (movie->fp))) + if (GET_FCC(movie->fp) != FCC("RIFF") || + !(movie->size = GET_FCC(movie->fp))) { return AVI_ERROR_FORMAT; } - movie->header = (AviMainHeader *) MEM_mallocN (sizeof (AviMainHeader), "movieheader"); + movie->header = (AviMainHeader *) MEM_mallocN(sizeof (AviMainHeader), "movieheader"); - if (GET_FCC (movie->fp) != FCC("AVI ") || - GET_FCC (movie->fp) != FCC("LIST") || - !GET_FCC (movie->fp) || - GET_FCC (movie->fp) != FCC("hdrl") || - (movie->header->fcc = GET_FCC (movie->fp)) != FCC("avih") || - !(movie->header->size = GET_FCC (movie->fp))) { + if (GET_FCC(movie->fp) != FCC("AVI ") || + GET_FCC(movie->fp) != FCC("LIST") || + !GET_FCC(movie->fp) || + GET_FCC(movie->fp) != FCC("hdrl") || + (movie->header->fcc = GET_FCC(movie->fp)) != FCC("avih") || + !(movie->header->size = GET_FCC(movie->fp))) + { DEBUG_PRINT("bad initial header info\n"); return AVI_ERROR_FORMAT; } @@ -472,40 +478,42 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) movie->header->Reserved[2] = GET_FCC(movie->fp); movie->header->Reserved[3] = GET_FCC(movie->fp); - fseek (movie->fp, movie->header->size-14*4, SEEK_CUR); + fseek(movie->fp, movie->header->size - 14 * 4, SEEK_CUR); if (movie->header->Streams < 1) { DEBUG_PRINT("streams less than 1\n"); return AVI_ERROR_FORMAT; } - movie->streams = (AviStreamRec *) MEM_callocN (sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); + movie->streams = (AviStreamRec *) MEM_callocN(sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); - for (temp=0; temp < movie->header->Streams; temp++) { + for (temp = 0; temp < movie->header->Streams; temp++) { if (GET_FCC(movie->fp) != FCC("LIST") || - !GET_FCC (movie->fp) || - GET_FCC (movie->fp) != FCC ("strl") || - (movie->streams[temp].sh.fcc = GET_FCC (movie->fp)) != FCC ("strh") || - !(movie->streams[temp].sh.size = GET_FCC (movie->fp))) { + !GET_FCC(movie->fp) || + GET_FCC(movie->fp) != FCC("strl") || + (movie->streams[temp].sh.fcc = GET_FCC(movie->fp)) != FCC("strh") || + !(movie->streams[temp].sh.size = GET_FCC(movie->fp))) + { DEBUG_PRINT("bad stream header information\n"); - return AVI_ERROR_FORMAT; + return AVI_ERROR_FORMAT; } - movie->streams[temp].sh.Type = GET_FCC (movie->fp); - movie->streams[temp].sh.Handler = GET_FCC (movie->fp); + movie->streams[temp].sh.Type = GET_FCC(movie->fp); + movie->streams[temp].sh.Handler = GET_FCC(movie->fp); fcca = movie->streams[temp].sh.Handler; if (movie->streams[temp].sh.Type == FCC("vids")) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0) { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { movie->streams[temp].format = AVI_FORMAT_AVI_RGB; } - else if (fcca == FCC ("mjpg")||fcca == FCC ("MJPG")) { + else if (fcca == FCC("mjpg") || fcca == FCC("MJPG")) { movie->streams[temp].format = AVI_FORMAT_MJPEG; } else { @@ -513,66 +521,70 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - movie->streams[temp].sh.Flags = GET_FCC (movie->fp); - movie->streams[temp].sh.Priority = GET_TCC (movie->fp); - movie->streams[temp].sh.Language = GET_TCC (movie->fp); - movie->streams[temp].sh.InitialFrames = GET_FCC (movie->fp); - movie->streams[temp].sh.Scale = GET_FCC (movie->fp); - movie->streams[temp].sh.Rate = GET_FCC (movie->fp); - movie->streams[temp].sh.Start = GET_FCC (movie->fp); - movie->streams[temp].sh.Length = GET_FCC (movie->fp); - movie->streams[temp].sh.SuggestedBufferSize = GET_FCC (movie->fp); - movie->streams[temp].sh.Quality = GET_FCC (movie->fp); - movie->streams[temp].sh.SampleSize = GET_FCC (movie->fp); - movie->streams[temp].sh.left = GET_TCC (movie->fp); - movie->streams[temp].sh.top = GET_TCC (movie->fp); - movie->streams[temp].sh.right = GET_TCC (movie->fp); - movie->streams[temp].sh.bottom = GET_TCC (movie->fp); + movie->streams[temp].sh.Flags = GET_FCC(movie->fp); + movie->streams[temp].sh.Priority = GET_TCC(movie->fp); + movie->streams[temp].sh.Language = GET_TCC(movie->fp); + movie->streams[temp].sh.InitialFrames = GET_FCC(movie->fp); + movie->streams[temp].sh.Scale = GET_FCC(movie->fp); + movie->streams[temp].sh.Rate = GET_FCC(movie->fp); + movie->streams[temp].sh.Start = GET_FCC(movie->fp); + movie->streams[temp].sh.Length = GET_FCC(movie->fp); + movie->streams[temp].sh.SuggestedBufferSize = GET_FCC(movie->fp); + movie->streams[temp].sh.Quality = GET_FCC(movie->fp); + movie->streams[temp].sh.SampleSize = GET_FCC(movie->fp); + movie->streams[temp].sh.left = GET_TCC(movie->fp); + movie->streams[temp].sh.top = GET_TCC(movie->fp); + movie->streams[temp].sh.right = GET_TCC(movie->fp); + movie->streams[temp].sh.bottom = GET_TCC(movie->fp); - fseek (movie->fp, movie->streams[temp].sh.size-14*4, SEEK_CUR); + fseek(movie->fp, movie->streams[temp].sh.size - 14 * 4, SEEK_CUR); - if (GET_FCC (movie->fp) != FCC("strf")) { + if (GET_FCC(movie->fp) != FCC("strf")) { DEBUG_PRINT("no stream format information\n"); return AVI_ERROR_FORMAT; } - movie->streams[temp].sf_size= GET_FCC(movie->fp); + movie->streams[temp].sf_size = GET_FCC(movie->fp); if (movie->streams[temp].sh.Type == FCC("vids")) { j = movie->streams[temp].sf_size - (sizeof(AviBitmapInfoHeader) - 8); if (j >= 0) { AviBitmapInfoHeader *bi; - movie->streams[temp].sf= MEM_mallocN(sizeof(AviBitmapInfoHeader), "streamformat"); + movie->streams[temp].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader), "streamformat"); - bi= (AviBitmapInfoHeader *) movie->streams[temp].sf; + bi = (AviBitmapInfoHeader *) movie->streams[temp].sf; - bi->fcc= FCC("strf"); - bi->size= movie->streams[temp].sf_size; - bi->Size= GET_FCC(movie->fp); - bi->Width= GET_FCC(movie->fp); - bi->Height= GET_FCC(movie->fp); - bi->Planes= GET_TCC(movie->fp); - bi->BitCount= GET_TCC(movie->fp); - bi->Compression= GET_FCC(movie->fp); - bi->SizeImage= GET_FCC(movie->fp); - bi->XPelsPerMeter= GET_FCC(movie->fp); - bi->YPelsPerMeter= GET_FCC(movie->fp); - bi->ClrUsed= GET_FCC(movie->fp); - bi->ClrImportant= GET_FCC(movie->fp); + bi->fcc = FCC("strf"); + bi->size = movie->streams[temp].sf_size; + bi->Size = GET_FCC(movie->fp); + bi->Width = GET_FCC(movie->fp); + bi->Height = GET_FCC(movie->fp); + bi->Planes = GET_TCC(movie->fp); + bi->BitCount = GET_TCC(movie->fp); + bi->Compression = GET_FCC(movie->fp); + bi->SizeImage = GET_FCC(movie->fp); + bi->XPelsPerMeter = GET_FCC(movie->fp); + bi->YPelsPerMeter = GET_FCC(movie->fp); + bi->ClrUsed = GET_FCC(movie->fp); + bi->ClrImportant = GET_FCC(movie->fp); fcca = bi->Compression; - if ( movie->streams[temp].format == - AVI_FORMAT_AVI_RGB) { - if (fcca == FCC ("DIB ") || - fcca == FCC ("RGB ") || - fcca == FCC ("rgb ") || - fcca == FCC ("RAW ") || - fcca == 0 ) { + if (movie->streams[temp].format == + AVI_FORMAT_AVI_RGB) + { + if (fcca == FCC("DIB ") || + fcca == FCC("RGB ") || + fcca == FCC("rgb ") || + fcca == FCC("RAW ") || + fcca == 0) + { + /* pass */ } - else if ( fcca == FCC ("mjpg") || - fcca == FCC ("MJPG")) { - movie->streams[temp].format = AVI_FORMAT_MJPEG; + else if (fcca == FCC("mjpg") || + fcca == FCC("MJPG")) + { + movie->streams[temp].format = AVI_FORMAT_MJPEG; } else { return AVI_ERROR_COMPRESSION; @@ -580,38 +592,38 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - if (j > 0) fseek (movie->fp, j, SEEK_CUR); + if (j > 0) fseek(movie->fp, j, SEEK_CUR); } - else fseek (movie->fp, movie->streams[temp].sf_size, SEEK_CUR); + else fseek(movie->fp, movie->streams[temp].sf_size, SEEK_CUR); /* Walk to the next LIST */ - while (GET_FCC (movie->fp) != FCC("LIST")) { - temp= GET_FCC (movie->fp); - if (temp<0 || ftell(movie->fp) > movie->size) { + while (GET_FCC(movie->fp) != FCC("LIST")) { + temp = GET_FCC(movie->fp); + if (temp < 0 || ftell(movie->fp) > movie->size) { DEBUG_PRINT("incorrect size in header or error in AVI\n"); - return AVI_ERROR_FORMAT; + return AVI_ERROR_FORMAT; } - fseek(movie->fp, temp, SEEK_CUR); + fseek(movie->fp, temp, SEEK_CUR); } - fseek(movie->fp, -4L, SEEK_CUR); + fseek(movie->fp, -4L, SEEK_CUR); } while (1) { - temp = GET_FCC (movie->fp); - size = GET_FCC (movie->fp); + temp = GET_FCC(movie->fp); + size = GET_FCC(movie->fp); if (size == 0) break; if (temp == FCC("LIST")) { - if (GET_FCC(movie->fp) == FCC ("movi")) + if (GET_FCC(movie->fp) == FCC("movi")) break; else - fseek (movie->fp, size-4, SEEK_CUR); + fseek(movie->fp, size - 4, SEEK_CUR); } else { - fseek (movie->fp, size, SEEK_CUR); + fseek(movie->fp, size, SEEK_CUR); } if (ftell(movie->fp) > movie->size) { DEBUG_PRINT("incorrect size in header or error in AVI\n"); @@ -619,31 +631,31 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) } } - movie->movi_offset = ftell (movie->fp); + movie->movi_offset = ftell(movie->fp); movie->read_offset = movie->movi_offset; /* Read in the index if the file has one, otherwise create one */ if (movie->header->Flags & AVIF_HASINDEX) { - fseek(movie->fp, size-4, SEEK_CUR); + fseek(movie->fp, size - 4, SEEK_CUR); if (GET_FCC(movie->fp) != FCC("idx1")) { DEBUG_PRINT("bad index informatio\n"); return AVI_ERROR_FORMAT; } - movie->index_entries = GET_FCC (movie->fp)/sizeof(AviIndexEntry); + movie->index_entries = GET_FCC(movie->fp) / sizeof(AviIndexEntry); if (movie->index_entries == 0) { DEBUG_PRINT("no index entries\n"); return AVI_ERROR_FORMAT; } - movie->entries = (AviIndexEntry *) MEM_mallocN (movie->index_entries * sizeof(AviIndexEntry), "movieentries"); + movie->entries = (AviIndexEntry *) MEM_mallocN(movie->index_entries * sizeof(AviIndexEntry), "movieentries"); - for (temp=0; temp < movie->index_entries; temp++) { - movie->entries[temp].ChunkId = GET_FCC (movie->fp); - movie->entries[temp].Flags = GET_FCC (movie->fp); - movie->entries[temp].Offset = GET_FCC (movie->fp); - movie->entries[temp].Size = GET_FCC (movie->fp); + for (temp = 0; temp < movie->index_entries; temp++) { + movie->entries[temp].ChunkId = GET_FCC(movie->fp); + movie->entries[temp].Flags = GET_FCC(movie->fp); + movie->entries[temp].Offset = GET_FCC(movie->fp); + movie->entries[temp].Size = GET_FCC(movie->fp); if (AVI_DEBUG) { printf("Index entry %04d: ChunkId:%s Flags:%d Offset:%d Size:%d\n", @@ -660,31 +672,32 @@ AviError AVI_open_movie(const char *name, AviMovie *movie) * undetermined reason */ if (movie->entries[0].Offset == movie->movi_offset) - movie->read_offset= 4; + movie->read_offset = 4; } DEBUG_PRINT("movie succesfully opened\n"); return AVI_ERROR_NONE; } -void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream) +void *AVI_read_frame(AviMovie *movie, AviFormat format, int frame, int stream) { - int cur_frame=-1, temp, i=0, rewind=1; + int cur_frame = -1, temp, i = 0, rewind = 1; void *buffer; /* Retrieve the record number of the desired frame in the index * If a chunk has Size 0 we need to rewind to previous frame */ while (rewind && frame > -1) { - i=0; - cur_frame=-1; + i = 0; + cur_frame = -1; rewind = 0; while (cur_frame < frame && i < movie->index_entries) { - if (fcc_is_data (movie->entries[i].ChunkId) && - fcc_get_stream (movie->entries[i].ChunkId) == stream) { - if ((cur_frame == frame -1) && (movie->entries[i].Size == 0)) { + if (fcc_is_data(movie->entries[i].ChunkId) && + fcc_get_stream(movie->entries[i].ChunkId) == stream) + { + if ((cur_frame == frame - 1) && (movie->entries[i].Size == 0)) { rewind = 1; - frame = frame -1; + frame = frame - 1; } else { cur_frame++; @@ -697,18 +710,18 @@ void *AVI_read_frame (AviMovie *movie, AviFormat format, int frame, int stream) if (cur_frame != frame) return NULL; - fseek (movie->fp, movie->read_offset + movie->entries[i-1].Offset, SEEK_SET); + fseek(movie->fp, movie->read_offset + movie->entries[i - 1].Offset, SEEK_SET); temp = GET_FCC(movie->fp); - buffer = MEM_mallocN (temp, "readbuffer"); + buffer = MEM_mallocN(temp, "readbuffer"); - if (fread (buffer, 1, temp, movie->fp) != temp) { + if (fread(buffer, 1, temp, movie->fp) != temp) { MEM_freeN(buffer); return NULL; } - buffer = avi_format_convert (movie, stream, buffer, movie->streams[stream].format, format, &temp); + buffer = avi_format_convert(movie, stream, buffer, movie->streams[stream].format, format, &temp); return buffer; } @@ -717,21 +730,21 @@ AviError AVI_close(AviMovie *movie) { int i; - fclose (movie->fp); + fclose(movie->fp); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { if (movie->streams[i].sf != NULL) - MEM_freeN (movie->streams[i].sf); + MEM_freeN(movie->streams[i].sf); } if (movie->header != NULL) - MEM_freeN (movie->header); - if (movie->streams!= NULL) - MEM_freeN (movie->streams); + MEM_freeN(movie->header); + if (movie->streams != NULL) + MEM_freeN(movie->streams); if (movie->entries != NULL) - MEM_freeN (movie->entries); + MEM_freeN(movie->entries); if (movie->offset_table != NULL) - MEM_freeN (movie->offset_table); + MEM_freeN(movie->offset_table); return AVI_ERROR_NONE; } @@ -747,21 +760,21 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) int64_t junk_pos; movie->type = AVI_MOVIE_WRITE; - movie->fp = fopen (name, "wb"); + movie->fp = fopen(name, "wb"); movie->index_entries = 0; if (movie->fp == NULL) return AVI_ERROR_OPEN; - movie->offset_table = (int64_t *) MEM_mallocN ((1+streams*2) * sizeof (int64_t), "offsettable"); + movie->offset_table = (int64_t *) MEM_mallocN((1 + streams * 2) * sizeof (int64_t), "offsettable"); - for (i=0; i < 1 + streams*2; i++) + for (i = 0; i < 1 + streams * 2; i++) movie->offset_table[i] = -1L; movie->entries = NULL; - movie->header = (AviMainHeader *) MEM_mallocN (sizeof(AviMainHeader), "movieheader"); + movie->header = (AviMainHeader *) MEM_mallocN(sizeof(AviMainHeader), "movieheader"); movie->header->fcc = FCC("avih"); movie->header->size = 56; @@ -780,20 +793,20 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) movie->header->Reserved[2] = 0; movie->header->Reserved[3] = 0; - movie->streams = (AviStreamRec *) MEM_mallocN (sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); + movie->streams = (AviStreamRec *) MEM_mallocN(sizeof(AviStreamRec) * movie->header->Streams, "moviestreams"); - va_start (ap, streams); + va_start(ap, streams); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { movie->streams[i].format = va_arg(ap, AviFormat); - movie->streams[i].sh.fcc = FCC ("strh"); + movie->streams[i].sh.fcc = FCC("strh"); movie->streams[i].sh.size = 56; - movie->streams[i].sh.Type = avi_get_format_type (movie->streams[i].format); + movie->streams[i].sh.Type = avi_get_format_type(movie->streams[i].format); if (movie->streams[i].sh.Type == 0) return AVI_ERROR_FORMAT; - movie->streams[i].sh.Handler = avi_get_format_fcc (movie->streams[i].format); + movie->streams[i].sh.Handler = avi_get_format_fcc(movie->streams[i].format); if (movie->streams[i].sh.Handler == 0) return AVI_ERROR_FORMAT; @@ -816,30 +829,30 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) if (movie->streams[i].sh.Type == FCC("vids")) { #if 0 if (movie->streams[i].format == AVI_FORMAT_MJPEG) { - movie->streams[i].sf = MEM_mallocN (sizeof(AviBitmapInfoHeader) - + sizeof(AviMJPEGUnknown), "moviestreamformatL"); + movie->streams[i].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader) + + sizeof(AviMJPEGUnknown), "moviestreamformatL"); movie->streams[i].sf_size = sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown); } else { #endif - movie->streams[i].sf = MEM_mallocN (sizeof(AviBitmapInfoHeader), "moviestreamformatS"); + movie->streams[i].sf = MEM_mallocN(sizeof(AviBitmapInfoHeader), "moviestreamformatS"); movie->streams[i].sf_size = sizeof(AviBitmapInfoHeader); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->fcc = FCC ("strf"); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->fcc = FCC("strf"); ((AviBitmapInfoHeader *) movie->streams[i].sf)->size = movie->streams[i].sf_size - 8; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Size = movie->streams[i].sf_size - 8; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->Planes = 1; ((AviBitmapInfoHeader *) movie->streams[i].sf)->BitCount = 24; - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Compression = avi_get_format_compression (movie->streams[i].format); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Compression = avi_get_format_compression(movie->streams[i].format); ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->XPelsPerMeter = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->YPelsPerMeter = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->ClrUsed = 0; ((AviBitmapInfoHeader *) movie->streams[i].sf)->ClrImportant = 0; -/* +#if 0 if (movie->streams[i].format == AVI_FORMAT_MJPEG) { AviMJPEGUnknown *tmp; @@ -857,7 +870,7 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) else if (movie->streams[i].sh.Type == FCC("auds")) { // pass } -*/ +#endif } } @@ -865,53 +878,53 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) list.size = 0; list.ids = FCC("AVI "); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); list.fcc = FCC("LIST"); list.size = 0; list.ids = FCC("hdrl"); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); header_pos1 = ftell(movie->fp); movie->offset_table[0] = ftell(movie->fp); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { list.fcc = FCC("LIST"); list.size = 0; list.ids = FCC("strl"); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); stream_pos1 = ftell(movie->fp); - movie->offset_table[1+i*2] = ftell(movie->fp); - awrite (movie, &movie->streams[i].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); + movie->offset_table[1 + i * 2] = ftell(movie->fp); + awrite(movie, &movie->streams[i].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); - movie->offset_table[1+i*2+1] = ftell(movie->fp); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + movie->offset_table[1 + i * 2 + 1] = ftell(movie->fp); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); stream_pos2 = ftell(movie->fp); - fseek (movie->fp, stream_pos1-8, SEEK_SET); + fseek(movie->fp, stream_pos1 - 8, SEEK_SET); - PUT_FCCN((stream_pos2-stream_pos1+4L), movie->fp); + PUT_FCCN((stream_pos2 - stream_pos1 + 4L), movie->fp); - fseek (movie->fp, stream_pos2, SEEK_SET); + fseek(movie->fp, stream_pos2, SEEK_SET); } - junk_pos= ftell(movie->fp); + junk_pos = ftell(movie->fp); if (junk_pos < 2024 - 8) { chunk.fcc = FCC("JUNK"); chunk.size = 2024 - 8 - (int)junk_pos; - awrite (movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); + awrite(movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); - for (i=0; i < chunk.size; i++) + for (i = 0; i < chunk.size; i++) putc(0, movie->fp); } @@ -921,13 +934,13 @@ AviError AVI_open_compress(char *name, AviMovie *movie, int streams, ...) list.size = 0; list.ids = FCC("movi"); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); - movie->movi_offset = ftell(movie->fp)-8L; + movie->movi_offset = ftell(movie->fp) - 8L; - fseek (movie->fp, AVI_HDRL_SOFF, SEEK_SET); + fseek(movie->fp, AVI_HDRL_SOFF, SEEK_SET); - PUT_FCCN((header_pos2-header_pos1+4L), movie->fp); + PUT_FCCN((header_pos2 - header_pos1 + 4L), movie->fp); return AVI_ERROR_NONE; } @@ -949,93 +962,92 @@ AviError AVI_write_frame(AviMovie *movie, int frame_num, ...) /* Allocate the new memory for the index entry */ - if (frame_num+1 > movie->index_entries) { - temp = (AviIndexEntry *) MEM_mallocN ((frame_num+1) * - (movie->header->Streams+1) * sizeof(AviIndexEntry), "newidxentry"); + if (frame_num + 1 > movie->index_entries) { + temp = (AviIndexEntry *) MEM_mallocN((frame_num + 1) * + (movie->header->Streams + 1) * sizeof(AviIndexEntry), "newidxentry"); if (movie->entries != NULL) { - memcpy (temp, movie->entries, movie->index_entries * (movie->header->Streams+1) - * sizeof(AviIndexEntry)); - MEM_freeN (movie->entries); + memcpy(temp, movie->entries, movie->index_entries * (movie->header->Streams + 1) * sizeof(AviIndexEntry)); + MEM_freeN(movie->entries); } movie->entries = temp; - movie->index_entries = frame_num+1; + movie->index_entries = frame_num + 1; } /* Slap a new record entry onto the end of the file */ - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); list.fcc = FCC("LIST"); list.size = 0; list.ids = FCC("rec "); - awrite (movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); + awrite(movie, &list, 1, sizeof(AviList), movie->fp, AVI_LIST); - rec_off = ftell (movie->fp)-8L; + rec_off = ftell(movie->fp) - 8L; /* Write a frame for every stream */ - va_start (ap, frame_num); + va_start(ap, frame_num); - for (stream=0; stream < movie->header->Streams; stream++) { - unsigned int tbuf=0; + for (stream = 0; stream < movie->header->Streams; stream++) { + unsigned int tbuf = 0; - format = va_arg (ap, AviFormat); - buffer = va_arg (ap, void*); - size = va_arg (ap, int); + format = va_arg(ap, AviFormat); + buffer = va_arg(ap, void *); + size = va_arg(ap, int); /* Convert the buffer into the output format */ - buffer = avi_format_convert (movie, stream, buffer, format, movie->streams[stream].format, &size); + buffer = avi_format_convert(movie, stream, buffer, format, movie->streams[stream].format, &size); /* Write the header info for this data chunk */ - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); - chunk.fcc = avi_get_data_id (format, stream); + chunk.fcc = avi_get_data_id(format, stream); chunk.size = size; - if (size%4) chunk.size += 4 - size%4; + if (size % 4) chunk.size += 4 - size % 4; - awrite (movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); + awrite(movie, &chunk, 1, sizeof(AviChunk), movie->fp, AVI_CHUNK); /* Write the index entry for this data chunk */ - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].ChunkId = chunk.fcc; - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Flags = AVIIF_KEYFRAME; - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Offset = (int)(ftell(movie->fp) - 12L - movie->movi_offset); - movie->entries[frame_num * (movie->header->Streams+1) + stream + 1].Size = chunk.size; + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].ChunkId = chunk.fcc; + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].Flags = AVIIF_KEYFRAME; + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].Offset = (int)(ftell(movie->fp) - 12L - movie->movi_offset); + movie->entries[frame_num * (movie->header->Streams + 1) + stream + 1].Size = chunk.size; /* Write the chunk */ - awrite (movie, buffer, 1, size, movie->fp, AVI_RAW); - MEM_freeN (buffer); + awrite(movie, buffer, 1, size, movie->fp, AVI_RAW); + MEM_freeN(buffer); - if (size%4) awrite (movie, &tbuf, 1, 4-size%4, movie->fp, AVI_RAW); + if (size % 4) awrite(movie, &tbuf, 1, 4 - size % 4, movie->fp, AVI_RAW); /* Update the stream headers length field */ movie->streams[stream].sh.Length++; - fseek (movie->fp, movie->offset_table[1+stream*2], SEEK_SET); - awrite (movie, &movie->streams[stream].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); + fseek(movie->fp, movie->offset_table[1 + stream * 2], SEEK_SET); + awrite(movie, &movie->streams[stream].sh, 1, sizeof(AviStreamHeader), movie->fp, AVI_STREAMH); } - va_end (ap); + va_end(ap); /* Record the entry for the new record */ - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); - movie->entries[frame_num * (movie->header->Streams+1)].ChunkId = FCC("rec "); - movie->entries[frame_num * (movie->header->Streams+1)].Flags = AVIIF_LIST; - movie->entries[frame_num * (movie->header->Streams+1)].Offset = (int)(rec_off - 8L - movie->movi_offset); - movie->entries[frame_num * (movie->header->Streams+1)].Size = (int)(ftell(movie->fp) - (rec_off + 4L)); + movie->entries[frame_num * (movie->header->Streams + 1)].ChunkId = FCC("rec "); + movie->entries[frame_num * (movie->header->Streams + 1)].Flags = AVIIF_LIST; + movie->entries[frame_num * (movie->header->Streams + 1)].Offset = (int)(rec_off - 8L - movie->movi_offset); + movie->entries[frame_num * (movie->header->Streams + 1)].Size = (int)(ftell(movie->fp) - (rec_off + 4L)); /* Update the record size */ - fseek (movie->fp, rec_off, SEEK_SET); - PUT_FCCN (movie->entries[frame_num * (movie->header->Streams+1)].Size, movie->fp); + fseek(movie->fp, rec_off, SEEK_SET); + PUT_FCCN(movie->entries[frame_num * (movie->header->Streams + 1)].Size, movie->fp); /* Update the main header information in the file */ movie->header->TotalFrames++; - fseek (movie->fp, movie->offset_table[0], SEEK_SET); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + fseek(movie->fp, movie->offset_table[0], SEEK_SET); + awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); return AVI_ERROR_NONE; } @@ -1044,38 +1056,38 @@ AviError AVI_close_compress(AviMovie *movie) { int temp, movi_size, i; - fseek (movie->fp, 0L, SEEK_END); + fseek(movie->fp, 0L, SEEK_END); movi_size = (int)ftell(movie->fp); - PUT_FCC ("idx1", movie->fp); - PUT_FCCN ((movie->index_entries*(movie->header->Streams+1)*16), movie->fp); + PUT_FCC("idx1", movie->fp); + PUT_FCCN((movie->index_entries * (movie->header->Streams + 1) * 16), movie->fp); - for (temp=0; temp < movie->index_entries*(movie->header->Streams+1); temp++) - awrite (movie, &movie->entries[temp], 1, sizeof(AviIndexEntry), movie->fp, AVI_INDEXE); + for (temp = 0; temp < movie->index_entries * (movie->header->Streams + 1); temp++) + awrite(movie, &movie->entries[temp], 1, sizeof(AviIndexEntry), movie->fp, AVI_INDEXE); temp = (int)ftell(movie->fp); - fseek (movie->fp, AVI_RIFF_SOFF, SEEK_SET); + fseek(movie->fp, AVI_RIFF_SOFF, SEEK_SET); - PUT_FCCN((temp-8L), movie->fp); + PUT_FCCN((temp - 8L), movie->fp); - fseek (movie->fp, movie->movi_offset, SEEK_SET); + fseek(movie->fp, movie->movi_offset, SEEK_SET); - PUT_FCCN((movi_size-(movie->movi_offset+4L)), movie->fp); + PUT_FCCN((movi_size - (movie->movi_offset + 4L)), movie->fp); - fclose (movie->fp); + fclose(movie->fp); - for (i=0; i < movie->header->Streams; i++) { + for (i = 0; i < movie->header->Streams; i++) { if (movie->streams[i].sf != NULL) - MEM_freeN (movie->streams[i].sf); + MEM_freeN(movie->streams[i].sf); } if (movie->header != NULL) - MEM_freeN (movie->header); + MEM_freeN(movie->header); if (movie->entries != NULL) - MEM_freeN (movie->entries); + MEM_freeN(movie->entries); if (movie->streams != NULL) - MEM_freeN (movie->streams); + MEM_freeN(movie->streams); if (movie->offset_table != NULL) - MEM_freeN (movie->offset_table); + MEM_freeN(movie->offset_table); return AVI_ERROR_NONE; } diff --git a/source/blender/avi/intern/avirgb.c b/source/blender/avi/intern/avirgb.c index 36e862708f4..78316990d54 100644 --- a/source/blender/avi/intern/avirgb.c +++ b/source/blender/avi/intern/avirgb.c @@ -42,108 +42,108 @@ /* implementation */ -void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int x, y, i, rowstride; unsigned char *buf; AviBitmapInfoHeader *bi; - short bits= 32; + short bits = 32; (void)size; /* unused */ - bi= (AviBitmapInfoHeader *) movie->streams[stream].sf; - if (bi) bits= bi->BitCount; + bi = (AviBitmapInfoHeader *) movie->streams[stream].sf; + if (bi) bits = bi->BitCount; - if (bits==16) { + if (bits == 16) { unsigned short *pxl; unsigned char *to; #ifdef __BIG_ENDIAN__ unsigned char *pxla; #endif - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); - y= movie->header->Height; - to= buf; + y = movie->header->Height; + to = buf; while (y--) { - pxl= (unsigned short *) (buffer + y * movie->header->Width * 2); + pxl = (unsigned short *) (buffer + y * movie->header->Width * 2); #ifdef __BIG_ENDIAN__ - pxla= (unsigned char *)pxl; + pxla = (unsigned char *)pxl; #endif - x= movie->header->Width; + x = movie->header->Width; while (x--) { #ifdef __BIG_ENDIAN__ - i= pxla[0]; - pxla[0]= pxla[1]; - pxla[1]= i; + i = pxla[0]; + pxla[0] = pxla[1]; + pxla[1] = i; - pxla+=2; + pxla += 2; #endif - *(to++)= ((*pxl>>10)&0x1f)*8; - *(to++)= ((*pxl>>5)&0x1f)*8; - *(to++)= (*pxl&0x1f)*8; + *(to++) = ((*pxl >> 10) & 0x1f) * 8; + *(to++) = ((*pxl >> 5) & 0x1f) * 8; + *(to++) = (*pxl & 0x1f) * 8; pxl++; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } else { - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); - rowstride = movie->header->Width*3; - if (bits!=16) if (movie->header->Width%2) rowstride++; + rowstride = movie->header->Width * 3; + if (bits != 16) if (movie->header->Width % 2) rowstride++; - for (y=0; y < movie->header->Height; y++) { - memcpy (&buf[y*movie->header->Width*3], &buffer[((movie->header->Height-1)-y)*rowstride], movie->header->Width*3); + for (y = 0; y < movie->header->Height; y++) { + memcpy(&buf[y * movie->header->Width * 3], &buffer[((movie->header->Height - 1) - y) * rowstride], movie->header->Width * 3); } - for (y=0; y < movie->header->Height*movie->header->Width*3; y+=3) { + for (y = 0; y < movie->header->Height * movie->header->Width * 3; y += 3) { i = buf[y]; - buf[y] = buf[y+2]; - buf[y+2] = i; + buf[y] = buf[y + 2]; + buf[y + 2] = i; } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } } -void *avi_converter_to_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int y, x, i, rowstride; unsigned char *buf; (void)stream; /* unused */ - *size= movie->header->Height * movie->header->Width * 3; - if (movie->header->Width%2) *size+= movie->header->Height; + *size = movie->header->Height * movie->header->Width * 3; + if (movie->header->Width % 2) *size += movie->header->Height; - buf = MEM_mallocN (*size, "toavirgbbuf"); + buf = MEM_mallocN(*size, "toavirgbbuf"); - rowstride = movie->header->Width*3; - if (movie->header->Width%2) rowstride++; + rowstride = movie->header->Width * 3; + if (movie->header->Width % 2) rowstride++; - for (y=0; y < movie->header->Height; y++) { - memcpy (&buf[y*rowstride], &buffer[((movie->header->Height-1)-y)*movie->header->Width*3], movie->header->Width*3); + for (y = 0; y < movie->header->Height; y++) { + memcpy(&buf[y * rowstride], &buffer[((movie->header->Height - 1) - y) * movie->header->Width * 3], movie->header->Width * 3); } - for (y=0; y < movie->header->Height; y++) { - for (x=0; x < movie->header->Width*3; x+=3) { - i = buf[y*rowstride+x]; - buf[y*rowstride+x] = buf[y*rowstride+x+2]; - buf[y*rowstride+x+2] = i; + for (y = 0; y < movie->header->Height; y++) { + for (x = 0; x < movie->header->Width * 3; x += 3) { + i = buf[y * rowstride + x]; + buf[y * rowstride + x] = buf[y * rowstride + x + 2]; + buf[y * rowstride + x + 2] = i; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } diff --git a/source/blender/avi/intern/codecs.c b/source/blender/avi/intern/codecs.c index c99938e7b9e..01e228d570e 100644 --- a/source/blender/avi/intern/codecs.c +++ b/source/blender/avi/intern/codecs.c @@ -39,7 +39,7 @@ #include "mjpeg.h" #include "rgb32.h" -void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) +void *avi_format_convert(AviMovie *movie, int stream, void *buffer, AviFormat from, AviFormat to, int *size) { if (from == to) return buffer; @@ -53,32 +53,32 @@ void *avi_format_convert (AviMovie *movie, int stream, void *buffer, AviFormat f } switch (to) { - case AVI_FORMAT_RGB24: - switch (from) { + case AVI_FORMAT_RGB24: + switch (from) { + case AVI_FORMAT_AVI_RGB: + buffer = avi_converter_from_avi_rgb(movie, stream, buffer, size); + break; + case AVI_FORMAT_MJPEG: + buffer = avi_converter_from_mjpeg(movie, stream, buffer, size); + break; + case AVI_FORMAT_RGB32: + buffer = avi_converter_from_rgb32(movie, stream, buffer, size); + break; + default: + break; + } + break; case AVI_FORMAT_AVI_RGB: - buffer = avi_converter_from_avi_rgb (movie, stream, buffer, size); + buffer = avi_converter_to_avi_rgb(movie, stream, buffer, size); break; case AVI_FORMAT_MJPEG: - buffer = avi_converter_from_mjpeg (movie, stream, buffer, size); + buffer = avi_converter_to_mjpeg(movie, stream, buffer, size); break; case AVI_FORMAT_RGB32: - buffer = avi_converter_from_rgb32 (movie, stream, buffer, size); + buffer = avi_converter_to_rgb32(movie, stream, buffer, size); break; default: break; - } - break; - case AVI_FORMAT_AVI_RGB: - buffer = avi_converter_to_avi_rgb (movie, stream, buffer, size); - break; - case AVI_FORMAT_MJPEG: - buffer = avi_converter_to_mjpeg (movie, stream, buffer, size); - break; - case AVI_FORMAT_RGB32: - buffer = avi_converter_to_rgb32 (movie, stream, buffer, size); - break; - default: - break; } return buffer; @@ -88,10 +88,10 @@ int avi_get_data_id(AviFormat format, int stream) { char fcc[5]; - if (avi_get_format_type (format) == FCC("vids")) - sprintf (fcc, "%2.2ddc", stream); - else if (avi_get_format_type (format) == FCC("auds")) - sprintf (fcc, "%2.2ddc", stream); + if (avi_get_format_type(format) == FCC("vids")) + sprintf(fcc, "%2.2ddc", stream); + else if (avi_get_format_type(format) == FCC("auds")) + sprintf(fcc, "%2.2ddc", stream); else return 0; @@ -101,48 +101,48 @@ int avi_get_data_id(AviFormat format, int stream) int avi_get_format_type(AviFormat format) { switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - case AVI_FORMAT_MJPEG: - return FCC("vids"); - break; - default: - return 0; - break; + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + case AVI_FORMAT_MJPEG: + return FCC("vids"); + break; + default: + return 0; + break; } } int avi_get_format_fcc(AviFormat format) { switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - return FCC("DIB "); - break; - case AVI_FORMAT_MJPEG: - return FCC("MJPG"); - break; - default: - return 0; - break; + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + return FCC("DIB "); + break; + case AVI_FORMAT_MJPEG: + return FCC("MJPG"); + break; + default: + return 0; + break; } } int avi_get_format_compression(AviFormat format) { switch (format) { - case AVI_FORMAT_RGB24: - case AVI_FORMAT_RGB32: - case AVI_FORMAT_AVI_RGB: - return 0; - break; - case AVI_FORMAT_MJPEG: - return FCC("MJPG"); - break; - default: - return 0; - break; + case AVI_FORMAT_RGB24: + case AVI_FORMAT_RGB32: + case AVI_FORMAT_AVI_RGB: + return 0; + break; + case AVI_FORMAT_MJPEG: + return FCC("MJPG"); + break; + default: + return 0; + break; } } diff --git a/source/blender/avi/intern/endian.c b/source/blender/avi/intern/endian.c index fd8cc56f551..c9b95d25810 100644 --- a/source/blender/avi/intern/endian.c +++ b/source/blender/avi/intern/endian.c @@ -46,125 +46,125 @@ #endif #ifdef __BIG_ENDIAN__ -static void invert (int *num) +static void invert(int *num) { - int new=0, i, j; + int new = 0, i, j; - for (j=0; j < 4; j++) { - for (i=0; i<8; i++) { - new |= ((*num>>(j*8+i))&1)<<((3-j)*8+i); + for (j = 0; j < 4; j++) { + for (i = 0; i < 8; i++) { + new |= ((*num >> (j * 8 + i)) & 1) << ((3 - j) * 8 + i); } } *num = new; } -static void sinvert (short int *num) +static void sinvert(short int *num) { - short int new=0; + short int new = 0; int i, j; - for (j=0; j < 2; j++) { - for (i=0; i<8; i++) { - new |= ((*num>>(j*8+i))&1)<<((1-j)*8+i); + for (j = 0; j < 2; j++) { + for (i = 0; i < 8; i++) { + new |= ((*num >> (j * 8 + i)) & 1) << ((1 - j) * 8 + i); } } *num = new; } -static void Ichunk (AviChunk *chunk) +static void Ichunk(AviChunk *chunk) { - invert (&chunk->fcc); - invert (&chunk->size); + invert(&chunk->fcc); + invert(&chunk->size); } #endif #ifdef __BIG_ENDIAN__ -static void Ilist (AviList *list) +static void Ilist(AviList *list) { - invert (&list->fcc); - invert (&list->size); - invert (&list->ids); + invert(&list->fcc); + invert(&list->size); + invert(&list->ids); } -static void Imainh (AviMainHeader *mainh) +static void Imainh(AviMainHeader *mainh) { - invert (&mainh->fcc); - invert (&mainh->size); - invert (&mainh->MicroSecPerFrame); - invert (&mainh->MaxBytesPerSec); - invert (&mainh->PaddingGranularity); - invert (&mainh->Flags); - invert (&mainh->TotalFrames); - invert (&mainh->InitialFrames); - invert (&mainh->Streams); - invert (&mainh->SuggestedBufferSize); - invert (&mainh->Width); - invert (&mainh->Height); - invert (&mainh->Reserved[0]); - invert (&mainh->Reserved[1]); - invert (&mainh->Reserved[2]); - invert (&mainh->Reserved[3]); + invert(&mainh->fcc); + invert(&mainh->size); + invert(&mainh->MicroSecPerFrame); + invert(&mainh->MaxBytesPerSec); + invert(&mainh->PaddingGranularity); + invert(&mainh->Flags); + invert(&mainh->TotalFrames); + invert(&mainh->InitialFrames); + invert(&mainh->Streams); + invert(&mainh->SuggestedBufferSize); + invert(&mainh->Width); + invert(&mainh->Height); + invert(&mainh->Reserved[0]); + invert(&mainh->Reserved[1]); + invert(&mainh->Reserved[2]); + invert(&mainh->Reserved[3]); } -static void Istreamh (AviStreamHeader *streamh) +static void Istreamh(AviStreamHeader *streamh) { - invert (&streamh->fcc); - invert (&streamh->size); - invert (&streamh->Type); - invert (&streamh->Handler); - invert (&streamh->Flags); - sinvert (&streamh->Priority); - sinvert (&streamh->Language); - invert (&streamh->InitialFrames); - invert (&streamh->Scale); - invert (&streamh->Rate); - invert (&streamh->Start); - invert (&streamh->Length); - invert (&streamh->SuggestedBufferSize); - invert (&streamh->Quality); - invert (&streamh->SampleSize); - sinvert (&streamh->left); - sinvert (&streamh->right); - sinvert (&streamh->top); - sinvert (&streamh->bottom); + invert(&streamh->fcc); + invert(&streamh->size); + invert(&streamh->Type); + invert(&streamh->Handler); + invert(&streamh->Flags); + sinvert(&streamh->Priority); + sinvert(&streamh->Language); + invert(&streamh->InitialFrames); + invert(&streamh->Scale); + invert(&streamh->Rate); + invert(&streamh->Start); + invert(&streamh->Length); + invert(&streamh->SuggestedBufferSize); + invert(&streamh->Quality); + invert(&streamh->SampleSize); + sinvert(&streamh->left); + sinvert(&streamh->right); + sinvert(&streamh->top); + sinvert(&streamh->bottom); } -static void Ibitmaph (AviBitmapInfoHeader *bitmaph) +static void Ibitmaph(AviBitmapInfoHeader *bitmaph) { - invert (&bitmaph->fcc); - invert (&bitmaph->size); - invert (&bitmaph->Size); - invert (&bitmaph->Width); - invert (&bitmaph->Height); - sinvert (&bitmaph->Planes); - sinvert (&bitmaph->BitCount); - invert (&bitmaph->Compression); - invert (&bitmaph->SizeImage); - invert (&bitmaph->XPelsPerMeter); - invert (&bitmaph->YPelsPerMeter); - invert (&bitmaph->ClrUsed); - invert (&bitmaph->ClrImportant); + invert(&bitmaph->fcc); + invert(&bitmaph->size); + invert(&bitmaph->Size); + invert(&bitmaph->Width); + invert(&bitmaph->Height); + sinvert(&bitmaph->Planes); + sinvert(&bitmaph->BitCount); + invert(&bitmaph->Compression); + invert(&bitmaph->SizeImage); + invert(&bitmaph->XPelsPerMeter); + invert(&bitmaph->YPelsPerMeter); + invert(&bitmaph->ClrUsed); + invert(&bitmaph->ClrImportant); } -static void Imjpegu (AviMJPEGUnknown *mjpgu) +static void Imjpegu(AviMJPEGUnknown *mjpgu) { - invert (&mjpgu->a); - invert (&mjpgu->b); - invert (&mjpgu->c); - invert (&mjpgu->d); - invert (&mjpgu->e); - invert (&mjpgu->f); - invert (&mjpgu->g); + invert(&mjpgu->a); + invert(&mjpgu->b); + invert(&mjpgu->c); + invert(&mjpgu->d); + invert(&mjpgu->e); + invert(&mjpgu->f); + invert(&mjpgu->g); } -static void Iindexe (AviIndexEntry *indexe) +static void Iindexe(AviIndexEntry *indexe) { - invert (&indexe->ChunkId); - invert (&indexe->Flags); - invert (&indexe->Offset); - invert (&indexe->Size); + invert(&indexe->ChunkId); + invert(&indexe->Flags); + invert(&indexe->Offset); + invert(&indexe->Size); } #endif /* __BIG_ENDIAN__ */ @@ -173,53 +173,53 @@ void awrite(AviMovie *movie, void *datain, int block, int size, FILE *fp, int ty #ifdef __BIG_ENDIAN__ void *data; - data = MEM_mallocN (size, "avi endian"); + data = MEM_mallocN(size, "avi endian"); - memcpy (data, datain, size); + memcpy(data, datain, size); switch (type) { - case AVI_RAW: - fwrite (data, block, size, fp); - break; - case AVI_CHUNK: - Ichunk ((AviChunk *) data); - fwrite (data, block, size, fp); - break; - case AVI_LIST: - Ilist ((AviList *) data); - fwrite (data, block, size, fp); - break; - case AVI_MAINH: - Imainh ((AviMainHeader *) data); - fwrite (data, block, size, fp); - break; - case AVI_STREAMH: - Istreamh ((AviStreamHeader *) data); - fwrite (data, block, size, fp); - break; - case AVI_BITMAPH: - Ibitmaph ((AviBitmapInfoHeader *) data); - if (size==sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown)) { - Imjpegu((AviMJPEGUnknown*)((char*)data+sizeof(AviBitmapInfoHeader))); - } - fwrite (data, block, size, fp); - break; - case AVI_MJPEGU: - Imjpegu ((AviMJPEGUnknown *) data); - fwrite (data, block, size, fp); - break; - case AVI_INDEXE: - Iindexe ((AviIndexEntry *) data); - fwrite (data, block, size, fp); - break; - default: - break; + case AVI_RAW: + fwrite(data, block, size, fp); + break; + case AVI_CHUNK: + Ichunk((AviChunk *) data); + fwrite(data, block, size, fp); + break; + case AVI_LIST: + Ilist((AviList *) data); + fwrite(data, block, size, fp); + break; + case AVI_MAINH: + Imainh((AviMainHeader *) data); + fwrite(data, block, size, fp); + break; + case AVI_STREAMH: + Istreamh((AviStreamHeader *) data); + fwrite(data, block, size, fp); + break; + case AVI_BITMAPH: + Ibitmaph((AviBitmapInfoHeader *) data); + if (size == sizeof(AviBitmapInfoHeader) + sizeof(AviMJPEGUnknown)) { + Imjpegu((AviMJPEGUnknown *)((char *)data + sizeof(AviBitmapInfoHeader))); + } + fwrite(data, block, size, fp); + break; + case AVI_MJPEGU: + Imjpegu((AviMJPEGUnknown *) data); + fwrite(data, block, size, fp); + break; + case AVI_INDEXE: + Iindexe((AviIndexEntry *) data); + fwrite(data, block, size, fp); + break; + default: + break; } - MEM_freeN (data); + MEM_freeN(data); #else /* __BIG_ENDIAN__ */ (void)movie; /* unused */ (void)type; /* unused */ - fwrite (datain, block, size, fp); + fwrite(datain, block, size, fp); #endif /* __BIG_ENDIAN__ */ } diff --git a/source/blender/avi/intern/mjpeg.c b/source/blender/avi/intern/mjpeg.c index 29356f8ef28..a700284bf68 100644 --- a/source/blender/avi/intern/mjpeg.c +++ b/source/blender/avi/intern/mjpeg.c @@ -42,14 +42,14 @@ #include "mjpeg.h" -#define PADUP(num, amt) ((num+(amt-1))&~(amt-1)) +#define PADUP(num, amt) ((num + (amt - 1)) & ~(amt - 1)) -static void jpegmemdestmgr_build (j_compress_ptr cinfo, unsigned char *buffer, int bufsize); -static void jpegmemsrcmgr_build (j_decompress_ptr dinfo, unsigned char *buffer, int bufsize); +static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize); +static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize); static int numbytes; -static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) +static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const UINT8 *val) { if (*htblptr == NULL) *htblptr = jpeg_alloc_huff_table((j_common_ptr) dinfo); @@ -64,25 +64,30 @@ static void add_huff_table (j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const U /* Set up the standard Huffman tables (cf. JPEG standard section K.3) */ /* IMPORTANT: these are only valid for 8-bit data precision! */ -static void std_huff_tables (j_decompress_ptr dinfo) +static void std_huff_tables(j_decompress_ptr dinfo) { static const UINT8 bits_dc_luminance[17] = { /* 0-base */ - 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 }; + 0, 0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 + }; static const UINT8 val_dc_luminance[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + }; static const UINT8 bits_dc_chrominance[17] = { /* 0-base */ - 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + 0, 0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 + }; static const UINT8 val_dc_chrominance[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 + }; static const UINT8 bits_ac_luminance[17] = { /* 0-base */ - 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d }; + 0, 0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 0x7d + }; static const UINT8 val_ac_luminance[] = { 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, @@ -105,10 +110,12 @@ static void std_huff_tables (j_decompress_ptr dinfo) 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; + 0xf9, 0xfa + }; static const UINT8 bits_ac_chrominance[17] = { /* 0-base */ - 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 }; + 0, 0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 0x77 + }; static const UINT8 val_ac_chrominance[] = { 0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, @@ -131,16 +138,17 @@ static void std_huff_tables (j_decompress_ptr dinfo) 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, - 0xf9, 0xfa }; + 0xf9, 0xfa + }; add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[0], - bits_dc_luminance, val_dc_luminance); + bits_dc_luminance, val_dc_luminance); add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[0], - bits_ac_luminance, val_ac_luminance); + bits_ac_luminance, val_ac_luminance); add_huff_table(dinfo, &dinfo->dc_huff_tbl_ptrs[1], - bits_dc_chrominance, val_dc_chrominance); + bits_dc_chrominance, val_dc_chrominance); add_huff_table(dinfo, &dinfo->ac_huff_tbl_ptrs[1], - bits_ac_chrominance, val_ac_chrominance); + bits_ac_chrominance, val_ac_chrominance); } static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, int bufsize) @@ -152,7 +160,7 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign (void)width; /* unused */ - numbytes= 0; + numbytes = 0; dinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&dinfo); @@ -166,8 +174,8 @@ static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsign jpeg_start_decompress(&dinfo); - rowstride= dinfo.output_width*dinfo.output_components; - for (y= 0; y= height) return 0; - inBuffer+= numbytes; - jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize-numbytes); + inBuffer += numbytes; + jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize - numbytes); - numbytes= 0; + numbytes = 0; jpeg_read_header(&dinfo, TRUE); if (dinfo.dc_huff_tbl_ptrs[0] == NULL) { std_huff_tables(&dinfo); } jpeg_start_decompress(&dinfo); - rowstride= dinfo.output_width*dinfo.output_components; - for (y= 0; ysent_table = TRUE; cinfo.dc_huff_tbl_ptrs[1]->sent_table = TRUE; @@ -232,24 +240,24 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char * jpeg_start_compress(&cinfo, FALSE); - i=0; + i = 0; marker[i++] = 'A'; marker[i++] = 'V'; marker[i++] = 'I'; marker[i++] = '1'; marker[i++] = 0; - while (i<60) + while (i < 60) marker[i++] = 32; - jpeg_write_marker (&cinfo, JPEG_APP0, marker, 60); + jpeg_write_marker(&cinfo, JPEG_APP0, marker, 60); - i=0; - while (i<60) + i = 0; + while (i < 60) marker[i++] = 0; - jpeg_write_marker (&cinfo, JPEG_COM, marker, 60); + jpeg_write_marker(&cinfo, JPEG_COM, marker, 60); - rowstride= cinfo.image_width*cinfo.input_components; + rowstride = cinfo.image_width * cinfo.input_components; for (y = 0; y < cinfo.image_height; y++) { jpeg_write_scanlines(&cinfo, (JSAMPARRAY) &inBuffer, 1); inBuffer += rowstride; @@ -260,43 +268,43 @@ static void Compress_JPEG(int quality, unsigned char *outbuffer, unsigned char * static void interlace(unsigned char *to, unsigned char *from, int width, int height) { - int i, rowstride= width*3; + int i, rowstride = width * 3; - for (i=0; iheader->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 1"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 1"); - deint= check_and_decode_jpeg(buffer, buf, movie->header->Width, movie->header->Height, *size); + deint = check_and_decode_jpeg(buffer, buf, movie->header->Width, movie->header->Height, *size); MEM_freeN(buffer); if (deint) { - buffer = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 2"); - interlace (buffer, buf, movie->header->Width, movie->header->Height); - MEM_freeN (buf); + buffer = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_from_mjpeg 2"); + interlace(buffer, buf, movie->header->Width, movie->header->Height); + MEM_freeN(buf); - buf= buffer; + buf = buffer; } return buf; } -void *avi_converter_to_mjpeg (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, int *size) { unsigned char *buf; - int bufsize= *size; + int bufsize = *size; numbytes = 0; - *size= 0; + *size = 0; - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 1"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 1"); if (!movie->interlace) { - check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf, buffer, movie->header->Width, movie->header->Height, bufsize); + check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf, buffer, movie->header->Width, movie->header->Height, bufsize); } else { - deinterlace (movie->odd_fields, buf, buffer, movie->header->Width, movie->header->Height); - MEM_freeN (buffer); + deinterlace(movie->odd_fields, buf, buffer, movie->header->Width, movie->header->Height); + MEM_freeN(buffer); - buffer= buf; - buf= MEM_mallocN (movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 2"); + buffer = buf; + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "avi.avi_converter_to_mjpeg 2"); - check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf, buffer, movie->header->Width, movie->header->Height/2, bufsize/2); - *size+= numbytes; - numbytes=0; - check_and_compress_jpeg(movie->streams[stream].sh.Quality/100, buf+*size, buffer+(movie->header->Height/2)*movie->header->Width*3, movie->header->Width, movie->header->Height/2, bufsize/2); + check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf, buffer, movie->header->Width, movie->header->Height / 2, bufsize / 2); + *size += numbytes; + numbytes = 0; + check_and_compress_jpeg(movie->streams[stream].sh.Quality / 100, buf + *size, buffer + (movie->header->Height / 2) * movie->header->Width * 3, movie->header->Width, movie->header->Height / 2, bufsize / 2); } *size += numbytes; - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } @@ -405,23 +413,23 @@ static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo) static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo) { - numbytes-= cinfo->dest->free_in_buffer; + numbytes -= cinfo->dest->free_in_buffer; MEM_freeN(cinfo->dest); } static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, int bufsize) { - cinfo->dest= MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build"); + cinfo->dest = MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build"); - cinfo->dest->init_destination= jpegmemdestmgr_init_destination; - cinfo->dest->empty_output_buffer= jpegmemdestmgr_empty_output_buffer; - cinfo->dest->term_destination= jpegmemdestmgr_term_destination; + cinfo->dest->init_destination = jpegmemdestmgr_init_destination; + cinfo->dest->empty_output_buffer = jpegmemdestmgr_empty_output_buffer; + cinfo->dest->term_destination = jpegmemdestmgr_term_destination; - cinfo->dest->next_output_byte= buffer; - cinfo->dest->free_in_buffer= bufsize; + cinfo->dest->next_output_byte = buffer; + cinfo->dest->free_in_buffer = bufsize; - numbytes= bufsize; + numbytes = bufsize; } /* Decompression from memory */ @@ -433,48 +441,48 @@ static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo) static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo) { - unsigned char *buf= (unsigned char*) dinfo->src->next_input_byte-2; + unsigned char *buf = (unsigned char *) dinfo->src->next_input_byte - 2; - /* if we get called, must have run out of data */ + /* if we get called, must have run out of data */ WARNMS(dinfo, JWRN_JPEG_EOF); - buf[0]= (JOCTET) 0xFF; - buf[1]= (JOCTET) JPEG_EOI; + buf[0] = (JOCTET) 0xFF; + buf[1] = (JOCTET) JPEG_EOI; - dinfo->src->next_input_byte= buf; - dinfo->src->bytes_in_buffer= 2; + dinfo->src->next_input_byte = buf; + dinfo->src->bytes_in_buffer = 2; return TRUE; } static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt) { - if (dinfo->src->bytes_in_buffersrc->bytes_in_buffer; + if (dinfo->src->bytes_in_buffer < skipcnt) + skipcnt = dinfo->src->bytes_in_buffer; - dinfo->src->next_input_byte+= skipcnt; - dinfo->src->bytes_in_buffer-= skipcnt; + dinfo->src->next_input_byte += skipcnt; + dinfo->src->bytes_in_buffer -= skipcnt; } static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo) { - numbytes-= dinfo->src->bytes_in_buffer; + numbytes -= dinfo->src->bytes_in_buffer; MEM_freeN(dinfo->src); } static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, unsigned char *buffer, int bufsize) { - dinfo->src= MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build"); + dinfo->src = MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build"); - dinfo->src->init_source= jpegmemsrcmgr_init_source; - dinfo->src->fill_input_buffer= jpegmemsrcmgr_fill_input_buffer; - dinfo->src->skip_input_data= jpegmemsrcmgr_skip_input_data; - dinfo->src->resync_to_restart= jpeg_resync_to_restart; - dinfo->src->term_source= jpegmemsrcmgr_term_source; + dinfo->src->init_source = jpegmemsrcmgr_init_source; + dinfo->src->fill_input_buffer = jpegmemsrcmgr_fill_input_buffer; + dinfo->src->skip_input_data = jpegmemsrcmgr_skip_input_data; + dinfo->src->resync_to_restart = jpeg_resync_to_restart; + dinfo->src->term_source = jpegmemsrcmgr_term_source; - dinfo->src->bytes_in_buffer= bufsize; - dinfo->src->next_input_byte= buffer; + dinfo->src->bytes_in_buffer = bufsize; + dinfo->src->next_input_byte = buffer; - numbytes= bufsize; + numbytes = bufsize; } diff --git a/source/blender/avi/intern/options.c b/source/blender/avi/intern/options.c index db9719c171d..7de91318ecf 100644 --- a/source/blender/avi/intern/options.c +++ b/source/blender/avi/intern/options.c @@ -54,78 +54,78 @@ AviError AVI_set_compress_option(AviMovie *movie, int option_type, int stream, A return AVI_ERROR_OPTION; switch (option_type) { - case AVI_OPTION_TYPE_MAIN: - switch (option) { - case AVI_OPTION_WIDTH: - movie->header->Width = *((int *) opt_data); - movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; + case AVI_OPTION_TYPE_MAIN: + switch (option) { + case AVI_OPTION_WIDTH: + movie->header->Width = *((int *) opt_data); + movie->header->SuggestedBufferSize = movie->header->Width * movie->header->Height * 3; + + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); + movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; + movie->streams[i].sh.right = *((int *) opt_data); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } + + break; + + case AVI_OPTION_HEIGHT: + movie->header->Height = *((int *) opt_data); + movie->header->SuggestedBufferSize = movie->header->Width * movie->header->Height * 3; + + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); + movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; + movie->streams[i].sh.bottom = *((int *) opt_data); + ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } + + break; + + case AVI_OPTION_QUALITY: + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + movie->streams[i].sh.Quality = (*((int *) opt_data)) * 100; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } + break; + + case AVI_OPTION_FRAMERATE: + useconds = (int)(1000000 / (*((double *) opt_data))); + if (useconds) + movie->header->MicroSecPerFrame = useconds; + + for (i = 0; i < movie->header->Streams; i++) { + if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { + movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; + fseek(movie->fp, movie->offset_table[1 + i * 2 + 1], SEEK_SET); + awrite(movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); + } + } - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Width = *((int *) opt_data); - movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; - movie->streams[i].sh.right = *((int *) opt_data); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } } + fseek(movie->fp, movie->offset_table[0], SEEK_SET); + awrite(movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); + break; - - case AVI_OPTION_HEIGHT: - movie->header->Height = *((int *) opt_data); - movie->header->SuggestedBufferSize = movie->header->Width*movie->header->Height*3; - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - ((AviBitmapInfoHeader *) movie->streams[i].sf)->Height = *((int *) opt_data); - movie->streams[i].sh.SuggestedBufferSize = movie->header->SuggestedBufferSize; - movie->streams[i].sh.bottom = *((int *) opt_data); - ((AviBitmapInfoHeader *) movie->streams[i].sf)->SizeImage = movie->header->SuggestedBufferSize; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } - } - + case AVI_OPTION_TYPE_STRH: break; - - case AVI_OPTION_QUALITY: - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - movie->streams[i].sh.Quality = (*((int *) opt_data))*100; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } - } + case AVI_OPTION_TYPE_STRF: + break; + default: + return AVI_ERROR_OPTION; break; - - case AVI_OPTION_FRAMERATE: - useconds = (int)(1000000/(*((double *) opt_data))); - if (useconds) - movie->header->MicroSecPerFrame = useconds; - - for (i=0; i < movie->header->Streams; i++) { - if (avi_get_format_type(movie->streams[i].format) == FCC("vids")) { - movie->streams[i].sh.Scale = movie->header->MicroSecPerFrame; - fseek (movie->fp, movie->offset_table[1+i*2+1], SEEK_SET); - awrite (movie, movie->streams[i].sf, 1, movie->streams[i].sf_size, movie->fp, AVI_BITMAPH); - } - } - - } - - fseek (movie->fp, movie->offset_table[0], SEEK_SET); - awrite (movie, movie->header, 1, sizeof(AviMainHeader), movie->fp, AVI_MAINH); - - break; - case AVI_OPTION_TYPE_STRH: - break; - case AVI_OPTION_TYPE_STRF: - break; - default: - return AVI_ERROR_OPTION; - break; } return AVI_ERROR_NONE; diff --git a/source/blender/avi/intern/rgb32.c b/source/blender/avi/intern/rgb32.c index 7b4958ca026..84630f09fe5 100644 --- a/source/blender/avi/intern/rgb32.c +++ b/source/blender/avi/intern/rgb32.c @@ -39,33 +39,33 @@ #include "MEM_guardedalloc.h" #include "rgb32.h" -void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int y, x, rowstridea, rowstrideb; unsigned char *buf; (void)stream; /* unused */ - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromrgb32buf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromrgb32buf"); *size = movie->header->Height * movie->header->Width * 3; - rowstridea = movie->header->Width*3; - rowstrideb = movie->header->Width*4; + rowstridea = movie->header->Width * 3; + rowstrideb = movie->header->Width * 4; - for (y=0; y < movie->header->Height; y++) { - for (x=0; x < movie->header->Width; x++) { - buf[y*rowstridea + x*3 + 0] = buffer[y*rowstrideb + x*4 + 3]; - buf[y*rowstridea + x*3 + 1] = buffer[y*rowstrideb + x*4 + 2]; - buf[y*rowstridea + x*3 + 2] = buffer[y*rowstrideb + x*4 + 1]; + for (y = 0; y < movie->header->Height; y++) { + for (x = 0; x < movie->header->Width; x++) { + buf[y * rowstridea + x * 3 + 0] = buffer[y * rowstrideb + x * 4 + 3]; + buf[y * rowstridea + x * 3 + 1] = buffer[y * rowstrideb + x * 4 + 2]; + buf[y * rowstridea + x * 3 + 2] = buffer[y * rowstrideb + x * 4 + 1]; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } -void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int i; unsigned char *buf; @@ -73,20 +73,20 @@ void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer (void)stream; /* unused */ - buf= MEM_mallocN (movie->header->Height * movie->header->Width * 4, "torgb32buf"); - *size= movie->header->Height * movie->header->Width * 4; + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 4, "torgb32buf"); + *size = movie->header->Height * movie->header->Width * 4; memset(buf, 255, *size); - to= buf; from= buffer; - i=movie->header->Height*movie->header->Width; + to = buf; from = buffer; + i = movie->header->Height * movie->header->Width; while (i--) { memcpy(to, from, 3); - to+=4; from+=3; + to += 4; from += 3; } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h index 911a94cb56a..18932ffdac8 100644 --- a/source/blender/blenfont/BLF_api.h +++ b/source/blender/blenfont/BLF_api.h @@ -174,12 +174,12 @@ char **BLF_dir_get(int *ndir); void BLF_dir_free(char **dirs, int count); /* font->flags. */ -#define BLF_ROTATION (1<<0) -#define BLF_CLIPPING (1<<1) -#define BLF_SHADOW (1<<2) -#define BLF_KERNING_DEFAULT (1<<3) -#define BLF_MATRIX (1<<4) -#define BLF_ASPECT (1<<5) +#define BLF_ROTATION (1 << 0) +#define BLF_CLIPPING (1 << 1) +#define BLF_SHADOW (1 << 2) +#define BLF_KERNING_DEFAULT (1 << 3) +#define BLF_MATRIX (1 << 4) +#define BLF_ASPECT (1 << 5) #define BLF_DRAW_STR_DUMMY_MAX 1024 diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c index 824f1715f3c..4fde9fe6787 100644 --- a/source/blender/blenfont/intern/blf_dir.c +++ b/source/blender/blenfont/intern/blf_dir.c @@ -163,10 +163,10 @@ int blf_dir_split(const char *str, char *file, int *size) file[i] = str[i]; file[i] = '.'; - file[i+1] = 't'; - file[i+2] = 't'; - file[i+3] = 'f'; - file[i+4] = '\0'; + file[i + 1] = 't'; + file[i + 2] = 't'; + file[i + 3] = 'f'; + file[i + 4] = '\0'; s++; *size = atoi(s); return 1; diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 7a4e1d4b781..1b4ce59067d 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -45,7 +45,7 @@ #include "BLI_blenlib.h" -#include "BLI_linklist.h" /* linknode */ +#include "BLI_linklist.h" /* linknode */ #include "BLI_math.h" #include "BIF_gl.h" @@ -103,7 +103,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font) if (glyph_ascii_table['0'] == NULL) { GlyphBLF *g; unsigned int i; - for (i = 0; i<256; i++) { + for (i = 0; i < 256; i++) { g = blf_glyph_search(font->glyph_cache, i); if (!g) { FT_UInt glyph_index = FT_Get_Char_Index(font->face, i); @@ -263,7 +263,7 @@ void blf_font_buffer(FontBLF *font, const char *str) /* don't draw beyond the buffer bounds */ int width_clip = g->width; int height_clip = g->height; - int yb_start = g->pitch < 0 ? 0 : g->height-1; + int yb_start = g->pitch < 0 ? 0 : g->height - 1; if (width_clip + chx > font->bw) width_clip -= chx + width_clip - font->bw; @@ -285,7 +285,7 @@ void blf_font_buffer(FontBLF *font, const char *str) if (a > 0.0f) { float alphatest; - fbuf = font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + fbuf = font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y) * font->bw)); if (a >= 1.0f) { fbuf[0] = font->b_col[0]; fbuf[1] = font->b_col[1]; @@ -293,10 +293,10 @@ void blf_font_buffer(FontBLF *font, const char *str) fbuf[3] = (alphatest = (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f; } else { - fbuf[0] = (font->b_col[0]*a) + (fbuf[0] * (1-a)); - fbuf[1] = (font->b_col[1]*a) + (fbuf[1] * (1-a)); - fbuf[2] = (font->b_col[2]*a) + (fbuf[2] * (1-a)); - fbuf[3] = (alphatest = (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f; + fbuf[0] = (font->b_col[0] * a) + (fbuf[0] * (1 - a)); + fbuf[1] = (font->b_col[1] * a) + (fbuf[1] * (1 - a)); + fbuf[2] = (font->b_col[2] * a) + (fbuf[2] * (1 - a)); + fbuf[3] = (alphatest = (fbuf[3] + (font->b_col[3] * a))) < 1.0f ? alphatest : 1.0f; } } } @@ -316,7 +316,7 @@ void blf_font_buffer(FontBLF *font, const char *str) if (a > 0.0f) { int alphatest; - cbuf = font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); + cbuf = font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y) * font->bw)); if (a >= 1.0f) { cbuf[0] = b_col_char[0]; cbuf[1] = b_col_char[1]; @@ -324,10 +324,10 @@ void blf_font_buffer(FontBLF *font, const char *str) cbuf[3] = (alphatest = ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255; } else { - cbuf[0] = (b_col_char[0]*a) + (cbuf[0] * (1-a)); - cbuf[1] = (b_col_char[1]*a) + (cbuf[1] * (1-a)); - cbuf[2] = (b_col_char[2]*a) + (cbuf[2] * (1-a)); - cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < + cbuf[0] = (b_col_char[0] * a) + (cbuf[0] * (1 - a)); + cbuf[1] = (b_col_char[1] * a) + (cbuf[1] * (1 - a)); + cbuf[2] = (b_col_char[2] * a) + (cbuf[2] * (1 - a)); + cbuf[3] = (alphatest = ((int)cbuf[3] + (int)((font->b_col[3] * a) * 255.0f))) < 255 ? alphatest : 255; } } diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index 9309cf15667..39945bf19b0 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -82,7 +82,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font) memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table)); memset(gc->bucket, 0, sizeof(gc->bucket)); - gc->textures = (GLuint *)malloc(sizeof(GLuint)*256); + gc->textures = (GLuint *)malloc(sizeof(GLuint) * 256); gc->ntex = 256; gc->cur_tex = -1; gc->x_offs = 0; @@ -147,8 +147,8 @@ void blf_glyph_cache_free(GlyphCacheBLF *gc) } } - if (gc->cur_tex+1 > 0) - glDeleteTextures(gc->cur_tex+1, gc->textures); + if (gc->cur_tex + 1 > 0) + glDeleteTextures(gc->cur_tex + 1, gc->textures); free((void *)gc->textures); MEM_freeN(gc); } @@ -163,7 +163,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) if (gc->cur_tex >= gc->ntex) { gc->ntex *= 2; - gc->textures = (GLuint *)realloc((void *)gc->textures, sizeof(GLuint)*gc->ntex); + gc->textures = (GLuint *)realloc((void *)gc->textures, sizeof(GLuint) * gc->ntex); } gc->p2_width = blf_next_p2((gc->rem_glyphs * gc->max_glyph_width) + (gc->pad * 2)); @@ -223,7 +223,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) if (sharp) err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO); else - err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ + err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ if (err) return NULL; @@ -314,11 +314,11 @@ static void blf_texture_draw(float uv[2][2], float dx, float y1, float dx1, floa static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[25] = {1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f, - 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, - 2/60.0f, 5/60.0f, 8/60.0f, 5/60.0f, 2/60.0f, - 1/60.0f, 3/60.0f, 5/60.0f, 3/60.0f, 1/60.0f, - 1/60.0f, 1/60.0f, 2/60.0f, 1/60.0f, 1/60.0f}; + float soft[25] = {1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f, + 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, + 2 / 60.0f, 5 / 60.0f, 8 / 60.0f, 5 / 60.0f, 2 / 60.0f, + 1 / 60.0f, 3 / 60.0f, 5 / 60.0f, 3 / 60.0f, 1 / 60.0f, + 1 / 60.0f, 1 / 60.0f, 2 / 60.0f, 1 / 60.0f, 1 / 60.0f}; float color[4], *fp = soft; int dx, dy; @@ -331,7 +331,7 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x for (dy = -2; dy < 3; dy++, fp++) { color[3] = *(fp) * shadow_col[3]; glColor4fv(color); - blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy); } } @@ -340,9 +340,9 @@ static void blf_texture5_draw(const float shadow_col[4], float uv[2][2], float x static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x1, float y1, float x2, float y2) { - float soft[9] = {1/16.0f, 2/16.0f, 1/16.0f, - 2/16.0f, 4/16.0f, 2/16.0f, - 1/16.0f, 2/16.0f, 1/16.0f}; + float soft[9] = {1 / 16.0f, 2 / 16.0f, 1 / 16.0f, + 2 / 16.0f, 4 / 16.0f, 2 / 16.0f, + 1 / 16.0f, 2 / 16.0f, 1 / 16.0f}; float color[4], *fp = soft; int dx, dy; @@ -355,7 +355,7 @@ static void blf_texture3_draw(const float shadow_col[4], float uv[2][2], float x for (dy = -1; dy < 2; dy++, fp++) { color[3] = *(fp) * shadow_col[3]; glColor4fv(color); - blf_texture_draw(uv, x1+dx, y1+dy, x2+dx, y2+dy); + blf_texture_draw(uv, x1 + dx, y1 + dy, x2 + dx, y2 + dy); } } diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index 96d3a231ba5..88d34b5e36f 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -42,7 +42,7 @@ #include -#if defined (_WIN32) +#if defined(_WIN32) #include #endif @@ -83,7 +83,7 @@ static const char *locales[] = { "catalan", "ca_AD", "czech", "cs_CZ", "ptb", "pt", -#if defined (_WIN32) && !defined(FREE_WINDOWS) +#if defined(_WIN32) && !defined(FREE_WINDOWS) "Chinese (Simplified)_China.1252", "zh_CN", "Chinese (Traditional)_China.1252", "zh_TW", #else @@ -170,19 +170,19 @@ void BLF_lang_set(const char *str) int ok = 1; const char *long_locale = locales[2 * U.language]; - if ((U.transopts&USER_DOTRANSLATE) == 0) + if ((U.transopts & USER_DOTRANSLATE) == 0) return; if (str) short_locale = str; else - short_locale = locales[ 2 * U.language + 1]; + short_locale = locales[2 * U.language + 1]; -#if defined (_WIN32) && !defined(FREE_WINDOWS) +#if defined(_WIN32) && !defined(FREE_WINDOWS) if (short_locale) { char *envStr; - if (U.language == 0)/* use system setting */ + if (U.language == 0) /* use system setting */ envStr = BLI_sprintfN("LANG=%s", getenv("LANG")); else envStr = BLI_sprintfN("LANG=%s", short_locale); @@ -201,8 +201,8 @@ void BLF_lang_set(const char *str) } #else { - static char default_lang[64] ="\0"; - static char default_language[64] ="\0"; + static char default_lang[64] = "\0"; + static char default_language[64] = "\0"; if (default_lang[0] == 0) get_language_variable("LANG", default_lang, sizeof(default_lang)); diff --git a/source/blender/blenfont/intern/blf_translation.c b/source/blender/blenfont/intern/blf_translation.c index 12fa15afa3c..9c863da9eba 100644 --- a/source/blender/blenfont/intern/blf_translation.c +++ b/source/blender/blenfont/intern/blf_translation.c @@ -39,7 +39,7 @@ /* needed for windows version of gettext */ #ifndef LC_MESSAGES -# define LC_MESSAGES 1729 +# define LC_MESSAGES 1729 #endif #endif @@ -57,7 +57,7 @@ #include "DNA_userdef_types.h" /* For user settings. */ #ifdef WITH_INTERNATIONAL -static const char unifont_filename[] ="droidsans.ttf.gz"; +static const char unifont_filename[] = "droidsans.ttf.gz"; static unsigned char *unifont_ttf = NULL; static int unifont_size = 0; @@ -70,7 +70,7 @@ unsigned char *BLF_get_unifont(int *unifont_size_r) BLI_snprintf(unifont_path, sizeof(unifont_path), "%s/%s", fontpath, unifont_filename); - unifont_ttf = (unsigned char*)BLI_file_ungzip_to_mem(unifont_path, &unifont_size); + unifont_ttf = (unsigned char *)BLI_file_ungzip_to_mem(unifont_path, &unifont_size); } else { printf("%s: 'fonts' data path not found for international font, continuing\n", __func__); @@ -90,7 +90,7 @@ void BLF_free_unifont(void) #endif -const char* BLF_gettext(const char *msgid) +const char *BLF_gettext(const char *msgid) { #ifdef WITH_INTERNATIONAL if (msgid && msgid[0]) @@ -124,7 +124,7 @@ const char *BLF_pgettext(const char *context, const char *message) sprintf(msg_ctxt_id, "%s%s%s", context, GETTEXT_CONTEXT_GLUE, message); - translation = (char*)dcgettext(TEXT_DOMAIN_NAME, msg_ctxt_id, LC_MESSAGES); + translation = (char *)dcgettext(TEXT_DOMAIN_NAME, msg_ctxt_id, LC_MESSAGES); if (dynamic_msg_ctxt_id) free(dynamic_msg_ctxt_id); diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h index a15192f156a..595a1e884d7 100644 --- a/source/blender/blenkernel/BKE_DerivedMesh.h +++ b/source/blender/blenkernel/BKE_DerivedMesh.h @@ -74,6 +74,8 @@ #include "BKE_customdata.h" #include "BKE_bvhutils.h" +struct CCGElem; +struct CCGKey; struct MVert; struct MEdge; struct MFace; @@ -102,11 +104,6 @@ struct PBVH; * Also, the mface origindex layer indexes mpolys, not mfaces. */ -typedef struct DMGridData { - float co[3]; - float no[3]; -} DMGridData; - typedef struct DMGridAdjacency { int index[4]; int rotation[4]; @@ -250,9 +247,10 @@ struct DerivedMesh { /* optional grid access for subsurf */ int (*getNumGrids)(DerivedMesh *dm); int (*getGridSize)(DerivedMesh *dm); - DMGridData **(*getGridData)(DerivedMesh *dm); + struct CCGElem **(*getGridData)(DerivedMesh *dm); DMGridAdjacency *(*getGridAdjacency)(DerivedMesh *dm); int *(*getGridOffset)(DerivedMesh *dm); + void (*getGridKey)(DerivedMesh *dm, struct CCGKey *key); DMFlagMat *(*getGridFlagMats)(DerivedMesh *dm); unsigned int **(*getGridHidden)(DerivedMesh *dm); diff --git a/source/blender/blenkernel/BKE_action.h b/source/blender/blenkernel/BKE_action.h index 564cd235869..a326b514f9a 100644 --- a/source/blender/blenkernel/BKE_action.h +++ b/source/blender/blenkernel/BKE_action.h @@ -59,13 +59,13 @@ extern "C" { struct bAction *add_empty_action(const char name[]); /* Allocate a copy of the given Action and all its data */ -struct bAction *copy_action(struct bAction *src); +struct bAction *BKE_action_copy(struct bAction *src); /* Deallocate all of the Action's data, but not the Action itself */ -void free_action(struct bAction *act); +void BKE_action_free(struct bAction *act); // XXX is this needed? -void make_local_action(struct bAction *act); +void BKE_action_make_local(struct bAction *act); /* Action API ----------------- */ @@ -122,7 +122,7 @@ void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, s void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu); /* Find a group with the given name */ -struct bActionGroup *action_groups_find_named(struct bAction *act, const char name[]); +struct bActionGroup *BKE_action_group_find_name(struct bAction *act, const char name[]); /* Clear all 'temp' flags on all groups */ void action_groups_clear_tempflags(struct bAction *act); @@ -133,71 +133,71 @@ void action_groups_clear_tempflags(struct bAction *act); * Deallocates a pose channel. * Does not free the pose channel itself. */ -void free_pose_channel(struct bPoseChannel *pchan); +void BKE_pose_channel_free(struct bPoseChannel *pchan); /** * Removes and deallocates all channels from a pose. * Does not free the pose itself. */ -void free_pose_channels(struct bPose *pose); +void BKE_pose_channels_free(struct bPose *pose); /** * Removes the hash for quick lookup of channels, must * be done when adding/removing channels. */ -void make_pose_channels_hash(struct bPose *pose); -void free_pose_channels_hash(struct bPose *pose); +void BKE_pose_channels_hash_make(struct bPose *pose); +void BKE_pose_channels_hash_free(struct bPose *pose); /** * Removes and deallocates all data from a pose, and also frees the pose. */ -void free_pose(struct bPose *pose); +void BKE_pose_free(struct bPose *pose); /** * Allocate a new pose on the heap, and copy the src pose and it's channels * into the new pose. *dst is set to the newly allocated structure, and assumed to be NULL. */ -void copy_pose(struct bPose **dst, struct bPose *src, int copyconstraints); +void BKE_pose_copy_data(struct bPose **dst, struct bPose *src, int copyconstraints); /** * Copy the internal members of each pose channel including constraints * and ID-Props, used when duplicating bones in editmode. */ -void duplicate_pose_channel_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from); +void BKE_pose_channel_copy_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from); /** * Return a pointer to the pose channel of the given name * from this pose. */ -struct bPoseChannel *get_pose_channel(const struct bPose *pose, const char *name); +struct bPoseChannel *BKE_pose_channel_find_name(const struct bPose *pose, const char *name); /** * Return a pointer to the active pose channel from this Object. * (Note: Object, not bPose is used here, as we need layer info from Armature) */ -struct bPoseChannel *get_active_posechannel(struct Object *ob); +struct bPoseChannel *BKE_pose_channel_active(struct Object *ob); /** * Looks to see if the channel with the given name * already exists in this pose - if not a new one is * allocated and initialized. */ -struct bPoseChannel *verify_pose_channel(struct bPose* pose, const char* name); +struct bPoseChannel *BKE_pose_channel_verify(struct bPose* pose, const char* name); /* Copy the data from the action-pose (src) into the pose */ void extract_pose_from_pose(struct bPose *pose, const struct bPose *src); /* sets constraint flags */ -void update_pose_constraint_flags(struct bPose *pose); +void BKE_pose_update_constraint_flags(struct bPose *pose); /* return the name of structure pointed by pose->ikparam */ -const char *get_ikparam_name(struct bPose *pose); +const char *BKE_pose_ikparam_get_name(struct bPose *pose); /* allocate and initialize pose->ikparam according to pose->iksolver */ -void init_pose_ikparam(struct bPose *pose); +void BKE_pose_ikparam_init(struct bPose *pose); /* initialize a bItasc structure with default value */ -void init_pose_itasc(struct bItasc *itasc); +void BKE_pose_itasc_init(struct bItasc *itasc); /* clears BONE_UNKEYED flags for frame changing */ // XXX to be depreceated for a more general solution in animsys... @@ -206,10 +206,10 @@ void framechange_poses_clear_unkeyed(void); /* Bone Groups API --------------------- */ /* Adds a new bone-group */ -void pose_add_group(struct Object *ob); +void BKE_pose_add_group(struct Object *ob); /* Remove the active bone-group */ -void pose_remove_group(struct Object *ob); +void BKE_pose_remove_group(struct Object *ob); /* Assorted Evaluation ----------------- */ @@ -217,9 +217,9 @@ void pose_remove_group(struct Object *ob); void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe); /* for proxy */ -void copy_pose_result(struct bPose *to, struct bPose *from); +void BKE_pose_copy_result(struct bPose *to, struct bPose *from); /* clear all transforms */ -void rest_pose(struct bPose *pose); +void BKE_pose_rest(struct bPose *pose); #ifdef __cplusplus }; diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h index dfe3fde17eb..b8c2c42f8d5 100644 --- a/source/blender/blenkernel/BKE_armature.h +++ b/source/blender/blenkernel/BKE_armature.h @@ -75,28 +75,28 @@ typedef struct PoseTree extern "C" { #endif -struct bArmature *add_armature(const char *name); -struct bArmature *get_armature(struct Object *ob); -void free_bonelist (struct ListBase *lb); -void free_armature(struct bArmature *arm); -void make_local_armature(struct bArmature *arm); -struct bArmature *copy_armature(struct bArmature *arm); +struct bArmature *BKE_armature_add(const char *name); +struct bArmature *BKE_armature_from_object(struct Object *ob); +void BKE_armature_bonelist_free (struct ListBase *lb); +void BKE_armature_free(struct bArmature *arm); +void BKE_armature_make_local(struct bArmature *arm); +struct bArmature *BKE_armature_copy(struct bArmature *arm); /* Bounding box. */ -struct BoundBox *BKE_armature_get_bb(struct Object *ob); +struct BoundBox *BKE_armature_boundbox_get(struct Object *ob); int bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail); -struct Bone *get_named_bone (struct bArmature *arm, const char *name); +struct Bone *BKE_armature_find_bone_name (struct bArmature *arm, const char *name); float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3], float r1, float r2, float rdist); -void where_is_armature (struct bArmature *arm); -void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone); -void armature_rebuild_pose(struct Object *ob, struct bArmature *arm); -void where_is_pose (struct Scene *scene, struct Object *ob); -void where_is_pose_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, int do_extra); -void where_is_pose_bone_tail(struct bPoseChannel *pchan); +void BKE_armature_where_is(struct bArmature *arm); +void BKE_armature_where_is_bone(struct Bone *bone, struct Bone *prevbone); +void BKE_pose_rebuild(struct Object *ob, struct bArmature *arm); +void BKE_pose_where_is(struct Scene *scene, struct Object *ob); +void BKE_pose_where_is_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, int do_extra); +void BKE_pose_where_is_bone_tail(struct bPoseChannel *pchan); /* get_objectspace_bone_matrix has to be removed still */ void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed); @@ -106,23 +106,23 @@ void mat3_to_vec_roll(float mat[][3], float *vec, float *roll); int get_selected_defgroups(struct Object *ob, char *defbase_sel, int defbase_len); /* Common Conversions Between Co-ordinate Spaces */ -void armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); -void armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); -void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); -void armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); +void BKE_armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]); +void BKE_armature_loc_world_to_pose(struct Object *ob, const float inloc[3], float outloc[3]); +void BKE_armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); +void BKE_armature_loc_pose_to_bone(struct bPoseChannel *pchan, const float inloc[3], float outloc[3]); +void BKE_armature_mat_bone_to_pose(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); +void BKE_armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]); -void armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); +void BKE_armature_mat_pose_to_bone_ex(struct Object *ob, struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]); -void pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[][3], short use_compat); -void pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4], short use_comat); -void pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]); -void pchan_calc_mat(struct bPoseChannel *pchan); +void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[][3], short use_compat); +void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4], short use_comat); +void BKE_pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]); +void BKE_pchan_calc_mat(struct bPoseChannel *pchan); /* Get the "pchan to pose" transform matrix. These matrices apply the effects of * HINGE/NO_SCALE/NO_LOCAL_LOCATION options over the pchan loc/rot/scale transformations. */ -void pchan_to_pose_mat(struct bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]); +void BKE_pchan_to_pose_mat(struct bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]); /* Rotation Mode Conversions - Used for PoseChannels + Objects... */ void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 62f1dbc5867..29e02562be3 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -42,7 +42,7 @@ extern "C" { * and keep comment above the defines. * Use STRINGIFY() rather than defining with quotes */ #define BLENDER_VERSION 263 -#define BLENDER_SUBVERSION 4 +#define BLENDER_SUBVERSION 5 #define BLENDER_MINVERSION 250 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_ccg.h b/source/blender/blenkernel/BKE_ccg.h new file mode 100644 index 00000000000..079994450d5 --- /dev/null +++ b/source/blender/blenkernel/BKE_ccg.h @@ -0,0 +1,168 @@ +/* + * ***** 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 by Nicholas Bishop. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BKE_CCG_H__ +#define __BKE_CCG_H__ + +/* defines BLI_INLINE */ +#include "BLI_utildefines.h" + +/* declares fprintf() and abort(), needed for BLI_assert */ +#include +#include + +struct CCGSubSurf; + +/* Each CCGElem is CCGSubSurf's representation of a subdivided + vertex. All CCGElems in a particular CCGSubSurf have the same + layout, but the layout can vary from one CCGSubSurf to another. For + this reason, CCGElem is presented as an opaque pointer, and + elements should always be accompanied by a CCGKey, which provides + the necessary offsets to access components of a CCGElem. +*/ +typedef struct CCGElem CCGElem; + +typedef struct CCGKey { + int level; + + /* number of bytes in each element (one float per layer, plus + three floats for normals if enabled) */ + int elem_size; + + /* number of elements along each side of grid */ + int grid_size; + /* number of elements in the grid (grid size squared) */ + int grid_area; + /* number of bytes in each grid (grid_area * elem_size) */ + int grid_bytes; + + /* currently always the last three floats, unless normals are + disabled */ + int normal_offset; + + /* offset in bytes of mask value; only valid if 'has_mask' is + true */ + int mask_offset; + + int num_layers; + int has_normals; + int has_mask; +} CCGKey; + +/* initialize 'key' at the specified level */ +void CCG_key(CCGKey *key, const struct CCGSubSurf *ss, int level); +void CCG_key_top_level(CCGKey *key, const struct CCGSubSurf *ss); + +/* get a pointer to the coordinate, normal, or mask components */ +BLI_INLINE float *CCG_elem_co(const CCGKey *key, CCGElem *elem); +BLI_INLINE float *CCG_elem_no(const CCGKey *key, CCGElem *elem); +BLI_INLINE float *CCG_elem_mask(const CCGKey *key, CCGElem *elem); + +/* get the element at 'offset' in an array */ +BLI_INLINE CCGElem *CCG_elem_offset(const CCGKey *key, CCGElem *elem, int offset); + +/* get the element at coordinate (x,y) in a face-grid array */ +BLI_INLINE CCGElem *CCG_grid_elem(const CCGKey *key, CCGElem *elem, int x, int y); + +/* combinations of above functions */ +BLI_INLINE float *CCG_grid_elem_co(const CCGKey *key, CCGElem *elem, int x, int y); +BLI_INLINE float *CCG_grid_elem_no(const CCGKey *key, CCGElem *elem, int x, int y); +BLI_INLINE float *CCG_grid_elem_mask(const CCGKey *key, CCGElem *elem, int x, int y); +BLI_INLINE float *CCG_elem_offset_co(const CCGKey *key, CCGElem *elem, int offset); +BLI_INLINE float *CCG_elem_offset_no(const CCGKey *key, CCGElem *elem, int offset); +BLI_INLINE float *CCG_elem_offset_mask(const CCGKey *key, CCGElem *elem, int offset); + +/* for iteration, get a pointer to the next element in an array */ +BLI_INLINE CCGElem *CCG_elem_next(const CCGKey *key, CCGElem *elem); + + +/* inline definitions follow */ + +BLI_INLINE float *CCG_elem_co(const CCGKey *UNUSED(key), CCGElem *elem) +{ + return (float*)elem; +} + +BLI_INLINE float *CCG_elem_no(const CCGKey *key, CCGElem *elem) +{ + BLI_assert(key->has_normals); + return (float*)((char*)elem + key->normal_offset); +} + +BLI_INLINE float *CCG_elem_mask(const CCGKey *key, CCGElem *elem) +{ + BLI_assert(key->has_mask); + return (float*)((char*)elem + (key->mask_offset)); +} + +BLI_INLINE CCGElem *CCG_elem_offset(const CCGKey *key, CCGElem *elem, int offset) +{ + return (CCGElem*)(((char*)elem) + key->elem_size * offset); +} + +BLI_INLINE CCGElem *CCG_grid_elem(const CCGKey *key, CCGElem *elem, int x, int y) +{ + BLI_assert(x < key->grid_size && y < key->grid_size); + return CCG_elem_offset(key, elem, (y * key->grid_size + x)); +} + +BLI_INLINE float *CCG_grid_elem_co(const CCGKey *key, CCGElem *elem, int x, int y) +{ + return CCG_elem_co(key, CCG_grid_elem(key, elem, x, y)); +} + +BLI_INLINE float *CCG_grid_elem_no(const CCGKey *key, CCGElem *elem, int x, int y) +{ + return CCG_elem_no(key, CCG_grid_elem(key, elem, x, y)); +} + +BLI_INLINE float *CCG_grid_elem_mask(const CCGKey *key, CCGElem *elem, int x, int y) +{ + return CCG_elem_mask(key, CCG_grid_elem(key, elem, x, y)); +} + +BLI_INLINE float *CCG_elem_offset_co(const CCGKey *key, CCGElem *elem, int offset) +{ + return CCG_elem_co(key, CCG_elem_offset(key, elem, offset)); +} + +BLI_INLINE float *CCG_elem_offset_no(const CCGKey *key, CCGElem *elem, int offset) +{ + return CCG_elem_no(key, CCG_elem_offset(key, elem, offset)); +} + +BLI_INLINE float *CCG_elem_offset_mask(const CCGKey *key, CCGElem *elem, int offset) +{ + return CCG_elem_mask(key, CCG_elem_offset(key, elem, offset)); +} + +BLI_INLINE CCGElem *CCG_elem_next(const CCGKey *key, CCGElem *elem) +{ + return CCG_elem_offset(key, elem, 1); +} + +#endif diff --git a/source/blender/blenkernel/BKE_constraint.h b/source/blender/blenkernel/BKE_constraint.h index f834ad5e774..35d07e7a7a7 100644 --- a/source/blender/blenkernel/BKE_constraint.h +++ b/source/blender/blenkernel/BKE_constraint.h @@ -62,7 +62,7 @@ typedef struct bConstraintOb { /* ---------------------------------------------------------------------------- */ /* Callback format for performing operations on ID-pointers for Constraints */ -typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, void *userdata); +typedef void (*ConstraintIDFunc)(struct bConstraint *con, struct ID **idpoin, short isReference, void *userdata); /* ....... */ @@ -87,8 +87,6 @@ typedef struct bConstraintTypeInfo { /* data management function pointers - special handling */ /* free any data that is allocated separately (optional) */ void (*free_data)(struct bConstraint *con); - /* adjust pointer to other ID-data using ID_NEW(), but not to targets (optional) */ - void (*relink_data)(struct bConstraint *con); /* run the provided callback function on all the ID-blocks linked to the constraint */ void (*id_looper)(struct bConstraint *con, ConstraintIDFunc func, void *userdata); /* copy any special data that is allocated separately (optional) */ diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 3b9328ae1aa..6267104022c 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -63,7 +63,7 @@ void BKE_curve_make_local(struct Curve *cu); short BKE_curve_type_get(struct Curve *cu); void BKE_curve_type_test(struct Object *ob); void BKE_curve_curve_dimension_update(struct Curve *cu); -void BKE_curve_tex_space_calc(struct Curve *cu); +void BKE_curve_texspace_calc(struct Curve *cu); int BKE_curve_minmax(struct Curve *cu, float min[3], float max[3]); int BKE_curve_center_median(struct Curve *cu, float cent[3]); diff --git a/source/blender/blenkernel/BKE_displist.h b/source/blender/blenkernel/BKE_displist.h index c5684e83903..cb8ddbf0b00 100644 --- a/source/blender/blenkernel/BKE_displist.h +++ b/source/blender/blenkernel/BKE_displist.h @@ -78,29 +78,28 @@ typedef struct DispList { unsigned int *bevelSplitFlag; } DispList; -extern void copy_displist(struct ListBase *lbn, struct ListBase *lb); -extern void free_disp_elem(DispList *dl); -extern DispList *find_displist_create(struct ListBase *lb, int type); -extern DispList *find_displist(struct ListBase *lb, int type); -extern void addnormalsDispList(struct ListBase *lb); -extern void count_displist(struct ListBase *lb, int *totvert, int *totface); -extern void freedisplist(struct ListBase *lb); -extern int displist_has_faces(struct ListBase *lb); +void BKE_displist_copy(struct ListBase *lbn, struct ListBase *lb); +void BKE_displist_elem_free(DispList *dl); +DispList *BKE_displist_find_or_create(struct ListBase *lb, int type); +DispList *BKE_displist_find(struct ListBase *lb, int type); +void BKE_displist_normals_add(struct ListBase *lb); +void BKE_displist_count(struct ListBase *lb, int *totvert, int *totface); +void BKE_displist_free(struct ListBase *lb); +int BKE_displist_has_faces(struct ListBase *lb); -extern void makeDispListSurf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); -extern void makeDispListCurveTypes(struct Scene *scene, struct Object *ob, int forOrco); -extern void makeDispListCurveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); -extern void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -extern void makeDispListMBall(struct Scene *scene, struct Object *ob); -extern void makeDispListMBall_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +void BKE_displist_make_surf(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forRender, int forOrco); +void BKE_displist_make_curveTypes(struct Scene *scene, struct Object *ob, int forOrco); +void BKE_displist_make_curveTypes_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase, struct DerivedMesh **derivedFinal, int forOrco); +void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +void BKE_displist_make_mball(struct Scene *scene, struct Object *ob); +void BKE_displist_make_mball_forRender(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); -void filldisplist(struct ListBase *dispbase, struct ListBase *to, int flipnormal); +int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4); +void BKE_displist_fill(struct ListBase *dispbase, struct ListBase *to, int flipnormal); -float calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); +float BKE_displist_calc_taper(struct Scene *scene, struct Object *taperobj, int cur, int tot); /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *makeOrcoDispList(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender); +float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender); #endif - diff --git a/source/blender/blenkernel/BKE_font.h b/source/blender/blenkernel/BKE_font.h index 16e98f25e0c..6636a70e94d 100644 --- a/source/blender/blenkernel/BKE_font.h +++ b/source/blender/blenkernel/BKE_font.h @@ -71,17 +71,17 @@ typedef struct EditFont { } EditFont; -void BKE_font_register_builtin(void *mem, int size); +void BKE_vfont_builtin_register(void *mem, int size); -void free_vfont(struct VFont *sc); -void free_ttfont(void); -struct VFont *get_builtin_font(void); -struct VFont *load_vfont(struct Main *bmain, const char *name); -struct TmpFont *vfont_find_tmpfont(struct VFont *vfont); +void BKE_vfont_free(struct VFont *sc); +void BKE_vfont_free_global_ttf(void); +struct VFont *BKE_vfont_builtin_get(void); +struct VFont *BKE_vfont_load(struct Main *bmain, const char *name); +struct TmpFont *BKE_vfont_find_tmpfont(struct VFont *vfont); -struct chartrans *BKE_text_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode); +struct chartrans *BKE_vfont_to_curve(struct Main *bmain, struct Scene *scene, struct Object *ob, int mode); -int BKE_font_getselection(struct Object *ob, int *start, int *end); +int BKE_vfont_select_get(struct Object *ob, int *start, int *end); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h index bb0216fe11c..134ec1acd8e 100644 --- a/source/blender/blenkernel/BKE_gpencil.h +++ b/source/blender/blenkernel/BKE_gpencil.h @@ -41,7 +41,7 @@ struct bGPDframe; void free_gpencil_strokes(struct bGPDframe *gpf); void free_gpencil_frames(struct bGPDlayer *gpl); void free_gpencil_layers(struct ListBase *list); -void free_gpencil_data(struct bGPdata *gpd); +void BKE_gpencil_free(struct bGPdata *gpd); struct bGPDframe *gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe); struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd); diff --git a/source/blender/blenkernel/BKE_group.h b/source/blender/blenkernel/BKE_group.h index 6629f0bdf7f..ccf9e0cef5b 100644 --- a/source/blender/blenkernel/BKE_group.h +++ b/source/blender/blenkernel/BKE_group.h @@ -40,10 +40,10 @@ struct Object; struct bAction; struct Scene; -void free_group_objects(struct Group *group); -void unlink_group(struct Group *group); +void BKE_group_free(struct Group *group); +void BKE_group_unlink(struct Group *group); struct Group *add_group(const char *name); -struct Group *copy_group(struct Group *group); +struct Group *BKE_group_copy(struct Group *group); int add_to_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base); int rem_from_group(struct Group *group, struct Object *ob, struct Scene *scene, struct Base *base); struct Group *find_group(struct Object *ob, struct Group *group); diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h index c2112d1e169..563f066bda6 100644 --- a/source/blender/blenkernel/BKE_image.h +++ b/source/blender/blenkernel/BKE_image.h @@ -46,14 +46,14 @@ struct Object; struct ImageFormatData; /* call from library */ -void free_image(struct Image *me); +void BKE_image_free(struct Image *me); -void BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); +void BKE_imbuf_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf); void BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels); -int BKE_alphatest_ibuf(struct ImBuf *ibuf); -int BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); -int BKE_write_ibuf(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); -int BKE_write_ibuf_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy); +int BKE_imbuf_alpha_test(struct ImBuf *ibuf); +int BKE_imbuf_write_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); +int BKE_imbuf_write(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf); +int BKE_imbuf_write_as(struct ImBuf *ibuf, const char *name, struct ImageFormatData *imf, const short is_copy); void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, const char imtype, const short use_ext, const short use_frames); int BKE_add_image_extension(char *string, const char imtype); char BKE_ftype_to_imtype(const int ftype); @@ -72,11 +72,11 @@ void BKE_imformat_defaults(struct ImageFormatData *im_format); struct anim *openanim(const char *name, int flags, int streamindex); -void image_de_interlace(struct Image *ima, int odd); +void BKE_image_de_interlace(struct Image *ima, int odd); -void make_local_image(struct Image *ima); +void BKE_image_make_local(struct Image *ima); -void tag_image_time(struct Image *ima); +void BKE_image_tag_time(struct Image *ima); void free_old_images(void); /* ********************************** NEW IMAGE API *********************** */ @@ -130,13 +130,15 @@ struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser); struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r); void BKE_image_release_ibuf(struct Image *ima, void *lock); +/* returns a new image or NULL if it can't load */ +struct Image *BKE_image_load(const char *filepath); /* returns existing Image when filename/type is same (frame optional) */ -struct Image *BKE_add_image_file(const char *name); +struct Image *BKE_image_load_exists(const char *filepath); /* adds image, adds ibuf, generates color or pattern */ -struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); +struct Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]); /* adds image from imbuf, owns imbuf */ -struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf); +struct Image *BKE_image_add_from_imbuf(struct ImBuf *ibuf); /* for reload, refresh, pack */ void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal); @@ -148,8 +150,8 @@ struct Image *BKE_image_verify_viewer(int type, const char *name); void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf); /* called on frame change or before render */ -void BKE_image_user_calc_frame(struct ImageUser *iuser, int cfra, int fieldnr); -int BKE_image_user_get_frame(const struct ImageUser *iuser, int cfra, int fieldnr); +void BKE_image_user_frame_calc(struct ImageUser *iuser, int cfra, int fieldnr); +int BKE_image_user_frame_get(const struct ImageUser *iuser, int cfra, int fieldnr); /* sets index offset for multilayer files */ struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser); @@ -176,7 +178,7 @@ void BKE_image_memorypack(struct Image *ima); void BKE_image_print_memlist(void); /* empty image block, of similar type and filename */ -struct Image *copy_image(struct Image *ima); +struct Image *BKE_image_copy(struct Image *ima); /* merge source into dest, and free source */ void BKE_image_merge(struct Image *dest, struct Image *source); diff --git a/source/blender/blenkernel/BKE_ipo.h b/source/blender/blenkernel/BKE_ipo.h index 547e7de7634..ca86e90f192 100644 --- a/source/blender/blenkernel/BKE_ipo.h +++ b/source/blender/blenkernel/BKE_ipo.h @@ -45,7 +45,7 @@ void do_versions_ipos_to_animato(struct Main *main); /* --------------------- xxx stuff ------------------------ */ -void free_ipo(struct Ipo *ipo); +void BKE_ipo_free(struct Ipo *ipo); #ifdef __cplusplus }; diff --git a/source/blender/blenkernel/BKE_key.h b/source/blender/blenkernel/BKE_key.h index 63d9d731097..757952515e5 100644 --- a/source/blender/blenkernel/BKE_key.h +++ b/source/blender/blenkernel/BKE_key.h @@ -47,12 +47,12 @@ struct Mesh; extern "C" { #endif -void free_key(struct Key *sc); +void BKE_key_free(struct Key *sc); void free_key_nolib(struct Key *key); struct Key *add_key(struct ID *id); -struct Key *copy_key(struct Key *key); +struct Key *BKE_key_copy(struct Key *key); struct Key *copy_key_nolib(struct Key *key); -void make_local_key(struct Key *key); +void BKE_key_make_local(struct Key *key); void sort_keys(struct Key *key); void key_curve_position_weights(float t, float *data, int type); diff --git a/source/blender/blenkernel/BKE_lamp.h b/source/blender/blenkernel/BKE_lamp.h index 50e25576320..f9137e50d74 100644 --- a/source/blender/blenkernel/BKE_lamp.h +++ b/source/blender/blenkernel/BKE_lamp.h @@ -38,11 +38,11 @@ extern "C" { struct Lamp; -void *add_lamp(const char *name); -struct Lamp *copy_lamp(struct Lamp *la); +void *BKE_lamp_add(const char *name); +struct Lamp *BKE_lamp_copy(struct Lamp *la); struct Lamp *localize_lamp(struct Lamp *la); -void make_local_lamp(struct Lamp *la); -void free_lamp(struct Lamp *la); +void BKE_lamp_make_local(struct Lamp *la); +void BKE_lamp_free(struct Lamp *la); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_lattice.h b/source/blender/blenkernel/BKE_lattice.h index a0075c4d6be..9a952fc6b1e 100644 --- a/source/blender/blenkernel/BKE_lattice.h +++ b/source/blender/blenkernel/BKE_lattice.h @@ -41,11 +41,11 @@ struct DerivedMesh; struct BPoint; struct MDeformVert; -void resizelattice(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); -struct Lattice *add_lattice(const char *name); -struct Lattice *copy_lattice(struct Lattice *lt); -void free_lattice(struct Lattice *lt); -void make_local_lattice(struct Lattice *lt); +void BKE_lattice_resize(struct Lattice *lt, int u, int v, int w, struct Object *ltOb); +struct Lattice *BKE_lattice_add(const char *name); +struct Lattice *BKE_lattice_copy(struct Lattice *lt); +void BKE_lattice_free(struct Lattice *lt); +void BKE_lattice_make_local(struct Lattice *lt); void calc_lat_fudu(int flag, int res, float *fu, float *du); void init_latt_deform(struct Object *oblatt, struct Object *ob); @@ -69,11 +69,11 @@ void armature_deform_verts(struct Object *armOb, struct Object *target, float (*defMats)[3][3], int numVerts, int deformflag, float (*prevCos)[3], const char *defgrp_name); -float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]; -void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]); -void lattice_calc_modifiers(struct Scene *scene, struct Object *ob); +float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3]; +void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]); +void BKE_lattice_modifiers_calc(struct Scene *scene, struct Object *ob); -struct MDeformVert* lattice_get_deform_verts(struct Object *lattice); +struct MDeformVert* BKE_lattice_deform_verts_get(struct Object *lattice); #endif diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index be21996428a..2804eb407db 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -45,15 +45,16 @@ struct bContext; struct PointerRNA; struct PropertyRNA; -void *alloc_libblock(struct ListBase *lb, short type, const char *name); -void *copy_libblock(struct ID *id); -void copy_libblock_data(struct ID *id, const struct ID *id_from, const short do_action); +void *BKE_libblock_alloc(struct ListBase *lb, short type, const char *name); +void *BKE_libblock_copy(struct ID *id); +void BKE_libblock_copy_data(struct ID *id, const struct ID *id_from, const short do_action); void BKE_id_lib_local_paths(struct Main *bmain, struct Library *lib, struct ID *id); void id_lib_extern(struct ID *id); void BKE_library_filepath_set(struct Library *lib, const char *filepath); void id_us_plus(struct ID *id); void id_us_min(struct ID *id); + int id_make_local(struct ID *id, int test); int id_single_user(struct bContext *C, struct ID *id, struct PointerRNA *ptr, struct PropertyRNA *prop); int id_copy(struct ID *id, struct ID **newid, int test); @@ -68,8 +69,8 @@ struct ListBase *which_libbase(struct Main *mainlib, short type); #define MAX_LIBARRAY 40 int set_listbasepointers(struct Main *main, struct ListBase **lb); -void free_libblock(struct ListBase *lb, void *idv); -void free_libblock_us(struct ListBase *lb, void *idv); +void BKE_libblock_free(struct ListBase *lb, void *idv); +void BKE_libblock_free_us(struct ListBase *lb, void *idv); void free_main(struct Main *mainvar); void tag_main_idcode(struct Main *mainvar, const short type, const short tag); @@ -81,7 +82,7 @@ void name_uiprefix_id(char *name, struct ID *id); void test_idbutton(char *name); void text_idbutton(struct ID *id, char *text); void BKE_library_make_local(struct Main *bmain, struct Library *lib, int untagged_only); -struct ID *find_id(const char *type, const char *name); +struct ID *BKE_libblock_find_name(const short type, const char *name); void clear_id_newpoins(void); void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, diff --git a/source/blender/blenkernel/BKE_material.h b/source/blender/blenkernel/BKE_material.h index 99561a687b9..801724d1d4f 100644 --- a/source/blender/blenkernel/BKE_material.h +++ b/source/blender/blenkernel/BKE_material.h @@ -46,15 +46,15 @@ struct MTFace; /* materials */ void init_def_material(void); -void free_material(struct Material *sc); +void BKE_material_free(struct Material *sc); void test_object_materials(struct ID *id); void resize_object_material(struct Object *ob, const short totcol); void init_material(struct Material *ma); -struct Material *add_material(const char *name); -struct Material *copy_material(struct Material *ma); +struct Material *BKE_material_add(const char *name); +struct Material *BKE_material_copy(struct Material *ma); struct Material *localize_material(struct Material *ma); struct Material *give_node_material(struct Material *ma); /* returns node material or self */ -void make_local_material(struct Material *ma); +void BKE_material_make_local(struct Material *ma); void extern_local_matarar(struct Material **matar, short totcol); void automatname(struct Material *); diff --git a/source/blender/blenkernel/BKE_mball.h b/source/blender/blenkernel/BKE_mball.h index 018ee7f6c94..356f2c8901c 100644 --- a/source/blender/blenkernel/BKE_mball.h +++ b/source/blender/blenkernel/BKE_mball.h @@ -37,30 +37,30 @@ struct Object; struct Scene; struct MetaElem; -void BKE_metaball_unlink(struct MetaBall *mb); -void BKE_metaball_free(struct MetaBall *mb); -struct MetaBall *BKE_metaball_add(const char *name); -struct MetaBall *BKE_metaball_copy(struct MetaBall *mb); +void BKE_mball_unlink(struct MetaBall *mb); +void BKE_mball_free(struct MetaBall *mb); +struct MetaBall *BKE_mball_add(const char *name); +struct MetaBall *BKE_mball_copy(struct MetaBall *mb); -void BKE_metaball_make_local(struct MetaBall *mb); +void BKE_mball_make_local(struct MetaBall *mb); -void BKE_metaball_cubeTable_free(void); +void BKE_mball_cubeTable_free(void); -void BKE_metaball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); -int BKE_metaball_is_basis_for(struct Object *ob1, struct Object *ob2); -int BKE_metaball_is_basis(struct Object *ob); -struct Object *BKE_metaball_basis_find(struct Scene *scene, struct Object *ob); +void BKE_mball_polygonize(struct Scene *scene, struct Object *ob, struct ListBase *dispbase); +int BKE_mball_is_basis_for(struct Object *ob1, struct Object *ob2); +int BKE_mball_is_basis(struct Object *ob); +struct Object *BKE_mball_basis_find(struct Scene *scene, struct Object *ob); -void BKE_metaball_tex_space_calc(struct Object *ob); -float *BKE_metaball_make_orco(struct Object *ob, struct ListBase *dispbase); +void BKE_mball_texspace_calc(struct Object *ob); +float *BKE_mball_make_orco(struct Object *ob, struct ListBase *dispbase); -void BKE_metaball_properties_copy(struct Scene *scene, struct Object *active_object); +void BKE_mball_properties_copy(struct Scene *scene, struct Object *active_object); -int BKE_metaball_minmax(struct MetaBall *mb, float min[3], float max[3]); -int BKE_metaball_center_median(struct MetaBall *mb, float cent[3]); -int BKE_metaball_center_bounds(struct MetaBall *mb, float cent[3]); -void BKE_metaball_translate(struct MetaBall *mb, float offset[3]); +int BKE_mball_minmax(struct MetaBall *mb, float min[3], float max[3]); +int BKE_mball_center_median(struct MetaBall *mb, float cent[3]); +int BKE_mball_center_bounds(struct MetaBall *mb, float cent[3]); +void BKE_mball_translate(struct MetaBall *mb, float offset[3]); -struct MetaElem *BKE_metaball_element_add(struct MetaBall *mb, const int type); +struct MetaElem *BKE_mball_element_add(struct MetaBall *mb, const int type); #endif diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index 14cb5d19ddf..bdadce2c7c7 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -76,109 +76,109 @@ struct BMesh *BKE_mesh_to_bmesh(struct Mesh *me, struct Object *ob); * if both of the above are 0, it'll use the indices of the mpolys of the MPoly * data in pdata, and ignore the origindex layer altogether. */ -int mesh_recalcTessellation(struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, - struct MVert *mvert, - int totface, int totloop, int totpoly, - const int do_face_normals); +int BKE_mesh_recalc_tessellation(struct CustomData *fdata, struct CustomData *ldata, struct CustomData *pdata, + struct MVert *mvert, + int totface, int totloop, int totpoly, + const int do_face_normals); /* for forwards compat only quad->tri polys to mface, skip ngons. */ -int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int totface, int totloop, int totpoly); +int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, + struct CustomData *pdata, int totface, int totloop, int totpoly); /*calculates a face normal.*/ void mesh_calc_poly_normal(struct MPoly *mpoly, struct MLoop *loopstart, struct MVert *mvarray, float no[3]); -void mesh_calc_poly_normal_coords(struct MPoly *mpoly, struct MLoop *loopstart, - const float (*vertex_coords)[3], float no[3]); +void BKE_mesh_calc_poly_normal_coords(struct MPoly *mpoly, struct MLoop *loopstart, + const float (*vertex_coords)[3], float no[3]); -void mesh_calc_poly_center(struct MPoly *mpoly, struct MLoop *loopstart, - struct MVert *mvarray, float cent[3]); +void BKE_mesh_calc_poly_center(struct MPoly *mpoly, struct MLoop *loopstart, + struct MVert *mvarray, float cent[3]); -float mesh_calc_poly_area(struct MPoly *mpoly, struct MLoop *loopstart, - struct MVert *mvarray, float polynormal[3]); +float BKE_mesh_calc_poly_area(struct MPoly *mpoly, struct MLoop *loopstart, + struct MVert *mvarray, float polynormal[3]); /* Find the index of the loop in 'poly' which references vertex, * returns -1 if not found */ int poly_find_loop_from_vert(const struct MPoly *poly, - const struct MLoop *loopstart, - unsigned vert); + const struct MLoop *loopstart, + unsigned vert); /* Fill 'adj_r' with the loop indices in 'poly' adjacent to the * vertex. Returns the index of the loop matching vertex, or -1 if the * vertex is not in 'poly' */ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const struct MPoly *poly, - const struct MLoop *mloop, unsigned vert); + const struct MLoop *mloop, unsigned vert); /* update the hide flag for edges and polys from the corresponding * flag in verts */ -void mesh_flush_hidden_from_verts(const struct MVert *mvert, - const struct MLoop *mloop, - struct MEdge *medge, int totedge, - struct MPoly *mpoly, int totpoly); +void BKE_mesh_flush_hidden_from_verts(const struct MVert *mvert, + const struct MLoop *mloop, + struct MEdge *medge, int totedge, + struct MPoly *mpoly, int totpoly); -void unlink_mesh(struct Mesh *me); -void free_mesh(struct Mesh *me, int unlink); -struct Mesh *add_mesh(const char *name); -struct Mesh *copy_mesh(struct Mesh *me); +void BKE_mesh_unlink(struct Mesh *me); +void BKE_mesh_free(struct Mesh *me, int unlink); +struct Mesh *BKE_mesh_add(const char *name); +struct Mesh *BKE_mesh_copy(struct Mesh *me); void mesh_update_customdata_pointers(struct Mesh *me, const short do_ensure_tess_cd); -void make_local_mesh(struct Mesh *me); -void boundbox_mesh(struct Mesh *me, float *loc, float *size); -void tex_space_mesh(struct Mesh *me); -float *get_mesh_orco_verts(struct Object *ob); -void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, int invert); +void BKE_mesh_make_local(struct Mesh *me); +void BKE_mesh_boundbox_calc(struct Mesh *me, float *loc, float *size); +void BKE_mesh_texspace_calc(struct Mesh *me); +float *BKE_mesh_orco_verts_get(struct Object *ob); +void BKE_mesh_orco_verts_transform(struct Mesh *me, float (*orco)[3], int totvert, int invert); int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr); -struct Mesh *get_mesh(struct Object *ob); +struct Mesh *BKE_mesh_from_object(struct Object *ob); void set_mesh(struct Object *ob, struct Mesh *me); -void mball_to_mesh(struct ListBase *lb, struct Mesh *me); -int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *totvert, - struct MEdge **alledge, int *totedge, struct MLoop **allloop, struct MPoly **allpoly, - int *totloop, int *totpoly); -int nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert, - struct MEdge **alledge, int *_totedge, struct MLoop **allloop, struct MPoly **allpoly, - int *_totloop, int *_totpoly); -void nurbs_to_mesh(struct Object *ob); -void mesh_to_curve(struct Scene *scene, struct Object *ob); +void BKE_mesh_from_metaball(struct ListBase *lb, struct Mesh *me); +int BKE_mesh_nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *totvert, + struct MEdge **alledge, int *totedge, struct MLoop **allloop, struct MPoly **allpoly, + int *totloop, int *totpoly); +int BKE_mesh_nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert, + struct MEdge **alledge, int *_totedge, struct MLoop **allloop, struct MPoly **allpoly, + int *_totloop, int *_totpoly); +void BKE_mesh_from_nurbs(struct Object *ob); +void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob); void free_dverts(struct MDeformVert *dvert, int totvert); void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */ -void mesh_delete_material_index(struct Mesh *me, short index); -void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth); +void BKE_mesh_delete_material_index(struct Mesh *me, short index); +void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); void BKE_mesh_convert_mfaces_to_mpolys(struct Mesh *mesh); -void mesh_calc_normals_tessface(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); +void BKE_mesh_calc_normals_tessface(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]); /* used for unit testing; compares two meshes, checking only * differences we care about. should be usable with leaf's * testing framework I get RNA work done, will use hackish * testing code for now.*/ -const char *mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh); +const char *BKE_mesh_cmp(struct Mesh *me1, struct Mesh *me2, float thresh); -struct BoundBox *mesh_get_bb(struct Object *ob); -void mesh_get_texspace(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]); +struct BoundBox *BKE_mesh_boundbox_get(struct Object *ob); +void BKE_mesh_texspace_get(struct Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]); /* if old, it converts mface->edcode to edge drawflags */ -void make_edges(struct Mesh *me, int old); +void BKE_mesh_make_edges(struct Mesh *me, int old); -void mesh_strip_loose_faces(struct Mesh *me); /* Needed for compatibility (some old read code). */ -void mesh_strip_loose_polysloops(struct Mesh *me); -void mesh_strip_loose_edges(struct Mesh *me); +void BKE_mesh_strip_loose_faces(struct Mesh *me); /* Needed for compatibility (some old read code). */ +void BKE_mesh_strip_loose_polysloops(struct Mesh *me); +void BKE_mesh_strip_loose_edges(struct Mesh *me); /* Calculate vertex and face normals, face normals are returned in *faceNors_r if non-NULL * and vertex normals are stored in actual mverts. */ -void mesh_calc_normals_mapping( +void BKE_mesh_calc_normals_mapping( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]); - /* extended version of 'mesh_calc_normals' with option not to calc vertex normals */ -void mesh_calc_normals_mapping_ex( + /* extended version of 'BKE_mesh_calc_normals' with option not to calc vertex normals */ +void BKE_mesh_calc_normals_mapping_ex( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], struct MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], const short only_face_normals); -void mesh_calc_normals( +void BKE_mesh_calc_normals( struct MVert *mverts, int numVerts, struct MLoop *mloop, struct MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3]); @@ -246,9 +246,10 @@ typedef struct UvElementMap { * to make that many islands, he can bite me :p */ #define INVALID_ISLAND 0xFFFF -UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, float *limit); -UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v); -void free_uv_vert_map(UvVertMap *vmap); +UvVertMap *BKE_mesh_uv_vert_map_make(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, + unsigned int totpoly, unsigned int totvert, int selected, float *limit); +UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v); +void BKE_mesh_uv_vert_map_free(UvVertMap *vmap); /* Connectivity data */ typedef struct MeshElemMap { @@ -270,10 +271,10 @@ void create_vert_edge_map(struct ListBase **map, IndexNode **mem, const struct M /* vertex level transformations & checks (no derived mesh) */ -int minmax_mesh(struct Mesh *me, float min[3], float max[3]); -int mesh_center_median(struct Mesh *me, float cent[3]); -int mesh_center_bounds(struct Mesh *me, float cent[3]); -void mesh_translate(struct Mesh *me, float offset[3], int do_keys); +int BKE_mesh_minmax(struct Mesh *me, float r_min[3], float r_max[3]); +int BKE_mesh_center_median(struct Mesh *me, float cent[3]); +int BKE_mesh_center_bounds(struct Mesh *me, float cent[3]); +void BKE_mesh_translate(struct Mesh *me, float offset[3], int do_keys); /* mesh_validate.c */ /* XXX Loop v/e are unsigned, so using max uint_32 value as invalid marker... */ @@ -298,10 +299,13 @@ void BKE_mesh_tessface_ensure(struct Mesh *mesh); void BKE_mesh_tessface_clear(struct Mesh *mesh); /* Convert a triangle or quadrangle of loop/poly data to tessface data */ -void mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int lindex[4], int findex, - const int polyindex, const int mf_len, - const int numTex, const int numCol, const int hasPCol, const int hasOrigSpace); +void BKE_mesh_loops_to_mface_corners(struct CustomData *fdata, struct CustomData *ldata, + struct CustomData *pdata, int lindex[4], int findex, + const int polyindex, const int mf_len, + const int numTex, const int numCol, const int hasPCol, const int hasOrigSpace); + +void BKE_mesh_poly_calc_angles(struct MVert *mvert, struct MLoop *mloop, + struct MPoly *mp, float angles[]); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index b4320b7025a..db57d411f31 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -109,6 +109,12 @@ typedef void (*ObjectWalkFunc)(void *userData, struct Object *ob, struct Object typedef void (*IDWalkFunc)(void *userData, struct Object *ob, struct ID **idpoin); typedef void (*TexWalkFunc)(void *userData, struct Object *ob, struct ModifierData *md, const char *propname); +typedef enum ModifierApplyFlag { + MOD_APPLY_RENDER = 1 << 0, /* Render time. */ + MOD_APPLY_USECACHE = 1 << 1, /* Last modifier in stack. */ +} ModifierApplyFlag; + + typedef struct ModifierTypeInfo { /* The user visible name for this modifier */ char name[32]; @@ -142,7 +148,7 @@ typedef struct ModifierTypeInfo { void (*deformVerts)(struct ModifierData *md, struct Object *ob, struct DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, - int useRenderParams, int isFinalCalc); + ModifierApplyFlag flag); /* Like deformMatricesEM but called from object mode (for supporting modifiers in sculpt mode) */ void (*deformMatrices)( @@ -187,7 +193,7 @@ typedef struct ModifierTypeInfo { struct DerivedMesh *(*applyModifier)( struct ModifierData *md, struct Object *ob, struct DerivedMesh *derivedData, - int useRenderParams, int isFinalCalc); + ModifierApplyFlag flag); /* Like applyModifier but called during editmode (for supporting * modifiers). diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index bc34b0131bf..1ff53291044 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -44,7 +44,7 @@ struct MultiresModifierData; struct Object; struct Scene; -/* Delete mesh mdisps */ +/* Delete mesh mdisps and grid paint masks */ void multires_customdata_delete(struct Mesh *me); void multires_mark_as_modified(struct Object *ob, enum MultiresModifiedFlags flags); @@ -59,24 +59,32 @@ void multires_modifier_update_hidden(struct DerivedMesh *dm); void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, struct Object *ob); -struct DerivedMesh *multires_dm_create_from_derived(struct MultiresModifierData*, - int local_mmd, struct DerivedMesh*, struct Object *, int); +typedef enum { + MULTIRES_USE_LOCAL_MMD = 1, + MULTIRES_USE_RENDER_PARAMS = 2, + MULTIRES_ALLOC_PAINT_MASK = 4 +} MultiresFlags; + +struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm, + struct MultiresModifierData *mmd, + struct Object *ob, + MultiresFlags flags); struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, - struct ModifierData *lastmd); + struct ModifierData *lastmd); struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, int use_first); struct DerivedMesh *get_multires_dm(struct Scene *scene, struct MultiresModifierData *mmd, - struct Object *ob); + struct Object *ob); void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob); void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, - int updateblock, int simple); + int updateblock, int simple); int multiresModifier_reshape(struct Scene *scene, struct MultiresModifierData *mmd, - struct Object *dst, struct Object *src); + struct Object *dst, struct Object *src); int multiresModifier_reshapeFromDM(struct Scene *scene, struct MultiresModifierData *mmd, - struct Object *ob, struct DerivedMesh *srcdm); + struct Object *ob, struct DerivedMesh *srcdm); int multiresModifier_reshapeFromDeformMod(struct Scene *scene, struct MultiresModifierData *mmd, - struct Object *ob, struct ModifierData *md); + struct Object *ob, struct ModifierData *md); void multires_stitch_grids(struct Object *); diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h index e7e1577c6b4..68b3e01b9ff 100644 --- a/source/blender/blenkernel/BKE_node.h +++ b/source/blender/blenkernel/BKE_node.h @@ -508,9 +508,10 @@ struct ShadeResult; #define SH_NODE_LAYER_WEIGHT 160 #define SH_NODE_VOLUME_TRANSPARENT 161 #define SH_NODE_VOLUME_ISOTROPIC 162 -#define SH_NODE_GAMMA 163 -#define SH_NODE_TEX_CHECKER 164 +#define SH_NODE_GAMMA 163 +#define SH_NODE_TEX_CHECKER 164 #define SH_NODE_BRIGHTCONTRAST 165 +#define SH_NODE_LIGHT_FALLOFF 166 /* custom defines options for Material node */ #define SH_NODE_MAT_DIFF 1 @@ -683,6 +684,11 @@ void ntreeCompositClearTags(struct bNodeTree *ntree); struct bNodeSocket *ntreeCompositOutputFileAddSocket(struct bNodeTree *ntree, struct bNode *node, const char *name, struct ImageFormatData *im_format); int ntreeCompositOutputFileRemoveActiveSocket(struct bNodeTree *ntree, struct bNode *node); +void ntreeCompositOutputFileSetPath(struct bNode *node, struct bNodeSocket *sock, const char *name); +void ntreeCompositOutputFileSetLayer(struct bNode *node, struct bNodeSocket *sock, const char *name); +/* needed in do_versions */ +void ntreeCompositOutputFileUniquePath(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim); +void ntreeCompositOutputFileUniqueLayer(struct ListBase *list, struct bNodeSocket *sock, const char defname[], char delim); /* ************** TEXTURE NODES *************** */ diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 2e334c4abc9..92a447f9351 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -50,65 +50,66 @@ struct RenderData; struct rctf; struct MovieClip; -void clear_workob(struct Object *workob); -void what_does_parent(struct Scene *scene, struct Object *ob, struct Object *workob); +void BKE_object_workob_clear(struct Object *workob); +void BKE_object_workob_calc_parent(struct Scene *scene, struct Object *ob, struct Object *workob); -void copy_baseflags(struct Scene *scene); -void copy_objectflags(struct Scene *scene); struct SoftBody *copy_softbody(struct SoftBody *sb); struct BulletSoftBody *copy_bulletsoftbody(struct BulletSoftBody *sb); -void copy_object_particlesystems(struct Object *obn, struct Object *ob); -void copy_object_softbody(struct Object *obn, struct Object *ob); -void object_free_particlesystems(struct Object *ob); -void object_free_softbody(struct Object *ob); -void object_free_bulletsoftbody(struct Object *ob); -void update_base_layer(struct Scene *scene, struct Object *ob); +void BKE_object_copy_particlesystems(struct Object *obn, struct Object *ob); +void BKE_object_copy_softbody(struct Object *obn, struct Object *ob); +void BKE_object_free_particlesystems(struct Object *ob); +void BKE_object_free_softbody(struct Object *ob); +void BKE_object_free_bulletsoftbody(struct Object *ob); +void BKE_object_update_base_layer(struct Scene *scene, struct Object *ob); -void free_object(struct Object *ob); -void object_free_display(struct Object *ob); +void BKE_object_free(struct Object *ob); +void BKE_object_free_display(struct Object *ob); -int object_support_modifier_type(struct Object *ob, int modifier_type); +int BKE_object_support_modifier_type_check(struct Object *ob, int modifier_type); -void object_link_modifiers(struct Object *ob, struct Object *from); -void object_free_modifiers(struct Object *ob); +void BKE_object_link_modifiers(struct Object *ob, struct Object *from); +void BKE_object_free_modifiers(struct Object *ob); -void object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); -void object_copy_proxy_drivers(struct Object *ob, struct Object *target); +void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); +void BKE_object_copy_proxy_drivers(struct Object *ob, struct Object *target); -void unlink_object(struct Object *ob); -int exist_object(struct Object *obtest); +void BKE_object_unlink(struct Object *ob); +int BKE_object_exists_check(struct Object *obtest); -struct Object *add_only_object(int type, const char *name); -struct Object *add_object(struct Scene *scene, int type); -void *add_obdata_from_type(int type); +struct Object *BKE_object_add_only_object(int type, const char *name); +struct Object *BKE_object_add(struct Scene *scene, int type); +void *BKE_object_obdata_add_from_type(int type); -struct Object *copy_object(struct Object *ob); -void make_local_object(struct Object *ob); -int object_is_libdata(struct Object *ob); -int object_data_is_libdata(struct Object *ob); +struct Object *BKE_object_copy(struct Object *ob); +void BKE_object_make_local(struct Object *ob); +int BKE_object_is_libdata(struct Object *ob); +int BKE_object_obdata_is_libdata(struct Object *ob); -void object_scale_to_mat3(struct Object *ob, float mat[][3]); -void object_rot_to_mat3(struct Object *ob, float mat[][3]); -void object_mat3_to_rot(struct Object *ob, float mat[][3], short use_compat); -void object_to_mat3(struct Object *ob, float mat[][3]); -void object_to_mat4(struct Object *ob, float mat[][4]); -void object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent); +void BKE_object_scale_to_mat3(struct Object *ob, float mat[][3]); +void BKE_object_rot_to_mat3(struct Object *ob, float mat[][3]); +void BKE_object_mat3_to_rot(struct Object *ob, float mat[][3], short use_compat); +void BKE_object_to_mat3(struct Object *ob, float mat[][3]); +void BKE_object_to_mat4(struct Object *ob, float mat[][4]); +void BKE_object_apply_mat4(struct Object *ob, float mat[][4], const short use_compat, const short use_parent); -struct Object *object_pose_armature_get(struct Object *ob); +struct Object *BKE_object_pose_armature_get(struct Object *ob); -void where_is_object_time(struct Scene *scene, struct Object *ob, float ctime); -void where_is_object(struct Scene *scene, struct Object *ob); -void where_is_object_simul(struct Scene *scene, struct Object *ob); -void where_is_object_mat(struct Scene *scene, struct Object *ob, float obmat[4][4]); +void BKE_object_where_is_calc(struct Scene *scene, struct Object *ob); +void BKE_object_where_is_calc_time(struct Scene *scene, struct Object *ob, float ctime); +void BKE_object_where_is_calc_simul(struct Scene *scene, struct Object *ob); +void BKE_object_where_is_calc_mat4(struct Scene *scene, struct Object *ob, float obmat[4][4]); -struct BoundBox *unit_boundbox(void); -void boundbox_set_from_min_max(struct BoundBox *bb, float min[3], float max[3]); -struct BoundBox *object_get_boundbox(struct Object *ob); -void object_get_dimensions(struct Object *ob, float vec[3]); -void object_set_dimensions(struct Object *ob, const float *value); -void object_boundbox_flag(struct Object *ob, int flag, int set); -void minmax_object(struct Object *ob, float min[3], float max[3]); -int minmax_object_duplis(struct Scene *scene, struct Object *ob, float min[3], float max[3]); +/* possibly belong in own moduke? */ +struct BoundBox *BKE_boundbox_alloc_unit(void); +void BKE_boundbox_init_from_minmax(struct BoundBox *bb, float min[3], float max[3]); +int BKE_boundbox_ray_hit_check(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); + +struct BoundBox *BKE_object_boundbox_get(struct Object *ob); +void BKE_object_dimensions_get(struct Object *ob, float vec[3]); +void BKE_object_dimensions_set(struct Object *ob, const float *value); +void BKE_object_boundbox_flag(struct Object *ob, int flag, int set); +void BKE_object_minmax(struct Object *ob, float r_min[3], float r_max[3]); +int BKE_object_minmax_dupli(struct Scene *scene, struct Object *ob, float r_min[3], float r_max[3]); /* sometimes min-max isn't enough, we need to loop over each point */ void BKE_object_foreach_display_point( @@ -122,10 +123,8 @@ void BKE_scene_foreach_display_point( int BKE_object_parent_loop_check(const struct Object *parent, const struct Object *ob); -int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]); - -void *object_tfm_backup(struct Object *ob); -void object_tfm_restore(struct Object *ob, void *obtfm_pt); +void *BKE_object_tfm_backup(struct Object *ob); +void BKE_object_tfm_restore(struct Object *ob, void *obtfm_pt); typedef struct ObjectTfmProtectedChannels { float loc[3], dloc[3]; @@ -136,28 +135,28 @@ typedef struct ObjectTfmProtectedChannels { float rotAngle, drotAngle; } ObjectTfmProtectedChannels; -void object_tfm_protected_backup(const struct Object *ob, - ObjectTfmProtectedChannels *obtfm); +void BKE_object_tfm_protected_backup(const struct Object *ob, + ObjectTfmProtectedChannels *obtfm); -void object_tfm_protected_restore(struct Object *ob, - const ObjectTfmProtectedChannels *obtfm, - const short protectflag); +void BKE_object_tfm_protected_restore(struct Object *ob, + const ObjectTfmProtectedChannels *obtfm, + const short protectflag); -void object_handle_update(struct Scene *scene, struct Object *ob); -void object_sculpt_modifiers_changed(struct Object *ob); +void BKE_object_handle_update(struct Scene *scene, struct Object *ob); +void BKE_object_sculpt_modifiers_changed(struct Object *ob); -int give_obdata_texspace(struct Object *ob, short **texflag, float **loc, float **size, float **rot); +int BKE_object_obdata_texspace_get(struct Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot); -int object_insert_ptcache(struct Object *ob); +int BKE_object_insert_ptcache(struct Object *ob); // void object_delete_ptcache(struct Object *ob, int index); -struct KeyBlock *object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix); +struct KeyBlock *BKE_object_insert_shape_key(struct Scene *scene, struct Object *ob, const char *name, int from_mix); -int object_is_modified(struct Scene *scene, struct Object *ob); -int object_is_deform_modified(struct Scene *scene, struct Object *ob); +int BKE_object_is_modified(struct Scene *scene, struct Object *ob); +int BKE_object_is_deform_modified(struct Scene *scene, struct Object *ob); -void object_relink(struct Object *ob); +void BKE_object_relink(struct Object *ob); -struct MovieClip *object_get_movieclip(struct Scene *scene, struct Object *ob, int use_default); +struct MovieClip *BKE_object_movieclip_get(struct Scene *scene, struct Object *ob, int use_default); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index bd31a62abf9..b32b7145ff4 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -35,6 +35,7 @@ struct Brush; struct MDisps; struct MeshElemMap; +struct GridPaintMask; struct MFace; struct MultireModifierData; struct MVert; @@ -66,7 +67,11 @@ int paint_vertsel_test(struct Object *ob); /* partial visibility */ int paint_is_face_hidden(const struct MFace *f, const struct MVert *mvert); int paint_is_grid_face_hidden(const unsigned int *grid_hidden, - int gridsize, int x, int y); + int gridsize, int x, int y); + +/* paint masks */ +float paint_grid_paint_mask(const struct GridPaintMask *gpm, unsigned level, + unsigned x, unsigned y); /* Session data (mode-specific) */ @@ -79,6 +84,7 @@ typedef struct SculptSession { int totvert, totpoly; float *face_normals; struct KeyBlock *kb; + float *vmask; /* Mesh connectivity */ const struct MeshElemMap *pmap; diff --git a/source/blender/blenkernel/BKE_particle.h b/source/blender/blenkernel/BKE_particle.h index 67dba6fd7a7..f776295b912 100644 --- a/source/blender/blenkernel/BKE_particle.h +++ b/source/blender/blenkernel/BKE_particle.h @@ -246,7 +246,7 @@ void psys_check_group_weights(struct ParticleSettings *part); int psys_uses_gravity(struct ParticleSimulationData *sim); /* free */ -void psys_free_settings(struct ParticleSettings *part); +void BKE_particlesettings_free(struct ParticleSettings *part); void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit); void psys_free(struct Object * ob, struct ParticleSystem * psys); @@ -266,8 +266,8 @@ struct ParticleSystemModifierData *psys_get_modifier(struct Object *ob, struct P struct ModifierData *object_add_particle_system(struct Scene *scene, struct Object *ob, const char *name); void object_remove_particle_system(struct Scene *scene, struct Object *ob); struct ParticleSettings *psys_new_settings(const char *name, struct Main *main); -struct ParticleSettings *psys_copy_settings(struct ParticleSettings *part); -void make_local_particlesettings(struct ParticleSettings *part); +struct ParticleSettings *BKE_particlesettings_copy(struct ParticleSettings *part); +void BKE_particlesettings_make_local(struct ParticleSettings *part); void psys_reset(struct ParticleSystem *psys, int mode); diff --git a/source/blender/blenkernel/BKE_scene.h b/source/blender/blenkernel/BKE_scene.h index e46d99ed873..3a93562707d 100644 --- a/source/blender/blenkernel/BKE_scene.h +++ b/source/blender/blenkernel/BKE_scene.h @@ -61,40 +61,44 @@ struct Base *_setlooper_base_step(struct Scene **sce_iter, struct Base *base); void free_avicodecdata(struct AviCodecData *acd); void free_qtcodecdata(struct QuicktimeCodecData *acd); -void free_scene(struct Scene *sce); -struct Scene *add_scene(const char *name); -struct Base *object_in_scene(struct Object *ob, struct Scene *sce); +void BKE_scene_free(struct Scene *sce); +struct Scene *BKE_scene_add(const char *name); -void set_scene_bg(struct Main *bmain, struct Scene *sce); -struct Scene *set_scene_name(struct Main *bmain, const char *name); +/* base functions */ +struct Base *BKE_scene_base_find(struct Scene *scene, struct Object *ob); +struct Base *BKE_scene_base_add(struct Scene *sce, struct Object *ob); +void BKE_scene_base_deselect_all(struct Scene *sce); +void BKE_scene_base_select(struct Scene *sce, struct Base *selbase); +int BKE_scene_base_iter_next(struct Scene **scene, int val, struct Base **base, struct Object **ob); -struct Scene *copy_scene(struct Scene *sce, int type); -void unlink_scene(struct Main *bmain, struct Scene *sce, struct Scene *newsce); +void BKE_scene_base_flag_to_objects(struct Scene *scene); +void BKE_scene_base_flag_from_objects(struct Scene *scene); -int next_object(struct Scene **scene, int val, struct Base **base, struct Object **ob); -struct Object *scene_find_camera(struct Scene *sc); -struct Object *scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH -int scene_camera_switch_update(struct Scene *scene); +void BKE_scene_set_background(struct Main *bmain, struct Scene *sce); +struct Scene *BKE_scene_set_name(struct Main *bmain, const char *name); -char *scene_find_marker_name(struct Scene *scene, int frame); -char *scene_find_last_marker_name(struct Scene *scene, int frame); +struct Scene *BKE_scene_copy(struct Scene *sce, int type); +void BKE_scene_unlink(struct Main *bmain, struct Scene *sce, struct Scene *newsce); -struct Base *scene_add_base(struct Scene *sce, struct Object *ob); -void scene_deselect_all(struct Scene *sce); -void scene_select_base(struct Scene *sce, struct Base *selbase); +struct Object *BKE_scene_camera_find(struct Scene *sc); +struct Object *BKE_scene_camera_switch_find(struct Scene *scene); // DURIAN_CAMERA_SWITCH +int BKE_scene_camera_switch_update(struct Scene *scene); + +char *BKE_scene_find_marker_name(struct Scene *scene, int frame); +char *BKE_scene_find_last_marker_name(struct Scene *scene, int frame); /* checks for cycle, returns 1 if it's all OK */ -int scene_check_setscene(struct Main *bmain, struct Scene *sce); +int BKE_scene_validate_setscene(struct Main *bmain, struct Scene *sce); -float BKE_curframe(struct Scene *scene); -float BKE_frame_to_ctime(struct Scene *scene, const float frame); +float BKE_scene_frame_get(struct Scene *scene); +float BKE_scene_frame_get_from_ctime(struct Scene *scene, const float frame); -void scene_update_tagged(struct Main *bmain, struct Scene *sce); +void BKE_scene_update_tagged(struct Main *bmain, struct Scene *sce); -void scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); +void BKE_scene_update_for_newframe(struct Main *bmain, struct Scene *sce, unsigned int lay); -struct SceneRenderLayer *scene_add_render_layer(struct Scene *sce, const char *name); -int scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl); +struct SceneRenderLayer *BKE_scene_add_render_layer(struct Scene *sce, const char *name); +int BKE_scene_remove_render_layer(struct Main *main, struct Scene *scene, struct SceneRenderLayer *srl); /* render profile */ int get_render_subsurf_level(struct RenderData *r, int level); @@ -102,7 +106,7 @@ int get_render_child_particle_number(struct RenderData *r, int num); int get_render_shadow_samples(struct RenderData *r, int samples); float get_render_aosss_error(struct RenderData *r, float error); -int scene_use_new_shading_nodes(struct Scene *scene); +int BKE_scene_use_new_shading_nodes(struct Scene *scene); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index fbb93c761c2..af6e793cf2f 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -252,7 +252,7 @@ float BKE_screen_view3d_zoom_to_fac(float camzoom); float BKE_screen_view3d_zoom_from_fac(float zoomfac); /* screen */ -void free_screen(struct bScreen *sc); +void BKE_screen_free(struct bScreen *sc); unsigned int BKE_screen_visible_layers(struct bScreen *screen, struct Scene *scene); #endif diff --git a/source/blender/blenkernel/BKE_sequencer.h b/source/blender/blenkernel/BKE_sequencer.h index 598d1b681bc..decbf5d0d2a 100644 --- a/source/blender/blenkernel/BKE_sequencer.h +++ b/source/blender/blenkernel/BKE_sequencer.h @@ -170,6 +170,22 @@ struct ImBuf *give_ibuf_seq_direct(SeqRenderData context, float cfra, struct Seq struct ImBuf *give_ibuf_seqbase(SeqRenderData context, float cfra, int chan_shown, struct ListBase *seqbasep); void give_ibuf_prefetch_request(SeqRenderData context, float cfra, int chan_shown); + +/* ********************************************************************** + * sequencer scene functions + * ********************************************************************** */ +struct Editing *BKE_sequencer_editing_get(struct Scene *scene, int alloc); +struct Editing *BKE_sequencer_editing_ensure(struct Scene *scene); +void BKE_sequencer_editing_free(struct Scene *scene); + +void BKE_sequencer_sort(struct Scene *scene); + +struct Sequence *BKE_sequencer_active_get(struct Scene *scene); +int BKE_sequencer_active_get_pair(struct Scene *scene, + struct Sequence **seq_act, struct Sequence **seq_other); +void BKE_sequencer_active_set(struct Scene *scene, struct Sequence *seq); + + /* apply functions recursively */ int seqbase_recursive_apply(struct ListBase *seqbase, int (*apply_func)(struct Sequence *seq, void *), void *arg); int seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence *, void *), void *arg); @@ -179,14 +195,12 @@ int seq_recursive_apply(struct Sequence *seq, int (*apply_func)(struct Sequence void seq_free_sequence(struct Scene *scene, struct Sequence *seq); void seq_free_sequence_recurse(struct Scene *scene, struct Sequence *seq); void seq_free_strip(struct Strip *strip); -void seq_free_editing(struct Scene *scene); + void seq_free_clipboard(void); -struct Editing *seq_give_editing(struct Scene *scene, int alloc); const char *give_seqname(struct Sequence *seq); void calc_sequence(struct Scene *scene, struct Sequence *seq); void calc_sequence_disp(struct Scene *scene, struct Sequence *seq); void reload_sequence_new_file(struct Scene *scene, struct Sequence * seq, int lock_range); -void sort_seq(struct Scene *scene); void build_seqar_cb(struct ListBase *seqbase, struct Sequence ***seqar, int *totseq, int (*test_func)(struct Sequence * seq)); int evaluate_seq_frame(struct Scene *scene, int cfra); @@ -296,10 +310,6 @@ void clear_scene_in_allseqs(struct Main *bmain, struct Scene *sce); struct Sequence *get_seq_by_name(struct ListBase *seqbase, const char *name, int recursive); -struct Sequence *seq_active_get(struct Scene *scene); -void seq_active_set(struct Scene *scene, struct Sequence *seq); -int seq_active_pair_get(struct Scene *scene, struct Sequence **seq_act, struct Sequence **seq_other); - /* api for adding new sequence strips */ typedef struct SeqLoadInfo { int start_frame; diff --git a/source/blender/blenkernel/BKE_sound.h b/source/blender/blenkernel/BKE_sound.h index 8b01dbde531..ec1b6577469 100644 --- a/source/blender/blenkernel/BKE_sound.h +++ b/source/blender/blenkernel/BKE_sound.h @@ -41,8 +41,7 @@ struct ListBase; struct Main; struct Sequence; -typedef struct SoundWaveform -{ +typedef struct SoundWaveform { int length; float *data; } SoundWaveform; @@ -58,29 +57,29 @@ void sound_exit(void); void sound_force_device(int device); int sound_define_from_str(const char *str); -struct bSound* sound_new_file(struct Main *main, const char *filename); +struct bSound *sound_new_file(struct Main *main, const char *filename); // XXX unused currently #if 0 -struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source); +struct bSound *sound_new_buffer(struct Main *bmain, struct bSound *source); -struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end); +struct bSound *sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end); #endif -void sound_delete(struct Main *bmain, struct bSound* sound); +void sound_delete(struct Main *bmain, struct bSound *sound); -void sound_cache(struct bSound* sound); +void sound_cache(struct bSound *sound); -void sound_cache_notifying(struct Main* main, struct bSound* sound); +void sound_cache_notifying(struct Main *main, struct bSound *sound); -void sound_delete_cache(struct bSound* sound); +void sound_delete_cache(struct bSound *sound); -void sound_load(struct Main *main, struct bSound* sound); +void sound_load(struct Main *main, struct bSound *sound); -void sound_free(struct bSound* sound); +void BKE_sound_free(struct bSound *sound); #ifdef __AUD_C_API_H__ -AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume); +AUD_Device *sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume); #endif void sound_create_scene(struct Scene *scene); @@ -93,32 +92,32 @@ void sound_update_fps(struct Scene *scene); void sound_update_scene_listener(struct Scene *scene); -void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip); -void* sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence); +void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip); +void *sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence); -void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip); -void* sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence); +void *sound_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip); +void *sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence); -void sound_remove_scene_sound(struct Scene *scene, void* handle); +void sound_remove_scene_sound(struct Scene *scene, void *handle); -void sound_mute_scene_sound(void* handle, char mute); +void sound_mute_scene_sound(void *handle, char mute); -void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip); +void sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip); void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence); -void sound_update_scene_sound(void* handle, struct bSound* sound); +void sound_update_scene_sound(void *handle, struct bSound *sound); void sound_set_cfra(int cfra); void sound_set_scene_volume(struct Scene *scene, float volume); -void sound_set_scene_sound_volume(void* handle, float volume, char animated); +void sound_set_scene_sound_volume(void *handle, float volume, char animated); -void sound_set_scene_sound_pitch(void* handle, float pitch, char animated); +void sound_set_scene_sound_pitch(void *handle, float pitch, char animated); -void sound_set_scene_sound_pan(void* handle, float pan, char animated); +void sound_set_scene_sound_pan(void *handle, float pan, char animated); -void sound_update_sequencer(struct Main* main, struct bSound* sound); +void sound_update_sequencer(struct Main *main, struct bSound *sound); void sound_play_scene(struct Scene *scene); @@ -130,12 +129,14 @@ float sound_sync_scene(struct Scene *scene); int sound_scene_playing(struct Scene *scene); -void sound_free_waveform(struct bSound* sound); +void sound_free_waveform(struct bSound *sound); -void sound_read_waveform(struct bSound* sound); +void sound_read_waveform(struct bSound *sound); -void sound_update_scene(struct Scene* scene); +void sound_update_scene(struct Scene *scene); -void* sound_get_factory(void* sound); +void *sound_get_factory(void *sound); + +float sound_get_length(struct bSound *sound); #endif diff --git a/source/blender/blenkernel/BKE_speaker.h b/source/blender/blenkernel/BKE_speaker.h index fddcfb2c7f3..52c177fce57 100644 --- a/source/blender/blenkernel/BKE_speaker.h +++ b/source/blender/blenkernel/BKE_speaker.h @@ -33,9 +33,9 @@ * \brief General operations for speakers. */ -void *add_speaker(const char *name); -struct Speaker *copy_speaker(struct Speaker *spk); -void make_local_speaker(struct Speaker *spk); -void free_speaker(struct Speaker *spk); +void *BKE_speaker_add(const char *name); +struct Speaker *BKE_speaker_copy(struct Speaker *spk); +void BKE_speaker_make_local(struct Speaker *spk); +void BKE_speaker_free(struct Speaker *spk); #endif diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 8179c688580..ea824a9998d 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -34,9 +34,9 @@ /* struct DerivedMesh is used directly */ #include "BKE_DerivedMesh.h" +struct CCGElem; struct DMFlagMat; struct DMGridAdjacency; -struct DMGridData; struct DerivedMesh; struct MeshElemMap; struct Mesh; @@ -51,16 +51,23 @@ struct CCGSubsurf; struct CCGVert; struct EdgeHash; struct PBVH; -struct DMGridData; struct DMGridAdjacency; /**************************** External *****************************/ +typedef enum { + SUBSURF_USE_RENDER_PARAMS = 1, + SUBSURF_IS_FINAL_CALC = 2, + SUBSURF_FOR_EDIT_MODE = 4, + SUBSURF_IN_EDIT_MODE = 8, + SUBSURF_ALLOC_PAINT_MASK = 16 +} SubsurfFlags; + struct DerivedMesh *subsurf_make_derived_from_derived( - struct DerivedMesh *dm, - struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int forEditMode, int inEditMode); + struct DerivedMesh *dm, + struct SubsurfModifierData *smd, + float (*vertCos)[3], + SubsurfFlags flags); void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]); @@ -72,9 +79,13 @@ int ccg_gridsize(int level); int ccg_factor(int low_level, int high_level); void subsurf_copy_grid_hidden(struct DerivedMesh *dm, - const struct MPoly *mpoly, - struct MVert *mvert, - const struct MDisps *mdisps); + const struct MPoly *mpoly, + struct MVert *mvert, + const struct MDisps *mdisps); + +void subsurf_copy_grid_paint_mask(struct DerivedMesh *dm, + const struct MPoly *mpoly, float *paint_mask, + const struct GridPaintMask *grid_paint_mask); typedef enum MultiresModifiedFlags { /* indicates the grids have been sculpted on, so MDisps @@ -93,10 +104,10 @@ typedef struct CCGDerivedMesh { int freeSS; int drawInteriorEdges, useSubsurfUv; - struct {int startVert; struct CCGVert *vert;} *vertMap; - struct {int startVert; int startEdge; struct CCGEdge *edge;} *edgeMap; + struct {int startVert; struct CCGVert *vert; } *vertMap; + struct {int startVert; int startEdge; struct CCGEdge *edge; } *edgeMap; struct {int startVert; int startEdge; - int startFace; struct CCGFace *face;} *faceMap; + int startFace; struct CCGFace *face; } *faceMap; short *edgeFlags; struct DMFlagMat *faceFlags; @@ -108,7 +119,7 @@ typedef struct CCGDerivedMesh { struct MeshElemMap *pmap; int *pmap_mem; - struct DMGridData **gridData; + struct CCGElem **gridData; struct DMGridAdjacency *gridAdjacency; int *gridOffset; struct CCGFace **gridFaces; diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 115c00d9e73..875903f2e20 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -42,17 +42,17 @@ struct Text; struct TextLine; struct SpaceText; -void free_text (struct Text *text); +void BKE_text_free (struct Text *text); void txt_set_undostate (int u); int txt_get_undostate (void); -struct Text* add_empty_text (const char *name); +struct Text* BKE_text_add (const char *name); int txt_extended_ascii_as_utf8(char **str); -int reopen_text (struct Text *text); -struct Text* add_text (const char *file, const char *relpath); -struct Text* copy_text (struct Text *ta); -void unlink_text (struct Main *bmain, struct Text *text); -void clear_text(struct Text *text); -void write_text(struct Text *text, const char *str); +int BKE_text_reload (struct Text *text); +struct Text* BKE_text_load (const char *file, const char *relpath); +struct Text* BKE_text_copy (struct Text *ta); +void BKE_text_unlink (struct Main *bmain, struct Text *text); +void BKE_text_clear (struct Text *text); +void BKE_text_write (struct Text *text, const char *str); char* txt_to_buf (struct Text *text); void txt_clean_text (struct Text *text); diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 2574c45eec2..ed58620b716 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -59,7 +59,7 @@ struct World; #define MAXCOLORBAND 32 -void free_texture(struct Tex *t); +void BKE_texture_free(struct Tex *t); int test_dlerr(const char *name, const char *symbol); void open_plugin_tex(struct PluginTex *pit); struct PluginTex *add_plugin_tex(char *str); @@ -79,9 +79,9 @@ void tex_set_type(struct Tex *tex, int type); void default_mtex(struct MTex *mtex); struct MTex *add_mtex(void); struct MTex *add_mtex_id(struct ID *id, int slot); -struct Tex *copy_texture(struct Tex *tex); +struct Tex *BKE_texture_copy(struct Tex *tex); struct Tex *localize_texture(struct Tex *tex); -void make_local_texture(struct Tex *tex); +void BKE_texture_make_local(struct Tex *tex); void autotexname(struct Tex *tex); struct Tex *give_current_object_texture(struct Object *ob); diff --git a/source/blender/blenkernel/BKE_world.h b/source/blender/blenkernel/BKE_world.h index 16ff3acaf71..67896fffc4d 100644 --- a/source/blender/blenkernel/BKE_world.h +++ b/source/blender/blenkernel/BKE_world.h @@ -35,11 +35,11 @@ struct World; -void free_world(struct World *sc); +void BKE_world_free(struct World *sc); struct World *add_world(const char *name); -struct World *copy_world(struct World *wrld); +struct World *BKE_world_copy(struct World *wrld); struct World *localize_world(struct World *wrld); -void make_local_world(struct World *wrld); +void BKE_world_make_local(struct World *wrld); #endif diff --git a/source/blender/blenkernel/BKE_writeavi.h b/source/blender/blenkernel/BKE_writeavi.h index 03174fb5284..78875951ca4 100644 --- a/source/blender/blenkernel/BKE_writeavi.h +++ b/source/blender/blenkernel/BKE_writeavi.h @@ -51,8 +51,8 @@ typedef struct bMovieHandle { void (*get_movie_path)(char *string, struct RenderData *rd); /* optional */ } bMovieHandle; -bMovieHandle *BKE_get_movie_handle(const char imtype); -void BKE_makeanimstring(char *string, struct RenderData *rd); +bMovieHandle *BKE_movie_handle_get(const char imtype); +void BKE_movie_filepath_get(char *string, struct RenderData *rd); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_writeffmpeg.h b/source/blender/blenkernel/BKE_writeffmpeg.h index c35105f7b8b..f8382f75c0a 100644 --- a/source/blender/blenkernel/BKE_writeffmpeg.h +++ b/source/blender/blenkernel/BKE_writeffmpeg.h @@ -66,20 +66,20 @@ struct RenderData; struct ReportList; struct Scene; -extern int start_ffmpeg(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); -extern void end_ffmpeg(void); -extern int append_ffmpeg(struct RenderData *rd, int start_frame, int frame, int *pixels, - int rectx, int recty, struct ReportList *reports); -void filepath_ffmpeg(char* string, struct RenderData* rd); +int BKE_ffmpeg_start(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); +void BKE_ffmpeg_end(void); +int BKE_ffmpeg_append(struct RenderData *rd, int start_frame, int frame, int *pixels, + int rectx, int recty, struct ReportList *reports); +void BKE_ffmpeg_filepath_get(char* string, struct RenderData* rd); -extern void ffmpeg_set_preset(struct RenderData *rd, int preset); -extern void ffmpeg_verify_image_type(struct RenderData *rd, struct ImageFormatData *imf); -extern void ffmpeg_verify_codec_settings(struct RenderData *rd); -extern int ffmpeg_alpha_channel_supported(struct RenderData *rd); +void BKE_ffmpeg_preset_set(struct RenderData *rd, int preset); +void BKE_ffmpeg_image_type_verify(struct RenderData *rd, struct ImageFormatData *imf); +void BKE_ffmpeg_codec_settings_verify(struct RenderData *rd); +int BKE_ffmpeg_alpha_channel_is_supported(struct RenderData *rd); -extern struct IDProperty *ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); -extern int ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); -extern void ffmpeg_property_del(struct RenderData *rd, void *type, void *prop_); +struct IDProperty *BKE_ffmpeg_property_add(struct RenderData *Rd, const char *type, int opt_index, int parent_index); +int BKE_ffmpeg_property_add_string(struct RenderData *rd, const char *type, const char *str); +void BKE_ffmpeg_property_del(struct RenderData *rd, void *type, void *prop_); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/BKE_writeframeserver.h b/source/blender/blenkernel/BKE_writeframeserver.h index cb607e1473c..bdce9abe8ad 100644 --- a/source/blender/blenkernel/BKE_writeframeserver.h +++ b/source/blender/blenkernel/BKE_writeframeserver.h @@ -40,11 +40,11 @@ struct RenderData; struct ReportList; struct Scene; -extern int start_frameserver(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); -extern void end_frameserver(void); -extern int append_frameserver(struct RenderData *rd, int start_frame, int frame, int *pixels, - int rectx, int recty, struct ReportList *reports); -extern int frameserver_loop(struct RenderData *rd, struct ReportList *reports); +int BKE_frameserver_start(struct Scene *scene, struct RenderData *rd, int rectx, int recty, struct ReportList *reports); +void BKE_frameserver_end(void); +int BKE_frameserver_append(struct RenderData *rd, int start_frame, int frame, int *pixels, + int rectx, int recty, struct ReportList *reports); +int BKE_frameserver_loop(struct RenderData *rd, struct ReportList *reports); #ifdef __cplusplus } diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 53e4a973cd4..42c9fa84a91 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -7,6 +7,7 @@ #include #include +#include "BKE_ccg.h" #include "CCGSubSurf.h" #include "BKE_subsurf.h" @@ -274,22 +275,6 @@ static int ccg_edgebase(int level) /***/ -static int VertDataEqual(const float *a, const float *b) -{ - return a[0] == b[0] && a[1] == b[1] && a[2] == b[2]; -} -#define VertDataZero(av) { float *_a = (float *)av; _a[0] = _a[1] = _a[2] = 0.0f; } -#define VertDataCopy(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; } -#define VertDataAdd(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; } -#define VertDataSub(av, bv) { float *_a = (float *)av, *_b = (float *) bv; _a[0] -= _b[0]; _a[1] -= _b[1]; _a[2] -= _b[2]; } -#define VertDataMulN(av, n) { float *_a = (float *)av; float _n = n; _a[0] *= _n; _a[1] *= _n; _a[2] *= _n; } -#define VertDataAvg4(tv, av, bv, cv, dv) \ - { \ - float *_t = (float *) tv, *_a = (float *) av, *_b = (float *) bv, *_c = (float *) cv, *_d = (float *) dv; \ - _t[0] = (_a[0] + _b[0] + _c[0] + _d[0]) * 0.25f; \ - _t[1] = (_a[1] + _b[1] + _c[1] + _d[1]) * 0.25f; \ - _t[2] = (_a[2] + _b[2] + _c[2] + _d[2]) * 0.25f; \ - } #define NormZero(av) { float *_a = (float *) av; _a[0] = _a[1] = _a[2] = 0.0f; } #define NormCopy(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] = _b[0]; _a[1] = _b[1]; _a[2] = _b[2]; } #define NormAdd(av, bv) { float *_a = (float *) av, *_b = (float *) bv; _a[0] += _b[0]; _a[1] += _b[1]; _a[2] += _b[2]; } @@ -402,6 +387,10 @@ struct CCGSubSurf { int calcVertNormals; int normalDataOffset; + /* data for paint masks */ + int allocMask; + int maskDataOffset; + /* data for age'ing (to debug sync) */ int currentAge; int useAgeCounts; @@ -424,6 +413,61 @@ struct CCGSubSurf { /***/ +static int VertDataEqual(const float a[], const float b[], const CCGSubSurf *ss) +{ + int i; + for(i = 0; i < ss->meshIFC.numLayers; i++) { + if(a[i] != b[i]) + return 0; + } + return 1; +} + +static void VertDataZero(float v[], const CCGSubSurf *ss) +{ + memset(v, 0, sizeof(float) * ss->meshIFC.numLayers); +} + +static void VertDataCopy(float dst[], const float src[], const CCGSubSurf *ss) +{ + int i; + for(i = 0; i < ss->meshIFC.numLayers; i++) + dst[i] = src[i]; +} + +static void VertDataAdd(float a[], const float b[], const CCGSubSurf *ss) +{ + int i; + for(i = 0; i < ss->meshIFC.numLayers; i++) + a[i] += b[i]; +} + +static void VertDataSub(float a[], const float b[], const CCGSubSurf *ss) +{ + int i; + for(i = 0; i < ss->meshIFC.numLayers; i++) + a[i] -= b[i]; +} + +static void VertDataMulN(float v[], float f, const CCGSubSurf *ss) +{ + int i; + for(i = 0; i < ss->meshIFC.numLayers; i++) + v[i] *= f; +} + +static void VertDataAvg4(float v[], + const float a[], const float b[], + const float c[], const float d[], + const CCGSubSurf *ss) +{ + int i; + for(i = 0; i < ss->meshIFC.numLayers; i++) + v[i] = (a[i] + b[i] + c[i] + d[i]) * 0.25f; +} + +/***/ + static CCGVert *_vert_new(CCGVertHDL vHDL, CCGSubSurf *ss) { int num_vert_data = ss->subdivLevels + 1; @@ -812,6 +856,8 @@ CCGSubSurf *ccgSubSurf_new(CCGMeshIFC *ifc, int subdivLevels, CCGAllocatorIFC *a ss->calcVertNormals = 0; ss->normalDataOffset = 0; + ss->allocMask = 0; + ss->q = CCGSUBSURF_alloc(ss, ss->meshIFC.vertDataSize); ss->r = CCGSUBSURF_alloc(ss, ss->meshIFC.vertDataSize); @@ -956,6 +1002,17 @@ CCGError ccgSubSurf_setCalcVertexNormals(CCGSubSurf *ss, int useVertNormals, int return eCCGError_None; } +void ccgSubSurf_setAllocMask(CCGSubSurf *ss, int allocMask, int maskOffset) +{ + ss->allocMask = allocMask; + ss->maskDataOffset = maskOffset; +} + +void ccgSubSurf_setNumLayers(CCGSubSurf *ss, int numLayers) +{ + ss->meshIFC.numLayers = numLayers; +} + /***/ CCGError ccgSubSurf_initFullSync(CCGSubSurf *ss) @@ -1071,14 +1128,15 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa v = _ehash_lookupWithPrev(ss->vMap, vHDL, &prevp); if (!v) { v = _vert_new(vHDL, ss); - VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); _ehash_insert(ss->vMap, (EHEntry *) v); v->flags = Vert_eEffected | seamflag; } - else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) { + else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) || + ((v->flags & Vert_eSeam) != seamflag)) { int i, j; - VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); v->flags = Vert_eEffected | seamflag; for (i = 0; i < v->numEdges; i++) { @@ -1102,14 +1160,15 @@ CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertDa v = _ehash_lookupWithPrev(ss->oldVMap, vHDL, &prevp); if (!v) { v = _vert_new(vHDL, ss); - VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); _ehash_insert(ss->vMap, (EHEntry *) v); v->flags = Vert_eEffected | seamflag; } - else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize)) || ((v->flags & Vert_eSeam) != seamflag)) { + else if (!VertDataEqual(vertData, _vert_getCo(v, 0, ss->meshIFC.vertDataSize), ss) || + ((v->flags & Vert_eSeam) != seamflag)) { *prevp = v->next; _ehash_insert(ss->vMap, (EHEntry *) v); - VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData); + VertDataCopy(_vert_getCo(v, 0, ss->meshIFC.vertDataSize), vertData, ss); v->flags = Vert_eEffected | Vert_eChanged | seamflag; } else { @@ -1516,7 +1575,7 @@ static void ccgSubSurf__calcVertNormals(CCGSubSurf *ss, } VertDataCopy((float *)((byte *)FACE_getCenterData(f) + normalDataOffset), - FACE_getIFNo(f, lvl, S, 0, 0)); + FACE_getIFNo(f, lvl, S, 0, 0), ss); for (x = 1; x < gridSize - 1; x++) NormCopy(FACE_getIENo(f, lvl, S, x), @@ -1587,7 +1646,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *co3 = FACE_getIFCo(f, curLvl, S, x + 0, y + 1); void *co = FACE_getIFCo(f, nextLvl, S, fx, fy); - VertDataAvg4(co, co0, co1, co2, co3); + VertDataAvg4(co, co0, co1, co2, co3, ss); } } } @@ -1605,7 +1664,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *co3 = FACE_getIFCo(f, nextLvl, S, fx, 1); void *co = FACE_getIECo(f, nextLvl, S, fx); - VertDataAvg4(co, co0, co1, co2, co3); + VertDataAvg4(co, co0, co1, co2, co3, ss); } /* interior face interior edge midpoints @@ -1624,7 +1683,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *co3 = FACE_getIFCo(f, nextLvl, S, fx + 1, fy); void *co = FACE_getIFCo(f, nextLvl, S, fx, fy); - VertDataAvg4(co, co0, co1, co2, co3); + VertDataAvg4(co, co0, co1, co2, co3, ss); } } @@ -1639,7 +1698,7 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *co3 = FACE_getIFCo(f, nextLvl, S, fx, fy + 1); void *co = FACE_getIFCo(f, nextLvl, S, fx, fy); - VertDataAvg4(co, co0, co1, co2, co3); + VertDataAvg4(co, co0, co1, co2, co3, ss); } } } @@ -1661,9 +1720,9 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *co1 = EDGE_getCo(e, curLvl, x + 1); void *co = EDGE_getCo(e, nextLvl, fx); - VertDataCopy(co, co0); - VertDataAdd(co, co1); - VertDataMulN(co, 0.5f); + VertDataCopy(co, co0, ss); + VertDataAdd(co, co1, ss); + VertDataMulN(co, 0.5f, ss); } } else { @@ -1674,26 +1733,26 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *co = EDGE_getCo(e, nextLvl, fx); int numFaces = 0; - VertDataCopy(q, co0); - VertDataAdd(q, co1); + VertDataCopy(q, co0, ss); + VertDataAdd(q, co1, ss); for (j = 0; j < e->numFaces; j++) { CCGFace *f = e->faces[j]; const int f_ed_idx = _face_getEdgeIndex(f, e); - VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx, 1, subdivLevels, vertDataSize)); + VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx, 1, subdivLevels, vertDataSize), ss); numFaces++; } - VertDataMulN(q, 1.0f / (2.0f + numFaces)); + VertDataMulN(q, 1.0f / (2.0f + numFaces), ss); - VertDataCopy(r, co0); - VertDataAdd(r, co1); - VertDataMulN(r, 0.5f); + VertDataCopy(r, co0, ss); + VertDataAdd(r, co1, ss); + VertDataMulN(r, 0.5f, ss); - VertDataCopy(co, q); - VertDataSub(r, q); - VertDataMulN(r, sharpness); - VertDataAdd(co, r); + VertDataCopy(co, q, ss); + VertDataSub(r, q, ss); + VertDataMulN(r, sharpness, ss); + VertDataAdd(co, r, ss); } } } @@ -1738,53 +1797,53 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, seam = 0; if (!v->numEdges) { - VertDataCopy(nCo, co); + VertDataCopy(nCo, co, ss); } else if (_vert_isBoundary(v)) { int numBoundary = 0; - VertDataZero(r); + VertDataZero(r, ss); for (j = 0; j < v->numEdges; j++) { CCGEdge *e = v->edges[j]; if (_edge_isBoundary(e)) { - VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); + VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss); numBoundary++; } } - VertDataCopy(nCo, co); - VertDataMulN(nCo, 0.75f); - VertDataMulN(r, 0.25f / numBoundary); - VertDataAdd(nCo, r); + VertDataCopy(nCo, co, ss); + VertDataMulN(nCo, 0.75f, ss); + VertDataMulN(r, 0.25f / numBoundary, ss); + VertDataAdd(nCo, r, ss); } else { int cornerIdx = (1 + (1 << (curLvl))) - 2; int numEdges = 0, numFaces = 0; - VertDataZero(q); + VertDataZero(q, ss); for (j = 0; j < v->numFaces; j++) { CCGFace *f = v->faces[j]; - VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx)); + VertDataAdd(q, FACE_getIFCo(f, nextLvl, _face_getVertIndex(f, v), cornerIdx, cornerIdx), ss); numFaces++; } - VertDataMulN(q, 1.0f / numFaces); - VertDataZero(r); + VertDataMulN(q, 1.0f / numFaces, ss); + VertDataZero(r, ss); for (j = 0; j < v->numEdges; j++) { CCGEdge *e = v->edges[j]; - VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); + VertDataAdd(r, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss); numEdges++; } - VertDataMulN(r, 1.0f / numEdges); + VertDataMulN(r, 1.0f / numEdges, ss); - VertDataCopy(nCo, co); - VertDataMulN(nCo, numEdges - 2.0f); - VertDataAdd(nCo, q); - VertDataAdd(nCo, r); - VertDataMulN(nCo, 1.0f / numEdges); + VertDataCopy(nCo, co, ss); + VertDataMulN(nCo, numEdges - 2.0f, ss); + VertDataAdd(nCo, q, ss); + VertDataAdd(nCo, r, ss); + VertDataMulN(nCo, 1.0f / numEdges, ss); } if ((sharpCount > 1 && v->numFaces) || seam) { - VertDataZero(q); + VertDataZero(q, ss); if (seam) { avgSharpness = 1.0f; @@ -1798,33 +1857,33 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, if (seam) { if (_edge_isBoundary(e)) - VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); + VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss); } else if (sharpness != 0.0f) { - VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize)); + VertDataAdd(q, _edge_getCoVert(e, v, curLvl, 1, vertDataSize), ss); } } - VertDataMulN(q, (float) 1 / sharpCount); + VertDataMulN(q, (float) 1 / sharpCount, ss); if (sharpCount != 2 || allSharp) { /* q = q + (co - q) * avgSharpness */ - VertDataCopy(r, co); - VertDataSub(r, q); - VertDataMulN(r, avgSharpness); - VertDataAdd(q, r); + VertDataCopy(r, co, ss); + VertDataSub(r, q, ss); + VertDataMulN(r, avgSharpness, ss); + VertDataAdd(q, r, ss); } /* r = co * 0.75 + q * 0.25 */ - VertDataCopy(r, co); - VertDataMulN(r, .75f); - VertDataMulN(q, .25f); - VertDataAdd(r, q); + VertDataCopy(r, co, ss); + VertDataMulN(r, .75f, ss); + VertDataMulN(q, .25f, ss); + VertDataAdd(r, q, ss); /* nCo = nCo + (r - nCo) * avgSharpness */ - VertDataSub(r, nCo); - VertDataMulN(r, avgSharpness); - VertDataAdd(nCo, r); + VertDataSub(r, nCo, ss); + VertDataMulN(r, avgSharpness, ss); + VertDataAdd(nCo, r, ss); } } @@ -1858,13 +1917,13 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, int fx = x * 2; void *co = EDGE_getCo(e, curLvl, x); void *nCo = EDGE_getCo(e, nextLvl, fx); - VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1)); - VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1)); - VertDataMulN(r, 0.5f); - VertDataCopy(nCo, co); - VertDataMulN(nCo, 0.75f); - VertDataMulN(r, 0.25f); - VertDataAdd(nCo, r); + VertDataCopy(r, EDGE_getCo(e, curLvl, x - 1), ss); + VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1), ss); + VertDataMulN(r, 0.5f, ss); + VertDataCopy(nCo, co, ss); + VertDataMulN(nCo, 0.75f, ss); + VertDataMulN(r, 0.25f, ss); + VertDataAdd(nCo, r, ss); } } else { @@ -1874,38 +1933,38 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, void *nCo = EDGE_getCo(e, nextLvl, fx); int numFaces = 0; - VertDataZero(q); - VertDataZero(r); - VertDataAdd(r, EDGE_getCo(e, curLvl, x - 1)); - VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1)); + VertDataZero(q, ss); + VertDataZero(r, ss); + VertDataAdd(r, EDGE_getCo(e, curLvl, x - 1), ss); + VertDataAdd(r, EDGE_getCo(e, curLvl, x + 1), ss); for (j = 0; j < e->numFaces; j++) { CCGFace *f = e->faces[j]; int f_ed_idx = _face_getEdgeIndex(f, e); - VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx - 1, 1, subdivLevels, vertDataSize)); - VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx + 1, 1, subdivLevels, vertDataSize)); + VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx - 1, 1, subdivLevels, vertDataSize), ss); + VertDataAdd(q, _face_getIFCoEdge(f, e, f_ed_idx, nextLvl, fx + 1, 1, subdivLevels, vertDataSize), ss); - VertDataAdd(r, _face_getIFCoEdge(f, e, f_ed_idx, curLvl, x, 1, subdivLevels, vertDataSize)); + VertDataAdd(r, _face_getIFCoEdge(f, e, f_ed_idx, curLvl, x, 1, subdivLevels, vertDataSize), ss); numFaces++; } - VertDataMulN(q, 1.0f / (numFaces * 2.0f)); - VertDataMulN(r, 1.0f / (2.0f + numFaces)); + VertDataMulN(q, 1.0f / (numFaces * 2.0f), ss); + VertDataMulN(r, 1.0f / (2.0f + numFaces), ss); - VertDataCopy(nCo, co); - VertDataMulN(nCo, (float) numFaces); - VertDataAdd(nCo, q); - VertDataAdd(nCo, r); - VertDataMulN(nCo, 1.0f / (2 + numFaces)); + VertDataCopy(nCo, co, ss); + VertDataMulN(nCo, (float) numFaces, ss); + VertDataAdd(nCo, q, ss); + VertDataAdd(nCo, r, ss); + VertDataMulN(nCo, 1.0f / (2 + numFaces), ss); if (sharpCount == 2) { - VertDataCopy(q, co); - VertDataMulN(q, 6.0f); - VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1)); - VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1)); - VertDataMulN(q, 1 / 8.0f); + VertDataCopy(q, co, ss); + VertDataMulN(q, 6.0f, ss); + VertDataAdd(q, EDGE_getCo(e, curLvl, x - 1), ss); + VertDataAdd(q, EDGE_getCo(e, curLvl, x + 1), ss); + VertDataMulN(q, 1 / 8.0f, ss); - VertDataSub(q, nCo); - VertDataMulN(q, avgSharpness); - VertDataAdd(nCo, q); + VertDataSub(q, nCo, ss); + VertDataMulN(q, avgSharpness, ss); + VertDataAdd(nCo, q, ss); } } } @@ -1931,21 +1990,21 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, * - old interior edge points * - new interior face midpoints */ - VertDataZero(q); + VertDataZero(q, ss); for (S = 0; S < f->numVerts; S++) { - VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1)); + VertDataAdd(q, FACE_getIFCo(f, nextLvl, S, 1, 1), ss); } - VertDataMulN(q, 1.0f / f->numVerts); - VertDataZero(r); + VertDataMulN(q, 1.0f / f->numVerts, ss); + VertDataZero(r, ss); for (S = 0; S < f->numVerts; S++) { - VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1)); + VertDataAdd(r, FACE_getIECo(f, curLvl, S, 1), ss); } - VertDataMulN(r, 1.0f / f->numVerts); + VertDataMulN(r, 1.0f / f->numVerts, ss); - VertDataMulN(FACE_getCenterData(f), f->numVerts - 2.0f); - VertDataAdd(FACE_getCenterData(f), q); - VertDataAdd(FACE_getCenterData(f), r); - VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts); + VertDataMulN((float*)FACE_getCenterData(f), f->numVerts - 2.0f, ss); + VertDataAdd((float*)FACE_getCenterData(f), q, ss); + VertDataAdd((float*)FACE_getCenterData(f), r, ss); + VertDataMulN((float*)FACE_getCenterData(f), 1.0f / f->numVerts, ss); for (S = 0; S < f->numVerts; S++) { /* interior face shift @@ -1964,18 +2023,20 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, FACE_getIFCo(f, nextLvl, S, fx - 1, fy - 1), FACE_getIFCo(f, nextLvl, S, fx + 1, fy - 1), FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 1), - FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1)); + FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 1), + ss); VertDataAvg4(r, FACE_getIFCo(f, nextLvl, S, fx - 1, fy + 0), FACE_getIFCo(f, nextLvl, S, fx + 1, fy + 0), FACE_getIFCo(f, nextLvl, S, fx + 0, fy - 1), - FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1)); + FACE_getIFCo(f, nextLvl, S, fx + 0, fy + 1), + ss); - VertDataCopy(nCo, co); - VertDataSub(nCo, q); - VertDataMulN(nCo, 0.25f); - VertDataAdd(nCo, r); + VertDataCopy(nCo, co, ss); + VertDataSub(nCo, q, ss); + VertDataMulN(nCo, 0.25f, ss); + VertDataAdd(nCo, r, ss); } } @@ -1993,18 +2054,19 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx - 1), FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx + 1), FACE_getIFCo(f, nextLvl, S, fx + 1, +1), - FACE_getIFCo(f, nextLvl, S, fx - 1, +1)); + FACE_getIFCo(f, nextLvl, S, fx - 1, +1), ss); VertDataAvg4(r, FACE_getIECo(f, nextLvl, S, fx - 1), FACE_getIECo(f, nextLvl, S, fx + 1), FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 1, fx), - FACE_getIFCo(f, nextLvl, S, fx, 1)); + FACE_getIFCo(f, nextLvl, S, fx, 1), + ss); - VertDataCopy(nCo, co); - VertDataSub(nCo, q); - VertDataMulN(nCo, 0.25f); - VertDataAdd(nCo, r); + VertDataCopy(nCo, co, ss); + VertDataSub(nCo, q, ss); + VertDataMulN(nCo, 0.25f, ss); + VertDataAdd(nCo, r, ss); } } } @@ -2024,8 +2086,8 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, #pragma omp parallel for private(i) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) for (i = 0; i < numEffectedE; i++) { CCGEdge *e = effectedE[i]; - VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl)); - VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize - 1), VERT_getCo(e->v1, nextLvl)); + VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl), ss); + VertDataCopy(EDGE_getCo(e, nextLvl, edgeSize - 1), VERT_getCo(e->v1, nextLvl), ss); } #pragma omp parallel for private(i) if (numEffectedF * edgeSize * edgeSize * 4 >= CCG_OMP_LIMIT) @@ -2037,19 +2099,19 @@ static void ccgSubSurf__calcSubdivLevel(CCGSubSurf *ss, CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; - VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl)); - VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx)); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss); + VertDataCopy(FACE_getIECo(f, nextLvl, S, cornerIdx), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, cornerIdx), ss); for (x = 1; x < gridSize - 1; x++) { void *co = FACE_getIECo(f, nextLvl, S, x); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co); - VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, 0), co, ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, (S + 1) % f->numVerts, 0, x), co, ss); } for (x = 0; x < gridSize - 1; x++) { int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize)); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize)); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, eI, vertDataSize), ss); } } } @@ -2103,11 +2165,11 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) for (ptrIdx = 0; ptrIdx < numEffectedF; ptrIdx++) { CCGFace *f = effectedF[ptrIdx]; void *co = FACE_getCenterData(f); - VertDataZero(co); + VertDataZero(co, ss); for (i = 0; i < f->numVerts; i++) { - VertDataAdd(co, VERT_getCo(FACE_getVerts(f)[i], curLvl)); + VertDataAdd(co, VERT_getCo(FACE_getVerts(f)[i], curLvl), ss); } - VertDataMulN(co, 1.0f / f->numVerts); + VertDataMulN(co, 1.0f / f->numVerts, ss); f->flags = 0; } @@ -2117,29 +2179,29 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) float sharpness = EDGE_getSharpness(e, curLvl); if (_edge_isBoundary(e) || sharpness >= 1.0f) { - VertDataCopy(co, VERT_getCo(e->v0, curLvl)); - VertDataAdd(co, VERT_getCo(e->v1, curLvl)); - VertDataMulN(co, 0.5f); + VertDataCopy(co, VERT_getCo(e->v0, curLvl), ss); + VertDataAdd(co, VERT_getCo(e->v1, curLvl), ss); + VertDataMulN(co, 0.5f, ss); } else { int numFaces = 0; - VertDataCopy(q, VERT_getCo(e->v0, curLvl)); - VertDataAdd(q, VERT_getCo(e->v1, curLvl)); + VertDataCopy(q, VERT_getCo(e->v0, curLvl), ss); + VertDataAdd(q, VERT_getCo(e->v1, curLvl), ss); for (i = 0; i < e->numFaces; i++) { CCGFace *f = e->faces[i]; - VertDataAdd(q, FACE_getCenterData(f)); + VertDataAdd(q, (float*)FACE_getCenterData(f), ss); numFaces++; } - VertDataMulN(q, 1.0f / (2.0f + numFaces)); + VertDataMulN(q, 1.0f / (2.0f + numFaces), ss); - VertDataCopy(r, VERT_getCo(e->v0, curLvl)); - VertDataAdd(r, VERT_getCo(e->v1, curLvl)); - VertDataMulN(r, 0.5f); + VertDataCopy(r, VERT_getCo(e->v0, curLvl), ss); + VertDataAdd(r, VERT_getCo(e->v1, curLvl), ss); + VertDataMulN(r, 0.5f, ss); - VertDataCopy(co, q); - VertDataSub(r, q); - VertDataMulN(r, sharpness); - VertDataAdd(co, r); + VertDataCopy(co, q, ss); + VertDataSub(r, q, ss); + VertDataMulN(r, sharpness, ss); + VertDataAdd(co, r, ss); } // edge flags cleared later @@ -2179,51 +2241,51 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) seam = 0; if (!v->numEdges) { - VertDataCopy(nCo, co); + VertDataCopy(nCo, co, ss); } else if (_vert_isBoundary(v)) { int numBoundary = 0; - VertDataZero(r); + VertDataZero(r, ss); for (i = 0; i < v->numEdges; i++) { CCGEdge *e = v->edges[i]; if (_edge_isBoundary(e)) { - VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl)); + VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl), ss); numBoundary++; } } - VertDataCopy(nCo, co); - VertDataMulN(nCo, 0.75f); - VertDataMulN(r, 0.25f / numBoundary); - VertDataAdd(nCo, r); + VertDataCopy(nCo, co, ss); + VertDataMulN(nCo, 0.75f, ss); + VertDataMulN(r, 0.25f / numBoundary, ss); + VertDataAdd(nCo, r, ss); } else { int numEdges = 0, numFaces = 0; - VertDataZero(q); + VertDataZero(q, ss); for (i = 0; i < v->numFaces; i++) { CCGFace *f = v->faces[i]; - VertDataAdd(q, FACE_getCenterData(f)); + VertDataAdd(q, (float*)FACE_getCenterData(f), ss); numFaces++; } - VertDataMulN(q, 1.0f / numFaces); - VertDataZero(r); + VertDataMulN(q, 1.0f / numFaces, ss); + VertDataZero(r, ss); for (i = 0; i < v->numEdges; i++) { CCGEdge *e = v->edges[i]; - VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl)); + VertDataAdd(r, VERT_getCo(_edge_getOtherVert(e, v), curLvl), ss); numEdges++; } - VertDataMulN(r, 1.0f / numEdges); + VertDataMulN(r, 1.0f / numEdges, ss); - VertDataCopy(nCo, co); - VertDataMulN(nCo, numEdges - 2.0f); - VertDataAdd(nCo, q); - VertDataAdd(nCo, r); - VertDataMulN(nCo, 1.0f / numEdges); + VertDataCopy(nCo, co, ss); + VertDataMulN(nCo, numEdges - 2.0f, ss); + VertDataAdd(nCo, q, ss); + VertDataAdd(nCo, r, ss); + VertDataMulN(nCo, 1.0f / numEdges, ss); } if (sharpCount > 1 || seam) { - VertDataZero(q); + VertDataZero(q, ss); if (seam) { avgSharpness = 1.0f; @@ -2238,35 +2300,35 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) if (seam) { if (_edge_isBoundary(e)) { CCGVert *oV = _edge_getOtherVert(e, v); - VertDataAdd(q, VERT_getCo(oV, curLvl)); + VertDataAdd(q, VERT_getCo(oV, curLvl), ss); } } else if (sharpness != 0.0f) { CCGVert *oV = _edge_getOtherVert(e, v); - VertDataAdd(q, VERT_getCo(oV, curLvl)); + VertDataAdd(q, VERT_getCo(oV, curLvl), ss); } } - VertDataMulN(q, (float) 1 / sharpCount); + VertDataMulN(q, (float) 1 / sharpCount, ss); if (sharpCount != 2 || allSharp) { /* q = q + (co - q) * avgSharpness */ - VertDataCopy(r, co); - VertDataSub(r, q); - VertDataMulN(r, avgSharpness); - VertDataAdd(q, r); + VertDataCopy(r, co, ss); + VertDataSub(r, q, ss); + VertDataMulN(r, avgSharpness, ss); + VertDataAdd(q, r, ss); } /* r = co * 0.75 + q * 0.25 */ - VertDataCopy(r, co); - VertDataMulN(r, 0.75f); - VertDataMulN(q, 0.25f); - VertDataAdd(r, q); + VertDataCopy(r, co, ss); + VertDataMulN(r, 0.75f, ss); + VertDataMulN(q, 0.25f, ss); + VertDataAdd(r, q, ss); /* nCo = nCo + (r - nCo) * avgSharpness */ - VertDataSub(r, nCo); - VertDataMulN(r, avgSharpness); - VertDataAdd(nCo, r); + VertDataSub(r, nCo, ss); + VertDataMulN(r, avgSharpness, ss); + VertDataAdd(nCo, r, ss); } // vert flags cleared later @@ -2294,8 +2356,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) for (i = 0; i < numEffectedE; i++) { CCGEdge *e = effectedE[i]; - VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl)); - VertDataCopy(EDGE_getCo(e, nextLvl, 2), VERT_getCo(e->v1, nextLvl)); + VertDataCopy(EDGE_getCo(e, nextLvl, 0), VERT_getCo(e->v0, nextLvl), ss); + VertDataCopy(EDGE_getCo(e, nextLvl, 2), VERT_getCo(e->v1, nextLvl), ss); } for (i = 0; i < numEffectedF; i++) { CCGFace *f = effectedF[i]; @@ -2303,13 +2365,13 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; - VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 1), VERT_getCo(FACE_getVerts(f)[S], nextLvl)); - VertDataCopy(FACE_getIECo(f, nextLvl, S, 1), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, 1)); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIECo(f, nextLvl, S, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 1), VERT_getCo(FACE_getVerts(f)[S], nextLvl), ss); + VertDataCopy(FACE_getIECo(f, nextLvl, S, 1), EDGE_getCo(FACE_getEdges(f)[S], nextLvl, 1), ss); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 0), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize)); - VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 1), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize)); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, 1, 0), _edge_getCoVert(e, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize), ss); + VertDataCopy(FACE_getIFCo(f, nextLvl, S, 0, 1), _edge_getCoVert(prevE, FACE_getVerts(f)[S], nextLvl, 1, vertDataSize), ss); } } @@ -2433,16 +2495,16 @@ CCGError ccgSubSurf_updateFromFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *prevE = FACE_getEdges(f)[(S + f->numVerts - 1) % f->numVerts]; - VertDataCopy(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0)); - VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx)); + VertDataCopy((float*)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss); + VertDataCopy(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss); for (x = 0; x < gridSize; x++) - VertDataCopy(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0)); + VertDataCopy(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0), ss); for (x = 0; x < gridSize; x++) { int eI = gridSize - 1 - x; - VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x)); - VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx)); + VertDataCopy(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x), ss); + VertDataCopy(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx), ss); } } } @@ -2475,17 +2537,17 @@ CCGError ccgSubSurf_updateToFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, for (x = 0; x < gridSize; x++) { int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); - VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); + VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss); + VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss); } for (x = 1; x < gridSize - 1; x++) { - VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x)); - VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x)); + VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x), ss); + VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x), ss); } - VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl)); + VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss); } } @@ -2518,7 +2580,7 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in for (i = 0; i < numEffectedV; i++) { CCGVert *v = effectedV[i]; if (v->numFaces) - VertDataZero(VERT_getCo(v, lvl)); + VertDataZero(VERT_getCo(v, lvl), ss); } for (i = 0; i < numEffectedE; i++) { @@ -2526,40 +2588,40 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in if (e->numFaces) for (x = 0; x < edgeSize; x++) - VertDataZero(EDGE_getCo(e, lvl, x)); + VertDataZero(EDGE_getCo(e, lvl, x), ss); } /* add */ for (i = 0; i < numEffectedF; i++) { CCGFace *f = effectedF[i]; - VertDataZero(FACE_getCenterData(f)); + VertDataZero((float*)FACE_getCenterData(f), ss); for (S = 0; S < f->numVerts; S++) for (x = 0; x < gridSize; x++) - VertDataZero(FACE_getIECo(f, lvl, S, x)); + VertDataZero(FACE_getIECo(f, lvl, S, x), ss); for (S = 0; S < f->numVerts; S++) { int prevS = (S + f->numVerts - 1) % f->numVerts; CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *prevE = FACE_getEdges(f)[prevS]; - VertDataAdd(FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0)); + VertDataAdd((float*)FACE_getCenterData(f), FACE_getIFCo(f, lvl, S, 0, 0), ss); if (FACE_getVerts(f)[S]->flags & Vert_eEffected) - VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx)); + VertDataAdd(VERT_getCo(FACE_getVerts(f)[S], lvl), FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), ss); for (x = 1; x < gridSize - 1; x++) { - VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0)); - VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x)); + VertDataAdd(FACE_getIECo(f, lvl, S, x), FACE_getIFCo(f, lvl, S, x, 0), ss); + VertDataAdd(FACE_getIECo(f, lvl, prevS, x), FACE_getIFCo(f, lvl, S, 0, x), ss); } for (x = 0; x < gridSize - 1; x++) { int eI = gridSize - 1 - x; if (FACE_getEdges(f)[S]->flags & Edge_eEffected) - VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x)); + VertDataAdd(_edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, cornerIdx, x), ss); if (FACE_getEdges(f)[prevS]->flags & Edge_eEffected) if (x != 0) - VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx)); + VertDataAdd(_edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), FACE_getIFCo(f, lvl, S, x, cornerIdx), ss); } } } @@ -2568,51 +2630,52 @@ CCGError ccgSubSurf_stitchFaces(CCGSubSurf *ss, int lvl, CCGFace **effectedF, in for (i = 0; i < numEffectedV; i++) { CCGVert *v = effectedV[i]; if (v->numFaces) - VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces); + VertDataMulN(VERT_getCo(v, lvl), 1.0f / v->numFaces, ss); } for (i = 0; i < numEffectedE; i++) { CCGEdge *e = effectedE[i]; - VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl)); - VertDataCopy(EDGE_getCo(e, lvl, edgeSize - 1), VERT_getCo(e->v1, lvl)); + VertDataCopy(EDGE_getCo(e, lvl, 0), VERT_getCo(e->v0, lvl), ss); + VertDataCopy(EDGE_getCo(e, lvl, edgeSize - 1), VERT_getCo(e->v1, lvl), ss); if (e->numFaces) for (x = 1; x < edgeSize - 1; x++) - VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces); + VertDataMulN(EDGE_getCo(e, lvl, x), 1.0f / e->numFaces, ss); } /* copy */ for (i = 0; i < numEffectedF; i++) { CCGFace *f = effectedF[i]; - VertDataMulN(FACE_getCenterData(f), 1.0f / f->numVerts); + VertDataMulN((float*)FACE_getCenterData(f), 1.0f / f->numVerts, ss); for (S = 0; S < f->numVerts; S++) for (x = 1; x < gridSize - 1; x++) - VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f); + VertDataMulN(FACE_getIECo(f, lvl, S, x), 0.5f, ss); for (S = 0; S < f->numVerts; S++) { int prevS = (S + f->numVerts - 1) % f->numVerts; CCGEdge *e = FACE_getEdges(f)[S]; CCGEdge *prevE = FACE_getEdges(f)[prevS]; - VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl)); + VertDataCopy(FACE_getIFCo(f, lvl, S, 0, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, cornerIdx), VERT_getCo(FACE_getVerts(f)[S], lvl), ss); for (x = 1; x < gridSize - 1; x++) { - VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x)); - VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x)); + VertDataCopy(FACE_getIFCo(f, lvl, S, x, 0), FACE_getIECo(f, lvl, S, x), ss); + VertDataCopy(FACE_getIFCo(f, lvl, S, 0, x), FACE_getIECo(f, lvl, prevS, x), ss); } for (x = 0; x < gridSize - 1; x++) { int eI = gridSize - 1 - x; - VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); - VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize)); + + VertDataCopy(FACE_getIFCo(f, lvl, S, cornerIdx, x), _edge_getCoVert(e, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss); + VertDataCopy(FACE_getIFCo(f, lvl, S, x, cornerIdx), _edge_getCoVert(prevE, FACE_getVerts(f)[S], lvl, eI, vertDataSize), ss); } - VertDataCopy(FACE_getIECo(f, lvl, S, 0), FACE_getCenterData(f)); - VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0)); + VertDataCopy(FACE_getIECo(f, lvl, S, 0), (float*)FACE_getCenterData(f), ss); + VertDataCopy(FACE_getIECo(f, lvl, S, gridSize - 1), FACE_getIFCo(f, lvl, S, gridSize - 1, 0), ss); } } @@ -3051,3 +3114,36 @@ int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss) int numFinalFaces = ss->numGrids * ((gridSize - 1) * (gridSize - 1)); return numFinalFaces; } + +/***/ + +void CCG_key(CCGKey *key, const CCGSubSurf *ss, int level) +{ + key->level = level; + + key->elem_size = ss->meshIFC.vertDataSize; + key->has_normals = ss->calcVertNormals; + key->num_layers = ss->meshIFC.numLayers; + + /* if normals are present, always the last three floats of an + element */ + if (key->has_normals) + key->normal_offset = key->elem_size - sizeof(float) * 3; + else + key->normal_offset = -1; + + key->grid_size = ccgSubSurf_getGridLevelSize(ss, level); + key->grid_area = key->grid_size * key->grid_size; + key->grid_bytes = key->elem_size * key->grid_area; + + key->has_mask = ss->allocMask; + if (key->has_mask) + key->mask_offset = ss->maskDataOffset; + else + key->mask_offset = -1; +} + +void CCG_key_top_level(CCGKey *key, const CCGSubSurf *ss) +{ + CCG_key(key, ss, ccgSubSurf_getSubdivisionLevels(ss)); +} diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index e73ef6b543e..33b37ac281c 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -15,7 +15,7 @@ typedef struct CCGFace CCGFace; typedef struct CCGMeshIFC { int vertUserSize, edgeUserSize, faceUserSize; - + int numLayers; int vertDataSize; } CCGMeshIFC; @@ -76,6 +76,9 @@ void ccgSubSurf_getUseAgeCounts (CCGSubSurf *ss, int *useAgeCounts_r, int *ve CCGError ccgSubSurf_setUseAgeCounts (CCGSubSurf *ss, int useAgeCounts, int vertUserOffset, int edgeUserOffset, int faceUserOffset); CCGError ccgSubSurf_setCalcVertexNormals (CCGSubSurf *ss, int useVertNormals, int normalDataOffset); +void ccgSubSurf_setAllocMask (CCGSubSurf *ss, int allocMask, int maskOffset); + +void ccgSubSurf_setNumLayers (CCGSubSurf *ss, int numLayers); /***/ diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index f648a9e297c..50c10ea3c3d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -446,10 +446,10 @@ void DM_update_tessface_data(DerivedMesh *dm) not_done--; } } - mesh_loops_to_mface_corners(fdata, ldata, pdata, - ml_idx, mf_idx, polyindex[mf_idx], - mf_len, - numTex, numCol, hasPCol, hasOrigSpace); + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + ml_idx, mf_idx, polyindex[mf_idx], + mf_len, + numTex, numCol, hasPCol, hasOrigSpace); } if (G.debug & G_DEBUG) @@ -814,7 +814,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, int numVerts; float (*deformedVerts)[3] = mesh_getVertexCos(me, &numVerts); - mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, 0, 0); + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, 0); dm = mesh_create_derived(me, ob, deformedVerts); if (build_shapekey_layers) @@ -828,7 +828,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, if (build_shapekey_layers) add_shapekey_layers(tdm, me, ob); - dm = mti->applyModifier(md, ob, tdm, 0, 0); + dm = mti->applyModifier(md, ob, tdm, 0); if (tdm != dm) tdm->release(tdm); } @@ -870,7 +870,7 @@ static void *get_orco_coords_dm(Object *ob, BMEditMesh *em, int layer, int *free if (em) return (float(*)[3])get_editbmesh_orco_verts(em); else - return (float(*)[3])get_mesh_orco_verts(ob); + return (float(*)[3])BKE_mesh_orco_verts_get(ob); } else if (layer == CD_CLOTH_ORCO) { /* apply shape key for cloth, this should really be solved @@ -932,7 +932,7 @@ static void add_orco_dm(Object *ob, BMEditMesh *em, DerivedMesh *dm, if (orco) { if (layer == CD_ORCO) - transform_mesh_orco_verts(ob->data, orco, totvert, 0); + BKE_mesh_orco_verts_transform(ob->data, orco, totvert, 0); if (!(layerorco = DM_get_vert_data_layer(dm, layer))) { DM_add_vert_layer(dm, layer, CD_CALLOC, NULL); @@ -1383,6 +1383,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* XXX Same as above... For now, only weights preview in WPaint mode. */ const int do_mod_wmcol = do_init_wmcol; + ModifierApplyFlag app_flags = useRenderParams ? MOD_APPLY_RENDER : 0; + ModifierApplyFlag deform_app_flags = app_flags; + if (useCache) + app_flags |= MOD_APPLY_USECACHE; + if (useDeform) + deform_app_flags |= MOD_APPLY_USECACHE; + if (mmd && !mmd->sculptlvl) has_multires = 0; @@ -1434,7 +1441,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if (!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts); - mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, useRenderParams, useDeform); + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, deform_app_flags); } else { break; @@ -1547,7 +1554,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } - mti->deformVerts(md, ob, dm, deformedVerts, numVerts, useRenderParams, useDeform); + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, deform_app_flags); } else { DerivedMesh *ndm; @@ -1622,7 +1629,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } - ndm = mti->applyModifier(md, ob, dm, useRenderParams, useCache); + ndm = mti->applyModifier(md, ob, dm, app_flags); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1645,7 +1652,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos nextmask &= ~CD_MASK_ORCO; DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX); - ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0); + ndm = mti->applyModifier(md, ob, orcodm, app_flags & ~MOD_APPLY_USECACHE); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1661,7 +1668,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos nextmask &= ~CD_MASK_CLOTH_ORCO; DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX); - ndm = mti->applyModifier(md, ob, clothorcodm, useRenderParams, 0); + ndm = mti->applyModifier(md, ob, clothorcodm, app_flags & ~MOD_APPLY_USECACHE); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1928,7 +1935,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D if (mti->deformVertsEM) mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts); - else mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); + else + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0); } else { DerivedMesh *ndm; @@ -1971,7 +1979,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D if (mti->applyModifierEM) ndm = mti->applyModifierEM(md, ob, em, orcodm); else - ndm = mti->applyModifier(md, ob, orcodm, 0, 0); + ndm = mti->applyModifier(md, ob, orcodm, 0); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1995,7 +2003,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D if (mti->applyModifierEM) ndm = mti->applyModifierEM(md, ob, em, dm); else - ndm = mti->applyModifier(md, ob, dm, 0, 0); + ndm = mti->applyModifier(md, ob, dm, 0); if (ndm) { if (dm && dm != ndm) @@ -2097,7 +2105,7 @@ static void clear_mesh_caches(Object *ob) me->bb = NULL; } - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); if (ob->derivedFinal) { ob->derivedFinal->needsFree = 1; @@ -2111,7 +2119,7 @@ static void clear_mesh_caches(Object *ob) } if (ob->sculpt) { - object_sculpt_modifiers_changed(ob); + BKE_object_sculpt_modifiers_changed(ob); } } @@ -2666,7 +2674,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) if (is_degenerate == 0) { copy_v2_v2(prev_edge, cur_edge); - ++i; + i++; } } } @@ -2725,7 +2733,7 @@ void DM_calc_auto_bump_scale(DerivedMesh *dm) f2x_surf_area = len_v3(norm); fsurf_ratio = f2x_surf_area/f2x_area_uv; // tri area divided by texture area - ++nr_accumulated; + nr_accumulated++; dsum += (double)(fsurf_ratio); } } @@ -2884,7 +2892,7 @@ void DM_set_object_boundbox(Object *ob, DerivedMesh *dm) if (!ob->bb) ob->bb= MEM_callocN(sizeof(BoundBox), "DM-BoundBox"); - boundbox_set_from_min_max(ob->bb, min, max); + BKE_boundbox_init_from_minmax(ob->bb, min, max); } /* --- NAVMESH (begin) --- */ diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 5a2407ca56b..9e46d03a3ab 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -69,7 +69,7 @@ * - Pose is the local (object level) component of armature. The current * object pose is saved in files, and (will be) is presorted for dependency * - Actions have fewer (or other) channels, and write data to a Pose - * - Currently ob->pose data is controlled in where_is_pose only. The (recalc) + * - Currently ob->pose data is controlled in BKE_pose_where_is only. The (recalc) * event system takes care of calling that * - The NLA system (here too) uses Poses as interpolation format for Actions * - Therefore we assume poses to be static, and duplicates of poses have channels in @@ -83,14 +83,14 @@ bAction *add_empty_action(const char name[]) { bAction *act; - act= alloc_libblock(&G.main->action, ID_AC, name); + act = BKE_libblock_alloc(&G.main->action, ID_AC, name); return act; } /* .................................. */ -/* temp data for make_local_action */ +/* temp data for BKE_action_make_local */ typedef struct tMakeLocalActionContext { bAction *act; /* original action */ bAction *act_new; /* new action */ @@ -99,18 +99,18 @@ typedef struct tMakeLocalActionContext { int is_local; /* some action users were not libraries */ } tMakeLocalActionContext; -/* helper function for make_local_action() - local/lib init step */ +/* helper function for BKE_action_make_local() - local/lib init step */ static void make_localact_init_cb(ID *id, AnimData *adt, void *mlac_ptr) { tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; if (adt->action == mlac->act) { - if (id->lib) mlac->is_lib= TRUE; - else mlac->is_local= TRUE; + if (id->lib) mlac->is_lib = TRUE; + else mlac->is_local = TRUE; } } -/* helper function for make_local_action() - change references */ +/* helper function for BKE_action_make_local() - change references */ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) { tMakeLocalActionContext *mlac = (tMakeLocalActionContext *)mlac_ptr; @@ -126,28 +126,28 @@ static void make_localact_apply_cb(ID *id, AnimData *adt, void *mlac_ptr) } // does copy_fcurve... -void make_local_action(bAction *act) +void BKE_action_make_local(bAction *act) { tMakeLocalActionContext mlac = {act, NULL, FALSE, FALSE}; - Main *bmain= G.main; + Main *bmain = G.main; - if (act->id.lib==NULL) + if (act->id.lib == NULL) return; // XXX: double-check this; it used to be just single-user check, but that was when fake-users were still default - if ((act->id.flag & LIB_FAKEUSER) && (act->id.us<=1)) { + if ((act->id.flag & LIB_FAKEUSER) && (act->id.us <= 1)) { id_clear_lib_data(bmain, &act->id); return; } BKE_animdata_main_cb(bmain, make_localact_init_cb, &mlac); - if (mlac.is_local && mlac.is_lib==FALSE) { + if (mlac.is_local && mlac.is_lib == FALSE) { id_clear_lib_data(bmain, &act->id); } else if (mlac.is_local && mlac.is_lib) { - mlac.act_new= copy_action(act); - mlac.act_new->id.us= 0; + mlac.act_new = BKE_action_copy(act); + mlac.act_new->id.us = 0; BKE_id_lib_local_paths(bmain, act->id.lib, &mlac.act_new->id); @@ -157,7 +157,7 @@ void make_local_action(bAction *act) /* .................................. */ -void free_action(bAction *act) +void BKE_action_free(bAction *act) { /* sanity check */ if (act == NULL) @@ -177,7 +177,7 @@ void free_action(bAction *act) /* .................................. */ -bAction *copy_action (bAction *src) +bAction *BKE_action_copy(bAction *src) { bAction *dst = NULL; bActionGroup *dgrp, *sgrp; @@ -185,29 +185,29 @@ bAction *copy_action (bAction *src) if (src == NULL) return NULL; - dst= copy_libblock(&src->id); + dst = BKE_libblock_copy(&src->id); /* duplicate the lists of groups and markers */ BLI_duplicatelist(&dst->groups, &src->groups); BLI_duplicatelist(&dst->markers, &src->markers); /* copy F-Curves, fixing up the links as we go */ - dst->curves.first= dst->curves.last= NULL; + dst->curves.first = dst->curves.last = NULL; - for (sfcu= src->curves.first; sfcu; sfcu= sfcu->next) { + for (sfcu = src->curves.first; sfcu; sfcu = sfcu->next) { /* duplicate F-Curve */ - dfcu= copy_fcurve(sfcu); + dfcu = copy_fcurve(sfcu); BLI_addtail(&dst->curves, dfcu); /* fix group links (kindof bad list-in-list search, but this is the most reliable way) */ - for (dgrp=dst->groups.first, sgrp=src->groups.first; dgrp && sgrp; dgrp=dgrp->next, sgrp=sgrp->next) { + for (dgrp = dst->groups.first, sgrp = src->groups.first; dgrp && sgrp; dgrp = dgrp->next, sgrp = sgrp->next) { if (sfcu->grp == sgrp) { - dfcu->grp= dgrp; + dfcu->grp = dgrp; if (dgrp->channels.first == sfcu) - dgrp->channels.first= dfcu; + dgrp->channels.first = dfcu; if (dgrp->channels.last == sfcu) - dgrp->channels.last= dfcu; + dgrp->channels.last = dfcu; break; } @@ -220,12 +220,12 @@ bAction *copy_action (bAction *src) /* *************** Action Groups *************** */ /* Get the active action-group for an Action */ -bActionGroup *get_active_actiongroup (bAction *act) +bActionGroup *get_active_actiongroup(bAction *act) { - bActionGroup *agrp= NULL; + bActionGroup *agrp = NULL; if (act && act->groups.first) { - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->flag & AGRP_ACTIVE) break; } @@ -244,8 +244,8 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) return; /* Deactive all others */ - for (grp= act->groups.first; grp; grp= grp->next) { - if ((grp==agrp) && (select)) + for (grp = act->groups.first; grp; grp = grp->next) { + if ((grp == agrp) && (select)) grp->flag |= AGRP_ACTIVE; else grp->flag &= ~AGRP_ACTIVE; @@ -253,7 +253,7 @@ void set_active_action_group(bAction *act, bActionGroup *agrp, short select) } /* Add a new action group with the given name to the action */ -bActionGroup *action_groups_add_new (bAction *act, const char name[]) +bActionGroup *action_groups_add_new(bAction *act, const char name[]) { bActionGroup *agrp; @@ -303,7 +303,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) * the lists will be in sync after linking */ if (agrp->channels.last == act->curves.last) - act->curves.last= fcurve; + act->curves.last = fcurve; /* link in the given F-Curve after the last F-Curve in the group, * which means that it should be able to fit in with the rest of the @@ -320,7 +320,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) agrp->channels.first = agrp->channels.last = fcurve; /* step through the groups preceding this one, finding the F-Curve there to attach this one after */ - for (grp= agrp->prev; grp; grp= grp->prev) { + for (grp = agrp->prev; grp; grp = grp->prev) { /* if this group has F-Curves, we want weave the given one in right after the last channel there, * but via the Action's list not this group's list * - this is so that the F-Curve is in the right place in the Action, @@ -342,7 +342,7 @@ void action_groups_add_channel(bAction *act, bActionGroup *agrp, FCurve *fcurve) } /* set the F-Curve's new group */ - fcurve->grp= agrp; + fcurve->grp = agrp; } /* Remove the given channel from all groups */ @@ -354,28 +354,28 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu) /* check if any group used this directly */ if (fcu->grp) { - bActionGroup *agrp= fcu->grp; + bActionGroup *agrp = fcu->grp; if (agrp->channels.first == agrp->channels.last) { if (agrp->channels.first == fcu) { - agrp->channels.first= NULL; - agrp->channels.last= NULL; + agrp->channels.first = NULL; + agrp->channels.last = NULL; } } else if (agrp->channels.first == fcu) { - if ((fcu->next) && (fcu->next->grp==agrp)) - agrp->channels.first= fcu->next; + if ((fcu->next) && (fcu->next->grp == agrp)) + agrp->channels.first = fcu->next; else - agrp->channels.first= NULL; + agrp->channels.first = NULL; } else if (agrp->channels.last == fcu) { - if ((fcu->prev) && (fcu->prev->grp==agrp)) - agrp->channels.last= fcu->prev; + if ((fcu->prev) && (fcu->prev->grp == agrp)) + agrp->channels.last = fcu->prev; else - agrp->channels.last= NULL; + agrp->channels.last = NULL; } - fcu->grp= NULL; + fcu->grp = NULL; } /* now just remove from list */ @@ -383,7 +383,7 @@ void action_groups_remove_channel(bAction *act, FCurve *fcu) } /* Find a group with the given name */ -bActionGroup *action_groups_find_named (bAction *act, const char name[]) +bActionGroup *BKE_action_group_find_name(bAction *act, const char name[]) { /* sanity checks */ if (ELEM3(NULL, act, act->groups.first, name) || (name[0] == 0)) @@ -410,7 +410,7 @@ void action_groups_clear_tempflags(bAction *act) /* *************** Pose channels *************** */ /* usually used within a loop, so we got a N^2 slowdown */ -bPoseChannel *get_pose_channel(const bPose *pose, const char *name) +bPoseChannel *BKE_pose_channel_find_name(const bPose *pose, const char *name) { if (ELEM(NULL, pose, name) || (name[0] == 0)) return NULL; @@ -423,7 +423,7 @@ bPoseChannel *get_pose_channel(const bPose *pose, const char *name) /* Use with care, not on Armature poses but for temporal ones */ /* (currently used for action constraints and in rebuild_pose) */ -bPoseChannel *verify_pose_channel(bPose *pose, const char *name) +bPoseChannel *BKE_pose_channel_verify(bPose *pose, const char *name) { bPoseChannel *chan; @@ -431,7 +431,7 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) return NULL; /* See if this channel exists */ - chan= BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name)); + chan = BLI_findstring(&pose->chanbase, name, offsetof(bPoseChannel, name)); if (chan) { return chan; } @@ -445,24 +445,24 @@ bPoseChannel *verify_pose_channel(bPose *pose, const char *name) unit_axis_angle(chan->rotAxis, &chan->rotAngle); chan->size[0] = chan->size[1] = chan->size[2] = 1.0f; - chan->limitmin[0]= chan->limitmin[1]= chan->limitmin[2]= -180.0f; - chan->limitmax[0]= chan->limitmax[1]= chan->limitmax[2]= 180.0f; - chan->stiffness[0]= chan->stiffness[1]= chan->stiffness[2]= 0.0f; + chan->limitmin[0] = chan->limitmin[1] = chan->limitmin[2] = -180.0f; + chan->limitmax[0] = chan->limitmax[1] = chan->limitmax[2] = 180.0f; + chan->stiffness[0] = chan->stiffness[1] = chan->stiffness[2] = 0.0f; chan->ikrotweight = chan->iklinweight = 0.0f; unit_m4(chan->constinv); - chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */ + chan->protectflag = OB_LOCK_ROT4D; /* lock by components by default */ BLI_addtail(&pose->chanbase, chan); - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(pose); return chan; } /* Find the active posechannel for an object (we can't just use pose, as layer info is in armature) */ -bPoseChannel *get_active_posechannel (Object *ob) +bPoseChannel *BKE_pose_channel_active(Object *ob) { - bArmature *arm= (ob) ? ob->data : NULL; + bArmature *arm = (ob) ? ob->data : NULL; bPoseChannel *pchan; if (ELEM3(NULL, ob, ob->pose, arm)) { @@ -470,7 +470,7 @@ bPoseChannel *get_active_posechannel (Object *ob) } /* find active */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone) && (pchan->bone == arm->act_bone) && (pchan->bone->layer & arm->layer)) return pchan; } @@ -478,37 +478,37 @@ bPoseChannel *get_active_posechannel (Object *ob) return NULL; } -const char *get_ikparam_name(bPose *pose) +const char *BKE_pose_ikparam_get_name(bPose *pose) { if (pose) { switch (pose->iksolver) { - case IKSOLVER_LEGACY: - return NULL; - case IKSOLVER_ITASC: - return "bItasc"; + case IKSOLVER_LEGACY: + return NULL; + case IKSOLVER_ITASC: + return "bItasc"; } } return NULL; } /* dst should be freed already, makes entire duplicate */ -void copy_pose(bPose **dst, bPose *src, int copycon) +void BKE_pose_copy_data(bPose **dst, bPose *src, int copycon) { bPose *outPose; bPoseChannel *pchan; ListBase listb; if (!src) { - *dst=NULL; + *dst = NULL; return; } - if (*dst==src) { - printf("copy_pose source and target are the same\n"); - *dst=NULL; + if (*dst == src) { + printf("BKE_pose_copy_data source and target are the same\n"); + *dst = NULL; return; } - outPose= MEM_callocN(sizeof(bPose), "pose"); + outPose = MEM_callocN(sizeof(bPose), "pose"); BLI_duplicatelist(&outPose->chanbase, &src->chanbase); @@ -516,16 +516,16 @@ void copy_pose(bPose **dst, bPose *src, int copycon) outPose->ikdata = NULL; outPose->ikparam = MEM_dupallocN(src->ikparam); - for (pchan=outPose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = outPose->chanbase.first; pchan; pchan = pchan->next) { // TODO: rename this argument... if (copycon) { copy_constraints(&listb, &pchan->constraints, TRUE); // copy_constraints NULLs listb - pchan->constraints= listb; - pchan->mpath= NULL; /* motion paths should not get copied yet... */ + pchan->constraints = listb; + pchan->mpath = NULL; /* motion paths should not get copied yet... */ } if (pchan->prop) { - pchan->prop= IDP_CopyProperty(pchan->prop); + pchan->prop = IDP_CopyProperty(pchan->prop); } } @@ -533,10 +533,10 @@ void copy_pose(bPose **dst, bPose *src, int copycon) if (copycon) BLI_duplicatelist(&outPose->agroups, &src->agroups); - *dst=outPose; + *dst = outPose; } -void init_pose_itasc(bItasc *itasc) +void BKE_pose_itasc_init(bItasc *itasc) { if (itasc) { itasc->iksolver = IKSOLVER_ITASC; @@ -545,7 +545,7 @@ void init_pose_itasc(bItasc *itasc) itasc->numiter = 100; itasc->numstep = 4; itasc->precision = 0.005f; - itasc->flag = ITASC_AUTO_STEP|ITASC_INITIAL_REITERATION; + itasc->flag = ITASC_AUTO_STEP | ITASC_INITIAL_REITERATION; itasc->feedback = 20.0f; itasc->maxvel = 50.0f; itasc->solver = ITASC_SOLVER_SDLS; @@ -553,48 +553,48 @@ void init_pose_itasc(bItasc *itasc) itasc->dampeps = 0.15; } } -void init_pose_ikparam(bPose *pose) +void BKE_pose_ikparam_init(bPose *pose) { bItasc *itasc; switch (pose->iksolver) { - case IKSOLVER_ITASC: - itasc = MEM_callocN(sizeof(bItasc), "itasc"); - init_pose_itasc(itasc); - pose->ikparam = itasc; - break; - case IKSOLVER_LEGACY: - default: - pose->ikparam = NULL; - break; + case IKSOLVER_ITASC: + itasc = MEM_callocN(sizeof(bItasc), "itasc"); + BKE_pose_itasc_init(itasc); + pose->ikparam = itasc; + break; + case IKSOLVER_LEGACY: + default: + pose->ikparam = NULL; + break; } } -void make_pose_channels_hash(bPose *pose) +void BKE_pose_channels_hash_make(bPose *pose) { if (!pose->chanhash) { bPoseChannel *pchan; - pose->chanhash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); - for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) + pose->chanhash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "make_pose_chan gh"); + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) BLI_ghash_insert(pose->chanhash, pchan->name, pchan); } } -void free_pose_channels_hash(bPose *pose) +void BKE_pose_channels_hash_free(bPose *pose) { if (pose->chanhash) { BLI_ghash_free(pose->chanhash, NULL, NULL); - pose->chanhash= NULL; + pose->chanhash = NULL; } } -void free_pose_channel(bPoseChannel *pchan) +void BKE_pose_channel_free(bPoseChannel *pchan) { if (pchan->mpath) { animviz_free_motionpath(pchan->mpath); - pchan->mpath= NULL; + pchan->mpath = NULL; } free_constraints(&pchan->constraints); @@ -605,25 +605,25 @@ void free_pose_channel(bPoseChannel *pchan) } } -void free_pose_channels(bPose *pose) +void BKE_pose_channels_free(bPose *pose) { bPoseChannel *pchan; if (pose->chanbase.first) { - for (pchan = pose->chanbase.first; pchan; pchan=pchan->next) - free_pose_channel(pchan); + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) + BKE_pose_channel_free(pchan); BLI_freelistN(&pose->chanbase); } - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(pose); } -void free_pose(bPose *pose) +void BKE_pose_free(bPose *pose) { if (pose) { /* free pose-channels */ - free_pose_channels(pose); + BKE_pose_channels_free(pose); /* free pose-groups */ if (pose->agroups.first) @@ -649,24 +649,24 @@ static void copy_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *chan copy_v3_v3(pchan->size, chan->size); copy_v3_v3(pchan->eul, chan->eul); copy_v3_v3(pchan->rotAxis, chan->rotAxis); - pchan->rotAngle= chan->rotAngle; + pchan->rotAngle = chan->rotAngle; copy_qt_qt(pchan->quat, chan->quat); - pchan->rotmode= chan->rotmode; + pchan->rotmode = chan->rotmode; copy_m4_m4(pchan->chan_mat, (float(*)[4])chan->chan_mat); copy_m4_m4(pchan->pose_mat, (float(*)[4])chan->pose_mat); - pchan->flag= chan->flag; + pchan->flag = chan->flag; - con= chan->constraints.first; - for (pcon= pchan->constraints.first; pcon && con; pcon= pcon->next, con= con->next) { - pcon->enforce= con->enforce; - pcon->headtail= con->headtail; + con = chan->constraints.first; + for (pcon = pchan->constraints.first; pcon && con; pcon = pcon->next, con = con->next) { + pcon->enforce = con->enforce; + pcon->headtail = con->headtail; } } /* makes copies of internal data, unlike copy_pose_channel_data which only * copies the pose state. - * hint: use when copying bones in editmode (on returned value from verify_pose_channel) */ -void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_from) + * hint: use when copying bones in editmode (on returned value from BKE_pose_channel_verify) */ +void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_from) { /* copy transform locks */ pchan->protectflag = pchan_from->protectflag; @@ -675,16 +675,16 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_ pchan->rotmode = pchan_from->rotmode; /* copy bone group */ - pchan->agrp_index= pchan_from->agrp_index; + pchan->agrp_index = pchan_from->agrp_index; /* ik (dof) settings */ pchan->ikflag = pchan_from->ikflag; copy_v3_v3(pchan->limitmin, pchan_from->limitmin); copy_v3_v3(pchan->limitmax, pchan_from->limitmax); copy_v3_v3(pchan->stiffness, pchan_from->stiffness); - pchan->ikstretch= pchan_from->ikstretch; - pchan->ikrotweight= pchan_from->ikrotweight; - pchan->iklinweight= pchan_from->iklinweight; + pchan->ikstretch = pchan_from->ikstretch; + pchan->ikrotweight = pchan_from->ikrotweight; + pchan->iklinweight = pchan_from->iklinweight; /* constraints */ copy_constraints(&pchan->constraints, &pchan_from->constraints, TRUE); @@ -694,14 +694,14 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_ /* unlikely but possible it exists */ IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); - pchan->prop= NULL; + pchan->prop = NULL; } if (pchan_from->prop) { - pchan->prop= IDP_CopyProperty(pchan_from->prop); + pchan->prop = IDP_CopyProperty(pchan_from->prop); } /* custom shape */ - pchan->custom= pchan_from->custom; + pchan->custom = pchan_from->custom; } @@ -709,45 +709,45 @@ void duplicate_pose_channel_data(bPoseChannel *pchan, const bPoseChannel *pchan_ * can do more constraints flags later */ /* pose should be entirely OK */ -void update_pose_constraint_flags(bPose *pose) +void BKE_pose_update_constraint_flags(bPose *pose) { bPoseChannel *pchan, *parchan; bConstraint *con; /* clear */ - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { - pchan->constflag= 0; + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + pchan->constflag = 0; } pose->flag &= ~POSE_CONSTRAINTS_TIMEDEPEND; /* detect */ - for (pchan= pose->chanbase.first; pchan; pchan=pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data = (bKinematicConstraint*)con->data; + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = (bKinematicConstraint *)con->data; pchan->constflag |= PCHAN_HAS_IK; - if (data->tar==NULL || (data->tar->type==OB_ARMATURE && data->subtarget[0]==0)) + if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == 0)) pchan->constflag |= PCHAN_HAS_TARGET; /* negative rootbone = recalc rootbone index. used in do_versions */ - if (data->rootbone<0) { - data->rootbone= 0; + if (data->rootbone < 0) { + data->rootbone = 0; - if (data->flag & CONSTRAINT_IK_TIP) parchan= pchan; - else parchan= pchan->parent; + if (data->flag & CONSTRAINT_IK_TIP) parchan = pchan; + else parchan = pchan->parent; while (parchan) { data->rootbone++; - if ((parchan->bone->flag & BONE_CONNECTED)==0) + if ((parchan->bone->flag & BONE_CONNECTED) == 0) break; - parchan= parchan->parent; + parchan = parchan->parent; } } } else if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { - bFollowPathConstraint *data= (bFollowPathConstraint *)con->data; + bFollowPathConstraint *data = (bFollowPathConstraint *)con->data; /* for drawing constraint colors when color set allows this */ pchan->constflag |= PCHAN_HAS_CONST; @@ -755,7 +755,7 @@ void update_pose_constraint_flags(bPose *pose) /* if we have a valid target, make sure that this will get updated on frame-change * (needed for when there is no anim-data for this pose) */ - if ((data->tar) && (data->tar->type==OB_CURVE)) + if ((data->tar) && (data->tar->type == OB_CURVE)) pose->flag |= POSE_CONSTRAINTS_TIMEDEPEND; } else if (con->type == CONSTRAINT_TYPE_SPLINEIK) @@ -778,10 +778,10 @@ void framechange_poses_clear_unkeyed(void) /* This needs to be done for each object that has a pose */ // TODO: proxies may/may not be correctly handled here... (this needs checking) - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* we only need to do this on objects with a pose */ - if ( (pose= ob->pose) ) { - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + if ( (pose = ob->pose) ) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone) pchan->bone->flag &= ~BONE_UNKEYED; } @@ -792,26 +792,26 @@ void framechange_poses_clear_unkeyed(void) /* ************************** Bone Groups ************************** */ /* Adds a new bone-group */ -void pose_add_group(Object *ob) +void BKE_pose_add_group(Object *ob) { - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bActionGroup *grp; if (ELEM(NULL, ob, ob->pose)) return; - grp= MEM_callocN(sizeof(bActionGroup), "PoseGroup"); + grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup"); BLI_strncpy(grp->name, "Group", sizeof(grp->name)); BLI_addtail(&pose->agroups, grp); BLI_uniquename(&pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); - pose->active_group= BLI_countlist(&pose->agroups); + pose->active_group = BLI_countlist(&pose->agroups); } /* Remove the active bone-group */ -void pose_remove_group(Object *ob) +void BKE_pose_remove_group(Object *ob) { - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bActionGroup *grp = NULL; bPoseChannel *pchan; @@ -822,15 +822,15 @@ void pose_remove_group(Object *ob) return; /* get group to remove */ - grp= BLI_findlink(&pose->agroups, pose->active_group-1); + grp = BLI_findlink(&pose->agroups, pose->active_group - 1); if (grp) { /* adjust group references (the trouble of using indices!): * - firstly, make sure nothing references it * - also, make sure that those after this item get corrected */ - for (pchan= pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->agrp_index == pose->active_group) - pchan->agrp_index= 0; + pchan->agrp_index = 0; else if (pchan->agrp_index > pose->active_group) pchan->agrp_index--; } @@ -839,7 +839,7 @@ void pose_remove_group(Object *ob) BLI_freelinkN(&pose->agroups, grp); pose->active_group--; if (pose->active_group < 0 || pose->agroups.first == NULL) { - pose->active_group= 0; + pose->active_group = 0; } } } @@ -853,7 +853,7 @@ short action_has_motion(const bAction *act) /* return on the first F-Curve that has some keyframes/samples defined */ if (act) { - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { if (fcu->totvert) return 1; } @@ -867,11 +867,11 @@ short action_has_motion(const bAction *act) void calc_action_range(const bAction *act, float *start, float *end, short incl_modifiers) { FCurve *fcu; - float min=999999999.0f, max=-999999999.0f; - short foundvert=0, foundmod=0; + float min = 999999999.0f, max = -999999999.0f; + short foundvert = 0, foundmod = 0; if (act) { - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { /* if curve has keyframes, consider them first */ if (fcu->totvert) { float nmin, nmax; @@ -881,65 +881,65 @@ void calc_action_range(const bAction *act, float *start, float *end, short incl_ calc_fcurve_range(fcu, &nmin, &nmax, FALSE, TRUE); /* compare to the running tally */ - min= MIN2(min, nmin); - max= MAX2(max, nmax); + min = MIN2(min, nmin); + max = MAX2(max, nmax); - foundvert= 1; + foundvert = 1; } /* if incl_modifiers is enabled, need to consider modifiers too * - only really care about the last modifier */ if ((incl_modifiers) && (fcu->modifiers.last)) { - FModifier *fcm= fcu->modifiers.last; + FModifier *fcm = fcu->modifiers.last; /* only use the maximum sensible limits of the modifiers if they are more extreme */ switch (fcm->type) { case FMODIFIER_TYPE_LIMITS: /* Limits F-Modifier */ { - FMod_Limits *fmd= (FMod_Limits *)fcm->data; + FMod_Limits *fmd = (FMod_Limits *)fcm->data; if (fmd->flag & FCM_LIMIT_XMIN) { - min= MIN2(min, fmd->rect.xmin); + min = MIN2(min, fmd->rect.xmin); } if (fmd->flag & FCM_LIMIT_XMAX) { - max= MAX2(max, fmd->rect.xmax); + max = MAX2(max, fmd->rect.xmax); } } - break; + break; case FMODIFIER_TYPE_CYCLES: /* Cycles F-Modifier */ { - FMod_Cycles *fmd= (FMod_Cycles *)fcm->data; + FMod_Cycles *fmd = (FMod_Cycles *)fcm->data; if (fmd->before_mode != FCM_EXTRAPOLATE_NONE) - min= MINAFRAMEF; + min = MINAFRAMEF; if (fmd->after_mode != FCM_EXTRAPOLATE_NONE) - max= MAXFRAMEF; + max = MAXFRAMEF; } - break; + break; // TODO: function modifier may need some special limits default: /* all other standard modifiers are on the infinite range... */ - min= MINAFRAMEF; - max= MAXFRAMEF; + min = MINAFRAMEF; + max = MAXFRAMEF; break; } - foundmod= 1; + foundmod = 1; } } } if (foundvert || foundmod) { - if (min==max) max+= 1.0f; - *start= min; - *end= max; + if (min == max) max += 1.0f; + *start = min; + *end = max; } else { - *start= 0.0f; - *end= 1.0f; + *start = 0.0f; + *end = 1.0f; } } @@ -950,8 +950,8 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, { PointerRNA ptr; FCurve *fcu; - char *basePath=NULL; - short flags=0; + char *basePath = NULL; + short flags = 0; /* build PointerRNA from provided data to obtain the paths to use */ if (pchan) @@ -962,15 +962,15 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, return 0; /* get the basic path to the properties of interest */ - basePath= RNA_path_from_ID_to_struct(&ptr); + basePath = RNA_path_from_ID_to_struct(&ptr); if (basePath == NULL) return 0; /* search F-Curves for the given properties * - we cannot use the groups, since they may not be grouped in that way... */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { - char *bPtr=NULL, *pPtr=NULL; + for (fcu = act->curves.first; fcu; fcu = fcu->next) { + char *bPtr = NULL, *pPtr = NULL; /* if enough flags have been found, we can stop checking unless we're also getting the curves */ if ((flags == ACT_TRANS_ALL) && (curves == NULL)) @@ -981,7 +981,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, continue; /* step 1: check for matching base path */ - bPtr= strstr(fcu->rna_path, basePath); + bPtr = strstr(fcu->rna_path, basePath); if (bPtr) { /* we must add len(basePath) bytes to the match so that we are at the end of the @@ -991,13 +991,13 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, /* step 2: check for some property with transforms * - to speed things up, only check for the ones not yet found - * unless we're getting the curves too + * unless we're getting the curves too * - if we're getting the curves, the BLI_genericNodeN() creates a LinkData * node wrapping the F-Curve, which then gets added to the list * - once a match has been found, the curve cannot possibly be any other one */ if ((curves) || (flags & ACT_TRANS_LOC) == 0) { - pPtr= strstr(bPtr, "location"); + pPtr = strstr(bPtr, "location"); if (pPtr) { flags |= ACT_TRANS_LOC; @@ -1008,7 +1008,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, } if ((curves) || (flags & ACT_TRANS_SCALE) == 0) { - pPtr= strstr(bPtr, "scale"); + pPtr = strstr(bPtr, "scale"); if (pPtr) { flags |= ACT_TRANS_SCALE; @@ -1019,7 +1019,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, } if ((curves) || (flags & ACT_TRANS_ROT) == 0) { - pPtr= strstr(bPtr, "rotation"); + pPtr = strstr(bPtr, "rotation"); if (pPtr) { flags |= ACT_TRANS_ROT; @@ -1031,7 +1031,7 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, if ((curves) || (flags & ACT_TRANS_PROP) == 0) { /* custom properties only */ - pPtr= strstr(bPtr, "[\""); /* extra '"' comment here to keep my texteditor functionlist working :) */ + pPtr = strstr(bPtr, "[\""); /* extra '"' comment here to keep my texteditor functionlist working :) */ if (pPtr) { flags |= ACT_TRANS_PROP; @@ -1059,20 +1059,20 @@ short action_get_item_transforms(bAction *act, Object *ob, bPoseChannel *pchan, void extract_pose_from_pose(bPose *pose, const bPose *src) { const bPoseChannel *schan; - bPoseChannel *pchan= pose->chanbase.first; + bPoseChannel *pchan = pose->chanbase.first; - if (pose==src) { + if (pose == src) { printf("extract_pose_from_pose source and target are the same\n"); return; } - for (schan=src->chanbase.first; (schan && pchan); schan=schan->next, pchan= pchan->next) { + for (schan = src->chanbase.first; (schan && pchan); schan = schan->next, pchan = pchan->next) { copy_pose_channel_data(pchan, schan); } } /* for do_all_pose_actions, clears the pose. Now also exported for proxy and tools */ -void rest_pose(bPose *pose) +void BKE_pose_rest(bPose *pose) { bPoseChannel *pchan; @@ -1082,35 +1082,35 @@ void rest_pose(bPose *pose) memset(pose->stride_offset, 0, sizeof(pose->stride_offset)); memset(pose->cyclic_offset, 0, sizeof(pose->cyclic_offset)); - for (pchan=pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { zero_v3(pchan->loc); zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); - pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f; + pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; - pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); + pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); } } /* both poses should be in sync */ -void copy_pose_result(bPose *to, bPose *from) +void BKE_pose_copy_result(bPose *to, bPose *from) { bPoseChannel *pchanto, *pchanfrom; - if (to==NULL || from==NULL) { + if (to == NULL || from == NULL) { printf("pose result copy error to:%p from:%p\n", (void *)to, (void *)from); // debug temp return; } - if (to==from) { - printf("copy_pose_result source and target are the same\n"); + if (to == from) { + printf("BKE_pose_copy_result source and target are the same\n"); return; } - for (pchanfrom= from->chanbase.first; pchanfrom; pchanfrom= pchanfrom->next) { - pchanto= get_pose_channel(to, pchanfrom->name); + for (pchanfrom = from->chanbase.first; pchanfrom; pchanfrom = pchanfrom->next) { + pchanto = BKE_pose_channel_find_name(to, pchanfrom->name); if (pchanto) { copy_m4_m4(pchanto->pose_mat, pchanfrom->pose_mat); copy_m4_m4(pchanto->chan_mat, pchanfrom->chan_mat); @@ -1124,9 +1124,9 @@ void copy_pose_result(bPose *to, bPose *from) copy_v3_v3(pchanto->pose_head, pchanfrom->pose_head); copy_v3_v3(pchanto->pose_tail, pchanfrom->pose_tail); - pchanto->rotmode= pchanfrom->rotmode; - pchanto->flag= pchanfrom->flag; - pchanto->protectflag= pchanfrom->protectflag; + pchanto->rotmode = pchanfrom->rotmode; + pchanto->flag = pchanfrom->flag; + pchanto->protectflag = pchanfrom->protectflag; } } } @@ -1136,31 +1136,31 @@ void copy_pose_result(bPose *to, bPose *from) */ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, char groupname[], float cframe) { - bActionGroup *agrp= action_groups_find_named(act, groupname); + bActionGroup *agrp = BKE_action_group_find_name(act, groupname); /* clear workob */ - clear_workob(workob); + BKE_object_workob_clear(workob); /* init workob */ copy_m4_m4(workob->obmat, ob->obmat); copy_m4_m4(workob->parentinv, ob->parentinv); copy_m4_m4(workob->constinv, ob->constinv); - workob->parent= ob->parent; + workob->parent = ob->parent; - workob->rotmode= ob->rotmode; + workob->rotmode = ob->rotmode; - workob->trackflag= ob->trackflag; - workob->upflag= ob->upflag; + workob->trackflag = ob->trackflag; + workob->upflag = ob->upflag; - workob->partype= ob->partype; - workob->par1= ob->par1; - workob->par2= ob->par2; - workob->par3= ob->par3; + workob->partype = ob->partype; + workob->par1 = ob->par1; + workob->par2 = ob->par2; + workob->par3 = ob->par3; workob->constraints.first = ob->constraints.first; workob->constraints.last = ob->constraints.last; - workob->pose= pose; /* need to set pose too, since this is used for both types of Action Constraint */ + workob->pose = pose; /* need to set pose too, since this is used for both types of Action Constraint */ BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); BLI_strncpy(workob->id.name, "OB", sizeof(workob->id.name)); /* we don't use real object name, otherwise RNA screws with the real thing */ @@ -1177,13 +1177,13 @@ void what_does_obaction(Object *ob, Object *workob, bPose *pose, bAction *act, c animsys_evaluate_action_group(&id_ptr, act, agrp, NULL, cframe); } else { - AnimData adt= {NULL}; + AnimData adt = {NULL}; /* init animdata, and attach to workob */ - workob->adt= &adt; + workob->adt = &adt; - adt.recalc= ADT_RECALC_ANIM; - adt.action= act; + adt.recalc = ADT_RECALC_ANIM; + adt.action = act; /* execute effects of Action on to workob (or it's PoseChannels) */ BKE_animsys_evaluate_animdata(NULL, &workob->id, &adt, cframe, ADT_RECALC_ANIM); @@ -1207,7 +1207,7 @@ static void blend_pose_strides(bPose *dst, bPose *src, float srcweight, short mo case ACTSTRIPMODE_ADD: dstweight = 1.0F; break; - default : + default: dstweight = 1.0F; } @@ -1238,30 +1238,30 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, /* matching offset bones */ /* take dst offset, and put src on on that location */ - if (strip->offs_bone[0]==0) + if (strip->offs_bone[0] == 0) return; /* are we also blending with matching bones? */ - if (strip->prev && strip->start>=strip->prev->start) { - bPoseChannel *dpchan= get_pose_channel(dst, strip->offs_bone); + if (strip->prev && strip->start >= strip->prev->start) { + bPoseChannel *dpchan = BKE_pose_channel_find_name(dst, strip->offs_bone); if (dpchan) { - bPoseChannel *spchan= get_pose_channel(src, strip->offs_bone); + bPoseChannel *spchan = BKE_pose_channel_find_name(src, strip->offs_bone); if (spchan) { float vec[3]; /* dst->ctime has the internal strip->prev action time */ /* map this time to nla time */ - float ctime= get_actionstrip_frame(strip, src->ctime, 1); + float ctime = get_actionstrip_frame(strip, src->ctime, 1); - if ( ctime > strip->prev->end) { + if (ctime > strip->prev->end) { bActionChannel *achan; /* add src to dest, minus the position of src on strip->prev->end */ - ctime= get_actionstrip_frame(strip, strip->prev->end, 0); + ctime = get_actionstrip_frame(strip, strip->prev->end, 0); - achan= get_action_channel(strip->act, strip->offs_bone); + achan = get_action_channel(strip->act, strip->offs_bone); if (achan && achan->ipo) { bPoseChannel pchan; /* Evaluates and sets the internal ipo value */ @@ -1298,63 +1298,63 @@ static void blend_pose_offset_bone(bActionStrip *strip, bPose *dst, bPose *src, */ static float stridechannel_frame(Object *ob, float sizecorr, bActionStrip *strip, Path *path, float pathdist, float *stride_offset) { - bAction *act= strip->act; - const char *name= strip->stridechannel; - bActionChannel *achan= get_action_channel(act, name); - int stride_axis= strip->stride_axis; + bAction *act = strip->act; + const char *name = strip->stridechannel; + bActionChannel *achan = get_action_channel(act, name); + int stride_axis = strip->stride_axis; if (achan && achan->ipo) { - IpoCurve *icu= NULL; - float minx=0.0f, maxx=0.0f, miny=0.0f, maxy=0.0f; - int foundvert= 0; - - if (stride_axis==0) stride_axis= AC_LOC_X; - else if (stride_axis==1) stride_axis= AC_LOC_Y; - else stride_axis= AC_LOC_Z; + IpoCurve *icu = NULL; + float minx = 0.0f, maxx = 0.0f, miny = 0.0f, maxy = 0.0f; + int foundvert = 0; + + if (stride_axis == 0) stride_axis = AC_LOC_X; + else if (stride_axis == 1) stride_axis = AC_LOC_Y; + else stride_axis = AC_LOC_Z; /* calculate the min/max */ - for (icu=achan->ipo->curve.first; icu; icu=icu->next) { - if (icu->adrcode==stride_axis) { - if (icu->totvert>1) { - foundvert= 1; - minx= icu->bezt[0].vec[1][0]; - maxx= icu->bezt[icu->totvert-1].vec[1][0]; + for (icu = achan->ipo->curve.first; icu; icu = icu->next) { + if (icu->adrcode == stride_axis) { + if (icu->totvert > 1) { + foundvert = 1; + minx = icu->bezt[0].vec[1][0]; + maxx = icu->bezt[icu->totvert - 1].vec[1][0]; - miny= icu->bezt[0].vec[1][1]; - maxy= icu->bezt[icu->totvert-1].vec[1][1]; + miny = icu->bezt[0].vec[1][1]; + maxy = icu->bezt[icu->totvert - 1].vec[1][1]; } break; } } - if (foundvert && miny!=maxy) { - float stridelen= sizecorr*fabs(maxy-miny), striptime; + if (foundvert && miny != maxy) { + float stridelen = sizecorr * fabs(maxy - miny), striptime; float actiondist, pdist, pdistNewNormalized, offs; float vec1[4], vec2[4], dir[3]; /* internal cycling, actoffs is in frames */ - offs= stridelen*strip->actoffs/(maxx-minx); + offs = stridelen * strip->actoffs / (maxx - minx); /* amount path moves object */ - pdist = (float)fmod (pathdist+offs, stridelen); - striptime= pdist/stridelen; + pdist = (float)fmod(pathdist + offs, stridelen); + striptime = pdist / stridelen; /* amount stride bone moves */ - actiondist= sizecorr*eval_icu(icu, minx + striptime*(maxx-minx)) - miny; + actiondist = sizecorr * eval_icu(icu, minx + striptime * (maxx - minx)) - miny; pdist = fabs(actiondist) - pdist; - pdistNewNormalized = (pathdist+pdist)/path->totdist; + pdistNewNormalized = (pathdist + pdist) / path->totdist; /* now we need to go pdist further (or less) on cu path */ - where_on_path(ob, (pathdist)/path->totdist, vec1, dir); /* vec needs size 4 */ + where_on_path(ob, (pathdist) / path->totdist, vec1, dir); /* vec needs size 4 */ if (pdistNewNormalized <= 1) { // search for correction in positive path-direction - where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ + where_on_path(ob, pdistNewNormalized, vec2, dir); /* vec needs size 4 */ sub_v3_v3v3(stride_offset, vec2, vec1); } else { // we reached the end of the path, search backwards instead - where_on_path(ob, (pathdist-pdist)/path->totdist, vec2, dir); /* vec needs size 4 */ + where_on_path(ob, (pathdist - pdist) / path->totdist, vec2, dir); /* vec needs size 4 */ sub_v3_v3v3(stride_offset, vec1, vec2); } mul_mat3_m4_v3(ob->obmat, stride_offset); @@ -1368,52 +1368,52 @@ static void cyclic_offs_bone(Object *ob, bPose *pose, bActionStrip *strip, float { /* only called when strip has cyclic, so >= 1.0f works... */ if (time >= 1.0f) { - bActionChannel *achan= get_action_channel(strip->act, strip->offs_bone); + bActionChannel *achan = get_action_channel(strip->act, strip->offs_bone); if (achan && achan->ipo) { - IpoCurve *icu= NULL; + IpoCurve *icu = NULL; Bone *bone; - float min[3]={0.0f, 0.0f, 0.0f}, max[3]={0.0f, 0.0f, 0.0f}; - int index=0, foundvert= 0; + float min[3] = {0.0f, 0.0f, 0.0f}, max[3] = {0.0f, 0.0f, 0.0f}; + int index = 0, foundvert = 0; /* calculate the min/max */ - for (icu=achan->ipo->curve.first; icu; icu=icu->next) { - if (icu->totvert>1) { + for (icu = achan->ipo->curve.first; icu; icu = icu->next) { + if (icu->totvert > 1) { - if (icu->adrcode==AC_LOC_X) - index= 0; - else if (icu->adrcode==AC_LOC_Y) - index= 1; - else if (icu->adrcode==AC_LOC_Z) - index= 2; + if (icu->adrcode == AC_LOC_X) + index = 0; + else if (icu->adrcode == AC_LOC_Y) + index = 1; + else if (icu->adrcode == AC_LOC_Z) + index = 2; else continue; - foundvert= 1; - min[index]= icu->bezt[0].vec[1][1]; - max[index]= icu->bezt[icu->totvert-1].vec[1][1]; + foundvert = 1; + min[index] = icu->bezt[0].vec[1][1]; + max[index] = icu->bezt[icu->totvert - 1].vec[1][1]; } } if (foundvert) { /* bring it into armature space */ sub_v3_v3v3(min, max, min); - bone= get_named_bone(ob->data, strip->offs_bone); /* weak */ + bone = BKE_armature_find_bone_name(ob->data, strip->offs_bone); /* weak */ if (bone) { mul_mat3_m4_v3(bone->arm_mat, min); - /* dominant motion, cyclic_offset was cleared in rest_pose */ + /* dominant motion, cyclic_offset was cleared in BKE_pose_rest */ if (strip->flag & (ACTSTRIP_CYCLIC_USEX | ACTSTRIP_CYCLIC_USEY | ACTSTRIP_CYCLIC_USEZ)) { - if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0]= time*min[0]; - if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1]= time*min[1]; - if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2]= time*min[2]; + if (strip->flag & ACTSTRIP_CYCLIC_USEX) pose->cyclic_offset[0] = time * min[0]; + if (strip->flag & ACTSTRIP_CYCLIC_USEY) pose->cyclic_offset[1] = time * min[1]; + if (strip->flag & ACTSTRIP_CYCLIC_USEZ) pose->cyclic_offset[2] = time * min[2]; } else { - if ( fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2])) - pose->cyclic_offset[0]= time*min[0]; - else if ( fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2])) - pose->cyclic_offset[1]= time*min[1]; + if (fabs(min[0]) >= fabs(min[1]) && fabs(min[0]) >= fabs(min[2])) + pose->cyclic_offset[0] = time * min[0]; + else if (fabs(min[1]) >= fabs(min[0]) && fabs(min[1]) >= fabs(min[2])) + pose->cyclic_offset[1] = time * min[1]; else - pose->cyclic_offset[2]= time*min[2]; + pose->cyclic_offset[2] = time * min[2]; } } } @@ -1427,13 +1427,13 @@ static Object *get_parent_path(Object *ob) { bConstraint *con; - if (ob->parent && ob->parent->type==OB_CURVE) + if (ob->parent && ob->parent->type == OB_CURVE) return ob->parent; - for (con = ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) { - if (con->enforce>0.5f) { - bFollowPathConstraint *data= con->data; + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { + if (con->enforce > 0.5f) { + bFollowPathConstraint *data = con->data; return data->tar; } } @@ -1447,71 +1447,71 @@ static Object *get_parent_path(Object *ob) static void do_nla(Scene *scene, Object *ob, int blocktype) { - bPose *tpose= NULL; - Key *key= NULL; - ListBase tchanbase={NULL, NULL}, chanbase={NULL, NULL}; - bActionStrip *strip, *striplast=NULL, *stripfirst=NULL; + bPose *tpose = NULL; + Key *key = NULL; + ListBase tchanbase = {NULL, NULL}, chanbase = {NULL, NULL}; + bActionStrip *strip, *striplast = NULL, *stripfirst = NULL; float striptime, frametime, length, actlength; float blendfac, stripframe; - float scene_cfra= BKE_curframe(scene); - int doit, dostride; + float scene_cfra = BKE_scene_frame_get(scene); + int doit, dostride; - if (blocktype==ID_AR) { - copy_pose(&tpose, ob->pose, 1); - rest_pose(ob->pose); // potentially destroying current not-keyed pose + if (blocktype == ID_AR) { + BKE_pose_copy_data(&tpose, ob->pose, 1); + BKE_pose_rest(ob->pose); // potentially destroying current not-keyed pose } else { - key= ob_get_key(ob); + key = ob_get_key(ob); } /* check on extend to left or right, when no strip is hit by 'cfra' */ - for (strip=ob->nlastrips.first; strip; strip=strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { /* escape loop on a hit */ - if ( scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */ + if (scene_cfra >= strip->start && scene_cfra <= strip->end + 0.1f) /* note 0.1 comes back below */ break; if (scene_cfra < strip->start) { - if (stripfirst==NULL) - stripfirst= strip; + if (stripfirst == NULL) + stripfirst = strip; else if (stripfirst->start > strip->start) - stripfirst= strip; + stripfirst = strip; } else if (scene_cfra > strip->end) { - if (striplast==NULL) - striplast= strip; + if (striplast == NULL) + striplast = strip; else if (striplast->end < strip->end) - striplast= strip; + striplast = strip; } } - if (strip==NULL) { /* extend */ + if (strip == NULL) { /* extend */ if (striplast) - scene_cfra= striplast->end; + scene_cfra = striplast->end; else if (stripfirst) - scene_cfra= stripfirst->start; + scene_cfra = stripfirst->start; } /* and now go over all strips */ - for (strip=ob->nlastrips.first; strip; strip=strip->next) { - doit=dostride= 0; + for (strip = ob->nlastrips.first; strip; strip = strip->next) { + doit = dostride = 0; - if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */ + if (strip->act && !(strip->flag & ACTSTRIP_MUTE)) { /* so theres an action */ /* Determine if the current frame is within the strip's range */ - length = strip->end-strip->start; - actlength = strip->actend-strip->actstart; + length = strip->end - strip->start; + actlength = strip->actend - strip->actstart; striptime = (scene_cfra - strip->start) / length; stripframe = (scene_cfra - strip->start); - if (striptime>=0.0) { + if (striptime >= 0.0) { - if (blocktype==ID_AR) - rest_pose(tpose); + if (blocktype == ID_AR) + BKE_pose_rest(tpose); /* To handle repeat, we add 0.1 frame extra to make sure the last frame is included */ - if (striptime < 1.0f + 0.1f/length) { + if (striptime < 1.0f + 0.1f / length) { /* Handle path */ - if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype==ID_AR) && (ob->ipoflag & OB_DISABLE_PATH)==0) { - Object *parent= get_parent_path(ob); + if ((strip->flag & ACTSTRIP_USESTRIDE) && (blocktype == ID_AR) && (ob->ipoflag & OB_DISABLE_PATH) == 0) { + Object *parent = get_parent_path(ob); if (parent) { Curve *cu = parent->data; @@ -1519,43 +1519,43 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (cu->flag & CU_PATH) { /* Ensure we have a valid path */ - if (cu->path==NULL || cu->path->data==NULL) makeDispListCurveTypes(scene, parent, 0); + if (cu->path == NULL || cu->path->data == NULL) makeDispListCurveTypes(scene, parent, 0); if (cu->path) { /* Find the position on the path */ - ctime= bsystem_time(scene, ob, scene_cfra, 0.0); + ctime = bsystem_time(scene, ob, scene_cfra, 0.0); - if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime)==0) { + if (calc_ipo_spec(cu->ipo, CU_SPEED, &ctime) == 0) { /* correct for actions not starting on zero */ - ctime= (ctime - strip->actstart)/cu->pathlen; + ctime = (ctime - strip->actstart) / cu->pathlen; CLAMP(ctime, 0.0, 1.0); } - pdist = ctime*cu->path->totdist; + pdist = ctime * cu->path->totdist; if (tpose && strip->stridechannel[0]) { - striptime= stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset); + striptime = stridechannel_frame(parent, ob->size[0], strip, cu->path, pdist, tpose->stride_offset); } else { if (strip->stridelen) { striptime = pdist / strip->stridelen; - striptime = (float)fmod (striptime+strip->actoffs, 1.0); + striptime = (float)fmod(striptime + strip->actoffs, 1.0); } else striptime = 0; } frametime = (striptime * actlength) + strip->actstart; - frametime= bsystem_time(scene, ob, frametime, 0.0); + frametime = bsystem_time(scene, ob, frametime, 0.0); - if (blocktype==ID_AR) { - extract_pose_from_action (tpose, strip->act, frametime); + if (blocktype == ID_AR) { + extract_pose_from_action(tpose, strip->act, frametime); } - else if (blocktype==ID_OB) { + else if (blocktype == ID_OB) { extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); if (key) extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); } - doit=dostride= 1; + doit = dostride = 1; } } } @@ -1564,29 +1564,29 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) else { /* Mod to repeat */ - if (strip->repeat!=1.0f) { - float cycle= striptime*strip->repeat; + if (strip->repeat != 1.0f) { + float cycle = striptime * strip->repeat; - striptime = (float)fmod (cycle, 1.0f + 0.1f/length); - cycle-= striptime; + striptime = (float)fmod(cycle, 1.0f + 0.1f / length); + cycle -= striptime; - if (blocktype==ID_AR) + if (blocktype == ID_AR) cyclic_offs_bone(ob, tpose, strip, cycle); } frametime = (striptime * actlength) + strip->actstart; - frametime= nla_time(scene, frametime, (float)strip->repeat); + frametime = nla_time(scene, frametime, (float)strip->repeat); - if (blocktype==ID_AR) { - extract_pose_from_action (tpose, strip->act, frametime); + if (blocktype == ID_AR) { + extract_pose_from_action(tpose, strip->act, frametime); } - else if (blocktype==ID_OB) { + else if (blocktype == ID_OB) { extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); if (key) extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); } - doit=1; + doit = 1; } } /* Handle extend */ @@ -1594,25 +1594,25 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (strip->flag & ACTSTRIP_HOLDLASTFRAME) { /* we want the strip to hold on the exact fraction of the repeat value */ - frametime = actlength * (strip->repeat-(int)strip->repeat); - if (frametime<=0.000001f) frametime= actlength; /* rounding errors... */ - frametime= bsystem_time(scene, ob, frametime+strip->actstart, 0.0); - - if (blocktype==ID_AR) - extract_pose_from_action (tpose, strip->act, frametime); - else if (blocktype==ID_OB) { + frametime = actlength * (strip->repeat - (int)strip->repeat); + if (frametime <= 0.000001f) frametime = actlength; /* rounding errors... */ + frametime = bsystem_time(scene, ob, frametime + strip->actstart, 0.0); + + if (blocktype == ID_AR) + extract_pose_from_action(tpose, strip->act, frametime); + else if (blocktype == ID_OB) { extract_ipochannels_from_action(&tchanbase, &ob->id, strip->act, "Object", frametime); if (key) extract_ipochannels_from_action(&tchanbase, &key->id, strip->act, "Shape", frametime); } /* handle cycle hold */ - if (strip->repeat!=1.0f) { - if (blocktype==ID_AR) - cyclic_offs_bone(ob, tpose, strip, strip->repeat-1.0f); + if (strip->repeat != 1.0f) { + if (blocktype == ID_AR) + cyclic_offs_bone(ob, tpose, strip, strip->repeat - 1.0f); } - doit=1; + doit = 1; } } @@ -1620,22 +1620,22 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) if (doit) { /* Handle blendin */ - if (strip->blendin>0.0 && stripframe<=strip->blendin && scene_cfra>=strip->start) { - blendfac = stripframe/strip->blendin; + if (strip->blendin > 0.0 && stripframe <= strip->blendin && scene_cfra >= strip->start) { + blendfac = stripframe / strip->blendin; } - else if (strip->blendout>0.0 && stripframe>=(length-strip->blendout) && scene_cfra<=strip->end) { - blendfac = (length-stripframe)/(strip->blendout); + else if (strip->blendout > 0.0 && stripframe >= (length - strip->blendout) && scene_cfra <= strip->end) { + blendfac = (length - stripframe) / (strip->blendout); } else blendfac = 1; - if (blocktype==ID_AR) {/* Blend this pose with the accumulated pose */ + if (blocktype == ID_AR) { /* Blend this pose with the accumulated pose */ /* offset bone, for matching cycles */ - blend_pose_offset_bone (strip, ob->pose, tpose, blendfac, strip->mode); + blend_pose_offset_bone(strip, ob->pose, tpose, blendfac, strip->mode); - blend_poses (ob->pose, tpose, blendfac, strip->mode); + blend_poses(ob->pose, tpose, blendfac, strip->mode); if (dostride) - blend_pose_strides (ob->pose, tpose, blendfac, strip->mode); + blend_pose_strides(ob->pose, tpose, blendfac, strip->mode); } else { blend_ipochannels(&chanbase, &tchanbase, blendfac, strip->mode); @@ -1646,17 +1646,17 @@ static void do_nla(Scene *scene, Object *ob, int blocktype) } } - if (blocktype==ID_OB) { + if (blocktype == ID_OB) { execute_ipochannels(&chanbase); } - else if (blocktype==ID_AR) { + else if (blocktype == ID_AR) { /* apply stride offset to object */ add_v3_v3(ob->obmat[3], ob->pose->stride_offset); } /* free */ if (tpose) - free_pose(tpose); + BKE_pose_free(tpose); if (chanbase.first) BLI_freelistN(&chanbase); } diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index afa4723bc6d..ed6eceb036b 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -88,23 +88,23 @@ void animviz_settings_init(bAnimVizSettings *avs) return; /* ghosting settings */ - avs->ghost_bc= avs->ghost_ac= 10; + avs->ghost_bc = avs->ghost_ac = 10; - avs->ghost_sf= 1; // xxx - take from scene instead? - avs->ghost_ef= 250; // xxx - take from scene instead? + avs->ghost_sf = 1; // xxx - take from scene instead? + avs->ghost_ef = 250; // xxx - take from scene instead? - avs->ghost_step= 1; + avs->ghost_step = 1; /* path settings */ - avs->path_bc= avs->path_ac= 10; + avs->path_bc = avs->path_ac = 10; - avs->path_sf= 1; // xxx - take from scene instead? - avs->path_ef= 250; // xxx - take from scene instead? + avs->path_sf = 1; // xxx - take from scene instead? + avs->path_ef = 250; // xxx - take from scene instead? - avs->path_viewflag= (MOTIONPATH_VIEW_KFRAS|MOTIONPATH_VIEW_KFNOS); + avs->path_viewflag = (MOTIONPATH_VIEW_KFRAS | MOTIONPATH_VIEW_KFNOS); - avs->path_step= 1; + avs->path_step = 1; } /* ------------------- */ @@ -121,8 +121,8 @@ void animviz_free_motionpath_cache(bMotionPath *mpath) MEM_freeN(mpath->points); /* reset the relevant parameters */ - mpath->points= NULL; - mpath->length= 0; + mpath->points = NULL; + mpath->length = 0; } /* Free the given motion path instance and its data @@ -162,22 +162,22 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec /* get destination data */ if (pchan) { /* paths for posechannel - assume that posechannel belongs to the object */ - avs= &ob->pose->avs; - dst= &pchan->mpath; + avs = &ob->pose->avs; + dst = &pchan->mpath; } else { /* paths for object */ - avs= &ob->avs; - dst= &ob->mpath; + avs = &ob->avs; + dst = &ob->mpath; } /* avoid 0 size allocs */ if (avs->path_sf >= avs->path_ef) { BKE_reportf(reports, RPT_ERROR, - "Motion Path frame extents invalid for %s (%d to %d).%s\n", - (pchan)? pchan->name : ob->id.name, - avs->path_sf, avs->path_ef, - (avs->path_sf == avs->path_ef)? " Cannot have single-frame paths." : ""); + "Motion Path frame extents invalid for %s (%d to %d).%s\n", + (pchan) ? pchan->name : ob->id.name, + avs->path_sf, avs->path_ef, + (avs->path_sf == avs->path_ef) ? " Cannot have single-frame paths." : ""); return NULL; } @@ -187,7 +187,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec if (*dst != NULL) { int expected_length = avs->path_ef - avs->path_sf; - mpath= *dst; + mpath = *dst; /* path is "valid" if length is valid, but must also be of the same length as is being requested */ if ((mpath->start_frame != mpath->end_frame) && (mpath->length > 0)) { @@ -204,15 +204,15 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec } else { /* create a new motionpath, and assign it */ - mpath= MEM_callocN(sizeof(bMotionPath), "bMotionPath"); - *dst= mpath; + mpath = MEM_callocN(sizeof(bMotionPath), "bMotionPath"); + *dst = mpath; } /* set settings from the viz settings */ - mpath->start_frame= avs->path_sf; - mpath->end_frame= avs->path_ef; + mpath->start_frame = avs->path_sf; + mpath->end_frame = avs->path_ef; - mpath->length= mpath->end_frame - mpath->start_frame; + mpath->length = mpath->end_frame - mpath->start_frame; if (avs->path_bakeflag & MOTIONPATH_BAKE_HEADS) mpath->flag |= MOTIONPATH_FLAG_BHEAD; @@ -220,7 +220,7 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec mpath->flag &= ~MOTIONPATH_FLAG_BHEAD; /* allocate a cache */ - mpath->points= MEM_callocN(sizeof(bMotionPathVert)*mpath->length, "bMotionPathVerts"); + mpath->points = MEM_callocN(sizeof(bMotionPathVert) * mpath->length, "bMotionPathVerts"); /* tag viz settings as currently having some path(s) which use it */ avs->path_bakeflag |= MOTIONPATH_BAKE_HAS_PATHS; @@ -235,16 +235,16 @@ bMotionPath *animviz_verify_motionpaths(ReportList *reports, Scene *scene, Objec typedef struct MPathTarget { struct MPathTarget *next, *prev; - bMotionPath *mpath; /* motion path in question */ + bMotionPath *mpath; /* motion path in question */ - Object *ob; /* source object */ - bPoseChannel *pchan; /* source posechannel (if applicable) */ + Object *ob; /* source object */ + bPoseChannel *pchan; /* source posechannel (if applicable) */ } MPathTarget; /* ........ */ /* get list of motion paths to be baked for the given object - * - assumes the given list is ready to be used + * - assumes the given list is ready to be used */ // TODO: it would be nice in future to be able to update objects dependent on these bones too? void animviz_get_object_motionpaths(Object *ob, ListBase *targets) @@ -254,27 +254,27 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets) /* object itself first */ if ((ob->avs.recalc & ANIMVIZ_RECALC_PATHS) && (ob->mpath)) { /* new target for object */ - mpt= MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob"); + mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget Ob"); BLI_addtail(targets, mpt); - mpt->mpath= ob->mpath; - mpt->ob= ob; + mpt->mpath = ob->mpath; + mpt->ob = ob; } /* bones */ if ((ob->pose) && (ob->pose->avs.recalc & ANIMVIZ_RECALC_PATHS)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((pchan->bone) && (arm->layer & pchan->bone->layer) && (pchan->mpath)) { /* new target for bone */ - mpt= MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"); + mpt = MEM_callocN(sizeof(MPathTarget), "MPathTarget PoseBone"); BLI_addtail(targets, mpt); - mpt->mpath= pchan->mpath; - mpt->ob= ob; - mpt->pchan= pchan; + mpt->mpath = pchan->mpath; + mpt->ob = ob; + mpt->pchan = pchan; } } } @@ -296,12 +296,12 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) MPathTarget *mpt; /* make sure our temp-tag isn't already in use */ - for (base= scene->base.first; base; base= base->next) + for (base = scene->base.first; base; base = base->next) base->object->flag &= ~BA_TEMP_TAG; /* for each target, dump its object to the start of the list if it wasn't moved already */ - for (mpt= targets->first; mpt; mpt= mpt->next) { - for (base=scene->base.first; base; base=baseNext) { + for (mpt = targets->first; mpt; mpt = mpt->next) { + for (base = scene->base.first; base; base = baseNext) { baseNext = base->next; if ((base->object == mpt->ob) && !(mpt->ob->flag & BA_TEMP_TAG)) { @@ -322,7 +322,7 @@ static void motionpaths_calc_optimise_depsgraph(Scene *scene, ListBase *targets) static void motionpaths_calc_update_scene(Scene *scene) { #if 1 // 'production' optimisations always on - Base *base, *last=NULL; + Base *base, *last = NULL; /* only stuff that moves or needs display still */ DAG_scene_update_flags(G.main, scene, scene->lay, TRUE); @@ -331,7 +331,7 @@ static void motionpaths_calc_update_scene(Scene *scene) * - all those afterwards are assumed to not be relevant for our calculations */ // optimize further by moving out... - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->object->flag & BA_TEMP_TAG) last = base; } @@ -339,21 +339,21 @@ static void motionpaths_calc_update_scene(Scene *scene) /* perform updates for tagged objects */ // XXX: this will break if rigs depend on scene or other data that // is animated but not attached to/updatable from objects - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { /* update this object */ - object_handle_update(scene, base->object); + BKE_object_handle_update(scene, base->object); /* if this is the last one we need to update, let's stop to save some time */ if (base == last) break; } #else // original, 'always correct' version - /* do all updates - * - if this is too slow, resort to using a more efficient way - * that doesn't force complete update, but for now, this is the - * most accurate way! - */ - scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving + /* do all updates + * - if this is too slow, resort to using a more efficient way + * that doesn't force complete update, but for now, this is the + * most accurate way! + */ + BKE_scene_update_for_newframe(G.main, scene, scene->lay); // XXX this is the best way we can get anything moving #endif } @@ -365,8 +365,8 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) MPathTarget *mpt; /* for each target, check if it can be baked on the current frame */ - for (mpt= targets->first; mpt; mpt= mpt->next) { - bMotionPath *mpath= mpt->mpath; + for (mpt = targets->first; mpt; mpt = mpt->next) { + bMotionPath *mpath = mpt->mpath; bMotionPathVert *mpv; /* current frame must be within the range the cache works for @@ -376,7 +376,7 @@ static void motionpaths_calc_bake_targets(Scene *scene, ListBase *targets) continue; /* get the relevant cache vert to write to */ - mpv= mpath->points + (CFRA - mpath->start_frame); + mpv = mpath->points + (CFRA - mpath->start_frame); /* pose-channel or object path baking? */ if (mpt->pchan) { @@ -421,10 +421,10 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) // TODO: this method could be improved... // 1) max range for standard baking // 2) minimum range for recalc baking (i.e. between keyframes, but how?) - for (mpt= targets->first; mpt; mpt= mpt->next) { + for (mpt = targets->first; mpt; mpt = mpt->next) { /* try to increase area to do (only as much as needed) */ - sfra= MIN2(sfra, mpt->mpath->start_frame); - efra= MAX2(efra, mpt->mpath->end_frame); + sfra = MIN2(sfra, mpt->mpath->start_frame); + efra = MAX2(efra, mpt->mpath->end_frame); } if (efra <= sfra) return; @@ -433,7 +433,7 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) motionpaths_calc_optimise_depsgraph(scene, targets); /* calculate path over requested range */ - for (CFRA=sfra; CFRA<=efra; CFRA++) { + for (CFRA = sfra; CFRA <= efra; CFRA++) { /* update relevant data for new frame */ motionpaths_calc_update_scene(scene); @@ -442,18 +442,18 @@ void animviz_calc_motionpaths(Scene *scene, ListBase *targets) } /* reset original environment */ - CFRA= cfra; + CFRA = cfra; motionpaths_calc_update_scene(scene); /* clear recalc flags from targets */ - for (mpt= targets->first; mpt; mpt= mpt->next) { + for (mpt = targets->first; mpt; mpt = mpt->next) { bAnimVizSettings *avs; /* get pointer to animviz settings for each target */ if (mpt->pchan) - avs= &mpt->ob->pose->avs; + avs = &mpt->ob->pose->avs; else - avs= &mpt->ob->avs; + avs = &mpt->ob->avs; /* clear the flag requesting recalculation of targets */ avs->recalc &= ~ANIMVIZ_RECALC_PATHS; @@ -474,7 +474,7 @@ void free_path(Path *path) } /* calculate a curve-deform path for a curve - * - only called from displist.c -> do_makeDispListCurveTypes + * - only called from displist.c -> do_makeDispListCurveTypes */ void calc_curvepath(Object *ob) { @@ -485,92 +485,92 @@ void calc_curvepath(Object *ob) Nurb *nu; Path *path; float *fp, *dist, *maxdist, xyz[3]; - float fac, d=0, fac1, fac2; - int a, tot, cycl=0; + float fac, d = 0, fac1, fac2; + int a, tot, cycl = 0; ListBase *nurbs; /* in a path vertices are with equal differences: path->len = number of verts */ /* NOW WITH BEVELCURVE!!! */ - if (ob==NULL || ob->type != OB_CURVE) return; - cu= ob->data; + if (ob == NULL || ob->type != OB_CURVE) return; + cu = ob->data; - nurbs= BKE_curve_nurbs_get(cu); - nu= nurbs->first; + nurbs = BKE_curve_nurbs_get(cu); + nu = nurbs->first; if (cu->path) free_path(cu->path); - cu->path= NULL; + cu->path = NULL; - bl= cu->bev.first; - if (bl==NULL || !bl->nr) return; + bl = cu->bev.first; + if (bl == NULL || !bl->nr) return; - cu->path=path= MEM_callocN(sizeof(Path), "calc_curvepath"); + cu->path = path = MEM_callocN(sizeof(Path), "calc_curvepath"); /* if POLY: last vertice != first vertice */ - cycl= (bl->poly!= -1); + cycl = (bl->poly != -1); - if (cycl) tot= bl->nr; - else tot= bl->nr-1; + if (cycl) tot = bl->nr; + else tot = bl->nr - 1; - path->len= tot+1; + path->len = tot + 1; /* exception: vector handle paths and polygon paths should be subdivided at least a factor resolu */ - if (path->lenresolu*SEGMENTSU(nu)) path->len= nu->resolu*SEGMENTSU(nu); + if (path->len < nu->resolu * SEGMENTSU(nu)) path->len = nu->resolu * SEGMENTSU(nu); - dist= (float *)MEM_mallocN((tot+1)*4, "calcpathdist"); + dist = (float *)MEM_mallocN((tot + 1) * 4, "calcpathdist"); - /* all lengths in *dist */ - bevp= bevpfirst= (BevPoint *)(bl+1); - fp= dist; - *fp= 0; - for (a=0; avec, bevp->vec); else - sub_v3_v3v3(xyz, (bevp+1)->vec, bevp->vec); + sub_v3_v3v3(xyz, (bevp + 1)->vec, bevp->vec); - *fp= *(fp-1)+len_v3(xyz); + *fp = *(fp - 1) + len_v3(xyz); bevp++; } - path->totdist= *fp; + path->totdist = *fp; - /* the path verts in path->data */ - /* now also with TILT value */ - pp= path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint)*path->len, "pathdata"); + /* the path verts in path->data */ + /* now also with TILT value */ + pp = path->data = (PathPoint *)MEM_callocN(sizeof(PathPoint) * path->len, "pathdata"); + + bevp = bevpfirst; + bevpn = bevp + 1; + bevplast = bevpfirst + (bl->nr - 1); + fp = dist + 1; + maxdist = dist + tot; + fac = 1.0f / ((float)path->len - 1.0f); + fac = fac * path->totdist; - bevp= bevpfirst; - bevpn= bevp+1; - bevplast= bevpfirst + (bl->nr-1); - fp= dist+1; - maxdist= dist+tot; - fac= 1.0f/((float)path->len-1.0f); - fac = fac * path->totdist; - - for (a=0; alen; a++) { + for (a = 0; a < path->len; a++) { - d= ((float)a)*fac; + d = ((float)a) * fac; /* we're looking for location (distance) 'd' in the array */ - while ((d>= *fp) && fp= *fp) && fp < maxdist) { fp++; - if (bevpbevplast) { - if (cycl) bevpn= bevpfirst; - else bevpn= bevplast; + if (bevp < bevplast) bevp++; + bevpn = bevp + 1; + if (bevpn > bevplast) { + if (cycl) bevpn = bevpfirst; + else bevpn = bevplast; } } - fac1= *(fp)- *(fp-1); - fac2= *(fp)-d; - fac1= fac2/fac1; - fac2= 1.0f-fac1; + fac1 = *(fp) - *(fp - 1); + fac2 = *(fp) - d; + fac1 = fac2 / fac1; + fac2 = 1.0f - fac1; interp_v3_v3v3(pp->vec, bevp->vec, bevpn->vec, fac2); - pp->vec[3]= fac1*bevp->alfa + fac2*bevpn->alfa; - pp->radius= fac1*bevp->radius + fac2*bevpn->radius; - pp->weight= fac1*bevp->weight + fac2*bevpn->weight; + pp->vec[3] = fac1 * bevp->alfa + fac2 * bevpn->alfa; + pp->radius = fac1 * bevp->radius + fac2 * bevpn->radius; + pp->weight = fac1 * bevp->weight + fac2 * bevpn->weight; interp_qt_qtqt(pp->quat, bevp->quat, bevpn->quat, fac2); normalize_qt(pp->quat); @@ -586,13 +586,13 @@ int interval_test(int min, int max, int p1, int cycl) { if (cycl) { if (p1 < min) - p1= ((p1 -min) % (max-min+1)) + max+1; + p1 = ((p1 - min) % (max - min + 1)) + max + 1; else if (p1 > max) - p1= ((p1 -min) % (max-min+1)) + min; + p1 = ((p1 - min) % (max - min + 1)) + min; } else { - if (p1 < min) p1= min; - else if (p1 > max) p1= max; + if (p1 < min) p1 = min; + else if (p1 > max) p1 = max; } return p1; } @@ -614,84 +614,84 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua PathPoint *pp, *p0, *p1, *p2, *p3; float fac; float data[4]; - int cycl=0, s0, s1, s2, s3; + int cycl = 0, s0, s1, s2, s3; - if (ob==NULL || ob->type != OB_CURVE) return 0; - cu= ob->data; - if (cu->path==NULL || cu->path->data==NULL) { + if (ob == NULL || ob->type != OB_CURVE) return 0; + cu = ob->data; + if (cu->path == NULL || cu->path->data == NULL) { printf("no path!\n"); return 0; } - path= cu->path; - pp= path->data; + path = cu->path; + pp = path->data; /* test for cyclic */ - bl= cu->bev.first; + bl = cu->bev.first; if (!bl) return 0; if (!bl->nr) return 0; - if (bl->poly> -1) cycl= 1; + if (bl->poly > -1) cycl = 1; - ctime *= (path->len-1); + ctime *= (path->len - 1); - s1= (int)floor(ctime); - fac= (float)(s1+1)-ctime; + s1 = (int)floor(ctime); + fac = (float)(s1 + 1) - ctime; /* path->len is corected for cyclic */ - s0= interval_test(0, path->len-1-cycl, s1-1, cycl); - s1= interval_test(0, path->len-1-cycl, s1, cycl); - s2= interval_test(0, path->len-1-cycl, s1+1, cycl); - s3= interval_test(0, path->len-1-cycl, s1+2, cycl); + s0 = interval_test(0, path->len - 1 - cycl, s1 - 1, cycl); + s1 = interval_test(0, path->len - 1 - cycl, s1, cycl); + s2 = interval_test(0, path->len - 1 - cycl, s1 + 1, cycl); + s3 = interval_test(0, path->len - 1 - cycl, s1 + 2, cycl); - p0= pp + s0; - p1= pp + s1; - p2= pp + s2; - p3= pp + s3; + p0 = pp + s0; + p1 = pp + s1; + p2 = pp + s2; + p3 = pp + s3; /* note, commented out for follow constraint */ //if (cu->flag & CU_FOLLOW) { - key_curve_tangent_weights(1.0f-fac, data, KEY_BSPLINE); + key_curve_tangent_weights(1.0f - fac, data, KEY_BSPLINE); - interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data); + interp_v3_v3v3v3v3(dir, p0->vec, p1->vec, p2->vec, p3->vec, data); - /* make compatible with vectoquat */ - negate_v3(dir); + /* make compatible with vectoquat */ + negate_v3(dir); //} - nu= cu->nurb.first; + nu = cu->nurb.first; /* make sure that first and last frame are included in the vectors here */ - if (nu->type == CU_POLY) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR); - else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f-fac, data, KEY_LINEAR); - else if (s0==s1 || p2==p3) key_curve_position_weights(1.0f-fac, data, KEY_CARDINAL); - else key_curve_position_weights(1.0f-fac, data, KEY_BSPLINE); + if (nu->type == CU_POLY) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); + else if (nu->type == CU_BEZIER) key_curve_position_weights(1.0f - fac, data, KEY_LINEAR); + else if (s0 == s1 || p2 == p3) key_curve_position_weights(1.0f - fac, data, KEY_CARDINAL); + else key_curve_position_weights(1.0f - fac, data, KEY_BSPLINE); - vec[0]= data[0]*p0->vec[0] + data[1]*p1->vec[0] + data[2]*p2->vec[0] + data[3]*p3->vec[0] ; /* X */ - vec[1]= data[0]*p0->vec[1] + data[1]*p1->vec[1] + data[2]*p2->vec[1] + data[3]*p3->vec[1] ; /* Y */ - vec[2]= data[0]*p0->vec[2] + data[1]*p1->vec[2] + data[2]*p2->vec[2] + data[3]*p3->vec[2] ; /* Z */ - vec[3]= data[0]*p0->vec[3] + data[1]*p1->vec[3] + data[2]*p2->vec[3] + data[3]*p3->vec[3] ; /* Tilt, should not be needed since we have quat still used */ + vec[0] = data[0] * p0->vec[0] + data[1] * p1->vec[0] + data[2] * p2->vec[0] + data[3] * p3->vec[0]; /* X */ + vec[1] = data[0] * p0->vec[1] + data[1] * p1->vec[1] + data[2] * p2->vec[1] + data[3] * p3->vec[1]; /* Y */ + vec[2] = data[0] * p0->vec[2] + data[1] * p1->vec[2] + data[2] * p2->vec[2] + data[3] * p3->vec[2]; /* Z */ + vec[3] = data[0] * p0->vec[3] + data[1] * p1->vec[3] + data[2] * p2->vec[3] + data[3] * p3->vec[3]; /* Tilt, should not be needed since we have quat still used */ if (quat) { float totfac, q1[4], q2[4]; - totfac= data[0]+data[3]; - if (totfac>FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); - else copy_qt_qt(q1, p1->quat); + totfac = data[0] + data[3]; + if (totfac > FLT_EPSILON) interp_qt_qtqt(q1, p0->quat, p3->quat, data[3] / totfac); + else copy_qt_qt(q1, p1->quat); - totfac= data[1]+data[2]; - if (totfac>FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); - else copy_qt_qt(q2, p3->quat); + totfac = data[1] + data[2]; + if (totfac > FLT_EPSILON) interp_qt_qtqt(q2, p1->quat, p2->quat, data[2] / totfac); + else copy_qt_qt(q2, p3->quat); - totfac = data[0]+data[1]+data[2]+data[3]; - if (totfac>FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1]+data[2]) / totfac); - else copy_qt_qt(quat, q2); + totfac = data[0] + data[1] + data[2] + data[3]; + if (totfac > FLT_EPSILON) interp_qt_qtqt(quat, q1, q2, (data[1] + data[2]) / totfac); + else copy_qt_qt(quat, q2); } if (radius) - *radius= data[0]*p0->radius + data[1]*p1->radius + data[2]*p2->radius + data[3]*p3->radius; + *radius = data[0] * p0->radius + data[1] * p1->radius + data[2] * p2->radius + data[3] * p3->radius; if (weight) - *weight= data[0]*p0->weight + data[1]*p1->weight + data[2]*p2->weight + data[3]*p3->weight; + *weight = data[0] * p0->weight + data[1] * p1->weight + data[2] * p2->weight + data[3] * p3->weight; return 1; } @@ -701,17 +701,17 @@ int where_on_path(Object *ob, float ctime, float vec[4], float dir[3], float qua static DupliObject *new_dupli_object(ListBase *lb, Object *ob, float mat[][4], int lay, int index, int type, int animated) { - DupliObject *dob= MEM_callocN(sizeof(DupliObject), "dupliobject"); + DupliObject *dob = MEM_callocN(sizeof(DupliObject), "dupliobject"); BLI_addtail(lb, dob); - dob->ob= ob; + dob->ob = ob; copy_m4_m4(dob->mat, mat); copy_m4_m4(dob->omat, ob->obmat); - dob->origlay= ob->lay; - dob->index= index; - dob->type= type; - dob->animated= (type == OB_DUPLIGROUP) && animated; - ob->lay= lay; + dob->origlay = ob->lay; + dob->index = index; + dob->type = type; + dob->animated = (type == OB_DUPLIGROUP) && animated; + ob->lay = lay; return dob; } @@ -723,20 +723,20 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i GroupObject *go; float mat[4][4], tmat[4][4]; - if (ob->dup_group==NULL) return; - group= ob->dup_group; + if (ob->dup_group == NULL) return; + group = ob->dup_group; /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; /* handles animated groups, and */ /* we need to check update for objects that are not in scene... */ group_handle_recalc_and_update(scene, ob, group); - animated= animated || group_is_animated(ob, group); + animated = animated || group_is_animated(ob, group); - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { /* note, if you check on layer here, render goes wrong... it still deforms verts and uses parent imat */ - if (go->ob!=ob) { + if (go->ob != ob) { /* group dupli offset, should apply after everything else */ if (!is_zero_v3(group->dupli_ofs)) { @@ -748,22 +748,22 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i mult_m4_m4m4(mat, ob->obmat, go->ob->obmat); } - dob= new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); + dob = new_dupli_object(lb, go->ob, mat, ob->lay, 0, OB_DUPLIGROUP, animated); /* check the group instance and object layers match, also that the object visible flags are ok. */ - if ( (dob->origlay & group->layer)==0 || - (G.rendering==0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || - (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER) - ) { - dob->no_draw= 1; + if ( (dob->origlay & group->layer) == 0 || + (G.rendering == 0 && dob->ob->restrictflag & OB_RESTRICT_VIEW) || + (G.rendering && dob->ob->restrictflag & OB_RESTRICT_RENDER) + ) { + dob->no_draw = 1; } else { - dob->no_draw= 0; + dob->no_draw = 0; } if (go->ob->transflag & OB_DUPLI) { copy_m4_m4(dob->ob->obmat, dob->mat); - object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level+1, animated); + object_duplilist_recursive(&group->id, scene, go->ob, lb, ob->obmat, level + 1, animated); copy_m4_m4(dob->ob->obmat, dob->omat); } } @@ -772,7 +772,7 @@ static void group_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, i static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, int animated) { - extern int enable_cu_speed; /* object.c */ + extern int enable_cu_speed; /* object.c */ Object copyob; int cfrao = scene->r.cfra; int dupend = ob->dupend; @@ -783,7 +783,7 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, /* if we don't have any data/settings which will lead to object movement, * don't waste time trying, as it will all look the same... */ - if (ob->parent==NULL && ob->constraints.first==NULL && ob->adt==NULL) + if (ob->parent == NULL && ob->constraints.first == NULL && ob->adt == NULL) return; /* make a copy of the object's original data (before any dupli-data overwrites it) @@ -794,18 +794,18 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, copyob = *ob; /* duplicate over the required range */ - if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed= 0; + if (ob->transflag & OB_DUPLINOSPEED) enable_cu_speed = 0; - for (scene->r.cfra= ob->dupsta; scene->r.cfra<=dupend; scene->r.cfra++) { - short ok= 1; + for (scene->r.cfra = ob->dupsta; scene->r.cfra <= dupend; scene->r.cfra++) { + short ok = 1; /* - dupoff = how often a frames within the range shouldn't be made into duplis * - dupon = the length of each "skipping" block in frames */ if (ob->dupoff) { - ok= scene->r.cfra - ob->dupsta; - ok= ok % (ob->dupon+ob->dupoff); - ok= (ok < ob->dupon); + ok = scene->r.cfra - ob->dupsta; + ok = ok % (ob->dupon + ob->dupoff); + ok = (ok < ob->dupon); } if (ok) { @@ -816,22 +816,22 @@ static void frames_duplilist(ListBase *lb, Scene *scene, Object *ob, int level, * However, this has always been the way that this worked (i.e. pre 2.5), so I guess that it'll be fine! */ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ - where_is_object_time(scene, ob, (float)scene->r.cfra); + BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); - dob= new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); + dob = new_dupli_object(lb, ob, ob->obmat, ob->lay, scene->r.cfra, OB_DUPLIFRAMES, animated); copy_m4_m4(dob->omat, copyob.obmat); } } - enable_cu_speed= 1; + enable_cu_speed = 1; /* reset frame to original frame, then re-evaluate animation as above * as 2.5 animation data may have far-reaching consequences */ - scene->r.cfra= cfrao; + scene->r.cfra = cfrao; BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, (float)scene->r.cfra, ADT_RECALC_ANIM); /* ob-eval will do drivers, so we don't need to do them */ - where_is_object_time(scene, ob, (float)scene->r.cfra); + BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); /* but, to make sure unkeyed object transforms are still sane, * let's copy object's original data back over @@ -857,7 +857,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], const float no_f[3], const short no_s[3]) { DupliObject *dob; - vertexDupliData *vdd= userData; + vertexDupliData *vdd = userData; float vec[3], q2[4], mat[3][3], tmat[4][4], obmat[4][4]; int origlay; @@ -870,10 +870,10 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], if (vdd->par->transflag & OB_DUPLIROT) { if (no_f) { - vec[0]= -no_f[0]; vec[1]= -no_f[1]; vec[2]= -no_f[2]; + vec[0] = -no_f[0]; vec[1] = -no_f[1]; vec[2] = -no_f[2]; } else if (no_s) { - vec[0]= -no_s[0]; vec[1]= -no_s[1]; vec[2]= -no_s[2]; + vec[0] = -no_s[0]; vec[1] = -no_s[1]; vec[2] = -no_s[2]; } vec_to_quat(q2, vec, vdd->ob->trackflag, vdd->ob->upflag); @@ -885,7 +885,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], origlay = vdd->ob->lay; - dob= new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); + dob = new_dupli_object(vdd->lb, vdd->ob, obmat, vdd->par->lay, index, OB_DUPLIVERTS, vdd->animated); /* restore the original layer so that each dupli will have proper dob->origlay */ vdd->ob->lay = origlay; @@ -897,7 +897,7 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], float tmpmat[4][4]; copy_m4_m4(tmpmat, vdd->ob->obmat); copy_m4_m4(vdd->ob->obmat, obmat); /* pretend we are really this mat */ - object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level+1, vdd->animated); + object_duplilist_recursive((ID *)vdd->id, vdd->scene, vdd->ob, vdd->lb, obmat, vdd->level + 1, vdd->animated); copy_m4_m4(vdd->ob->obmat, tmpmat); } } @@ -905,13 +905,13 @@ static void vertex_dupli__mapFunc(void *userData, int index, const float co[3], static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], int level, int animated) { Object *ob, *ob_iter; - Mesh *me= par->data; + Mesh *me = par->data; Base *base = NULL; DerivedMesh *dm; vertexDupliData vdd; Scene *sce = NULL; Group *group = NULL; - GroupObject * go = NULL; + GroupObject *go = NULL; BMEditMesh *em; float vec[3], no[3], pmat[4][4]; int totvert, a, oblay; @@ -920,54 +920,54 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl copy_m4_m4(pmat, par->obmat); /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; em = me->edit_btmesh; if (em) { - dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); + dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); } else - dm= mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); + dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); if (G.rendering) { - vdd.orco= (float(*)[3])get_mesh_orco_verts(par); - transform_mesh_orco_verts(me, vdd.orco, me->totvert, 0); + vdd.orco = (float(*)[3])BKE_mesh_orco_verts_get(par); + BKE_mesh_orco_verts_transform(me, vdd.orco, me->totvert, 0); } else - vdd.orco= NULL; + vdd.orco = NULL; totvert = dm->getNumVerts(dm); /* having to loop on scene OR group objects is NOT FUN */ if (GS(id->name) == ID_SCE) { sce = (Scene *)id; - lay= sce->lay; - base= sce->base.first; + lay = sce->lay; + base = sce->base.first; } else { group = (Group *)id; - lay= group->layer; + lay = group->layer; go = group->gobject.first; } /* Start looping on Scene OR Group objects */ while (base || go) { if (sce) { - ob_iter= base->object; + ob_iter = base->object; oblay = base->lay; } else { - ob_iter= go->ob; + ob_iter = go->ob; oblay = ob_iter->lay; } - if (lay & oblay && scene->obedit!=ob_iter) { - ob=ob_iter->parent; + if (lay & oblay && scene->obedit != ob_iter) { + ob = ob_iter->parent; while (ob) { - if (ob==par) { + if (ob == par) { ob = ob_iter; - /* End Scene/Group object loop, below is generic */ + /* End Scene/Group object loop, below is generic */ /* par_space_mat - only used for groups so we can modify the space dupli's are in @@ -978,23 +978,23 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl else copy_m4_m4(vdd.obmat, ob->obmat); - vdd.id= id; - vdd.level= level; - vdd.animated= animated; - vdd.lb= lb; - vdd.ob= ob; - vdd.scene= scene; - vdd.par= par; + vdd.id = id; + vdd.level = level; + vdd.animated = animated; + vdd.lb = lb; + vdd.ob = ob; + vdd.scene = scene; + vdd.par = par; copy_m4_m4(vdd.pmat, pmat); /* mballs have a different dupli handling */ - if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ + if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ if (me->edit_btmesh) { - dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void*) &vdd); + dm->foreachMappedVert(dm, vertex_dupli__mapFunc, (void *) &vdd); } else { - for (a=0; agetVertCo(dm, a, vec); dm->getVertNo(dm, a, no); @@ -1012,11 +1012,11 @@ static void vertex_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, fl break; } - ob= ob->parent; + ob = ob->parent; } } - if (sce) base= base->next; /* scene loop */ - else go= go->next; /* group loop */ + if (sce) base = base->next; /* scene loop */ + else go = go->next; /* group loop */ } if (vdd.orco) @@ -1030,7 +1030,7 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa Base *base = NULL; DupliObject *dob; DerivedMesh *dm; - Mesh *me= par->data; + Mesh *me = par->data; MLoopUV *mloopuv; MPoly *mpoly, *mp; MLoop *mloop; @@ -1044,63 +1044,63 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa float ob__obmat[4][4]; /* needed for groups where the object matrix needs to be modified */ /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; copy_m4_m4(pmat, par->obmat); em = me->edit_btmesh; if (em) { - dm= editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); + dm = editbmesh_get_derived_cage(scene, par, em, CD_MASK_BAREMESH); } else { dm = mesh_get_derived_deform(scene, par, CD_MASK_BAREMESH); } - totface= dm->getNumPolys(dm); - mpoly= dm->getPolyArray(dm); - mloop= dm->getLoopArray(dm); - mvert= dm->getVertArray(dm); + totface = dm->getNumPolys(dm); + mpoly = dm->getPolyArray(dm); + mloop = dm->getLoopArray(dm); + mvert = dm->getVertArray(dm); if (G.rendering) { - orco= (float(*)[3])get_mesh_orco_verts(par); - transform_mesh_orco_verts(me, orco, me->totvert, 0); - mloopuv= me->mloopuv; + orco = (float(*)[3])BKE_mesh_orco_verts_get(par); + BKE_mesh_orco_verts_transform(me, orco, me->totvert, 0); + mloopuv = me->mloopuv; } else { - orco= NULL; - mloopuv= NULL; + orco = NULL; + mloopuv = NULL; } /* having to loop on scene OR group objects is NOT FUN */ if (GS(id->name) == ID_SCE) { sce = (Scene *)id; - lay= sce->lay; - base= sce->base.first; + lay = sce->lay; + base = sce->base.first; } else { group = (Group *)id; - lay= group->layer; + lay = group->layer; go = group->gobject.first; } /* Start looping on Scene OR Group objects */ while (base || go) { if (sce) { - ob_iter= base->object; + ob_iter = base->object; oblay = base->lay; } else { - ob_iter= go->ob; + ob_iter = go->ob; oblay = ob_iter->lay; } - if (lay & oblay && scene->obedit!=ob_iter) { - ob=ob_iter->parent; + if (lay & oblay && scene->obedit != ob_iter) { + ob = ob_iter->parent; while (ob) { - if (ob==par) { + if (ob == par) { ob = ob_iter; - /* End Scene/Group object loop, below is generic */ + /* End Scene/Group object loop, below is generic */ /* par_space_mat - only used for groups so we can modify the space dupli's are in * when par_space_mat is NULL ob->obmat can be used instead of ob__obmat @@ -1113,9 +1113,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_m3_m4(imat, ob->parentinv); /* mballs have a different dupli handling */ - if (ob->type!=OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ + if (ob->type != OB_MBALL) ob->flag |= OB_DONE; /* doesnt render */ - for (a=0, mp= mpoly; aloopstart; + MLoop *loopstart = mloop + mp->loopstart; if (mp->totloop < 3) { /* highly unlikely but to be safe */ continue; } else { - v1= mvert[(mv1= loopstart[0].v)].co; - v2= mvert[(mv2= loopstart[1].v)].co; - v3= mvert[(mv3= loopstart[2].v)].co; + v1 = mvert[(mv1 = loopstart[0].v)].co; + v2 = mvert[(mv2 = loopstart[1].v)].co; + v3 = mvert[(mv3 = loopstart[2].v)].co; #if 0 if (mp->totloop > 3) { - v4= mvert[(mv4= loopstart[3].v)].co; + v4 = mvert[(mv4 = loopstart[3].v)].co; } #endif } /* translation */ - mesh_calc_poly_center(mp, loopstart, mvert, cent); + BKE_mesh_calc_poly_center(mp, loopstart, mvert, cent); mul_m4_v3(pmat, cent); @@ -1160,8 +1160,8 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa /* scale */ if (par->transflag & OB_DUPLIFACES_SCALE) { - float size= mesh_calc_poly_area(mp, loopstart, mvert, NULL); - size= sqrtf(size) * par->dupfacesca; + float size = BKE_mesh_calc_poly_area(mp, loopstart, mvert, NULL); + size = sqrtf(size) * par->dupfacesca; mul_m3_fl(mat, size); } @@ -1171,9 +1171,9 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa copy_m4_m4(tmat, obmat); mul_m4_m4m3(obmat, tmat, mat); - dob= new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated); + dob = new_dupli_object(lb, ob, obmat, par->lay, a, OB_DUPLIFACES, animated); if (G.rendering) { - w= 1.0f / (float)mp->totloop; + w = 1.0f / (float)mp->totloop; if (orco) { int j; @@ -1194,18 +1194,18 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa float tmpmat[4][4]; copy_m4_m4(tmpmat, ob->obmat); copy_m4_m4(ob->obmat, obmat); /* pretend we are really this mat */ - object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level+1, animated); + object_duplilist_recursive((ID *)id, scene, ob, lb, ob->obmat, level + 1, animated); copy_m4_m4(ob->obmat, tmpmat); } } break; } - ob= ob->parent; + ob = ob->parent; } } - if (sce) base= base->next; /* scene loop */ - else go= go->next; /* group loop */ + if (sce) base = base->next; /* scene loop */ + else go = go->next; /* group loop */ } if (orco) @@ -1217,30 +1217,30 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, float par_space_mat[][4], ParticleSystem *psys, int level, int animated) { GroupObject *go; - Object *ob=NULL, **oblist=NULL, obcopy, *obcopylist=NULL; + Object *ob = NULL, **oblist = NULL, obcopy, *obcopylist = NULL; DupliObject *dob; ParticleDupliWeight *dw; ParticleSettings *part; ParticleData *pa; - ChildParticle *cpa=NULL; + ChildParticle *cpa = NULL; ParticleKey state; ParticleCacheKey *cache; float ctime, pa_time, scale = 1.0f; - float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size=0.0; + float tmat[4][4], mat[4][4], pamat[4][4], vec[3], size = 0.0; float (*obmat)[4], (*oldobmat)[4]; int a, b, counter, hair = 0; - int totpart, totchild, totgroup=0 /*, pa_num */; + int totpart, totchild, totgroup = 0 /*, pa_num */; int no_draw_flag = PARS_UNEXIST; - if (psys==NULL) return; + if (psys == NULL) return; /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; - part=psys->part; + part = psys->part; - if (part==NULL) + if (part == NULL) return; if (!psys_check_enabled(par, psys)) @@ -1249,19 +1249,19 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (G.rendering == 0) no_draw_flag |= PARS_NO_DISP; - ctime = BKE_curframe(scene); /* NOTE: in old animsys, used parent object's timeoffset... */ + ctime = BKE_scene_frame_get(scene); /* NOTE: in old animsys, used parent object's timeoffset... */ totpart = psys->totpart; totchild = psys->totchild; BLI_srandom(31415926 + psys->seed); - if ((psys->renderdata || part->draw_as==PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { - ParticleSimulationData sim= {NULL}; - sim.scene= scene; - sim.ob= par; - sim.psys= psys; - sim.psmd= psys_get_modifier(par, psys); + if ((psys->renderdata || part->draw_as == PART_DRAW_REND) && ELEM(part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { + ParticleSimulationData sim = {NULL}; + sim.scene = scene; + sim.ob = par; + sim.psys = psys; + sim.psmd = psys_get_modifier(par, psys); /* make sure emitter imat is in global coordinates instead of render view coordinates */ invert_m4_m4(par->imat, par->obmat); @@ -1274,7 +1274,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->dup_group == NULL || part->dup_group->gobject.first == NULL) return; - for (go=part->dup_group->gobject.first; go; go=go->next) + for (go = part->dup_group->gobject.first; go; go = go->next) if (go->ob == par) return; } @@ -1282,7 +1282,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* if we have a hair particle system, use the path cache */ if (part->type == PART_HAIR) { if (psys->flag & PSYS_HAIR_DONE) - hair= (totchild == 0 || psys->childcache) && psys->pathcache; + hair = (totchild == 0 || psys->childcache) && psys->pathcache; if (!hair) return; @@ -1296,29 +1296,29 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p psys->lattice = psys_get_lattice(&sim); /* gather list of objects or single object */ - if (part->ren_as==PART_DRAW_GR) { + if (part->ren_as == PART_DRAW_GR) { group_handle_recalc_and_update(scene, par, part->dup_group); if (part->draw & PART_DRAW_COUNT_GR) { - for (dw=part->dupliweights.first; dw; dw=dw->next) + for (dw = part->dupliweights.first; dw; dw = dw->next) totgroup += dw->count; } else { - for (go=part->dup_group->gobject.first; go; go=go->next) + for (go = part->dup_group->gobject.first; go; go = go->next) totgroup++; } /* we also copy the actual objects to restore afterwards, since - * where_is_object_time will change the object which breaks transform */ - oblist = MEM_callocN(totgroup*sizeof(Object *), "dupgroup object list"); - obcopylist = MEM_callocN(totgroup*sizeof(Object), "dupgroup copy list"); + * BKE_object_where_is_calc_time will change the object which breaks transform */ + oblist = MEM_callocN(totgroup * sizeof(Object *), "dupgroup object list"); + obcopylist = MEM_callocN(totgroup * sizeof(Object), "dupgroup copy list"); if (part->draw & PART_DRAW_COUNT_GR && totgroup) { dw = part->dupliweights.first; - for (a=0; anext) { - for (b=0; bcount; b++, a++) { + for (a = 0; a < totgroup; dw = dw->next) { + for (b = 0; b < dw->count; b++, a++) { oblist[a] = dw->ob; obcopylist[a] = *dw->ob; } @@ -1326,7 +1326,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } else { go = part->dup_group->gobject.first; - for (a=0; anext) { + for (a = 0; a < totgroup; a++, go = go->next) { oblist[a] = go->ob; obcopylist[a] = *go->ob; } @@ -1337,13 +1337,13 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p obcopy = *ob; } - if (totchild==0 || part->draw & PART_DRAW_PARENT) + if (totchild == 0 || part->draw & PART_DRAW_PARENT) a = 0; else a = totpart; - for (pa=psys->particles, counter=0; aparticles, counter = 0; a < totpart + totchild; a++, pa++, counter++) { + if (a < totpart) { /* handle parent particle */ if (pa->flag & no_draw_flag) continue; @@ -1364,29 +1364,29 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p /* some hair paths might be non-existent so they can't be used for duplication */ if (hair && ((a < totpart && psys->pathcache[a]->steps < 0) || - (a >= totpart && psys->childcache[a-totpart]->steps < 0))) + (a >= totpart && psys->childcache[a - totpart]->steps < 0))) { continue; } - if (part->ren_as==PART_DRAW_GR) { + if (part->ren_as == PART_DRAW_GR) { /* prevent divide by zero below [#28336] */ if (totgroup == 0) continue; /* for groups, pick the object based on settings */ - if (part->draw&PART_DRAW_RAND_GR) - b= BLI_rand() % totgroup; + if (part->draw & PART_DRAW_RAND_GR) + b = BLI_rand() % totgroup; else - b= a % totgroup; + b = a % totgroup; ob = oblist[b]; obmat = oblist[b]->obmat; oldobmat = obcopylist[b].obmat; } else { - obmat= ob->obmat; - oldobmat= obcopy.obmat; + obmat = ob->obmat; + oldobmat = obcopy.obmat; } if (hair) { @@ -1396,12 +1396,12 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p psys_get_dupli_path_transform(&sim, pa, NULL, cache, pamat, &scale); } else { - cache = psys->childcache[a-totpart]; + cache = psys->childcache[a - totpart]; psys_get_dupli_path_transform(&sim, NULL, cpa, cache, pamat, &scale); } copy_v3_v3(pamat[3], cache->co); - pamat[3][3]= 1.0f; + pamat[3][3] = 1.0f; } else { @@ -1415,17 +1415,17 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p normalize_qt_qt(tquat, state.rot); quat_to_mat4(pamat, tquat); copy_v3_v3(pamat[3], state.co); - pamat[3][3]= 1.0f; + pamat[3][3] = 1.0f; } } - if (part->ren_as==PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { - for (go= part->dup_group->gobject.first, b=0; go; go= go->next, b++) { + if (part->ren_as == PART_DRAW_GR && psys->part->draw & PART_DRAW_WHOLE_GR) { + for (go = part->dup_group->gobject.first, b = 0; go; go = go->next, b++) { copy_m4_m4(tmat, oblist[b]->obmat); /* apply particle scale */ - mul_mat3_m4_fl(tmat, size*scale); - mul_v3_fl(tmat[3], size*scale); + mul_mat3_m4_fl(tmat, size * scale); + mul_v3_fl(tmat[3], size * scale); /* group dupli offset, should apply after everything else */ if (!is_zero_v3(part->dup_group->dupli_ofs)) sub_v3_v3v3(tmat[3], tmat[3], part->dup_group->dupli_ofs); @@ -1437,7 +1437,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p else copy_m4_m4(mat, tmat); - dob= new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); + dob = new_dupli_object(lb, go->ob, mat, par->lay, counter, OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, obcopylist[b].obmat); if (G.rendering) psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco); @@ -1445,7 +1445,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p } else { /* to give ipos in object correct offset */ - where_is_object_time(scene, ob, ctime-pa_time); + BKE_object_where_is_calc_time(scene, ob, ctime - pa_time); copy_v3_v3(vec, obmat[3]); obmat[3][0] = obmat[3][1] = obmat[3][2] = 0.0f; @@ -1457,7 +1457,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p xvec[1] = xvec[2] = 0; vec_to_quat(q, xvec, ob->trackflag, ob->upflag); quat_to_mat4(obmat, q); - obmat[3][3]= 1.0f; + obmat[3][3] = 1.0f; } /* Normal particles and cached hair live in global space so we need to @@ -1469,7 +1469,7 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p copy_m4_m4(mat, pamat); mult_m4_m4m4(tmat, mat, obmat); - mul_mat3_m4_fl(tmat, size*scale); + mul_mat3_m4_fl(tmat, size * scale); if (par_space_mat) mult_m4_m4m4(mat, par_space_mat, tmat); @@ -1479,20 +1479,20 @@ static void new_particle_duplilist(ListBase *lb, ID *id, Scene *scene, Object *p if (part->draw & PART_DRAW_GLOBAL_OB) add_v3_v3v3(mat[3], mat[3], vec); - dob= new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated); + dob = new_dupli_object(lb, ob, mat, ob->lay, counter, GS(id->name) == ID_GR ? OB_DUPLIGROUP : OB_DUPLIPARTS, animated); copy_m4_m4(dob->omat, oldobmat); if (G.rendering) psys_get_dupli_texture(psys, part, sim.psmd, pa, cpa, dob->uv, dob->orco); } } - /* restore objects since they were changed in where_is_object_time */ - if (part->ren_as==PART_DRAW_GR) { - for (a=0; aren_as == PART_DRAW_GR) { + for (a = 0; a < totgroup; a++) + *(oblist[a]) = obcopylist[a]; } else - *ob= obcopy; + *ob = obcopy; } /* clean up */ @@ -1512,19 +1512,19 @@ static Object *find_family_object(Object **obar, char *family, char ch) Object *ob; int flen; - if ( obar[(int)ch] ) return obar[(int)ch]; + if (obar[(int)ch]) return obar[(int)ch]; - flen= strlen(family); + flen = strlen(family); - ob= G.main->object.first; + ob = G.main->object.first; while (ob) { if (ob->id.name[flen + 2] == ch) { - if ( strncmp(ob->id.name+2, family, flen)==0 ) break; + if (strncmp(ob->id.name + 2, family, flen) == 0) break; } - ob= ob->id.next; + ob = ob->id.next; } - obar[(int)ch]= ob; + obar[(int)ch] = ob; return ob; } @@ -1532,37 +1532,37 @@ static Object *find_family_object(Object **obar, char *family, char ch) static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, int animated) { - Object *ob, *obar[256]= {NULL}; + Object *ob, *obar[256] = {NULL}; Curve *cu; struct chartrans *ct, *chartransdata; float vec[3], obmat[4][4], pmat[4][4], fsize, xof, yof; int slen, a; /* simple preventing of too deep nested groups */ - if (level>MAX_DUPLI_RECUR) return; + if (level > MAX_DUPLI_RECUR) return; copy_m4_m4(pmat, par->obmat); /* in par the family name is stored, use this to find the other objects */ - chartransdata= BKE_text_to_curve(G.main, scene, par, FO_DUPLI); - if (chartransdata==NULL) return; + chartransdata = BKE_vfont_to_curve(G.main, scene, par, FO_DUPLI); + if (chartransdata == NULL) return; - cu= par->data; - slen= strlen(cu->str); - fsize= cu->fsize; - xof= cu->xof; - yof= cu->yof; + cu = par->data; + slen = strlen(cu->str); + fsize = cu->fsize; + xof = cu->xof; + yof = cu->yof; - ct= chartransdata; + ct = chartransdata; - for (a=0; afamily, cu->str[a]); + ob = find_family_object(obar, cu->family, cu->str[a]); if (ob) { - vec[0]= fsize*(ct->xof - xof); - vec[1]= fsize*(ct->yof - yof); - vec[2]= 0.0; + vec[0] = fsize * (ct->xof - xof); + vec[1] = fsize * (ct->yof - yof); + vec[2] = 0.0; mul_m4_v3(pmat, vec); @@ -1580,7 +1580,7 @@ static void font_duplilist(ListBase *lb, Scene *scene, Object *par, int level, i static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBase *duplilist, float par_space_mat[][4], int level, int animated) { - if ((ob->transflag & OB_DUPLI)==0) + if ((ob->transflag & OB_DUPLI) == 0) return; /* Should the dupli's be generated for this object? - Respect restrict flags */ @@ -1597,35 +1597,35 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas if (ob->transflag & OB_DUPLIPARTS) { ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) - new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level+1, animated); + for (; psys; psys = psys->next) + new_particle_duplilist(duplilist, id, scene, ob, par_space_mat, psys, level + 1, animated); } else if (ob->transflag & OB_DUPLIVERTS) { - if (ob->type==OB_MESH) { - vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated); + if (ob->type == OB_MESH) { + vertex_duplilist(duplilist, id, scene, ob, par_space_mat, level + 1, animated); } - else if (ob->type==OB_FONT) { - if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */ - font_duplilist(duplilist, scene, ob, level+1, animated); + else if (ob->type == OB_FONT) { + if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */ + font_duplilist(duplilist, scene, ob, level + 1, animated); } } } else if (ob->transflag & OB_DUPLIFACES) { - if (ob->type==OB_MESH) - face_duplilist(duplilist, id, scene, ob, par_space_mat, level+1, animated); + if (ob->type == OB_MESH) + face_duplilist(duplilist, id, scene, ob, par_space_mat, level + 1, animated); } else if (ob->transflag & OB_DUPLIFRAMES) { - if (GS(id->name)==ID_SCE) { /* TODO - support dupligroups */ - frames_duplilist(duplilist, scene, ob, level+1, animated); + if (GS(id->name) == ID_SCE) { /* TODO - support dupligroups */ + frames_duplilist(duplilist, scene, ob, level + 1, animated); } } else if (ob->transflag & OB_DUPLIGROUP) { DupliObject *dob; - group_duplilist(duplilist, scene, ob, level+1, animated); /* now recursive */ + group_duplilist(duplilist, scene, ob, level + 1, animated); /* now recursive */ - if (level==0) { - for (dob= duplilist->first; dob; dob= dob->next) + if (level == 0) { + for (dob = duplilist->first; dob; dob = dob->next) if (dob->type == OB_DUPLIGROUP) copy_m4_m4(dob->ob->obmat, dob->mat); } @@ -1636,8 +1636,8 @@ static void object_duplilist_recursive(ID *id, Scene *scene, Object *ob, ListBas * note; group dupli's already set transform matrix. see note in group_duplilist() */ ListBase *object_duplilist(Scene *sce, Object *ob) { - ListBase *duplilist= MEM_mallocN(sizeof(ListBase), "duplilist"); - duplilist->first= duplilist->last= NULL; + ListBase *duplilist = MEM_mallocN(sizeof(ListBase), "duplilist"); + duplilist->first = duplilist->last = NULL; object_duplilist_recursive((ID *)sce, sce, ob, duplilist, NULL, 0, 0); return duplilist; } @@ -1649,8 +1649,8 @@ void free_object_duplilist(ListBase *lb) /* loop in reverse order, if object is instanced multiple times * the original layer may not really be original otherwise, proper * solution is more complicated */ - for (dob= lb->last; dob; dob= dob->prev) { - dob->ob->lay= dob->origlay; + for (dob = lb->last; dob; dob = dob->prev) { + dob->ob->lay = dob->origlay; copy_m4_m4(dob->ob->obmat, dob->omat); } @@ -1662,16 +1662,16 @@ int count_duplilist(Object *ob) { if (ob->transflag & OB_DUPLI) { if (ob->transflag & OB_DUPLIVERTS) { - if (ob->type==OB_MESH) { + if (ob->type == OB_MESH) { if (ob->transflag & OB_DUPLIVERTS) { ParticleSystem *psys = ob->particlesystem.first; - int pdup=0; + int pdup = 0; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) pdup += psys->totpart; - if (pdup==0) { - Mesh *me= ob->data; + if (pdup == 0) { + Mesh *me = ob->data; return me->totvert; } else @@ -1680,9 +1680,9 @@ int count_duplilist(Object *ob) } } else if (ob->transflag & OB_DUPLIFRAMES) { - int tot= ob->dupend - ob->dupsta; - tot/= (ob->dupon+ob->dupoff); - return tot*ob->dupon; + int tot = ob->dupend - ob->dupsta; + tot /= (ob->dupon + ob->dupoff); + return tot * ob->dupon; } } return 1; diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 73f1ce1526a..8982017403d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -254,8 +254,8 @@ AnimData *BKE_copy_animdata (AnimData *adt, const short do_action) /* make a copy of action - at worst, user has to delete copies... */ if (do_action) { - dadt->action= copy_action(adt->action); - dadt->tmpact= copy_action(adt->tmpact); + dadt->action= BKE_action_copy(adt->action); + dadt->tmpact= BKE_action_copy(adt->tmpact); } else { id_us_plus((ID *)dadt->action); @@ -299,11 +299,11 @@ void BKE_copy_animdata_id_action(ID *id) if (adt) { if (adt->action) { id_us_min((ID *)adt->action); - adt->action= copy_action(adt->action); + adt->action= BKE_action_copy(adt->action); } if (adt->tmpact) { id_us_min((ID *)adt->tmpact); - adt->tmpact= copy_action(adt->tmpact); + adt->tmpact= BKE_action_copy(adt->tmpact); } } } @@ -315,8 +315,8 @@ static void make_local_strips(ListBase *strips) NlaStrip *strip; for (strip=strips->first; strip; strip=strip->next) { - if (strip->act) make_local_action(strip->act); - if (strip->remap && strip->remap->target) make_local_action(strip->remap->target); + if (strip->act) BKE_action_make_local(strip->act); + if (strip->remap && strip->remap->target) BKE_action_make_local(strip->remap->target); make_local_strips(&strip->strips); } @@ -328,10 +328,10 @@ void BKE_animdata_make_local(AnimData *adt) NlaTrack *nlt; /* Actions - Active and Temp */ - if (adt->action) make_local_action(adt->action); - if (adt->tmpact) make_local_action(adt->tmpact); + if (adt->action) BKE_action_make_local(adt->action); + if (adt->tmpact) BKE_action_make_local(adt->tmpact); /* Remaps */ - if (adt->remap && adt->remap->target) make_local_action(adt->remap->target); + if (adt->remap && adt->remap->target) BKE_action_make_local(adt->remap->target); /* Drivers */ // TODO: need to remap the ID-targets too? @@ -426,7 +426,7 @@ void action_move_fcurves_by_basepath(bAction *srcAct, bAction *dstAct, const cha /* if grouped... */ if (fcu->grp) { /* make sure there will be a matching group on the other side for the migrants */ - agrp = action_groups_find_named(dstAct, fcu->grp->name); + agrp = BKE_action_group_find_name(dstAct, fcu->grp->name); if (agrp == NULL) { /* add a new one with a similar name (usually will be the same though) */ diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index b0d0ace2a7e..09b295aabf1 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -75,25 +75,25 @@ /* **************** Generic Functions, data level *************** */ -bArmature *add_armature(const char *name) +bArmature *BKE_armature_add(const char *name) { bArmature *arm; - arm = alloc_libblock (&G.main->armature, ID_AR, name); - arm->deformflag = ARM_DEF_VGROUP|ARM_DEF_ENVELOPE; + arm = BKE_libblock_alloc(&G.main->armature, ID_AR, name); + arm->deformflag = ARM_DEF_VGROUP | ARM_DEF_ENVELOPE; arm->flag = ARM_COL_CUSTOM; /* custom bone-group colors */ arm->layer = 1; return arm; } -bArmature *get_armature(Object *ob) +bArmature *BKE_armature_from_object(Object *ob) { if (ob->type == OB_ARMATURE) return (bArmature *)ob->data; return NULL; } -void free_bonelist(ListBase *lb) +void BKE_armature_bonelist_free(ListBase *lb) { Bone *bone; @@ -102,16 +102,16 @@ void free_bonelist(ListBase *lb) IDP_FreeProperty(bone->prop); MEM_freeN(bone->prop); } - free_bonelist(&bone->childbase); + BKE_armature_bonelist_free(&bone->childbase); } BLI_freelistN(lb); } -void free_armature(bArmature *arm) +void BKE_armature_free(bArmature *arm) { if (arm) { - free_bonelist(&arm->bonebase); + BKE_armature_bonelist_free(&arm->bonebase); /* free editmode data */ if (arm->edbo) { @@ -135,7 +135,7 @@ void free_armature(bArmature *arm) } } -void make_local_armature(bArmature *arm) +void BKE_armature_make_local(bArmature *arm) { Main *bmain = G.main; int is_local = FALSE, is_lib = FALSE; @@ -161,7 +161,7 @@ void make_local_armature(bArmature *arm) id_clear_lib_data(bmain, &arm->id); } else if (is_local && is_lib) { - bArmature *arm_new = copy_armature(arm); + bArmature *arm_new = BKE_armature_copy(arm); arm_new->id.us = 0; /* Remap paths of new ID using old library as base. */ @@ -179,7 +179,7 @@ void make_local_armature(bArmature *arm) } } -static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, Bone **newActBone) +static void copy_bonechildren(Bone *newBone, Bone *oldBone, Bone *actBone, Bone **newActBone) { Bone *curBone, *newChildBone; @@ -201,13 +201,13 @@ static void copy_bonechildren(Bone* newBone, Bone* oldBone, Bone* actBone, Bone } } -bArmature *copy_armature(bArmature *arm) +bArmature *BKE_armature_copy(bArmature *arm) { bArmature *newArm; Bone *oldBone, *newBone; - Bone *newActBone= NULL; + Bone *newActBone = NULL; - newArm = copy_libblock(&arm->id); + newArm = BKE_libblock_copy(&arm->id); BLI_duplicatelist(&newArm->bonebase, &arm->bonebase); /* Duplicate the childrens' lists*/ @@ -245,7 +245,7 @@ static Bone *get_named_bone_bonechildren(Bone *bone, const char *name) /* Walk the list until the bone is found */ -Bone *get_named_bone(bArmature *arm, const char *name) +Bone *BKE_armature_find_bone_name(bArmature *arm, const char *name) { Bone *bone = NULL, *curBone; @@ -340,27 +340,27 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a while (change) { /* remove extensions */ change = 0; - if (len > 2 && basename[len-2] == '.') { - if (basename[len-1] == 'L' || basename[len-1] == 'R') { /* L R */ - basename[len-2] = '\0'; + if (len > 2 && basename[len - 2] == '.') { + if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */ + basename[len - 2] = '\0'; len -= 2; change = 1; } } - else if (len > 3 && basename[len-3] == '.') { - if ((basename[len-2] == 'F' && basename[len-1] == 'r') || /* Fr */ - (basename[len-2] == 'B' && basename[len-1] == 'k')) /* Bk */ + else if (len > 3 && basename[len - 3] == '.') { + if ((basename[len - 2] == 'F' && basename[len - 1] == 'r') || /* Fr */ + (basename[len - 2] == 'B' && basename[len - 1] == 'k')) /* Bk */ { - basename[len-3] = '\0'; + basename[len - 3] = '\0'; len -= 3; change = 1; } } - else if (len > 4 && basename[len-4] == '.') { - if ((basename[len-3] == 'T' && basename[len-2] == 'o' && basename[len-1] == 'p') || /* Top */ - (basename[len-3] == 'B' && basename[len-2] == 'o' && basename[len-1] == 't')) /* Bot */ + else if (len > 4 && basename[len - 4] == '.') { + if ((basename[len - 3] == 'T' && basename[len - 2] == 'o' && basename[len - 1] == 'p') || /* Top */ + (basename[len - 3] == 'B' && basename[len - 2] == 'o' && basename[len - 1] == 't')) /* Bot */ { - basename[len-4] = '\0'; + basename[len - 4] = '\0'; len -= 4; change = 1; } @@ -368,7 +368,7 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a } if ((MAXBONENAME - len) < strlen(extension) + 1) { /* add 1 for the '.' */ - strncpy(name, basename, len-strlen(extension)); + strncpy(name, basename, len - strlen(extension)); } BLI_snprintf(name, MAXBONENAME, "%s.%s", basename, extension); @@ -382,44 +382,44 @@ int bone_autoside_name(char name[MAXBONENAME], int UNUSED(strip_number), short a /* ************* B-Bone support ******************* */ -#define MAX_BBONE_SUBDIV 32 +#define MAX_BBONE_SUBDIV 32 /* data has MAX_BBONE_SUBDIV+1 interpolated points, will become desired amount with equal distances */ static void equalize_bezier(float *data, int desired) { float *fp, totdist, ddist, dist, fac1, fac2; - float pdist[MAX_BBONE_SUBDIV+1]; - float temp[MAX_BBONE_SUBDIV+1][4]; + float pdist[MAX_BBONE_SUBDIV + 1]; + float temp[MAX_BBONE_SUBDIV + 1][4]; int a, nr; pdist[0] = 0.0f; for (a = 0, fp = data; a < MAX_BBONE_SUBDIV; a++, fp += 4) { copy_qt_qt(temp[a], fp); - pdist[a+1] = pdist[a] + len_v3v3(fp, fp+4); + pdist[a + 1] = pdist[a] + len_v3v3(fp, fp + 4); } /* do last point */ copy_qt_qt(temp[a], fp); totdist = pdist[a]; /* go over distances and calculate new points */ - ddist = totdist/((float)desired); + ddist = totdist / ((float)desired); nr = 1; - for (a = 1, fp = data+4; a < desired; a++, fp += 4) { - dist = ((float)a)*ddist; + for (a = 1, fp = data + 4; a < desired; a++, fp += 4) { + dist = ((float)a) * ddist; /* we're looking for location (distance) 'dist' in the array */ while ((dist >= pdist[nr]) && nr < MAX_BBONE_SUBDIV) nr++; - fac1 = pdist[nr] - pdist[nr-1]; + fac1 = pdist[nr] - pdist[nr - 1]; fac2 = pdist[nr] - dist; fac1 = fac2 / fac1; fac2 = 1.0f - fac1; - fp[0] = fac1*temp[nr-1][0] + fac2*temp[nr][0]; - fp[1] = fac1*temp[nr-1][1] + fac2*temp[nr][1]; - fp[2] = fac1*temp[nr-1][2] + fac2*temp[nr][2]; - fp[3] = fac1*temp[nr-1][3] + fac2*temp[nr][3]; + fp[0] = fac1 * temp[nr - 1][0] + fac2 * temp[nr][0]; + fp[1] = fac1 * temp[nr - 1][1] + fac2 * temp[nr][1]; + fp[2] = fac1 * temp[nr - 1][2] + fac2 * temp[nr][2]; + fp[3] = fac1 * temp[nr - 1][3] + fac2 * temp[nr][3]; } /* set last point, needed for orientation calculus */ copy_qt_qt(fp, temp[MAX_BBONE_SUBDIV]); @@ -436,7 +436,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) Bone *bone = pchan->bone; float h1[3], h2[3], scale[3], length, hlength1, hlength2, roll1 = 0.0f, roll2; float mat3[3][3], imat[4][4], posemat[4][4], scalemat[4][4], iscalemat[4][4]; - float data[MAX_BBONE_SUBDIV+1][4], *fp; + float data[MAX_BBONE_SUBDIV + 1][4], *fp; int a, doscale = 0; length = bone->length; @@ -459,8 +459,8 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) } } - hlength1 = bone->ease1*length*0.390464f; /* 0.5*sqrt(2)*kappa, the handle length for near-perfect circles */ - hlength2 = bone->ease2*length*0.390464f; + hlength1 = bone->ease1 * length * 0.390464f; /* 0.5*sqrt(2)*kappa, the handle length for near-perfect circles */ + hlength2 = bone->ease2 * length * 0.390464f; /* evaluate next and prev bones */ if (bone->flag & BONE_CONNECTED) @@ -494,7 +494,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) copy_v3_v3(h1, prev->pose_head); mul_m4_v3(imat, h1); - if (prev->bone->segments>1) { + if (prev->bone->segments > 1) { /* if previous bone is B-bone too, use average handle direction */ h1[1] -= length; roll1 = 0.0f; @@ -534,10 +534,10 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) mul_m4_v3(imat, h2); /* if next bone is B-bone too, use average handle direction */ - if (next->bone->segments>1) + if (next->bone->segments > 1) ; else - h2[1]-= length; + h2[1] -= length; normalize_v3(h2); /* find the next roll to interpolate as well */ @@ -579,7 +579,7 @@ Mat4 *b_bone_spline_setup(bPoseChannel *pchan, int rest) /* make transformation matrices for the segments for drawing */ for (a = 0, fp = data[0]; a < bone->segments; a++, fp += 4) { - sub_v3_v3v3(h1, fp+4, fp); + sub_v3_v3v3(h1, fp + 4, fp); vec_roll_to_mat3(h1, fp[3], mat3); /* fp[3] is roll */ copy_m4_m3(result_array[a].mat, mat3); @@ -613,11 +613,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info int a; /* allocate b_bone matrices and dual quats */ - b_bone_mats = MEM_mallocN((1+bone->segments)*sizeof(Mat4), "BBone defmats"); + b_bone_mats = MEM_mallocN((1 + bone->segments) * sizeof(Mat4), "BBone defmats"); pdef_info->b_bone_mats = b_bone_mats; if (use_quaternion) { - b_bone_dual_quats = MEM_mallocN((bone->segments)*sizeof(DualQuat), "BBone dqs"); + b_bone_dual_quats = MEM_mallocN((bone->segments) * sizeof(DualQuat), "BBone dqs"); pdef_info->b_bone_dual_quats = b_bone_dual_quats; } @@ -634,11 +634,11 @@ static void pchan_b_bone_defmats(bPoseChannel *pchan, bPoseChanDeform *pdef_info for (a = 0; a < bone->segments; a++) { invert_m4_m4(tmat, b_bone_rest[a].mat); - mul_serie_m4(b_bone_mats[a+1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, + mul_serie_m4(b_bone_mats[a + 1].mat, pchan->chan_mat, bone->arm_mat, b_bone[a].mat, tmat, b_bone_mats[0].mat, NULL, NULL, NULL); if (use_quaternion) - mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a+1].mat); + mat4_to_dquat(&b_bone_dual_quats[a], bone->arm_mat, b_bone_mats[a + 1].mat); } } @@ -650,24 +650,24 @@ static void b_bone_deform(bPoseChanDeform *pdef_info, Bone *bone, float co[3], D int a; /* need to transform co back to bonespace, only need y */ - y = mat[0][1]*co[0] + mat[1][1]*co[1] + mat[2][1]*co[2] + mat[3][1]; + y = mat[0][1] * co[0] + mat[1][1] * co[1] + mat[2][1] * co[2] + mat[3][1]; /* now calculate which of the b_bones are deforming this */ - segment = bone->length/((float)bone->segments); - a = (int)(y/segment); + segment = bone->length / ((float)bone->segments); + a = (int)(y / segment); /* note; by clamping it extends deform at endpoints, goes best with * straight joints in restpos. */ - CLAMP(a, 0, bone->segments-1); + CLAMP(a, 0, bone->segments - 1); if (dq) { copy_dq_dq(dq, &(pdef_info->b_bone_dual_quats)[a]); } else { - mul_m4_v3(b_bone[a+1].mat, co); + mul_m4_v3(b_bone[a + 1].mat, co); if (defmat) { - copy_m3_m4(defmat, b_bone[a+1].mat); + copy_m3_m4(defmat, b_bone[a + 1].mat); } } } @@ -699,27 +699,27 @@ float distfactor_to_bone(const float vec[3], const float b1[3], const float b2[3 rad = rad2; } else { - dist = (hsqr - (a*a)); + dist = (hsqr - (a * a)); if (l != 0.0f) { - rad = a/l; - rad = rad*rad2 + (1.0f-rad)*rad1; + rad = a / l; + rad = rad * rad2 + (1.0f - rad) * rad1; } else rad = rad1; } - a = rad*rad; + a = rad * rad; if (dist < a) return 1.0f; else { - l = rad+rdist; + l = rad + rdist; l *= l; if (rdist == 0.0f || dist >= l) return 0.0f; else { - a = sqrtf(dist)-rad; - return 1.0f-( a*a )/( rdist*rdist ); + a = sqrtf(dist) - rad; + return 1.0f - (a * a) / (rdist * rdist); } } } @@ -796,15 +796,15 @@ static void pchan_bone_deform(bPoseChannel *pchan, bPoseChanDeform *pdef_info, f copy_v3_v3(cop, co); if (vec) { - if (pchan->bone->segments>1) + if (pchan->bone->segments > 1) /* applies on cop and bbonemat */ b_bone_deform(pdef_info, pchan->bone, cop, NULL, (mat) ? bbonemat : NULL); else mul_m4_v3(pchan->chan_mat, cop); - vec[0] += (cop[0]-co[0])*weight; - vec[1] += (cop[1]-co[1])*weight; - vec[2] += (cop[2]-co[2])*weight; + vec[0] += (cop[0] - co[0]) * weight; + vec[1] += (cop[1] - co[1]) * weight; + vec[2] += (cop[2] - co[2]) * weight; if (mat) pchan_deform_mat_add(pchan, weight, bbonemat, mat); @@ -856,10 +856,10 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float totchan = BLI_countlist(&armOb->pose->chanbase); if (use_quaternion) { - dualquats = MEM_callocN(sizeof(DualQuat)*totchan, "dualquats"); + dualquats = MEM_callocN(sizeof(DualQuat) * totchan, "dualquats"); } - pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform)*totchan, "bPoseChanDeform"); + pdef_info_array = MEM_callocN(sizeof(bPoseChanDeform) * totchan, "bPoseChanDeform"); totchan = 0; pdef_info = pdef_info_array; @@ -891,7 +891,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float Lattice *lt = target->data; dverts = lt->dvert; if (dverts) - target_totvert = lt->pntsu*lt->pntsv*lt->pntsw; + target_totvert = lt->pntsu * lt->pntsv * lt->pntsw; } } @@ -909,7 +909,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float defnrToPC = MEM_callocN(sizeof(*defnrToPC) * defbase_tot, "defnrToBone"); defnrToPCIndex = MEM_callocN(sizeof(*defnrToPCIndex) * defbase_tot, "defnrToIndex"); for (i = 0, dg = target->defbase.first; dg; i++, dg = dg->next) { - defnrToPC[i] = get_pose_channel(armOb->pose, dg->name); + defnrToPC[i] = BKE_pose_channel_find_name(armOb->pose, dg->name); /* exclude non-deforming bones */ if (defnrToPC[i]) { if (defnrToPC[i]->bone->flag & BONE_NO_DEFORM) { @@ -963,7 +963,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float armature_weight = defvert_find_weight(dvert, armature_def_nr); if (invert_vgroup) - armature_weight = 1.0f-armature_weight; + armature_weight = 1.0f - armature_weight; /* hackish: the blending factor can be used for blending with prevCos too */ if (prevCos) { @@ -1039,7 +1039,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float smat = summat; } else { - mul_v3_fl(vec, armature_weight/contrib); + mul_v3_fl(vec, armature_weight / contrib); add_v3_v3v3(co, vec, co); } @@ -1051,7 +1051,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float copy_m3_m3(tmpmat, defMats[i]); if (!use_quaternion) /* quaternion already is scale corrected */ - mul_m3_fl(smat, armature_weight/contrib); + mul_m3_fl(smat, armature_weight / contrib); mul_serie_m3(defMats[i], tmpmat, pre, smat, post, NULL, NULL, NULL, NULL); } @@ -1063,9 +1063,9 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float /* interpolate with previous modifier position using weight group */ if (prevCos) { float mw = 1.0f - prevco_weight; - vertexCos[i][0] = prevco_weight*vertexCos[i][0] + mw*co[0]; - vertexCos[i][1] = prevco_weight*vertexCos[i][1] + mw*co[1]; - vertexCos[i][2] = prevco_weight*vertexCos[i][2] + mw*co[2]; + vertexCos[i][0] = prevco_weight * vertexCos[i][0] + mw * co[0]; + vertexCos[i][1] = prevco_weight * vertexCos[i][1] + mw * co[1]; + vertexCos[i][2] = prevco_weight * vertexCos[i][2] + mw * co[2]; } } @@ -1090,7 +1090,7 @@ void armature_deform_verts(Object *armOb, Object *target, DerivedMesh *dm, float /* ************ END Armature Deform ******************* */ -void get_objectspace_bone_matrix(struct Bone* bone, float M_accumulatedMatrix[][4], int UNUSED(root), +void get_objectspace_bone_matrix(struct Bone *bone, float M_accumulatedMatrix[][4], int UNUSED(root), int UNUSED(posed)) { copy_m4_m4(M_accumulatedMatrix, bone->arm_mat); @@ -1099,7 +1099,7 @@ void get_objectspace_bone_matrix(struct Bone* bone, float M_accumulatedMatrix[][ /* **************** Space to Space API ****************** */ /* Convert World-Space Matrix to Pose-Space Matrix */ -void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) { float obmat[4][4]; @@ -1117,7 +1117,7 @@ void armature_mat_world_to_pose(Object *ob, float inmat[][4], float outmat[][4]) /* Convert World-Space Location to Pose-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3]) +void BKE_armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3]) { float xLocMat[4][4] = MAT4_UNITY; float nLocMat[4][4]; @@ -1126,7 +1126,7 @@ void armature_loc_world_to_pose(Object *ob, const float inloc[3], float outloc[3 copy_v3_v3(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ - armature_mat_world_to_pose(ob, xLocMat, nLocMat); + BKE_armature_mat_world_to_pose(ob, xLocMat, nLocMat); copy_v3_v3(outloc, nLocMat[3]); } @@ -1165,7 +1165,7 @@ static void get_offset_bone_mat(Bone *bone, float offs_bone[][4]) * pose-channel into its local space (i.e. 'visual'-keyframing). * (note: I don't understand that, so I keep it :p --mont29). */ -void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]) +void BKE_pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_mat[][4]) { Bone *bone, *parbone; bPoseChannel *parchan; @@ -1229,7 +1229,7 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m mult_m4_m4m4(loc_mat, bone_loc, tmat4); } /* Those flags do not affect position, use plain parent transform space! */ - else if (bone->flag & (BONE_HINGE|BONE_NO_SCALE)) { + else if (bone->flag & (BONE_HINGE | BONE_NO_SCALE)) { mult_m4_m4m4(loc_mat, parchan->pose_mat, offs_bone); } /* Else (i.e. default, usual case), just use the same matrix for rotation/scaling, and location. */ @@ -1254,14 +1254,14 @@ void pchan_to_pose_mat(bPoseChannel *pchan, float rotscale_mat[][4], float loc_m /* Convert Pose-Space Matrix to Bone-Space Matrix. * NOTE: this cannot be used to convert to pose-space transforms of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) { float rotscale_mat[4][4], loc_mat[4][4], inmat_[4][4]; /* Security, this allows to call with inmat == outmat! */ copy_m4_m4(inmat_, inmat); - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); invert_m4(rotscale_mat); invert_m4(loc_mat); @@ -1270,14 +1270,14 @@ void armature_mat_pose_to_bone(bPoseChannel *pchan, float inmat[][4], float outm } /* Convert Bone-Space Matrix to Pose-Space Matrix. */ -void armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outmat[][4]) { float rotscale_mat[4][4], loc_mat[4][4], inmat_[4][4]; /* Security, this allows to call with inmat == outmat! */ copy_m4_m4(inmat_, inmat); - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); mult_m4_m4m4(outmat, rotscale_mat, inmat_); mul_v3_m4v3(outmat[3], loc_mat, inmat_[3]); @@ -1286,7 +1286,7 @@ void armature_mat_bone_to_pose(bPoseChannel *pchan, float inmat[][4], float outm /* Convert Pose-Space Location to Bone-Space Location * NOTE: this cannot be used to convert to pose-space location of the supplied * pose-channel into its local space (i.e. 'visual'-keyframing) */ -void armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3]) +void BKE_armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float outloc[3]) { float xLocMat[4][4] = MAT4_UNITY; float nLocMat[4][4]; @@ -1295,29 +1295,29 @@ void armature_loc_pose_to_bone(bPoseChannel *pchan, const float inloc[3], float copy_v3_v3(xLocMat[3], inloc); /* get bone-space cursor matrix and extract location */ - armature_mat_pose_to_bone(pchan, xLocMat, nLocMat); + BKE_armature_mat_pose_to_bone(pchan, xLocMat, nLocMat); copy_v3_v3(outloc, nLocMat[3]); } -void armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[][4], float outmat[][4]) +void BKE_armature_mat_pose_to_bone_ex(Object *ob, bPoseChannel *pchan, float inmat[][4], float outmat[][4]) { bPoseChannel work_pchan = *pchan; /* recalculate pose matrix with only parent transformations, * bone loc/sca/rot is ignored, scene and frame are not used. */ - where_is_pose_bone(NULL, ob, &work_pchan, 0.0f, FALSE); + BKE_pose_where_is_bone(NULL, ob, &work_pchan, 0.0f, FALSE); /* find the matrix, need to remove the bone transforms first so this is * calculated as a matrix to set rather then a difference ontop of whats * already there. */ unit_m4(outmat); - pchan_apply_mat4(&work_pchan, outmat, FALSE); + BKE_pchan_apply_mat4(&work_pchan, outmat, FALSE); - armature_mat_pose_to_bone(&work_pchan, inmat, outmat); + BKE_armature_mat_pose_to_bone(&work_pchan, inmat, outmat); } -/* same as object_mat3_to_rot() */ -void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) +/* same as BKE_object_mat3_to_rot() */ +void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) { switch (pchan->rotmode) { case ROT_MODE_QUAT: @@ -1335,18 +1335,18 @@ void pchan_mat3_to_rot(bPoseChannel *pchan, float mat[][3], short use_compat) } /* Apply a 4x4 matrix to the pose bone, - * similar to object_apply_mat4() */ -void pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) + * similar to BKE_object_apply_mat4() */ +void BKE_pchan_apply_mat4(bPoseChannel *pchan, float mat[][4], short use_compat) { float rot[3][3]; mat4_to_loc_rot_size(pchan->loc, rot, pchan->size, mat); - pchan_mat3_to_rot(pchan, rot, use_compat); + BKE_pchan_mat3_to_rot(pchan, rot, use_compat); } /* Remove rest-position effects from pose-transform for obtaining * 'visual' transformation of pose-channel. * (used by the Visual-Keyframing stuff) */ -void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) +void BKE_armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]) { float imat[4][4]; @@ -1463,8 +1463,12 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) * * was 0.000001, causes bug [#30438] (which is same as [#27675, imho). * Reseting it to org value seems to cause no more [#23954]... + * + * was 0.0000000000001, caused bug [#31333], smaller values give unstable + * roll when toggling editmode again... + * No good value here, trying 0.000000001 as best compromize. :/ */ - if (dot_v3v3(axis, axis) > 1.0e-13f) { + if (dot_v3v3(axis, axis) > 1.0e-9f) { /* if nor is *not* a multiple of target ... */ normalize_v3(axis); @@ -1496,7 +1500,7 @@ void vec_roll_to_mat3(const float vec[3], const float roll, float mat[][3]) /* recursive part, calculates restposition of entire tree of children */ /* used by exiting editmode too */ -void where_is_armature_bone(Bone *bone, Bone *prevbone) +void BKE_armature_where_is_bone(Bone *bone, Bone *prevbone) { float vec[3]; @@ -1529,19 +1533,19 @@ void where_is_armature_bone(Bone *bone, Bone *prevbone) /* and the kiddies */ prevbone = bone; for (bone = bone->childbase.first; bone; bone = bone->next) { - where_is_armature_bone(bone, prevbone); + BKE_armature_where_is_bone(bone, prevbone); } } /* updates vectors and matrices on rest-position level, only needed * after editing armature itself, now only on reading file */ -void where_is_armature(bArmature *arm) +void BKE_armature_where_is(bArmature *arm) { Bone *bone; /* hierarchical from root to children */ for (bone = arm->bonebase.first; bone; bone = bone->next) { - where_is_armature_bone(bone, NULL); + BKE_armature_where_is_bone(bone, NULL); } } @@ -1561,7 +1565,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected * to avoid crashing check for possible errors here */ for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->layer & layer_protected) { - if (get_pose_channel(frompose, pchan->name) == NULL) { + if (BKE_pose_channel_find_name(frompose, pchan->name) == NULL) { printf("failed to sync proxy armature because '%s' is missing pose channel '%s'\n", from->id.name, pchan->name); error = 1; @@ -1573,19 +1577,19 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected return; /* clear all transformation values from library */ - rest_pose(frompose); + BKE_pose_rest(frompose); /* copy over all of the proxy's bone groups */ - /* TODO for later - * - implement 'local' bone groups as for constraints - * Note: this isn't trivial, as bones reference groups by index not by pointer, - * so syncing things correctly needs careful attention */ + /* TODO for later + * - implement 'local' bone groups as for constraints + * Note: this isn't trivial, as bones reference groups by index not by pointer, + * so syncing things correctly needs careful attention */ BLI_freelistN(&pose->agroups); BLI_duplicatelist(&pose->agroups, &frompose->agroups); pose->active_group = frompose->active_group; for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { - pchanp = get_pose_channel(frompose, pchan->name); + pchanp = BKE_pose_channel_find_name(frompose, pchan->name); if (pchan->bone->layer & layer_protected) { ListBase proxylocal_constraints = {NULL, NULL}; @@ -1638,7 +1642,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected } /* free stuff from current channel */ - free_pose_channel(pchan); + BKE_pose_channel_free(pchan); /* the final copy */ *pchan = pchanw; @@ -1672,7 +1676,7 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int counter) { - bPoseChannel *pchan = verify_pose_channel(pose, bone->name); /* verify checks and/or adds */ + bPoseChannel *pchan = BKE_pose_channel_verify(pose, bone->name); /* verify checks and/or adds */ pchan->bone = bone; pchan->parent = parchan; @@ -1683,7 +1687,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int counter = rebuild_pose_bone(pose, bone, pchan, counter); /* for quick detecting of next bone in chain, only b-bone uses it now */ if (bone->flag & BONE_CONNECTED) - pchan->child = get_pose_channel(pose, bone->name); + pchan->child = BKE_pose_channel_find_name(pose, bone->name); } return counter; @@ -1691,7 +1695,7 @@ static int rebuild_pose_bone(bPose *pose, Bone *bone, bPoseChannel *parchan, int /* only after leave editmode, duplicating, validating older files, library syncing */ /* NOTE: pose->flag is set for it */ -void armature_rebuild_pose(Object *ob, bArmature *arm) +void BKE_pose_rebuild(Object *ob, bArmature *arm) { Bone *bone; bPose *pose; @@ -1723,8 +1727,8 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) for (pchan = pose->chanbase.first; pchan; pchan = next) { next = pchan->next; if (pchan->bone == NULL) { - free_pose_channel(pchan); - free_pose_channels_hash(pose); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(pose); BLI_freelinkN(&pose->chanbase, pchan); } } @@ -1732,20 +1736,20 @@ void armature_rebuild_pose(Object *ob, bArmature *arm) /* synchronize protected layers with proxy */ if (ob->proxy) { - object_copy_proxy_drivers(ob, ob->proxy); + BKE_object_copy_proxy_drivers(ob, ob->proxy); pose_proxy_synchronize(ob, ob->proxy, arm->layer_protected); } - update_pose_constraint_flags(ob->pose); /* for IK detection for example */ + BKE_pose_update_constraint_flags(ob->pose); /* for IK detection for example */ /* the sorting */ - if (counter>1) + if (counter > 1) DAG_pose_sort(ob); ob->pose->flag &= ~POSE_RECALC; ob->pose->flag |= POSE_WAS_REBUILT; - make_pose_channels_hash(ob->pose); + BKE_pose_channels_hash_make(ob->pose); } @@ -1792,7 +1796,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos if ((ikData->tar == NULL) || (ikData->tar->type != OB_CURVE)) continue; /* skip if disabled */ - if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF))) + if ((con->enforce == 0.0f) || (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF))) continue; /* otherwise, constraint is ok... */ @@ -1814,7 +1818,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos /* only happens on reload file, but violates depsgraph still... fix! */ if ((cu->path == NULL) || (cu->path->data == NULL)) - makeDispListCurveTypes(scene, ikData->tar, 0); + BKE_displist_make_curveTypes(scene, ikData->tar, 0); } /* find the root bone and the chain of bones from the root to the tip @@ -1831,7 +1835,7 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos if (segcount == 0) return; else - pchanRoot = pchanChain[segcount-1]; + pchanRoot = pchanChain[segcount - 1]; /* perform binding step if required */ if ((ikData->flag & CONSTRAINT_SPLINEIK_BOUND) == 0) { @@ -1841,8 +1845,8 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos /* setup new empty array for the points list */ if (ikData->points) MEM_freeN(ikData->points); - ikData->numpoints = ikData->chainlen+1; - ikData->points = MEM_callocN(sizeof(float)*ikData->numpoints, "Spline IK Binding"); + ikData->numpoints = ikData->chainlen + 1; + ikData->points = MEM_callocN(sizeof(float) * ikData->numpoints, "Spline IK Binding"); /* bind 'tip' of chain (i.e. first joint = tip of bone with the Spline IK Constraint) */ ikData->points[0] = 1.0f; @@ -1856,13 +1860,13 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos */ if ((ikData->flag & CONSTRAINT_SPLINEIK_EVENSPLITS) || (totLength == 0.0f)) { /* 1) equi-spaced joints */ - ikData->points[i+1] = ikData->points[i] - segmentLen; + ikData->points[i + 1] = ikData->points[i] - segmentLen; } else { /* 2) to find this point on the curve, we take a step from the previous joint * a distance given by the proportion that this bone takes */ - ikData->points[i+1] = ikData->points[i] - (boneLengths[i] / totLength); + ikData->points[i + 1] = ikData->points[i] - (boneLengths[i] / totLength); } } @@ -1916,8 +1920,8 @@ static void splineik_init_tree_from_pchan(Scene *scene, Object *UNUSED(ob), bPos tree->chainlen = segcount; /* copy over the array of links to bones in the chain (from tip to root) */ - tree->chain = MEM_callocN(sizeof(bPoseChannel*)*segcount, "SplineIK Chain"); - memcpy(tree->chain, pchanChain, sizeof(bPoseChannel*)*segcount); + tree->chain = MEM_callocN(sizeof(bPoseChannel *) * segcount, "SplineIK Chain"); + memcpy(tree->chain, pchanChain, sizeof(bPoseChannel *) * segcount); /* store reference to joint position array */ tree->points = jointPoints; @@ -1956,10 +1960,10 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o { bSplineIKConstraint *ikData = tree->ikData; float poseHead[3], poseTail[3], poseMat[4][4]; - float splineVec[3], scaleFac, radius =1.0f; + float splineVec[3], scaleFac, radius = 1.0f; /* firstly, calculate the bone matrix the standard way, since this is needed for roll control */ - where_is_pose_bone(scene, ob, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); copy_v3_v3(poseHead, pchan->pose_head); copy_v3_v3(poseTail, pchan->pose_tail); @@ -1970,14 +1974,14 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o float tailBlendFac = 1.0f; /* determine if the bone should still be affected by SplineIK */ - if (tree->points[index+1] >= 1.0f) { + if (tree->points[index + 1] >= 1.0f) { /* spline doesn't affect the bone anymore, so done... */ pchan->flag |= POSE_DONE; return; } - else if ((tree->points[index] >= 1.0f) && (tree->points[index+1] < 1.0f)) { + else if ((tree->points[index] >= 1.0f) && (tree->points[index + 1] < 1.0f)) { /* blending factor depends on the amount of the bone still left on the chain */ - tailBlendFac = (1.0f - tree->points[index+1]) / (tree->points[index] - tree->points[index+1]); + tailBlendFac = (1.0f - tree->points[index + 1]) / (tree->points[index] - tree->points[index + 1]); } /* tail endpoint */ @@ -1997,7 +2001,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o } /* head endpoint */ - if (where_on_path(ikData->tar, tree->points[index+1], vec, dir, NULL, &rad, NULL)) { + if (where_on_path(ikData->tar, tree->points[index + 1], vec, dir, NULL, &rad, NULL)) { /* apply curve's object-mode transforms to the position * unless the option to allow curve to be positioned elsewhere is activated (i.e. no root) */ @@ -2009,7 +2013,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o copy_v3_v3(poseHead, vec); /* set the new radius (it should be the average value) */ - radius = (radius+rad) / 2; + radius = (radius + rad) / 2; } } @@ -2083,7 +2087,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o scale = len_v3(pchan->pose_mat[2]); mul_v3_fl(poseMat[2], scale); } - break; + break; case CONSTRAINT_SPLINEIK_XZS_VOLUMETRIC: { /* 'volume preservation' */ @@ -2106,7 +2110,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o mul_v3_fl(poseMat[0], scale); mul_v3_fl(poseMat[2], scale); } - break; + break; } /* finally, multiply the x and z scaling by the radius of the curve too, @@ -2145,7 +2149,7 @@ static void splineik_evaluate_bone(tSplineIK_Tree *tree, Scene *scene, Object *o copy_v3_v3(pchan->pose_head, poseHead); /* recalculate tail, as it's now outdated after the head gets adjusted above! */ - where_is_pose_bone_tail(pchan); + BKE_pose_where_is_bone_tail(pchan); /* done! */ pchan->flag |= POSE_DONE; @@ -2164,7 +2168,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_ * - the chain is traversed in the opposite order to storage order (i.e. parent to children) * so that dependencies are correct */ - for (i = tree->chainlen-1; i >= 0; i--) { + for (i = tree->chainlen - 1; i >= 0; i--) { bPoseChannel *pchan = tree->chain[i]; splineik_evaluate_bone(tree, scene, ob, pchan, i, ctime); } @@ -2183,7 +2187,7 @@ static void splineik_execute_tree(Scene *scene, Object *ob, bPoseChannel *pchan_ /* ********************** THE POSE SOLVER ******************* */ /* loc/rot/size to given mat4 */ -void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) +void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) { float smat[3][3]; float rmat[3][3]; @@ -2226,12 +2230,12 @@ void pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4]) /* loc/rot/size to mat4 */ /* used in constraint.c too */ -void pchan_calc_mat(bPoseChannel *pchan) +void BKE_pchan_calc_mat(bPoseChannel *pchan) { /* this is just a wrapper around the copy of this function which calculates the matrix * and stores the result in any given channel */ - pchan_to_mat4(pchan, pchan->chan_mat); + BKE_pchan_to_mat4(pchan, pchan->chan_mat); } #if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ @@ -2241,116 +2245,116 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha { bActionModifier *amod; bActionStrip *strip, *strip2; - float scene_cfra= (float)scene->r.cfra; + float scene_cfra = (float)scene->r.cfra; int do_modif; - for (strip=armob->nlastrips.first; strip; strip=strip->next) { - do_modif=0; + for (strip = armob->nlastrips.first; strip; strip = strip->next) { + do_modif = 0; - if (scene_cfra>=strip->start && scene_cfra<=strip->end) - do_modif=1; + if (scene_cfra >= strip->start && scene_cfra <= strip->end) + do_modif = 1; if ((scene_cfra > strip->end) && (strip->flag & ACTSTRIP_HOLDLASTFRAME)) { - do_modif=1; + do_modif = 1; /* if there are any other strips active, ignore modifiers for this strip - * 'hold' option should only hold action modifiers if there are * no other active strips */ - for (strip2=strip->next; strip2; strip2=strip2->next) { + for (strip2 = strip->next; strip2; strip2 = strip2->next) { if (strip2 == strip) continue; - if (scene_cfra>=strip2->start && scene_cfra<=strip2->end) { + if (scene_cfra >= strip2->start && scene_cfra <= strip2->end) { if (!(strip2->flag & ACTSTRIP_MUTE)) - do_modif=0; + do_modif = 0; } } /* if there are any later, activated, strips with 'hold' set, they take precedence, * so ignore modifiers for this strip */ - for (strip2=strip->next; strip2; strip2=strip2->next) { + for (strip2 = strip->next; strip2; strip2 = strip2->next) { if (scene_cfra < strip2->start) continue; if ((strip2->flag & ACTSTRIP_HOLDLASTFRAME) && !(strip2->flag & ACTSTRIP_MUTE)) { - do_modif=0; + do_modif = 0; } } } if (do_modif) { /* temporal solution to prevent 2 strips accumulating */ - if (scene_cfra==strip->end && strip->next && strip->next->start==scene_cfra) + if (scene_cfra == strip->end && strip->next && strip->next->start == scene_cfra) continue; - for (amod= strip->modifiers.first; amod; amod= amod->next) { + for (amod = strip->modifiers.first; amod; amod = amod->next) { switch (amod->type) { - case ACTSTRIP_MOD_DEFORM: - { - /* validate first */ - if (amod->ob && amod->ob->type==OB_CURVE && amod->channel[0]) { + case ACTSTRIP_MOD_DEFORM: + { + /* validate first */ + if (amod->ob && amod->ob->type == OB_CURVE && amod->channel[0]) { - if ( strcmp(pchan->name, amod->channel)==0 ) { - float mat4[4][4], mat3[3][3]; + if (strcmp(pchan->name, amod->channel) == 0) { + float mat4[4][4], mat3[3][3]; - curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); - copy_m4_m4(mat4, pchan->pose_mat); - mul_m4_m3m4(pchan->pose_mat, mat3, mat4); + curve_deform_vector(scene, amod->ob, armob, bone->arm_mat[3], pchan->pose_mat[3], mat3, amod->no_rot_axis); + copy_m4_m4(mat4, pchan->pose_mat); + mul_m4_m3m4(pchan->pose_mat, mat3, mat4); + } } } - } break; - case ACTSTRIP_MOD_NOISE: - { - if ( strcmp(pchan->name, amod->channel)==0 ) { - float nor[3], loc[3], ofs; - float eul[3], size[3], eulo[3], sizeo[3]; + case ACTSTRIP_MOD_NOISE: + { + if (strcmp(pchan->name, amod->channel) == 0) { + float nor[3], loc[3], ofs; + float eul[3], size[3], eulo[3], sizeo[3]; - /* calculate turbulance */ - ofs = amod->turbul / 200.0f; + /* calculate turbulance */ + ofs = amod->turbul / 200.0f; - /* make a copy of starting conditions */ - copy_v3_v3(loc, pchan->pose_mat[3]); - mat4_to_eul(eul, pchan->pose_mat); - mat4_to_size(size, pchan->pose_mat); - copy_v3_v3(eulo, eul); - copy_v3_v3(sizeo, size); + /* make a copy of starting conditions */ + copy_v3_v3(loc, pchan->pose_mat[3]); + mat4_to_eul(eul, pchan->pose_mat); + mat4_to_size(size, pchan->pose_mat); + copy_v3_v3(eulo, eul); + copy_v3_v3(sizeo, size); - /* apply noise to each set of channels */ - if (amod->channels & 4) { - /* for scaling */ - nor[0] = BLI_gNoise(amod->noisesize, size[0]+ofs, size[1], size[2], 0, 0) - ofs; - nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1]+ofs, size[2], 0, 0) - ofs; - nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2]+ofs, 0, 0) - ofs; - add_v3_v3(size, nor); + /* apply noise to each set of channels */ + if (amod->channels & 4) { + /* for scaling */ + nor[0] = BLI_gNoise(amod->noisesize, size[0] + ofs, size[1], size[2], 0, 0) - ofs; + nor[1] = BLI_gNoise(amod->noisesize, size[0], size[1] + ofs, size[2], 0, 0) - ofs; + nor[2] = BLI_gNoise(amod->noisesize, size[0], size[1], size[2] + ofs, 0, 0) - ofs; + add_v3_v3(size, nor); - if (sizeo[0] != 0) - mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); - if (sizeo[1] != 0) - mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]); - if (sizeo[2] != 0) - mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]); - } - if (amod->channels & 2) { - /* for rotation */ - nor[0] = BLI_gNoise(amod->noisesize, eul[0]+ofs, eul[1], eul[2], 0, 0) - ofs; - nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1]+ofs, eul[2], 0, 0) - ofs; - nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2]+ofs, 0, 0) - ofs; + if (sizeo[0] != 0) + mul_v3_fl(pchan->pose_mat[0], size[0] / sizeo[0]); + if (sizeo[1] != 0) + mul_v3_fl(pchan->pose_mat[1], size[1] / sizeo[1]); + if (sizeo[2] != 0) + mul_v3_fl(pchan->pose_mat[2], size[2] / sizeo[2]); + } + if (amod->channels & 2) { + /* for rotation */ + nor[0] = BLI_gNoise(amod->noisesize, eul[0] + ofs, eul[1], eul[2], 0, 0) - ofs; + nor[1] = BLI_gNoise(amod->noisesize, eul[0], eul[1] + ofs, eul[2], 0, 0) - ofs; + nor[2] = BLI_gNoise(amod->noisesize, eul[0], eul[1], eul[2] + ofs, 0, 0) - ofs; - compatible_eul(nor, eulo); - add_v3_v3(eul, nor); - compatible_eul(eul, eulo); + compatible_eul(nor, eulo); + add_v3_v3(eul, nor); + compatible_eul(eul, eulo); - loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); - } - if (amod->channels & 1) { - /* for location */ - nor[0] = BLI_gNoise(amod->noisesize, loc[0]+ofs, loc[1], loc[2], 0, 0) - ofs; - nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1]+ofs, loc[2], 0, 0) - ofs; - nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2]+ofs, 0, 0) - ofs; + loc_eul_size_to_mat4(pchan->pose_mat, loc, eul, size); + } + if (amod->channels & 1) { + /* for location */ + nor[0] = BLI_gNoise(amod->noisesize, loc[0] + ofs, loc[1], loc[2], 0, 0) - ofs; + nor[1] = BLI_gNoise(amod->noisesize, loc[0], loc[1] + ofs, loc[2], 0, 0) - ofs; + nor[2] = BLI_gNoise(amod->noisesize, loc[0], loc[1], loc[2] + ofs, 0, 0) - ofs; - add_v3_v3v3(pchan->pose_mat[3], loc, nor); + add_v3_v3v3(pchan->pose_mat[3], loc, nor); + } } } - } break; } } @@ -2361,7 +2365,7 @@ static void do_strip_modifiers(Scene *scene, Object *armob, Bone *bone, bPoseCha #endif /* calculate tail of posechannel */ -void where_is_pose_bone_tail(bPoseChannel *pchan) +void BKE_pose_where_is_bone_tail(bPoseChannel *pchan) { float vec[3]; @@ -2374,17 +2378,17 @@ void where_is_pose_bone_tail(bPoseChannel *pchan) /* pchan is validated, as having bone and parent pointer * 'do_extra': when zero skips loc/size/rot, constraints and strip modifiers. */ -void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, int do_extra) +void BKE_pose_where_is_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, int do_extra) { /* This gives a chan_mat with actions (ipos) results. */ if (do_extra) - pchan_calc_mat(pchan); + BKE_pchan_calc_mat(pchan); else unit_m4(pchan->chan_mat); /* Construct the posemat based on PoseChannels, that we do before applying constraints. */ /* pose_mat(b) = pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b) */ - armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); + BKE_armature_mat_bone_to_pose(pchan, pchan->chan_mat, pchan->pose_mat); /* Only rootbones get the cyclic offset (unless user doesn't want that). */ /* XXX That could be a problem for snapping and other "reverse transform" features... */ @@ -2394,7 +2398,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti } if (do_extra) { -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ /* do NLA strip modifiers - i.e. curve follow */ do_strip_modifiers(scene, ob, bone, pchan); #endif @@ -2413,7 +2417,7 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti cob = constraints_make_evalob(scene, ob, pchan, CONSTRAINT_OBTYPE_BONE); /* Solve PoseChannel's Constraints */ - solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */ + solve_constraints(&pchan->constraints, cob, ctime); /* ctime doesnt alter objects */ /* cleanup after Constraint Solving * - applies matrix back to pchan, and frees temporary struct used @@ -2430,12 +2434,12 @@ void where_is_pose_bone(Scene *scene, Object *ob, bPoseChannel *pchan, float cti /* calculate head */ copy_v3_v3(pchan->pose_head, pchan->pose_mat[3]); /* calculate tail */ - where_is_pose_bone_tail(pchan); + BKE_pose_where_is_bone_tail(pchan); } /* This only reads anim data from channels, and writes to channels */ /* This is the only function adding poses */ -void where_is_pose(Scene *scene, Object *ob) +void BKE_pose_where_is(Scene *scene, Object *ob) { bArmature *arm; Bone *bone; @@ -2450,9 +2454,9 @@ void where_is_pose(Scene *scene, Object *ob) if (ELEM(NULL, arm, scene)) return; if ((ob->pose == NULL) || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, arm); + BKE_pose_rebuild(ob, arm); - ctime = BKE_curframe(scene); /* not accurate... */ + ctime = BKE_scene_frame_get(scene); /* not accurate... */ /* In editmode or restposition we read the data from the bones */ if (arm->edbo || (arm->flag & ARM_RESTPOS)) { @@ -2470,7 +2474,7 @@ void where_is_pose(Scene *scene, Object *ob) /* 1. clear flags */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { - pchan->flag &= ~(POSE_DONE|POSE_CHAIN|POSE_IKTREE|POSE_IKSPLINE); + pchan->flag &= ~(POSE_DONE | POSE_CHAIN | POSE_IKTREE | POSE_IKSPLINE); } /* 2a. construct the IK tree (standard IK) */ @@ -2494,7 +2498,7 @@ void where_is_pose(Scene *scene, Object *ob) } /* 5. otherwise just call the normal solver */ else if (!(pchan->flag & POSE_DONE)) { - where_is_pose_bone(scene, ob, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob, pchan, ctime, 1); } } /* 6. release the IK tree */ @@ -2517,13 +2521,13 @@ int get_selected_defgroups(Object *ob, char *dg_selection, int defbase_tot) { bDeformGroup *defgroup; unsigned int i; - Object *armob = object_pose_armature_get(ob); + Object *armob = BKE_object_pose_armature_get(ob); int dg_flags_sel_tot = 0; if (armob) { bPose *pose = armob->pose; for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { - bPoseChannel *pchan = get_pose_channel(pose, defgroup->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, defgroup->name); if (pchan && (pchan->bone->flag & BONE_SELECTED)) { dg_selection[i] = TRUE; dg_flags_sel_tot++; @@ -2545,7 +2549,7 @@ int minmax_armature(Object *ob, float min[3], float max[3]) { bPoseChannel *pchan; - /* For now, we assume where_is_pose has already been called (hence we have valid data in pachan). */ + /* For now, we assume BKE_pose_where_is has already been called (hence we have valid data in pachan). */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { DO_MINMAX(pchan->pose_head, min, max); DO_MINMAX(pchan->pose_tail, min, max); @@ -2581,10 +2585,10 @@ void boundbox_armature(Object *ob, float *loc, float *size) size[1] = (max[1] - min[1]) / 2.0f; size[2] = (max[2] - min[2]) / 2.0f; - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } -BoundBox *BKE_armature_get_bb(Object *ob) +BoundBox *BKE_armature_boundbox_get(Object *ob) { boundbox_armature(ob, NULL, NULL); diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index b0bfd2ee98d..b2cbf0a1ce1 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -91,11 +91,15 @@ #include "WM_api.h" // XXXXX BAD, very BAD dependency (bad level call) - remove asap, elubie +#ifdef WITH_PYTHON +#include "BPY_extern.h" +#endif + Global G; UserDef U; /* ListBase = {NULL, NULL}; */ -char versionstr[48]= ""; +char versionstr[48] = ""; /* ********** free ********** */ @@ -104,9 +108,9 @@ void free_blender(void) { /* samples are in a global list..., also sets G.main->sound->sample NULL */ free_main(G.main); - G.main= NULL; + G.main = NULL; - BKE_spacetypes_free(); /* after free main, it uses space callbacks */ + BKE_spacetypes_free(); /* after free main, it uses space callbacks */ IMB_exit(); @@ -122,18 +126,18 @@ void initglobals(void) { memset(&G, 0, sizeof(Global)); - U.savetime= 1; + U.savetime = 1; - G.main= MEM_callocN(sizeof(Main), "initglobals"); + G.main = MEM_callocN(sizeof(Main), "initglobals"); strcpy(G.ima, "//"); if (BLENDER_SUBVERSION) - BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION); + BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d.%d", BLENDER_VERSION / 100, BLENDER_VERSION % 100, BLENDER_SUBVERSION); else - BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION/100, BLENDER_VERSION%100); + BLI_snprintf(versionstr, sizeof(versionstr), "v%d.%02d", BLENDER_VERSION / 100, BLENDER_VERSION % 100); -#ifdef _WIN32 // FULLSCREEN +#ifdef _WIN32 // FULLSCREEN G.windowstate = G_WINDOWSTATE_USERDEF; #endif @@ -154,11 +158,11 @@ static void clear_global(void) { // extern short winqueue_break; /* screen.c */ - free_main(G.main); /* free all lib data */ + free_main(G.main); /* free all lib data */ // free_vertexpaint(); - G.main= NULL; + G.main = NULL; } static int clean_paths_visit_cb(void *UNUSED(userdata), char *path_dst, const char *path_src) @@ -175,7 +179,7 @@ static void clean_paths(Main *main) BLI_bpath_traverse_main(main, clean_paths_visit_cb, BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, NULL); - for (scene= main->scene.first; scene; scene= scene->id.next) { + for (scene = main->scene.first; scene; scene = scene->id.next) { BLI_clean(scene->r.pic); } } @@ -188,17 +192,17 @@ static void clean_paths(Main *main) static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath) { - bScreen *curscreen= NULL; - Scene *curscene= NULL; + bScreen *curscreen = NULL; + Scene *curscene = NULL; int recover; char mode; /* 'u' = undo save, 'n' = no UI load */ - if (bfd->main->screen.first==NULL) mode= 'u'; - else if (G.fileflags & G_FILE_NO_UI) mode= 'n'; - else mode= 0; + if (bfd->main->screen.first == NULL) mode = 'u'; + else if (G.fileflags & G_FILE_NO_UI) mode = 'n'; + else mode = 0; - recover= (G.fileflags & G_FILE_RECOVER); + recover = (G.fileflags & G_FILE_RECOVER); /* Free all render results, without this stale data gets displayed after loading files */ if (mode != 'u') { @@ -222,12 +226,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath SWAP(ListBase, G.main->script, bfd->main->script); /* we re-use current screen */ - curscreen= CTX_wm_screen(C); + curscreen = CTX_wm_screen(C); /* but use new Scene pointer */ - curscene= bfd->curscene; - if (curscene==NULL) curscene= bfd->main->scene.first; + curscene = bfd->curscene; + if (curscene == NULL) curscene = bfd->main->scene.first; /* and we enforce curscene to be in current screen */ - if (curscreen) curscreen->scene= curscene; /* can run in bgmode */ + if (curscreen) curscreen->scene = curscene; /* can run in bgmode */ /* clear_global will free G.main, here we can still restore pointers */ lib_link_screen_restore(bfd->main, curscreen, curscene); @@ -240,7 +244,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* clear old property update cache, in case some old references are left dangling */ RNA_property_update_cache_free(); - G.main= bfd->main; + G.main = bfd->main; CTX_data_main_set(C, G.main); @@ -251,7 +255,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath /* only here free userdef themes... */ BKE_userdef_free(); - U= *bfd->user; + U = *bfd->user; MEM_freeN(bfd->user); } @@ -261,9 +265,9 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath CTX_data_scene_set(C, curscene); } else { - G.winpos= bfd->winpos; - G.displaymode= bfd->displaymode; - G.fileflags= bfd->fileflags; + G.winpos = bfd->winpos; + G.displaymode = bfd->displaymode; + G.fileflags = bfd->fileflags; CTX_wm_manager_set(C, bfd->main->wm.first); CTX_wm_screen_set(C, bfd->curscreen); CTX_data_scene_set(C, bfd->curscreen->scene); @@ -273,20 +277,25 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath } /* this can happen when active scene was lib-linked, and doesn't exist anymore */ - if (CTX_data_scene(C)==NULL) { + if (CTX_data_scene(C) == NULL) { CTX_data_scene_set(C, bfd->main->scene.first); - CTX_wm_screen(C)->scene= CTX_data_scene(C); - curscene= CTX_data_scene(C); + CTX_wm_screen(C)->scene = CTX_data_scene(C); + curscene = CTX_data_scene(C); } /* special cases, override loaded flags: */ if (G.f != bfd->globalf) { const int flags_keep = (G_SWAP_EXCHANGE | G_SCRIPT_AUTOEXEC | G_SCRIPT_OVERRIDE_PREF); - bfd->globalf= (bfd->globalf & ~flags_keep) | (G.f & flags_keep); + bfd->globalf = (bfd->globalf & ~flags_keep) | (G.f & flags_keep); } - G.f= bfd->globalf; + G.f = bfd->globalf; + +#ifdef WITH_PYTHON + /* let python know about new main */ + BPY_context_update(C); +#endif if (!G.background) { //setscreen(G.curscreen); @@ -300,12 +309,12 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath if (recover && bfd->filename[0] && G.relbase_valid) { /* in case of autosave or quit.blend, use original filename instead * use relbase_valid to make sure the file is saved, else we get in the filename */ - filepath= bfd->filename; + filepath = bfd->filename; } #if 0 else if (!G.relbase_valid) { /* otherwise, use an empty string as filename, rather than */ - filepath=""; + filepath = ""; } #endif @@ -314,7 +323,7 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath BLI_strncpy(G.main->name, filepath, FILE_MAX); /* baseflags, groups, make depsgraph, etc */ - set_scene_bg(G.main, CTX_data_scene(C)); + BKE_scene_set_background(G.main, CTX_data_scene(C)); MEM_freeN(bfd); @@ -324,8 +333,8 @@ static void setup_app_data(bContext *C, BlendFileData *bfd, const char *filepath static int handle_subversion_warning(Main *main, ReportList *reports) { if (main->minversionfile > BLENDER_VERSION || - (main->minversionfile == BLENDER_VERSION && - main->minsubversionfile > BLENDER_SUBVERSION)) { + (main->minversionfile == BLENDER_VERSION && + main->minsubversionfile > BLENDER_SUBVERSION)) { BKE_reportf(reports, RPT_ERROR, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile); } @@ -348,8 +357,8 @@ void BKE_userdef_free(void) wmKeyMapItem *kmi; wmKeyMapDiffItem *kmdi; - for (km=U.user_keymaps.first; km; km=km->next) { - for (kmdi=km->diff_items.first; kmdi; kmdi=kmdi->next) { + for (km = U.user_keymaps.first; km; km = km->next) { + for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) { if (kmdi->add_item) { keymap_item_free(kmdi->add_item); MEM_freeN(kmdi->add_item); @@ -360,7 +369,7 @@ void BKE_userdef_free(void) } } - for (kmi=km->items.first; kmi; kmi=kmi->next) + for (kmi = km->items.first; kmi; kmi = kmi->next) keymap_item_free(kmi); BLI_freelistN(&km->diff_items); @@ -377,41 +386,41 @@ void BKE_userdef_free(void) int BKE_read_file(bContext *C, const char *filepath, ReportList *reports) { BlendFileData *bfd; - int retval= BKE_READ_FILE_OK; + int retval = BKE_READ_FILE_OK; - if (strstr(filepath, BLENDER_STARTUP_FILE)==NULL) /* don't print user-pref loading */ + if (strstr(filepath, BLENDER_STARTUP_FILE) == NULL) /* don't print user-pref loading */ printf("read blend: %s\n", filepath); - bfd= BLO_read_from_file(filepath, reports); + bfd = BLO_read_from_file(filepath, reports); if (bfd) { - if (bfd->user) retval= BKE_READ_FILE_OK_USERPREFS; + if (bfd->user) retval = BKE_READ_FILE_OK_USERPREFS; - if (0==handle_subversion_warning(bfd->main, reports)) { + if (0 == handle_subversion_warning(bfd->main, reports)) { free_main(bfd->main); MEM_freeN(bfd); - bfd= NULL; - retval= BKE_READ_FILE_FAIL; + bfd = NULL; + retval = BKE_READ_FILE_FAIL; } else - setup_app_data(C, bfd, filepath); // frees BFD + setup_app_data(C, bfd, filepath); // frees BFD } else BKE_reports_prependf(reports, "Loading %s failed: ", filepath); - return (bfd?retval:BKE_READ_FILE_FAIL); + return (bfd ? retval : BKE_READ_FILE_FAIL); } -int BKE_read_file_from_memory(bContext *C, char* filebuf, int filelength, ReportList *reports) +int BKE_read_file_from_memory(bContext *C, char *filebuf, int filelength, ReportList *reports) { BlendFileData *bfd; - bfd= BLO_read_from_memory(filebuf, filelength, reports); + bfd = BLO_read_from_memory(filebuf, filelength, reports); if (bfd) setup_app_data(C, bfd, ""); else BKE_reports_prepend(reports, "Loading failed: "); - return (bfd?1:0); + return (bfd ? 1 : 0); } /* memfile is the undo buffer */ @@ -419,13 +428,13 @@ int BKE_read_file_from_memfile(bContext *C, MemFile *memfile, ReportList *report { BlendFileData *bfd; - bfd= BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports); + bfd = BLO_read_from_memfile(CTX_data_main(C), G.main->name, memfile, reports); if (bfd) setup_app_data(C, bfd, ""); else BKE_reports_prepend(reports, "Loading failed: "); - return (bfd?1:0); + return (bfd ? 1 : 0); } @@ -435,7 +444,7 @@ static void (*blender_test_break_cb)(void) = NULL; void set_blender_test_break_cb(void (*func)(void) ) { - blender_test_break_cb= func; + blender_test_break_cb = func; } @@ -446,15 +455,15 @@ int blender_test_break(void) blender_test_break_cb(); } - return (G.afbreek==1); + return (G.afbreek == 1); } /* ***************** GLOBAL UNDO *************** */ -#define UNDO_DISK 0 +#define UNDO_DISK 0 -#define MAXUNDONAME 64 +#define MAXUNDONAME 64 typedef struct UndoElem { struct UndoElem *next, *prev; char str[FILE_MAX]; @@ -463,31 +472,31 @@ typedef struct UndoElem { uintptr_t undosize; } UndoElem; -static ListBase undobase={NULL, NULL}; -static UndoElem *curundo= NULL; +static ListBase undobase = {NULL, NULL}; +static UndoElem *curundo = NULL; static int read_undosave(bContext *C, UndoElem *uel) { char mainstr[sizeof(G.main->name)]; - int success=0, fileflags; + int success = 0, fileflags; /* This is needed so undoing/redoing doesn't crash with threaded previews going */ WM_jobs_stop_all(CTX_wm_manager(C)); - BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ + BLI_strncpy(mainstr, G.main->name, sizeof(mainstr)); /* temporal store */ - fileflags= G.fileflags; + fileflags = G.fileflags; G.fileflags |= G_FILE_NO_UI; if (UNDO_DISK) - success= (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); + success = (BKE_read_file(C, uel->str, NULL) != BKE_READ_FILE_FAIL); else - success= BKE_read_file_from_memfile(C, &uel->memfile, NULL); + success = BKE_read_file_from_memfile(C, &uel->memfile, NULL); /* restore */ BLI_strncpy(G.main->name, mainstr, sizeof(G.main->name)); /* restore */ - G.fileflags= fileflags; + G.fileflags = fileflags; if (success) { /* important not to update time here, else non keyed tranforms are lost */ @@ -504,33 +513,33 @@ void BKE_write_undo(bContext *C, const char *name) int nr /*, success */ /* UNUSED */; UndoElem *uel; - if ( (U.uiflag & USER_GLOBALUNDO)==0) return; - if ( U.undosteps==0) return; + if ( (U.uiflag & USER_GLOBALUNDO) == 0) return; + if (U.undosteps == 0) return; /* remove all undos after (also when curundo==NULL) */ while (undobase.last != curundo) { - uel= undobase.last; + uel = undobase.last; BLI_remlink(&undobase, uel); BLO_free_memfile(&uel->memfile); MEM_freeN(uel); } /* make new */ - curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file"); + curundo = uel = MEM_callocN(sizeof(UndoElem), "undo file"); BLI_strncpy(uel->name, name, sizeof(uel->name)); BLI_addtail(&undobase, uel); /* and limit amount to the maximum */ - nr= 0; - uel= undobase.last; + nr = 0; + uel = undobase.last; while (uel) { nr++; - if (nr==U.undosteps) break; - uel= uel->prev; + if (nr == U.undosteps) break; + uel = uel->prev; } if (uel) { - while (undobase.first!=uel) { - UndoElem *first= undobase.first; + while (undobase.first != uel) { + UndoElem *first = undobase.first; BLI_remlink(&undobase, first); /* the merge is because of compression */ BLO_merge_memfile(&first->memfile, &first->next->memfile); @@ -541,14 +550,14 @@ void BKE_write_undo(bContext *C, const char *name) /* disk save version */ if (UNDO_DISK) { - static int counter= 0; + static int counter = 0; char filepath[FILE_MAX]; char numstr[32]; int fileflags = G.fileflags & ~(G_FILE_HISTORY); /* don't do file history on undo */ /* calculate current filepath */ counter++; - counter= counter % U.undosteps; + counter = counter % U.undosteps; BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); BLI_make_file_string("/", filepath, BLI_temporary_dir(), numstr); @@ -558,34 +567,34 @@ void BKE_write_undo(bContext *C, const char *name) BLI_strncpy(curundo->str, filepath, sizeof(curundo->str)); } else { - MemFile *prevfile=NULL; + MemFile *prevfile = NULL; - if (curundo->prev) prevfile= &(curundo->prev->memfile); + if (curundo->prev) prevfile = &(curundo->prev->memfile); - memused= MEM_get_memory_in_use(); + memused = MEM_get_memory_in_use(); /* success= */ /* UNUSED */ BLO_write_file_mem(CTX_data_main(C), prevfile, &curundo->memfile, G.fileflags); - curundo->undosize= MEM_get_memory_in_use() - memused; + curundo->undosize = MEM_get_memory_in_use() - memused; } if (U.undomemory != 0) { /* limit to maximum memory (afterwards, we can't know in advance) */ - totmem= 0; - maxmem= ((uintptr_t)U.undomemory)*1024*1024; + totmem = 0; + maxmem = ((uintptr_t)U.undomemory) * 1024 * 1024; /* keep at least two (original + other) */ - uel= undobase.last; + uel = undobase.last; while (uel && uel->prev) { - totmem+= uel->undosize; - if (totmem>maxmem) break; - uel= uel->prev; + totmem += uel->undosize; + if (totmem > maxmem) break; + uel = uel->prev; } if (uel) { if (uel->prev && uel->prev->prev) - uel= uel->prev; + uel = uel->prev; - while (undobase.first!=uel) { - UndoElem *first= undobase.first; + while (undobase.first != uel) { + UndoElem *first = undobase.first; BLI_remlink(&undobase, first); /* the merge is because of compression */ BLO_merge_memfile(&first->memfile, &first->next->memfile); @@ -599,25 +608,25 @@ void BKE_write_undo(bContext *C, const char *name) void BKE_undo_step(bContext *C, int step) { - if (step==0) { + if (step == 0) { read_undosave(C, curundo); } - else if (step==1) { + else if (step == 1) { /* curundo should never be NULL, after restart or load file it should call undo_save */ - if (curundo==NULL || curundo->prev==NULL) ; // XXX error("No undo available"); + if (curundo == NULL || curundo->prev == NULL) ; // XXX error("No undo available"); else { if (G.debug & G_DEBUG) printf("undo %s\n", curundo->name); - curundo= curundo->prev; + curundo = curundo->prev; read_undosave(C, curundo); } } else { /* curundo has to remain current situation! */ - if (curundo==NULL || curundo->next==NULL) ; // XXX error("No redo available"); + if (curundo == NULL || curundo->next == NULL) ; // XXX error("No redo available"); else { read_undosave(C, curundo->next); - curundo= curundo->next; + curundo = curundo->next; if (G.debug & G_DEBUG) printf("redo %s\n", curundo->name); } } @@ -627,30 +636,30 @@ void BKE_reset_undo(void) { UndoElem *uel; - uel= undobase.first; + uel = undobase.first; while (uel) { BLO_free_memfile(&uel->memfile); - uel= uel->next; + uel = uel->next; } BLI_freelistN(&undobase); - curundo= NULL; + curundo = NULL; } /* based on index nr it does a restore */ void BKE_undo_number(bContext *C, int nr) { - curundo= BLI_findlink(&undobase, nr); + curundo = BLI_findlink(&undobase, nr); BKE_undo_step(C, 0); } /* go back to the last occurance of name in stack */ void BKE_undo_name(bContext *C, const char *name) { - UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); + UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); if (uel && uel->prev) { - curundo= uel->prev; + curundo = uel->prev; BKE_undo_step(C, 0); } } @@ -659,7 +668,7 @@ void BKE_undo_name(bContext *C, const char *name) int BKE_undo_valid(const char *name) { if (name) { - UndoElem *uel= BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); + UndoElem *uel = BLI_rfindstring(&undobase, name, offsetof(UndoElem, name)); return uel && uel->prev; } @@ -670,13 +679,13 @@ int BKE_undo_valid(const char *name) /* if active pointer, set it to 1 if true */ const char *BKE_undo_get_name(int nr, int *active) { - UndoElem *uel= BLI_findlink(&undobase, nr); + UndoElem *uel = BLI_findlink(&undobase, nr); - if (active) *active= 0; + if (active) *active = 0; if (uel) { - if (active && uel==curundo) - *active= 1; + if (active && uel == curundo) + *active = 1; return uel->name; } return NULL; @@ -685,23 +694,23 @@ const char *BKE_undo_get_name(int nr, int *active) char *BKE_undo_menu_string(void) { UndoElem *uel; - DynStr *ds= BLI_dynstr_new(); + DynStr *ds = BLI_dynstr_new(); char *menu; BLI_dynstr_append(ds, "Global Undo History %t"); - for (uel= undobase.first; uel; uel= uel->next) { + for (uel = undobase.first; uel; uel = uel->next) { BLI_dynstr_append(ds, "|"); BLI_dynstr_append(ds, uel->name); } - menu= BLI_dynstr_get_cstring(ds); + menu = BLI_dynstr_get_cstring(ds); BLI_dynstr_free(ds); return menu; } - /* saves quit.blend */ +/* saves quit.blend */ void BKE_undo_save_quit(void) { UndoElem *uel; @@ -709,16 +718,16 @@ void BKE_undo_save_quit(void) int file; char str[FILE_MAX]; - if ( (U.uiflag & USER_GLOBALUNDO)==0) return; + if ( (U.uiflag & USER_GLOBALUNDO) == 0) return; - uel= curundo; - if (uel==NULL) { + uel = curundo; + if (uel == NULL) { printf("No undo buffer to save recovery file\n"); return; } /* no undo state to save */ - if (undobase.first==undobase.last) return; + if (undobase.first == undobase.last) return; BLI_make_file_string("/", str, BLI_temporary_dir(), "quit.blend"); @@ -728,28 +737,28 @@ void BKE_undo_save_quit(void) return; } - chunk= uel->memfile.chunks.first; + chunk = uel->memfile.chunks.first; while (chunk) { - if ( write(file, chunk->buf, chunk->size) != chunk->size) break; - chunk= chunk->next; + if (write(file, chunk->buf, chunk->size) != chunk->size) break; + chunk = chunk->next; } close(file); - if (chunk) ; //XXX error("Unable to save %s, internal error", str); + if (chunk) ; //XXX error("Unable to save %s, internal error", str); else printf("Saved session recovery to %s\n", str); } /* sets curscene */ Main *BKE_undo_get_main(Scene **scene) { - Main *mainp= NULL; - BlendFileData *bfd= BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); + Main *mainp = NULL; + BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL); if (bfd) { - mainp= bfd->main; + mainp = bfd->main; if (scene) - *scene= bfd->curscene; + *scene = bfd->curscene; MEM_freeN(bfd); } diff --git a/source/blender/blenkernel/intern/booleanops_mesh.c b/source/blender/blenkernel/intern/booleanops_mesh.c index 7c225eb0fad..972793227a8 100644 --- a/source/blender/blenkernel/intern/booleanops_mesh.c +++ b/source/blender/blenkernel/intern/booleanops_mesh.c @@ -78,7 +78,7 @@ MakeCSGMeshFromBlenderBase( Mesh *me; if (output == NULL || base == NULL) return 0; - me = get_mesh(base->object); + me = BKE_mesh_from_object(base->object); output->m_descriptor.user_face_vertex_data_size = 0; output->m_descriptor.user_data_size = sizeof(FaceData); @@ -105,7 +105,7 @@ CSG_LoadBlenderMesh( Mesh *me; if (output == NULL || obj == NULL) return 0; - me = get_mesh(obj); + me = BKE_mesh_from_object(obj); output->m_descriptor.user_face_vertex_data_size = 0; output->m_descriptor.user_data_size = sizeof(FaceData); diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 51258b13f68..f019287144d 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -75,49 +75,49 @@ static void brush_defaults(Brush *brush) brush->ob_mode = OB_MODE_ALL_PAINT; /* BRUSH SCULPT TOOL SETTINGS */ - brush->weight= 1.0f; /* weight of brush 0 - 1.0 */ - brush->size= 35; /* radius of the brush in pixels */ - brush->alpha= 0.5f; /* brush strength/intensity probably variable should be renamed? */ - brush->autosmooth_factor= 0.0f; - brush->crease_pinch_factor= 0.5f; + brush->weight = 1.0f; /* weight of brush 0 - 1.0 */ + brush->size = 35; /* radius of the brush in pixels */ + brush->alpha = 0.5f; /* brush strength/intensity probably variable should be renamed? */ + brush->autosmooth_factor = 0.0f; + brush->crease_pinch_factor = 0.5f; brush->sculpt_plane = SCULPT_DISP_DIR_AREA; - brush->plane_offset= 0.0f; /* how far above or below the plane that is found by averaging the faces */ - brush->plane_trim= 0.5f; - brush->clone.alpha= 0.5f; - brush->normal_weight= 0.0f; + brush->plane_offset = 0.0f; /* how far above or below the plane that is found by averaging the faces */ + brush->plane_trim = 0.5f; + brush->clone.alpha = 0.5f; + brush->normal_weight = 0.0f; brush->flag |= BRUSH_ALPHA_PRESSURE; /* BRUSH PAINT TOOL SETTINGS */ - brush->rgb[0]= 1.0f; /* default rgb color of the brush when painting - white */ - brush->rgb[1]= 1.0f; - brush->rgb[2]= 1.0f; + brush->rgb[0] = 1.0f; /* default rgb color of the brush when painting - white */ + brush->rgb[1] = 1.0f; + brush->rgb[2] = 1.0f; /* BRUSH STROKE SETTINGS */ - brush->flag |= (BRUSH_SPACE|BRUSH_SPACE_ATTEN); - brush->spacing= 10; /* how far each brush dot should be spaced as a percentage of brush diameter */ + brush->flag |= (BRUSH_SPACE | BRUSH_SPACE_ATTEN); + brush->spacing = 10; /* how far each brush dot should be spaced as a percentage of brush diameter */ - brush->smooth_stroke_radius= 75; - brush->smooth_stroke_factor= 0.9f; + brush->smooth_stroke_radius = 75; + brush->smooth_stroke_factor = 0.9f; - brush->rate= 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */ + brush->rate = 0.1f; /* time delay between dots of paint or sculpting when doing airbrush mode */ - brush->jitter= 0.0f; + brush->jitter = 0.0f; /* BRUSH TEXTURE SETTINGS */ default_mtex(&brush->mtex); - brush->texture_sample_bias= 0; /* value to added to texture samples */ - brush->texture_overlay_alpha= 33; + brush->texture_sample_bias = 0; /* value to added to texture samples */ + brush->texture_overlay_alpha = 33; /* brush appearance */ - brush->add_col[0]= 1.00; /* add mode color is light red */ - brush->add_col[1]= 0.39; - brush->add_col[2]= 0.39; + brush->add_col[0] = 1.00; /* add mode color is light red */ + brush->add_col[1] = 0.39; + brush->add_col[2] = 0.39; - brush->sub_col[0]= 0.39; /* subtract mode color is light blue */ - brush->sub_col[1]= 0.39; - brush->sub_col[2]= 1.00; + brush->sub_col[0] = 0.39; /* subtract mode color is light blue */ + brush->sub_col[1] = 0.39; + brush->sub_col[2] = 1.00; } /* Datablock add/copy/free/make_local */ @@ -126,7 +126,7 @@ Brush *BKE_brush_add(const char *name) { Brush *brush; - brush= alloc_libblock(&G.main->brush, ID_BR, name); + brush = BKE_libblock_alloc(&G.main->brush, ID_BR, name); /* enable fake user by default */ brush->id.flag |= LIB_FAKEUSER; @@ -135,7 +135,7 @@ Brush *BKE_brush_add(const char *name) brush->sculpt_tool = SCULPT_TOOL_DRAW; /* sculpting defaults to the draw tool for new brushes */ - /* the default alpha falloff curve */ + /* the default alpha falloff curve */ BKE_brush_curve_preset(brush, CURVE_PRESET_SMOOTH); return brush; @@ -145,17 +145,17 @@ Brush *BKE_brush_copy(Brush *brush) { Brush *brushn; - brushn= copy_libblock(&brush->id); + brushn = BKE_libblock_copy(&brush->id); if (brush->mtex.tex) - id_us_plus((ID*)brush->mtex.tex); + id_us_plus((ID *)brush->mtex.tex); if (brush->icon_imbuf) - brushn->icon_imbuf= IMB_dupImBuf(brush->icon_imbuf); + brushn->icon_imbuf = IMB_dupImBuf(brush->icon_imbuf); brushn->preview = NULL; - brushn->curve= curvemapping_copy(brush->curve); + brushn->curve = curvemapping_copy(brush->curve); /* enable fake user by default */ if (!(brushn->id.flag & LIB_FAKEUSER)) { @@ -194,11 +194,11 @@ void BKE_brush_make_local(Brush *brush) * - mixed: make copy */ - Main *bmain= G.main; + Main *bmain = G.main; Scene *scene; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; - if (brush->id.lib==NULL) return; + if (brush->id.lib == NULL) return; if (brush->clone.image) { /* special case: ima always local immediately. Clone image should only @@ -207,10 +207,10 @@ void BKE_brush_make_local(Brush *brush) extern_local_brush(brush); } - for (scene= bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene=scene->id.next) { - if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) { - if (scene->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (scene = bmain->scene.first; scene && ELEM(0, is_lib, is_local); scene = scene->id.next) { + if (paint_brush(&scene->toolsettings->imapaint.paint) == brush) { + if (scene->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -225,16 +225,16 @@ void BKE_brush_make_local(Brush *brush) } } else if (is_local && is_lib) { - Brush *brush_new= BKE_brush_copy(brush); - brush_new->id.us= 1; /* only keep fake user */ + Brush *brush_new = BKE_brush_copy(brush); + brush_new->id.us = 1; /* only keep fake user */ brush_new->id.flag |= LIB_FAKEUSER; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, brush->id.lib, &brush_new->id); - for (scene= bmain->scene.first; scene; scene=scene->id.next) { - if (paint_brush(&scene->toolsettings->imapaint.paint)==brush) { - if (scene->id.lib==NULL) { + for (scene = bmain->scene.first; scene; scene = scene->id.next) { + if (paint_brush(&scene->toolsettings->imapaint.paint) == brush) { + if (scene->id.lib == NULL) { paint_brush_set(&scene->toolsettings->imapaint.paint, brush_new); } } @@ -245,16 +245,16 @@ void BKE_brush_make_local(Brush *brush) void BKE_brush_debug_print_state(Brush *br) { /* create a fake brush and set it to the defaults */ - Brush def= {{NULL}}; + Brush def = {{NULL}}; brush_defaults(&def); #define BR_TEST(field, t) \ if (br->field != def.field) \ printf("br->" #field " = %" #t ";\n", br->field) -#define BR_TEST_FLAG(_f) \ +#define BR_TEST_FLAG(_f) \ if ((br->flag & _f) && !(def.flag & _f)) \ - printf("br->flag |= " #_f ";\n"); \ + printf("br->flag |= " #_f ";\n"); \ else if (!(br->flag & _f) && (def.flag & _f)) \ printf("br->flag &= ~" #_f ";\n") @@ -339,77 +339,77 @@ void BKE_brush_sculpt_reset(Brush *br) BKE_brush_curve_preset(br, CURVE_PRESET_SMOOTH); switch (br->sculpt_tool) { - case SCULPT_TOOL_CLAY: - br->flag |= BRUSH_FRONTFACE; - break; - case SCULPT_TOOL_CREASE: - br->flag |= BRUSH_DIR_IN; - br->alpha = 0.25; - break; - case SCULPT_TOOL_FILL: - br->add_col[1] = 1; - br->sub_col[0] = 0.25; - br->sub_col[1] = 1; - break; - case SCULPT_TOOL_FLATTEN: - br->add_col[1] = 1; - br->sub_col[0] = 0.25; - br->sub_col[1] = 1; - break; - case SCULPT_TOOL_INFLATE: - br->add_col[0] = 0.750000; - br->add_col[1] = 0.750000; - br->add_col[2] = 0.750000; - br->sub_col[0] = 0.250000; - br->sub_col[1] = 0.250000; - br->sub_col[2] = 0.250000; - break; - case SCULPT_TOOL_NUDGE: - br->add_col[0] = 0.250000; - br->add_col[1] = 1.000000; - br->add_col[2] = 0.250000; - break; - case SCULPT_TOOL_PINCH: - br->add_col[0] = 0.750000; - br->add_col[1] = 0.750000; - br->add_col[2] = 0.750000; - br->sub_col[0] = 0.250000; - br->sub_col[1] = 0.250000; - br->sub_col[2] = 0.250000; - break; - case SCULPT_TOOL_SCRAPE: - br->add_col[1] = 1.000000; - br->sub_col[0] = 0.250000; - br->sub_col[1] = 1.000000; - break; - case SCULPT_TOOL_ROTATE: - br->alpha = 1.0; - break; - case SCULPT_TOOL_SMOOTH: - br->flag &= ~BRUSH_SPACE_ATTEN; - br->spacing = 5; - br->add_col[0] = 0.750000; - br->add_col[1] = 0.750000; - br->add_col[2] = 0.750000; - break; - case SCULPT_TOOL_GRAB: - case SCULPT_TOOL_SNAKE_HOOK: - case SCULPT_TOOL_THUMB: - br->size = 75; - br->flag &= ~BRUSH_ALPHA_PRESSURE; - br->flag &= ~BRUSH_SPACE; - br->flag &= ~BRUSH_SPACE_ATTEN; - br->add_col[0] = 0.250000; - br->add_col[1] = 1.000000; - br->add_col[2] = 0.250000; - break; - default: - break; + case SCULPT_TOOL_CLAY: + br->flag |= BRUSH_FRONTFACE; + break; + case SCULPT_TOOL_CREASE: + br->flag |= BRUSH_DIR_IN; + br->alpha = 0.25; + break; + case SCULPT_TOOL_FILL: + br->add_col[1] = 1; + br->sub_col[0] = 0.25; + br->sub_col[1] = 1; + break; + case SCULPT_TOOL_FLATTEN: + br->add_col[1] = 1; + br->sub_col[0] = 0.25; + br->sub_col[1] = 1; + break; + case SCULPT_TOOL_INFLATE: + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 0.250000; + br->sub_col[2] = 0.250000; + break; + case SCULPT_TOOL_NUDGE: + br->add_col[0] = 0.250000; + br->add_col[1] = 1.000000; + br->add_col[2] = 0.250000; + break; + case SCULPT_TOOL_PINCH: + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 0.250000; + br->sub_col[2] = 0.250000; + break; + case SCULPT_TOOL_SCRAPE: + br->add_col[1] = 1.000000; + br->sub_col[0] = 0.250000; + br->sub_col[1] = 1.000000; + break; + case SCULPT_TOOL_ROTATE: + br->alpha = 1.0; + break; + case SCULPT_TOOL_SMOOTH: + br->flag &= ~BRUSH_SPACE_ATTEN; + br->spacing = 5; + br->add_col[0] = 0.750000; + br->add_col[1] = 0.750000; + br->add_col[2] = 0.750000; + break; + case SCULPT_TOOL_GRAB: + case SCULPT_TOOL_SNAKE_HOOK: + case SCULPT_TOOL_THUMB: + br->size = 75; + br->flag &= ~BRUSH_ALPHA_PRESSURE; + br->flag &= ~BRUSH_SPACE; + br->flag &= ~BRUSH_SPACE_ATTEN; + br->add_col[0] = 0.250000; + br->add_col[1] = 1.000000; + br->add_col[2] = 0.250000; + break; + default: + break; } } /* Library Operations */ -void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) +void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/ int preset) { CurveMap *cm = NULL; @@ -426,20 +426,20 @@ void BKE_brush_curve_preset(Brush *b, /*CurveMappingPreset*/int preset) int BKE_brush_texture_set_nr(Brush *brush, int nr) { - ID *idtest, *id=NULL; + ID *idtest, *id = NULL; - id= (ID *)brush->mtex.tex; + id = (ID *)brush->mtex.tex; - idtest= (ID*)BLI_findlink(&G.main->tex, nr-1); - if (idtest==NULL) { /* new tex */ - if (id) idtest= (ID *)copy_texture((Tex *)id); - else idtest= (ID *)add_texture("Tex"); + idtest = (ID *)BLI_findlink(&G.main->tex, nr - 1); + if (idtest == NULL) { /* new tex */ + if (id) idtest = (ID *)BKE_texture_copy((Tex *)id); + else idtest = (ID *)add_texture("Tex"); idtest->us--; } - if (idtest!=id) { + if (idtest != id) { BKE_brush_texture_delete(brush); - brush->mtex.tex= (Tex*)idtest; + brush->mtex.tex = (Tex *)idtest; id_us_plus(idtest); return 1; @@ -459,13 +459,13 @@ int BKE_brush_texture_delete(Brush *brush) int BKE_brush_clone_image_set_nr(Brush *brush, int nr) { if (brush && nr > 0) { - Image *ima= (Image*)BLI_findlink(&G.main->image, nr-1); + Image *ima = (Image *)BLI_findlink(&G.main->image, nr - 1); if (ima) { BKE_brush_clone_image_delete(brush); - brush->clone.image= ima; + brush->clone.image = ima; id_us_plus(&ima->id); - brush->clone.offset[0]= brush->clone.offset[1]= 0.0f; + brush->clone.offset[0] = brush->clone.offset[1] = 0.0f; return 1; } @@ -478,7 +478,7 @@ int BKE_brush_clone_image_delete(Brush *brush) { if (brush && brush->clone.image) { brush->clone.image->id.us--; - brush->clone.image= NULL; + brush->clone.image = NULL; return 1; } @@ -488,34 +488,34 @@ int BKE_brush_clone_image_delete(Brush *brush) /* Brush Sampling */ void BKE_brush_sample_tex(const Scene *scene, Brush *brush, const float xy[2], float rgba[4], const int thread) { - MTex *mtex= &brush->mtex; + MTex *mtex = &brush->mtex; if (mtex && mtex->tex) { float co[3], tin, tr, tg, tb, ta; int hasrgb; - const int radius= BKE_brush_size_get(scene, brush); + const int radius = BKE_brush_size_get(scene, brush); - co[0]= xy[0]/radius; - co[1]= xy[1]/radius; - co[2]= 0.0f; + co[0] = xy[0] / radius; + co[1] = xy[1] / radius; + co[2] = 0.0f; - hasrgb= externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread); + hasrgb = externtex(mtex, co, &tin, &tr, &tg, &tb, &ta, thread); if (hasrgb) { - rgba[0]= tr; - rgba[1]= tg; - rgba[2]= tb; - rgba[3]= ta; + rgba[0] = tr; + rgba[1] = tg; + rgba[2] = tb; + rgba[3] = ta; } else { - rgba[0]= tin; - rgba[1]= tin; - rgba[2]= tin; - rgba[3]= 1.0f; + rgba[0] = tin; + rgba[1] = tin; + rgba[2] = tin; + rgba[3] = 1.0f; } } else { - rgba[0]= rgba[1]= rgba[2]= rgba[3]= 1.0f; + rgba[0] = rgba[1] = rgba[2] = rgba[3] = 1.0f; } } @@ -525,20 +525,20 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf ImBuf *ibuf; float xy[2], rgba[4], *dstf; int x, y, rowbytes, xoff, yoff, imbflag; - const int radius= BKE_brush_size_get(scene, brush); + const int radius = BKE_brush_size_get(scene, brush); unsigned char *dst, crgb[3]; - const float alpha= BKE_brush_alpha_get(scene, brush); + const float alpha = BKE_brush_alpha_get(scene, brush); float brush_rgb[3]; - imbflag= (flt)? IB_rectfloat: IB_rect; - xoff = -bufsize/2.0f + 0.5f; - yoff = -bufsize/2.0f + 0.5f; - rowbytes= bufsize*4; + imbflag = (flt) ? IB_rectfloat : IB_rect; + xoff = -bufsize / 2.0f + 0.5f; + yoff = -bufsize / 2.0f + 0.5f; + rowbytes = bufsize * 4; if (*outbuf) - ibuf= *outbuf; + ibuf = *outbuf; else - ibuf= IMB_allocImBuf(bufsize, bufsize, 32, imbflag); + ibuf = IMB_allocImBuf(bufsize, bufsize, 32, imbflag); if (flt) { copy_v3_v3(brush_rgb, brush->rgb); @@ -546,16 +546,16 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf srgb_to_linearrgb_v3_v3(brush_rgb, brush_rgb); } - for (y=0; y < ibuf->y; y++) { - dstf = ibuf->rect_float + y*rowbytes; + for (y = 0; y < ibuf->y; y++) { + dstf = ibuf->rect_float + y * rowbytes; - for (x=0; x < ibuf->x; x++, dstf+=4) { + for (x = 0; x < ibuf->x; x++, dstf += 4) { xy[0] = x + xoff; xy[1] = y + yoff; if (texfall == 0) { copy_v3_v3(dstf, brush_rgb); - dstf[3]= alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3] = alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } else if (texfall == 1) { BKE_brush_sample_tex(scene, brush, xy, dstf, 0); @@ -563,7 +563,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf else { BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3v3(dstf, rgba, brush_rgb); - dstf[3] = rgba[3]*alpha*BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + dstf[3] = rgba[3] *alpha *BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); } } } @@ -572,10 +572,10 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf float alpha_f; /* final float alpha to convert to char */ rgb_float_to_uchar(crgb, brush->rgb); - for (y=0; y < ibuf->y; y++) { - dst = (unsigned char *)ibuf->rect + y*rowbytes; + for (y = 0; y < ibuf->y; y++) { + dst = (unsigned char *)ibuf->rect + y * rowbytes; - for (x=0; x < ibuf->x; x++, dst+=4) { + for (x = 0; x < ibuf->x; x++, dst += 4) { xy[0] = x + xoff; xy[1] = y + yoff; @@ -594,7 +594,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf else if (texfall == 2) { BKE_brush_sample_tex(scene, brush, xy, rgba, 0); mul_v3_v3(rgba, brush->rgb); - alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + alpha_f = rgba[3] *alpha *BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); rgb_float_to_uchar(dst, rgba); @@ -602,7 +602,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf } else { BKE_brush_sample_tex(scene, brush, xy, rgba, 0); - alpha_f = rgba[3] * alpha * BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); + alpha_f = rgba[3] *alpha *BKE_brush_curve_strength_clamp(brush, len_v2(xy), radius); dst[0] = crgb[0]; dst[1] = crgb[1]; @@ -613,7 +613,7 @@ void BKE_brush_imbuf_new(const Scene *scene, Brush *brush, short flt, short texf } } - *outbuf= ibuf; + *outbuf = ibuf; } /* Unified Size and Strength */ @@ -636,9 +636,9 @@ void BKE_brush_size_set(Scene *scene, Brush *brush, int size) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; if (ups->flag & UNIFIED_PAINT_SIZE) - ups->size= size; + ups->size = size; else - brush->size= size; + brush->size = size; } int BKE_brush_size_get(const Scene *scene, Brush *brush) @@ -653,8 +653,8 @@ int BKE_brush_use_locked_size(const Scene *scene, Brush *brush) const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_SIZE) ? - (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) : - (brush->flag & BRUSH_LOCK_SIZE); + (us_flag & UNIFIED_PAINT_BRUSH_LOCK_SIZE) : + (brush->flag & BRUSH_LOCK_SIZE); } int BKE_brush_use_size_pressure(const Scene *scene, Brush *brush) @@ -662,8 +662,8 @@ int BKE_brush_use_size_pressure(const Scene *scene, Brush *brush) const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_SIZE) ? - (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) : - (brush->flag & BRUSH_SIZE_PRESSURE); + (us_flag & UNIFIED_PAINT_BRUSH_SIZE_PRESSURE) : + (brush->flag & BRUSH_SIZE_PRESSURE); } int BKE_brush_use_alpha_pressure(const Scene *scene, Brush *brush) @@ -671,8 +671,8 @@ int BKE_brush_use_alpha_pressure(const Scene *scene, Brush *brush) const short us_flag = scene->toolsettings->unified_paint_settings.flag; return (us_flag & UNIFIED_PAINT_ALPHA) ? - (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) : - (brush->flag & BRUSH_ALPHA_PRESSURE); + (us_flag & UNIFIED_PAINT_BRUSH_ALPHA_PRESSURE) : + (brush->flag & BRUSH_ALPHA_PRESSURE); } void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius) @@ -680,9 +680,9 @@ void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojec UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; if (ups->flag & UNIFIED_PAINT_SIZE) - ups->unprojected_radius= unprojected_radius; + ups->unprojected_radius = unprojected_radius; else - brush->unprojected_radius= unprojected_radius; + brush->unprojected_radius = unprojected_radius; } float BKE_brush_unprojected_radius_get(const Scene *scene, Brush *brush) @@ -690,8 +690,8 @@ float BKE_brush_unprojected_radius_get(const Scene *scene, Brush *brush) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; return (ups->flag & UNIFIED_PAINT_SIZE) ? - ups->unprojected_radius : - brush->unprojected_radius; + ups->unprojected_radius : + brush->unprojected_radius; } static void brush_alpha_set(Scene *scene, Brush *brush, float alpha) @@ -699,9 +699,9 @@ static void brush_alpha_set(Scene *scene, Brush *brush, float alpha) UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; if (ups->flag & UNIFIED_PAINT_ALPHA) - ups->alpha= alpha; + ups->alpha = alpha; else - brush->alpha= alpha; + brush->alpha = alpha; } float BKE_brush_alpha_get(const Scene *scene, Brush *brush) @@ -722,7 +722,7 @@ void BKE_brush_weight_set(const Scene *scene, Brush *brush, float value) { UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings; - if(ups->flag & UNIFIED_PAINT_WEIGHT) + if (ups->flag & UNIFIED_PAINT_WEIGHT) ups->weight = value; else brush->weight = value; @@ -749,7 +749,7 @@ void BKE_brush_scale_size(int *BKE_brush_size_get, /* avoid division by zero */ if (old_unprojected_radius != 0) scale /= new_unprojected_radius; - (*BKE_brush_size_get)= (int)((float)(*BKE_brush_size_get) * scale); + (*BKE_brush_size_get) = (int)((float)(*BKE_brush_size_get) * scale); } /* Brush Painting */ @@ -757,9 +757,9 @@ void BKE_brush_scale_size(int *BKE_brush_size_get, typedef struct BrushPainterCache { short enabled; - int size; /* size override, if 0 uses 2*BKE_brush_size_get(brush) */ - short flt; /* need float imbuf? */ - short texonly; /* no alpha, color or fallof, only texture in imbuf */ + int size; /* size override, if 0 uses 2*BKE_brush_size_get(brush) */ + short flt; /* need float imbuf? */ + short texonly; /* no alpha, color or fallof, only texture in imbuf */ int lastsize; float lastalpha; @@ -774,18 +774,18 @@ struct BrushPainter { Scene *scene; Brush *brush; - float lastmousepos[2]; /* mouse position of last paint call */ + float lastmousepos[2]; /* mouse position of last paint call */ - float accumdistance; /* accumulated distance of brush since last paint op */ - float lastpaintpos[2]; /* position of last paint op */ + float accumdistance; /* accumulated distance of brush since last paint op */ + float lastpaintpos[2]; /* position of last paint op */ float startpaintpos[2]; /* position of first paint */ - double accumtime; /* accumulated time since last paint op (airbrush) */ - double lasttime; /* time of last update */ + double accumtime; /* accumulated time since last paint op (airbrush) */ + double lasttime; /* time of last update */ float lastpressure; - short firsttouch; /* first paint op */ + short firsttouch; /* first paint op */ float startsize; float startalpha; @@ -797,12 +797,12 @@ struct BrushPainter { BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush) { - BrushPainter *painter= MEM_callocN(sizeof(BrushPainter), "BrushPainter"); + BrushPainter *painter = MEM_callocN(sizeof(BrushPainter), "BrushPainter"); - painter->brush= brush; - painter->scene= scene; - painter->firsttouch= 1; - painter->cache.lastsize= -1; /* force ibuf create in refresh */ + painter->brush = brush; + painter->scene = scene; + painter->firsttouch = 1; + painter->cache.lastsize = -1; /* force ibuf create in refresh */ painter->startsize = BKE_brush_size_get(scene, brush); painter->startalpha = BKE_brush_alpha_get(scene, brush); @@ -815,23 +815,24 @@ BrushPainter *BKE_brush_painter_new(Scene *scene, Brush *brush) void BKE_brush_painter_require_imbuf(BrushPainter *painter, short flt, short texonly, int size) { if ((painter->cache.flt != flt) || (painter->cache.size != size) || - ((painter->cache.texonly != texonly) && texonly)) { + ((painter->cache.texonly != texonly) && texonly)) + { if (painter->cache.ibuf) IMB_freeImBuf(painter->cache.ibuf); if (painter->cache.maskibuf) IMB_freeImBuf(painter->cache.maskibuf); - painter->cache.ibuf= painter->cache.maskibuf= NULL; - painter->cache.lastsize= -1; /* force ibuf create in refresh */ + painter->cache.ibuf = painter->cache.maskibuf = NULL; + painter->cache.lastsize = -1; /* force ibuf create in refresh */ } if (painter->cache.flt != flt) { if (painter->cache.texibuf) IMB_freeImBuf(painter->cache.texibuf); - painter->cache.texibuf= NULL; - painter->cache.lastsize= -1; /* force ibuf create in refresh */ + painter->cache.texibuf = NULL; + painter->cache.lastsize = -1; /* force ibuf create in refresh */ } - painter->cache.size= size; - painter->cache.flt= flt; - painter->cache.texonly= texonly; - painter->cache.enabled= 1; + painter->cache.size = size; + painter->cache.flt = flt; + painter->cache.texonly = texonly; + painter->cache.enabled = 1; } void BKE_brush_painter_free(BrushPainter *painter) @@ -853,13 +854,13 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, int x, int y, int w, int h, int xt, int yt, const float pos[2]) { - Scene *scene= painter->scene; - Brush *brush= painter->brush; + Scene *scene = painter->scene; + Brush *brush = painter->brush; ImBuf *ibuf, *maskibuf, *texibuf; - float *bf, *mf, *tf, *otf=NULL, xoff, yoff, xy[2], rgba[4]; - unsigned char *b, *m, *t, *ot= NULL; - int dotexold, origx= x, origy= y; - const int radius= BKE_brush_size_get(painter->scene, brush); + float *bf, *mf, *tf, *otf = NULL, xoff, yoff, xy[2], rgba[4]; + unsigned char *b, *m, *t, *ot = NULL; + int dotexold, origx = x, origy = y; + const int radius = BKE_brush_size_get(painter->scene, brush); xoff = -radius + 0.5f; yoff = -radius + 0.5f; @@ -880,14 +881,14 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, if (painter->cache.flt) { for (; y < h; y++) { - bf = ibuf->rect_float + (y*ibuf->x + origx)*4; - tf = texibuf->rect_float + (y*texibuf->x + origx)*4; - mf = maskibuf->rect_float + (y*maskibuf->x + origx)*4; + bf = ibuf->rect_float + (y * ibuf->x + origx) * 4; + tf = texibuf->rect_float + (y * texibuf->x + origx) * 4; + mf = maskibuf->rect_float + (y * maskibuf->x + origx) * 4; if (dotexold) - otf = oldtexibuf->rect_float + ((y - origy + yt)*oldtexibuf->x + xt)*4; + otf = oldtexibuf->rect_float + ((y - origy + yt) * oldtexibuf->x + xt) * 4; - for (x=origx; x < w; x++, bf+=4, mf+=4, tf+=4) { + for (x = origx; x < w; x++, bf += 4, mf += 4, tf += 4) { if (dotexold) { copy_v3_v3(tf, otf); tf[3] = otf[3]; @@ -900,23 +901,23 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, BKE_brush_sample_tex(scene, brush, xy, tf, 0); } - bf[0] = tf[0]*mf[0]; - bf[1] = tf[1]*mf[1]; - bf[2] = tf[2]*mf[2]; - bf[3] = tf[3]*mf[3]; + bf[0] = tf[0] * mf[0]; + bf[1] = tf[1] * mf[1]; + bf[2] = tf[2] * mf[2]; + bf[3] = tf[3] * mf[3]; } } } else { for (; y < h; y++) { - b = (unsigned char *)ibuf->rect + (y*ibuf->x + origx)*4; - t = (unsigned char *)texibuf->rect + (y*texibuf->x + origx)*4; - m = (unsigned char *)maskibuf->rect + (y*maskibuf->x + origx)*4; + b = (unsigned char *)ibuf->rect + (y * ibuf->x + origx) * 4; + t = (unsigned char *)texibuf->rect + (y * texibuf->x + origx) * 4; + m = (unsigned char *)maskibuf->rect + (y * maskibuf->x + origx) * 4; if (dotexold) - ot = (unsigned char *)oldtexibuf->rect + ((y - origy + yt)*oldtexibuf->x + xt)*4; + ot = (unsigned char *)oldtexibuf->rect + ((y - origy + yt) * oldtexibuf->x + xt) * 4; - for (x=origx; x < w; x++, b+=4, m+=4, t+=4) { + for (x = origx; x < w; x++, b += 4, m += 4, t += 4) { if (dotexold) { t[0] = ot[0]; t[1] = ot[1]; @@ -932,10 +933,10 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, rgba_float_to_uchar(t, rgba); } - b[0] = t[0]*m[0]/255; - b[1] = t[1]*m[1]/255; - b[2] = t[2]*m[2]/255; - b[3] = t[3]*m[3]/255; + b[0] = t[0] * m[0] / 255; + b[1] = t[1] * m[1] / 255; + b[2] = t[2] * m[2] / 255; + b[3] = t[3] * m[3] / 255; } } } @@ -943,40 +944,40 @@ static void brush_painter_do_partial(BrushPainter *painter, ImBuf *oldtexibuf, static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const float pos[2]) { - const Scene *scene= painter->scene; - Brush *brush= painter->brush; - BrushPainterCache *cache= &painter->cache; + const Scene *scene = painter->scene; + Brush *brush = painter->brush; + BrushPainterCache *cache = &painter->cache; ImBuf *oldtexibuf, *ibuf; int imbflag, destx, desty, srcx, srcy, w, h, x1, y1, x2, y2; - const int diameter= 2*BKE_brush_size_get(scene, brush); + const int diameter = 2 * BKE_brush_size_get(scene, brush); - imbflag= (cache->flt)? IB_rectfloat: IB_rect; + imbflag = (cache->flt) ? IB_rectfloat : IB_rect; if (!cache->ibuf) - cache->ibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag); - ibuf= cache->ibuf; + cache->ibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag); + ibuf = cache->ibuf; - oldtexibuf= cache->texibuf; - cache->texibuf= IMB_allocImBuf(diameter, diameter, 32, imbflag); + oldtexibuf = cache->texibuf; + cache->texibuf = IMB_allocImBuf(diameter, diameter, 32, imbflag); if (oldtexibuf) { - srcx= srcy= 0; - destx= (int)painter->lastpaintpos[0] - (int)pos[0]; - desty= (int)painter->lastpaintpos[1] - (int)pos[1]; - w= oldtexibuf->x; - h= oldtexibuf->y; + srcx = srcy = 0; + destx = (int)painter->lastpaintpos[0] - (int)pos[0]; + desty = (int)painter->lastpaintpos[1] - (int)pos[1]; + w = oldtexibuf->x; + h = oldtexibuf->y; IMB_rectclip(cache->texibuf, oldtexibuf, &destx, &desty, &srcx, &srcy, &w, &h); } else { - srcx= srcy= 0; - destx= desty= 0; - w= h= 0; + srcx = srcy = 0; + destx = desty = 0; + w = h = 0; } - x1= destx; - y1= desty; - x2= destx+w; - y2= desty+h; + x1 = destx; + y1 = desty; + x2 = destx + w; + y2 = desty + h; /* blend existing texture in new position */ if ((x1 < x2) && (y1 < y2)) @@ -998,30 +999,30 @@ static void brush_painter_fixed_tex_partial_update(BrushPainter *painter, const static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2], int use_color_correction) { - const Scene *scene= painter->scene; - Brush *brush= painter->brush; - BrushPainterCache *cache= &painter->cache; - MTex *mtex= &brush->mtex; + const Scene *scene = painter->scene; + Brush *brush = painter->brush; + BrushPainterCache *cache = &painter->cache; + MTex *mtex = &brush->mtex; int size; short flt; - const int diameter= 2*BKE_brush_size_get(scene, brush); - const float alpha= BKE_brush_alpha_get(scene, brush); + const int diameter = 2 * BKE_brush_size_get(scene, brush); + const float alpha = BKE_brush_alpha_get(scene, brush); if (diameter != cache->lastsize || - alpha != cache->lastalpha || - brush->jitter != cache->lastjitter) + alpha != cache->lastalpha || + brush->jitter != cache->lastjitter) { if (cache->ibuf) { IMB_freeImBuf(cache->ibuf); - cache->ibuf= NULL; + cache->ibuf = NULL; } if (cache->maskibuf) { IMB_freeImBuf(cache->maskibuf); - cache->maskibuf= NULL; + cache->maskibuf = NULL; } - flt= cache->flt; - size= (cache->size)? cache->size: diameter; + flt = cache->flt; + size = (cache->size) ? cache->size : diameter; if (brush->flag & BRUSH_FIXED_TEX) { BKE_brush_imbuf_new(scene, brush, flt, 3, size, &cache->maskibuf, use_color_correction); @@ -1030,9 +1031,9 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 else BKE_brush_imbuf_new(scene, brush, flt, 2, size, &cache->ibuf, use_color_correction); - cache->lastsize= diameter; - cache->lastalpha= alpha; - cache->lastjitter= brush->jitter; + cache->lastsize = diameter; + cache->lastalpha = alpha; + cache->lastjitter = brush->jitter; } else if ((brush->flag & BRUSH_FIXED_TEX) && mtex && mtex->tex) { int dx = (int)painter->lastpaintpos[0] - (int)pos[0]; @@ -1045,42 +1046,42 @@ static void brush_painter_refresh_cache(BrushPainter *painter, const float pos[2 void BKE_brush_painter_break_stroke(BrushPainter *painter) { - painter->firsttouch= 1; + painter->firsttouch = 1; } static void brush_pressure_apply(BrushPainter *painter, Brush *brush, float pressure) { if (BKE_brush_use_alpha_pressure(painter->scene, brush)) - brush_alpha_set(painter->scene, brush, MAX2(0.0f, painter->startalpha*pressure)); + brush_alpha_set(painter->scene, brush, MAX2(0.0f, painter->startalpha * pressure)); if (BKE_brush_use_size_pressure(painter->scene, brush)) - BKE_brush_size_set(painter->scene, brush, MAX2(1.0f, painter->startsize*pressure)); + BKE_brush_size_set(painter->scene, brush, MAX2(1.0f, painter->startsize * pressure)); if (brush->flag & BRUSH_JITTER_PRESSURE) - brush->jitter = MAX2(0.0f, painter->startjitter*pressure); + brush->jitter = MAX2(0.0f, painter->startjitter * pressure); if (brush->flag & BRUSH_SPACING_PRESSURE) - brush->spacing = MAX2(1.0f, painter->startspacing*(1.5f-pressure)); + brush->spacing = MAX2(1.0f, painter->startspacing * (1.5f - pressure)); } void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], float jitterpos[2]) { - int use_jitter= brush->jitter != 0; + int use_jitter = brush->jitter != 0; /* jitter-ed brush gives weird and unpredictable result for this * kinds of stroke, so manyally disable jitter usage (sergey) */ - use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH|BRUSH_ANCHORED)) == 0; + use_jitter &= (brush->flag & (BRUSH_RESTORE_MESH | BRUSH_ANCHORED)) == 0; if (use_jitter) { float rand_pos[2]; - const int radius= BKE_brush_size_get(scene, brush); - const int diameter= 2*radius; + const int radius = BKE_brush_size_get(scene, brush); + const int diameter = 2 * radius; // find random position within a circle of diameter 1 do { - rand_pos[0] = BLI_frand()-0.5f; - rand_pos[1] = BLI_frand()-0.5f; + rand_pos[0] = BLI_frand() - 0.5f; + rand_pos[1] = BLI_frand() - 0.5f; } while (len_v2(rand_pos) > 0.5f); - jitterpos[0] = pos[0] + 2*rand_pos[0]*diameter*brush->jitter; - jitterpos[1] = pos[1] + 2*rand_pos[1]*diameter*brush->jitter; + jitterpos[0] = pos[0] + 2 * rand_pos[0] * diameter * brush->jitter; + jitterpos[1] = pos[1] + 2 * rand_pos[1] * diameter * brush->jitter; } else { copy_v2_v2(jitterpos, pos); @@ -1090,92 +1091,92 @@ void BKE_brush_jitter_pos(const Scene *scene, Brush *brush, const float pos[2], int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float pos[2], double time, float pressure, void *user, int use_color_correction) { - Scene *scene= painter->scene; - Brush *brush= painter->brush; - int totpaintops= 0; + Scene *scene = painter->scene; + Brush *brush = painter->brush; + int totpaintops = 0; if (pressure == 0.0f) { if (painter->lastpressure) // XXX - hack, operator misses - pressure= painter->lastpressure; + pressure = painter->lastpressure; else - pressure = 1.0f; /* zero pressure == not using tablet */ + pressure = 1.0f; /* zero pressure == not using tablet */ } if (painter->firsttouch) { /* paint exactly once on first touch */ - painter->startpaintpos[0]= pos[0]; - painter->startpaintpos[1]= pos[1]; + painter->startpaintpos[0] = pos[0]; + painter->startpaintpos[1] = pos[1]; brush_pressure_apply(painter, brush, pressure); if (painter->cache.enabled) brush_painter_refresh_cache(painter, pos, use_color_correction); totpaintops += func(user, painter->cache.ibuf, pos, pos); - painter->lasttime= time; - painter->firsttouch= 0; - painter->lastpaintpos[0]= pos[0]; - painter->lastpaintpos[1]= pos[1]; + painter->lasttime = time; + painter->firsttouch = 0; + painter->lastpaintpos[0] = pos[0]; + painter->lastpaintpos[1] = pos[1]; } #if 0 else if (painter->brush->flag & BRUSH_AIRBRUSH) { float spacing, step, paintpos[2], dmousepos[2], len; - double starttime, curtime= time; + double starttime, curtime = time; /* compute brush spacing adapted to brush size */ - spacing= brush->rate; //radius*brush->spacing*0.01f; + spacing = brush->rate; //radius*brush->spacing*0.01f; /* setup starting time, direction vector and accumulated time */ - starttime= painter->accumtime; + starttime = painter->accumtime; sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); - len= normalize_v2(dmousepos); + len = normalize_v2(dmousepos); painter->accumtime += curtime - painter->lasttime; /* do paint op over unpainted time distance */ while (painter->accumtime >= spacing) { - step= (spacing - starttime)*len; - paintpos[0]= painter->lastmousepos[0] + dmousepos[0]*step; - paintpos[1]= painter->lastmousepos[1] + dmousepos[1]*step; + step = (spacing - starttime) * len; + paintpos[0] = painter->lastmousepos[0] + dmousepos[0] * step; + paintpos[1] = painter->lastmousepos[1] + dmousepos[1] * step; if (painter->cache.enabled) brush_painter_refresh_cache(painter); totpaintops += func(user, painter->cache.ibuf, - painter->lastpaintpos, paintpos); + painter->lastpaintpos, paintpos); - painter->lastpaintpos[0]= paintpos[0]; - painter->lastpaintpos[1]= paintpos[1]; + painter->lastpaintpos[0] = paintpos[0]; + painter->lastpaintpos[1] = paintpos[1]; painter->accumtime -= spacing; starttime -= spacing; } - painter->lasttime= curtime; + painter->lasttime = curtime; } #endif else { float startdistance, spacing, step, paintpos[2], dmousepos[2], finalpos[2]; float t, len, press; - const int radius= BKE_brush_size_get(scene, brush); + const int radius = BKE_brush_size_get(scene, brush); /* compute brush spacing adapted to brush radius, spacing may depend * on pressure, so update it */ brush_pressure_apply(painter, brush, painter->lastpressure); - spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; + spacing = MAX2(1.0f, radius) * brush->spacing * 0.01f; /* setup starting distance, direction vector and accumulated distance */ - startdistance= painter->accumdistance; + startdistance = painter->accumdistance; sub_v2_v2v2(dmousepos, pos, painter->lastmousepos); - len= normalize_v2(dmousepos); + len = normalize_v2(dmousepos); painter->accumdistance += len; if (brush->flag & BRUSH_SPACE) { /* do paint op over unpainted distance */ while ((len > 0.0f) && (painter->accumdistance >= spacing)) { - step= spacing - startdistance; - paintpos[0]= painter->lastmousepos[0] + dmousepos[0]*step; - paintpos[1]= painter->lastmousepos[1] + dmousepos[1]*step; + step = spacing - startdistance; + paintpos[0] = painter->lastmousepos[0] + dmousepos[0] * step; + paintpos[1] = painter->lastmousepos[1] + dmousepos[1] * step; - t = step/len; - press= (1.0f-t)*painter->lastpressure + t*pressure; + t = step / len; + press = (1.0f - t) * painter->lastpressure + t * pressure; brush_pressure_apply(painter, brush, press); - spacing= MAX2(1.0f, radius)*brush->spacing*0.01f; + spacing = MAX2(1.0f, radius) * brush->spacing * 0.01f; BKE_brush_jitter_pos(scene, brush, paintpos, finalpos); @@ -1183,10 +1184,10 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p brush_painter_refresh_cache(painter, finalpos, use_color_correction); totpaintops += - func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos); + func(user, painter->cache.ibuf, painter->lastpaintpos, finalpos); - painter->lastpaintpos[0]= paintpos[0]; - painter->lastpaintpos[1]= paintpos[1]; + painter->lastpaintpos[0] = paintpos[0]; + painter->lastpaintpos[1] = paintpos[1]; painter->accumdistance -= spacing; startdistance -= spacing; } @@ -1199,21 +1200,21 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p totpaintops += func(user, painter->cache.ibuf, pos, finalpos); - painter->lastpaintpos[0]= pos[0]; - painter->lastpaintpos[1]= pos[1]; - painter->accumdistance= 0; + painter->lastpaintpos[0] = pos[0]; + painter->lastpaintpos[1] = pos[1]; + painter->accumdistance = 0; } /* do airbrush paint ops, based on the number of paint ops left over * from regular painting. this is a temporary solution until we have * accurate time stamps for mouse move events */ if (brush->flag & BRUSH_AIRBRUSH) { - double curtime= time; - double painttime= brush->rate*totpaintops; + double curtime = time; + double painttime = brush->rate * totpaintops; painter->accumtime += curtime - painter->lasttime; if (painter->accumtime <= painttime) - painter->accumtime= 0.0; + painter->accumtime = 0.0; else painter->accumtime -= painttime; @@ -1226,17 +1227,17 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p brush_painter_refresh_cache(painter, finalpos, use_color_correction); totpaintops += - func(user, painter->cache.ibuf, painter->lastmousepos, finalpos); + func(user, painter->cache.ibuf, painter->lastmousepos, finalpos); painter->accumtime -= (double)brush->rate; } - painter->lasttime= curtime; + painter->lasttime = curtime; } } - painter->lastmousepos[0]= pos[0]; - painter->lastmousepos[1]= pos[1]; - painter->lastpressure= pressure; + painter->lastmousepos[0] = pos[0]; + painter->lastmousepos[1] = pos[1]; + painter->lastpressure = pressure; brush_alpha_set(scene, brush, painter->startalpha); BKE_brush_size_set(scene, brush, painter->startsize); @@ -1249,12 +1250,12 @@ int BKE_brush_painter_paint(BrushPainter *painter, BrushFunc func, const float p /* Uses the brush curve control to find a strength value between 0 and 1 */ float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) { - if (p >= len) return 0; - else p= p/len; + if (p >= len) return 0; + else p = p / len; - p= curvemapping_evaluateF(br->curve, 0, p); - if (p < 0.0f) p= 0.0f; - else if (p > 1.0f) p= 1.0f; + p = curvemapping_evaluateF(br->curve, 0, p); + if (p < 0.0f) p = 0.0f; + else if (p > 1.0f) p = 1.0f; return p; } /* same as above but can return negative values if the curve enables @@ -1262,9 +1263,9 @@ float BKE_brush_curve_strength_clamp(Brush *br, float p, const float len) float BKE_brush_curve_strength(Brush *br, float p, const float len) { if (p >= len) - p= 1.0f; + p = 1.0f; else - p= p/len; + p = p / len; return curvemapping_evaluateF(br->curve, 0, p); } @@ -1274,7 +1275,7 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) { unsigned int *texcache = NULL; MTex *mtex = &br->mtex; - TexResult texres= {0}; + TexResult texres = {0}; int hasrgb, ix, iy; int side = half_side * 2; @@ -1286,11 +1287,11 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) BKE_image_get_ibuf(mtex->tex->ima, NULL); /*do normalized cannonical view coords for texture*/ - for (y=-1.0, iy=0; iytex, co, NULL, NULL, 0, &texres); @@ -1300,14 +1301,12 @@ unsigned int *BKE_brush_gen_texture_cache(Brush *br, int half_side) * if the texture didn't give an RGB value, copy the intensity across */ if (hasrgb & TEX_RGB) - texres.tin = (0.35f * texres.tr + 0.45f * - texres.tg + 0.2f * texres.tb); + texres.tin = rgb_to_grayscale(&texres.tr); - texres.tin = texres.tin * 255.0f; - ((char*)texcache)[(iy*side+ix)*4] = (char)texres.tin; - ((char*)texcache)[(iy*side+ix)*4+1] = (char)texres.tin; - ((char*)texcache)[(iy*side+ix)*4+2] = (char)texres.tin; - ((char*)texcache)[(iy*side+ix)*4+3] = (char)texres.tin; + ((char *)texcache)[(iy * side + ix) * 4] = + ((char *)texcache)[(iy * side + ix) * 4 + 1] = + ((char *)texcache)[(iy * side + ix) * 4 + 2] = + ((char *)texcache)[(iy * side + ix) * 4 + 3] = (char)(texres.tin * 255.0f); } } } @@ -1328,19 +1327,19 @@ struct ImBuf *BKE_brush_gen_radial_control_imbuf(Brush *br) im->rect_float = MEM_callocN(sizeof(float) * side * side, "radial control rect"); im->x = im->y = side; - for (i=0; irect_float[i*side + j]= BKE_brush_curve_strength_clamp(br, magn, half); + for (i = 0; i < side; ++i) { + for (j = 0; j < side; ++j) { + float magn = sqrt(pow(i - half, 2) + pow(j - half, 2)); + im->rect_float[i * side + j] = BKE_brush_curve_strength_clamp(br, magn, half); } } /* Modulate curve with texture */ if (texcache) { - for (i=0; irect_float[i*side+j]*= (((char*)&col)[0]+((char*)&col)[1]+((char*)&col)[2])/3.0f/255.0f; + for (i = 0; i < side; ++i) { + for (j = 0; j < side; ++j) { + const int col = texcache[i * side + j]; + im->rect_float[i * side + j] *= (((char *)&col)[0] + ((char *)&col)[1] + ((char *)&col)[2]) / 3.0f / 255.0f; } } diff --git a/source/blender/blenkernel/intern/bvhutils.c b/source/blender/blenkernel/intern/bvhutils.c index f0bc2dddbad..24583c124e6 100644 --- a/source/blender/blenkernel/intern/bvhutils.c +++ b/source/blender/blenkernel/intern/bvhutils.c @@ -101,11 +101,11 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f sub_v3_v3v3(e1, v2, v0); A00 = dot_v3v3(e0, e0); - A01 = dot_v3v3(e0, e1 ); - A11 = dot_v3v3(e1, e1 ); - B0 = dot_v3v3(diff, e0 ); - B1 = dot_v3v3(diff, e1 ); - C = dot_v3v3(diff, diff ); + A01 = dot_v3v3(e0, e1); + A11 = dot_v3v3(e1, e1); + B0 = dot_v3v3(diff, e0); + B1 = dot_v3v3(diff, e1); + C = dot_v3v3(diff, diff); Det = fabs(A00 * A11 - A01 * A01); S = A01 * B1 - A11 * B0; T = A01 * B0 - A00 * B1; @@ -122,7 +122,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } else { if (fabsf(A00) > FLT_EPSILON) - S = -B0/A00; + S = -B0 / A00; else S = 0.0f; sqrDist = B0 * S + C; @@ -195,7 +195,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } } else { /* Region 0 */ - // Minimum at interior lv + /* Minimum at interior lv */ float invDet; if (fabsf(Det) > FLT_EPSILON) invDet = 1.0f / Det; @@ -203,8 +203,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f invDet = 0.0f; S *= invDet; T *= invDet; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; } } else { @@ -213,10 +213,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f if (S < 0.0f) { /* Region 2 */ tmp0 = A01 + B0; tmp1 = A11 + B1; - if ( tmp1 > tmp0 ) { + if (tmp1 > tmp0) { numer = tmp1 - tmp0; denom = A00 - 2.0f * A01 + A11; - if ( numer >= denom ) { + if (numer >= denom) { S = 1.0f; T = 0.0f; sqrDist = A00 + 2.0f * B0 + C; @@ -228,14 +228,14 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else S = 0.0f; T = 1.0f - S; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; le = 2; } } else { S = 0.0f; - if ( tmp1 <= 0.0f ) { + if (tmp1 <= 0.0f) { T = 1.0f; sqrDist = A11 + 2.0f * B1 + C; lv = 2; @@ -258,10 +258,10 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else if (T < 0.0f) { /* Region 6 */ tmp0 = A01 + B1; tmp1 = A00 + B0; - if ( tmp1 > tmp0 ) { + if (tmp1 > tmp0) { numer = tmp1 - tmp0; denom = A00 - 2.0f * A01 + A11; - if ( numer >= denom ) { + if (numer >= denom) { T = 1.0f; S = 0.0f; sqrDist = A11 + 2.0f * B1 + C; @@ -273,8 +273,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else T = 0.0f; S = 1.0f - T; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; le = 2; } } @@ -302,7 +302,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } else { /* Region 1 */ numer = A11 + B1 - A01 - B0; - if ( numer <= 0.0f ) { + if (numer <= 0.0f) { S = 0.0f; T = 1.0f; sqrDist = A11 + 2.0f * B1 + C; @@ -310,7 +310,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } else { denom = A00 - 2.0f * A01 + A11; - if ( numer >= denom ) { + if (numer >= denom) { S = 1.0f; T = 0.0f; sqrDist = A00 + 2.0f * B0 + C; @@ -322,8 +322,8 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f else S = 0.0f; T = 1.0f - S; - sqrDist = S * ( A00 * S + A01 * T + 2.0f * B0 ) + - T * ( A01 * S + A11 * T + 2.0f * B1 ) + C; + sqrDist = S * (A00 * S + A01 * T + 2.0f * B0) + + T * (A01 * S + A11 * T + 2.0f * B1) + C; le = 2; } } @@ -331,7 +331,7 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f } // Account for numerical round-off error - if ( sqrDist < FLT_EPSILON ) + if (sqrDist < FLT_EPSILON) sqrDist = 0.0f; { @@ -362,19 +362,18 @@ float nearest_point_in_tri_surface(const float v0[3], const float v1[3], const f // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. static void mesh_faces_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { - const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; - MVert *vert = data->vert; + const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; + MVert *vert = data->vert; MFace *face = data->face + index; float *t0, *t1, *t2, *t3; - t0 = vert[ face->v1 ].co; - t1 = vert[ face->v2 ].co; - t2 = vert[ face->v3 ].co; - t3 = face->v4 ? vert[ face->v4].co : NULL; + t0 = vert[face->v1].co; + t1 = vert[face->v2].co; + t2 = vert[face->v3].co; + t3 = face->v4 ? vert[face->v4].co : NULL; - do - { + do { float nearest_tmp[3], dist; int vertex, edge; @@ -397,8 +396,8 @@ static void mesh_faces_nearest_point(void *userdata, int index, const float co[3 // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit) { - const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; - MVert *vert = data->vert; + const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; + MVert *vert = data->vert; MFace *face = data->face + index; float *t0, *t1, *t2, *t3; @@ -408,8 +407,7 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r t3 = face->v4 ? vert[face->v4].co : NULL; - do - { + do { float dist; if (data->sphere_radius == 0.0f) dist = bvhtree_ray_tri_intersection(ray, hit->dist, t0, t1, t2); @@ -435,14 +433,14 @@ static void mesh_faces_spherecast(void *userdata, int index, const BVHTreeRay *r // userdata must be a BVHMeshCallbackUserdata built from the same mesh as the tree. static void mesh_edges_nearest_point(void *userdata, int index, const float co[3], BVHTreeNearest *nearest) { - const BVHTreeFromMesh *data = (BVHTreeFromMesh*) userdata; - MVert *vert = data->vert; + const BVHTreeFromMesh *data = (BVHTreeFromMesh *) userdata; + MVert *vert = data->vert; MEdge *edge = data->edge + index; float nearest_tmp[3], dist; float *t0, *t1; - t0 = vert[ edge->v1 ].co; - t1 = vert[ edge->v2 ].co; + t0 = vert[edge->v1].co; + t1 = vert[edge->v2].co; closest_to_line_segment_v3(nearest_tmp, co, t0, t1); dist = len_squared_v3v3(nearest_tmp, co); @@ -460,15 +458,15 @@ static void mesh_edges_nearest_point(void *userdata, int index, const float co[3 * BVH builders */ // Builds a bvh tree.. where nodes are the vertexs of the given mesh -BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree *bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_VERTICES); //Not in cache if (tree == NULL) { int i; - int numVerts= mesh->getNumVerts(mesh); - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + int numVerts = mesh->getNumVerts(mesh); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); if (vert != NULL) { tree = BLI_bvhtree_new(numVerts, epsilon, tree_type, axis); @@ -514,14 +512,14 @@ BVHTree* bvhtree_from_mesh_verts(BVHTreeFromMesh *data, DerivedMesh *mesh, float } // Builds a bvh tree.. where nodes are the faces of the given mesh. -BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree *bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_FACES); //Not in cache if (tree == NULL) { int i; - int numFaces= mesh->getNumTessFaces(mesh); + int numFaces = mesh->getNumTessFaces(mesh); /* BMESH specific check that we have tessfaces, * we _could_ tessellate here but rather not - campbell @@ -534,7 +532,7 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float /* Create a bvh-tree of the given target */ tree = BLI_bvhtree_new(numFaces, epsilon, tree_type, axis); if (tree != NULL) { - BMEditMesh *em= data->em_evil; + BMEditMesh *em = data->em_evil; if (em) { /* data->em_evil is only set for snapping, and only for the mesh of the object * which is currently open in edit mode. When set, the bvhtree should not contain @@ -594,17 +592,17 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } } else { - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MFace *face = mesh->getTessFaceDataArray(mesh, CD_MFACE); if (vert != NULL && face != NULL) { for (i = 0; i < numFaces; i++) { float co[4][3]; - copy_v3_v3(co[0], vert[ face[i].v1 ].co); - copy_v3_v3(co[1], vert[ face[i].v2 ].co); - copy_v3_v3(co[2], vert[ face[i].v3 ].co); + copy_v3_v3(co[0], vert[face[i].v1].co); + copy_v3_v3(co[1], vert[face[i].v2].co); + copy_v3_v3(co[2], vert[face[i].v3].co); if (face[i].v4) - copy_v3_v3(co[3], vert[ face[i].v4 ].co); + copy_v3_v3(co[3], vert[face[i].v4].co); BLI_bvhtree_insert(tree, i, co[0], face[i].v4 ? 4 : 3); } @@ -644,15 +642,15 @@ BVHTree* bvhtree_from_mesh_faces(BVHTreeFromMesh *data, DerivedMesh *mesh, float } // Builds a bvh tree.. where nodes are the faces of the given mesh. -BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) +BVHTree *bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float epsilon, int tree_type, int axis) { BVHTree *tree = bvhcache_find(&mesh->bvhCache, BVHTREE_FROM_EDGES); //Not in cache if (tree == NULL) { int i; - int numEdges= mesh->getNumEdges(mesh); - MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); + int numEdges = mesh->getNumEdges(mesh); + MVert *vert = mesh->getVertDataArray(mesh, CD_MVERT); MEdge *edge = mesh->getEdgeDataArray(mesh, CD_MEDGE); if (vert != NULL && edge != NULL) { @@ -661,8 +659,8 @@ BVHTree* bvhtree_from_mesh_edges(BVHTreeFromMesh *data, DerivedMesh *mesh, float if (tree != NULL) { for (i = 0; i < numEdges; i++) { float co[4][3]; - copy_v3_v3(co[0], vert[ edge[i].v1 ].co); - copy_v3_v3(co[1], vert[ edge[i].v2 ].co); + copy_v3_v3(co[0], vert[edge[i].v1].co); + copy_v3_v3(co[1], vert[edge[i].v2].co); BLI_bvhtree_insert(tree, i, co[0], 2); } @@ -712,8 +710,7 @@ void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data) /* BVHCache */ -typedef struct BVHCacheItem -{ +typedef struct BVHCacheItem { int type; BVHTree *tree; @@ -721,8 +718,8 @@ typedef struct BVHCacheItem static void bvhcacheitem_set_if_match(void *_cached, void *_search) { - BVHCacheItem * cached = (BVHCacheItem *)_cached; - BVHCacheItem * search = (BVHCacheItem *)_search; + BVHCacheItem *cached = (BVHCacheItem *)_cached; + BVHCacheItem *search = (BVHCacheItem *)_search; if (search->type == cached->type) { search->tree = cached->tree; diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 11c628e7848..e1cfcee1367 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -54,15 +54,15 @@ void *BKE_camera_add(const char *name) { Camera *cam; - cam= alloc_libblock(&G.main->camera, ID_CA, name); + cam = BKE_libblock_alloc(&G.main->camera, ID_CA, name); - cam->lens= 35.0f; - cam->sensor_x= 32.0f; - cam->sensor_y= 18.0f; - cam->clipsta= 0.1f; - cam->clipend= 100.0f; - cam->drawsize= 0.5f; - cam->ortho_scale= 6.0; + cam->lens = 35.0f; + cam->sensor_x = 32.0f; + cam->sensor_y = 18.0f; + cam->clipsta = 0.1f; + cam->clipend = 100.0f; + cam->drawsize = 0.5f; + cam->ortho_scale = 6.0; cam->flag |= CAM_SHOWPASSEPARTOUT; cam->passepartalpha = 0.5f; @@ -73,7 +73,7 @@ Camera *BKE_camera_copy(Camera *cam) { Camera *camn; - camn= copy_libblock(&cam->id); + camn = BKE_libblock_copy(&cam->id); id_lib_extern((ID *)camn->dof_ob); @@ -82,25 +82,25 @@ Camera *BKE_camera_copy(Camera *cam) void BKE_camera_make_local(Camera *cam) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (cam->id.lib==NULL) return; - if (cam->id.us==1) { + if (cam->id.lib == NULL) return; + if (cam->id.us == 1) { id_clear_lib_data(bmain, &cam->id); return; } - for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { - if (ob->data==cam) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { + if (ob->data == cam) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -108,17 +108,17 @@ void BKE_camera_make_local(Camera *cam) id_clear_lib_data(bmain, &cam->id); } else if (is_local && is_lib) { - Camera *cam_new= BKE_camera_copy(cam); + Camera *cam_new = BKE_camera_copy(cam); - cam_new->id.us= 0; + cam_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, cam->id.lib, &cam_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->data == cam) { - if (ob->id.lib==NULL) { - ob->data= cam_new; + if (ob->id.lib == NULL) { + ob->data = cam_new; cam_new->id.us++; cam->id.us--; } @@ -136,10 +136,10 @@ void BKE_camera_free(Camera *ca) void BKE_camera_object_mode(RenderData *rd, Object *cam_ob) { - rd->mode &= ~(R_ORTHO|R_PANORAMA); + rd->mode &= ~(R_ORTHO | R_PANORAMA); - if (cam_ob && cam_ob->type==OB_CAMERA) { - Camera *cam= cam_ob->data; + if (cam_ob && cam_ob->type == OB_CAMERA) { + Camera *cam = cam_ob->data; if (cam->type == CAM_ORTHO) rd->mode |= R_ORTHO; if (cam->type == CAM_PANO) rd->mode |= R_PANORAMA; } @@ -193,11 +193,11 @@ void BKE_camera_params_init(CameraParams *params) memset(params, 0, sizeof(CameraParams)); /* defaults */ - params->sensor_x= DEFAULT_SENSOR_WIDTH; - params->sensor_y= DEFAULT_SENSOR_HEIGHT; - params->sensor_fit= CAMERA_SENSOR_FIT_AUTO; + params->sensor_x = DEFAULT_SENSOR_WIDTH; + params->sensor_y = DEFAULT_SENSOR_HEIGHT; + params->sensor_fit = CAMERA_SENSOR_FIT_AUTO; - params->zoom= 1.0f; + params->zoom = 1.0f; } void BKE_camera_params_from_object(CameraParams *params, Object *ob) @@ -205,73 +205,73 @@ void BKE_camera_params_from_object(CameraParams *params, Object *ob) if (!ob) return; - if (ob->type==OB_CAMERA) { + if (ob->type == OB_CAMERA) { /* camera object */ - Camera *cam= ob->data; + Camera *cam = ob->data; if (cam->type == CAM_ORTHO) - params->is_ortho= TRUE; - params->lens= cam->lens; - params->ortho_scale= cam->ortho_scale; + params->is_ortho = TRUE; + params->lens = cam->lens; + params->ortho_scale = cam->ortho_scale; - params->shiftx= cam->shiftx; - params->shifty= cam->shifty; + params->shiftx = cam->shiftx; + params->shifty = cam->shifty; - params->sensor_x= cam->sensor_x; - params->sensor_y= cam->sensor_y; - params->sensor_fit= cam->sensor_fit; + params->sensor_x = cam->sensor_x; + params->sensor_y = cam->sensor_y; + params->sensor_fit = cam->sensor_fit; - params->clipsta= cam->clipsta; - params->clipend= cam->clipend; + params->clipsta = cam->clipsta; + params->clipend = cam->clipend; } - else if (ob->type==OB_LAMP) { + else if (ob->type == OB_LAMP) { /* lamp object */ - Lamp *la= ob->data; - float fac= cosf((float)M_PI*la->spotsize/360.0f); - float phi= acos(fac); + Lamp *la = ob->data; + float fac = cosf((float)M_PI * la->spotsize / 360.0f); + float phi = acos(fac); - params->lens= 16.0f*fac/sinf(phi); - if (params->lens==0.0f) - params->lens= 35.0f; + params->lens = 16.0f * fac / sinf(phi); + if (params->lens == 0.0f) + params->lens = 35.0f; - params->clipsta= la->clipsta; - params->clipend= la->clipend; + params->clipsta = la->clipsta; + params->clipend = la->clipend; } } void BKE_camera_params_from_view3d(CameraParams *params, View3D *v3d, RegionView3D *rv3d) { /* common */ - params->lens= v3d->lens; - params->clipsta= v3d->near; - params->clipend= v3d->far; + params->lens = v3d->lens; + params->clipsta = v3d->near; + params->clipend = v3d->far; - if (rv3d->persp==RV3D_CAMOB) { + if (rv3d->persp == RV3D_CAMOB) { /* camera view */ BKE_camera_params_from_object(params, v3d->camera); - params->zoom= BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); + params->zoom = BKE_screen_view3d_zoom_to_fac((float)rv3d->camzoom); - params->offsetx= 2.0f*rv3d->camdx*params->zoom; - params->offsety= 2.0f*rv3d->camdy*params->zoom; + params->offsetx = 2.0f * rv3d->camdx * params->zoom; + params->offsety = 2.0f * rv3d->camdy * params->zoom; params->shiftx *= params->zoom; params->shifty *= params->zoom; - params->zoom= 1.0f/params->zoom; + params->zoom = 1.0f / params->zoom; } - else if (rv3d->persp==RV3D_ORTHO) { + else if (rv3d->persp == RV3D_ORTHO) { /* orthographic view */ - params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality - params->clipsta= - params->clipend; + params->clipend *= 0.5f; // otherwise too extreme low zbuffer quality + params->clipsta = -params->clipend; - params->is_ortho= TRUE; + params->is_ortho = TRUE; params->ortho_scale = rv3d->dist; - params->zoom= 2.0f; + params->zoom = 2.0f; } else { /* perspective view */ - params->zoom= 2.0f; + params->zoom = 2.0f; } } @@ -282,28 +282,28 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win int sensor_fit; /* fields rendering */ - params->ycor= yasp/xasp; + params->ycor = yasp / xasp; if (params->use_fields) params->ycor *= 2.0f; if (params->is_ortho) { /* orthographic camera */ /* scale == 1.0 means exact 1 to 1 mapping */ - pixsize= params->ortho_scale; + pixsize = params->ortho_scale; } else { /* perspective camera */ - sensor_size= BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); - pixsize= (sensor_size * params->clipsta)/params->lens; + sensor_size = BKE_camera_sensor_size(params->sensor_fit, params->sensor_x, params->sensor_y); + pixsize = (sensor_size * params->clipsta) / params->lens; } /* determine sensor fit */ - sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp*winx, yasp*winy); + sensor_fit = BKE_camera_sensor_fit(params->sensor_fit, xasp * winx, yasp * winy); - if (sensor_fit==CAMERA_SENSOR_FIT_HOR) - viewfac= winx; + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) + viewfac = winx; else - viewfac= params->ycor * winy; + viewfac = params->ycor * winy; pixsize /= viewfac; @@ -312,14 +312,14 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win /* compute view plane: * fully centered, zbuffer fills in jittered between -.5 and +.5 */ - viewplane.xmin = -0.5f*(float)winx; - viewplane.ymin = -0.5f*params->ycor*(float)winy; - viewplane.xmax = 0.5f*(float)winx; - viewplane.ymax = 0.5f*params->ycor*(float)winy; + viewplane.xmin = -0.5f * (float)winx; + viewplane.ymin = -0.5f * params->ycor * (float)winy; + viewplane.xmax = 0.5f * (float)winx; + viewplane.ymax = 0.5f * params->ycor * (float)winy; /* lens shift and offset */ - dx= params->shiftx*viewfac + winx*params->offsetx; - dy= params->shifty*viewfac + winy*params->offsety; + dx = params->shiftx * viewfac + winx * params->offsetx; + dy = params->shifty * viewfac + winy * params->offsety; viewplane.xmin += dx; viewplane.ymin += dy; @@ -329,12 +329,12 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win /* fields offset */ if (params->field_second) { if (params->field_odd) { - viewplane.ymin-= 0.5f * params->ycor; - viewplane.ymax-= 0.5f * params->ycor; + viewplane.ymin -= 0.5f * params->ycor; + viewplane.ymax -= 0.5f * params->ycor; } else { - viewplane.ymin+= 0.5f * params->ycor; - viewplane.ymax+= 0.5f * params->ycor; + viewplane.ymin += 0.5f * params->ycor; + viewplane.ymax += 0.5f * params->ycor; } } @@ -345,9 +345,9 @@ void BKE_camera_params_compute_viewplane(CameraParams *params, int winx, int win viewplane.ymin *= pixsize; viewplane.ymax *= pixsize; - params->viewdx= pixsize; - params->viewdy= params->ycor * pixsize; - params->viewplane= viewplane; + params->viewdx = pixsize; + params->viewdy = params->ycor * pixsize; + params->viewplane = viewplane; } /* viewplane is assumed to be already computed */ @@ -374,61 +374,61 @@ void BKE_camera_view_frame_ex(Scene *scene, Camera *camera, float drawsize, cons /* aspect correcton */ if (scene) { - float aspx= (float) scene->r.xsch*scene->r.xasp; - float aspy= (float) scene->r.ysch*scene->r.yasp; - int sensor_fit= BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy); + float aspx = (float) scene->r.xsch * scene->r.xasp; + float aspy = (float) scene->r.ysch * scene->r.yasp; + int sensor_fit = BKE_camera_sensor_fit(camera->sensor_fit, aspx, aspy); - if (sensor_fit==CAMERA_SENSOR_FIT_HOR) { - r_asp[0]= 1.0; - r_asp[1]= aspy / aspx; + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { + r_asp[0] = 1.0; + r_asp[1] = aspy / aspx; } else { - r_asp[0]= aspx / aspy; - r_asp[1]= 1.0; + r_asp[0] = aspx / aspy; + r_asp[1] = 1.0; } } else { - r_asp[0]= 1.0f; - r_asp[1]= 1.0f; + r_asp[0] = 1.0f; + r_asp[1] = 1.0f; } - if (camera->type==CAM_ORTHO) { - facx= 0.5f * camera->ortho_scale * r_asp[0] * scale[0]; - facy= 0.5f * camera->ortho_scale * r_asp[1] * scale[1]; - r_shift[0]= camera->shiftx * camera->ortho_scale * scale[0]; - r_shift[1]= camera->shifty * camera->ortho_scale * scale[1]; - depth= do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : - drawsize * camera->ortho_scale * scale[2]; + if (camera->type == CAM_ORTHO) { + facx = 0.5f * camera->ortho_scale * r_asp[0] * scale[0]; + facy = 0.5f * camera->ortho_scale * r_asp[1] * scale[1]; + r_shift[0] = camera->shiftx * camera->ortho_scale * scale[0]; + r_shift[1] = camera->shifty * camera->ortho_scale * scale[1]; + depth = do_clip ? -((camera->clipsta * scale[2]) + 0.1f) : -drawsize * camera->ortho_scale * scale[2]; - *r_drawsize= 0.5f * camera->ortho_scale; + *r_drawsize = 0.5f * camera->ortho_scale; } else { /* that way it's always visible - clipsta+0.1 */ float fac; - float half_sensor= 0.5f*((camera->sensor_fit==CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x)); + float half_sensor = 0.5f * ((camera->sensor_fit == CAMERA_SENSOR_FIT_VERT) ? (camera->sensor_y) : (camera->sensor_x)); - *r_drawsize= drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); + *r_drawsize = drawsize / ((scale[0] + scale[1] + scale[2]) / 3.0f); if (do_clip) { /* fixed depth, variable size (avoids exceeding clipping range) */ depth = -(camera->clipsta + 0.1f); - fac = depth / (camera->lens/(-half_sensor) * scale[2]); + fac = depth / (camera->lens / (-half_sensor) * scale[2]); } else { /* fixed size, variable depth (stays a reasonable size in the 3D view) */ - depth= *r_drawsize * camera->lens/(-half_sensor) * scale[2]; - fac= *r_drawsize; + depth = *r_drawsize * camera->lens / (-half_sensor) * scale[2]; + fac = *r_drawsize; } - facx= fac * r_asp[0] * scale[0]; - facy= fac * r_asp[1] * scale[1]; - r_shift[0]= camera->shiftx*fac*2 * scale[0]; - r_shift[1]= camera->shifty*fac*2 * scale[1]; + facx = fac * r_asp[0] * scale[0]; + facy = fac * r_asp[1] * scale[1]; + r_shift[0] = camera->shiftx * fac * 2 * scale[0]; + r_shift[1] = camera->shifty * fac * 2 * scale[1]; } - r_vec[0][0]= r_shift[0] + facx; r_vec[0][1]= r_shift[1] + facy; r_vec[0][2]= depth; - r_vec[1][0]= r_shift[0] + facx; r_vec[1][1]= r_shift[1] - facy; r_vec[1][2]= depth; - r_vec[2][0]= r_shift[0] - facx; r_vec[2][1]= r_shift[1] - facy; r_vec[2][2]= depth; - r_vec[3][0]= r_shift[0] - facx; r_vec[3][1]= r_shift[1] + facy; r_vec[3][2]= depth; + r_vec[0][0] = r_shift[0] + facx; r_vec[0][1] = r_shift[1] + facy; r_vec[0][2] = depth; + r_vec[1][0] = r_shift[0] + facx; r_vec[1][1] = r_shift[1] - facy; r_vec[1][2] = depth; + r_vec[2][0] = r_shift[0] - facx; r_vec[2][1] = r_shift[1] - facy; r_vec[2][2] = depth; + r_vec[3][0] = r_shift[0] - facx; r_vec[3][1] = r_shift[1] + facy; r_vec[3][2] = depth; } void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) @@ -436,10 +436,10 @@ void BKE_camera_view_frame(Scene *scene, Camera *camera, float r_vec[4][3]) float dummy_asp[2]; float dummy_shift[2]; float dummy_drawsize; - const float dummy_scale[3]= {1.0f, 1.0f, 1.0f}; + const float dummy_scale[3] = {1.0f, 1.0f, 1.0f}; BKE_camera_view_frame_ex(scene, camera, FALSE, 1.0, dummy_scale, - dummy_asp, dummy_shift, &dummy_drawsize, r_vec); + dummy_asp, dummy_shift, &dummy_drawsize, r_vec); } @@ -452,13 +452,13 @@ typedef struct CameraViewFrameData { static void BKE_camera_to_frame_view_cb(const float co[3], void *user_data) { - CameraViewFrameData *data= (CameraViewFrameData *)user_data; + CameraViewFrameData *data = (CameraViewFrameData *)user_data; unsigned int i; - for (i= 0; i < 4; i++) { - float nd= dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]); + for (i = 0; i < 4; i++) { + float nd = dist_to_plane_v3(co, data->frame_tx[i], data->normal_tx[i]); if (nd < data->dist_vals[i]) { - data->dist_vals[i]= nd; + data->dist_vals[i] = nd; } } @@ -472,7 +472,7 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object float shift[2]; float plane_tx[4][3]; float rot_obmat[3][3]; - const float zero[3]= {0, 0, 0}; + const float zero[3] = {0, 0, 0}; CameraViewFrameData data_cb; unsigned int i; @@ -482,36 +482,36 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object copy_m3_m4(rot_obmat, camera_ob->obmat); normalize_m3(rot_obmat); - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { /* normalize so Z is always 1.0f*/ - mul_v3_fl(data_cb.frame_tx[i], 1.0f/data_cb.frame_tx[i][2]); + mul_v3_fl(data_cb.frame_tx[i], 1.0f / data_cb.frame_tx[i][2]); } /* get the shift back out of the frame */ - shift[0]= (data_cb.frame_tx[0][0] + - data_cb.frame_tx[1][0] + - data_cb.frame_tx[2][0] + - data_cb.frame_tx[3][0]) / 4.0f; - shift[1]= (data_cb.frame_tx[0][1] + - data_cb.frame_tx[1][1] + - data_cb.frame_tx[2][1] + - data_cb.frame_tx[3][1]) / 4.0f; + shift[0] = (data_cb.frame_tx[0][0] + + data_cb.frame_tx[1][0] + + data_cb.frame_tx[2][0] + + data_cb.frame_tx[3][0]) / 4.0f; + shift[1] = (data_cb.frame_tx[0][1] + + data_cb.frame_tx[1][1] + + data_cb.frame_tx[2][1] + + data_cb.frame_tx[3][1]) / 4.0f; - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { mul_m3_v3(rot_obmat, data_cb.frame_tx[i]); } - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { normal_tri_v3(data_cb.normal_tx[i], zero, data_cb.frame_tx[i], data_cb.frame_tx[(i + 1) % 4]); } /* initialize callback data */ - data_cb.dist_vals[0]= - data_cb.dist_vals[1]= - data_cb.dist_vals[2]= - data_cb.dist_vals[3]= FLT_MAX; - data_cb.tot= 0; + data_cb.dist_vals[0] = + data_cb.dist_vals[1] = + data_cb.dist_vals[2] = + data_cb.dist_vals[3] = FLT_MAX; + data_cb.tot = 0; /* run callback on all visible points */ BKE_scene_foreach_display_point(scene, v3d, BA_SELECT, BKE_camera_to_frame_view_cb, &data_cb); @@ -526,7 +526,7 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object float plane_isect_pt_1[3], plane_isect_pt_2[3]; /* apply the dist-from-plane's to the transformed plane points */ - for (i= 0; i < 4; i++) { + for (i = 0; i < 4; i++) { mul_v3_v3fl(plane_tx[i], data_cb.normal_tx[i], data_cb.dist_vals[i]); } @@ -547,14 +547,14 @@ int BKE_camera_view_frame_fit_to_scene(Scene *scene, struct View3D *v3d, Object return FALSE; } else { - float cam_plane_no[3]= {0.0f, 0.0f, -1.0f}; + float cam_plane_no[3] = {0.0f, 0.0f, -1.0f}; float plane_isect_delta[3]; float plane_isect_delta_len; mul_m3_v3(rot_obmat, cam_plane_no); sub_v3_v3v3(plane_isect_delta, plane_isect_pt_2, plane_isect_pt_1); - plane_isect_delta_len= len_v3(plane_isect_delta); + plane_isect_delta_len = len_v3(plane_isect_delta); if (dot_v3v3(plane_isect_delta, cam_plane_no) > 0.0f) { copy_v3_v3(r_co, plane_isect_pt_1); diff --git a/source/blender/blenkernel/intern/cdderivedmesh.c b/source/blender/blenkernel/intern/cdderivedmesh.c index 78a8b975b85..3ef2ce56cd6 100644 --- a/source/blender/blenkernel/intern/cdderivedmesh.c +++ b/source/blender/blenkernel/intern/cdderivedmesh.c @@ -1,4 +1,4 @@ - /* +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or @@ -172,7 +172,7 @@ static void cdDM_copyPolyArray(DerivedMesh *dm, MPoly *poly_r) static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; int i; if (dm->numVertData) { @@ -188,7 +188,7 @@ static void cdDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) static void cdDM_getVertCo(DerivedMesh *dm, int index, float co_r[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; copy_v3_v3(co_r, cddm->mvert[index].co); } @@ -204,16 +204,16 @@ static void cdDM_getVertCos(DerivedMesh *dm, float (*cos_r)[3]) static void cdDM_getVertNo(DerivedMesh *dm, int index, float no_r[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; normal_short_to_float_v3(no_r, cddm->mvert[index].no); } static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; if (!cddm->pmap && ob->type == OB_MESH) { - Mesh *me= ob->data; + Mesh *me = ob->data; create_vert_poly_map(&cddm->pmap, &cddm->pmap_mem, me->mpoly, me->mloop, @@ -225,7 +225,7 @@ static const MeshElemMap *cdDM_getPolyMap(Object *ob, DerivedMesh *dm) static int can_pbvh_draw(Object *ob, DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; Mesh *me = ob->data; int deformed = 0; @@ -245,12 +245,12 @@ static int can_pbvh_draw(Object *ob, DerivedMesh *dm) return cddm->mvert == me->mvert || ob->sculpt->kb; } -static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) +static PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; if (!ob) { - cddm->pbvh= NULL; + cddm->pbvh = NULL; return NULL; } @@ -258,7 +258,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) return NULL; if (ob->sculpt->pbvh) { - cddm->pbvh= ob->sculpt->pbvh; + cddm->pbvh = ob->sculpt->pbvh; cddm->pbvh_draw = can_pbvh_draw(ob, dm); } @@ -276,7 +276,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) BKE_mesh_tessface_ensure(me); BLI_pbvh_build_mesh(cddm->pbvh, me->mface, me->mvert, - me->totface, me->totvert); + me->totface, me->totvert, &me->vdata); deformed = ss->modifiers_active || me->key; @@ -286,7 +286,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) int totvert; totvert = deformdm->getNumVerts(deformdm); - vertCos = MEM_callocN(3*totvert*sizeof(float), "cdDM_getPBVH vertCos"); + vertCos = MEM_callocN(3 * totvert * sizeof(float), "cdDM_getPBVH vertCos"); deformdm->getVertCos(deformdm, vertCos); BLI_pbvh_apply_vertCos(cddm->pbvh, vertCos); MEM_freeN(vertCos); @@ -300,7 +300,7 @@ static struct PBVH *cdDM_getPBVH(Object *ob, DerivedMesh *dm) * TODO: proper fix is to support the pbvh in all drawing modes */ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; float (*face_nors)[3]; if (!cddm->pbvh || !cddm->pbvh_draw || !dm->numTessFaceData) @@ -313,7 +313,7 @@ static void cdDM_update_normals_from_pbvh(DerivedMesh *dm) static void cdDM_drawVerts(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; int i; @@ -323,7 +323,7 @@ static void cdDM_drawVerts(DerivedMesh *dm) glVertex3fv(mv->co); glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); if (!GPU_buffer_legacy(dm)) { if (dm->drawObject->tot_triangle_point) @@ -337,7 +337,7 @@ static void cdDM_drawVerts(DerivedMesh *dm) static void cdDM_drawUVEdges(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MFace *mf = cddm->mface; MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); int i; @@ -346,7 +346,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) if (GPU_buffer_legacy(dm)) { glBegin(GL_LINES); for (i = 0; i < dm->numTessFaceData; i++, mf++, tf++) { - if (!(mf->flag&ME_HIDE)) { + if (!(mf->flag & ME_HIDE)) { glVertex2fv(tf->uv[0]); glVertex2fv(tf->uv[1]); @@ -377,19 +377,19 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) GPU_uvedge_setup(dm); if (!GPU_buffer_legacy(dm)) { for (i = 0; i < dm->numTessFaceData; i++, mf++) { - if (!(mf->flag&ME_HIDE)) { + if (!(mf->flag & ME_HIDE)) { draw = 1; } else { draw = 0; } - if ( prevdraw != draw ) { - if ( prevdraw > 0 && (curpos-prevstart) > 0) { - glDrawArrays(GL_LINES, prevstart, curpos-prevstart); + if (prevdraw != draw) { + if (prevdraw > 0 && (curpos - prevstart) > 0) { + glDrawArrays(GL_LINES, prevstart, curpos - prevstart); } prevstart = curpos; } - if ( mf->v4 ) { + if (mf->v4) { curpos += 8; } else { @@ -397,8 +397,8 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) } prevdraw = draw; } - if ( prevdraw > 0 && (curpos-prevstart) > 0 ) { - glDrawArrays(GL_LINES, prevstart, curpos-prevstart); + if (prevdraw > 0 && (curpos - prevstart) > 0) { + glDrawArrays(GL_LINES, prevstart, curpos - prevstart); } } GPU_buffer_unbind(); @@ -408,7 +408,7 @@ static void cdDM_drawUVEdges(DerivedMesh *dm) static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mvert = cddm->mvert; MEdge *medge = cddm->medge; int i; @@ -426,7 +426,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges } glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ int prevstart = 0; int prevdraw = 1; int draw = TRUE; @@ -442,16 +442,16 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges else { draw = FALSE; } - if ( prevdraw != draw ) { - if ( prevdraw > 0 && (i-prevstart) > 0 ) { + if (prevdraw != draw) { + if (prevdraw > 0 && (i - prevstart) > 0) { GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } prevstart = i; } prevdraw = draw; } - if ( prevdraw > 0 && (i-prevstart) > 0 ) { - GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i-prevstart) * 2); + if (prevdraw > 0 && (i - prevstart) > 0) { + GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } } GPU_buffer_unbind(); @@ -460,7 +460,7 @@ static void cdDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdges static void cdDM_drawLooseEdges(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mvert = cddm->mvert; MEdge *medge = cddm->medge; int i; @@ -469,14 +469,14 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) DEBUG_VBO("Using legacy code. cdDM_drawLooseEdges\n"); glBegin(GL_LINES); for (i = 0; i < dm->numEdgeData; i++, medge++) { - if (medge->flag&ME_LOOSEEDGE) { + if (medge->flag & ME_LOOSEEDGE) { glVertex3fv(mvert[medge->v1].co); glVertex3fv(mvert[medge->v2].co); } } glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ int prevstart = 0; int prevdraw = 1; int draw = 1; @@ -484,21 +484,21 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) GPU_edge_setup(dm); if (!GPU_buffer_legacy(dm)) { for (i = 0; i < dm->numEdgeData; i++, medge++) { - if (medge->flag&ME_LOOSEEDGE) { + if (medge->flag & ME_LOOSEEDGE) { draw = 1; } else { draw = 0; } - if ( prevdraw != draw ) { - if ( prevdraw > 0 && (i-prevstart) > 0) { + if (prevdraw != draw) { + if (prevdraw > 0 && (i - prevstart) > 0) { GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } prevstart = i; } prevdraw = draw; } - if ( prevdraw > 0 && (i-prevstart) > 0 ) { + if (prevdraw > 0 && (i - prevstart) > 0) { GPU_buffer_draw_elements(dm->drawObject->edges, GL_LINES, prevstart * 2, (i - prevstart) * 2); } } @@ -507,13 +507,13 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm) } static void cdDM_drawFacesSolid(DerivedMesh *dm, - float (*partial_redraw_planes)[4], - int UNUSED(fast), DMSetMaterial setMaterial) + float (*partial_redraw_planes)[4], + int UNUSED(fast), DMSetMaterial setMaterial) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mvert = cddm->mvert; MFace *mface = cddm->mface; - float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); + float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); int a, glmode = -1, shademodel = -1, matnr = -1, drawCurrentMat = 1; #define PASSVERT(index) { \ @@ -521,7 +521,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, short *no = mvert[index].no; \ glNormal3sv(no); \ } \ - glVertex3fv(mvert[index].co); \ + glVertex3fv(mvert[index].co); \ } if (cddm->pbvh && cddm->pbvh_draw) { @@ -541,9 +541,9 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, for (a = 0; a < dm->numTessFaceData; a++, mface++) { int new_glmode, new_matnr, new_shademodel; - new_glmode = mface->v4?GL_QUADS:GL_TRIANGLES; + new_glmode = mface->v4 ? GL_QUADS : GL_TRIANGLES; new_matnr = mface->mat_nr + 1; - new_shademodel = (mface->flag & ME_SMOOTH)?GL_SMOOTH:GL_FLAT; + new_shademodel = (mface->flag & ME_SMOOTH) ? GL_SMOOTH : GL_FLAT; if (new_glmode != glmode || new_matnr != matnr || new_shademodel != shademodel) { glEnd(); @@ -584,7 +584,7 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } glEnd(); } - else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ + else { /* use OpenGL VBOs or Vertex Arrays instead for better, faster rendering */ GPU_vertex_setup(dm); GPU_normal_setup(dm); if (!GPU_buffer_legacy(dm)) { @@ -604,16 +604,16 @@ static void cdDM_drawFacesSolid(DerivedMesh *dm, } static void cdDM_drawFacesTex_common(DerivedMesh *dm, - DMSetDrawOptionsTex drawParams, - DMSetDrawOptions drawParamsMapped, - DMCompareDrawOptions compareDrawOptions, - void *userData) + DMSetDrawOptionsTex drawParams, + DMSetDrawOptions drawParamsMapped, + DMCompareDrawOptions compareDrawOptions, + void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; MFace *mf = DM_get_tessface_data_layer(dm, CD_MFACE); MCol *realcol = dm->getTessFaceDataArray(dm, CD_TEXTURE_MCOL); - float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); + float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); int i, j, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); int startFace = 0 /*, lastFlag = 0xdeadbeef */ /* UNUSED */; @@ -631,25 +631,25 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, unsigned char *cp = NULL; if (drawParams) { - draw_option = drawParams(tf? &tf[i]: NULL, (mcol != NULL), mf->mat_nr); + draw_option = drawParams(tf ? &tf[i] : NULL, (mcol != NULL), mf->mat_nr); } else { if (index) { orig = *index++; - if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; } + if (orig == ORIGINDEX_NONE) { if (nors) nors += 3; continue; } if (drawParamsMapped) draw_option = drawParamsMapped(userData, orig); - else { if (nors) nors += 3; continue; } + else { if (nors) nors += 3; continue; } } else - if (drawParamsMapped) draw_option = drawParamsMapped(userData, i); - else { if (nors) nors += 3; continue; } + if (drawParamsMapped) draw_option = drawParamsMapped(userData, i); + else { if (nors) nors += 3; continue; } } if (draw_option != DM_DRAW_OPTION_SKIP) { if (draw_option != DM_DRAW_OPTION_NO_MCOL && mcol) - cp = (unsigned char*) &mcol[i*4]; + cp = (unsigned char *) &mcol[i * 4]; - if (!(mf->flag&ME_SMOOTH)) { + if (!(mf->flag & ME_SMOOTH)) { if (nors) { glNormal3fv(nors); } @@ -665,30 +665,30 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } } - glBegin(mf->v4?GL_QUADS:GL_TRIANGLES); + glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES); if (tf) glTexCoord2fv(tf[i].uv[0]); if (cp) glColor3ub(cp[3], cp[2], cp[1]); mvert = &mv[mf->v1]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); if (tf) glTexCoord2fv(tf[i].uv[1]); if (cp) glColor3ub(cp[7], cp[6], cp[5]); mvert = &mv[mf->v2]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); if (tf) glTexCoord2fv(tf[i].uv[2]); if (cp) glColor3ub(cp[11], cp[10], cp[9]); mvert = &mv[mf->v3]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); if (mf->v4) { if (tf) glTexCoord2fv(tf[i].uv[3]); if (cp) glColor3ub(cp[15], cp[14], cp[13]); mvert = &mv[mf->v4]; - if (mf->flag&ME_SMOOTH) glNormal3sv(mvert->no); + if (mf->flag & ME_SMOOTH) glNormal3sv(mvert->no); glVertex3fv(mvert->co); } glEnd(); @@ -705,7 +705,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, GPU_vertex_setup(dm); GPU_normal_setup(dm); GPU_uv_setup(dm); - if ( col != NULL ) { + if (col != NULL) { #if 0 if (realcol && dm->drawObject->colType == CD_TEXTURE_MCOL) { col = 0; @@ -717,13 +717,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if (col != 0) #endif { - unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm)*4*3*sizeof(unsigned char), "cdDM_drawFacesTex_common"); + unsigned char *colors = MEM_mallocN(dm->getNumTessFaces(dm) * 4 * 3 * sizeof(unsigned char), "cdDM_drawFacesTex_common"); for (i = 0; i < dm->getNumTessFaces(dm); i++) { for (j = 0; j < 4; j++) { /* bgr -> rgb is intentional (and stupid), but how its stored internally */ - colors[i*12+j*3] = col[i*4+j].b; - colors[i*12+j*3+1] = col[i*4+j].g; - colors[i*12+j*3+2] = col[i*4+j].r; + colors[i * 12 + j * 3] = col[i * 4 + j].b; + colors[i * 12 + j * 3 + 1] = col[i * 4 + j].g; + colors[i * 12 + j * 3 + 2] = col[i * 4 + j].r; } } GPU_color3_upload(dm, colors); @@ -737,7 +737,7 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } if (!GPU_buffer_legacy(dm)) { - int tottri = dm->drawObject->tot_triangle_point/3; + int tottri = dm->drawObject->tot_triangle_point / 3; int next_actualFace = dm->drawObject->triangle_to_mface[0]; glShadeModel(GL_SMOOTH); @@ -747,11 +747,11 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; - if (i != tottri-1) - next_actualFace= dm->drawObject->triangle_to_mface[i+1]; + if (i != tottri - 1) + next_actualFace = dm->drawObject->triangle_to_mface[i + 1]; if (drawParams) { - draw_option = drawParams(tf? &tf[actualFace]: NULL, (mcol != NULL), mf[actualFace].mat_nr); + draw_option = drawParams(tf ? &tf[actualFace] : NULL, (mcol != NULL), mf[actualFace].mat_nr); } else { if (index) { @@ -761,8 +761,8 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, draw_option = drawParamsMapped(userData, orig); } else - if (drawParamsMapped) - draw_option = drawParamsMapped(userData, actualFace); + if (drawParamsMapped) + draw_option = drawParamsMapped(userData, actualFace); } /* flush buffer if current triangle isn't drawable or it's last triangle */ @@ -771,13 +771,13 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, if (!flush && compareDrawOptions) { /* also compare draw options and flush buffer if they're different * need for face selection highlight in edit mode */ - flush|= compareDrawOptions(userData, actualFace, next_actualFace) == 0; + flush |= compareDrawOptions(userData, actualFace, next_actualFace) == 0; } if (flush) { - int first = startFace*3; + int first = startFace * 3; /* Add one to the length if we're drawing at the end of the array */ - int count = (i-startFace+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; + int count = (i - startFace + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3; if (count) { if (col) @@ -799,24 +799,24 @@ static void cdDM_drawFacesTex_common(DerivedMesh *dm, } static void cdDM_drawFacesTex(DerivedMesh *dm, - DMSetDrawOptionsTex setDrawOptions, - DMCompareDrawOptions compareDrawOptions, - void *userData) + DMSetDrawOptionsTex setDrawOptions, + DMCompareDrawOptions compareDrawOptions, + void *userData) { cdDM_drawFacesTex_common(dm, setDrawOptions, NULL, compareDrawOptions, userData); } static void cdDM_drawMappedFaces(DerivedMesh *dm, - DMSetDrawOptions setDrawOptions, - DMSetMaterial setMaterial, - DMCompareDrawOptions compareDrawOptions, - void *userData, DMDrawFlag flag) + DMSetDrawOptions setDrawOptions, + DMSetMaterial setMaterial, + DMCompareDrawOptions compareDrawOptions, + void *userData, DMDrawFlag flag) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; MFace *mf = cddm->mface; MCol *mc; - float *nors= DM_get_tessface_data_layer(dm, CD_NORMAL); + float *nors = DM_get_tessface_data_layer(dm, CD_NORMAL); int useColors = flag & DM_DRAW_USE_COLORS; int i, orig, *index = DM_get_tessface_data_layer(dm, CD_ORIGINDEX); @@ -836,12 +836,12 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int drawSmooth = (flag & DM_DRAW_ALWAYS_SMOOTH) ? 1 : (mf->flag & ME_SMOOTH); DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; - orig = (index==NULL) ? i : *index++; + orig = (index == NULL) ? i : *index++; if (orig == ORIGINDEX_NONE) - draw_option= setMaterial(mf->mat_nr + 1, NULL); + draw_option = setMaterial(mf->mat_nr + 1, NULL); else if (setDrawOptions != NULL) - draw_option= setDrawOptions(userData, orig); + draw_option = setDrawOptions(userData, orig); if (draw_option != DM_DRAW_OPTION_SKIP) { unsigned char *cp = NULL; @@ -852,7 +852,7 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, /* no need to set shading mode to flat because * normals are already used to change shading */ glShadeModel(GL_SMOOTH); - glBegin(mf->v4?GL_QUADS:GL_TRIANGLES); + glBegin(mf->v4 ? GL_QUADS : GL_TRIANGLES); if (!drawSmooth) { if (nors) { @@ -907,10 +907,10 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, int prevstart = 0; GPU_vertex_setup(dm); GPU_normal_setup(dm); - if ( useColors && mc ) + if (useColors && mc) GPU_color_setup(dm); if (!GPU_buffer_legacy(dm)) { - int tottri = dm->drawObject->tot_triangle_point/3; + int tottri = dm->drawObject->tot_triangle_point / 3; glShadeModel(GL_SMOOTH); if (tottri == 0) { @@ -932,15 +932,15 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, DMDrawOption draw_option = DM_DRAW_OPTION_NORMAL; int flush = 0; - if (i != tottri-1) - next_actualFace= dm->drawObject->triangle_to_mface[i+1]; + if (i != tottri - 1) + next_actualFace = dm->drawObject->triangle_to_mface[i + 1]; - orig = (index==NULL) ? actualFace : index[actualFace]; + orig = (index == NULL) ? actualFace : index[actualFace]; if (orig == ORIGINDEX_NONE) - draw_option= setMaterial(mface->mat_nr + 1, NULL); + draw_option = setMaterial(mface->mat_nr + 1, NULL); else if (setDrawOptions != NULL) - draw_option= setDrawOptions(userData, orig); + draw_option = setDrawOptions(userData, orig); /* Goal is to draw as long of a contiguous triangle * array as possible, so draw when we hit either an @@ -957,9 +957,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, } if (flush) { - int first = prevstart*3; + int first = prevstart * 3; /* Add one to the length if we're drawing at the end of the array */ - int count = (i-prevstart+(draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0))*3; + int count = (i - prevstart + (draw_option != DM_DRAW_OPTION_SKIP ? 1 : 0)) * 3; if (count) glDrawArrays(GL_TRIANGLES, first, count); @@ -976,9 +976,9 @@ static void cdDM_drawMappedFaces(DerivedMesh *dm, } static void cdDM_drawMappedFacesTex(DerivedMesh *dm, - DMSetDrawOptions setDrawOptions, - DMCompareDrawOptions compareDrawOptions, - void *userData) + DMSetDrawOptions setDrawOptions, + DMCompareDrawOptions compareDrawOptions, + void *userData) { cdDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData); } @@ -1007,15 +1007,15 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int /* vertex colors */ for (b = 0; b < attribs->totmcol; b++) { - MCol *cp = &attribs->mcol[b].array[a*4 + vert]; + MCol *cp = &attribs->mcol[b].array[a * 4 + vert]; GLubyte col[4]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; glVertexAttrib4ubvARB(attribs->mcol[b].gl_index, col); } /* tangent for normal mapping */ if (attribs->tottang) { - float *tang = attribs->tang.array[a*4 + vert]; + float *tang = attribs->tang.array[a * 4 + vert]; glVertexAttrib4fvARB(attribs->tang.gl_index, tang); } @@ -1028,11 +1028,11 @@ static void cddm_draw_attrib_vertex(DMVertexAttribs *attribs, MVert *mvert, int } static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, - DMSetMaterial setMaterial, - DMSetDrawOptions setDrawOptions, - void *userData) + DMSetMaterial setMaterial, + DMSetDrawOptions setDrawOptions, + void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; GPUVertexAttribs gattribs; DMVertexAttribs attribs; MVert *mvert = cddm->mvert; @@ -1049,7 +1049,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, glShadeModel(GL_SMOOTH); - if ( GPU_buffer_legacy(dm) || setDrawOptions != NULL ) { + if (GPU_buffer_legacy(dm) || setDrawOptions != NULL) { DEBUG_VBO("Using legacy code. cdDM_drawMappedFacesGLSL\n"); memset(&attribs, 0, sizeof(attribs)); @@ -1073,7 +1073,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, continue; } else if (setDrawOptions) { - orig = (index)? index[a]: a; + orig = (index) ? index[a] : a; if (orig == ORIGINDEX_NONE) { /* since the material is set by setMaterial(), faces with no @@ -1128,7 +1128,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_normal_setup(dm); if (!GPU_buffer_legacy(dm)) { - for (i = 0; i < dm->drawObject->tot_triangle_point/3; i++) { + for (i = 0; i < dm->drawObject->tot_triangle_point / 3; i++) { a = dm->drawObject->triangle_to_mface[i]; @@ -1148,7 +1148,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_interleaved_attrib_setup(buffer, datatypes, numdata); } - glDrawArrays(GL_TRIANGLES, start*3, numfaces*3); + glDrawArrays(GL_TRIANGLES, start * 3, numfaces * 3); if (numdata != 0) { @@ -1215,84 +1215,84 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, } } - if (dodraw && numdata != 0 ) { + if (dodraw && numdata != 0) { offset = 0; if (attribs.totorco) { - copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v1]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v2]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v3]); - offset += sizeof(float)*3; + copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v1]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v2]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v3]); + offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[0]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[1]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[0]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[1]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[2]); - offset += sizeof(float)*2; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[2]); + offset += sizeof(float) * 2; } for (b = 0; b < attribs.totmcol; b++) { - MCol *cp = &attribs.mcol[b].array[a*4 + 0]; + MCol *cp = &attribs.mcol[b].array[a * 4 + 0]; GLubyte col[4]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 1]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 2]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col); - offset += sizeof(unsigned char)*4; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 1]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 2]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; } if (attribs.tottang) { - float *tang = attribs.tang.array[a*4 + 0]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang); - tang = attribs.tang.array[a*4 + 1]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize], tang); - tang = attribs.tang.array[a*4 + 2]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); - offset += sizeof(float)*4; + float *tang = attribs.tang.array[a * 4 + 0]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); + tang = attribs.tang.array[a * 4 + 1]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); + tang = attribs.tang.array[a * 4 + 2]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); + offset += sizeof(float) * 4; } (void)offset; } curface++; if (mface->v4) { - if (dodraw && numdata != 0 ) { + if (dodraw && numdata != 0) { offset = 0; if (attribs.totorco) { - copy_v3_v3((float *)&varray[elementsize*curface*3], (float *)attribs.orco.array[mface->v3]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize], (float *)attribs.orco.array[mface->v4]); - copy_v3_v3((float *)&varray[elementsize*curface*3+elementsize*2], (float *)attribs.orco.array[mface->v1]); - offset += sizeof(float)*3; + copy_v3_v3((float *)&varray[elementsize * curface * 3], (float *)attribs.orco.array[mface->v3]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize], (float *)attribs.orco.array[mface->v4]); + copy_v3_v3((float *)&varray[elementsize * curface * 3 + elementsize * 2], (float *)attribs.orco.array[mface->v1]); + offset += sizeof(float) * 3; } for (b = 0; b < attribs.tottface; b++) { MTFace *tf = &attribs.tface[b].array[a]; - copy_v2_v2((float *)&varray[elementsize*curface*3+offset], tf->uv[2]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize], tf->uv[3]); - copy_v2_v2((float *)&varray[elementsize*curface*3+offset+elementsize*2], tf->uv[0]); - offset += sizeof(float)*2; + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset], tf->uv[2]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize], tf->uv[3]); + copy_v2_v2((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tf->uv[0]); + offset += sizeof(float) * 2; } for (b = 0; b < attribs.totmcol; b++) { - MCol *cp = &attribs.mcol[b].array[a*4 + 2]; + MCol *cp = &attribs.mcol[b].array[a * 4 + 2]; GLubyte col[4]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 3]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize], (char *)col); - cp = &attribs.mcol[b].array[a*4 + 0]; - col[0]= cp->b; col[1]= cp->g; col[2]= cp->r; col[3]= cp->a; - copy_v4_v4_char((char *)&varray[elementsize*curface*3+offset+elementsize*2], (char *)col); - offset += sizeof(unsigned char)*4; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 3]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize], (char *)col); + cp = &attribs.mcol[b].array[a * 4 + 0]; + col[0] = cp->b; col[1] = cp->g; col[2] = cp->r; col[3] = cp->a; + copy_v4_v4_char((char *)&varray[elementsize * curface * 3 + offset + elementsize * 2], (char *)col); + offset += sizeof(unsigned char) * 4; } if (attribs.tottang) { - float *tang = attribs.tang.array[a*4 + 2]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset], tang); - tang = attribs.tang.array[a*4 + 3]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize], tang); - tang = attribs.tang.array[a*4 + 0]; - copy_v4_v4((float *)&varray[elementsize*curface*3+offset+elementsize*2], tang); - offset += sizeof(float)*4; + float *tang = attribs.tang.array[a * 4 + 2]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset], tang); + tang = attribs.tang.array[a * 4 + 3]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize], tang); + tang = attribs.tang.array[a * 4 + 0]; + copy_v4_v4((float *)&varray[elementsize * curface * 3 + offset + elementsize * 2], tang); + offset += sizeof(float) * 4; } (void)offset; } @@ -1307,7 +1307,7 @@ static void cdDM_drawMappedFacesGLSL(DerivedMesh *dm, GPU_buffer_unlock(buffer); GPU_interleaved_attrib_setup(buffer, datatypes, numdata); } - glDrawArrays(GL_TRIANGLES, start*3, (curface-start)*3); + glDrawArrays(GL_TRIANGLES, start * 3, (curface - start) * 3); } } GPU_buffer_unbind(); @@ -1324,10 +1324,10 @@ static void cdDM_drawFacesGLSL(DerivedMesh *dm, DMSetMaterial setMaterial) } static void cdDM_drawMappedFacesMat(DerivedMesh *dm, - void (*setMaterial)(void *userData, int, void *attribs), - int (*setFace)(void *userData, int index), void *userData) + void (*setMaterial)(void *userData, int, void *attribs), + int (*setFace)(void *userData, int index), void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; GPUVertexAttribs gattribs; DMVertexAttribs attribs; MVert *mvert = cddm->mvert; @@ -1363,7 +1363,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, /* skipping faces */ if (setFace) { - orig = (index)? index[a]: a; + orig = (index) ? index[a] : a; if (orig != ORIGINDEX_NONE && !setFace(userData, orig)) continue; @@ -1404,7 +1404,7 @@ static void cdDM_drawMappedFacesMat(DerivedMesh *dm, static void cdDM_drawMappedEdges(DerivedMesh *dm, DMSetDrawOptions setDrawOptions, void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *vert = cddm->mvert; MEdge *edge = cddm->medge; int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX); @@ -1450,7 +1450,7 @@ static void cdDM_foreachMappedEdge( void (*func)(void *userData, int index, const float v0co[3], const float v1co[3]), void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*) dm; + CDDerivedMesh *cddm = (CDDerivedMesh *) dm; MVert *mv = cddm->mvert; MEdge *med = cddm->medge; int i, orig, *index = DM_get_edge_data_layer(dm, CD_ORIGINDEX); @@ -1471,7 +1471,7 @@ static void cdDM_foreachMappedFaceCenter( void (*func)(void *userData, int index, const float cent[3], const float no[3]), void *userData) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MVert *mv = cddm->mvert; MPoly *mp = cddm->mpoly; MLoop *ml = cddm->mloop; @@ -1492,7 +1492,7 @@ static void cdDM_foreachMappedFaceCenter( ml = &cddm->mloop[mp->loopstart]; cent[0] = cent[1] = cent[2] = 0.0f; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { add_v3_v3v3(cent, cent, mv[ml->v].co); } mul_v3_fl(cent, 1.0f / (float)j); @@ -1519,12 +1519,12 @@ static void cdDM_foreachMappedFaceCenter( void CDDM_recalc_tessellation_ex(DerivedMesh *dm, const int do_face_nor_cpy) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; - dm->numTessFaceData = mesh_recalcTessellation(&dm->faceData, &dm->loopData, &dm->polyData, - cddm->mvert, - dm->numTessFaceData, dm->numLoopData, dm->numPolyData, - do_face_nor_cpy); + dm->numTessFaceData = BKE_mesh_recalc_tessellation(&dm->faceData, &dm->loopData, &dm->polyData, + cddm->mvert, + dm->numTessFaceData, dm->numLoopData, dm->numPolyData, + do_face_nor_cpy); if (!CustomData_get_layer(&dm->faceData, CD_ORIGINDEX)) { int *polyIndex = CustomData_get_layer(&dm->faceData, CD_POLYINDEX); @@ -1551,7 +1551,7 @@ static void cdDM_free_internal(CDDerivedMesh *cddm) static void cdDM_release(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (DM_release(dm)) { cdDM_free_internal(cddm); @@ -1671,18 +1671,18 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob)) /* this does a referenced copy, with an exception for fluidsim */ DM_init(dm, DM_TYPE_CDDM, mesh->totvert, mesh->totedge, mesh->totface, - mesh->totloop, mesh->totpoly); + mesh->totloop, mesh->totpoly); dm->deformedOnly = 1; - alloctype= CD_REFERENCE; + alloctype = CD_REFERENCE; CustomData_merge(&mesh->vdata, &dm->vertData, mask, alloctype, - mesh->totvert); + mesh->totvert); CustomData_merge(&mesh->edata, &dm->edgeData, mask, alloctype, - mesh->totedge); - CustomData_merge(&mesh->fdata, &dm->faceData, mask|CD_MASK_POLYINDEX, alloctype, - mesh->totface); + mesh->totedge); + CustomData_merge(&mesh->fdata, &dm->faceData, mask | CD_MASK_POLYINDEX, alloctype, + mesh->totface); CustomData_merge(&mesh->ldata, &dm->loopData, mask, alloctype, mesh->totloop); CustomData_merge(&mesh->pdata, &dm->polyData, mask, alloctype, @@ -1723,8 +1723,9 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) MPoly *allpoly; int totvert, totedge, totloop, totpoly; - if (nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge, - &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) { + if (BKE_mesh_nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge, + &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) + { /* Error initializing mdata. This often happens when curve is empty */ return CDDM_new(0, 0, 0, 0, 0); } @@ -1732,12 +1733,12 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) dm = CDDM_new(totvert, totedge, 0, totloop, totpoly); dm->deformedOnly = 1; - cddm = (CDDerivedMesh*)dm; + cddm = (CDDerivedMesh *)dm; - memcpy(cddm->mvert, allvert, totvert*sizeof(MVert)); - memcpy(cddm->medge, alledge, totedge*sizeof(MEdge)); - memcpy(cddm->mloop, allloop, totloop*sizeof(MLoop)); - memcpy(cddm->mpoly, allpoly, totpoly*sizeof(MPoly)); + memcpy(cddm->mvert, allvert, totvert * sizeof(MVert)); + memcpy(cddm->medge, alledge, totedge * sizeof(MEdge)); + memcpy(cddm->mloop, allloop, totloop * sizeof(MLoop)); + memcpy(cddm->mpoly, allpoly, totpoly * sizeof(MPoly)); MEM_freeN(allvert); MEM_freeN(alledge); @@ -1750,8 +1751,8 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase) } static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, - int cdindex, BMLoop *l3[3], - int numCol, int numTex) + int cdindex, BMLoop *l3[3], + int numCol, int numTex) { BMLoop *l; BMFace *f = l3[0]->f; @@ -1768,7 +1769,7 @@ static void loops_to_customdata_corners(BMesh *bm, CustomData *facedata, ME_MTEXFACE_CPY(texface, texpoly); - for (j = 0 ; j < 3; j++) { + for (j = 0; j < 3; j++) { l = l3[j]; mloopuv = CustomData_bmesh_get_n(&bm->ldata, l->head.data, CD_MLOOPUV, i); copy_v2_v2(texface->uv[j], mloopuv->uv); @@ -1806,7 +1807,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis bm->totloop, bm->totface); - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; BMIter iter, liter; BMVert *eve; BMEdge *eed; @@ -1832,7 +1833,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis /*don't add origindex layer if one already exists*/ add_orig = !CustomData_has_layer(&bm->pdata, CD_ORIGINDEX); - mask = use_mdisps ? CD_MASK_DERIVEDMESH|CD_MASK_MDISPS : CD_MASK_DERIVEDMESH; + mask = use_mdisps ? CD_MASK_DERIVEDMESH | CD_MASK_MDISPS : CD_MASK_DERIVEDMESH; /* don't process shapekeys, we only feed them through the modifier stack as needed, * e.g. for applying modifiers or the like*/ @@ -1866,7 +1867,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis mv->flag = BM_vert_flag_to_mflag(eve); if (has_vert_bweight) - mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT)*255.0f); + mv->bweight = (unsigned char)(BM_elem_float_data_get(&bm->vdata, eve, CD_BWEIGHT) * 255.0f); if (add_orig) *index = i; @@ -1885,9 +1886,9 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis med->v2 = BM_elem_index_get(eed->v2); if (has_crease) - med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE)*255.0f); + med->crease = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_CREASE) * 255.0f); if (has_edge_bweight) - med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT)*255.0f); + med->bweight = (unsigned char)(BM_elem_float_data_get(&bm->edata, eed, CD_BWEIGHT) * 255.0f); med->flag = BM_edge_flag_to_mflag(eed); @@ -1916,7 +1917,7 @@ DerivedMesh *CDDM_from_BMEditMesh(BMEditMesh *em, Mesh *UNUSED(me), int use_mdis mf->mat_nr = efa->mat_nr; mf->flag = BM_face_flag_to_mflag(efa); - *index = add_orig ? BM_elem_index_get(efa) : *(int*)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX); + *index = add_orig ? BM_elem_index_get(efa) : *(int *)CustomData_bmesh_get(&bm->pdata, efa->head.data, CD_ORIGINDEX); *polyindex = BM_elem_index_get(efa); loops_to_customdata_corners(bm, &dm->faceData, i, l, numCol, numTex); @@ -1973,7 +1974,7 @@ static DerivedMesh *cddm_copy_ex(DerivedMesh *source, int faces_from_tessfaces) /* this initializes dm, and copies all non mvert/medge/mface layers */ DM_from_template(dm, source, DM_TYPE_CDDM, numVerts, numEdges, numTessFaces, - numLoops, numPolys); + numLoops, numPolys); dm->deformedOnly = source->deformedOnly; dm->dirty = source->dirty; @@ -2055,7 +2056,7 @@ DerivedMesh *CDDM_from_template(DerivedMesh *source, void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MVert *vert; int i; @@ -2069,7 +2070,7 @@ void CDDM_apply_vert_coords(DerivedMesh *dm, float (*vertCoords)[3]) void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3]) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MVert *vert; int i; @@ -2083,7 +2084,7 @@ void CDDM_apply_vert_normals(DerivedMesh *dm, short (*vertNormals)[3]) void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; float (*face_nors)[3] = NULL; if (dm->numVertData == 0) return; @@ -2113,16 +2114,16 @@ void CDDM_calc_normals_mapping_ex(DerivedMesh *dm, const short only_face_normals } - face_nors = MEM_mallocN(sizeof(float)*3*dm->numTessFaceData, "face_nors"); + face_nors = MEM_mallocN(sizeof(float) * 3 * dm->numTessFaceData, "face_nors"); /* calculate face normals */ - mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, - CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, - only_face_normals); + BKE_mesh_calc_normals_mapping_ex(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), + dm->numLoopData, dm->numPolyData, NULL, cddm->mface, dm->numTessFaceData, + CustomData_get_layer(&dm->faceData, CD_POLYINDEX), face_nors, + only_face_normals); CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_ASSIGN, - face_nors, dm->numTessFaceData); + face_nors, dm->numTessFaceData); } @@ -2137,7 +2138,7 @@ void CDDM_calc_normals_mapping(DerivedMesh *dm) /* bmesh note: this matches what we have in trunk */ void CDDM_calc_normals(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; float (*poly_nors)[3]; if (dm->numVertData == 0) return; @@ -2151,13 +2152,13 @@ void CDDM_calc_normals(DerivedMesh *dm) poly_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData); } - mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), - dm->numLoopData, dm->numPolyData, poly_nors); + BKE_mesh_calc_normals(cddm->mvert, dm->numVertData, CDDM_get_loops(dm), CDDM_get_polys(dm), + dm->numLoopData, dm->numPolyData, poly_nors); } void CDDM_calc_normals_tessface(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; float (*face_nors)[3]; if (dm->numVertData == 0) return; @@ -2171,8 +2172,8 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm) face_nors = CustomData_add_layer(&dm->faceData, CD_NORMAL, CD_CALLOC, NULL, dm->numTessFaceData); } - mesh_calc_normals_tessface(cddm->mvert, dm->numVertData, - cddm->mface, dm->numTessFaceData, face_nors); + BKE_mesh_calc_normals_tessface(cddm->mvert, dm->numVertData, + cddm->mface, dm->numTessFaceData, face_nors); } #if 1 @@ -2189,7 +2190,7 @@ void CDDM_calc_normals_tessface(DerivedMesh *dm) */ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; CDDerivedMesh *cddm2 = NULL; MVert *mv, *mvert = NULL; BLI_array_declare(mvert); @@ -2208,9 +2209,9 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) totloop = dm->numLoopData; totpoly = dm->numPolyData; - newv = MEM_callocN(sizeof(int)*dm->numVertData, "newv vtable CDDM_merge_verts"); - newe = MEM_callocN(sizeof(int)*dm->numEdgeData, "newv etable CDDM_merge_verts"); - newl = MEM_callocN(sizeof(int)*totloop, "newv ltable CDDM_merge_verts"); + newv = MEM_callocN(sizeof(int) * dm->numVertData, "newv vtable CDDM_merge_verts"); + newe = MEM_callocN(sizeof(int) * dm->numEdgeData, "newv etable CDDM_merge_verts"); + newl = MEM_callocN(sizeof(int) * totloop, "newv ltable CDDM_merge_verts"); /*fill newl with destination vertex indices*/ mv = cddm->mvert; @@ -2246,7 +2247,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) if (LIKELY(med->v1 != med->v2)) { const unsigned int v1 = (vtargetmap[med->v1] != -1) ? vtargetmap[med->v1] : med->v1; const unsigned int v2 = (vtargetmap[med->v2] != -1) ? vtargetmap[med->v2] : med->v2; - void **eh_p= BLI_edgehash_lookup_p(ehash, v1, v2); + void **eh_p = BLI_edgehash_lookup_p(ehash, v1, v2); if (eh_p) { newe[i] = GET_INT_FROM_POINTER(*eh_p); @@ -2274,8 +2275,8 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) for (j = 0; j < mp->totloop; j++, ml++) { med = cddm->medge + ml->e; if (LIKELY(med->v1 != med->v2)) { - newl[j+mp->loopstart] = BLI_array_count(mloop); - BLI_array_append(oldl, j+mp->loopstart); + newl[j + mp->loopstart] = BLI_array_count(mloop); + BLI_array_append(oldl, j + mp->loopstart); BLI_array_append(mloop, *ml); c++; } @@ -2293,7 +2294,7 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) } /*create new cddm*/ - cddm2 = (CDDerivedMesh*) CDDM_from_template((DerivedMesh*)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly)); + cddm2 = (CDDerivedMesh *) CDDM_from_template((DerivedMesh *)cddm, BLI_array_count(mvert), BLI_array_count(medge), 0, BLI_array_count(mloop), BLI_array_count(mpoly)); /*update edge indices and copy customdata*/ med = medge; @@ -2330,10 +2331,10 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) } /*copy over data. CustomData_add_layer can do this, need to look it up.*/ - memcpy(cddm2->mvert, mvert, sizeof(MVert)*BLI_array_count(mvert)); - memcpy(cddm2->medge, medge, sizeof(MEdge)*BLI_array_count(medge)); - memcpy(cddm2->mloop, mloop, sizeof(MLoop)*BLI_array_count(mloop)); - memcpy(cddm2->mpoly, mpoly, sizeof(MPoly)*BLI_array_count(mpoly)); + memcpy(cddm2->mvert, mvert, sizeof(MVert) * BLI_array_count(mvert)); + memcpy(cddm2->medge, medge, sizeof(MEdge) * BLI_array_count(medge)); + memcpy(cddm2->mloop, mloop, sizeof(MLoop) * BLI_array_count(mloop)); + memcpy(cddm2->mpoly, mpoly, sizeof(MPoly) * BLI_array_count(mpoly)); BLI_array_free(mvert); BLI_array_free(medge); BLI_array_free(mloop); BLI_array_free(mpoly); if (newv) @@ -2357,13 +2358,13 @@ DerivedMesh *CDDM_merge_verts(DerivedMesh *dm, const int *vtargetmap) dm->needsFree = 1; dm->release(dm); - return (DerivedMesh*)cddm2; + return (DerivedMesh *)cddm2; } #endif void CDDM_calc_edges_tessface(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; CustomData edgeData; EdgeHashIterator *ehi; MFace *mf = cddm->mface; @@ -2400,10 +2401,10 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm) med = CustomData_get_layer(&edgeData, CD_MEDGE); index = CustomData_get_layer(&edgeData, CD_ORIGINDEX); for (i = 0; !BLI_edgehashIterator_isDone(ehi); - BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { + BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); - med->flag = ME_EDGEDRAW|ME_EDGERENDER; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; *index = ORIGINDEX_NONE; } BLI_edgehashIterator_free(ehi); @@ -2421,7 +2422,7 @@ void CDDM_calc_edges_tessface(DerivedMesh *dm) /* warning, this uses existing edges but CDDM_calc_edges_tessface() doesn't */ void CDDM_calc_edges(DerivedMesh *dm) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; CustomData edgeData; EdgeHashIterator *ehi; MPoly *mp = cddm->mpoly; @@ -2437,7 +2438,7 @@ void CDDM_calc_edges(DerivedMesh *dm) med = cddm->medge; if (med) { for (i = 0; i < numEdges; i++, med++) { - BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i+1)); + BLI_edgehash_insert(eh, med->v1, med->v2, SET_INT_IN_POINTER(i + 1)); } } @@ -2463,12 +2464,12 @@ void CDDM_calc_edges(DerivedMesh *dm) med = CustomData_get_layer(&edgeData, CD_MEDGE); index = CustomData_get_layer(&edgeData, CD_ORIGINDEX); for (i = 0; !BLI_edgehashIterator_isDone(ehi); - BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { + BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) { BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2); j = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - med->flag = ME_EDGEDRAW|ME_EDGERENDER; - *index = j==0 ? ORIGINDEX_NONE : eindex[j-1]; + med->flag = ME_EDGEDRAW | ME_EDGERENDER; + *index = j == 0 ? ORIGINDEX_NONE : eindex[j - 1]; BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(i)); } @@ -2497,7 +2498,7 @@ void CDDM_calc_edges(DerivedMesh *dm) void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts) { if (numVerts < dm->numVertData) - CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData-numVerts); + CustomData_free_elem(&dm->vertData, numVerts, dm->numVertData - numVerts); dm->numVertData = numVerts; } @@ -2505,7 +2506,7 @@ void CDDM_lower_num_verts(DerivedMesh *dm, int numVerts) void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) { if (numEdges < dm->numEdgeData) - CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData-numEdges); + CustomData_free_elem(&dm->edgeData, numEdges, dm->numEdgeData - numEdges); dm->numEdgeData = numEdges; } @@ -2513,7 +2514,7 @@ void CDDM_lower_num_edges(DerivedMesh *dm, int numEdges) void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces) { if (numTessFaces < dm->numTessFaceData) - CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData-numTessFaces); + CustomData_free_elem(&dm->faceData, numTessFaces, dm->numTessFaceData - numTessFaces); dm->numTessFaceData = numTessFaces; } @@ -2521,7 +2522,7 @@ void CDDM_lower_num_tessfaces(DerivedMesh *dm, int numTessFaces) void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) { if (numPolys < dm->numPolyData) - CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData-numPolys); + CustomData_free_elem(&dm->polyData, numPolys, dm->numPolyData - numPolys); dm->numPolyData = numPolys; } @@ -2530,60 +2531,60 @@ void CDDM_lower_num_polys(DerivedMesh *dm, int numPolys) MVert *CDDM_get_vert(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mvert[index]; + return &((CDDerivedMesh *)dm)->mvert[index]; } MEdge *CDDM_get_edge(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->medge[index]; + return &((CDDerivedMesh *)dm)->medge[index]; } MFace *CDDM_get_tessface(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mface[index]; + return &((CDDerivedMesh *)dm)->mface[index]; } MLoop *CDDM_get_loop(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mloop[index]; + return &((CDDerivedMesh *)dm)->mloop[index]; } MPoly *CDDM_get_poly(DerivedMesh *dm, int index) { - return &((CDDerivedMesh*)dm)->mpoly[index]; + return &((CDDerivedMesh *)dm)->mpoly[index]; } /* array access functions */ MVert *CDDM_get_verts(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mvert; + return ((CDDerivedMesh *)dm)->mvert; } MEdge *CDDM_get_edges(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->medge; + return ((CDDerivedMesh *)dm)->medge; } MFace *CDDM_get_tessfaces(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mface; + return ((CDDerivedMesh *)dm)->mface; } MLoop *CDDM_get_loops(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mloop; + return ((CDDerivedMesh *)dm)->mloop; } MPoly *CDDM_get_polys(DerivedMesh *dm) { - return ((CDDerivedMesh*)dm)->mpoly; + return ((CDDerivedMesh *)dm)->mpoly; } void CDDM_tessfaces_to_faces(DerivedMesh *dm) { /*converts mfaces to mpolys/mloops*/ - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; MFace *mf; MEdge *me; EdgeHash *eh = BLI_edgehash_new(); @@ -2627,13 +2628,13 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) MPoly *mp; int l, *polyindex; - cddm->mloop = MEM_callocN(sizeof(MLoop)*totloop, "cddm->mloop in CDDM_tessfaces_to_faces"); - cddm->mpoly = MEM_callocN(sizeof(MPoly)*cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces"); + cddm->mloop = MEM_callocN(sizeof(MLoop) * totloop, "cddm->mloop in CDDM_tessfaces_to_faces"); + cddm->mpoly = MEM_callocN(sizeof(MPoly) * cddm->dm.numTessFaceData, "cddm->mpoly in CDDM_tessfaces_to_faces"); CustomData_add_layer(&cddm->dm.loopData, CD_MLOOP, CD_ASSIGN, cddm->mloop, totloop); CustomData_add_layer(&cddm->dm.polyData, CD_MPOLY, CD_ASSIGN, cddm->mpoly, cddm->dm.numPolyData); CustomData_merge(&cddm->dm.faceData, &cddm->dm.polyData, - CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData); + CD_MASK_ORIGINDEX, CD_DUPLICATE, cddm->dm.numTessFaceData); polyindex = CustomData_get_layer(&cddm->dm.faceData, CD_POLYINDEX); @@ -2656,12 +2657,12 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) ml++, l++; ml->v = mf->v3; - ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4?mf->v4:mf->v1)); + ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v3, mf->v4 ? mf->v4 : mf->v1)); ml++, l++; if (mf->v4) { ml->v = mf->v4; - ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1)); + ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v4, mf->v1)); ml++, l++; } @@ -2674,7 +2675,7 @@ void CDDM_tessfaces_to_faces(DerivedMesh *dm) void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->vertData, CD_MVERT)) CustomData_add_layer(&dm->vertData, CD_MVERT, CD_ASSIGN, mvert, dm->numVertData); @@ -2684,7 +2685,7 @@ void CDDM_set_mvert(DerivedMesh *dm, MVert *mvert) void CDDM_set_medge(DerivedMesh *dm, MEdge *medge) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->edgeData, CD_MEDGE)) CustomData_add_layer(&dm->edgeData, CD_MEDGE, CD_ASSIGN, medge, dm->numEdgeData); @@ -2694,7 +2695,7 @@ void CDDM_set_medge(DerivedMesh *dm, MEdge *medge) void CDDM_set_mface(DerivedMesh *dm, MFace *mface) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->faceData, CD_MFACE)) CustomData_add_layer(&dm->faceData, CD_MFACE, CD_ASSIGN, mface, dm->numTessFaceData); @@ -2704,7 +2705,7 @@ void CDDM_set_mface(DerivedMesh *dm, MFace *mface) void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->loopData, CD_MLOOP)) CustomData_add_layer(&dm->loopData, CD_MLOOP, CD_ASSIGN, mloop, dm->numLoopData); @@ -2714,7 +2715,7 @@ void CDDM_set_mloop(DerivedMesh *dm, MLoop *mloop) void CDDM_set_mpoly(DerivedMesh *dm, MPoly *mpoly) { - CDDerivedMesh *cddm = (CDDerivedMesh*)dm; + CDDerivedMesh *cddm = (CDDerivedMesh *)dm; if (!CustomData_has_layer(&dm->polyData, CD_MPOLY)) CustomData_add_layer(&dm->polyData, CD_MPOLY, CD_ASSIGN, mpoly, dm->numPolyData); diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index 2955e20c9e2..7ba117861bb 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -62,9 +62,9 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa int a; float clipminx, clipminy, clipmaxx, clipmaxy; - cumap= MEM_callocN(sizeof(CurveMapping), "new curvemap"); - cumap->flag= CUMA_DO_CLIP; - if (tot==4) cumap->cur= 3; /* rhms, hack for 'col' curve? */ + cumap = MEM_callocN(sizeof(CurveMapping), "new curvemap"); + cumap->flag = CUMA_DO_CLIP; + if (tot == 4) cumap->cur = 3; /* rhms, hack for 'col' curve? */ clipminx = MIN2(minx, maxx); clipminy = MIN2(miny, maxy); @@ -72,20 +72,20 @@ CurveMapping *curvemapping_add(int tot, float minx, float miny, float maxx, floa clipmaxy = MAX2(miny, maxy); BLI_init_rctf(&cumap->curr, clipminx, clipmaxx, clipminy, clipmaxy); - cumap->clipr= cumap->curr; + cumap->clipr = cumap->curr; - cumap->white[0]= cumap->white[1]= cumap->white[2]= 1.0f; - cumap->bwmul[0]= cumap->bwmul[1]= cumap->bwmul[2]= 1.0f; + cumap->white[0] = cumap->white[1] = cumap->white[2] = 1.0f; + cumap->bwmul[0] = cumap->bwmul[1] = cumap->bwmul[2] = 1.0f; - for (a=0; acm[a].flag= CUMA_EXTEND_EXTRAPOLATE; - cumap->cm[a].totpoint= 2; - cumap->cm[a].curve= MEM_callocN(2*sizeof(CurveMapPoint), "curve points"); - - cumap->cm[a].curve[0].x= minx; - cumap->cm[a].curve[0].y= miny; - cumap->cm[a].curve[1].x= maxx; - cumap->cm[a].curve[1].y= maxy; + for (a = 0; a < tot; a++) { + cumap->cm[a].flag = CUMA_EXTEND_EXTRAPOLATE; + cumap->cm[a].totpoint = 2; + cumap->cm[a].curve = MEM_callocN(2 * sizeof(CurveMapPoint), "curve points"); + + cumap->cm[a].curve[0].x = minx; + cumap->cm[a].curve[0].y = miny; + cumap->cm[a].curve[1].x = maxx; + cumap->cm[a].curve[1].y = maxy; } cumap->changed_timestamp = 0; @@ -98,7 +98,7 @@ void curvemapping_free(CurveMapping *cumap) int a; if (cumap) { - for (a=0; acm[a].curve) MEM_freeN(cumap->cm[a].curve); if (cumap->cm[a].table) MEM_freeN(cumap->cm[a].table); if (cumap->cm[a].premultable) MEM_freeN(cumap->cm[a].premultable); @@ -112,14 +112,14 @@ CurveMapping *curvemapping_copy(CurveMapping *cumap) int a; if (cumap) { - CurveMapping *cumapn= MEM_dupallocN(cumap); - for (a=0; acm[a].curve) - cumapn->cm[a].curve= MEM_dupallocN(cumap->cm[a].curve); + cumapn->cm[a].curve = MEM_dupallocN(cumap->cm[a].curve); if (cumap->cm[a].table) - cumapn->cm[a].table= MEM_dupallocN(cumap->cm[a].table); + cumapn->cm[a].table = MEM_dupallocN(cumap->cm[a].table); if (cumap->cm[a].premultable) - cumapn->cm[a].premultable= MEM_dupallocN(cumap->cm[a].premultable); + cumapn->cm[a].premultable = MEM_dupallocN(cumap->cm[a].premultable); } return cumapn; } @@ -135,11 +135,11 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con if (black) copy_v3_v3(cumap->black, black); - for (a=0; a<3; a++) { - if (cumap->white[a]==cumap->black[a]) - cumap->bwmul[a]= 0.0f; + for (a = 0; a < 3; a++) { + if (cumap->white[a] == cumap->black[a]) + cumap->bwmul[a] = 0.0f; else - cumap->bwmul[a]= 1.0f/(cumap->white[a] - cumap->black[a]); + cumap->bwmul[a] = 1.0f / (cumap->white[a] - cumap->black[a]); } } @@ -149,52 +149,52 @@ void curvemapping_set_black_white(CurveMapping *cumap, const float black[3], con /* removes with flag set */ void curvemap_remove(CurveMap *cuma, int flag) { - CurveMapPoint *cmp= MEM_mallocN((cuma->totpoint)*sizeof(CurveMapPoint), "curve points"); - int a, b, removed=0; + CurveMapPoint *cmp = MEM_mallocN((cuma->totpoint) * sizeof(CurveMapPoint), "curve points"); + int a, b, removed = 0; /* well, lets keep the two outer points! */ - cmp[0]= cuma->curve[0]; - for (a=1, b=1; atotpoint-1; a++) { + cmp[0] = cuma->curve[0]; + for (a = 1, b = 1; a < cuma->totpoint - 1; a++) { if (!(cuma->curve[a].flag & flag)) { - cmp[b]= cuma->curve[a]; + cmp[b] = cuma->curve[a]; b++; } else removed++; } - cmp[b]= cuma->curve[a]; + cmp[b] = cuma->curve[a]; MEM_freeN(cuma->curve); - cuma->curve= cmp; + cuma->curve = cmp; cuma->totpoint -= removed; } void curvemap_insert(CurveMap *cuma, float x, float y) { - CurveMapPoint *cmp= MEM_callocN((cuma->totpoint+1)*sizeof(CurveMapPoint), "curve points"); - int a, b, foundloc= 0; + CurveMapPoint *cmp = MEM_callocN((cuma->totpoint + 1) * sizeof(CurveMapPoint), "curve points"); + int a, b, foundloc = 0; /* insert fragments of the old one and the new point to the new curve */ cuma->totpoint++; - for (a=0, b=0; atotpoint; a++) { + for (a = 0, b = 0; a < cuma->totpoint; a++) { if ((x < cuma->curve[a].x) && !foundloc) { - cmp[a].x= x; - cmp[a].y= y; - cmp[a].flag= CUMA_SELECT; - foundloc= 1; + cmp[a].x = x; + cmp[a].y = y; + cmp[a].flag = CUMA_SELECT; + foundloc = 1; } else { - cmp[a].x= cuma->curve[b].x; - cmp[a].y= cuma->curve[b].y; - cmp[a].flag= cuma->curve[b].flag; + cmp[a].x = cuma->curve[b].x; + cmp[a].y = cuma->curve[b].y; + cmp[a].flag = cuma->curve[b].flag; cmp[a].flag &= ~CUMA_SELECT; /* make sure old points don't remain selected */ - cmp[a].shorty= cuma->curve[b].shorty; + cmp[a].shorty = cuma->curve[b].shorty; b++; } } /* free old curve and replace it with new one */ MEM_freeN(cuma->curve); - cuma->curve= cmp; + cuma->curve = cmp; } void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) @@ -203,91 +203,91 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) MEM_freeN(cuma->curve); switch (preset) { - case CURVE_PRESET_LINE: cuma->totpoint= 2; break; - case CURVE_PRESET_SHARP: cuma->totpoint= 4; break; - case CURVE_PRESET_SMOOTH: cuma->totpoint= 4; break; - case CURVE_PRESET_MAX: cuma->totpoint= 2; break; - case CURVE_PRESET_MID9: cuma->totpoint= 9; break; - case CURVE_PRESET_ROUND: cuma->totpoint= 4; break; - case CURVE_PRESET_ROOT: cuma->totpoint= 4; break; + case CURVE_PRESET_LINE: cuma->totpoint = 2; break; + case CURVE_PRESET_SHARP: cuma->totpoint = 4; break; + case CURVE_PRESET_SMOOTH: cuma->totpoint = 4; break; + case CURVE_PRESET_MAX: cuma->totpoint = 2; break; + case CURVE_PRESET_MID9: cuma->totpoint = 9; break; + case CURVE_PRESET_ROUND: cuma->totpoint = 4; break; + case CURVE_PRESET_ROOT: cuma->totpoint = 4; break; } - cuma->curve= MEM_callocN(cuma->totpoint*sizeof(CurveMapPoint), "curve points"); + cuma->curve = MEM_callocN(cuma->totpoint * sizeof(CurveMapPoint), "curve points"); switch (preset) { case CURVE_PRESET_LINE: - cuma->curve[0].x= clipr->xmin; - cuma->curve[0].y= clipr->ymax; - cuma->curve[0].flag= 0; - cuma->curve[1].x= clipr->xmax; - cuma->curve[1].y= clipr->ymin; - cuma->curve[1].flag= 0; + cuma->curve[0].x = clipr->xmin; + cuma->curve[0].y = clipr->ymax; + cuma->curve[0].flag = 0; + cuma->curve[1].x = clipr->xmax; + cuma->curve[1].y = clipr->ymin; + cuma->curve[1].flag = 0; break; case CURVE_PRESET_SHARP: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.50; - cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.04; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.25; + cuma->curve[1].y = 0.50; + cuma->curve[2].x = 0.75; + cuma->curve[2].y = 0.04; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; case CURVE_PRESET_SMOOTH: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.94; - cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.06; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.25; + cuma->curve[1].y = 0.94; + cuma->curve[2].x = 0.75; + cuma->curve[2].y = 0.06; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; case CURVE_PRESET_MAX: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 1; - cuma->curve[1].y= 1; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 1; + cuma->curve[1].y = 1; break; case CURVE_PRESET_MID9: - { - int i; - for (i = 0; i < cuma->totpoint; i++) { - cuma->curve[i].x = i / ((float)cuma->totpoint - 1); - cuma->curve[i].y = 0.5; - } + { + int i; + for (i = 0; i < cuma->totpoint; i++) { + cuma->curve[i].x = i / ((float)cuma->totpoint - 1); + cuma->curve[i].y = 0.5; } - break; + } + break; case CURVE_PRESET_ROUND: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.5; - cuma->curve[1].y= 0.90; - cuma->curve[2].x= 0.86; - cuma->curve[2].y= 0.5; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.5; + cuma->curve[1].y = 0.90; + cuma->curve[2].x = 0.86; + cuma->curve[2].y = 0.5; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; case CURVE_PRESET_ROOT: - cuma->curve[0].x= 0; - cuma->curve[0].y= 1; - cuma->curve[1].x= 0.25; - cuma->curve[1].y= 0.95; - cuma->curve[2].x= 0.75; - cuma->curve[2].y= 0.44; - cuma->curve[3].x= 1; - cuma->curve[3].y= 0; + cuma->curve[0].x = 0; + cuma->curve[0].y = 1; + cuma->curve[1].x = 0.25; + cuma->curve[1].y = 0.95; + cuma->curve[2].x = 0.75; + cuma->curve[2].y = 0.44; + cuma->curve[3].x = 1; + cuma->curve[3].y = 0; break; } /* mirror curve in x direction to have positive slope * rather than default negative slope */ if (slope == CURVEMAP_SLOPE_POSITIVE) { - int i, last=cuma->totpoint-1; - CurveMapPoint *newpoints= MEM_dupallocN(cuma->curve); + int i, last = cuma->totpoint - 1; + CurveMapPoint *newpoints = MEM_dupallocN(cuma->curve); - for (i=0; itotpoint; i++) { - newpoints[i].y = cuma->curve[last-i].y; + for (i = 0; i < cuma->totpoint; i++) { + newpoints[i].y = cuma->curve[last - i].y; } MEM_freeN(cuma->curve); @@ -296,7 +296,7 @@ void curvemap_reset(CurveMap *cuma, rctf *clipr, int preset, int slope) if (cuma->table) { MEM_freeN(cuma->table); - cuma->table= NULL; + cuma->table = NULL; } } @@ -305,7 +305,7 @@ void curvemap_sethandle(CurveMap *cuma, int type) { int a; - for (a=0; atotpoint; a++) { + for (a = 0; a < cuma->totpoint; a++) { if (cuma->curve[a].flag & CUMA_SELECT) { if (type) cuma->curve[a].flag |= CUMA_VECTOR; else cuma->curve[a].flag &= ~CUMA_VECTOR; @@ -322,65 +322,65 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex float len, len_a, len_b; float dvec_a[2], dvec_b[2]; - if (bezt->h1==0 && bezt->h2==0) { + if (bezt->h1 == 0 && bezt->h2 == 0) { return; } - p2= bezt->vec[1]; + p2 = bezt->vec[1]; - if (prev==NULL) { - p3= next->vec[1]; - pt[0]= 2.0f*p2[0] - p3[0]; - pt[1]= 2.0f*p2[1] - p3[1]; - p1= pt; + if (prev == NULL) { + p3 = next->vec[1]; + pt[0] = 2.0f * p2[0] - p3[0]; + pt[1] = 2.0f * p2[1] - p3[1]; + p1 = pt; } else { - p1= prev->vec[1]; + p1 = prev->vec[1]; } - if (next==NULL) { - p1= prev->vec[1]; - pt[0]= 2.0f*p2[0] - p1[0]; - pt[1]= 2.0f*p2[1] - p1[1]; - p3= pt; + if (next == NULL) { + p1 = prev->vec[1]; + pt[0] = 2.0f * p2[0] - p1[0]; + pt[1] = 2.0f * p2[1] - p1[1]; + p3 = pt; } else { - p3= next->vec[1]; + p3 = next->vec[1]; } sub_v2_v2v2(dvec_a, p2, p1); sub_v2_v2v2(dvec_b, p3, p2); - len_a= len_v2(dvec_a); - len_b= len_v2(dvec_b); + len_a = len_v2(dvec_a); + len_b = len_v2(dvec_b); - if (len_a==0.0f) len_a=1.0f; - if (len_b==0.0f) len_b=1.0f; + if (len_a == 0.0f) len_a = 1.0f; + if (len_b == 0.0f) len_b = 1.0f; - if (bezt->h1==HD_AUTO || bezt->h2==HD_AUTO) { /* auto */ + if (bezt->h1 == HD_AUTO || bezt->h2 == HD_AUTO) { /* auto */ float tvec[2]; - tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a; - tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a; + tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a; + tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a; - len= len_v2(tvec) * 2.5614f; - if (len!=0.0f) { + len = len_v2(tvec) * 2.5614f; + if (len != 0.0f) { - if (bezt->h1==HD_AUTO) { - len_a/=len; - madd_v2_v2v2fl(p2-3, p2, tvec, -len_a); + if (bezt->h1 == HD_AUTO) { + len_a /= len; + madd_v2_v2v2fl(p2 - 3, p2, tvec, -len_a); } - if (bezt->h2==HD_AUTO) { - len_b/=len; - madd_v2_v2v2fl(p2+3, p2, tvec, len_b); + if (bezt->h2 == HD_AUTO) { + len_b /= len; + madd_v2_v2v2fl(p2 + 3, p2, tvec, len_b); } } } - if (bezt->h1==HD_VECT) { /* vector */ - madd_v2_v2v2fl(p2-3, p2, dvec_a, -1.0f/3.0f); + if (bezt->h1 == HD_VECT) { /* vector */ + madd_v2_v2v2fl(p2 - 3, p2, dvec_a, -1.0f / 3.0f); } - if (bezt->h2==HD_VECT) { - madd_v2_v2v2fl(p2+3, p2, dvec_b, 1.0f/3.0f); + if (bezt->h2 == HD_VECT) { + madd_v2_v2v2fl(p2 + 3, p2, dvec_b, 1.0f / 3.0f); } } @@ -389,27 +389,27 @@ static void calchandle_curvemap(BezTriple *bezt, BezTriple *prev, BezTriple *nex static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], const float last[2]) { if (x <= first[0]) { - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) { + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { /* no extrapolate */ return first[1]; } else { - if (cuma->ext_in[0]==0.0f) - return first[1] + cuma->ext_in[1]*10000.0f; + if (cuma->ext_in[0] == 0.0f) + return first[1] + cuma->ext_in[1] * 10000.0f; else - return first[1] + cuma->ext_in[1]*(x - first[0])/cuma->ext_in[0]; + return first[1] + cuma->ext_in[1] * (x - first[0]) / cuma->ext_in[0]; } } else if (x >= last[0]) { - if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE)==0) { + if ((cuma->flag & CUMA_EXTEND_EXTRAPOLATE) == 0) { /* no extrapolate */ return last[1]; } else { - if (cuma->ext_out[0]==0.0f) - return last[1] - cuma->ext_out[1]*10000.0f; + if (cuma->ext_out[0] == 0.0f) + return last[1] - cuma->ext_out[1] * 10000.0f; else - return last[1] + cuma->ext_out[1]*(x - last[0])/cuma->ext_out[0]; + return last[1] + cuma->ext_out[1] * (x - last[0]) / cuma->ext_out[0]; } } return 0.0f; @@ -418,74 +418,74 @@ static float curvemap_calc_extend(CurveMap *cuma, float x, const float first[2], /* only creates a table for a single channel in CurveMapping */ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) { - CurveMapPoint *cmp= cuma->curve; + CurveMapPoint *cmp = cuma->curve; BezTriple *bezt; float *fp, *allpoints, *lastpoint, curf, range; int a, totpoint; - if (cuma->curve==NULL) return; + if (cuma->curve == NULL) return; /* default rect also is table range */ - cuma->mintable= clipr->xmin; - cuma->maxtable= clipr->xmax; + cuma->mintable = clipr->xmin; + cuma->maxtable = clipr->xmax; /* hrmf... we now rely on blender ipo beziers, these are more advanced */ - bezt= MEM_callocN(cuma->totpoint*sizeof(BezTriple), "beztarr"); + bezt = MEM_callocN(cuma->totpoint * sizeof(BezTriple), "beztarr"); - for (a=0; atotpoint; a++) { - cuma->mintable= MIN2(cuma->mintable, cmp[a].x); - cuma->maxtable= MAX2(cuma->maxtable, cmp[a].x); - bezt[a].vec[1][0]= cmp[a].x; - bezt[a].vec[1][1]= cmp[a].y; + for (a = 0; a < cuma->totpoint; a++) { + cuma->mintable = MIN2(cuma->mintable, cmp[a].x); + cuma->maxtable = MAX2(cuma->maxtable, cmp[a].x); + bezt[a].vec[1][0] = cmp[a].x; + bezt[a].vec[1][1] = cmp[a].y; if (cmp[a].flag & CUMA_VECTOR) - bezt[a].h1= bezt[a].h2= HD_VECT; + bezt[a].h1 = bezt[a].h2 = HD_VECT; else - bezt[a].h1= bezt[a].h2= HD_AUTO; + bezt[a].h1 = bezt[a].h2 = HD_AUTO; } - for (a=0; atotpoint; a++) { - if (a==0) - calchandle_curvemap(bezt, NULL, bezt+1, 0); - else if (a==cuma->totpoint-1) - calchandle_curvemap(bezt+a, bezt+a-1, NULL, 0); + for (a = 0; a < cuma->totpoint; a++) { + if (a == 0) + calchandle_curvemap(bezt, NULL, bezt + 1, 0); + else if (a == cuma->totpoint - 1) + calchandle_curvemap(bezt + a, bezt + a - 1, NULL, 0); else - calchandle_curvemap(bezt+a, bezt+a-1, bezt+a+1, 0); + calchandle_curvemap(bezt + a, bezt + a - 1, bezt + a + 1, 0); } /* first and last handle need correction, instead of pointing to center of next/prev, * we let it point to the closest handle */ - if (cuma->totpoint>2) { + if (cuma->totpoint > 2) { float hlen, nlen, vec[3]; - if (bezt[0].h2==HD_AUTO) { + if (bezt[0].h2 == HD_AUTO) { - hlen= len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ + hlen = len_v3v3(bezt[0].vec[1], bezt[0].vec[2]); /* original handle length */ /* clip handle point */ copy_v3_v3(vec, bezt[1].vec[0]); if (vec[0] < bezt[0].vec[1][0]) - vec[0]= bezt[0].vec[1][0]; + vec[0] = bezt[0].vec[1][0]; sub_v3_v3(vec, bezt[0].vec[1]); - nlen= len_v3(vec); - if (nlen>FLT_EPSILON) { - mul_v3_fl(vec, hlen/nlen); + nlen = len_v3(vec); + if (nlen > FLT_EPSILON) { + mul_v3_fl(vec, hlen / nlen); add_v3_v3v3(bezt[0].vec[2], vec, bezt[0].vec[1]); sub_v3_v3v3(bezt[0].vec[0], bezt[0].vec[1], vec); } } - a= cuma->totpoint-1; - if (bezt[a].h2==HD_AUTO) { + a = cuma->totpoint - 1; + if (bezt[a].h2 == HD_AUTO) { - hlen= len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ + hlen = len_v3v3(bezt[a].vec[1], bezt[a].vec[0]); /* original handle length */ /* clip handle point */ - copy_v3_v3(vec, bezt[a-1].vec[2]); + copy_v3_v3(vec, bezt[a - 1].vec[2]); if (vec[0] > bezt[a].vec[1][0]) - vec[0]= bezt[a].vec[1][0]; + vec[0] = bezt[a].vec[1][0]; sub_v3_v3(vec, bezt[a].vec[1]); - nlen= len_v3(vec); - if (nlen>FLT_EPSILON) { - mul_v3_fl(vec, hlen/nlen); + nlen = len_v3(vec); + if (nlen > FLT_EPSILON) { + mul_v3_fl(vec, hlen / nlen); add_v3_v3v3(bezt[a].vec[0], vec, bezt[a].vec[1]); sub_v3_v3v3(bezt[a].vec[2], bezt[a].vec[1], vec); } @@ -494,63 +494,63 @@ static void curvemap_make_table(CurveMap *cuma, rctf *clipr) /* make the bezier curve */ if (cuma->table) MEM_freeN(cuma->table); - totpoint= (cuma->totpoint-1)*CM_RESOL; - fp= allpoints= MEM_callocN(totpoint*2*sizeof(float), "table"); + totpoint = (cuma->totpoint - 1) * CM_RESOL; + fp = allpoints = MEM_callocN(totpoint * 2 * sizeof(float), "table"); - for (a=0; atotpoint-1; a++, fp += 2*CM_RESOL) { - correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a+1].vec[0], bezt[a+1].vec[1]); - BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a+1].vec[0][0], bezt[a+1].vec[1][0], fp, CM_RESOL-1, 2*sizeof(float)); - BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a+1].vec[0][1], bezt[a+1].vec[1][1], fp+1, CM_RESOL-1, 2*sizeof(float)); + for (a = 0; a < cuma->totpoint - 1; a++, fp += 2 * CM_RESOL) { + correct_bezpart(bezt[a].vec[1], bezt[a].vec[2], bezt[a + 1].vec[0], bezt[a + 1].vec[1]); + BKE_curve_forward_diff_bezier(bezt[a].vec[1][0], bezt[a].vec[2][0], bezt[a + 1].vec[0][0], bezt[a + 1].vec[1][0], fp, CM_RESOL - 1, 2 * sizeof(float)); + BKE_curve_forward_diff_bezier(bezt[a].vec[1][1], bezt[a].vec[2][1], bezt[a + 1].vec[0][1], bezt[a + 1].vec[1][1], fp + 1, CM_RESOL - 1, 2 * sizeof(float)); } /* store first and last handle for extrapolation, unit length */ - cuma->ext_in[0]= bezt[0].vec[0][0] - bezt[0].vec[1][0]; - cuma->ext_in[1]= bezt[0].vec[0][1] - bezt[0].vec[1][1]; - range= sqrt(cuma->ext_in[0]*cuma->ext_in[0] + cuma->ext_in[1]*cuma->ext_in[1]); - cuma->ext_in[0]/= range; - cuma->ext_in[1]/= range; - - a= cuma->totpoint-1; - cuma->ext_out[0]= bezt[a].vec[1][0] - bezt[a].vec[2][0]; - cuma->ext_out[1]= bezt[a].vec[1][1] - bezt[a].vec[2][1]; - range= sqrt(cuma->ext_out[0]*cuma->ext_out[0] + cuma->ext_out[1]*cuma->ext_out[1]); - cuma->ext_out[0]/= range; - cuma->ext_out[1]/= range; + cuma->ext_in[0] = bezt[0].vec[0][0] - bezt[0].vec[1][0]; + cuma->ext_in[1] = bezt[0].vec[0][1] - bezt[0].vec[1][1]; + range = sqrt(cuma->ext_in[0] * cuma->ext_in[0] + cuma->ext_in[1] * cuma->ext_in[1]); + cuma->ext_in[0] /= range; + cuma->ext_in[1] /= range; + + a = cuma->totpoint - 1; + cuma->ext_out[0] = bezt[a].vec[1][0] - bezt[a].vec[2][0]; + cuma->ext_out[1] = bezt[a].vec[1][1] - bezt[a].vec[2][1]; + range = sqrt(cuma->ext_out[0] * cuma->ext_out[0] + cuma->ext_out[1] * cuma->ext_out[1]); + cuma->ext_out[0] /= range; + cuma->ext_out[1] /= range; /* cleanup */ MEM_freeN(bezt); - range= CM_TABLEDIV*(cuma->maxtable - cuma->mintable); - cuma->range= 1.0f/range; + range = CM_TABLEDIV * (cuma->maxtable - cuma->mintable); + cuma->range = 1.0f / range; /* now make a table with CM_TABLE equal x distances */ - fp= allpoints; - lastpoint= allpoints + 2*(totpoint-1); - cmp= MEM_callocN((CM_TABLE+1)*sizeof(CurveMapPoint), "dist table"); - - for (a=0; a<=CM_TABLE; a++) { - curf= cuma->mintable + range*(float)a; - cmp[a].x= curf; + fp = allpoints; + lastpoint = allpoints + 2 * (totpoint - 1); + cmp = MEM_callocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "dist table"); + + for (a = 0; a <= CM_TABLE; a++) { + curf = cuma->mintable + range * (float)a; + cmp[a].x = curf; /* get the first x coordinate larger than curf */ - while (curf >= fp[0] && fp!=lastpoint) { - fp+=2; + while (curf >= fp[0] && fp != lastpoint) { + fp += 2; } - if (fp==allpoints || (curf >= fp[0] && fp==lastpoint)) - cmp[a].y= curvemap_calc_extend(cuma, curf, allpoints, lastpoint); + if (fp == allpoints || (curf >= fp[0] && fp == lastpoint)) + cmp[a].y = curvemap_calc_extend(cuma, curf, allpoints, lastpoint); else { - float fac1= fp[0] - fp[-2]; - float fac2= fp[0] - curf; + float fac1 = fp[0] - fp[-2]; + float fac2 = fp[0] - curf; if (fac1 > FLT_EPSILON) - fac1= fac2/fac1; + fac1 = fac2 / fac1; else - fac1= 0.0f; - cmp[a].y= fac1*fp[-1] + (1.0f-fac1)*fp[1]; + fac1 = 0.0f; + cmp[a].y = fac1 * fp[-1] + (1.0f - fac1) * fp[1]; } } MEM_freeN(allpoints); - cuma->table= cmp; + cuma->table = cmp; } /* call when you do images etc, needs restore too. also verifies tables */ @@ -561,34 +561,34 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore) if (restore) { if (cumap->flag & CUMA_PREMULLED) { - for (a=0; a<3; a++) { + for (a = 0; a < 3; a++) { MEM_freeN(cumap->cm[a].table); - cumap->cm[a].table= cumap->cm[a].premultable; - cumap->cm[a].premultable= NULL; + cumap->cm[a].table = cumap->cm[a].premultable; + cumap->cm[a].premultable = NULL; } cumap->flag &= ~CUMA_PREMULLED; } } else { - if ((cumap->flag & CUMA_PREMULLED)==0) { + if ((cumap->flag & CUMA_PREMULLED) == 0) { /* verify and copy */ - for (a=0; a<3; a++) { - if (cumap->cm[a].table==NULL) - curvemap_make_table(cumap->cm+a, &cumap->clipr); - cumap->cm[a].premultable= cumap->cm[a].table; - cumap->cm[a].table= MEM_mallocN((CM_TABLE+1)*sizeof(CurveMapPoint), "premul table"); - memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE+1)*sizeof(CurveMapPoint)); + for (a = 0; a < 3; a++) { + if (cumap->cm[a].table == NULL) + curvemap_make_table(cumap->cm + a, &cumap->clipr); + cumap->cm[a].premultable = cumap->cm[a].table; + cumap->cm[a].table = MEM_mallocN((CM_TABLE + 1) * sizeof(CurveMapPoint), "premul table"); + memcpy(cumap->cm[a].table, cumap->cm[a].premultable, (CM_TABLE + 1) * sizeof(CurveMapPoint)); } - if (cumap->cm[3].table==NULL) - curvemap_make_table(cumap->cm+3, &cumap->clipr); + if (cumap->cm[3].table == NULL) + curvemap_make_table(cumap->cm + 3, &cumap->clipr); /* premul */ - for (a=0; a<3; a++) { + for (a = 0; a < 3; a++) { int b; - for (b=0; b<=CM_TABLE; b++) { - cumap->cm[a].table[b].y= curvemap_evaluateF(cumap->cm+3, cumap->cm[a].table[b].y); + for (b = 0; b <= CM_TABLE; b++) { + cumap->cm[a].table[b].y = curvemap_evaluateF(cumap->cm + 3, cumap->cm[a].table[b].y); } } @@ -599,10 +599,10 @@ void curvemapping_premultiply(CurveMapping *cumap, int restore) static int sort_curvepoints(const void *a1, const void *a2) { - const struct CurveMapPoint *x1=a1, *x2=a2; + const struct CurveMapPoint *x1 = a1, *x2 = a2; - if ( x1->x > x2->x ) return 1; - else if ( x1->x < x2->x) return -1; + if (x1->x > x2->x) return 1; + else if (x1->x < x2->x) return -1; return 0; } @@ -611,30 +611,30 @@ static int sort_curvepoints(const void *a1, const void *a2) /* note; only does current curvemap! */ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) { - CurveMap *cuma= cumap->cm+cumap->cur; - CurveMapPoint *cmp= cuma->curve; - rctf *clipr= &cumap->clipr; - float thresh= 0.01f*(clipr->xmax - clipr->xmin); - float dx= 0.0f, dy= 0.0f; + CurveMap *cuma = cumap->cm + cumap->cur; + CurveMapPoint *cmp = cuma->curve; + rctf *clipr = &cumap->clipr; + float thresh = 0.01f * (clipr->xmax - clipr->xmin); + float dx = 0.0f, dy = 0.0f; int a; cumap->changed_timestamp++; /* clamp with clip */ if (cumap->flag & CUMA_DO_CLIP) { - for (a=0; atotpoint; a++) { + for (a = 0; a < cuma->totpoint; a++) { if (cmp[a].flag & CUMA_SELECT) { if (cmp[a].x < clipr->xmin) - dx= MIN2(dx, cmp[a].x - clipr->xmin); + dx = MIN2(dx, cmp[a].x - clipr->xmin); else if (cmp[a].x > clipr->xmax) - dx= MAX2(dx, cmp[a].x - clipr->xmax); + dx = MAX2(dx, cmp[a].x - clipr->xmax); if (cmp[a].y < clipr->ymin) - dy= MIN2(dy, cmp[a].y - clipr->ymin); + dy = MIN2(dy, cmp[a].y - clipr->ymin); else if (cmp[a].y > clipr->ymax) - dy= MAX2(dy, cmp[a].y - clipr->ymax); + dy = MAX2(dy, cmp[a].y - clipr->ymax); } } - for (a=0; atotpoint; a++) { + for (a = 0; a < cuma->totpoint; a++) { if (cmp[a].flag & CUMA_SELECT) { cmp[a].x -= dx; cmp[a].y -= dy; @@ -646,25 +646,25 @@ void curvemapping_changed(CurveMapping *cumap, int rem_doubles) qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints); /* remove doubles, threshold set on 1% of default range */ - if (rem_doubles && cuma->totpoint>2) { - for (a=0; atotpoint-1; a++) { - dx= cmp[a].x - cmp[a+1].x; - dy= cmp[a].y - cmp[a+1].y; - if ( sqrtf(dx*dx + dy*dy) < thresh ) { - if (a==0) { - cmp[a+1].flag|= 2; - if (cmp[a+1].flag & CUMA_SELECT) + if (rem_doubles && cuma->totpoint > 2) { + for (a = 0; a < cuma->totpoint - 1; a++) { + dx = cmp[a].x - cmp[a + 1].x; + dy = cmp[a].y - cmp[a + 1].y; + if (sqrtf(dx * dx + dy * dy) < thresh) { + if (a == 0) { + cmp[a + 1].flag |= 2; + if (cmp[a + 1].flag & CUMA_SELECT) cmp[a].flag |= CUMA_SELECT; } else { - cmp[a].flag|= 2; + cmp[a].flag |= 2; if (cmp[a].flag & CUMA_SELECT) - cmp[a+1].flag |= CUMA_SELECT; + cmp[a + 1].flag |= CUMA_SELECT; } - break; /* we assume 1 deletion per edit is ok */ + break; /* we assume 1 deletion per edit is ok */ } } - if (a != cuma->totpoint-1) + if (a != cuma->totpoint - 1) curvemap_remove(cuma, 2); } curvemap_make_table(cuma, clipr); @@ -677,31 +677,31 @@ float curvemap_evaluateF(CurveMap *cuma, float value) int i; /* index in table */ - fi= (value-cuma->mintable)*cuma->range; - i= (int)fi; + fi = (value - cuma->mintable) * cuma->range; + i = (int)fi; /* fi is table float index and should check against table range i.e. [0.0 CM_TABLE] */ - if (fi<0.0f || fi>CM_TABLE) + if (fi < 0.0f || fi > CM_TABLE) return curvemap_calc_extend(cuma, value, &cuma->table[0].x, &cuma->table[CM_TABLE].x); else { - if (i<0) return cuma->table[0].y; - if (i>=CM_TABLE) return cuma->table[CM_TABLE].y; + if (i < 0) return cuma->table[0].y; + if (i >= CM_TABLE) return cuma->table[CM_TABLE].y; - fi= fi-(float)i; - return (1.0f-fi)*cuma->table[i].y + (fi)*cuma->table[i+1].y; + fi = fi - (float)i; + return (1.0f - fi) * cuma->table[i].y + (fi) * cuma->table[i + 1].y; } } /* works with curve 'cur' */ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) { - CurveMap *cuma= cumap->cm+cur; + CurveMap *cuma = cumap->cm + cur; /* allocate or bail out */ - if (cuma->table==NULL) { + if (cuma->table == NULL) { curvemap_make_table(cuma, &cumap->clipr); - if (cuma->table==NULL) - return 1.0f-value; + if (cuma->table == NULL) + return 1.0f - value; } return curvemap_evaluateF(cuma, value); } @@ -709,17 +709,17 @@ float curvemapping_evaluateF(CurveMapping *cumap, int cur, float value) /* vector case */ void curvemapping_evaluate3F(CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0]= curvemapping_evaluateF(cumap, 0, vecin[0]); - vecout[1]= curvemapping_evaluateF(cumap, 1, vecin[1]); - vecout[2]= curvemapping_evaluateF(cumap, 2, vecin[2]); + vecout[0] = curvemapping_evaluateF(cumap, 0, vecin[0]); + vecout[1] = curvemapping_evaluateF(cumap, 1, vecin[1]); + vecout[2] = curvemapping_evaluateF(cumap, 2, vecin[2]); } /* RGB case, no black/white points, no premult */ void curvemapping_evaluateRGBF(CurveMapping *cumap, float vecout[3], const float vecin[3]) { - vecout[0]= curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0])); - vecout[1]= curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1])); - vecout[2]= curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2])); + vecout[0] = curvemapping_evaluateF(cumap, 0, curvemapping_evaluateF(cumap, 3, vecin[0])); + vecout[1] = curvemapping_evaluateF(cumap, 1, curvemapping_evaluateF(cumap, 3, vecin[1])); + vecout[2] = curvemapping_evaluateF(cumap, 2, curvemapping_evaluateF(cumap, 3, vecin[2])); } @@ -728,14 +728,14 @@ void curvemapping_evaluate_premulRGBF(CurveMapping *cumap, float vecout[3], cons { float fac; - fac= (vecin[0] - cumap->black[0])*cumap->bwmul[0]; - vecout[0]= curvemap_evaluateF(cumap->cm, fac); + fac = (vecin[0] - cumap->black[0]) * cumap->bwmul[0]; + vecout[0] = curvemap_evaluateF(cumap->cm, fac); - fac= (vecin[1] - cumap->black[1])*cumap->bwmul[1]; - vecout[1]= curvemap_evaluateF(cumap->cm+1, fac); + fac = (vecin[1] - cumap->black[1]) * cumap->bwmul[1]; + vecout[1] = curvemap_evaluateF(cumap->cm + 1, fac); - fac= (vecin[2] - cumap->black[2])*cumap->bwmul[2]; - vecout[2]= curvemap_evaluateF(cumap->cm+2, fac); + fac = (vecin[2] - cumap->black[2]) * cumap->bwmul[2]; + vecout[2] = curvemap_evaluateF(cumap->cm + 2, fac); } @@ -746,14 +746,14 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) int pixel; float *pix_in; float col[3]; - int stride= 4; + int stride = 4; float *pix_out; - if (ibuf==NULL) + if (ibuf == NULL) return; - if (ibuf->rect_float==NULL) + if (ibuf->rect_float == NULL) IMB_float_from_rect(ibuf); - else if (ibuf->rect==NULL) + else if (ibuf->rect == NULL) imb_addrectImBuf(ibuf); if (!ibuf->rect || !ibuf->rect_float) @@ -765,27 +765,27 @@ void curvemapping_do_ibuf(CurveMapping *cumap, ImBuf *ibuf) curvemapping_premultiply(cumap, 0); - pix_in= ibuf->rect_float; - pix_out= tmpbuf->rect_float; + pix_in = ibuf->rect_float; + pix_out = tmpbuf->rect_float; if (ibuf->channels) - stride= ibuf->channels; + stride = ibuf->channels; - for (pixel= ibuf->x*ibuf->y; pixel>0; pixel--, pix_in+=stride, pix_out+=stride) { - if (stride<3) { - col[0]= curvemap_evaluateF(cumap->cm, *pix_in); + for (pixel = ibuf->x * ibuf->y; pixel > 0; pixel--, pix_in += stride, pix_out += stride) { + if (stride < 3) { + col[0] = curvemap_evaluateF(cumap->cm, *pix_in); - pix_out[1]= pix_out[2]= pix_out[3]= pix_out[0]= col[0]; + pix_out[1] = pix_out[2] = pix_out[3] = pix_out[0] = col[0]; } else { curvemapping_evaluate_premulRGBF(cumap, col, pix_in); - pix_out[0]= col[0]; - pix_out[1]= col[1]; - pix_out[2]= col[2]; - if (stride>3) - pix_out[3]= pix_in[3]; + pix_out[0] = col[0]; + pix_out[1] = col[1]; + pix_out[2] = col[2]; + if (stride > 3) + pix_out[3] = pix_in[3]; else - pix_out[3]= 1.f; + pix_out[3] = 1.f; } } @@ -800,16 +800,16 @@ int curvemapping_RGBA_does_something(CurveMapping *cumap) { int a; - if (cumap->black[0]!=0.0f) return 1; - if (cumap->black[1]!=0.0f) return 1; - if (cumap->black[2]!=0.0f) return 1; - if (cumap->white[0]!=1.0f) return 1; - if (cumap->white[1]!=1.0f) return 1; - if (cumap->white[2]!=1.0f) return 1; + if (cumap->black[0] != 0.0f) return 1; + if (cumap->black[1] != 0.0f) return 1; + if (cumap->black[2] != 0.0f) return 1; + if (cumap->white[0] != 1.0f) return 1; + if (cumap->white[1] != 1.0f) return 1; + if (cumap->white[2] != 1.0f) return 1; - for (a=0; acm[a].curve) { - if (cumap->cm[a].totpoint!=2) return 1; + if (cumap->cm[a].totpoint != 2) return 1; if (cumap->cm[a].curve[0].x != 0.0f) return 1; if (cumap->cm[a].curve[0].y != 0.0f) return 1; @@ -824,11 +824,11 @@ void curvemapping_initialize(CurveMapping *cumap) { int a; - if (cumap==NULL) return; + if (cumap == NULL) return; - for (a=0; acm[a].table==NULL) - curvemap_make_table(cumap->cm+a, &cumap->clipr); + for (a = 0; a < CM_TOT; a++) { + if (cumap->cm[a].table == NULL) + curvemap_make_table(cumap->cm + a, &cumap->clipr); } } @@ -836,29 +836,29 @@ void curvemapping_table_RGBA(CurveMapping *cumap, float **array, int *size) { int a; - *size = CM_TABLE+1; - *array = MEM_callocN(sizeof(float)*(*size)*4, "CurveMapping"); + *size = CM_TABLE + 1; + *array = MEM_callocN(sizeof(float) * (*size) * 4, "CurveMapping"); curvemapping_initialize(cumap); - for (a=0; a<*size; a++) { + for (a = 0; a < *size; a++) { if (cumap->cm[0].table) - (*array)[a*4+0]= cumap->cm[0].table[a].y; + (*array)[a * 4 + 0] = cumap->cm[0].table[a].y; if (cumap->cm[1].table) - (*array)[a*4+1]= cumap->cm[1].table[a].y; + (*array)[a * 4 + 1] = cumap->cm[1].table[a].y; if (cumap->cm[2].table) - (*array)[a*4+2]= cumap->cm[2].table[a].y; + (*array)[a * 4 + 2] = cumap->cm[2].table[a].y; if (cumap->cm[3].table) - (*array)[a*4+3]= cumap->cm[3].table[a].y; + (*array)[a * 4 + 3] = cumap->cm[3].table[a].y; } } /* ***************** Histogram **************** */ -#define INV_255 (1.f/255.f) +#define INV_255 (1.f / 255.f) DO_INLINE int get_bin_float(float f) { - int bin= (int)((f*255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */ + int bin = (int)((f * 255.0f) + 0.5f); /* 0.5 to prevent quantisation differences */ /* note: clamp integer instead of float to avoid problems with NaN */ CLAMP(bin, 0, 255); @@ -907,17 +907,17 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) int x, y, c; unsigned int n, nl; double div, divl; - float *rf=NULL; - unsigned char *rc=NULL; + float *rf = NULL; + unsigned char *rc = NULL; unsigned int *bin_r, *bin_g, *bin_b, *bin_lum; int savedlines, saveline; float rgb[3], ycc[3], luma; - int ycc_mode=-1; + int ycc_mode = -1; const short is_float = (ibuf->rect_float != NULL); - if (ibuf->rect==NULL && ibuf->rect_float==NULL) return; + if (ibuf->rect == NULL && ibuf->rect_float == NULL) return; - if (scopes->ok == 1 ) return; + if (scopes->ok == 1) return; if (scopes->hist.ymax == 0.f) scopes->hist.ymax = 1.f; @@ -950,19 +950,19 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) bin_lum = MEM_callocN(256 * sizeof(unsigned int), "temp historgram bins"); /* convert to number of lines with logarithmic scale */ - scopes->sample_lines = (scopes->accuracy*0.01f) * (scopes->accuracy*0.01f) * ibuf->y; + scopes->sample_lines = (scopes->accuracy * 0.01f) * (scopes->accuracy * 0.01f) * ibuf->y; if (scopes->sample_full) scopes->sample_lines = ibuf->y; /* scan the image */ - savedlines=0; - for (c=0; c<3; c++) { - scopes->minmax[c][0]=25500.0f; - scopes->minmax[c][1]=-25500.0f; + savedlines = 0; + for (c = 0; c < 3; c++) { + scopes->minmax[c][0] = 25500.0f; + scopes->minmax[c][1] = -25500.0f; } - scopes->waveform_tot = ibuf->x*scopes->sample_lines; + scopes->waveform_tot = ibuf->x * scopes->sample_lines; if (scopes->waveform_1) MEM_freeN(scopes->waveform_1); @@ -973,10 +973,10 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) if (scopes->vecscope) MEM_freeN(scopes->vecscope); - scopes->waveform_1= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); - scopes->waveform_2= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); - scopes->waveform_3= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); - scopes->vecscope= MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); + scopes->waveform_1 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 1"); + scopes->waveform_2 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 2"); + scopes->waveform_3 = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "waveform point channel 3"); + scopes->vecscope = MEM_callocN(scopes->waveform_tot * 2 * sizeof(float), "vectorscope point channel"); if (is_float) rf = ibuf->rect_float; @@ -984,7 +984,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) rc = (unsigned char *)ibuf->rect; for (y = 0; y < ibuf->y; y++) { - if (savedlinessample_lines && y>=((savedlines)*ibuf->y)/(scopes->sample_lines+1)) { + if (savedlines < scopes->sample_lines && y >= ((savedlines) * ibuf->y) / (scopes->sample_lines + 1)) { saveline = 1; } else { @@ -999,7 +999,7 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) copy_v3_v3(rgb, rf); } else { - for (c=0; c<3; c++) + for (c = 0; c < 3; c++) rgb[c] = rc[c] * INV_255; } @@ -1007,44 +1007,44 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) luma = rgb_to_luma(rgb); /* check for min max */ - if (ycc_mode == -1 ) { - for (c=0; c<3; c++) { + if (ycc_mode == -1) { + for (c = 0; c < 3; c++) { if (rgb[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = rgb[c]; if (rgb[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = rgb[c]; } } else { rgb_to_ycc(rgb[0], rgb[1], rgb[2], &ycc[0], &ycc[1], &ycc[2], ycc_mode); - for (c=0; c<3; c++) { - ycc[c] *=INV_255; + for (c = 0; c < 3; c++) { + ycc[c] *= INV_255; if (ycc[c] < scopes->minmax[c][0]) scopes->minmax[c][0] = ycc[c]; if (ycc[c] > scopes->minmax[c][1]) scopes->minmax[c][1] = ycc[c]; } } /* increment count for histo*/ - bin_r[ get_bin_float(rgb[0]) ] += 1; - bin_g[ get_bin_float(rgb[1]) ] += 1; - bin_b[ get_bin_float(rgb[2]) ] += 1; - bin_lum[ get_bin_float(luma) ] += 1; + bin_r[get_bin_float(rgb[0])] += 1; + bin_g[get_bin_float(rgb[1])] += 1; + bin_b[get_bin_float(rgb[2])] += 1; + bin_lum[get_bin_float(luma)] += 1; /* save sample if needed */ if (saveline) { const float fx = (float)x / (float)ibuf->x; - const int idx = 2*(ibuf->x*savedlines+x); + const int idx = 2 * (ibuf->x * savedlines + x); save_sample_line(scopes, idx, fx, rgb, ycc); } - rf+= ibuf->channels; - rc+= ibuf->channels; + rf += ibuf->channels; + rc += ibuf->channels; } if (saveline) - savedlines +=1; + savedlines += 1; } /* convert hist data to float (proportional to max count) */ - n=0; - nl=0; - for (x=0; x<256; x++) { + n = 0; + nl = 0; + for (x = 0; x < 256; x++) { if (bin_r[x] > n) n = bin_r[x]; if (bin_g[x] > n) @@ -1054,9 +1054,9 @@ void scopes_update(Scopes *scopes, ImBuf *ibuf, int use_color_management) if (bin_lum[x] > nl) nl = bin_lum[x]; } - div = 1.0/(double)n; - divl = 1.0/(double)nl; - for (x=0; x<256; x++) { + div = 1.0 / (double)n; + divl = 1.0 / (double)nl; + for (x = 0; x < 256; x++) { scopes->hist.data_r[x] = bin_r[x] * div; scopes->hist.data_g[x] = bin_g[x] * div; scopes->hist.data_b[x] = bin_b[x] * div; @@ -1092,14 +1092,14 @@ void scopes_free(Scopes *scopes) void scopes_new(Scopes *scopes) { - scopes->accuracy=30.0; - scopes->hist.mode=HISTO_MODE_RGB; - scopes->wavefrm_alpha=0.3; - scopes->vecscope_alpha=0.3; - scopes->wavefrm_height= 100; - scopes->vecscope_height= 100; - scopes->hist.height= 100; - scopes->ok= 0; + scopes->accuracy = 30.0; + scopes->hist.mode = HISTO_MODE_RGB; + scopes->wavefrm_alpha = 0.3; + scopes->vecscope_alpha = 0.3; + scopes->wavefrm_height = 100; + scopes->vecscope_height = 100; + scopes->hist.height = 100; + scopes->ok = 0; scopes->waveform_1 = NULL; scopes->waveform_2 = NULL; scopes->waveform_3 = NULL; diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 424ded0397e..868da0fda94 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -69,7 +69,7 @@ #include "BKE_constraint.h" #include "BKE_displist.h" #include "BKE_deform.h" -#include "BKE_DerivedMesh.h" /* for geometry targets */ +#include "BKE_DerivedMesh.h" /* for geometry targets */ #include "BKE_cdderivedmesh.h" /* for geometry targets */ #include "BKE_object.h" #include "BKE_ipo.h" @@ -90,7 +90,7 @@ #endif #ifndef M_PI -#define M_PI 3.14159265358979323846 +#define M_PI 3.14159265358979323846 #endif @@ -113,15 +113,15 @@ void unique_constraint_name(bConstraint *con, ListBase *list) /* package an object/bone for use in constraint evaluation */ /* This function MEM_calloc's a bConstraintOb struct, that will need to be freed after evaluation */ -bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, short datatype) +bConstraintOb *constraints_make_evalob(Scene *scene, Object *ob, void *subdata, short datatype) { bConstraintOb *cob; /* create regardless of whether we have any data! */ - cob= MEM_callocN(sizeof(bConstraintOb), "bConstraintOb"); + cob = MEM_callocN(sizeof(bConstraintOb), "bConstraintOb"); /* for system time, part of deglobalization, code nicer later with local time (ton) */ - cob->scene= scene; + cob->scene = scene; /* based on type of available data */ switch (datatype) { @@ -139,7 +139,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, copy_m4_m4(cob->startmat, cob->matrix); } - break; + break; case CONSTRAINT_OBTYPE_BONE: { /* only set if we have valid bone, otherwise default */ @@ -150,11 +150,11 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, if (cob->pchan->rotmode > 0) { /* should be some type of Euler order */ - cob->rotOrder= cob->pchan->rotmode; + cob->rotOrder = cob->pchan->rotmode; } else { /* Quats, so eulers should just use default order */ - cob->rotOrder= EULER_ORDER_DEFAULT; + cob->rotOrder = EULER_ORDER_DEFAULT; } /* matrix in world-space */ @@ -165,7 +165,7 @@ bConstraintOb *constraints_make_evalob (Scene *scene, Object *ob, void *subdata, copy_m4_m4(cob->startmat, cob->matrix); } - break; + break; default: /* other types not yet handled */ unit_m4(cob->matrix); @@ -202,7 +202,7 @@ void constraints_clear_evalob(bConstraintOb *cob) invert_m4_m4(cob->ob->constinv, delta); } } - break; + break; case CONSTRAINT_OBTYPE_BONE: { /* cob->ob or cob->pchan might not exist */ @@ -214,7 +214,7 @@ void constraints_clear_evalob(bConstraintOb *cob) invert_m4_m4(cob->pchan->constinv, delta); } } - break; + break; } /* free tempolary struct */ @@ -278,7 +278,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] float imat[4][4]; /* prevent crashes in these unlikely events */ - if (ob==NULL || mat==NULL) return; + if (ob == NULL || mat == NULL) return; /* optimize trick - check if need to do anything */ if (from == to) return; @@ -298,8 +298,8 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); } } - break; - case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */ + break; + case CONSTRAINT_SPACE_POSE: /* ---------- FROM POSESPACE ---------- */ { /* pose to world */ if (to == CONSTRAINT_SPACE_WORLD) { @@ -308,7 +308,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* pose to local */ else if (to == CONSTRAINT_SPACE_LOCAL) { if (pchan->bone) { - armature_mat_pose_to_bone(pchan, mat, mat); + BKE_armature_mat_pose_to_bone(pchan, mat, mat); #if 0 /* XXX Old code, will remove it later. */ constraint_pchan_diff_mat(pchan, diff_mat); @@ -317,7 +317,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* override with local location */ if ((pchan->parent) && (pchan->bone->flag & BONE_NO_LOCAL_LOCATION)) { - armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat); + BKE_armature_mat_pose_to_bone_ex(ob, pchan, pchan->pose_mat, tempmat); copy_v3_v3(mat[3], tempmat[3]); } #endif @@ -331,13 +331,13 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] } } } - break; + break; case CONSTRAINT_SPACE_LOCAL: /* ------------ FROM LOCALSPACE --------- */ { /* local to pose - do inverse procedure that was done for pose to local */ if (pchan->bone) { /* we need the posespace_matrix = local_matrix + (parent_posespace_matrix + restpos) */ - armature_mat_bone_to_pose(pchan, mat, mat); + BKE_armature_mat_bone_to_pose(pchan, mat, mat); #if 0 constraint_pchan_diff_mat(pchan, diff_mat); @@ -351,7 +351,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); } } - break; + break; case CONSTRAINT_SPACE_PARLOCAL: /* -------------- FROM LOCAL WITH PARENT ---------- */ { /* local + parent to pose */ @@ -366,12 +366,12 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] constraint_mat_convertspace(ob, pchan, mat, CONSTRAINT_SPACE_POSE, to); } } - break; + break; } } else { /* objects */ - if (from==CONSTRAINT_SPACE_WORLD && to==CONSTRAINT_SPACE_LOCAL) { + if (from == CONSTRAINT_SPACE_WORLD && to == CONSTRAINT_SPACE_LOCAL) { /* check if object has a parent */ if (ob->parent) { /* 'subtract' parent's effects from owner */ @@ -383,7 +383,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* Local space in this case will have to be defined as local to the owner's * transform-property-rotated axes. So subtract this rotation component. */ - object_to_mat4(ob, diff_mat); + BKE_object_to_mat4(ob, diff_mat); normalize_m4(diff_mat); zero_v3(diff_mat[3]); @@ -391,7 +391,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] mult_m4_m4m4(mat, imat, mat); } } - else if (from==CONSTRAINT_SPACE_LOCAL && to==CONSTRAINT_SPACE_WORLD) { + else if (from == CONSTRAINT_SPACE_LOCAL && to == CONSTRAINT_SPACE_WORLD) { /* check that object has a parent - otherwise this won't work */ if (ob->parent) { /* 'add' parent's effect back to owner */ @@ -402,7 +402,7 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* Local space in this case will have to be defined as local to the owner's * transform-property-rotated axes. So add back this rotation component. */ - object_to_mat4(ob, diff_mat); + BKE_object_to_mat4(ob, diff_mat); normalize_m4(diff_mat); zero_v3(diff_mat[3]); @@ -415,15 +415,15 @@ void constraint_mat_convertspace(Object *ob, bPoseChannel *pchan, float mat[][4] /* ------------ General Target Matrix Tools ---------- */ /* function that sets the given matrix based on given vertex group in mesh */ -static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat[][4]) +static void contarget_get_mesh_mat(Object *ob, const char *substring, float mat[][4]) { DerivedMesh *dm = NULL; - Mesh *me= ob->data; + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; float vec[3] = {0.0f, 0.0f, 0.0f}; float normal[3] = {0.0f, 0.0f, 0.0f}, plane[3]; float imat[3][3], tmat[3][3]; - const int defgroup= defgroup_name_index(ob, substring); + const int defgroup = defgroup_name_index(ob, substring); short freeDM = 0; /* initialize target matrix using target matrix */ @@ -436,7 +436,7 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat if (em) { /* target is in editmode, so get a special derived mesh */ dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); - freeDM= 1; + freeDM = 1; } else { /* when not in EditMode, use the 'final' derived mesh, depsgraph @@ -454,10 +454,10 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat /* check that dvert is a valid pointers (just in case) */ if (dvert) { - MDeformVert *dv= dvert; + MDeformVert *dv = dvert; /* get the average of all verts with that are in the vertex-group */ for (i = 0; i < numVerts; i++, dv++) { - MDeformWeight *dw= defvert_find_index(dv, defgroup); + MDeformWeight *dw = defvert_find_index(dv, defgroup); if (dw && dw->weight != 0.0f) { dm->getVertCo(dm, i, co); dm->getVertNo(dm, i, nor); @@ -512,20 +512,20 @@ static void contarget_get_mesh_mat (Object *ob, const char *substring, float mat } /* function that sets the given matrix based on given vertex group in lattice */ -static void contarget_get_lattice_mat (Object *ob, const char *substring, float mat[][4]) +static void contarget_get_lattice_mat(Object *ob, const char *substring, float mat[][4]) { - Lattice *lt= (Lattice *)ob->data; + Lattice *lt = (Lattice *)ob->data; - DispList *dl = find_displist(&ob->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; + DispList *dl = BKE_displist_find(&ob->disp, DL_VERTS); + float *co = dl ? dl->verts : NULL; BPoint *bp = lt->def; MDeformVert *dv = lt->dvert; - int tot_verts= lt->pntsu*lt->pntsv*lt->pntsw; - float vec[3]= {0.0f, 0.0f, 0.0f}, tvec[3]; - int grouped=0; + int tot_verts = lt->pntsu * lt->pntsv * lt->pntsw; + float vec[3] = {0.0f, 0.0f, 0.0f}, tvec[3]; + int grouped = 0; int i, n; - const int defgroup= defgroup_name_index(ob, substring); + const int defgroup = defgroup_name_index(ob, substring); /* initialize target matrix using target matrix */ copy_m4_m4(mat, ob->obmat); @@ -537,9 +537,9 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* 1. Loop through control-points checking if in nominated vertex-group. * 2. If it is, add it to vec to find the average point. */ - for (i=0; i < tot_verts; i++, dv++) { - for (n= 0; n < dv->totweight; n++) { - MDeformWeight *dw= defvert_find_index(dv, defgroup); + for (i = 0; i < tot_verts; i++, dv++) { + for (n = 0; n < dv->totweight; n++) { + MDeformWeight *dw = defvert_find_index(dv, defgroup); if (dw && dw->weight > 0.0f) { /* copy coordinates of point to temporary vector, then add to find average */ memcpy(tvec, co ? co : bp->vec, 3 * sizeof(float)); @@ -551,7 +551,7 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* advance pointer to coordinate data */ if (co) co += 3; - else bp++; + else bp++; } /* find average location, then multiply by ob->obmat to find world-space location */ @@ -565,14 +565,14 @@ static void contarget_get_lattice_mat (Object *ob, const char *substring, float /* generic function to get the appropriate matrix for most target cases */ /* The cases where the target can be object data have not been implemented */ -static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) +static void constraint_target_to_mat4(Object *ob, const char *substring, float mat[][4], short from, short to, float headtail) { /* Case OBJECT */ if (!strlen(substring)) { copy_m4_m4(mat, ob->obmat); constraint_mat_convertspace(ob, NULL, mat, from, to); } - /* Case VERTEXGROUP */ + /* Case VERTEXGROUP */ /* Current method just takes the average location of all the points in the * VertexGroup, and uses that as the location value of the targets. Where * possible, the orientation will also be calculated, by calculating an @@ -593,7 +593,7 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float else { bPoseChannel *pchan; - pchan = get_pose_channel(ob->pose, substring); + pchan = BKE_pose_channel_find_name(ob->pose, substring); if (pchan) { /* Multiply the PoseSpace accumulation/final matrix for this * PoseChannel by the Armature Object's Matrix to get a worldspace @@ -631,14 +631,14 @@ static void constraint_target_to_mat4 (Object *ob, const char *substring, float */ /* Template for type-info data: - * - make a copy of this when creating new constraints, and just change the functions - * pointed to as necessary - * - although the naming of functions doesn't matter, it would help for code - * readability, to follow the same naming convention as is presented here - * - any functions that a constraint doesn't need to define, don't define - * for such cases, just use NULL - * - these should be defined after all the functions have been defined, so that - * forward-definitions/prototypes don't need to be used! + * - make a copy of this when creating new constraints, and just change the functions + * pointed to as necessary + * - although the naming of functions doesn't matter, it would help for code + * readability, to follow the same naming convention as is presented here + * - any functions that a constraint doesn't need to define, don't define + * for such cases, just use NULL + * - these should be defined after all the functions have been defined, so that + * forward-definitions/prototypes don't need to be used! * - keep this copy #if-def'd so that future constraints can get based off this */ #if 0 @@ -648,7 +648,6 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { "ConstrName", /* name */ "bConstrNameConstraint", /* struct name */ constrname_free, /* free data */ - constrname_relink, /* relink data */ constrname_id_looper, /* id looper */ constrname_copy, /* copy data */ constrname_new_data, /* new data */ @@ -662,7 +661,7 @@ static bConstraintTypeInfo CTI_CONSTRNAME = { /* This function should be used for the get_target_matrix member of all * constraints that are not picky about what happens to their target matrix. */ -static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) +static void default_get_tarmat(bConstraint *con, bConstraintOb *UNUSED(cob), bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); @@ -678,26 +677,26 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC // TODO: cope with getting rotation order... #define SINGLETARGET_GET_TARS(con, datatar, datasubtarget, ct, list) \ { \ - ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ + ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ \ - ct->tar= datatar; \ + ct->tar = datatar; \ BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \ - ct->space= con->tarspace; \ - ct->flag= CONSTRAINT_TAR_TEMP; \ + ct->space = con->tarspace; \ + ct->flag = CONSTRAINT_TAR_TEMP; \ \ if (ct->tar) { \ - if ((ct->tar->type==OB_ARMATURE) && (ct->subtarget[0])) { \ - bPoseChannel *pchan= get_pose_channel(ct->tar->pose, ct->subtarget); \ + if ((ct->tar->type == OB_ARMATURE) && (ct->subtarget[0])) { \ + bPoseChannel *pchan = BKE_pose_channel_find_name(ct->tar->pose, ct->subtarget); \ ct->type = CONSTRAINT_OBTYPE_BONE; \ - ct->rotOrder= (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \ - }\ + ct->rotOrder = (pchan) ? (pchan->rotmode) : EULER_ORDER_DEFAULT; \ + } \ else if (OB_TYPE_SUPPORT_VGROUP(ct->tar->type) && (ct->subtarget[0])) { \ ct->type = CONSTRAINT_OBTYPE_VERT; \ ct->rotOrder = EULER_ORDER_DEFAULT; \ } \ - else {\ + else { \ ct->type = CONSTRAINT_OBTYPE_OBJECT; \ - ct->rotOrder= ct->tar->rotmode; \ + ct->rotOrder = ct->tar->rotmode; \ } \ } \ \ @@ -712,11 +711,11 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC // TODO: cope with getting rotation order... #define SINGLETARGETNS_GET_TARS(con, datatar, ct, list) \ { \ - ct= MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ + ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ \ - ct->tar= datatar; \ - ct->space= con->tarspace; \ - ct->flag= CONSTRAINT_TAR_TEMP; \ + ct->tar = datatar; \ + ct->space = con->tarspace; \ + ct->flag = CONSTRAINT_TAR_TEMP; \ \ if (ct->tar) ct->type = CONSTRAINT_OBTYPE_OBJECT; \ \ @@ -734,13 +733,13 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC if (ct) { \ bConstraintTarget *ctn = ct->next; \ if (nocopy == 0) { \ - datatar= ct->tar; \ + datatar = ct->tar; \ BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \ - con->tarspace= (char)ct->space; \ + con->tarspace = (char)ct->space; \ } \ \ BLI_freelinkN(list, ct); \ - ct= ctn; \ + ct = ctn; \ } \ } @@ -755,39 +754,39 @@ static void default_get_tarmat (bConstraint *con, bConstraintOb *UNUSED(cob), bC if (ct) { \ bConstraintTarget *ctn = ct->next; \ if (nocopy == 0) { \ - datatar= ct->tar; \ - con->tarspace= (char)ct->space; \ + datatar = ct->tar; \ + con->tarspace = (char)ct->space; \ } \ \ BLI_freelinkN(list, ct); \ - ct= ctn; \ + ct = ctn; \ } \ } /* --------- ChildOf Constraint ------------ */ -static void childof_new_data (void *cdata) +static void childof_new_data(void *cdata) { - bChildOfConstraint *data= (bChildOfConstraint *)cdata; + bChildOfConstraint *data = (bChildOfConstraint *)cdata; data->flag = (CHILDOF_LOCX | CHILDOF_LOCY | CHILDOF_LOCZ | - CHILDOF_ROTX |CHILDOF_ROTY | CHILDOF_ROTZ | - CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ); + CHILDOF_ROTX | CHILDOF_ROTY | CHILDOF_ROTZ | + CHILDOF_SIZEX | CHILDOF_SIZEY | CHILDOF_SIZEZ); unit_m4(data->invmat); } -static void childof_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void childof_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bChildOfConstraint *data= con->data; + bChildOfConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int childof_get_tars (bConstraint *con, ListBase *list) +static int childof_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bChildOfConstraint *data= con->data; + bChildOfConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -799,21 +798,21 @@ static int childof_get_tars (bConstraint *con, ListBase *list) return 0; } -static void childof_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void childof_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bChildOfConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bChildOfConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void childof_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bChildOfConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bChildOfConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -850,15 +849,15 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta mat4_to_size(sizo, invmat); /* disable channels not enabled */ - if (!(data->flag & CHILDOF_LOCX)) loc[0]= loco[0]= 0.0f; - if (!(data->flag & CHILDOF_LOCY)) loc[1]= loco[1]= 0.0f; - if (!(data->flag & CHILDOF_LOCZ)) loc[2]= loco[2]= 0.0f; - if (!(data->flag & CHILDOF_ROTX)) eul[0]= eulo[0]= 0.0f; - if (!(data->flag & CHILDOF_ROTY)) eul[1]= eulo[1]= 0.0f; - if (!(data->flag & CHILDOF_ROTZ)) eul[2]= eulo[2]= 0.0f; - if (!(data->flag & CHILDOF_SIZEX)) size[0]= sizo[0]= 1.0f; - if (!(data->flag & CHILDOF_SIZEY)) size[1]= sizo[1]= 1.0f; - if (!(data->flag & CHILDOF_SIZEZ)) size[2]= sizo[2]= 1.0f; + if (!(data->flag & CHILDOF_LOCX)) loc[0] = loco[0] = 0.0f; + if (!(data->flag & CHILDOF_LOCY)) loc[1] = loco[1] = 0.0f; + if (!(data->flag & CHILDOF_LOCZ)) loc[2] = loco[2] = 0.0f; + if (!(data->flag & CHILDOF_ROTX)) eul[0] = eulo[0] = 0.0f; + if (!(data->flag & CHILDOF_ROTY)) eul[1] = eulo[1] = 0.0f; + if (!(data->flag & CHILDOF_ROTZ)) eul[2] = eulo[2] = 0.0f; + if (!(data->flag & CHILDOF_SIZEX)) size[0] = sizo[0] = 1.0f; + if (!(data->flag & CHILDOF_SIZEY)) size[1] = sizo[1] = 1.0f; + if (!(data->flag & CHILDOF_SIZEZ)) size[2] = sizo[2] = 1.0f; /* make new target mat and offset mat */ loc_eulO_size_to_mat4(ct->matrix, loc, eul, size, ct->rotOrder); @@ -874,13 +873,13 @@ static void childof_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta */ copy_m4_m4(tempmat, cob->matrix); mult_m4_m4m4(cob->matrix, parmat, tempmat); - + /* without this, changes to scale and rotation can change location * of a parentless bone or a disconnected bone. Even though its set * to zero above. */ - if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0]= tempmat[3][0]; - if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1]= tempmat[3][1]; - if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2]= tempmat[3][2]; + if (!(data->flag & CHILDOF_LOCX)) cob->matrix[3][0] = tempmat[3][0]; + if (!(data->flag & CHILDOF_LOCY)) cob->matrix[3][1] = tempmat[3][1]; + if (!(data->flag & CHILDOF_LOCZ)) cob->matrix[3][2] = tempmat[3][2]; } } } @@ -892,7 +891,6 @@ static bConstraintTypeInfo CTI_CHILDOF = { "ChildOf", /* name */ "bChildOfConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ childof_id_looper, /* id looper */ NULL, /* copy data */ childof_new_data, /* new data */ @@ -904,26 +902,26 @@ static bConstraintTypeInfo CTI_CHILDOF = { /* -------- TrackTo Constraint ------- */ -static void trackto_new_data (void *cdata) +static void trackto_new_data(void *cdata) { - bTrackToConstraint *data= (bTrackToConstraint *)cdata; + bTrackToConstraint *data = (bTrackToConstraint *)cdata; data->reserved1 = TRACK_Y; data->reserved2 = UP_Z; } -static void trackto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void trackto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bTrackToConstraint *data= con->data; + bTrackToConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int trackto_get_tars (bConstraint *con, ListBase *list) +static int trackto_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bTrackToConstraint *data= con->data; + bTrackToConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -935,11 +933,11 @@ static int trackto_get_tars (bConstraint *con, ListBase *list) return 0; } -static void trackto_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void trackto_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bTrackToConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bTrackToConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) @@ -947,9 +945,9 @@ static void trackto_flush_tars (bConstraint *con, ListBase *list, short nocopy) } -static int basis_cross (int n, int m) +static int basis_cross(int n, int m) { - switch (n-m) { + switch (n - m) { case 1: case -2: return 1; @@ -963,7 +961,7 @@ static int basis_cross (int n, int m) } } -static void vectomat (float *vec, float *target_up, short axis, short upflag, short flags, float m[][3]) +static void vectomat(float *vec, float *target_up, short axis, short upflag, short flags, float m[][3]) { float n[3]; float u[3]; /* vector specifying the up axis */ @@ -1027,10 +1025,10 @@ static void vectomat (float *vec, float *target_up, short axis, short upflag, sh } -static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void trackto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bTrackToConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bTrackToConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float size[3], vec[3]; @@ -1041,23 +1039,23 @@ static void trackto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta mat4_to_size(size, cob->matrix); /* Clear the object's rotation */ - cob->matrix[0][0]=size[0]; - cob->matrix[0][1]=0; - cob->matrix[0][2]=0; - cob->matrix[1][0]=0; - cob->matrix[1][1]=size[1]; - cob->matrix[1][2]=0; - cob->matrix[2][0]=0; - cob->matrix[2][1]=0; - cob->matrix[2][2]=size[2]; + cob->matrix[0][0] = size[0]; + cob->matrix[0][1] = 0; + cob->matrix[0][2] = 0; + cob->matrix[1][0] = 0; + cob->matrix[1][1] = size[1]; + cob->matrix[1][2] = 0; + cob->matrix[2][0] = 0; + cob->matrix[2][1] = 0; + cob->matrix[2][2] = size[2]; /* targetmat[2] instead of ownermat[2] is passed to vectomat * for backwards compatibility it seems... (Aligorith) */ sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); vectomat(vec, ct->matrix[2], - (short)data->reserved1, (short)data->reserved2, - data->flags, totmat); + (short)data->reserved1, (short)data->reserved2, + data->flags, totmat); copy_m4_m4(tmat, cob->matrix); mul_m4_m3m4(cob->matrix, totmat, tmat); @@ -1070,7 +1068,6 @@ static bConstraintTypeInfo CTI_TRACKTO = { "TrackTo", /* name */ "bTrackToConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ trackto_id_looper, /* id looper */ NULL, /* copy data */ trackto_new_data, /* new data */ @@ -1082,32 +1079,32 @@ static bConstraintTypeInfo CTI_TRACKTO = { /* --------- Inverse-Kinemetics --------- */ -static void kinematic_new_data (void *cdata) +static void kinematic_new_data(void *cdata) { - bKinematicConstraint *data= (bKinematicConstraint *)cdata; + bKinematicConstraint *data = (bKinematicConstraint *)cdata; - data->weight= 1.0f; - data->orientweight= 1.0f; + data->weight = 1.0f; + data->orientweight = 1.0f; data->iterations = 500; - data->dist= 1.0f; - data->flag= CONSTRAINT_IK_TIP|CONSTRAINT_IK_STRETCH|CONSTRAINT_IK_POS; + data->dist = 1.0f; + data->flag = CONSTRAINT_IK_TIP | CONSTRAINT_IK_STRETCH | CONSTRAINT_IK_POS; } -static void kinematic_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void kinematic_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bKinematicConstraint *data= con->data; + bKinematicConstraint *data = con->data; /* chain target */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); /* poletarget */ - func(con, (ID**)&data->poletar, userdata); + func(con, (ID **)&data->poletar, FALSE, userdata); } -static int kinematic_get_tars (bConstraint *con, ListBase *list) +static int kinematic_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bKinematicConstraint *data= con->data; + bKinematicConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints is used twice here */ @@ -1120,11 +1117,11 @@ static int kinematic_get_tars (bConstraint *con, ListBase *list) return 0; } -static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void kinematic_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bKinematicConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bKinematicConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) @@ -1132,15 +1129,15 @@ static void kinematic_flush_tars (bConstraint *con, ListBase *list, short nocopy } } -static void kinematic_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void kinematic_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { - bKinematicConstraint *data= con->data; + bKinematicConstraint *data = con->data; if (VALID_CONS_TARGET(ct)) constraint_target_to_mat4(ct->tar, ct->subtarget, ct->matrix, CONSTRAINT_SPACE_WORLD, ct->space, con->headtail); else if (ct) { if (data->flag & CONSTRAINT_IK_AUTO) { - Object *ob= cob->ob; + Object *ob = cob->ob; if (ob == NULL) { unit_m4(ct->matrix); @@ -1164,7 +1161,6 @@ static bConstraintTypeInfo CTI_KINEMATIC = { "IK", /* name */ "bKinematicConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ kinematic_id_looper, /* id looper */ NULL, /* copy data */ kinematic_new_data, /* new data */ @@ -1176,9 +1172,9 @@ static bConstraintTypeInfo CTI_KINEMATIC = { /* -------- Follow-Path Constraint ---------- */ -static void followpath_new_data (void *cdata) +static void followpath_new_data(void *cdata) { - bFollowPathConstraint *data= (bFollowPathConstraint *)cdata; + bFollowPathConstraint *data = (bFollowPathConstraint *)cdata; data->trackflag = TRACK_Y; data->upflag = UP_Z; @@ -1186,18 +1182,18 @@ static void followpath_new_data (void *cdata) data->followflag = 0; } -static void followpath_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void followpath_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int followpath_get_tars (bConstraint *con, ListBase *list) +static int followpath_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -1209,25 +1205,25 @@ static int followpath_get_tars (bConstraint *con, ListBase *list) return 0; } -static void followpath_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void followpath_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bFollowPathConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bFollowPathConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) } } -static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void followpath_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; if (VALID_CONS_TARGET(ct)) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; float vec[4], dir[3], radius; - float totmat[4][4]= MAT4_UNITY; + float totmat[4][4] = MAT4_UNITY; float curvetime; unit_m4(ct->matrix); @@ -1237,15 +1233,15 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr */ /* only happens on reload file, but violates depsgraph still... fix! */ - if (cu->path==NULL || cu->path->data==NULL) - makeDispListCurveTypes(cob->scene, ct->tar, 0); + if (cu->path == NULL || cu->path->data == NULL) + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); if (cu->path && cu->path->data) { float quat[4]; if ((data->followflag & FOLLOWPATH_STATIC) == 0) { /* animated position along curve depending on time */ Nurb *nu = cu->nurb.first; - curvetime= cu->ctime - data->offset; + curvetime = cu->ctime - data->offset; /* ctime is now a proper var setting of Curve which gets set by Animato like any other var that's animated, * but this will only work if it actually is animated... @@ -1269,21 +1265,21 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } else { /* fixed position along curve */ - curvetime= data->offset_fac; + curvetime = data->offset_fac; } - if ( where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/ + if (where_on_path(ct->tar, curvetime, vec, dir, (data->followflag & FOLLOWPATH_FOLLOW) ? quat : NULL, &radius, NULL) ) { /* quat_pt is quat or NULL*/ if (data->followflag & FOLLOWPATH_FOLLOW) { #if 0 float x1, q[4]; vec_to_quat(quat, dir, (short)data->trackflag, (short)data->upflag); normalize_v3(dir); - q[0]= (float)cos(0.5*vec[3]); - x1= (float)sin(0.5*vec[3]); - q[1]= -x1*dir[0]; - q[2]= -x1*dir[1]; - q[3]= -x1*dir[2]; + q[0] = (float)cos(0.5 * vec[3]); + x1 = (float)sin(0.5 * vec[3]); + q[1] = -x1 * dir[0]; + q[2] = -x1 * dir[1]; + q[3] = -x1 * dir[2]; mul_qt_qtqt(quat, q, quat); #else quat_apply_track(quat, data->trackflag, data->upflag); @@ -1309,15 +1305,15 @@ static void followpath_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr unit_m4(ct->matrix); } -static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void followpath_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { float obmat[4][4]; float size[3]; - bFollowPathConstraint *data= con->data; + bFollowPathConstraint *data = con->data; /* get Object transform (loc/rot/size) to determine transformation from path */ // TODO: this used to be local at one point, but is probably more useful as-is @@ -1330,7 +1326,7 @@ static void followpath_evaluate (bConstraint *con, bConstraintOb *cob, ListBase mul_serie_m4(cob->matrix, ct->matrix, obmat, NULL, NULL, NULL, NULL, NULL, NULL); /* un-apply scaling caused by path */ - if ((data->followflag & FOLLOWPATH_RADIUS)==0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ + if ((data->followflag & FOLLOWPATH_RADIUS) == 0) { /* XXX - assume that scale correction means that radius will have some scale error in it - Campbell */ float obsize[3]; mat4_to_size(obsize, cob->matrix); @@ -1350,7 +1346,6 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = { "Follow Path", /* name */ "bFollowPathConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ followpath_id_looper, /* id looper */ NULL, /* copy data */ followpath_new_data, /* new data */ @@ -1363,7 +1358,7 @@ static bConstraintTypeInfo CTI_FOLLOWPATH = { /* --------- Limit Location --------- */ -static void loclimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void loclimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bLocLimitConstraint *data = con->data; @@ -1399,7 +1394,6 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { "Limit Location", /* name */ "bLocLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1411,7 +1405,7 @@ static bConstraintTypeInfo CTI_LOCLIMIT = { /* -------- Limit Rotation --------- */ -static void rotlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void rotlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bRotLimitConstraint *data = con->data; float loc[3]; @@ -1457,7 +1451,6 @@ static bConstraintTypeInfo CTI_ROTLIMIT = { "Limit Rotation", /* name */ "bRotLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1470,7 +1463,7 @@ static bConstraintTypeInfo CTI_ROTLIMIT = { /* --------- Limit Scaling --------- */ -static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void sizelimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { bSizeLimitConstraint *data = con->data; float obsize[3], size[3]; @@ -1504,11 +1497,11 @@ static void sizelimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * } if (obsize[0]) - mul_v3_fl(cob->matrix[0], size[0]/obsize[0]); + mul_v3_fl(cob->matrix[0], size[0] / obsize[0]); if (obsize[1]) - mul_v3_fl(cob->matrix[1], size[1]/obsize[1]); + mul_v3_fl(cob->matrix[1], size[1] / obsize[1]); if (obsize[2]) - mul_v3_fl(cob->matrix[2], size[2]/obsize[2]); + mul_v3_fl(cob->matrix[2], size[2] / obsize[2]); } static bConstraintTypeInfo CTI_SIZELIMIT = { @@ -1517,7 +1510,6 @@ static bConstraintTypeInfo CTI_SIZELIMIT = { "Limit Scaling", /* name */ "bSizeLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1529,25 +1521,25 @@ static bConstraintTypeInfo CTI_SIZELIMIT = { /* ----------- Copy Location ------------- */ -static void loclike_new_data (void *cdata) +static void loclike_new_data(void *cdata) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)cdata; + bLocateLikeConstraint *data = (bLocateLikeConstraint *)cdata; - data->flag = LOCLIKE_X|LOCLIKE_Y|LOCLIKE_Z; + data->flag = LOCLIKE_X | LOCLIKE_Y | LOCLIKE_Z; } -static void loclike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void loclike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bLocateLikeConstraint *data= con->data; + bLocateLikeConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int loclike_get_tars (bConstraint *con, ListBase *list) +static int loclike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bLocateLikeConstraint *data= con->data; + bLocateLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1559,21 +1551,21 @@ static int loclike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void loclike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void loclike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bLocateLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bLocateLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void loclike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void loclike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bLocateLikeConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bLocateLikeConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float offset[3] = {0.0f, 0.0f, 0.0f}; @@ -1608,7 +1600,6 @@ static bConstraintTypeInfo CTI_LOCLIKE = { "Copy Location", /* name */ "bLocateLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ loclike_id_looper, /* id looper */ NULL, /* copy data */ loclike_new_data, /* new data */ @@ -1620,25 +1611,25 @@ static bConstraintTypeInfo CTI_LOCLIKE = { /* ----------- Copy Rotation ------------- */ -static void rotlike_new_data (void *cdata) +static void rotlike_new_data(void *cdata) { - bRotateLikeConstraint *data= (bRotateLikeConstraint *)cdata; + bRotateLikeConstraint *data = (bRotateLikeConstraint *)cdata; - data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; + data->flag = ROTLIKE_X | ROTLIKE_Y | ROTLIKE_Z; } -static void rotlike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void rotlike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bChildOfConstraint *data= con->data; + bChildOfConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int rotlike_get_tars (bConstraint *con, ListBase *list) +static int rotlike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bRotateLikeConstraint *data= con->data; + bRotateLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1650,26 +1641,26 @@ static int rotlike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void rotlike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void rotlike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bRotateLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bRotateLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void rotlike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bRotateLikeConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bRotateLikeConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { - float loc[3]; - float eul[3], obeul[3]; - float size[3]; + float loc[3]; + float eul[3], obeul[3]; + float size[3]; copy_v3_v3(loc, cob->matrix[3]); mat4_to_size(size, cob->matrix); @@ -1679,7 +1670,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta /* we must get compatible eulers from the beginning because some of them can be modified below (see bug #21875) */ mat4_to_compatible_eulO(eul, obeul, cob->rotOrder, ct->matrix); - if ((data->flag & ROTLIKE_X)==0) + if ((data->flag & ROTLIKE_X) == 0) eul[0] = obeul[0]; else { if (data->flag & ROTLIKE_OFFSET) @@ -1689,7 +1680,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[0] *= -1; } - if ((data->flag & ROTLIKE_Y)==0) + if ((data->flag & ROTLIKE_Y) == 0) eul[1] = obeul[1]; else { if (data->flag & ROTLIKE_OFFSET) @@ -1699,7 +1690,7 @@ static void rotlike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta eul[1] *= -1; } - if ((data->flag & ROTLIKE_Z)==0) + if ((data->flag & ROTLIKE_Z) == 0) eul[2] = obeul[2]; else { if (data->flag & ROTLIKE_OFFSET) @@ -1721,7 +1712,6 @@ static bConstraintTypeInfo CTI_ROTLIKE = { "Copy Rotation", /* name */ "bRotateLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ rotlike_id_looper, /* id looper */ NULL, /* copy data */ rotlike_new_data, /* new data */ @@ -1733,25 +1723,25 @@ static bConstraintTypeInfo CTI_ROTLIKE = { /* ---------- Copy Scaling ---------- */ -static void sizelike_new_data (void *cdata) +static void sizelike_new_data(void *cdata) { - bSizeLikeConstraint *data= (bSizeLikeConstraint *)cdata; + bSizeLikeConstraint *data = (bSizeLikeConstraint *)cdata; - data->flag = SIZELIKE_X|SIZELIKE_Y|SIZELIKE_Z; + data->flag = SIZELIKE_X | SIZELIKE_Y | SIZELIKE_Z; } -static void sizelike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void sizelike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bSizeLikeConstraint *data= con->data; + bSizeLikeConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int sizelike_get_tars (bConstraint *con, ListBase *list) +static int sizelike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bSizeLikeConstraint *data= con->data; + bSizeLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1763,21 +1753,21 @@ static int sizelike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void sizelike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void sizelike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bSizeLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bSizeLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void sizelike_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void sizelike_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bSizeLikeConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bSizeLikeConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float obsize[3], size[3]; @@ -1818,7 +1808,6 @@ static bConstraintTypeInfo CTI_SIZELIKE = { "Copy Scale", /* name */ "bSizeLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ sizelike_id_looper, /* id looper */ NULL, /* copy data */ sizelike_new_data, /* new data */ @@ -1830,18 +1819,18 @@ static bConstraintTypeInfo CTI_SIZELIKE = { /* ----------- Copy Transforms ------------- */ -static void translike_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void translike_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bTransLikeConstraint *data= con->data; + bTransLikeConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int translike_get_tars (bConstraint *con, ListBase *list) +static int translike_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bTransLikeConstraint *data= con->data; + bTransLikeConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -1853,20 +1842,20 @@ static int translike_get_tars (bConstraint *con, ListBase *list) return 0; } -static void translike_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void translike_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bTransLikeConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bTransLikeConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void translike_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) +static void translike_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { /* just copy the entire transform matrix of the target */ @@ -1880,7 +1869,6 @@ static bConstraintTypeInfo CTI_TRANSLIKE = { "Copy Transforms", /* name */ "bTransLikeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ translike_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -1892,17 +1880,17 @@ static bConstraintTypeInfo CTI_TRANSLIKE = { /* ---------- Maintain Volume ---------- */ -static void samevolume_new_data (void *cdata) +static void samevolume_new_data(void *cdata) { - bSameVolumeConstraint *data= (bSameVolumeConstraint *)cdata; + bSameVolumeConstraint *data = (bSameVolumeConstraint *)cdata; data->flag = SAMEVOL_Y; data->volume = 1.0f; } -static void samevolume_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) +static void samevolume_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) { - bSameVolumeConstraint *data= con->data; + bSameVolumeConstraint *data = con->data; float volume = data->volume; float fac = 1.0f; @@ -1937,7 +1925,6 @@ static bConstraintTypeInfo CTI_SAMEVOL = { "Maintain Volume", /* name */ "bSameVolumeConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ NULL, /* id looper */ NULL, /* copy data */ samevolume_new_data, /* new data */ @@ -1949,9 +1936,9 @@ static bConstraintTypeInfo CTI_SAMEVOL = { /* ----------- Python Constraint -------------- */ -static void pycon_free (bConstraint *con) +static void pycon_free(bConstraint *con) { - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; /* id-properties */ IDP_FreeProperty(data->prop); @@ -1961,14 +1948,7 @@ static void pycon_free (bConstraint *con) BLI_freelistN(&data->targets); } -static void pycon_relink (bConstraint *con) -{ - bPythonConstraint *data= con->data; - - ID_NEW(data->text); -} - -static void pycon_copy (bConstraint *con, bConstraint *srccon) +static void pycon_copy(bConstraint *con, bConstraint *srccon) { bPythonConstraint *pycon = (bPythonConstraint *)con->data; bPythonConstraint *opycon = (bPythonConstraint *)srccon->data; @@ -1977,19 +1957,19 @@ static void pycon_copy (bConstraint *con, bConstraint *srccon) BLI_duplicatelist(&pycon->targets, &opycon->targets); } -static void pycon_new_data (void *cdata) +static void pycon_new_data(void *cdata) { - bPythonConstraint *data= (bPythonConstraint *)cdata; + bPythonConstraint *data = (bPythonConstraint *)cdata; /* everything should be set correctly by calloc, except for the prop->type constant.*/ data->prop = MEM_callocN(sizeof(IDProperty), "PyConstraintProps"); data->prop->type = IDP_GROUP; } -static int pycon_get_tars (bConstraint *con, ListBase *list) +static int pycon_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; list->first = data->targets.first; list->last = data->targets.last; @@ -2000,34 +1980,34 @@ static int pycon_get_tars (bConstraint *con, ListBase *list) return 0; } -static void pycon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void pycon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; bConstraintTarget *ct; /* targets */ - for (ct= data->targets.first; ct; ct= ct->next) - func(con, (ID**)&ct->tar, userdata); + for (ct = data->targets.first; ct; ct = ct->next) + func(con, (ID **)&ct->tar, FALSE, userdata); /* script */ - func(con, (ID**)&data->text, userdata); + func(con, (ID **)&data->text, TRUE, userdata); } /* Whether this approach is maintained remains to be seen (aligorith) */ -static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void pycon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { #ifdef WITH_PYTHON - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; #endif if (VALID_CONS_TARGET(ct)) { /* special exception for curves - depsgraph issues */ if (ct->tar->type == OB_CURVE) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* this check is to make sure curve objects get updated on file load correctly.*/ - if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */ - makeDispListCurveTypes(cob->scene, ct->tar, 0); + if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* firstly calculate the matrix the normal way, then let the py-function override @@ -2045,16 +2025,16 @@ static void pycon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintT unit_m4(ct->matrix); } -static void pycon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void pycon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { #ifndef WITH_PYTHON (void)con; (void)cob; (void)targets; /* unused */ return; #else - bPythonConstraint *data= con->data; + bPythonConstraint *data = con->data; /* only evaluate in python if we're allowed to do so */ - if ((G.f & G_SCRIPT_AUTOEXEC)==0) return; + if ((G.f & G_SCRIPT_AUTOEXEC) == 0) return; /* currently removed, until I this can be re-implemented for multiple targets */ #if 0 @@ -2076,7 +2056,6 @@ static bConstraintTypeInfo CTI_PYTHON = { "Script", /* name */ "bPythonConstraint", /* struct name */ pycon_free, /* free data */ - pycon_relink, /* relink data */ pycon_id_looper, /* id looper */ pycon_copy, /* copy data */ pycon_new_data, /* new data */ @@ -2088,35 +2067,29 @@ static bConstraintTypeInfo CTI_PYTHON = { /* -------- Action Constraint ----------- */ -static void actcon_relink (bConstraint *con) +static void actcon_new_data(void *cdata) { - bActionConstraint *data= con->data; - ID_NEW(data->act); -} - -static void actcon_new_data (void *cdata) -{ - bActionConstraint *data= (bActionConstraint *)cdata; + bActionConstraint *data = (bActionConstraint *)cdata; /* set type to 20 (Loc X), as 0 is Rot X for backwards compatibility */ data->type = 20; } -static void actcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void actcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bActionConstraint *data= con->data; + bActionConstraint *data = con->data; /* target */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); /* action */ - func(con, (ID**)&data->act, userdata); + func(con, (ID **)&data->act, TRUE, userdata); } -static int actcon_get_tars (bConstraint *con, ListBase *list) +static int actcon_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bActionConstraint *data= con->data; + bActionConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2128,18 +2101,18 @@ static int actcon_get_tars (bConstraint *con, ListBase *list) return 0; } -static void actcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void actcon_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bActionConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bActionConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void actcon_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bActionConstraint *data = con->data; @@ -2157,33 +2130,33 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* determine where in transform range target is */ /* data->type is mapped as follows for backwards compatibility: * 00,01,02 - rotation (it used to be like this) - * 10,11,12 - scaling + * 10,11,12 - scaling * 20,21,22 - location */ if (data->type < 10) { /* extract rotation (is in whatever space target should be in) */ mat4_to_eul(vec, tempmat); mul_v3_fl(vec, RAD2DEGF(1.0f)); /* rad -> deg */ - axis= data->type; + axis = data->type; } else if (data->type < 20) { /* extract scaling (is in whatever space target should be in) */ mat4_to_size(vec, tempmat); - axis= data->type - 10; + axis = data->type - 10; } else { /* extract location */ copy_v3_v3(vec, tempmat[3]); - axis= data->type - 20; + axis = data->type - 20; } /* Target defines the animation */ - s = (vec[axis]-data->min) / (data->max-data->min); + s = (vec[axis] - data->min) / (data->max - data->min); CLAMP(s, 0, 1); - t = (s * (data->end-data->start)) + data->start; + t = (s * (data->end - data->start)) + data->start; if (G.debug & G_DEBUG) - printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name+2, (cob->pchan)?cob->pchan->name:NULL); + printf("do Action Constraint %s - Ob %s Pchan %s\n", con->name, cob->ob->id.name + 2, (cob->pchan) ? cob->pchan->name : NULL); /* Get the appropriate information from the action */ if (cob->type == CONSTRAINT_OBTYPE_BONE) { @@ -2199,18 +2172,18 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint */ pchan = cob->pchan; - tchan= verify_pose_channel(pose, pchan->name); - tchan->rotmode= pchan->rotmode; + tchan = BKE_pose_channel_verify(pose, pchan->name); + tchan->rotmode = pchan->rotmode; /* evaluate action using workob (it will only set the PoseChannel in question) */ what_does_obaction(cob->ob, &workob, pose, data->act, pchan->name, t); /* convert animation to matrices for use here */ - pchan_calc_mat(tchan); + BKE_pchan_calc_mat(tchan); copy_m4_m4(ct->matrix, tchan->chan_mat); /* Clean up */ - free_pose(pose); + BKE_pose_free(pose); } else if (cob->type == CONSTRAINT_OBTYPE_OBJECT) { Object workob; @@ -2218,7 +2191,7 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint /* evaluate using workob */ // FIXME: we don't have any consistent standards on limiting effects on object... what_does_obaction(cob->ob, &workob, NULL, data->act, NULL, t); - object_to_mat4(&workob, ct->matrix); + BKE_object_to_mat4(&workob, ct->matrix); } else { /* behavior undefined... */ @@ -2227,9 +2200,9 @@ static void actcon_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraint } } -static void actcon_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) +static void actcon_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float temp[4][4]; @@ -2248,7 +2221,6 @@ static bConstraintTypeInfo CTI_ACTION = { "Action", /* name */ "bActionConstraint", /* struct name */ NULL, /* free data */ - actcon_relink, /* relink data */ actcon_id_looper, /* id looper */ NULL, /* copy data */ actcon_new_data, /* new data */ @@ -2260,26 +2232,26 @@ static bConstraintTypeInfo CTI_ACTION = { /* --------- Locked Track ---------- */ -static void locktrack_new_data (void *cdata) +static void locktrack_new_data(void *cdata) { - bLockTrackConstraint *data= (bLockTrackConstraint *)cdata; + bLockTrackConstraint *data = (bLockTrackConstraint *)cdata; data->trackflag = TRACK_Y; data->lockflag = LOCK_Z; } -static void locktrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void locktrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bLockTrackConstraint *data= con->data; + bLockTrackConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int locktrack_get_tars (bConstraint *con, ListBase *list) +static int locktrack_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bLockTrackConstraint *data= con->data; + bLockTrackConstraint *data = con->data; bConstraintTarget *ct; /* the following macro is used for all standard single-target constraints */ @@ -2291,21 +2263,21 @@ static int locktrack_get_tars (bConstraint *con, ListBase *list) return 0; } -static void locktrack_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void locktrack_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bLockTrackConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bLockTrackConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void locktrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bLockTrackConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bLockTrackConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float vec[3], vec2[3]; @@ -2318,217 +2290,217 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* Vector object -> target */ sub_v3_v3v3(vec, ct->matrix[3], cob->matrix[3]); switch (data->lockflag) { - case LOCK_X: /* LOCK X */ - { - switch (data->trackflag) { - case TRACK_Y: /* LOCK X TRACK Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); + case LOCK_X: /* LOCK X */ + { + switch (data->trackflag) { + case TRACK_Y: /* LOCK X TRACK Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_Z: /* LOCK X TRACK Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); + case TRACK_Z: /* LOCK X TRACK Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - case TRACK_nY: /* LOCK X TRACK -Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); - negate_v3(totmat[1]); + case TRACK_nY: /* LOCK X TRACK -Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_nZ: /* LOCK X TRACK -Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[0]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); - negate_v3(totmat[2]); + case TRACK_nZ: /* LOCK X TRACK -Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[0]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); - /* the x axis is fixed */ - normalize_v3_v3(totmat[0], cob->matrix[0]); + /* the x axis is fixed */ + normalize_v3_v3(totmat[0], cob->matrix[0]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; + } } - } break; - case LOCK_Y: /* LOCK Y */ - { - switch (data->trackflag) { - case TRACK_X: /* LOCK Y TRACK X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); + case LOCK_Y: /* LOCK Y */ + { + switch (data->trackflag) { + case TRACK_X: /* LOCK Y TRACK X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_Z: /* LOCK Y TRACK Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); + case TRACK_Z: /* LOCK Y TRACK Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - case TRACK_nX: /* LOCK Y TRACK -X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); - negate_v3(totmat[0]); + case TRACK_nX: /* LOCK Y TRACK -X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[2], totmat[0], totmat[1]); + } break; - case TRACK_nZ: /* LOCK Y TRACK -Z */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[1]); - sub_v3_v3v3(totmat[2], vec, vec2); - normalize_v3(totmat[2]); - negate_v3(totmat[2]); + case TRACK_nZ: /* LOCK Y TRACK -Z */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[1]); + sub_v3_v3v3(totmat[2], vec, vec2); + normalize_v3(totmat[2]); + negate_v3(totmat[2]); - /* the y axis is fixed */ - normalize_v3_v3(totmat[1], cob->matrix[1]); + /* the y axis is fixed */ + normalize_v3_v3(totmat[1], cob->matrix[1]); - /* the z axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the z axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; + } } - } break; - case LOCK_Z: /* LOCK Z */ - { - switch (data->trackflag) { - case TRACK_X: /* LOCK Z TRACK X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); + case LOCK_Z: /* LOCK Z */ + { + switch (data->trackflag) { + case TRACK_X: /* LOCK Z TRACK X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - case TRACK_Y: /* LOCK Z TRACK Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); + case TRACK_Y: /* LOCK Z TRACK Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - case TRACK_nX: /* LOCK Z TRACK -X */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[0], vec, vec2); - normalize_v3(totmat[0]); - negate_v3(totmat[0]); + case TRACK_nX: /* LOCK Z TRACK -X */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[0], vec, vec2); + normalize_v3(totmat[0]); + negate_v3(totmat[0]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[1], totmat[2], totmat[0]); + } break; - case TRACK_nY: /* LOCK Z TRACK -Y */ - { - /* Projection of Vector on the plane */ - project_v3_v3v3(vec2, vec, cob->matrix[2]); - sub_v3_v3v3(totmat[1], vec, vec2); - normalize_v3(totmat[1]); - negate_v3(totmat[1]); + case TRACK_nY: /* LOCK Z TRACK -Y */ + { + /* Projection of Vector on the plane */ + project_v3_v3v3(vec2, vec, cob->matrix[2]); + sub_v3_v3v3(totmat[1], vec, vec2); + normalize_v3(totmat[1]); + negate_v3(totmat[1]); - /* the z axis is fixed */ - normalize_v3_v3(totmat[2], cob->matrix[2]); + /* the z axis is fixed */ + normalize_v3_v3(totmat[2], cob->matrix[2]); - /* the x axis gets mapped onto a third orthogonal vector */ - cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); - } + /* the x axis gets mapped onto a third orthogonal vector */ + cross_v3_v3v3(totmat[0], totmat[1], totmat[2]); + } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; + } } - } break; - default: - { - unit_m3(totmat); - } + default: + { + unit_m3(totmat); + } break; } /* Block to keep matrix heading */ @@ -2536,16 +2508,16 @@ static void locktrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * normalize_m3(tmpmat); invert_m3_m3(invmat, tmpmat); mul_m3_m3m3(tmpmat, totmat, invmat); - totmat[0][0] = tmpmat[0][0];totmat[0][1] = tmpmat[0][1];totmat[0][2] = tmpmat[0][2]; - totmat[1][0] = tmpmat[1][0];totmat[1][1] = tmpmat[1][1];totmat[1][2] = tmpmat[1][2]; - totmat[2][0] = tmpmat[2][0];totmat[2][1] = tmpmat[2][1];totmat[2][2] = tmpmat[2][2]; + totmat[0][0] = tmpmat[0][0]; totmat[0][1] = tmpmat[0][1]; totmat[0][2] = tmpmat[0][2]; + totmat[1][0] = tmpmat[1][0]; totmat[1][1] = tmpmat[1][1]; totmat[1][2] = tmpmat[1][2]; + totmat[2][0] = tmpmat[2][0]; totmat[2][1] = tmpmat[2][1]; totmat[2][2] = tmpmat[2][2]; copy_m4_m4(tmat, cob->matrix); mdet = determinant_m3(totmat[0][0], totmat[0][1], totmat[0][2], totmat[1][0], totmat[1][1], totmat[1][2], totmat[2][0], totmat[2][1], totmat[2][2]); - if (mdet==0) { + if (mdet == 0) { unit_m3(totmat); } @@ -2560,7 +2532,6 @@ static bConstraintTypeInfo CTI_LOCKTRACK = { "Locked Track", /* name */ "bLockTrackConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ locktrack_id_looper, /* id looper */ NULL, /* copy data */ locktrack_new_data, /* new data */ @@ -2572,25 +2543,25 @@ static bConstraintTypeInfo CTI_LOCKTRACK = { /* ---------- Limit Distance Constraint ----------- */ -static void distlimit_new_data (void *cdata) +static void distlimit_new_data(void *cdata) { - bDistLimitConstraint *data= (bDistLimitConstraint *)cdata; + bDistLimitConstraint *data = (bDistLimitConstraint *)cdata; - data->dist= 0.0f; + data->dist = 0.0f; } -static void distlimit_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void distlimit_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bDistLimitConstraint *data= con->data; + bDistLimitConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int distlimit_get_tars (bConstraint *con, ListBase *list) +static int distlimit_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bDistLimitConstraint *data= con->data; + bDistLimitConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2602,40 +2573,40 @@ static int distlimit_get_tars (bConstraint *con, ListBase *list) return 0; } -static void distlimit_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void distlimit_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bDistLimitConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bDistLimitConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void distlimit_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bDistLimitConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bDistLimitConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { - float dvec[3], dist=0.0f, sfac=1.0f; - short clamp_surf= 0; + float dvec[3], dist = 0.0f, sfac = 1.0f; + short clamp_surf = 0; /* calculate our current distance from the target */ - dist= len_v3v3(cob->matrix[3], ct->matrix[3]); + dist = len_v3v3(cob->matrix[3], ct->matrix[3]); /* set distance (flag is only set when user demands it) */ if (data->dist == 0) - data->dist= dist; + data->dist = dist; /* check if we're which way to clamp from, and calculate interpolation factor (if needed) */ if (data->mode == LIMITDIST_OUTSIDE) { /* if inside, then move to surface */ if (dist <= data->dist) { - clamp_surf= 1; - if (dist != 0.0f) sfac= data->dist / dist; + clamp_surf = 1; + if (dist != 0.0f) sfac = data->dist / dist; } /* if soft-distance is enabled, start fading once owner is dist+softdist from the target */ else if (data->flag & LIMITDIST_USESOFT) { @@ -2647,24 +2618,24 @@ static void distlimit_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * else if (data->mode == LIMITDIST_INSIDE) { /* if outside, then move to surface */ if (dist >= data->dist) { - clamp_surf= 1; - if (dist != 0.0f) sfac= data->dist / dist; + clamp_surf = 1; + if (dist != 0.0f) sfac = data->dist / dist; } /* if soft-distance is enabled, start fading once owner is dist-soft from the target */ else if (data->flag & LIMITDIST_USESOFT) { // FIXME: there's a problem with "jumping" when this kicks in if (dist >= (data->dist - data->soft)) { - sfac = (float)( data->soft*(1.0f - expf(-(dist - data->dist)/data->soft)) + data->dist ); + sfac = (float)(data->soft * (1.0f - expf(-(dist - data->dist) / data->soft)) + data->dist); if (dist != 0.0f) sfac /= dist; - clamp_surf= 1; + clamp_surf = 1; } } } else { - if (IS_EQF(dist, data->dist)==0) { - clamp_surf= 1; - if (dist != 0.0f) sfac= data->dist / dist; + if (IS_EQF(dist, data->dist) == 0) { + clamp_surf = 1; + if (dist != 0.0f) sfac = data->dist / dist; } } @@ -2685,7 +2656,6 @@ static bConstraintTypeInfo CTI_DISTLIMIT = { "Limit Distance", /* name */ "bDistLimitConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ distlimit_id_looper, /* id looper */ NULL, /* copy data */ distlimit_new_data, /* new data */ @@ -2697,9 +2667,9 @@ static bConstraintTypeInfo CTI_DISTLIMIT = { /* ---------- Stretch To ------------ */ -static void stretchto_new_data (void *cdata) +static void stretchto_new_data(void *cdata) { - bStretchToConstraint *data= (bStretchToConstraint *)cdata; + bStretchToConstraint *data = (bStretchToConstraint *)cdata; data->volmode = 0; data->plane = 0; @@ -2707,18 +2677,18 @@ static void stretchto_new_data (void *cdata) data->bulge = 1.0; } -static void stretchto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void stretchto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bStretchToConstraint *data= con->data; + bStretchToConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int stretchto_get_tars (bConstraint *con, ListBase *list) +static int stretchto_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bStretchToConstraint *data= con->data; + bStretchToConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2730,21 +2700,21 @@ static int stretchto_get_tars (bConstraint *con, ListBase *list) return 0; } -static void stretchto_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void stretchto_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bStretchToConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bStretchToConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void stretchto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bStretchToConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bStretchToConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -2780,40 +2750,40 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * if (data->bulge == 0) data->bulge = 1.0; - scale[1] = dist/data->orglength; + scale[1] = dist / data->orglength; switch (data->volmode) { - /* volume preserving scaling */ - case VOLUME_XZ : - scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge*(data->orglength/dist)); - scale[2] = scale[0]; - break; - case VOLUME_X: - scale[0] = 1.0f + data->bulge * (data->orglength /dist - 1); - scale[2] = 1.0; - break; - case VOLUME_Z: - scale[0] = 1.0; - scale[2] = 1.0f + data->bulge * (data->orglength /dist - 1); - break; + /* volume preserving scaling */ + case VOLUME_XZ: + scale[0] = 1.0f - (float)sqrt(data->bulge) + (float)sqrt(data->bulge * (data->orglength / dist)); + scale[2] = scale[0]; + break; + case VOLUME_X: + scale[0] = 1.0f + data->bulge * (data->orglength / dist - 1); + scale[2] = 1.0; + break; + case VOLUME_Z: + scale[0] = 1.0; + scale[2] = 1.0f + data->bulge * (data->orglength / dist - 1); + break; /* don't care for volume */ - case NO_VOLUME: - scale[0] = 1.0; - scale[2] = 1.0; - break; - default: /* should not happen, but in case*/ - return; + case NO_VOLUME: + scale[0] = 1.0; + scale[2] = 1.0; + break; + default: /* should not happen, but in case*/ + return; } /* switch (data->volmode) */ /* Clear the object's rotation and scale */ - cob->matrix[0][0]=size[0]*scale[0]; - cob->matrix[0][1]=0; - cob->matrix[0][2]=0; - cob->matrix[1][0]=0; - cob->matrix[1][1]=size[1]*scale[1]; - cob->matrix[1][2]=0; - cob->matrix[2][0]=0; - cob->matrix[2][1]=0; - cob->matrix[2][2]=size[2]*scale[2]; + cob->matrix[0][0] = size[0] * scale[0]; + cob->matrix[0][1] = 0; + cob->matrix[0][2] = 0; + cob->matrix[1][0] = 0; + cob->matrix[1][1] = size[1] * scale[1]; + cob->matrix[1][2] = 0; + cob->matrix[2][0] = 0; + cob->matrix[2][1] = 0; + cob->matrix[2][2] = size[2] * scale[2]; sub_v3_v3v3(vec, cob->matrix[3], ct->matrix[3]); normalize_v3(vec); @@ -2821,32 +2791,32 @@ static void stretchto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* new Y aligns object target connection*/ negate_v3_v3(totmat[1], vec); switch (data->plane) { - case PLANE_X: - /* build new Z vector */ - /* othogonal to "new Y" "old X! plane */ - cross_v3_v3v3(orth, vec, xx); - normalize_v3(orth); - - /* new Z*/ - copy_v3_v3(totmat[2], orth); - - /* we decided to keep X plane*/ - cross_v3_v3v3(xx, orth, vec); - normalize_v3_v3(totmat[0], xx); - break; - case PLANE_Z: - /* build new X vector */ - /* othogonal to "new Y" "old Z! plane */ - cross_v3_v3v3(orth, vec, zz); - normalize_v3(orth); - - /* new X */ - negate_v3_v3(totmat[0], orth); - - /* we decided to keep Z */ - cross_v3_v3v3(zz, orth, vec); - normalize_v3_v3(totmat[2], zz); - break; + case PLANE_X: + /* build new Z vector */ + /* othogonal to "new Y" "old X! plane */ + cross_v3_v3v3(orth, vec, xx); + normalize_v3(orth); + + /* new Z*/ + copy_v3_v3(totmat[2], orth); + + /* we decided to keep X plane*/ + cross_v3_v3v3(xx, orth, vec); + normalize_v3_v3(totmat[0], xx); + break; + case PLANE_Z: + /* build new X vector */ + /* othogonal to "new Y" "old Z! plane */ + cross_v3_v3v3(orth, vec, zz); + normalize_v3(orth); + + /* new X */ + negate_v3_v3(totmat[0], orth); + + /* we decided to keep Z */ + cross_v3_v3v3(zz, orth, vec); + normalize_v3_v3(totmat[2], zz); + break; } /* switch (data->plane) */ copy_m4_m4(tmat, cob->matrix); @@ -2860,7 +2830,6 @@ static bConstraintTypeInfo CTI_STRETCHTO = { "Stretch To", /* name */ "bStretchToConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ stretchto_id_looper, /* id looper */ NULL, /* copy data */ stretchto_new_data, /* new data */ @@ -2872,9 +2841,9 @@ static bConstraintTypeInfo CTI_STRETCHTO = { /* ---------- Floor ------------ */ -static void minmax_new_data (void *cdata) +static void minmax_new_data(void *cdata) { - bMinMaxConstraint *data= (bMinMaxConstraint *)cdata; + bMinMaxConstraint *data = (bMinMaxConstraint *)cdata; data->minmaxflag = TRACK_Z; data->offset = 0.0f; @@ -2882,18 +2851,18 @@ static void minmax_new_data (void *cdata) data->flag = 0; } -static void minmax_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void minmax_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bMinMaxConstraint *data= con->data; + bMinMaxConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int minmax_get_tars (bConstraint *con, ListBase *list) +static int minmax_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bMinMaxConstraint *data= con->data; + bMinMaxConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -2905,21 +2874,21 @@ static int minmax_get_tars (bConstraint *con, ListBase *list) return 0; } -static void minmax_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void minmax_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bMinMaxConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bMinMaxConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void minmax_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bMinMaxConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bMinMaxConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -2939,38 +2908,38 @@ static void minmax_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *tar } switch (data->minmaxflag) { - case TRACK_Z: - val1 = tarmat[3][2]; - val2 = obmat[3][2]-data->offset; - index = 2; - break; - case TRACK_Y: - val1 = tarmat[3][1]; - val2 = obmat[3][1]-data->offset; - index = 1; - break; - case TRACK_X: - val1 = tarmat[3][0]; - val2 = obmat[3][0]-data->offset; - index = 0; - break; - case TRACK_nZ: - val2 = tarmat[3][2]; - val1 = obmat[3][2]-data->offset; - index = 2; - break; - case TRACK_nY: - val2 = tarmat[3][1]; - val1 = obmat[3][1]-data->offset; - index = 1; - break; - case TRACK_nX: - val2 = tarmat[3][0]; - val1 = obmat[3][0]-data->offset; - index = 0; - break; - default: - return; + case TRACK_Z: + val1 = tarmat[3][2]; + val2 = obmat[3][2] - data->offset; + index = 2; + break; + case TRACK_Y: + val1 = tarmat[3][1]; + val2 = obmat[3][1] - data->offset; + index = 1; + break; + case TRACK_X: + val1 = tarmat[3][0]; + val2 = obmat[3][0] - data->offset; + index = 0; + break; + case TRACK_nZ: + val2 = tarmat[3][2]; + val1 = obmat[3][2] - data->offset; + index = 2; + break; + case TRACK_nY: + val2 = tarmat[3][1]; + val1 = obmat[3][1] - data->offset; + index = 1; + break; + case TRACK_nX: + val2 = tarmat[3][0]; + val1 = obmat[3][0] - data->offset; + index = 0; + break; + default: + return; } if (val1 > val2) { @@ -3005,7 +2974,6 @@ static bConstraintTypeInfo CTI_MINMAX = { "Floor", /* name */ "bMinMaxConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ minmax_id_looper, /* id looper */ NULL, /* copy data */ minmax_new_data, /* new data */ @@ -3017,27 +2985,27 @@ static bConstraintTypeInfo CTI_MINMAX = { /* ------- RigidBody Joint ---------- */ -static void rbj_new_data (void *cdata) +static void rbj_new_data(void *cdata) { - bRigidBodyJointConstraint *data= (bRigidBodyJointConstraint *)cdata; + bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint *)cdata; // removed code which set target of this constraint - data->type=1; + data->type = 1; } -static void rbj_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void rbj_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bRigidBodyJointConstraint *data= con->data; + bRigidBodyJointConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); - func(con, (ID**)&data->child, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); + func(con, (ID **)&data->child, FALSE, userdata); } -static int rbj_get_tars (bConstraint *con, ListBase *list) +static int rbj_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bRigidBodyJointConstraint *data= con->data; + bRigidBodyJointConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -3049,11 +3017,11 @@ static int rbj_get_tars (bConstraint *con, ListBase *list) return 0; } -static void rbj_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void rbj_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bRigidBodyJointConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bRigidBodyJointConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) @@ -3066,7 +3034,6 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = { "Rigid Body Joint", /* name */ "bRigidBodyJointConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ rbj_id_looper, /* id looper */ NULL, /* copy data */ rbj_new_data, /* new data */ @@ -3078,18 +3045,18 @@ static bConstraintTypeInfo CTI_RIGIDBODYJOINT = { /* -------- Clamp To ---------- */ -static void clampto_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void clampto_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bClampToConstraint *data= con->data; + bClampToConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int clampto_get_tars (bConstraint *con, ListBase *list) +static int clampto_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bClampToConstraint *data= con->data; + bClampToConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -3101,29 +3068,29 @@ static int clampto_get_tars (bConstraint *con, ListBase *list) return 0; } -static void clampto_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void clampto_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bClampToConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bClampToConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) } } -static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void clampto_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) */ /* only happens on reload file, but violates depsgraph still... fix! */ - if (cu->path==NULL || cu->path->data==NULL) - makeDispListCurveTypes(cob->scene, ct->tar, 0); + if (cu->path == NULL || cu->path->data == NULL) + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* technically, this isn't really needed for evaluation, but we don't know what else @@ -3133,23 +3100,23 @@ static void clampto_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bC unit_m4(ct->matrix); } -static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void clampto_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bClampToConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bClampToConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target and it is a curve */ if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_CURVE)) { - Curve *cu= data->tar->data; + Curve *cu = data->tar->data; float obmat[4][4], ownLoc[3]; float curveMin[3], curveMax[3]; - float targetMatrix[4][4]= MAT4_UNITY; + float targetMatrix[4][4] = MAT4_UNITY; copy_m4_m4(obmat, cob->matrix); copy_v3_v3(ownLoc, obmat[3]); INIT_MINMAX(curveMin, curveMax) - minmax_object(ct->tar, curveMin, curveMax); + BKE_object_minmax(ct->tar, curveMin, curveMax); /* get targetmatrix */ if (cu->path && cu->path->data) { @@ -3167,20 +3134,20 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta * extent. Otherwise, default to the x-axis, as that is quite * frequently used. */ - if ((size[2]>size[0]) && (size[2]>size[1])) - clamp_axis= CLAMPTO_Z - 1; - else if ((size[1]>size[0]) && (size[1]>size[2])) - clamp_axis= CLAMPTO_Y - 1; + if ((size[2] > size[0]) && (size[2] > size[1])) + clamp_axis = CLAMPTO_Z - 1; + else if ((size[1] > size[0]) && (size[1] > size[2])) + clamp_axis = CLAMPTO_Y - 1; else clamp_axis = CLAMPTO_X - 1; } else - clamp_axis= data->flag - 1; + clamp_axis = data->flag - 1; /* 2. determine position relative to curve on a 0-1 scale based on bounding box */ if (data->flag2 & CLAMPTO_CYCLIC) { /* cyclic, so offset within relative bounding box is used */ - float len= (curveMax[clamp_axis] - curveMin[clamp_axis]); + float len = (curveMax[clamp_axis] - curveMin[clamp_axis]); float offset; /* check to make sure len is not so close to zero that it'll cause errors */ @@ -3195,7 +3162,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta } else if (ownLoc[clamp_axis] > curveMax[clamp_axis]) { /* bounding-box range is after */ - offset= curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len; + offset = curveMax[clamp_axis] + (int)((ownLoc[clamp_axis] - curveMax[clamp_axis]) / len) * len; /* now, we calculate as per normal, except using offset instead of curveMax[clamp_axis] */ curvetime = (ownLoc[clamp_axis] - offset) / (len); @@ -3207,7 +3174,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta } else { /* as length is close to zero, curvetime by default should be 0 (i.e. the start) */ - curvetime= 0.0f; + curvetime = 0.0f; } } else { @@ -3216,7 +3183,7 @@ static void clampto_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *ta curvetime = 0.0f; else if (ownLoc[clamp_axis] >= curveMax[clamp_axis]) curvetime = 1.0f; - else if ( IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0 ) + else if (IS_EQ((curveMax[clamp_axis] - curveMin[clamp_axis]), 0) == 0) curvetime = (ownLoc[clamp_axis] - curveMin[clamp_axis]) / (curveMax[clamp_axis] - curveMin[clamp_axis]); else curvetime = 0.0f; @@ -3242,7 +3209,6 @@ static bConstraintTypeInfo CTI_CLAMPTO = { "Clamp To", /* name */ "bClampToConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ clampto_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -3254,27 +3220,27 @@ static bConstraintTypeInfo CTI_CLAMPTO = { /* ---------- Transform Constraint ----------- */ -static void transform_new_data (void *cdata) +static void transform_new_data(void *cdata) { - bTransformConstraint *data= (bTransformConstraint *)cdata; + bTransformConstraint *data = (bTransformConstraint *)cdata; - data->map[0]= 0; - data->map[1]= 1; - data->map[2]= 2; + data->map[0] = 0; + data->map[1] = 1; + data->map[2] = 2; } -static void transform_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void transform_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bTransformConstraint *data= con->data; + bTransformConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int transform_get_tars (bConstraint *con, ListBase *list) +static int transform_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bTransformConstraint *data= con->data; + bTransformConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -3286,21 +3252,21 @@ static int transform_get_tars (bConstraint *con, ListBase *list) return 0; } -static void transform_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void transform_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bTransformConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bTransformConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void transform_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bTransformConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bTransformConstraint *data = con->data; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -3329,21 +3295,21 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* determine where in range current transforms lie */ if (data->expo) { - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { if (data->from_max[i] - data->from_min[i]) - sval[i]= (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); + sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); else - sval[i]= 0.0f; + sval[i] = 0.0f; } } else { /* clamp transforms out of range */ - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { CLAMP(dvec[i], data->from_min[i], data->from_max[i]); if (data->from_max[i] - data->from_min[i]) - sval[i]= (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); + sval[i] = (dvec[i] - data->from_min[i]) / (data->from_max[i] - data->from_min[i]); else - sval[i]= 0.0f; + sval[i] = 0.0f; } } @@ -3351,18 +3317,18 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * /* apply transforms */ switch (data->to) { case 2: /* scaling */ - for (i=0; i<3; i++) - size[i]= data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])); + for (i = 0; i < 3; i++) + size[i] = data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i])); break; case 1: /* rotation */ - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { float tmin, tmax; - tmin= data->to_min[i]; - tmax= data->to_max[i]; + tmin = data->to_min[i]; + tmax = data->to_max[i]; /* all values here should be in degrees */ - eul[i]= tmin + (sval[(int)data->map[i]] * (tmax - tmin)); + eul[i] = tmin + (sval[(int)data->map[i]] * (tmax - tmin)); /* now convert final value back to radians */ eul[i] = DEG2RADF(eul[i]); @@ -3370,8 +3336,8 @@ static void transform_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * break; default: /* location */ /* get new location */ - for (i=0; i<3; i++) - loc[i]= (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]))); + for (i = 0; i < 3; i++) + loc[i] = (data->to_min[i] + (sval[(int)data->map[i]] * (data->to_max[i] - data->to_min[i]))); /* add original location back on (so that it can still be moved) */ add_v3_v3v3(loc, cob->matrix[3], loc); @@ -3389,7 +3355,6 @@ static bConstraintTypeInfo CTI_TRANSFORM = { "Transform", /* name */ "bTransformConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ transform_id_looper, /* id looper */ NULL, /* copy data */ transform_new_data, /* new data */ @@ -3401,15 +3366,15 @@ static bConstraintTypeInfo CTI_TRANSFORM = { /* ---------- Shrinkwrap Constraint ----------- */ -static void shrinkwrap_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void shrinkwrap_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bShrinkwrapConstraint *data= con->data; + bShrinkwrapConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->target, userdata); + func(con, (ID **)&data->target, FALSE, userdata); } -static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) +static int shrinkwrap_get_tars(bConstraint *con, ListBase *list) { if (con && list) { bShrinkwrapConstraint *data = con->data; @@ -3424,22 +3389,22 @@ static int shrinkwrap_get_tars (bConstraint *con, ListBase *list) } -static void shrinkwrap_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void shrinkwrap_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { bShrinkwrapConstraint *data = con->data; - bConstraintTarget *ct= list->first; + bConstraintTarget *ct = list->first; SINGLETARGETNS_FLUSH_TARS(con, data->target, ct, list, nocopy) } } -static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void shrinkwrap_get_tarmat(bConstraint *con, bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { bShrinkwrapConstraint *scon = (bShrinkwrapConstraint *) con->data; - if ( VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) { + if (VALID_CONS_TARGET(ct) && (ct->tar->type == OB_MESH) ) { int fail = FALSE; float co[3] = {0.0f, 0.0f, 0.0f}; float no[3] = {0.0f, 0.0f, 0.0f}; @@ -3450,7 +3415,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr BVHTreeRayHit hit; BVHTreeNearest nearest; - BVHTreeFromMesh treeData= {NULL}; + BVHTreeFromMesh treeData = {NULL}; nearest.index = -1; nearest.dist = FLT_MAX; @@ -3483,10 +3448,10 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr dist = len_v3v3(co, nearest.co); if (dist != 0.0f) { - interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist)/dist); /* linear interpolation */ + interp_v3_v3v3(co, co, nearest.co, (dist - scon->dist) / dist); /* linear interpolation */ } space_transform_invert(&transform, co); - break; + break; case MOD_SHRINKWRAP_PROJECT: if (scon->projAxis & MOD_SHRINKWRAP_PROJECT_OVER_X_AXIS) no[0] = 1.0f; @@ -3512,7 +3477,7 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr break; } copy_v3_v3(co, hit.co); - break; + break; } free_bvhtree_from_mesh(&treeData); @@ -3531,9 +3496,9 @@ static void shrinkwrap_get_tarmat (bConstraint *con, bConstraintOb *cob, bConstr } } -static void shrinkwrap_evaluate (bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) +static void shrinkwrap_evaluate(bConstraint *UNUSED(con), bConstraintOb *cob, ListBase *targets) { - bConstraintTarget *ct= targets->first; + bConstraintTarget *ct = targets->first; /* only evaluate if there is a target */ if (VALID_CONS_TARGET(ct)) { @@ -3547,7 +3512,6 @@ static bConstraintTypeInfo CTI_SHRINKWRAP = { "Shrinkwrap", /* name */ "bShrinkwrapConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ shrinkwrap_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ @@ -3559,25 +3523,25 @@ static bConstraintTypeInfo CTI_SHRINKWRAP = { /* --------- Damped Track ---------- */ -static void damptrack_new_data (void *cdata) +static void damptrack_new_data(void *cdata) { - bDampTrackConstraint *data= (bDampTrackConstraint *)cdata; + bDampTrackConstraint *data = (bDampTrackConstraint *)cdata; data->trackflag = TRACK_Y; } -static void damptrack_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void damptrack_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bDampTrackConstraint *data= con->data; + bDampTrackConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int damptrack_get_tars (bConstraint *con, ListBase *list) +static int damptrack_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bDampTrackConstraint *data= con->data; + bDampTrackConstraint *data = con->data; bConstraintTarget *ct; /* the following macro is used for all standard single-target constraints */ @@ -3589,11 +3553,11 @@ static int damptrack_get_tars (bConstraint *con, ListBase *list) return 0; } -static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void damptrack_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bDampTrackConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bDampTrackConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) @@ -3602,14 +3566,14 @@ static void damptrack_flush_tars (bConstraint *con, ListBase *list, short nocopy /* array of direction vectors for the tracking flags */ static const float track_dir_vecs[6][3] = { - {+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */ - {-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */ + {+1, 0, 0}, {0, +1, 0}, {0, 0, +1}, /* TRACK_X, TRACK_Y, TRACK_Z */ + {-1, 0, 0}, {0, -1, 0}, {0, 0, -1} /* TRACK_NX, TRACK_NY, TRACK_NZ */ }; -static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void damptrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bDampTrackConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bDampTrackConstraint *data = con->data; + bConstraintTarget *ct = targets->first; if (VALID_CONS_TARGET(ct)) { float obvec[3], tarvec[3], obloc[3]; @@ -3650,8 +3614,8 @@ static void damptrack_evaluate (bConstraint *con, bConstraintOb *cob, ListBase * */ cross_v3_v3v3(raxis, obvec, tarvec); - rangle= dot_v3v3(obvec, tarvec); - rangle= acos( MAX2(-1.0f, MIN2(1.0f, rangle)) ); + rangle = dot_v3v3(obvec, tarvec); + rangle = acos(MAX2(-1.0f, MIN2(1.0f, rangle)) ); /* construct rotation matrix from the axis-angle rotation found above * - this call takes care to make sure that the axis provided is a unit vector first @@ -3675,7 +3639,6 @@ static bConstraintTypeInfo CTI_DAMPTRACK = { "Damped Track", /* name */ "bDampTrackConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ damptrack_id_looper, /* id looper */ NULL, /* copy data */ damptrack_new_data, /* new data */ @@ -3687,43 +3650,43 @@ static bConstraintTypeInfo CTI_DAMPTRACK = { /* ----------- Spline IK ------------ */ -static void splineik_free (bConstraint *con) +static void splineik_free(bConstraint *con) { - bSplineIKConstraint *data= con->data; + bSplineIKConstraint *data = con->data; /* binding array */ if (data->points) MEM_freeN(data->points); } -static void splineik_copy (bConstraint *con, bConstraint *srccon) +static void splineik_copy(bConstraint *con, bConstraint *srccon) { - bSplineIKConstraint *src= srccon->data; - bSplineIKConstraint *dst= con->data; + bSplineIKConstraint *src = srccon->data; + bSplineIKConstraint *dst = con->data; /* copy the binding array */ - dst->points= MEM_dupallocN(src->points); + dst->points = MEM_dupallocN(src->points); } -static void splineik_new_data (void *cdata) +static void splineik_new_data(void *cdata) { - bSplineIKConstraint *data= (bSplineIKConstraint *)cdata; + bSplineIKConstraint *data = (bSplineIKConstraint *)cdata; - data->chainlen= 1; + data->chainlen = 1; } -static void splineik_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void splineik_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bSplineIKConstraint *data= con->data; + bSplineIKConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int splineik_get_tars (bConstraint *con, ListBase *list) +static int splineik_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bSplineIKConstraint *data= con->data; + bSplineIKConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints without subtargets */ @@ -3735,29 +3698,29 @@ static int splineik_get_tars (bConstraint *con, ListBase *list) return 0; } -static void splineik_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void splineik_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bSplineIKConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bSplineIKConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGETNS_FLUSH_TARS(con, data->tar, ct, list, nocopy) } } -static void splineik_get_tarmat (bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) +static void splineik_get_tarmat(bConstraint *UNUSED(con), bConstraintOb *cob, bConstraintTarget *ct, float UNUSED(ctime)) { if (VALID_CONS_TARGET(ct)) { - Curve *cu= ct->tar->data; + Curve *cu = ct->tar->data; /* note: when creating constraints that follow path, the curve gets the CU_PATH set now, * currently for paths to work it needs to go through the bevlist/displist system (ton) */ /* only happens on reload file, but violates depsgraph still... fix! */ - if (cu->path==NULL || cu->path->data==NULL) - makeDispListCurveTypes(cob->scene, ct->tar, 0); + if (cu->path == NULL || cu->path->data == NULL) + BKE_displist_make_curveTypes(cob->scene, ct->tar, 0); } /* technically, this isn't really needed for evaluation, but we don't know what else @@ -3773,7 +3736,6 @@ static bConstraintTypeInfo CTI_SPLINEIK = { "Spline IK", /* name */ "bSplineIKConstraint", /* struct name */ splineik_free, /* free data */ - NULL, /* relink data */ splineik_id_looper, /* id looper */ splineik_copy, /* copy data */ splineik_new_data, /* new data */ @@ -3785,18 +3747,18 @@ static bConstraintTypeInfo CTI_SPLINEIK = { /* ----------- Pivot ------------- */ -static void pivotcon_id_looper (bConstraint *con, ConstraintIDFunc func, void *userdata) +static void pivotcon_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bPivotConstraint *data= con->data; + bPivotConstraint *data = con->data; /* target only */ - func(con, (ID**)&data->tar, userdata); + func(con, (ID **)&data->tar, FALSE, userdata); } -static int pivotcon_get_tars (bConstraint *con, ListBase *list) +static int pivotcon_get_tars(bConstraint *con, ListBase *list) { if (con && list) { - bPivotConstraint *data= con->data; + bPivotConstraint *data = con->data; bConstraintTarget *ct; /* standard target-getting macro for single-target constraints */ @@ -3808,21 +3770,21 @@ static int pivotcon_get_tars (bConstraint *con, ListBase *list) return 0; } -static void pivotcon_flush_tars (bConstraint *con, ListBase *list, short nocopy) +static void pivotcon_flush_tars(bConstraint *con, ListBase *list, short nocopy) { if (con && list) { - bPivotConstraint *data= con->data; - bConstraintTarget *ct= list->first; + bPivotConstraint *data = con->data; + bConstraintTarget *ct = list->first; /* the following macro is used for all standard single-target constraints */ SINGLETARGET_FLUSH_TARS(con, data->tar, data->subtarget, ct, list, nocopy) } } -static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *targets) +static void pivotcon_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *targets) { - bPivotConstraint *data= con->data; - bConstraintTarget *ct= targets->first; + bPivotConstraint *data = con->data; + bConstraintTarget *ct = targets->first; float pivot[3], vec[3]; float rotMat[3][3]; @@ -3883,11 +3845,11 @@ static void pivotcon_evaluate (bConstraint *con, bConstraintOb *cob, ListBase *t } /* perform the pivoting... */ - /* 1. take the vector from owner to the pivot */ + /* 1. take the vector from owner to the pivot */ sub_v3_v3v3(vec, cob->matrix[3], pivot); - /* 2. rotate this vector by the rotation of the object... */ + /* 2. rotate this vector by the rotation of the object... */ mul_m3_v3(rotMat, vec); - /* 3. make the rotation in terms of the pivot now */ + /* 3. make the rotation in terms of the pivot now */ add_v3_v3v3(cob->matrix[3], pivot, vec); } @@ -3898,7 +3860,6 @@ static bConstraintTypeInfo CTI_PIVOT = { "Pivot", /* name */ "bPivotConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ pivotcon_id_looper, /* id looper */ NULL, /* copy data */ NULL, /* new data */ // XXX: might be needed to get 'normal' pivot behavior... @@ -3922,9 +3883,9 @@ static void followtrack_id_looper(bConstraint *con, ConstraintIDFunc func, void { bFollowTrackConstraint *data = con->data; - func(con, (ID**)&data->clip, userdata); - func(con, (ID**)&data->camera, userdata); - func(con, (ID**)&data->depth_ob, userdata); + func(con, (ID **)&data->clip, TRUE, userdata); + func(con, (ID **)&data->camera, FALSE, userdata); + func(con, (ID **)&data->depth_ob, FALSE, userdata); } static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -3935,10 +3896,10 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase MovieTracking *tracking; MovieTrackingTrack *track; MovieTrackingObject *tracking_object; - Object *camob= data->camera ? data->camera : scene->camera; + Object *camob = data->camera ? data->camera : scene->camera; if (data->flag & FOLLOWTRACK_ACTIVECLIP) - clip= scene->clip; + clip = scene->clip; if (!clip || !data->track[0] || !camob) return; @@ -3964,7 +3925,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase copy_m4_m4(obmat, cob->matrix); - if ((tracking_object->flag & TRACKING_OBJECT_CAMERA)==0) { + if ((tracking_object->flag & TRACKING_OBJECT_CAMERA) == 0) { float imat[4][4]; copy_m4_m4(mat, camob->obmat); @@ -3986,10 +3947,10 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase else { MovieTrackingMarker *marker; float vec[3], disp[3], axis[3], mat[4][4]; - float aspect= (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); + float aspect = (scene->r.xsch * scene->r.xasp) / (scene->r.ysch * scene->r.yasp); float len, d; - where_is_object_mat(scene, camob, mat); + BKE_object_where_is_calc_mat4(scene, camob, mat); /* camera axis */ vec[0] = 0.0f; @@ -4034,7 +3995,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase copy_v3_v3(cob->matrix[3], disp); } else { - d= (len * params.sensor_x) / (2.0f * params.lens); + d = (len * params.sensor_x) / (2.0f * params.lens); vec[0] = d * (2.0f * (pos[0] + params.shiftx) - 1.0f); vec[1] = d * (2.0f * (pos[1] + params.shifty) - 1.0f); @@ -4092,7 +4053,6 @@ static bConstraintTypeInfo CTI_FOLLOWTRACK = { "Follow Track", /* name */ "bFollowTrackConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ followtrack_id_looper, /* id looper */ NULL, /* copy data */ followtrack_new_data, /* new data */ @@ -4116,7 +4076,7 @@ static void camerasolver_id_looper(bConstraint *con, ConstraintIDFunc func, void { bCameraSolverConstraint *data = con->data; - func(con, (ID**)&data->clip, userdata); + func(con, (ID **)&data->clip, TRUE, userdata); } static void camerasolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -4147,7 +4107,6 @@ static bConstraintTypeInfo CTI_CAMERASOLVER = { "Camera Solver", /* name */ "bCameraSolverConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ camerasolver_id_looper, /* id looper */ NULL, /* copy data */ camerasolver_new_data, /* new data */ @@ -4170,10 +4129,10 @@ static void objectsolver_new_data(void *cdata) static void objectsolver_id_looper(bConstraint *con, ConstraintIDFunc func, void *userdata) { - bObjectSolverConstraint *data= con->data; + bObjectSolverConstraint *data = con->data; - func(con, (ID**)&data->clip, userdata); - func(con, (ID**)&data->camera, userdata); + func(con, (ID **)&data->clip, FALSE, userdata); + func(con, (ID **)&data->camera, FALSE, userdata); } static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase *UNUSED(targets)) @@ -4184,7 +4143,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase Object *camob = data->camera ? data->camera : scene->camera; if (data->flag & OBJECTSOLVER_ACTIVECLIP) - clip= scene->clip; + clip = scene->clip; if (!camob || !clip) return; @@ -4198,7 +4157,7 @@ static void objectsolver_evaluate(bConstraint *con, bConstraintOb *cob, ListBase if (object) { float mat[4][4], obmat[4][4], imat[4][4], cammat[4][4], camimat[4][4], parmat[4][4]; - where_is_object_mat(scene, camob, cammat); + BKE_object_where_is_calc_mat4(scene, camob, cammat); BKE_tracking_get_interpolated_camera(tracking, object, scene->r.cfra, mat); @@ -4221,7 +4180,6 @@ static bConstraintTypeInfo CTI_OBJECTSOLVER = { "Object Solver", /* name */ "bObjectSolverConstraint", /* struct name */ NULL, /* free data */ - NULL, /* relink data */ objectsolver_id_looper, /* id looper */ NULL, /* copy data */ objectsolver_new_data, /* new data */ @@ -4238,46 +4196,46 @@ static bConstraintTypeInfo CTI_OBJECTSOLVER = { /* These globals only ever get directly accessed in this file */ static bConstraintTypeInfo *constraintsTypeInfo[NUM_CONSTRAINT_TYPES]; -static short CTI_INIT= 1; /* when non-zero, the list needs to be updated */ +static short CTI_INIT = 1; /* when non-zero, the list needs to be updated */ /* This function only gets called when CTI_INIT is non-zero */ -static void constraints_init_typeinfo (void) +static void constraints_init_typeinfo(void) { - constraintsTypeInfo[0]= NULL; /* 'Null' Constraint */ - constraintsTypeInfo[1]= &CTI_CHILDOF; /* ChildOf Constraint */ - constraintsTypeInfo[2]= &CTI_TRACKTO; /* TrackTo Constraint */ - constraintsTypeInfo[3]= &CTI_KINEMATIC; /* IK Constraint */ - constraintsTypeInfo[4]= &CTI_FOLLOWPATH; /* Follow-Path Constraint */ - constraintsTypeInfo[5]= &CTI_ROTLIMIT; /* Limit Rotation Constraint */ - constraintsTypeInfo[6]= &CTI_LOCLIMIT; /* Limit Location Constraint */ - constraintsTypeInfo[7]= &CTI_SIZELIMIT; /* Limit Scaling Constraint */ - constraintsTypeInfo[8]= &CTI_ROTLIKE; /* Copy Rotation Constraint */ - constraintsTypeInfo[9]= &CTI_LOCLIKE; /* Copy Location Constraint */ - constraintsTypeInfo[10]= &CTI_SIZELIKE; /* Copy Scaling Constraint */ - constraintsTypeInfo[11]= &CTI_PYTHON; /* Python/Script Constraint */ - constraintsTypeInfo[12]= &CTI_ACTION; /* Action Constraint */ - constraintsTypeInfo[13]= &CTI_LOCKTRACK; /* Locked-Track Constraint */ - constraintsTypeInfo[14]= &CTI_DISTLIMIT; /* Limit Distance Constraint */ - constraintsTypeInfo[15]= &CTI_STRETCHTO; /* StretchTo Constaint */ - constraintsTypeInfo[16]= &CTI_MINMAX; /* Floor Constraint */ - constraintsTypeInfo[17]= &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */ - constraintsTypeInfo[18]= &CTI_CLAMPTO; /* ClampTo Constraint */ - constraintsTypeInfo[19]= &CTI_TRANSFORM; /* Transformation Constraint */ - constraintsTypeInfo[20]= &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */ - constraintsTypeInfo[21]= &CTI_DAMPTRACK; /* Damped TrackTo Constraint */ - constraintsTypeInfo[22]= &CTI_SPLINEIK; /* Spline IK Constraint */ - constraintsTypeInfo[23]= &CTI_TRANSLIKE; /* Copy Transforms Constraint */ - constraintsTypeInfo[24]= &CTI_SAMEVOL; /* Maintain Volume Constraint */ - constraintsTypeInfo[25]= &CTI_PIVOT; /* Pivot Constraint */ - constraintsTypeInfo[26]= &CTI_FOLLOWTRACK; /* Follow Track Constraint */ - constraintsTypeInfo[27]= &CTI_CAMERASOLVER; /* Camera Solver Constraint */ - constraintsTypeInfo[28]= &CTI_OBJECTSOLVER; /* Object Solver Constraint */ + constraintsTypeInfo[0] = NULL; /* 'Null' Constraint */ + constraintsTypeInfo[1] = &CTI_CHILDOF; /* ChildOf Constraint */ + constraintsTypeInfo[2] = &CTI_TRACKTO; /* TrackTo Constraint */ + constraintsTypeInfo[3] = &CTI_KINEMATIC; /* IK Constraint */ + constraintsTypeInfo[4] = &CTI_FOLLOWPATH; /* Follow-Path Constraint */ + constraintsTypeInfo[5] = &CTI_ROTLIMIT; /* Limit Rotation Constraint */ + constraintsTypeInfo[6] = &CTI_LOCLIMIT; /* Limit Location Constraint */ + constraintsTypeInfo[7] = &CTI_SIZELIMIT; /* Limit Scaling Constraint */ + constraintsTypeInfo[8] = &CTI_ROTLIKE; /* Copy Rotation Constraint */ + constraintsTypeInfo[9] = &CTI_LOCLIKE; /* Copy Location Constraint */ + constraintsTypeInfo[10] = &CTI_SIZELIKE; /* Copy Scaling Constraint */ + constraintsTypeInfo[11] = &CTI_PYTHON; /* Python/Script Constraint */ + constraintsTypeInfo[12] = &CTI_ACTION; /* Action Constraint */ + constraintsTypeInfo[13] = &CTI_LOCKTRACK; /* Locked-Track Constraint */ + constraintsTypeInfo[14] = &CTI_DISTLIMIT; /* Limit Distance Constraint */ + constraintsTypeInfo[15] = &CTI_STRETCHTO; /* StretchTo Constaint */ + constraintsTypeInfo[16] = &CTI_MINMAX; /* Floor Constraint */ + constraintsTypeInfo[17] = &CTI_RIGIDBODYJOINT; /* RigidBody Constraint */ + constraintsTypeInfo[18] = &CTI_CLAMPTO; /* ClampTo Constraint */ + constraintsTypeInfo[19] = &CTI_TRANSFORM; /* Transformation Constraint */ + constraintsTypeInfo[20] = &CTI_SHRINKWRAP; /* Shrinkwrap Constraint */ + constraintsTypeInfo[21] = &CTI_DAMPTRACK; /* Damped TrackTo Constraint */ + constraintsTypeInfo[22] = &CTI_SPLINEIK; /* Spline IK Constraint */ + constraintsTypeInfo[23] = &CTI_TRANSLIKE; /* Copy Transforms Constraint */ + constraintsTypeInfo[24] = &CTI_SAMEVOL; /* Maintain Volume Constraint */ + constraintsTypeInfo[25] = &CTI_PIVOT; /* Pivot Constraint */ + constraintsTypeInfo[26] = &CTI_FOLLOWTRACK; /* Follow Track Constraint */ + constraintsTypeInfo[27] = &CTI_CAMERASOLVER; /* Camera Solver Constraint */ + constraintsTypeInfo[28] = &CTI_OBJECTSOLVER; /* Object Solver Constraint */ } /* This function should be used for getting the appropriate type-info when only * a constraint type is known */ -bConstraintTypeInfo *get_constraint_typeinfo (int type) +bConstraintTypeInfo *get_constraint_typeinfo(int type) { /* initialize the type-info list? */ if (CTI_INIT) { @@ -4287,7 +4245,7 @@ bConstraintTypeInfo *get_constraint_typeinfo (int type) /* only return for valid types */ if ( (type >= CONSTRAINT_TYPE_NULL) && - (type < NUM_CONSTRAINT_TYPES ) ) + (type < NUM_CONSTRAINT_TYPES) ) { /* there shouldn't be any segfaults here... */ return constraintsTypeInfo[type]; @@ -4302,7 +4260,7 @@ bConstraintTypeInfo *get_constraint_typeinfo (int type) /* This function should always be used to get the appropriate type-info, as it * has checks which prevent segfaults in some weird cases. */ -bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con) +bConstraintTypeInfo *constraint_get_typeinfo(bConstraint *con) { /* only return typeinfo for valid constraints */ if (con) @@ -4318,17 +4276,31 @@ bConstraintTypeInfo *constraint_get_typeinfo (bConstraint *con) /* ---------- Data Management ------- */ +/* helper function for free_constraint_data() - unlinks references */ +static void con_unlink_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData)) +{ + if (*idpoin && isReference) + id_us_min(*idpoin); +} + /* Free data of a specific constraint if it has any info. * be sure to run BIK_clear_data() when freeing an IK constraint, - * unless DAG_scene_sort is called. */ + * unless DAG_scene_sort is called. + */ void free_constraint_data(bConstraint *con) { if (con->data) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); - /* perform any special freeing constraint may have */ - if (cti && cti->free_data) - cti->free_data(con); + if (cti) { + /* perform any special freeing constraint may have */ + if (cti->free_data) + cti->free_data(con); + + /* unlink the referenced resources it uses */ + if (cti->id_looper) + cti->id_looper(con, con_unlink_refs_cb, NULL); + } /* free constraint data now */ MEM_freeN(con->data); @@ -4341,7 +4313,7 @@ void free_constraints(ListBase *list) bConstraint *con; /* Free constraint data and also any extra data */ - for (con= list->first; con; con= con->next) + for (con = list->first; con; con = con->next) free_constraint_data(con); /* Free the whole list */ @@ -4370,8 +4342,8 @@ void remove_constraints_type(ListBase *list, short type, short last_only) return; /* remove from the end of the list to make it faster to find the last instance */ - for (con= list->last; con; con= conp) { - conp= con->prev; + for (con = list->last; con; con = conp) { + conp = con->prev; if (con->type == type) { remove_constraint(list, con); @@ -4384,10 +4356,10 @@ void remove_constraints_type(ListBase *list, short type, short last_only) /* ......... */ /* Creates a new constraint, initializes its data, and returns it */ -static bConstraint *add_new_constraint_internal (const char *name, short type) +static bConstraint *add_new_constraint_internal(const char *name, short type) { - bConstraint *con= MEM_callocN(sizeof(bConstraint), "Constraint"); - bConstraintTypeInfo *cti= get_constraint_typeinfo(type); + bConstraint *con = MEM_callocN(sizeof(bConstraint), "Constraint"); + bConstraintTypeInfo *cti = get_constraint_typeinfo(type); const char *newName; /* Set up a generic constraint datablock */ @@ -4405,12 +4377,12 @@ static bConstraint *add_new_constraint_internal (const char *name, short type) cti->new_data(con->data); /* if no name is provided, use the type of the constraint as the name */ - newName= (name && name[0]) ? name : cti->name; + newName = (name && name[0]) ? name : cti->name; } else { /* if no name is provided, use the generic "Const" name */ // NOTE: any constraint type that gets here really shouldn't get added... - newName= (name && name[0]) ? name : "Const"; + newName = (name && name[0]) ? name : "Const"; } /* copy the name */ @@ -4421,13 +4393,13 @@ static bConstraint *add_new_constraint_internal (const char *name, short type) } /* if pchan is not NULL then assume we're adding a pose constraint */ -static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type) +static bConstraint *add_new_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type) { bConstraint *con; ListBase *list; /* add the constraint */ - con= add_new_constraint_internal(name, type); + con = add_new_constraint_internal(name, type); /* find the constraint stack - bone or object? */ list = (pchan) ? (&pchan->constraints) : (&ob->constraints); @@ -4462,7 +4434,7 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c con->flag |= CONSTRAINT_SPACEONCE; } } - break; + break; } return con; @@ -4471,7 +4443,7 @@ static bConstraint *add_new_constraint (Object *ob, bPoseChannel *pchan, const c /* ......... */ /* Add new constraint for the given bone */ -bConstraint *add_pose_constraint (Object *ob, bPoseChannel *pchan, const char *name, short type) +bConstraint *add_pose_constraint(Object *ob, bPoseChannel *pchan, const char *name, short type) { if (pchan == NULL) return NULL; @@ -4487,43 +4459,34 @@ bConstraint *add_ob_constraint(Object *ob, const char *name, short type) /* ......... */ +/* helper for relink_constraints() - call ID_NEW() on every ID reference the constraint has */ +static void con_relink_id_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userdata)) +{ + /* ID_NEW() expects a struct with inline "id" member as first + * since we've got the actual ID block, let's just inline this + * code. + * + * See ID_NEW(a) in BKE_utildefines.h + */ + if ((*idpoin) && (*idpoin)->newid) + (*idpoin) = (void *)(*idpoin)->newid; +} + /* Reassign links that constraints have to other data (called during file loading?) */ void relink_constraints(ListBase *conlist) { - bConstraint *con; - bConstraintTarget *ct; - - for (con= conlist->first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); - - if (cti) { - /* relink any targets */ - if (cti->get_constraint_targets) { - ListBase targets = {NULL, NULL}; - - cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { - ID_NEW(ct->tar); - } - - if (cti->flush_constraint_targets) - cti->flush_constraint_targets(con, &targets, 0); - } - - /* relink any other special data */ - if (cti->relink_data) - cti->relink_data(con); - } - } + /* just a wrapper around ID-loop for just calling ID_NEW() on all ID refs */ + id_loop_constraints(conlist, con_relink_id_cb, NULL); } + /* Run the given callback on all ID-blocks in list of constraints */ void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdata) { bConstraint *con; - for (con= conlist->first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = conlist->first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (cti) { if (cti->id_looper) @@ -4535,22 +4498,30 @@ void id_loop_constraints(ListBase *conlist, ConstraintIDFunc func, void *userdat /* ......... */ /* helper for copy_constraints(), to be used for making sure that ID's are valid */ -static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, void *UNUSED(userData)) +static void con_extern_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *UNUSED(userData)) { if (*idpoin && (*idpoin)->lib) id_lib_extern(*idpoin); } +/* helper for copy_constraints(), to be used for making sure that usercounts of copied ID's are fixed up */ +static void con_fix_copied_refs_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *UNUSED(userData)) +{ + /* increment usercount if this is a reference type */ + if ((*idpoin) && (isReference)) + id_us_plus(*idpoin); +} + /* duplicate all of the constraints in a constraint stack */ void copy_constraints(ListBase *dst, const ListBase *src, int do_extern) { bConstraint *con, *srccon; - dst->first= dst->last= NULL; + dst->first = dst->last = NULL; BLI_duplicatelist(dst, src); - for (con=dst->first, srccon=src->first; con && srccon; srccon=srccon->next, con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = dst->first, srccon = src->first; con && srccon; srccon = srccon->next, con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); /* make a new copy of the constraint's data */ con->data = MEM_dupallocN(con->data); @@ -4560,6 +4531,10 @@ void copy_constraints(ListBase *dst, const ListBase *src, int do_extern) /* perform custom copying operations if needed */ if (cti->copy_data) cti->copy_data(con, srccon); + + /* fix usercounts for all referenced data in referenced data */ + if (cti->id_looper) + cti->id_looper(con, con_fix_copied_refs_cb, NULL); /* for proxies we don't want to make extern */ if (do_extern) { @@ -4579,13 +4554,13 @@ bConstraint *constraints_findByName(ListBase *list, const char *name) } /* finds the 'active' constraint in a constraint stack */ -bConstraint *constraints_get_active (ListBase *list) +bConstraint *constraints_get_active(ListBase *list) { bConstraint *con; /* search for the first constraint with the 'active' flag set */ if (list) { - for (con= list->first; con; con= con->next) { + for (con = list->first; con; con = con->next) { if (con->flag & CONSTRAINT_ACTIVE) return con; } @@ -4601,7 +4576,7 @@ void constraints_set_active(ListBase *list, bConstraint *con) bConstraint *c; if (list) { - for (c= list->first; c; c= c->next) { + for (c = list->first; c; c = c->next) { if (c == con) c->flag |= CONSTRAINT_ACTIVE; else @@ -4618,8 +4593,8 @@ void extract_proxylocal_constraints(ListBase *dst, ListBase *src) bConstraint *con, *next; /* for each tagged constraint, remove from src and move to dst */ - for (con= src->first; con; con= next) { - next= con->next; + for (con = src->first; con; con = next) { + next = con->next; /* check if tagged */ if (con->flag & CONSTRAINT_PROXY_LOCAL) { @@ -4635,7 +4610,7 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan) /* Currently, constraints can only be on object or bone level */ if (ob && ob->proxy) { if (ob->pose && pchan) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; /* On bone-level, check if bone is on proxy-protected layer */ if ((pchan->bone) && (pchan->bone->layer & arm->layer_protected)) @@ -4661,21 +4636,21 @@ short proxylocked_constraints_owner(Object *ob, bPoseChannel *pchan) */ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, short ownertype, void *ownerdata, float mat[][4], float ctime) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintOb *cob; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { /* make 'constraint-ob' */ - cob= MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb"); - cob->type= ownertype; + cob = MEM_callocN(sizeof(bConstraintOb), "tempConstraintOb"); + cob->type = ownertype; cob->scene = scene; switch (ownertype) { case CONSTRAINT_OBTYPE_OBJECT: /* it is usually this case */ { - cob->ob= (Object *)ownerdata; - cob->pchan= NULL; + cob->ob = (Object *)ownerdata; + cob->pchan = NULL; if (cob->ob) { copy_m4_m4(cob->matrix, cob->ob->obmat); copy_m4_m4(cob->startmat, cob->matrix); @@ -4685,11 +4660,11 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, unit_m4(cob->startmat); } } - break; + break; case CONSTRAINT_OBTYPE_BONE: /* this may occur in some cases */ { - cob->ob= NULL; /* this might not work at all :/ */ - cob->pchan= (bPoseChannel *)ownerdata; + cob->ob = NULL; /* this might not work at all :/ */ + cob->pchan = (bPoseChannel *)ownerdata; if (cob->pchan) { copy_m4_m4(cob->matrix, cob->pchan->pose_mat); copy_m4_m4(cob->startmat, cob->matrix); @@ -4699,16 +4674,16 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, unit_m4(cob->startmat); } } - break; + break; } /* get targets - we only need the first one though (and there should only be one) */ cti->get_constraint_targets(con, &targets); /* only calculate the target matrix on the first target */ - ct= (bConstraintTarget *)targets.first; + ct = (bConstraintTarget *)targets.first; while (ct && n-- > 0) - ct= ct->next; + ct = ct->next; if (ct) { if (cti->get_target_matrix) @@ -4730,26 +4705,26 @@ void get_constraint_target_matrix(struct Scene *scene, bConstraint *con, int n, /* Get the list of targets required for solving a constraint */ void get_constraint_targets_for_solving(bConstraint *con, bConstraintOb *cob, ListBase *targets, float ctime) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (cti && cti->get_constraint_targets) { bConstraintTarget *ct; /* get targets - * - constraints should use ct->matrix, not directly accessing values + * - constraints should use ct->matrix, not directly accessing values * - ct->matrix members have not yet been calculated here! */ cti->get_constraint_targets(con, targets); /* set matrices - * - calculate if possible, otherwise just initialize as identity matrix + * - calculate if possible, otherwise just initialize as identity matrix */ if (cti->get_target_matrix) { - for (ct= targets->first; ct; ct= ct->next) + for (ct = targets->first; ct; ct = ct->next) cti->get_target_matrix(con, cob, ct, ctime); } else { - for (ct= targets->first; ct; ct= ct->next) + for (ct = targets->first; ct; ct = ct->next) unit_m4(ct->matrix); } } @@ -4774,20 +4749,20 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime) return; /* loop over available constraints, solving and blending them */ - for (con= conlist->first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = conlist->first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; /* these we can skip completely (invalid constraints...) */ if (cti == NULL) continue; - if (con->flag & (CONSTRAINT_DISABLE|CONSTRAINT_OFF)) continue; + if (con->flag & (CONSTRAINT_DISABLE | CONSTRAINT_OFF)) continue; /* these constraints can't be evaluated anyway */ if (cti->evaluate_constraint == NULL) continue; /* influence == 0 should be ignored */ if (con->enforce == 0.0f) continue; /* influence of constraint - * - value should have been set from animation data already + * - value should have been set from animation data already */ enf = con->enforce; @@ -4816,9 +4791,9 @@ void solve_constraints(ListBase *conlist, bConstraintOb *cob, float ctime) constraint_mat_convertspace(cob->ob, cob->pchan, cob->matrix, con->ownspace, CONSTRAINT_SPACE_WORLD); /* Interpolate the enforcement, to blend result of constraint into final owner transform - * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), - * since some constraints may not convert the solution back to the input space before blending - * but all are guaranteed to end up in good "worldspace" result + * - all this happens in worldspace to prevent any weirdness creeping in ([#26014] and [#25725]), + * since some constraints may not convert the solution back to the input space before blending + * but all are guaranteed to end up in good "worldspace" result */ /* Note: all kind of stuff here before (caused trouble), much easier to just interpolate, or did I miss something? -jahka */ if (enf < 1.0f) { diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c index bd47e7cbd37..d736309f605 100644 --- a/source/blender/blenkernel/intern/context.c +++ b/source/blender/blenkernel/intern/context.c @@ -92,14 +92,14 @@ bContext *CTX_create(void) { bContext *C; - C= MEM_callocN(sizeof(bContext), "bContext"); + C = MEM_callocN(sizeof(bContext), "bContext"); return C; } bContext *CTX_copy(const bContext *C) { - bContext *newC= MEM_dupallocN((void*)C); + bContext *newC = MEM_dupallocN((void *)C); return newC; } @@ -118,23 +118,23 @@ bContextStore *CTX_store_add(ListBase *contexts, const char *name, PointerRNA *p /* ensure we have a context to put the entry in, if it was already used * we have to copy the context to ensure */ - ctx= contexts->last; + ctx = contexts->last; if (!ctx || ctx->used) { if (ctx) { - lastctx= ctx; - ctx= MEM_dupallocN(lastctx); + lastctx = ctx; + ctx = MEM_dupallocN(lastctx); BLI_duplicatelist(&ctx->entries, &lastctx->entries); } else - ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); + ctx = MEM_callocN(sizeof(bContextStore), "bContextStore"); BLI_addtail(contexts, ctx); } - entry= MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry"); + entry = MEM_callocN(sizeof(bContextStoreEntry), "bContextStoreEntry"); BLI_strncpy(entry->name, name, sizeof(entry->name)); - entry->ptr= *ptr; + entry->ptr = *ptr; BLI_addtail(&ctx->entries, entry); @@ -148,22 +148,22 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context) /* ensure we have a context to put the entries in, if it was already used * we have to copy the context to ensure */ - ctx= contexts->last; + ctx = contexts->last; if (!ctx || ctx->used) { if (ctx) { - lastctx= ctx; - ctx= MEM_dupallocN(lastctx); + lastctx = ctx; + ctx = MEM_dupallocN(lastctx); BLI_duplicatelist(&ctx->entries, &lastctx->entries); } else - ctx= MEM_callocN(sizeof(bContextStore), "bContextStore"); + ctx = MEM_callocN(sizeof(bContextStore), "bContextStore"); BLI_addtail(contexts, ctx); } - for (tentry= context->entries.first; tentry; tentry= tentry->next) { - entry= MEM_dupallocN(tentry); + for (tentry = context->entries.first; tentry; tentry = tentry->next) { + entry = MEM_dupallocN(tentry); BLI_addtail(&ctx->entries, entry); } @@ -172,14 +172,14 @@ bContextStore *CTX_store_add_all(ListBase *contexts, bContextStore *context) void CTX_store_set(bContext *C, bContextStore *store) { - C->wm.store= store; + C->wm.store = store; } bContextStore *CTX_store_copy(bContextStore *store) { bContextStore *ctx; - ctx= MEM_dupallocN(store); + ctx = MEM_dupallocN(store); BLI_duplicatelist(&ctx->entries, &store->entries); return ctx; @@ -195,7 +195,7 @@ void CTX_store_free_list(ListBase *contexts) { bContextStore *ctx; - while ((ctx= contexts->first)) { + while ((ctx = contexts->first)) { BLI_remlink(contexts, ctx); CTX_store_free(ctx); } @@ -209,7 +209,7 @@ int CTX_py_init_get(bContext *C) } void CTX_py_init_set(bContext *C, int value) { - C->data.py_init= value; + C->data.py_init = value; } void *CTX_py_dict_get(const bContext *C) @@ -218,7 +218,7 @@ void *CTX_py_dict_get(const bContext *C) } void CTX_py_dict_set(bContext *C, void *value) { - C->data.py_context= value; + C->data.py_context = value; } /* data context utility functions */ @@ -237,8 +237,8 @@ static void *ctx_wm_python_context_get(const bContext *C, const char *member, vo if (C && CTX_py_dict_get(C)) { memset(&result, 0, sizeof(bContextDataResult)); - BPY_context_member_get((bContext*)C, member, &result); - if(result.ptr.data) + BPY_context_member_get((bContext *)C, member, &result); + if (result.ptr.data) return result.ptr.data; } #endif @@ -251,8 +251,8 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res bScreen *sc; ScrArea *sa; ARegion *ar; - int done= 0, recursion= C->data.recursion; - int ret= 0; + int done = 0, recursion = C->data.recursion; + int ret = 0; memset(result, 0, sizeof(bContextDataResult)); #ifdef WITH_PYTHON @@ -271,42 +271,42 @@ static int ctx_data_get(bContext *C, const char *member, bContextDataResult *res * Values in order of importance * (0, -1, 1) - Where 1 is highest priority * */ - if (done!=1 && recursion < 1 && C->wm.store) { + if (done != 1 && recursion < 1 && C->wm.store) { bContextStoreEntry *entry; - C->data.recursion= 1; + C->data.recursion = 1; - entry= BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); + entry = BLI_rfindstring(&C->wm.store->entries, member, offsetof(bContextStoreEntry, name)); if (entry) { - result->ptr= entry->ptr; - done= 1; + result->ptr = entry->ptr; + done = 1; } } - if (done!=1 && recursion < 2 && (ar=CTX_wm_region(C))) { - C->data.recursion= 2; + if (done != 1 && recursion < 2 && (ar = CTX_wm_region(C))) { + C->data.recursion = 2; if (ar->type && ar->type->context) { ret = ar->type->context(C, member, result); - if (ret) done= -(-ret | -done); + if (ret) done = -(-ret | -done); } } - if (done!=1 && recursion < 3 && (sa=CTX_wm_area(C))) { - C->data.recursion= 3; + if (done != 1 && recursion < 3 && (sa = CTX_wm_area(C))) { + C->data.recursion = 3; if (sa->type && sa->type->context) { ret = sa->type->context(C, member, result); - if (ret) done= -(-ret | -done); + if (ret) done = -(-ret | -done); } } - if (done!=1 && recursion < 4 && (sc=CTX_wm_screen(C))) { - bContextDataCallback cb= sc->context; - C->data.recursion= 4; + if (done != 1 && recursion < 4 && (sc = CTX_wm_screen(C))) { + bContextDataCallback cb = sc->context; + C->data.recursion = 4; if (cb) { ret = cb(C, member, result); - if (ret) done= -(-ret | -done); + if (ret) done = -(-ret | -done); } } - C->data.recursion= recursion; + C->data.recursion = recursion; return done; } @@ -315,7 +315,7 @@ static void *ctx_data_pointer_get(const bContext *C, const char *member) { bContextDataResult result; - if (C && ctx_data_get((bContext*)C, member, &result)==1) + if (C && ctx_data_get((bContext *)C, member, &result) == 1) return result.ptr.data; return NULL; @@ -327,15 +327,15 @@ static int ctx_data_pointer_verify(const bContext *C, const char *member, void * /* if context is NULL, pointer must be NULL too and that is a valid return */ if (C == NULL) { - *pointer= NULL; + *pointer = NULL; return 1; } - else if (ctx_data_get((bContext*)C, member, &result)==1) { - *pointer= result.ptr.data; + else if (ctx_data_get((bContext *)C, member, &result) == 1) { + *pointer = result.ptr.data; return 1; } else { - *pointer= NULL; + *pointer = NULL; return 0; } } @@ -344,13 +344,13 @@ static int ctx_data_collection_get(const bContext *C, const char *member, ListBa { bContextDataResult result; - if (ctx_data_get((bContext*)C, member, &result)==1) { - *list= result.list; + if (ctx_data_get((bContext *)C, member, &result) == 1) { + *list = result.list; return 1; } - list->first= NULL; - list->last= NULL; + list->first = NULL; + list->last = NULL; return 0; } @@ -359,7 +359,7 @@ PointerRNA CTX_data_pointer_get(const bContext *C, const char *member) { bContextDataResult result; - if (ctx_data_get((bContext*)C, member, &result)==1) + if (ctx_data_get((bContext *)C, member, &result) == 1) return result.ptr; else return PointerRNA_NULL; @@ -379,11 +379,11 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) { bContextDataResult result; - if (ctx_data_get((bContext*)C, member, &result)==1) { + if (ctx_data_get((bContext *)C, member, &result) == 1) { return result.list; } else { - ListBase list= {NULL, NULL}; + ListBase list = {NULL, NULL}; return list; } } @@ -392,17 +392,17 @@ ListBase CTX_data_collection_get(const bContext *C, const char *member) int CTX_data_get(const bContext *C, const char *member, PointerRNA *r_ptr, ListBase *r_lb, short *r_type) { bContextDataResult result; - int ret= ctx_data_get((bContext*)C, member, &result); + int ret = ctx_data_get((bContext *)C, member, &result); - if (ret==1) { - *r_ptr= result.ptr; - *r_lb= result.list; - *r_type= result.type; + if (ret == 1) { + *r_ptr = result.ptr; + *r_lb = result.list; + *r_type = result.type; } else { memset(r_ptr, 0, sizeof(*r_ptr)); memset(r_lb, 0, sizeof(*r_lb)); - *r_type= 0; + *r_type = 0; } return ret; @@ -418,8 +418,8 @@ static void data_dir_add(ListBase *lb, const char *member) if (BLI_findstring(lb, member, offsetof(LinkData, data))) return; - link= MEM_callocN(sizeof(LinkData), "LinkData"); - link->data= (void*)member; + link = MEM_callocN(sizeof(LinkData), "LinkData"); + link->data = (void *)member; BLI_addtail(lb, link); } @@ -437,32 +437,32 @@ ListBase CTX_data_dir_get(const bContext *C) if (C->wm.store) { bContextStoreEntry *entry; - for (entry=C->wm.store->entries.first; entry; entry=entry->next) + for (entry = C->wm.store->entries.first; entry; entry = entry->next) data_dir_add(&lb, entry->name); } - if ((ar=CTX_wm_region(C)) && ar->type && ar->type->context) { + if ((ar = CTX_wm_region(C)) && ar->type && ar->type->context) { memset(&result, 0, sizeof(result)); ar->type->context(C, "", &result); if (result.dir) - for (a=0; result.dir[a]; a++) + for (a = 0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } - if ((sa=CTX_wm_area(C)) && sa->type && sa->type->context) { + if ((sa = CTX_wm_area(C)) && sa->type && sa->type->context) { memset(&result, 0, sizeof(result)); sa->type->context(C, "", &result); if (result.dir) - for (a=0; result.dir[a]; a++) + for (a = 0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } - if ((sc=CTX_wm_screen(C)) && sc->context) { - bContextDataCallback cb= sc->context; + if ((sc = CTX_wm_screen(C)) && sc->context) { + bContextDataCallback cb = sc->context; memset(&result, 0, sizeof(result)); cb(C, "", &result); if (result.dir) - for (a=0; result.dir[a]; a++) + for (a = 0; result.dir[a]; a++) data_dir_add(&lb, result.dir[a]); } @@ -493,7 +493,7 @@ void CTX_data_id_list_add(bContextDataResult *result, ID *id) { CollectionPointerLink *link; - link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add"); + link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_id_list_add"); RNA_id_pointer_create(id, &link->ptr); BLI_addtail(&result->list, link); @@ -503,18 +503,18 @@ void CTX_data_list_add(bContextDataResult *result, ID *id, StructRNA *type, void { CollectionPointerLink *link; - link= MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add"); + link = MEM_callocN(sizeof(CollectionPointerLink), "CTX_data_list_add"); RNA_pointer_create(id, type, data, &link->ptr); BLI_addtail(&result->list, link); } -int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase*)) +int ctx_data_list_count(const bContext *C, int (*func)(const bContext *, ListBase *)) { ListBase list; if (func(C, &list)) { - int tot= BLI_countlist(&list); + int tot = BLI_countlist(&list); BLI_freelistN(&list); return tot; } @@ -524,12 +524,12 @@ int ctx_data_list_count(const bContext *C, int (*func)(const bContext*, ListBase void CTX_data_dir_set(bContextDataResult *result, const char **dir) { - result->dir= dir; + result->dir = dir; } void CTX_data_type_set(bContextDataResult *result, short type) { - result->type= type; + result->type = type; } short CTX_data_type_get(bContextDataResult *result) @@ -564,7 +564,7 @@ ScrArea *CTX_wm_area(const bContext *C) SpaceLink *CTX_wm_space_data(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - return (sa)? sa->spacedata.first: NULL; + return (sa) ? sa->spacedata.first : NULL; } ARegion *CTX_wm_region(const bContext *C) @@ -575,7 +575,7 @@ ARegion *CTX_wm_region(const bContext *C) void *CTX_wm_region_data(const bContext *C) { ARegion *ar = CTX_wm_region(C); - return (ar)? ar->regiondata: NULL; + return (ar) ? ar->regiondata : NULL; } struct ARegion *CTX_wm_menu(const bContext *C) @@ -594,7 +594,7 @@ struct ReportList *CTX_wm_reports(const bContext *C) View3D *CTX_wm_view3d(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_VIEW3D) + if (sa && sa->spacetype == SPACE_VIEW3D) return sa->spacedata.first; return NULL; } @@ -604,7 +604,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C) ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); - if (sa && sa->spacetype==SPACE_VIEW3D) + if (sa && sa->spacetype == SPACE_VIEW3D) if (ar) return ar->regiondata; return NULL; @@ -613,7 +613,7 @@ RegionView3D *CTX_wm_region_view3d(const bContext *C) struct SpaceText *CTX_wm_space_text(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_TEXT) + if (sa && sa->spacetype == SPACE_TEXT) return sa->spacedata.first; return NULL; } @@ -621,7 +621,7 @@ struct SpaceText *CTX_wm_space_text(const bContext *C) struct SpaceConsole *CTX_wm_space_console(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_CONSOLE) + if (sa && sa->spacetype == SPACE_CONSOLE) return sa->spacedata.first; return NULL; } @@ -629,7 +629,7 @@ struct SpaceConsole *CTX_wm_space_console(const bContext *C) struct SpaceImage *CTX_wm_space_image(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_IMAGE) + if (sa && sa->spacetype == SPACE_IMAGE) return sa->spacedata.first; return NULL; } @@ -637,7 +637,7 @@ struct SpaceImage *CTX_wm_space_image(const bContext *C) struct SpaceButs *CTX_wm_space_buts(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_BUTS) + if (sa && sa->spacetype == SPACE_BUTS) return sa->spacedata.first; return NULL; } @@ -645,7 +645,7 @@ struct SpaceButs *CTX_wm_space_buts(const bContext *C) struct SpaceFile *CTX_wm_space_file(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_FILE) + if (sa && sa->spacetype == SPACE_FILE) return sa->spacedata.first; return NULL; } @@ -653,7 +653,7 @@ struct SpaceFile *CTX_wm_space_file(const bContext *C) struct SpaceSeq *CTX_wm_space_seq(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_SEQ) + if (sa && sa->spacetype == SPACE_SEQ) return sa->spacedata.first; return NULL; } @@ -661,7 +661,7 @@ struct SpaceSeq *CTX_wm_space_seq(const bContext *C) struct SpaceOops *CTX_wm_space_outliner(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_OUTLINER) + if (sa && sa->spacetype == SPACE_OUTLINER) return sa->spacedata.first; return NULL; } @@ -669,7 +669,7 @@ struct SpaceOops *CTX_wm_space_outliner(const bContext *C) struct SpaceNla *CTX_wm_space_nla(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_NLA) + if (sa && sa->spacetype == SPACE_NLA) return sa->spacedata.first; return NULL; } @@ -677,7 +677,7 @@ struct SpaceNla *CTX_wm_space_nla(const bContext *C) struct SpaceTime *CTX_wm_space_time(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_TIME) + if (sa && sa->spacetype == SPACE_TIME) return sa->spacedata.first; return NULL; } @@ -685,7 +685,7 @@ struct SpaceTime *CTX_wm_space_time(const bContext *C) struct SpaceNode *CTX_wm_space_node(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_NODE) + if (sa && sa->spacetype == SPACE_NODE) return sa->spacedata.first; return NULL; } @@ -693,7 +693,7 @@ struct SpaceNode *CTX_wm_space_node(const bContext *C) struct SpaceLogic *CTX_wm_space_logic(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_LOGIC) + if (sa && sa->spacetype == SPACE_LOGIC) return sa->spacedata.first; return NULL; } @@ -701,7 +701,7 @@ struct SpaceLogic *CTX_wm_space_logic(const bContext *C) struct SpaceIpo *CTX_wm_space_graph(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_IPO) + if (sa && sa->spacetype == SPACE_IPO) return sa->spacedata.first; return NULL; } @@ -709,7 +709,7 @@ struct SpaceIpo *CTX_wm_space_graph(const bContext *C) struct SpaceAction *CTX_wm_space_action(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_ACTION) + if (sa && sa->spacetype == SPACE_ACTION) return sa->spacedata.first; return NULL; } @@ -717,7 +717,7 @@ struct SpaceAction *CTX_wm_space_action(const bContext *C) struct SpaceInfo *CTX_wm_space_info(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_INFO) + if (sa && sa->spacetype == SPACE_INFO) return sa->spacedata.first; return NULL; } @@ -725,7 +725,7 @@ struct SpaceInfo *CTX_wm_space_info(const bContext *C) struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_USERPREF) + if (sa && sa->spacetype == SPACE_USERPREF) return sa->spacedata.first; return NULL; } @@ -733,58 +733,58 @@ struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C) struct SpaceClip *CTX_wm_space_clip(const bContext *C) { ScrArea *sa = CTX_wm_area(C); - if (sa && sa->spacetype==SPACE_CLIP) + if (sa && sa->spacetype == SPACE_CLIP) return sa->spacedata.first; return NULL; } void CTX_wm_manager_set(bContext *C, wmWindowManager *wm) { - C->wm.manager= wm; - C->wm.window= NULL; - C->wm.screen= NULL; - C->wm.area= NULL; - C->wm.region= NULL; + C->wm.manager = wm; + C->wm.window = NULL; + C->wm.screen = NULL; + C->wm.area = NULL; + C->wm.region = NULL; } void CTX_wm_window_set(bContext *C, wmWindow *win) { - C->wm.window= win; - C->wm.screen= (win)? win->screen: NULL; + C->wm.window = win; + C->wm.screen = (win) ? win->screen : NULL; if (C->wm.screen) - C->data.scene= C->wm.screen->scene; - C->wm.area= NULL; - C->wm.region= NULL; + C->data.scene = C->wm.screen->scene; + C->wm.area = NULL; + C->wm.region = NULL; } void CTX_wm_screen_set(bContext *C, bScreen *screen) { - C->wm.screen= screen; + C->wm.screen = screen; if (C->wm.screen) - C->data.scene= C->wm.screen->scene; - C->wm.area= NULL; - C->wm.region= NULL; + C->data.scene = C->wm.screen->scene; + C->wm.area = NULL; + C->wm.region = NULL; } void CTX_wm_area_set(bContext *C, ScrArea *area) { - C->wm.area= area; - C->wm.region= NULL; + C->wm.area = area; + C->wm.region = NULL; } void CTX_wm_region_set(bContext *C, ARegion *region) { - C->wm.region= region; + C->wm.region = region; } void CTX_wm_menu_set(bContext *C, ARegion *menu) { - C->wm.menu= menu; + C->wm.menu = menu; } void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg) { - C->wm.operator_poll_msg= msg; + C->wm.operator_poll_msg = msg; } const char *CTX_wm_operator_poll_msg_get(bContext *C) @@ -798,7 +798,7 @@ Main *CTX_data_main(const bContext *C) { Main *bmain; - if (ctx_data_pointer_verify(C, "blend_data", (void*)&bmain)) + if (ctx_data_pointer_verify(C, "blend_data", (void *)&bmain)) return bmain; else return C->data.main; @@ -806,14 +806,14 @@ Main *CTX_data_main(const bContext *C) void CTX_data_main_set(bContext *C, Main *bmain) { - C->data.main= bmain; + C->data.main = bmain; } Scene *CTX_data_scene(const bContext *C) { Scene *scene; - if (ctx_data_pointer_verify(C, "scene", (void*)&scene)) + if (ctx_data_pointer_verify(C, "scene", (void *)&scene)) return scene; else return C->data.scene; @@ -821,7 +821,7 @@ Scene *CTX_data_scene(const bContext *C) int CTX_data_mode_enum(const bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit) { switch (obedit->type) { @@ -846,7 +846,7 @@ int CTX_data_mode_enum(const bContext *C) if (ob) { if (ob->mode & OB_MODE_POSE) return CTX_MODE_POSE; - else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; + else if (ob->mode & OB_MODE_SCULPT) return CTX_MODE_SCULPT; else if (ob->mode & OB_MODE_WEIGHT_PAINT) return CTX_MODE_PAINT_WEIGHT; else if (ob->mode & OB_MODE_VERTEX_PAINT) return CTX_MODE_PAINT_VERTEX; else if (ob->mode & OB_MODE_TEXTURE_PAINT) return CTX_MODE_PAINT_TEXTURE; @@ -884,7 +884,7 @@ const char *CTX_data_mode_string(const bContext *C) void CTX_data_scene_set(bContext *C, Scene *scene) { - C->data.scene= scene; + C->data.scene = scene; } ToolSettings *CTX_data_tool_settings(const bContext *C) diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 85e3d85dfc4..43cc63aefa6 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -32,7 +32,7 @@ #include // floor #include -#include +#include #include "MEM_guardedalloc.h" @@ -42,24 +42,24 @@ #include "BLI_utildefines.h" #include "BLI_ghash.h" -#include "DNA_curve_types.h" -#include "DNA_material_types.h" +#include "DNA_curve_types.h" +#include "DNA_material_types.h" /* for dereferencing pointers */ -#include "DNA_key_types.h" -#include "DNA_scene_types.h" -#include "DNA_vfont_types.h" +#include "DNA_key_types.h" +#include "DNA_scene_types.h" +#include "DNA_vfont_types.h" #include "DNA_object_types.h" #include "BKE_animsys.h" -#include "BKE_anim.h" -#include "BKE_curve.h" -#include "BKE_displist.h" -#include "BKE_font.h" -#include "BKE_global.h" -#include "BKE_key.h" -#include "BKE_library.h" -#include "BKE_main.h" +#include "BKE_anim.h" +#include "BKE_curve.h" +#include "BKE_displist.h" +#include "BKE_font.h" +#include "BKE_global.h" +#include "BKE_key.h" +#include "BKE_library.h" +#include "BKE_main.h" #include "BKE_object.h" #include "BKE_material.h" @@ -73,42 +73,53 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c void BKE_curve_unlink(Curve *cu) { int a; - - for (a=0; atotcol; a++) { + + for (a = 0; a < cu->totcol; a++) { if (cu->mat[a]) cu->mat[a]->id.us--; - cu->mat[a]= NULL; + cu->mat[a] = NULL; } - if (cu->vfont) cu->vfont->id.us--; - cu->vfont= NULL; + if (cu->vfont) + cu->vfont->id.us--; + cu->vfont = NULL; - if (cu->vfontb) cu->vfontb->id.us--; - cu->vfontb= NULL; + if (cu->vfontb) + cu->vfontb->id.us--; + cu->vfontb = NULL; - if (cu->vfonti) cu->vfonti->id.us--; - cu->vfonti= NULL; + if (cu->vfonti) + cu->vfonti->id.us--; + cu->vfonti = NULL; - if (cu->vfontbi) cu->vfontbi->id.us--; - cu->vfontbi= NULL; - - if (cu->key) cu->key->id.us--; - cu->key= NULL; + if (cu->vfontbi) + cu->vfontbi->id.us--; + cu->vfontbi = NULL; + + if (cu->key) + cu->key->id.us--; + cu->key = NULL; } /* frees editcurve entirely */ void BKE_curve_editfont_free(Curve *cu) { if (cu->editfont) { - EditFont *ef= cu->editfont; - - if (ef->oldstr) MEM_freeN(ef->oldstr); - if (ef->oldstrinfo) MEM_freeN(ef->oldstrinfo); - if (ef->textbuf) MEM_freeN(ef->textbuf); - if (ef->textbufinfo) MEM_freeN(ef->textbufinfo); - if (ef->copybuf) MEM_freeN(ef->copybuf); - if (ef->copybufinfo) MEM_freeN(ef->copybufinfo); - + EditFont *ef = cu->editfont; + + if (ef->oldstr) + MEM_freeN(ef->oldstr); + if (ef->oldstrinfo) + MEM_freeN(ef->oldstrinfo); + if (ef->textbuf) + MEM_freeN(ef->textbuf); + if (ef->textbufinfo) + MEM_freeN(ef->textbufinfo); + if (ef->copybuf) + MEM_freeN(ef->copybuf); + if (ef->copybufinfo) + MEM_freeN(ef->copybufinfo); + MEM_freeN(ef); - cu->editfont= NULL; + cu->editfont = NULL; } } @@ -118,7 +129,7 @@ void BKE_curve_editNurb_keyIndex_free(EditNurb *editnurb) return; } BLI_ghash_free(editnurb->keyindex, NULL, (GHashValFreeFP)MEM_freeN); - editnurb->keyindex= NULL; + editnurb->keyindex = NULL; } void BKE_curve_editNurb_free(Curve *cu) @@ -127,7 +138,7 @@ void BKE_curve_editNurb_free(Curve *cu) BKE_nurbList_free(&cu->editnurb->nurbs); BKE_curve_editNurb_keyIndex_free(cu->editnurb); MEM_freeN(cu->editnurb); - cu->editnurb= NULL; + cu->editnurb = NULL; } } @@ -136,56 +147,63 @@ void BKE_curve_free(Curve *cu) { BKE_nurbList_free(&cu->nurb); BLI_freelistN(&cu->bev); - freedisplist(&cu->disp); + BKE_displist_free(&cu->disp); BKE_curve_editfont_free(cu); BKE_curve_editNurb_free(cu); BKE_curve_unlink(cu); BKE_free_animdata((ID *)cu); - - if (cu->mat) MEM_freeN(cu->mat); - if (cu->str) MEM_freeN(cu->str); - if (cu->strinfo) MEM_freeN(cu->strinfo); - if (cu->bb) MEM_freeN(cu->bb); - if (cu->path) free_path(cu->path); - if (cu->tb) MEM_freeN(cu->tb); + + if (cu->mat) + MEM_freeN(cu->mat); + if (cu->str) + MEM_freeN(cu->str); + if (cu->strinfo) + MEM_freeN(cu->strinfo); + if (cu->bb) + MEM_freeN(cu->bb); + if (cu->path) + free_path(cu->path); + if (cu->tb) + MEM_freeN(cu->tb); } Curve *BKE_curve_add(const char *name, int type) { Curve *cu; - cu = alloc_libblock(&G.main->curve, ID_CU, name); + cu = BKE_libblock_alloc(&G.main->curve, ID_CU, name); copy_v3_fl(cu->size, 1.0f); - cu->flag= CU_FRONT|CU_BACK|CU_DEFORM_BOUNDS_OFF|CU_PATH_RADIUS; - cu->pathlen= 100; - cu->resolu= cu->resolv= (type == OB_SURF) ? 4 : 12; - cu->width= 1.0; + cu->flag = CU_FRONT | CU_BACK | CU_DEFORM_BOUNDS_OFF | CU_PATH_RADIUS; + cu->pathlen = 100; + cu->resolu = cu->resolv = (type == OB_SURF) ? 4 : 12; + cu->width = 1.0; cu->wordspace = 1.0; - cu->spacing= cu->linedist= 1.0; - cu->fsize= 1.0; - cu->ulheight = 0.05; - cu->texflag= CU_AUTOSPACE; - cu->smallcaps_scale= 0.75f; - cu->twist_mode= CU_TWIST_MINIMUM; // XXX: this one seems to be the best one in most cases, at least for curve deform... - cu->type= type; - cu->bevfac1= 0.0f; - cu->bevfac2= 1.0f; - - cu->bb= unit_boundbox(); - - if (type==OB_FONT) { - cu->vfont= cu->vfontb= cu->vfonti= cu->vfontbi= get_builtin_font(); - cu->vfont->id.us+=4; - cu->str= MEM_mallocN(12, "str"); + cu->spacing = cu->linedist = 1.0; + cu->fsize = 1.0; + cu->ulheight = 0.05; + cu->texflag = CU_AUTOSPACE; + cu->smallcaps_scale = 0.75f; + /* XXX: this one seems to be the best one in most cases, at least for curve deform... */ + cu->twist_mode = CU_TWIST_MINIMUM; + cu->type = type; + cu->bevfac1 = 0.0f; + cu->bevfac2 = 1.0f; + + cu->bb = BKE_boundbox_alloc_unit(); + + if (type == OB_FONT) { + cu->vfont = cu->vfontb = cu->vfonti = cu->vfontbi = BKE_vfont_builtin_get(); + cu->vfont->id.us += 4; + cu->str = MEM_mallocN(12, "str"); BLI_strncpy(cu->str, "Text", 12); - cu->len= cu->pos= 4; - cu->strinfo= MEM_callocN(12*sizeof(CharInfo), "strinfo new"); - cu->totbox= cu->actbox= 1; - cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "textbox"); + cu->len = cu->pos = 4; + cu->strinfo = MEM_callocN(12 * sizeof(CharInfo), "strinfo new"); + cu->totbox = cu->actbox = 1; + cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "textbox"); cu->tb[0].w = cu->tb[0].h = 0.0; } - + return cu; } @@ -193,52 +211,52 @@ Curve *BKE_curve_copy(Curve *cu) { Curve *cun; int a; - - cun= copy_libblock(&cu->id); - cun->nurb.first= cun->nurb.last= NULL; + + cun = BKE_libblock_copy(&cu->id); + cun->nurb.first = cun->nurb.last = NULL; BKE_nurbList_duplicate(&(cun->nurb), &(cu->nurb)); - cun->mat= MEM_dupallocN(cu->mat); - for (a=0; atotcol; a++) { + cun->mat = MEM_dupallocN(cu->mat); + for (a = 0; a < cun->totcol; a++) { id_us_plus((ID *)cun->mat[a]); } - - cun->str= MEM_dupallocN(cu->str); - cun->strinfo= MEM_dupallocN(cu->strinfo); - cun->tb= MEM_dupallocN(cu->tb); - cun->bb= MEM_dupallocN(cu->bb); - - cun->key= copy_key(cu->key); - if (cun->key) cun->key->from= (ID *)cun; - - cun->disp.first= cun->disp.last= NULL; - cun->bev.first= cun->bev.last= NULL; - cun->path= NULL; - cun->editnurb= NULL; - cun->editfont= NULL; - cun->selboxes= NULL; + cun->str = MEM_dupallocN(cu->str); + cun->strinfo = MEM_dupallocN(cu->strinfo); + cun->tb = MEM_dupallocN(cu->tb); + cun->bb = MEM_dupallocN(cu->bb); -#if 0 // XXX old animation system + cun->key = BKE_key_copy(cu->key); + if (cun->key) cun->key->from = (ID *)cun; + + cun->disp.first = cun->disp.last = NULL; + cun->bev.first = cun->bev.last = NULL; + cun->path = NULL; + + cun->editnurb = NULL; + cun->editfont = NULL; + cun->selboxes = NULL; + +#if 0 // XXX old animation system /* single user ipo too */ - if (cun->ipo) cun->ipo= copy_ipo(cun->ipo); + if (cun->ipo) cun->ipo = copy_ipo(cun->ipo); #endif // XXX old animation system id_us_plus((ID *)cun->vfont); - id_us_plus((ID *)cun->vfontb); + id_us_plus((ID *)cun->vfontb); id_us_plus((ID *)cun->vfonti); id_us_plus((ID *)cun->vfontbi); - + return cun; } static void extern_local_curve(Curve *cu) -{ +{ id_lib_extern((ID *)cu->vfont); - id_lib_extern((ID *)cu->vfontb); + id_lib_extern((ID *)cu->vfontb); id_lib_extern((ID *)cu->vfonti); id_lib_extern((ID *)cu->vfontbi); - + if (cu->mat) { extern_local_matarar(cu->mat, cu->totcol); } @@ -246,27 +264,28 @@ static void extern_local_curve(Curve *cu) void BKE_curve_make_local(Curve *cu) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; - + int is_local = FALSE, is_lib = FALSE; + /* - when there are only lib users: don't do * - when there are only local users: set flag * - mixed: do a copy */ - - if (cu->id.lib==NULL) return; - if (cu->id.us==1) { + if (cu->id.lib == NULL) + return; + + if (cu->id.us == 1) { id_clear_lib_data(bmain, &cu->id); extern_local_curve(cu); return; } - for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { if (ob->data == cu) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -275,15 +294,15 @@ void BKE_curve_make_local(Curve *cu) extern_local_curve(cu); } else if (is_local && is_lib) { - Curve *cu_new= BKE_curve_copy(cu); - cu_new->id.us= 0; + Curve *cu_new = BKE_curve_copy(cu); + cu_new->id.us = 0; BKE_id_lib_local_paths(bmain, cu->id.lib, &cu_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { - if (ob->data==cu) { - if (ob->id.lib==NULL) { - ob->data= cu_new; + for (ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->data == cu) { + if (ob->id.lib == NULL) { + ob->data = cu_new; cu_new->id.us++; cu->id.us--; } @@ -305,18 +324,18 @@ ListBase *BKE_curve_editNurbs_get(Curve *cu) short BKE_curve_type_get(Curve *cu) { Nurb *nu; - int type= cu->type; + int type = cu->type; if (cu->vfont) { return OB_FONT; } if (!cu->type) { - type= OB_CURVE; + type = OB_CURVE; - for (nu= cu->nurb.first; nu; nu= nu->next) { - if (nu->pntsv>1) { - type= OB_SURF; + for (nu = cu->nurb.first; nu; nu = nu->next) { + if (nu->pntsv > 1) { + type = OB_SURF; } } } @@ -326,16 +345,16 @@ short BKE_curve_type_get(Curve *cu) void BKE_curve_curve_dimension_update(Curve *cu) { - ListBase *nurbs= BKE_curve_nurbs_get(cu); - Nurb *nu= nurbs->first; + ListBase *nurbs = BKE_curve_nurbs_get(cu); + Nurb *nu = nurbs->first; - if (cu->flag&CU_3D) { - for ( ; nu; nu= nu->next) { + if (cu->flag & CU_3D) { + for (; nu; nu = nu->next) { nu->flag &= ~CU_2D; } } else { - for ( ; nu; nu= nu->next) { + for (; nu; nu = nu->next) { nu->flag |= CU_2D; BKE_nurb_test2D(nu); @@ -348,36 +367,36 @@ void BKE_curve_curve_dimension_update(Curve *cu) void BKE_curve_type_test(Object *ob) { - ob->type= BKE_curve_type_get(ob->data); + ob->type = BKE_curve_type_get(ob->data); - if (ob->type==OB_CURVE) + if (ob->type == OB_CURVE) BKE_curve_curve_dimension_update((Curve *)ob->data); } -void BKE_curve_tex_space_calc(Curve *cu) +void BKE_curve_texspace_calc(Curve *cu) { DispList *dl; BoundBox *bb; float *fp, min[3], max[3]; - int tot, doit= 0; - - if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= cu->bb; - + int tot, doit = 0; + + if (cu->bb == NULL) + cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = cu->bb; + INIT_MINMAX(min, max); - dl= cu->disp.first; + dl = cu->disp.first; while (dl) { - tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts; - if (tot) doit= 1; - fp= dl->verts; + if (tot) doit = 1; + fp = dl->verts; while (tot--) { DO_MINMAX(fp, min, max); fp += 3; } - dl= dl->next; + dl = dl->next; } if (!doit) { @@ -385,27 +404,27 @@ void BKE_curve_tex_space_calc(Curve *cu) max[0] = max[1] = max[2] = 1.0f; } - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); if (cu->texflag & CU_AUTOSPACE) { mid_v3_v3v3(cu->loc, min, max); - cu->size[0]= (max[0]-min[0])/2.0f; - cu->size[1]= (max[1]-min[1])/2.0f; - cu->size[2]= (max[2]-min[2])/2.0f; + cu->size[0] = (max[0] - min[0]) / 2.0f; + cu->size[1] = (max[1] - min[1]) / 2.0f; + cu->size[2] = (max[2] - min[2]) / 2.0f; zero_v3(cu->rot); - if (cu->size[0]==0.0f) cu->size[0]= 1.0f; - else if (cu->size[0]>0.0f && cu->size[0]<0.00001f) cu->size[0]= 0.00001f; - else if (cu->size[0]<0.0f && cu->size[0]> -0.00001f) cu->size[0]= -0.00001f; - - if (cu->size[1]==0.0f) cu->size[1]= 1.0f; - else if (cu->size[1]>0.0f && cu->size[1]<0.00001f) cu->size[1]= 0.00001f; - else if (cu->size[1]<0.0f && cu->size[1]> -0.00001f) cu->size[1]= -0.00001f; - - if (cu->size[2]==0.0f) cu->size[2]= 1.0f; - else if (cu->size[2]>0.0f && cu->size[2]<0.00001f) cu->size[2]= 0.00001f; - else if (cu->size[2]<0.0f && cu->size[2]> -0.00001f) cu->size[2]= -0.00001f; + if (cu->size[0] == 0.0f) cu->size[0] = 1.0f; + else if (cu->size[0] > 0.0f && cu->size[0] < 0.00001f) cu->size[0] = 0.00001f; + else if (cu->size[0] < 0.0f && cu->size[0] > -0.00001f) cu->size[0] = -0.00001f; + + if (cu->size[1] == 0.0f) cu->size[1] = 1.0f; + else if (cu->size[1] > 0.0f && cu->size[1] < 0.00001f) cu->size[1] = 0.00001f; + else if (cu->size[1] < 0.0f && cu->size[1] > -0.00001f) cu->size[1] = -0.00001f; + + if (cu->size[2] == 0.0f) cu->size[2] = 1.0f; + else if (cu->size[2] > 0.0f && cu->size[2] < 0.00001f) cu->size[2] = 0.00001f; + else if (cu->size[2] < 0.0f && cu->size[2] > -0.00001f) cu->size[2] = -0.00001f; } } @@ -413,14 +432,16 @@ void BKE_curve_tex_space_calc(Curve *cu) int BKE_nurbList_verts_count(ListBase *nurb) { Nurb *nu; - int tot=0; - - nu= nurb->first; + int tot = 0; + + nu = nurb->first; while (nu) { - if (nu->bezt) tot+= 3*nu->pntsu; - else if (nu->bp) tot+= nu->pntsu*nu->pntsv; - - nu= nu->next; + if (nu->bezt) + tot += 3 * nu->pntsu; + else if (nu->bp) + tot += nu->pntsu * nu->pntsv; + + nu = nu->next; } return tot; } @@ -428,14 +449,16 @@ int BKE_nurbList_verts_count(ListBase *nurb) int BKE_nurbList_verts_count_without_handles(ListBase *nurb) { Nurb *nu; - int tot=0; - - nu= nurb->first; + int tot = 0; + + nu = nurb->first; while (nu) { - if (nu->bezt) tot+= nu->pntsu; - else if (nu->bp) tot+= nu->pntsu*nu->pntsv; - - nu= nu->next; + if (nu->bezt) + tot += nu->pntsu; + else if (nu->bp) + tot += nu->pntsu * nu->pntsv; + + nu = nu->next; } return tot; } @@ -445,16 +468,20 @@ int BKE_nurbList_verts_count_without_handles(ListBase *nurb) void BKE_nurb_free(Nurb *nu) { - if (nu==NULL) return; + if (nu == NULL) return; - if (nu->bezt) MEM_freeN(nu->bezt); - nu->bezt= NULL; - if (nu->bp) MEM_freeN(nu->bp); - nu->bp= NULL; - if (nu->knotsu) MEM_freeN(nu->knotsu); - nu->knotsu= NULL; - if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv= NULL; + if (nu->bezt) + MEM_freeN(nu->bezt); + nu->bezt = NULL; + if (nu->bp) + MEM_freeN(nu->bp); + nu->bp = NULL; + if (nu->knotsu) + MEM_freeN(nu->knotsu); + nu->knotsu = NULL; + if (nu->knotsv) + MEM_freeN(nu->knotsv); + nu->knotsv = NULL; /* if (nu->trim.first) freeNurblist(&(nu->trim)); */ MEM_freeN(nu); @@ -466,15 +493,15 @@ void BKE_nurbList_free(ListBase *lb) { Nurb *nu, *next; - if (lb==NULL) return; + if (lb == NULL) return; - nu= lb->first; + nu = lb->first; while (nu) { - next= nu->next; + next = nu->next; BKE_nurb_free(nu); - nu= next; + nu = next; } - lb->first= lb->last= NULL; + lb->first = lb->last = NULL; } Nurb *BKE_nurb_duplicate(Nurb *nu) @@ -482,35 +509,35 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) Nurb *newnu; int len; - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "duplicateNurb"); - if (newnu==NULL) return NULL; + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "duplicateNurb"); + if (newnu == NULL) return NULL; memcpy(newnu, nu, sizeof(Nurb)); if (nu->bezt) { - newnu->bezt= - (BezTriple*)MEM_mallocN((nu->pntsu)* sizeof(BezTriple), "duplicateNurb2"); - memcpy(newnu->bezt, nu->bezt, nu->pntsu*sizeof(BezTriple)); + newnu->bezt = + (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "duplicateNurb2"); + memcpy(newnu->bezt, nu->bezt, nu->pntsu * sizeof(BezTriple)); } else { - len= nu->pntsu*nu->pntsv; - newnu->bp= - (BPoint*)MEM_mallocN((len)* sizeof(BPoint), "duplicateNurb3"); - memcpy(newnu->bp, nu->bp, len*sizeof(BPoint)); - - newnu->knotsu= newnu->knotsv= NULL; - + len = nu->pntsu * nu->pntsv; + newnu->bp = + (BPoint *)MEM_mallocN((len) * sizeof(BPoint), "duplicateNurb3"); + memcpy(newnu->bp, nu->bp, len * sizeof(BPoint)); + + newnu->knotsu = newnu->knotsv = NULL; + if (nu->knotsu) { - len= KNOTSU(nu); + len = KNOTSU(nu); if (len) { - newnu->knotsu= MEM_mallocN(len*sizeof(float), "duplicateNurb4"); - memcpy(newnu->knotsu, nu->knotsu, sizeof(float)*len); + newnu->knotsu = MEM_mallocN(len * sizeof(float), "duplicateNurb4"); + memcpy(newnu->knotsu, nu->knotsu, sizeof(float) * len); } } - if (nu->pntsv>1 && nu->knotsv) { - len= KNOTSV(nu); + if (nu->pntsv > 1 && nu->knotsv) { + len = KNOTSV(nu); if (len) { - newnu->knotsv= MEM_mallocN(len*sizeof(float), "duplicateNurb5"); - memcpy(newnu->knotsv, nu->knotsv, sizeof(float)*len); + newnu->knotsv = MEM_mallocN(len * sizeof(float), "duplicateNurb5"); + memcpy(newnu->knotsv, nu->knotsv, sizeof(float) * len); } } } @@ -520,15 +547,15 @@ Nurb *BKE_nurb_duplicate(Nurb *nu) void BKE_nurbList_duplicate(ListBase *lb1, ListBase *lb2) { Nurb *nu, *nun; - + BKE_nurbList_free(lb1); - - nu= lb2->first; + + nu = lb2->first; while (nu) { - nun= BKE_nurb_duplicate(nu); + nun = BKE_nurb_duplicate(nu); BLI_addtail(lb1, nun); - - nu= nu->next; + + nu = nu->next; } } @@ -537,25 +564,25 @@ void BKE_nurb_test2D(Nurb *nu) BezTriple *bezt; BPoint *bp; int a; - - if ((nu->flag & CU_2D)==0) + + if ((nu->flag & CU_2D) == 0) return; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - bezt->vec[0][2]= 0.0; - bezt->vec[1][2]= 0.0; - bezt->vec[2][2]= 0.0; + bezt->vec[0][2] = 0.0; + bezt->vec[1][2] = 0.0; + bezt->vec[2][2] = 0.0; bezt++; } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - bp->vec[2]= 0.0; + bp->vec[2] = 0.0; bp++; } } @@ -568,8 +595,8 @@ void BKE_nurb_minmax(Nurb *nu, float *min, float *max) int a; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { DO_MINMAX(bezt->vec[0], min, max); DO_MINMAX(bezt->vec[1], min, max); @@ -578,8 +605,8 @@ void BKE_nurb_minmax(Nurb *nu, float *min, float *max) } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { DO_MINMAX(bp->vec, min, max); bp++; @@ -590,9 +617,9 @@ void BKE_nurb_minmax(Nurb *nu, float *min, float *max) /* be sure to call makeknots after this */ void BKE_nurb_points_add(Nurb *nu, int number) { - BPoint *tmp= nu->bp; + BPoint *tmp = nu->bp; int i; - nu->bp= (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add"); + nu->bp = (BPoint *)MEM_mallocN((nu->pntsu + number) * sizeof(BPoint), "rna_Curve_spline_points_add"); if (tmp) { memmove(nu->bp, tmp, nu->pntsu * sizeof(BPoint)); @@ -601,8 +628,8 @@ void BKE_nurb_points_add(Nurb *nu, int number) memset(nu->bp + nu->pntsu, 0, number * sizeof(BPoint)); - for (i=0, tmp= nu->bp + nu->pntsu; i < number; i++, tmp++) { - tmp->radius= 1.0f; + for (i = 0, tmp = nu->bp + nu->pntsu; i < number; i++, tmp++) { + tmp->radius = 1.0f; } nu->pntsu += number; @@ -610,9 +637,9 @@ void BKE_nurb_points_add(Nurb *nu, int number) void BKE_nurb_bezierPoints_add(Nurb *nu, int number) { - BezTriple *tmp= nu->bezt; + BezTriple *tmp = nu->bezt; int i; - nu->bezt= (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add"); + nu->bezt = (BezTriple *)MEM_mallocN((nu->pntsu + number) * sizeof(BezTriple), "rna_Curve_spline_points_add"); if (tmp) { memmove(nu->bezt, tmp, nu->pntsu * sizeof(BezTriple)); @@ -621,8 +648,8 @@ void BKE_nurb_bezierPoints_add(Nurb *nu, int number) memset(nu->bezt + nu->pntsu, 0, number * sizeof(BezTriple)); - for (i=0, tmp= nu->bezt + nu->pntsu; i < number; i++, tmp++) { - tmp->radius= 1.0f; + for (i = 0, tmp = nu->bezt + nu->pntsu; i < number; i++, tmp++) { + tmp->radius = 1.0f; } nu->pntsu += number; @@ -634,44 +661,46 @@ void BKE_nurb_bezierPoints_add(Nurb *nu, int number) static void calcknots(float *knots, const short pnts, const short order, const short flag) { /* knots: number of pnts NOT corrected for cyclic */ - const int pnts_order= pnts + order; + const int pnts_order = pnts + order; float k; int a; - switch (flag & (CU_NURB_ENDPOINT|CU_NURB_BEZIER)) { - case CU_NURB_ENDPOINT: - k= 0.0; - for (a=1; a <= pnts_order; a++) { - knots[a-1]= k; - if (a >= order && a <= pnts) k+= 1.0f; - } - break; - case CU_NURB_BEZIER: - /* Warning, the order MUST be 2 or 4, - * if this is not enforced, the displist will be corrupt */ - if (order==4) { - k= 0.34; - for (a=0; a < pnts_order; a++) { - knots[a]= floorf(k); - k+= (1.0f/3.0f); + switch (flag & (CU_NURB_ENDPOINT | CU_NURB_BEZIER)) { + case CU_NURB_ENDPOINT: + k = 0.0; + for (a = 1; a <= pnts_order; a++) { + knots[a - 1] = k; + if (a >= order && a <= pnts) + k += 1.0f; } - } - else if (order==3) { - k= 0.6f; - for (a=0; a < pnts_order; a++) { - if (a >= order && a <= pnts) k+= 0.5f; - knots[a]= floorf(k); + break; + case CU_NURB_BEZIER: + /* Warning, the order MUST be 2 or 4, + * if this is not enforced, the displist will be corrupt */ + if (order == 4) { + k = 0.34; + for (a = 0; a < pnts_order; a++) { + knots[a] = floorf(k); + k += (1.0f / 3.0f); + } } - } - else { - printf("bez nurb curve order is not 3 or 4, should never happen\n"); - } - break; - default: - for (a=0; a < pnts_order; a++) { - knots[a]= (float)a; - } - break; + else if (order == 3) { + k = 0.6f; + for (a = 0; a < pnts_order; a++) { + if (a >= order && a <= pnts) + k += 0.5f; + knots[a] = floorf(k); + } + } + else { + printf("bez nurb curve order is not 3 or 4, should never happen\n"); + } + break; + default: + for (a = 0; a < pnts_order; a++) { + knots[a] = (float)a; + } + break; } } @@ -680,23 +709,26 @@ static void makecyclicknots(float *knots, short pnts, short order) { int a, b, order2, c; - if (knots==NULL) return; + if (knots == NULL) + return; - order2=order-1; + order2 = order - 1; /* do first long rows (order -1), remove identical knots at endpoints */ - if (order>2) { - b= pnts+order2; - for (a=1; a 2) { + b = pnts + order2; + for (a = 1; a < order2; a++) { + if (knots[b] != knots[b - a]) + break; } - if (a==order2) knots[pnts+order-2]+= 1.0f; + if (a == order2) + knots[pnts + order - 2] += 1.0f; } - b= order; - c=pnts + order + order2; - for (a=pnts+order2; atype == CU_NURBS) { if (uv == 1) { - if (nu->knotsu) MEM_freeN(nu->knotsu); + if (nu->knotsu) + MEM_freeN(nu->knotsu); if (BKE_nurb_check_valid_u(nu)) { - nu->knotsu= MEM_callocN(4+sizeof(float)*KNOTSU(nu), "makeknots"); + nu->knotsu = MEM_callocN(4 + sizeof(float) * KNOTSU(nu), "makeknots"); if (nu->flagu & CU_NURB_CYCLIC) { calcknots(nu->knotsu, nu->pntsu, nu->orderu, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsu, nu->pntsu, nu->orderu); @@ -718,13 +751,14 @@ static void makeknots(Nurb *nu, short uv) calcknots(nu->knotsu, nu->pntsu, nu->orderu, nu->flagu); } } - else nu->knotsu= NULL; - + else + nu->knotsu = NULL; } else if (uv == 2) { - if (nu->knotsv) MEM_freeN(nu->knotsv); + if (nu->knotsv) + MEM_freeN(nu->knotsv); if (BKE_nurb_check_valid_v(nu)) { - nu->knotsv= MEM_callocN(4+sizeof(float)*KNOTSV(nu), "makeknots"); + nu->knotsv = MEM_callocN(4 + sizeof(float) * KNOTSV(nu), "makeknots"); if (nu->flagv & CU_NURB_CYCLIC) { calcknots(nu->knotsv, nu->pntsv, nu->orderv, 0); /* cyclic should be uniform */ makecyclicknots(nu->knotsv, nu->pntsv, nu->orderv); @@ -733,7 +767,7 @@ static void makeknots(Nurb *nu, short uv) calcknots(nu->knotsv, nu->pntsv, nu->orderv, nu->flagv); } } - else nu->knotsv= NULL; + else nu->knotsv = NULL; } } } @@ -753,59 +787,62 @@ static void basisNurb(float t, short order, short pnts, float *knots, float *bas float d, e; int i, i1 = 0, i2 = 0, j, orderpluspnts, opp2, o2; - orderpluspnts= order+pnts; - opp2 = orderpluspnts-1; + orderpluspnts = order + pnts; + opp2 = orderpluspnts - 1; /* this is for float inaccuracy */ - if (t < knots[0]) t= knots[0]; - else if (t > knots[opp2]) t= knots[opp2]; + if (t < knots[0]) + t = knots[0]; + else + if (t > knots[opp2]) t = knots[opp2]; /* this part is order '1' */ - o2 = order + 1; - for (i=0;i= knots[i] && t<=knots[i+1]) { - basis[i]= 1.0; - i1= i-o2; - if (i1<0) i1= 0; - i2= i; + o2 = order + 1; + for (i = 0; i < opp2; i++) { + if (knots[i] != knots[i + 1] && t >= knots[i] && t <= knots[i + 1]) { + basis[i] = 1.0; + i1 = i - o2; + if (i1 < 0) i1 = 0; + i2 = i; i++; - while (i= orderpluspnts) i2= opp2-j; + if (i2 + j >= orderpluspnts) i2 = opp2 - j; - for (i= i1; i<=i2; i++) { - if (basis[i]!=0.0f) - d= ((t-knots[i])*basis[i]) / (knots[i+j-1]-knots[i]); + for (i = i1; i <= i2; i++) { + if (basis[i] != 0.0f) + d = ((t - knots[i]) * basis[i]) / (knots[i + j - 1] - knots[i]); else - d= 0.0f; + d = 0.0f; - if (basis[i+1] != 0.0f) - e= ((knots[i+j]-t)*basis[i+1]) / (knots[i+j]-knots[i+1]); + if (basis[i + 1] != 0.0f) + e = ((knots[i + j] - t) * basis[i + 1]) / (knots[i + j] - knots[i + 1]); else - e= 0.0; + e = 0.0; - basis[i]= d+e; + basis[i] = d + e; } } - *start= 1000; - *end= 0; + *start = 1000; + *end = 0; - for (i=i1; i<=i2; i++) { + for (i = i1; i <= i2; i++) { if (basis[i] > 0.0f) { - *end= i; - if (*start==1000) *start= i; + *end = i; + if (*start == 1000) *start = i; } } } @@ -819,151 +856,165 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, float u, v, ustart, uend, ustep, vstart, vend, vstep, sumdiv; int i, j, iofs, jofs, cycl, len, curu, curv; int istart, iend, jsta, jen, *jstart, *jend, ratcomp; - - int totu = nu->pntsu*resolu, totv = nu->pntsv*resolv; - - if (nu->knotsu==NULL || nu->knotsv==NULL) return; - if (nu->orderu>nu->pntsu) return; - if (nu->orderv>nu->pntsv) return; - if (coord_array==NULL) return; - + + int totu = nu->pntsu * resolu, totv = nu->pntsv * resolv; + + if (nu->knotsu == NULL || nu->knotsv == NULL) + return; + if (nu->orderu > nu->pntsu) + return; + if (nu->orderv > nu->pntsv) + return; + if (coord_array == NULL) + return; + /* allocate and initialize */ len = totu * totv; - if (len==0) return; - + if (len == 0) + return; - - sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbfaces1"); - - len= totu*totv; - if (len==0) { + sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbfaces1"); + + len = totu * totv; + if (len == 0) { MEM_freeN(sum); return; } - bp= nu->bp; - i= nu->pntsu*nu->pntsv; - ratcomp=0; + bp = nu->bp; + i = nu->pntsu * nu->pntsv; + ratcomp = 0; while (i--) { if (bp->vec[3] != 1.0f) { - ratcomp= 1; + ratcomp = 1; break; } bp++; } - - fp= nu->knotsu; - ustart= fp[nu->orderu-1]; - if (nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; - else uend= fp[nu->pntsu]; - ustep= (uend-ustart)/((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1); - - basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbfaces3"); - fp= nu->knotsv; - vstart= fp[nu->orderv-1]; - - if (nu->flagv & CU_NURB_CYCLIC) vend= fp[nu->pntsv+nu->orderv-1]; - else vend= fp[nu->pntsv]; - vstep= (vend-vstart)/((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1); - - len= KNOTSV(nu); - basisv= (float *)MEM_mallocN(sizeof(float)*len*totv, "makeNurbfaces3"); - jstart= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces4"); - jend= (int *)MEM_mallocN(sizeof(float)*totv, "makeNurbfaces5"); + fp = nu->knotsu; + ustart = fp[nu->orderu - 1]; + if (nu->flagu & CU_NURB_CYCLIC) + uend = fp[nu->pntsu + nu->orderu - 1]; + else + uend = fp[nu->pntsu]; + ustep = (uend - ustart) / ((nu->flagu & CU_NURB_CYCLIC) ? totu : totu - 1); + + basisu = (float *)MEM_mallocN(sizeof(float) * KNOTSU(nu), "makeNurbfaces3"); + + fp = nu->knotsv; + vstart = fp[nu->orderv - 1]; + + if (nu->flagv & CU_NURB_CYCLIC) + vend = fp[nu->pntsv + nu->orderv - 1]; + else + vend = fp[nu->pntsv]; + vstep = (vend - vstart) / ((nu->flagv & CU_NURB_CYCLIC) ? totv : totv - 1); + + len = KNOTSV(nu); + basisv = (float *)MEM_mallocN(sizeof(float) * len * totv, "makeNurbfaces3"); + jstart = (int *)MEM_mallocN(sizeof(float) * totv, "makeNurbfaces4"); + jend = (int *)MEM_mallocN(sizeof(float) * totv, "makeNurbfaces5"); /* precalculation of basisv and jstart, jend */ - if (nu->flagv & CU_NURB_CYCLIC) cycl= nu->orderv-1; - else cycl= 0; - v= vstart; - basis= basisv; - curv= totv; + if (nu->flagv & CU_NURB_CYCLIC) + cycl = nu->orderv - 1; + else cycl = 0; + v = vstart; + basis = basisv; + curv = totv; while (curv--) { - basisNurb(v, nu->orderv, (short)(nu->pntsv+cycl), nu->knotsv, basis, jstart+curv, jend+curv); - basis+= KNOTSV(nu); - v+= vstep; + basisNurb(v, nu->orderv, (short)(nu->pntsv + cycl), nu->knotsv, basis, jstart + curv, jend + curv); + basis += KNOTSV(nu); + v += vstep; } - if (nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1; - else cycl= 0; - in= coord_array; - u= ustart; - curu= totu; + if (nu->flagu & CU_NURB_CYCLIC) + cycl = nu->orderu - 1; + else + cycl = 0; + in = coord_array; + u = ustart; + curu = totu; while (curu--) { + basisNurb(u, nu->orderu, (short)(nu->pntsu + cycl), nu->knotsu, basisu, &istart, &iend); - basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend); - - basis= basisv; - curv= totv; + basis = basisv; + curv = totv; while (curv--) { - - jsta= jstart[curv]; - jen= jend[curv]; + jsta = jstart[curv]; + jen = jend[curv]; /* calculate sum */ - sumdiv= 0.0; - fp= sum; + sumdiv = 0.0; + fp = sum; - for (j= jsta; j<=jen; j++) { + for (j = jsta; j <= jen; j++) { - if (j>=nu->pntsv) jofs= (j - nu->pntsv); - else jofs= j; - bp= nu->bp+ nu->pntsu*jofs+istart-1; + if (j >= nu->pntsv) + jofs = (j - nu->pntsv); + else + jofs = j; + bp = nu->bp + nu->pntsu * jofs + istart - 1; - for (i= istart; i<=iend; i++, fp++) { - - if (i>= nu->pntsu) { - iofs= i- nu->pntsu; - bp= nu->bp+ nu->pntsu*jofs+iofs; + for (i = istart; i <= iend; i++, fp++) { + if (i >= nu->pntsu) { + iofs = i - nu->pntsu; + bp = nu->bp + nu->pntsu * jofs + iofs; } - else bp++; + else + bp++; if (ratcomp) { - *fp= basisu[i]*basis[j]*bp->vec[3]; - sumdiv+= *fp; + *fp = basisu[i] * basis[j] * bp->vec[3]; + sumdiv += *fp; } - else *fp= basisu[i]*basis[j]; + else + *fp = basisu[i] * basis[j]; } } - + if (ratcomp) { - fp= sum; - for (j= jsta; j<=jen; j++) { - for (i= istart; i<=iend; i++, fp++) { - *fp/= sumdiv; + fp = sum; + for (j = jsta; j <= jen; j++) { + for (i = istart; i <= iend; i++, fp++) { + *fp /= sumdiv; } } } /* one! (1.0) real point now */ - fp= sum; - for (j= jsta; j<=jen; j++) { + fp = sum; + for (j = jsta; j <= jen; j++) { - if (j>=nu->pntsv) jofs= (j - nu->pntsv); - else jofs= j; - bp= nu->bp+ nu->pntsu*jofs+istart-1; + if (j >= nu->pntsv) + jofs = (j - nu->pntsv); + else + jofs = j; + bp = nu->bp + nu->pntsu * jofs + istart - 1; - for (i= istart; i<=iend; i++, fp++) { - - if (i>= nu->pntsu) { - iofs= i- nu->pntsu; - bp= nu->bp+ nu->pntsu*jofs+iofs; + for (i = istart; i <= iend; i++, fp++) { + if (i >= nu->pntsu) { + iofs = i - nu->pntsu; + bp = nu->bp + nu->pntsu * jofs + iofs; } - else bp++; + else + bp++; if (*fp != 0.0f) { - in[0]+= (*fp) * bp->vec[0]; - in[1]+= (*fp) * bp->vec[1]; - in[2]+= (*fp) * bp->vec[2]; + in[0] += (*fp) * bp->vec[0]; + in[1] += (*fp) * bp->vec[1]; + in[2] += (*fp) * bp->vec[2]; } } } - in+=3; - basis+= KNOTSV(nu); + in += 3; + basis += KNOTSV(nu); } - u+= ustep; - if (rowstride!=0) in = (float*) (((unsigned char*) in) + (rowstride - 3*totv*sizeof(*in))); + u += ustep; + if (rowstride != 0) + in = (float *) (((unsigned char *) in) + (rowstride - 3 * totv * sizeof(*in))); } /* free */ @@ -974,100 +1025,112 @@ void BKE_nurb_makeFaces(Nurb *nu, float *coord_array, int rowstride, int resolu, MEM_freeN(jend); } -void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) +void BKE_nurb_makeCurve(Nurb *nu, float *coord_array, float *tilt_array, float *radius_array, float *weight_array, + int resolu, int stride) /* coord_array has to be 3*4*pntsu*resolu in size and zero-ed * tilt_array and radius_array will be written to if valid */ { BPoint *bp; float u, ustart, uend, ustep, sumdiv; float *basisu, *sum, *fp; - float *coord_fp= coord_array, *tilt_fp= tilt_array, *radius_fp= radius_array, *weight_fp= weight_array; + float *coord_fp = coord_array, *tilt_fp = tilt_array, *radius_fp = radius_array, *weight_fp = weight_array; int i, len, istart, iend, cycl; - if (nu->knotsu==NULL) return; - if (nu->orderu>nu->pntsu) return; - if (coord_array==NULL) return; + if (nu->knotsu == NULL) + return; + if (nu->orderu > nu->pntsu) + return; + if (coord_array == NULL) + return; /* allocate and initialize */ - len= nu->pntsu; - if (len==0) return; - sum= (float *)MEM_callocN(sizeof(float)*len, "makeNurbcurve1"); - - resolu= (resolu*SEGMENTSU(nu)); - - if (resolu==0) { + len = nu->pntsu; + if (len == 0) + return; + sum = (float *)MEM_callocN(sizeof(float) * len, "makeNurbcurve1"); + + resolu = (resolu * SEGMENTSU(nu)); + + if (resolu == 0) { MEM_freeN(sum); return; } - fp= nu->knotsu; - ustart= fp[nu->orderu-1]; - if (nu->flagu & CU_NURB_CYCLIC) uend= fp[nu->pntsu+nu->orderu-1]; - else uend= fp[nu->pntsu]; - ustep= (uend-ustart)/(resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1)); - - basisu= (float *)MEM_mallocN(sizeof(float)*KNOTSU(nu), "makeNurbcurve3"); + fp = nu->knotsu; + ustart = fp[nu->orderu - 1]; + if (nu->flagu & CU_NURB_CYCLIC) + uend = fp[nu->pntsu + nu->orderu - 1]; + else + uend = fp[nu->pntsu]; + ustep = (uend - ustart) / (resolu - ((nu->flagu & CU_NURB_CYCLIC) ? 0 : 1)); - if (nu->flagu & CU_NURB_CYCLIC) cycl= nu->orderu-1; - else cycl= 0; + basisu = (float *)MEM_mallocN(sizeof(float) * KNOTSU(nu), "makeNurbcurve3"); - u= ustart; + if (nu->flagu & CU_NURB_CYCLIC) + cycl = nu->orderu - 1; + else + cycl = 0; + + u = ustart; while (resolu--) { + basisNurb(u, nu->orderu, (short)(nu->pntsu + cycl), nu->knotsu, basisu, &istart, &iend); - basisNurb(u, nu->orderu, (short)(nu->pntsu+cycl), nu->knotsu, basisu, &istart, &iend); /* calc sum */ - sumdiv= 0.0; - fp= sum; - bp= nu->bp+ istart-1; - for (i= istart; i<=iend; i++, fp++) { + sumdiv = 0.0; + fp = sum; + bp = nu->bp + istart - 1; + for (i = istart; i <= iend; i++, fp++) { + if (i >= nu->pntsu) + bp = nu->bp + (i - nu->pntsu); + else + bp++; - if (i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu); - else bp++; - - *fp= basisu[i]*bp->vec[3]; - sumdiv+= *fp; + *fp = basisu[i] * bp->vec[3]; + sumdiv += *fp; } if (sumdiv != 0.0f) if (sumdiv < 0.999f || sumdiv > 1.001f) { - /* is normalizing needed? */ - fp= sum; - for (i= istart; i<=iend; i++, fp++) { - *fp/= sumdiv; + /* is normalizing needed? */ + fp = sum; + for (i = istart; i <= iend; i++, fp++) { + *fp /= sumdiv; + } } - } /* one! (1.0) real point */ - fp= sum; - bp= nu->bp+ istart-1; - for (i= istart; i<=iend; i++, fp++) { - - if (i>=nu->pntsu) bp= nu->bp+(i - nu->pntsu); - else bp++; + fp = sum; + bp = nu->bp + istart - 1; + for (i = istart; i <= iend; i++, fp++) { + if (i >= nu->pntsu) + bp = nu->bp + (i - nu->pntsu); + else + bp++; if (*fp != 0.0f) { - - coord_fp[0]+= (*fp) * bp->vec[0]; - coord_fp[1]+= (*fp) * bp->vec[1]; - coord_fp[2]+= (*fp) * bp->vec[2]; - + coord_fp[0] += (*fp) * bp->vec[0]; + coord_fp[1] += (*fp) * bp->vec[1]; + coord_fp[2] += (*fp) * bp->vec[2]; + if (tilt_fp) (*tilt_fp) += (*fp) * bp->alfa; - + if (radius_fp) (*radius_fp) += (*fp) * bp->radius; if (weight_fp) (*weight_fp) += (*fp) * bp->weight; - } } coord_fp = (float *)(((char *)coord_fp) + stride); - - if (tilt_fp) tilt_fp = (float *)(((char *)tilt_fp) + stride); - if (radius_fp) radius_fp = (float *)(((char *)radius_fp) + stride); - if (weight_fp) weight_fp = (float *)(((char *)weight_fp) + stride); - - u+= ustep; + + if (tilt_fp) + tilt_fp = (float *)(((char *)tilt_fp) + stride); + if (radius_fp) + radius_fp = (float *)(((char *)radius_fp) + stride); + if (weight_fp) + weight_fp = (float *)(((char *)weight_fp) + stride); + + u += ustep; } /* free */ @@ -1081,25 +1144,25 @@ void BKE_curve_forward_diff_bezier(float q0, float q1, float q2, float q3, float float rt0, rt1, rt2, rt3, f; int a; - f= (float)it; - rt0= q0; - rt1= 3.0f*(q1-q0)/f; - f*= f; - rt2= 3.0f*(q0-2.0f*q1+q2)/f; - f*= it; - rt3= (q3-q0+3.0f*(q1-q2))/f; + f = (float)it; + rt0 = q0; + rt1 = 3.0f * (q1 - q0) / f; + f *= f; + rt2 = 3.0f * (q0 - 2.0f * q1 + q2) / f; + f *= it; + rt3 = (q3 - q0 + 3.0f * (q1 - q2)) / f; - q0= rt0; - q1= rt1+rt2+rt3; - q2= 2*rt2+6*rt3; - q3= 6*rt3; + q0 = rt0; + q1 = rt1 + rt2 + rt3; + q2 = 2 * rt2 + 6 * rt3; + q3 = 6 * rt3; - for (a=0; a<=it; a++) { - *p= q0; - p = (float *)(((char *)p)+stride); - q0+= q1; - q1+= q2; - q2+= q3; + for (a = 0; a <= it; a++) { + *p = q0; + p = (float *)(((char *)p) + stride); + q0 += q1; + q1 += q2; + q2 += q3; } } @@ -1110,15 +1173,15 @@ static void forward_diff_bezier_cotangent(float *p0, float *p1, float *p2, float * * This could also be optimized like forward_diff_bezier */ int a; - for (a=0; a<=it; a++) { + for (a = 0; a <= it; a++) { float t = (float)a / (float)it; int i; - for (i=0; i<3; i++) { - p[i]= (-6*t + 6)*p0[i] + (18*t - 12)*p1[i] + (-18*t + 6)*p2[i] + (6*t)*p3[i]; + for (i = 0; i < 3; i++) { + p[i] = (-6 * t + 6) * p0[i] + (18 * t - 12) * p1[i] + (-18 * t + 6) * p2[i] + (6 * t) * p3[i]; } normalize_v3(p); - p = (float *)(((char *)p)+stride); + p = (float *)(((char *)p) + stride); } } @@ -1128,15 +1191,15 @@ float *BKE_curve_surf_make_orco(Object *ob) { /* Note: this function is used in convertblender only atm, so * suppose nonzero curve's render resolution should always be used */ - Curve *cu= ob->data; + Curve *cu = ob->data; Nurb *nu; - int a, b, tot=0; + int a, b, tot = 0; int sizeu, sizev; int resolu, resolv; float *fp, *coord_array; - + /* first calculate the size of the datablock */ - nu= cu->nurb.first; + nu = cu->nurb.first; while (nu) { /* as we want to avoid the seam in a cyclic nurbs * texture wrapping, reserve extra orco data space to save these extra needed @@ -1147,85 +1210,93 @@ float *BKE_curve_surf_make_orco(Object *ob) * See also convertblender.c: init_render_surf() */ - resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu; - resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv; - - sizeu = nu->pntsu*resolu; - sizev = nu->pntsv*resolv; + resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; + resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; + + sizeu = nu->pntsu * resolu; + sizev = nu->pntsv * resolv; if (nu->flagu & CU_NURB_CYCLIC) sizeu++; if (nu->flagv & CU_NURB_CYCLIC) sizev++; - if (nu->pntsv>1) tot+= sizeu * sizev; - - nu= nu->next; + if (nu->pntsv > 1) tot += sizeu * sizev; + + nu = nu->next; } /* makeNurbfaces wants zeros */ - fp= coord_array= MEM_callocN(3*sizeof(float)*tot, "make_orco"); - - nu= cu->nurb.first; - while (nu) { - resolu= cu->resolu_ren ? cu->resolu_ren : nu->resolu; - resolv= cu->resolv_ren ? cu->resolv_ren : nu->resolv; + fp = coord_array = MEM_callocN(3 * sizeof(float) * tot, "make_orco"); + + nu = cu->nurb.first; + while (nu) { + resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; + resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; + + if (nu->pntsv > 1) { + sizeu = nu->pntsu * resolu; + sizev = nu->pntsv * resolv; + + if (nu->flagu & CU_NURB_CYCLIC) + sizeu++; + if (nu->flagv & CU_NURB_CYCLIC) + sizev++; - if (nu->pntsv>1) { - sizeu = nu->pntsu*resolu; - sizev = nu->pntsv*resolv; - if (nu->flagu & CU_NURB_CYCLIC) sizeu++; - if (nu->flagv & CU_NURB_CYCLIC) sizev++; - if (cu->flag & CU_UV_ORCO) { - for (b=0; b< sizeu; b++) { - for (a=0; a< sizev; a++) { - - if (sizev <2) fp[0]= 0.0f; - else fp[0]= -1.0f + 2.0f*((float)a)/(sizev - 1); - - if (sizeu <2) fp[1]= 0.0f; - else fp[1]= -1.0f + 2.0f*((float)b)/(sizeu - 1); - - fp[2]= 0.0; - - fp+= 3; + for (b = 0; b < sizeu; b++) { + for (a = 0; a < sizev; a++) { + + if (sizev < 2) + fp[0] = 0.0f; + else + fp[0] = -1.0f + 2.0f * ((float)a) / (sizev - 1); + + if (sizeu < 2) + fp[1] = 0.0f; + else + fp[1] = -1.0f + 2.0f * ((float)b) / (sizeu - 1); + + fp[2] = 0.0; + + fp += 3; } } } else { - float *_tdata= MEM_callocN((nu->pntsu*resolu) * (nu->pntsv*resolv) *3*sizeof(float), "temp data"); - float *tdata= _tdata; - + int size = (nu->pntsu * resolu) * (nu->pntsv * resolv) * 3 * sizeof(float); + float *_tdata = MEM_callocN(size, "temp data"); + float *tdata = _tdata; + BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv); - - for (b=0; bflagu & CU_NURB_CYCLIC)) - use_b= 0; - - for (a=0; aflagv & CU_NURB_CYCLIC)) - use_a= 0; - - tdata = _tdata + 3 * (use_b * (nu->pntsv*resolv) + use_a); - - fp[0]= (tdata[0]-cu->loc[0])/cu->size[0]; - fp[1]= (tdata[1]-cu->loc[1])/cu->size[1]; - fp[2]= (tdata[2]-cu->loc[2])/cu->size[2]; - fp+= 3; + + for (b = 0; b < sizeu; b++) { + int use_b = b; + if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC)) + use_b = 0; + + for (a = 0; a < sizev; a++) { + int use_a = a; + if (a == sizev - 1 && (nu->flagv & CU_NURB_CYCLIC)) + use_a = 0; + + tdata = _tdata + 3 * (use_b * (nu->pntsv * resolv) + use_a); + + fp[0] = (tdata[0] - cu->loc[0]) / cu->size[0]; + fp[1] = (tdata[1] - cu->loc[1]) / cu->size[1]; + fp[2] = (tdata[2] - cu->loc[2]) / cu->size[2]; + fp += 3; } } - + MEM_freeN(_tdata); } } - nu= nu->next; + nu = nu->next; } - + return coord_array; } - /* NOTE: This routine is tied to the order of vertex - * built by displist and as passed to the renderer. - */ +/* NOTE: This routine is tied to the order of vertex + * built by displist and as passed to the renderer. + */ float *BKE_curve_make_orco(Scene *scene, Object *ob) { Curve *cu = ob->data; @@ -1234,79 +1305,81 @@ float *BKE_curve_make_orco(Scene *scene, Object *ob) float *fp, *coord_array; ListBase disp = {NULL, NULL}; - makeDispListCurveTypes_forOrco(scene, ob, &disp); + BKE_displist_make_curveTypes_forOrco(scene, ob, &disp); numVerts = 0; - for (dl=disp.first; dl; dl=dl->next) { - if (dl->type==DL_INDEX3) { + for (dl = disp.first; dl; dl = dl->next) { + if (dl->type == DL_INDEX3) { numVerts += dl->nr; } - else if (dl->type==DL_SURF) { - /* convertblender.c uses the Surface code for creating renderfaces when cyclic U only (closed circle beveling) */ + else if (dl->type == DL_SURF) { + /* convertblender.c uses the Surface code for creating renderfaces when cyclic U only + * (closed circle beveling) + */ if (dl->flag & DL_CYCL_U) { if (dl->flag & DL_CYCL_V) - numVerts += (dl->parts+1)*(dl->nr+1); + numVerts += (dl->parts + 1) * (dl->nr + 1); else - numVerts += dl->parts*(dl->nr+1); + numVerts += dl->parts * (dl->nr + 1); } else - numVerts += dl->parts*dl->nr; + numVerts += dl->parts * dl->nr; } } - fp= coord_array= MEM_mallocN(3*sizeof(float)*numVerts, "cu_orco"); - for (dl=disp.first; dl; dl=dl->next) { - if (dl->type==DL_INDEX3) { - for (u=0; unr; u++, fp+=3) { + fp = coord_array = MEM_mallocN(3 * sizeof(float) * numVerts, "cu_orco"); + for (dl = disp.first; dl; dl = dl->next) { + if (dl->type == DL_INDEX3) { + for (u = 0; u < dl->nr; u++, fp += 3) { if (cu->flag & CU_UV_ORCO) { - fp[0]= 2.0f*u/(dl->nr-1) - 1.0f; - fp[1]= 0.0; - fp[2]= 0.0; + fp[0] = 2.0f * u / (dl->nr - 1) - 1.0f; + fp[1] = 0.0; + fp[2] = 0.0; } else { - copy_v3_v3(fp, &dl->verts[u*3]); + copy_v3_v3(fp, &dl->verts[u * 3]); - fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; - fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; - fp[2]= (fp[2]-cu->loc[2])/cu->size[2]; + fp[0] = (fp[0] - cu->loc[0]) / cu->size[0]; + fp[1] = (fp[1] - cu->loc[1]) / cu->size[1]; + fp[2] = (fp[2] - cu->loc[2]) / cu->size[2]; } } } - else if (dl->type==DL_SURF) { - int sizeu= dl->nr, sizev= dl->parts; - + else if (dl->type == DL_SURF) { + int sizeu = dl->nr, sizev = dl->parts; + /* exception as handled in convertblender.c too */ if (dl->flag & DL_CYCL_U) { sizeu++; if (dl->flag & DL_CYCL_V) sizev++; } - - for (u=0; uflag & CU_UV_ORCO) { - fp[0]= 2.0f*u/(sizev - 1) - 1.0f; - fp[1]= 2.0f*v/(sizeu - 1) - 1.0f; - fp[2]= 0.0; + fp[0] = 2.0f * u / (sizev - 1) - 1.0f; + fp[1] = 2.0f * v / (sizeu - 1) - 1.0f; + fp[2] = 0.0; } else { float *vert; - int realv= v % dl->nr; - int realu= u % dl->parts; - - vert= dl->verts + 3*(dl->nr*realu + realv); + int realv = v % dl->nr; + int realu = u % dl->parts; + + vert = dl->verts + 3 * (dl->nr * realu + realv); copy_v3_v3(fp, vert); - fp[0]= (fp[0]-cu->loc[0])/cu->size[0]; - fp[1]= (fp[1]-cu->loc[1])/cu->size[1]; - fp[2]= (fp[2]-cu->loc[2])/cu->size[2]; + fp[0] = (fp[0] - cu->loc[0]) / cu->size[0]; + fp[1] = (fp[1] - cu->loc[1]) / cu->size[1]; + fp[2] = (fp[2] - cu->loc[2]) / cu->size[2]; } } } } } - freedisplist(&disp); + BKE_displist_free(&disp); return coord_array; } @@ -1321,189 +1394,190 @@ void BKE_curve_bevel_make(Scene *scene, Object *ob, ListBase *disp, int forRende float *fp, facx, facy, angle, dangle; int nr, a; - cu= ob->data; + cu = ob->data; disp->first = disp->last = NULL; /* if a font object is being edited, then do nothing */ // XXX if ( ob == obedit && ob->type == OB_FONT ) return; if (cu->bevobj) { - if (cu->bevobj->type!=OB_CURVE) return; + if (cu->bevobj->type != OB_CURVE) + return; - bevcu= cu->bevobj->data; - if (bevcu->ext1==0.0f && bevcu->ext2==0.0f) { - ListBase bevdisp= {NULL, NULL}; - facx= cu->bevobj->size[0]; - facy= cu->bevobj->size[1]; + bevcu = cu->bevobj->data; + if (bevcu->ext1 == 0.0f && bevcu->ext2 == 0.0f) { + ListBase bevdisp = {NULL, NULL}; + facx = cu->bevobj->size[0]; + facy = cu->bevobj->size[1]; if (forRender) { - makeDispListCurveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); - dl= bevdisp.first; + BKE_displist_make_curveTypes_forRender(scene, cu->bevobj, &bevdisp, NULL, 0); + dl = bevdisp.first; } else { - dl= cu->bevobj->disp.first; - if (dl==NULL) { - makeDispListCurveTypes(scene, cu->bevobj, 0); - dl= cu->bevobj->disp.first; + dl = cu->bevobj->disp.first; + if (dl == NULL) { + BKE_displist_make_curveTypes(scene, cu->bevobj, 0); + dl = cu->bevobj->disp.first; } } while (dl) { if (ELEM(dl->type, DL_POLY, DL_SEGM)) { - dlnew= MEM_mallocN(sizeof(DispList), "makebevelcurve1"); - *dlnew= *dl; - dlnew->verts= MEM_mallocN(3*sizeof(float)*dl->parts*dl->nr, "makebevelcurve1"); - memcpy(dlnew->verts, dl->verts, 3*sizeof(float)*dl->parts*dl->nr); + dlnew = MEM_mallocN(sizeof(DispList), "makebevelcurve1"); + *dlnew = *dl; + dlnew->verts = MEM_mallocN(3 * sizeof(float) * dl->parts * dl->nr, "makebevelcurve1"); + memcpy(dlnew->verts, dl->verts, 3 * sizeof(float) * dl->parts * dl->nr); - if (dlnew->type==DL_SEGM) dlnew->flag |= (DL_FRONT_CURVE|DL_BACK_CURVE); + if (dlnew->type == DL_SEGM) + dlnew->flag |= (DL_FRONT_CURVE | DL_BACK_CURVE); BLI_addtail(disp, dlnew); - fp= dlnew->verts; - nr= dlnew->parts*dlnew->nr; + fp = dlnew->verts; + nr = dlnew->parts * dlnew->nr; while (nr--) { - fp[2]= fp[1]*facy; - fp[1]= -fp[0]*facx; - fp[0]= 0.0; - fp+= 3; + fp[2] = fp[1] * facy; + fp[1] = -fp[0] * facx; + fp[0] = 0.0; + fp += 3; } } - dl= dl->next; + dl = dl->next; } - freedisplist(&bevdisp); + BKE_displist_free(&bevdisp); } } - else if (cu->ext1==0.0f && cu->ext2==0.0f) { + else if (cu->ext1 == 0.0f && cu->ext2 == 0.0f) { ; } - else if (cu->ext2==0.0f) { - dl= MEM_callocN(sizeof(DispList), "makebevelcurve2"); - dl->verts= MEM_mallocN(2*3*sizeof(float), "makebevelcurve2"); + else if (cu->ext2 == 0.0f) { + dl = MEM_callocN(sizeof(DispList), "makebevelcurve2"); + dl->verts = MEM_mallocN(2 * 3 * sizeof(float), "makebevelcurve2"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->flag= DL_FRONT_CURVE|DL_BACK_CURVE; - dl->nr= 2; - - fp= dl->verts; - fp[0]= fp[1]= 0.0; - fp[2]= -cu->ext1; - fp[3]= fp[4]= 0.0; - fp[5]= cu->ext1; + dl->type = DL_SEGM; + dl->parts = 1; + dl->flag = DL_FRONT_CURVE | DL_BACK_CURVE; + dl->nr = 2; + + fp = dl->verts; + fp[0] = fp[1] = 0.0; + fp[2] = -cu->ext1; + fp[3] = fp[4] = 0.0; + fp[5] = cu->ext1; } - else if ( (cu->flag & (CU_FRONT|CU_BACK))==0 && cu->ext1==0.0f) { // we make a full round bevel in that case - - nr= 4+ 2*cu->bevresol; - - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); + else if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0 && cu->ext1 == 0.0f) { // we make a full round bevel in that case + nr = 4 + 2 * cu->bevresol; + + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1"); + dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1"); BLI_addtail(disp, dl); - dl->type= DL_POLY; - dl->parts= 1; - dl->flag= DL_BACK_CURVE; - dl->nr= nr; + dl->type = DL_POLY; + dl->parts = 1; + dl->flag = DL_BACK_CURVE; + dl->nr = nr; /* a circle */ - fp= dl->verts; - dangle= (2.0f*(float)M_PI/(nr)); - angle= -(nr-1)*dangle; - - for (a=0; aext2)); - fp[2]= (sinf(angle)*(cu->ext2)) - cu->ext1; - angle+= dangle; - fp+= 3; + fp = dl->verts; + dangle = (2.0f * (float)M_PI / (nr)); + angle = -(nr - 1) * dangle; + + for (a = 0; a < nr; a++) { + fp[0] = 0.0; + fp[1] = (cosf(angle) * (cu->ext2)); + fp[2] = (sinf(angle) * (cu->ext2)) - cu->ext1; + angle += dangle; + fp += 3; } } else { short dnr; - + /* bevel now in three parts, for proper vertex normals */ /* part 1, back */ if ((cu->flag & CU_BACK) || !(cu->flag & CU_FRONT)) { - dnr= nr= 2+ cu->bevresol; - if ( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; + dnr = nr = 2 + cu->bevresol; + if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) + nr = 3 + 2 * cu->bevresol; - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p1"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p1"); + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p1"); + dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p1"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->flag= DL_BACK_CURVE; - dl->nr= nr; + dl->type = DL_SEGM; + dl->parts = 1; + dl->flag = DL_BACK_CURVE; + dl->nr = nr; /* half a circle */ - fp= dl->verts; - dangle= (0.5*M_PI/(dnr-1)); - angle= -(nr-1)*dangle; + fp = dl->verts; + dangle = (0.5 * M_PI / (dnr - 1)); + angle = -(nr - 1) * dangle; - for (a=0; aext2)); - fp[2]= (float)(sinf(angle)*(cu->ext2)) - cu->ext1; - angle+= dangle; - fp+= 3; + for (a = 0; a < nr; a++) { + fp[0] = 0.0; + fp[1] = (float)(cosf(angle) * (cu->ext2)); + fp[2] = (float)(sinf(angle) * (cu->ext2)) - cu->ext1; + angle += dangle; + fp += 3; } } - + /* part 2, sidefaces */ - if (cu->ext1!=0.0f) { - nr= 2; - - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p2"); - dl->verts= MEM_callocN(nr*3*sizeof(float), "makebevelcurve p2"); + if (cu->ext1 != 0.0f) { + nr = 2; + + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p2"); + dl->verts = MEM_callocN(nr * 3 * sizeof(float), "makebevelcurve p2"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->parts= 1; - dl->nr= nr; - - fp= dl->verts; - fp[1]= cu->ext2; - fp[2]= -cu->ext1; - fp[4]= cu->ext2; - fp[5]= cu->ext1; - - if ( (cu->flag & (CU_FRONT|CU_BACK))==0) { - dl= MEM_dupallocN(dl); - dl->verts= MEM_dupallocN(dl->verts); + dl->type = DL_SEGM; + dl->parts = 1; + dl->nr = nr; + + fp = dl->verts; + fp[1] = cu->ext2; + fp[2] = -cu->ext1; + fp[4] = cu->ext2; + fp[5] = cu->ext1; + + if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) { + dl = MEM_dupallocN(dl); + dl->verts = MEM_dupallocN(dl->verts); BLI_addtail(disp, dl); - - fp= dl->verts; - fp[1]= -fp[1]; - fp[2]= -fp[2]; - fp[4]= -fp[4]; - fp[5]= -fp[5]; + + fp = dl->verts; + fp[1] = -fp[1]; + fp[2] = -fp[2]; + fp[4] = -fp[4]; + fp[5] = -fp[5]; } } - + /* part 3, front */ if ((cu->flag & CU_FRONT) || !(cu->flag & CU_BACK)) { - dnr= nr= 2+ cu->bevresol; - if ( (cu->flag & (CU_FRONT|CU_BACK))==0) - nr= 3+ 2*cu->bevresol; + dnr = nr = 2 + cu->bevresol; + if ( (cu->flag & (CU_FRONT | CU_BACK)) == 0) + nr = 3 + 2 * cu->bevresol; - dl= MEM_callocN(sizeof(DispList), "makebevelcurve p3"); - dl->verts= MEM_mallocN(nr*3*sizeof(float), "makebevelcurve p3"); + dl = MEM_callocN(sizeof(DispList), "makebevelcurve p3"); + dl->verts = MEM_mallocN(nr * 3 * sizeof(float), "makebevelcurve p3"); BLI_addtail(disp, dl); - dl->type= DL_SEGM; - dl->flag= DL_FRONT_CURVE; - dl->parts= 1; - dl->nr= nr; + dl->type = DL_SEGM; + dl->flag = DL_FRONT_CURVE; + dl->parts = 1; + dl->nr = nr; /* half a circle */ - fp= dl->verts; - angle= 0.0; - dangle= (0.5*M_PI/(dnr-1)); + fp = dl->verts; + angle = 0.0; + dangle = (0.5 * M_PI / (dnr - 1)); - for (a=0; aext2)); - fp[2]= (float)(sinf(angle)*(cu->ext2)) + cu->ext1; - angle+= dangle; - fp+= 3; + for (a = 0; a < nr; a++) { + fp[0] = 0.0; + fp[1] = (float)(cosf(angle) * (cu->ext2)); + fp[2] = (float)(sinf(angle) * (cu->ext2)) + cu->ext1; + angle += dangle; + fp += 3; } } } @@ -1521,25 +1595,27 @@ static int cu_isectLL(const float v1[3], const float v2[3], const float v3[3], c */ float deler; - deler= (v1[cox]-v2[cox])*(v3[coy]-v4[coy])-(v3[cox]-v4[cox])*(v1[coy]-v2[coy]); - if (deler==0.0f) return -1; + deler = (v1[cox] - v2[cox]) * (v3[coy] - v4[coy]) - (v3[cox] - v4[cox]) * (v1[coy] - v2[coy]); + if (deler == 0.0f) + return -1; - *labda= (v1[coy]-v3[coy])*(v3[cox]-v4[cox])-(v1[cox]-v3[cox])*(v3[coy]-v4[coy]); - *labda= -(*labda/deler); + *labda = (v1[coy] - v3[coy]) * (v3[cox] - v4[cox]) - (v1[cox] - v3[cox]) * (v3[coy] - v4[coy]); + *labda = -(*labda / deler); - deler= v3[coy]-v4[coy]; - if (deler==0) { - deler=v3[cox]-v4[cox]; - *mu= -(*labda*(v2[cox]-v1[cox])+v1[cox]-v3[cox])/deler; + deler = v3[coy] - v4[coy]; + if (deler == 0) { + deler = v3[cox] - v4[cox]; + *mu = -(*labda * (v2[cox] - v1[cox]) + v1[cox] - v3[cox]) / deler; } else { - *mu= -(*labda*(v2[coy]-v1[coy])+v1[coy]-v3[coy])/deler; + *mu = -(*labda * (v2[coy] - v1[coy]) + v1[coy] - v3[coy]) / deler; } - vec[cox]= *labda*(v2[cox]-v1[cox])+v1[cox]; - vec[coy]= *labda*(v2[coy]-v1[coy])+v1[coy]; + vec[cox] = *labda * (v2[cox] - v1[cox]) + v1[cox]; + vec[coy] = *labda * (v2[coy] - v1[coy]) + v1[coy]; - if (*labda>=0.0f && *labda<=1.0f && *mu>=0.0f && *mu<=1.0f) { - if (*labda==0.0f || *labda==1.0f || *mu==0.0f || *mu==1.0f) return 1; + if (*labda >= 0.0f && *labda <= 1.0f && *mu >= 0.0f && *mu <= 1.0f) { + if (*labda == 0.0f || *labda == 1.0f || *mu == 0.0f || *mu == 1.0f) + return 1; return 2; } return 0; @@ -1552,49 +1628,50 @@ static short bevelinside(BevList *bl1, BevList *bl2) /* returns '1' if correct hole */ BevPoint *bevp, *prevbevp; float min, max, vec[3], hvec1[3], hvec2[3], lab, mu; - int nr, links=0, rechts=0, mode; + int nr, links = 0, rechts = 0, mode; /* take first vertex of possible hole */ - bevp= (BevPoint *)(bl2+1); - hvec1[0]= bevp->vec[0]; - hvec1[1]= bevp->vec[1]; - hvec1[2]= 0.0; + bevp = (BevPoint *)(bl2 + 1); + hvec1[0] = bevp->vec[0]; + hvec1[1] = bevp->vec[1]; + hvec1[2] = 0.0; copy_v3_v3(hvec2, hvec1); - hvec2[0]+=1000; + hvec2[0] += 1000; /* test it with all edges of potential surounding poly */ /* count number of transitions left-right */ - bevp= (BevPoint *)(bl1+1); - nr= bl1->nr; - prevbevp= bevp+(nr-1); + bevp = (BevPoint *)(bl1 + 1); + nr = bl1->nr; + prevbevp = bevp + (nr - 1); while (nr--) { - min= prevbevp->vec[1]; - max= bevp->vec[1]; - if (maxvec[1]; + min = prevbevp->vec[1]; + max = bevp->vec[1]; + if (max < min) { + min = max; + max = prevbevp->vec[1]; } - if (min!=max) { - if (min<=hvec1[1] && max>=hvec1[1]) { + if (min != max) { + if (min <= hvec1[1] && max >= hvec1[1]) { /* there's a transition, calc intersection point */ - mode= cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec); + mode = cu_isectLL(prevbevp->vec, bevp->vec, hvec1, hvec2, 0, 1, &lab, &mu, vec); /* if lab==0.0 or lab==1.0 then the edge intersects exactly a transition * only allow for one situation: we choose lab= 1.0 */ if (mode >= 0 && lab != 0.0f) { - if (vec[0]left > x2->left ) return 1; - else if ( x1->left < x2->left) return -1; + if (x1->left > x2->left) + return 1; + else if (x1->left < x2->left) + return -1; return 0; } @@ -1620,103 +1699,119 @@ static void calc_bevel_sin_cos(float x1, float y1, float x2, float y2, float *si { float t01, t02, x3, y3; - t01= (float)sqrt(x1*x1+y1*y1); - t02= (float)sqrt(x2*x2+y2*y2); - if (t01==0.0f) t01= 1.0f; - if (t02==0.0f) t02= 1.0f; + t01 = (float)sqrt(x1 * x1 + y1 * y1); + t02 = (float)sqrt(x2 * x2 + y2 * y2); + if (t01 == 0.0f) + t01 = 1.0f; + if (t02 == 0.0f) + t02 = 1.0f; - x1/=t01; - y1/=t01; - x2/=t02; - y2/=t02; + x1 /= t01; + y1 /= t01; + x2 /= t02; + y2 /= t02; - t02= x1*x2+y1*y2; - if (fabs(t02)>=1.0) t02= .5*M_PI; - else t02= (saacos(t02))/2.0f; + t02 = x1 * x2 + y1 * y2; + if (fabs(t02) >= 1.0) + t02 = .5 * M_PI; + else + t02 = (saacos(t02)) / 2.0f; - t02= (float)sin(t02); - if (t02==0.0f) t02= 1.0f; + t02 = (float)sin(t02); + if (t02 == 0.0f) + t02 = 1.0f; - x3= x1-x2; - y3= y1-y2; - if (x3==0 && y3==0) { - x3= y1; - y3= -x1; + x3 = x1 - x2; + y3 = y1 - y2; + if (x3 == 0 && y3 == 0) { + x3 = y1; + y3 = -x1; } else { - t01= (float)sqrt(x3*x3+y3*y3); - x3/=t01; - y3/=t01; + t01 = (float)sqrt(x3 * x3 + y3 * y3); + x3 /= t01; + y3 /= t01; } - *sina= -y3/t02; - *cosa= x3/t02; + *sina = -y3 / t02; + *cosa = x3 / t02; } -static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, float *weight_array, int resolu, int stride) +static void alfa_bezpart(BezTriple *prevbezt, BezTriple *bezt, Nurb *nu, float *tilt_array, float *radius_array, + float *weight_array, int resolu, int stride) { BezTriple *pprev, *next, *last; float fac, dfac, t[4]; int a; - - if (tilt_array==NULL && radius_array==NULL) + + if (tilt_array == NULL && radius_array == NULL) return; - - last= nu->bezt+(nu->pntsu-1); - + + last = nu->bezt + (nu->pntsu - 1); + /* returns a point */ - if (prevbezt==nu->bezt) { - if (nu->flagu & CU_NURB_CYCLIC) pprev= last; - else pprev= prevbezt; + if (prevbezt == nu->bezt) { + if (nu->flagu & CU_NURB_CYCLIC) + pprev = last; + else + pprev = prevbezt; } - else pprev= prevbezt-1; - + else + pprev = prevbezt - 1; + /* next point */ - if (bezt==last) { - if (nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; - else next= bezt; + if (bezt == last) { + if (nu->flagu & CU_NURB_CYCLIC) + next = nu->bezt; + else + next = bezt; } - else next= bezt+1; - - fac= 0.0; - dfac= 1.0f/(float)resolu; - - for (a=0; atilt_interp==KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */ - *tilt_array = prevbezt->alfa + (bezt->alfa - prevbezt->alfa)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + if (nu->tilt_interp == KEY_CU_EASE) { /* May as well support for tilt also 2.47 ease interp */ + *tilt_array = prevbezt->alfa + + (bezt->alfa - prevbezt->alfa) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { key_curve_position_weights(fac, t, nu->tilt_interp); - *tilt_array= t[0]*pprev->alfa + t[1]*prevbezt->alfa + t[2]*bezt->alfa + t[3]*next->alfa; + *tilt_array = t[0] * pprev->alfa + t[1] * prevbezt->alfa + t[2] * bezt->alfa + t[3] * next->alfa; } - - tilt_array = (float *)(((char *)tilt_array) + stride); + + tilt_array = (float *)(((char *)tilt_array) + stride); } - + if (radius_array) { - if (nu->radius_interp==KEY_CU_EASE) { + if (nu->radius_interp == KEY_CU_EASE) { /* Support 2.47 ease interp * Note! - this only takes the 2 points into account, * giving much more localized results to changes in radius, sometimes you want that */ - *radius_array = prevbezt->radius + (bezt->radius - prevbezt->radius)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + *radius_array = prevbezt->radius + + (bezt->radius - prevbezt->radius) * (3.0f * fac * fac - 2.0f * fac * fac * fac); } else { - + /* reuse interpolation from tilt if we can */ - if (tilt_array==NULL || nu->tilt_interp != nu->radius_interp) { + if (tilt_array == NULL || nu->tilt_interp != nu->radius_interp) { key_curve_position_weights(fac, t, nu->radius_interp); } - *radius_array= t[0]*pprev->radius + t[1]*prevbezt->radius + t[2]*bezt->radius + t[3]*next->radius; + *radius_array = t[0] * pprev->radius + t[1] * prevbezt->radius + + t[2] * bezt->radius + t[3] * next->radius; } - - radius_array = (float *)(((char *)radius_array) + stride); + + radius_array = (float *)(((char *)radius_array) + stride); } if (weight_array) { /* basic interpolation for now, could copy tilt interp too */ - *weight_array = prevbezt->weight + (bezt->weight - prevbezt->weight)*(3.0f*fac*fac - 2.0f*fac*fac*fac); + *weight_array = prevbezt->weight + + (bezt->weight - prevbezt->weight) * (3.0f * fac * fac - 2.0f * fac * fac * fac); weight_array = (float *)(((char *)weight_array) + stride); } @@ -1732,35 +1827,36 @@ static void bevel_list_cyclic_fix_3D(BevList *bl) { BevPoint *bevp, *bevp1; - bevp= (BevPoint *)(bl+1); - bevp1= bevp+1; + bevp = (BevPoint *)(bl + 1); + bevp1 = bevp + 1; copy_qt_qt(bevp->quat, bevp1->quat); copy_v3_v3(bevp->dir, bevp1->dir); copy_v3_v3(bevp->tan, bevp1->tan); - bevp= (BevPoint *)(bl+1); - bevp+= (bl->nr-1); - bevp1= bevp-1; + bevp = (BevPoint *)(bl + 1); + bevp += (bl->nr - 1); + bevp1 = bevp - 1; copy_qt_qt(bevp->quat, bevp1->quat); copy_v3_v3(bevp->dir, bevp1->dir); copy_v3_v3(bevp->tan, bevp1->tan); } + /* utility for make_bevel_list_3D_* funcs */ static void bevel_list_calc_bisect(BevList *bl) { BevPoint *bevp2, *bevp1, *bevp0; int nr; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { /* totally simple */ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1769,17 +1865,17 @@ static void bevel_list_flip_tangents(BevList *bl) BevPoint *bevp2, *bevp1, *bevp0; int nr; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { if (RAD2DEGF(angle_v2v2(bevp0->tan, bevp1->tan)) > 90.0f) negate_v3(bevp1->tan); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1790,16 +1886,16 @@ static void bevel_list_apply_tilt(BevList *bl) int nr; float q[4]; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); - nr= bl->nr; + nr = bl->nr; while (nr--) { axis_angle_to_quat(q, bevp1->dir, bevp1->alfa); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); normalize_qt(bevp1->quat); - bevp1= bevp2; + bevp1 = bevp2; bevp2++; } } @@ -1813,26 +1909,24 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) float bevp0_quat[4]; int a; - for (a=0; a < smooth_iter; a++) { + for (a = 0; a < smooth_iter; a++) { + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + nr = bl->nr; - nr= bl->nr; - - if (bl->poly== -1) { /* check its not cyclic */ + if (bl->poly == -1) { /* check its not cyclic */ /* skip the first point */ /* bevp0= bevp1; */ - bevp1= bevp2; + bevp1 = bevp2; bevp2++; nr--; - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; nr--; - } copy_qt_qt(bevp0_quat, bevp0->quat); @@ -1853,9 +1947,8 @@ static void bevel_list_smooth(BevList *bl, int smooth_iter) interp_qt_qtqt(bevp1->quat, bevp1->quat, q, 0.5); normalize_qt(bevp1->quat); - /* bevp0= bevp1; */ /* UNUSED */ - bevp1= bevp2; + bevp1 = bevp2; bevp2++; } } @@ -1866,18 +1959,18 @@ static void make_bevel_list_3D_zup(BevList *bl) BevPoint *bevp2, *bevp1, *bevp0; /* standard for all make_bevel_list_3D_* funcs */ int nr; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { /* totally simple */ bisect_v3_v3v3v3(bevp1->dir, bevp0->vec, bevp1->vec, bevp2->vec); vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1890,18 +1983,18 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) bevel_list_calc_bisect(bl); - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - if (nr+4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ + if (nr + 4 > bl->nr) { /* first time and second time, otherwise first point adjusts last */ vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); } else { - float angle= angle_normalized_v3v3(bevp0->dir, bevp1->dir); + float angle = angle_normalized_v3v3(bevp0->dir, bevp1->dir); if (angle > 0.0f) { /* otherwise we can keep as is */ float cross_tmp[3]; @@ -1914,8 +2007,8 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) } } - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } @@ -1932,14 +2025,14 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) * * this is why we compare last with second last * */ - float vec_1[3]= {0, 1, 0}, vec_2[3]= {0, 1, 0}, angle, ang_fac, cross_tmp[3]; + float vec_1[3] = {0, 1, 0}, vec_2[3] = {0, 1, 0}, angle, ang_fac, cross_tmp[3]; BevPoint *bevp_first; BevPoint *bevp_last; - bevp_first= (BevPoint *)(bl+1); - bevp_first+= bl->nr-1; + bevp_first = (BevPoint *)(bl + 1); + bevp_first += bl->nr - 1; bevp_last = bevp_first; bevp_last--; @@ -1950,7 +2043,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) normalize_v3(vec_2); /* align the vector, can avoid this and it looks 98% OK but - * better to align the angle quat roll's before comparing */ + * better to align the angle quat roll's before comparing */ { cross_v3_v3v3(cross_tmp, bevp_last->dir, bevp_first->dir); angle = angle_normalized_v3v3(bevp_first->dir, bevp_last->dir); @@ -1958,7 +2051,7 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) mul_qt_v3(q, vec_2); } - angle= angle_normalized_v3v3(vec_1, vec_2); + angle = angle_normalized_v3v3(vec_1, vec_2); /* flip rotation if needs be */ cross_v3_v3v3(cross_tmp, vec_1, vec_2); @@ -1966,19 +2059,19 @@ static void make_bevel_list_3D_minimum_twist(BevList *bl) if (angle_normalized_v3v3(bevp_first->dir, cross_tmp) < DEG2RADF(90.0f)) angle = -angle; - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - ang_fac= angle * (1.0f-((float)nr/bl->nr)); /* also works */ + ang_fac = angle * (1.0f - ((float)nr / bl->nr)); /* also works */ axis_angle_to_quat(q, bevp1->dir, ang_fac); mul_qt_qtqt(bevp1->quat, q, bevp1->quat); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } } @@ -1992,38 +2085,36 @@ static void make_bevel_list_3D_tangent(BevList *bl) float bevp0_tan[3], cross_tmp[3]; bevel_list_calc_bisect(bl); - if (bl->poly== -1) /* check its not cyclic */ - bevel_list_cyclic_fix_3D(bl); // XXX - run this now so tangents will be right before doing the flipping + if (bl->poly == -1) /* check its not cyclic */ + bevel_list_cyclic_fix_3D(bl); // XXX - run this now so tangents will be right before doing the flipping bevel_list_flip_tangents(bl); /* correct the tangents */ - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); cross_v3_v3v3(bevp1->tan, cross_tmp, bevp1->dir); normalize_v3(bevp1->tan); - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } /* now for the real twist calc */ - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; copy_v3_v3(bevp0_tan, bevp0->tan); - nr= bl->nr; + nr = bl->nr; while (nr--) { - /* make perpendicular, modify tan in place, is ok */ float cross_tmp[3]; float zero[3] = {0, 0, 0}; @@ -2033,7 +2124,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) tri_to_quat(bevp1->quat, zero, cross_tmp, bevp1->tan); /* XXX - could be faster */ /* bevp0= bevp1; */ /* UNUSED */ - bevp1= bevp2; + bevp1 = bevp2; bevp2++; } } @@ -2041,17 +2132,17 @@ static void make_bevel_list_3D_tangent(BevList *bl) static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode) { switch (twist_mode) { - case CU_TWIST_TANGENT: - make_bevel_list_3D_tangent(bl); - break; - case CU_TWIST_MINIMUM: - make_bevel_list_3D_minimum_twist(bl); - break; - default: /* CU_TWIST_Z_UP default, pre 2.49c */ - make_bevel_list_3D_zup(bl); + case CU_TWIST_TANGENT: + make_bevel_list_3D_tangent(bl); + break; + case CU_TWIST_MINIMUM: + make_bevel_list_3D_minimum_twist(bl); + break; + default: /* CU_TWIST_Z_UP default, pre 2.49c */ + make_bevel_list_3D_zup(bl); } - if (bl->poly== -1) /* check its not cyclic */ + if (bl->poly == -1) /* check its not cyclic */ bevel_list_cyclic_fix_3D(bl); if (smooth_iter) @@ -2060,15 +2151,13 @@ static void make_bevel_list_3D(BevList *bl, int smooth_iter, int twist_mode) bevel_list_apply_tilt(bl); } - - /* only for 2 points */ static void make_bevel_list_segment_3D(BevList *bl) { float q[4]; - BevPoint *bevp2= (BevPoint *)(bl+1); - BevPoint *bevp1= bevp2+1; + BevPoint *bevp2 = (BevPoint *)(bl + 1); + BevPoint *bevp1 = bevp2 + 1; /* simple quat/dir */ sub_v3_v3v3(bevp1->dir, bevp1->vec, bevp2->vec); @@ -2083,8 +2172,6 @@ static void make_bevel_list_segment_3D(BevList *bl) copy_qt_qt(bevp2->quat, bevp1->quat); } - - void BKE_curve_bevelList_make(Object *ob) { /* @@ -2103,160 +2190,162 @@ void BKE_curve_bevelList_make(Object *ob) struct bevelsort *sortdata, *sd, *sd1; int a, b, nr, poly, resolu = 0, len = 0; int do_tilt, do_radius, do_weight; - + /* this function needs an object, because of tflag and upflag */ - cu= ob->data; + cu = ob->data; /* do we need to calculate the radius for each point? */ /* do_radius = (cu->bevobj || cu->taperobj || (cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ? 0 : 1; */ - + /* STEP 1: MAKE POLYS */ BLI_freelistN(&(cu->bev)); - if (cu->editnurb && ob->type!=OB_FONT) { - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + if (cu->editnurb && ob->type != OB_FONT) { + ListBase *nurbs = BKE_curve_editNurbs_get(cu); nu = nurbs->first; } else { nu = cu->nurb.first; } - + while (nu) { - /* check if we will calculate tilt data */ do_tilt = CU_DO_TILT(cu, nu); do_radius = CU_DO_RADIUS(cu, nu); /* normal display uses the radius, better just to calculate them */ do_weight = 1; - + /* check we are a single point? also check we are not a surface and that the orderu is sane, * enforced in the UI but can go wrong possibly */ if (!BKE_nurb_check_valid_u(nu)) { - bl= MEM_callocN(sizeof(BevList)+1*sizeof(BevPoint), "makeBevelList1"); + bl = MEM_callocN(sizeof(BevList) + 1 * sizeof(BevPoint), "makeBevelList1"); BLI_addtail(&(cu->bev), bl); - bl->nr= 0; + bl->nr = 0; } else { - if (G.rendering && cu->resolu_ren!=0) - resolu= cu->resolu_ren; + if (G.rendering && cu->resolu_ren != 0) + resolu = cu->resolu_ren; else - resolu= nu->resolu; - + resolu = nu->resolu; + if (nu->type == CU_POLY) { - len= nu->pntsu; - bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList2"); + len = nu->pntsu; + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList2"); BLI_addtail(&(cu->bev), bl); - - if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; - else bl->poly= -1; - bl->nr= len; - bl->dupe_nr= 0; - bevp= (BevPoint *)(bl+1); - bp= nu->bp; - + + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; + else bl->poly = -1; + bl->nr = len; + bl->dupe_nr = 0; + bevp = (BevPoint *)(bl + 1); + bp = nu->bp; + while (len--) { copy_v3_v3(bevp->vec, bp->vec); - bevp->alfa= bp->alfa; - bevp->radius= bp->radius; - bevp->weight= bp->weight; - bevp->split_tag= TRUE; + bevp->alfa = bp->alfa; + bevp->radius = bp->radius; + bevp->weight = bp->weight; + bevp->split_tag = TRUE; bevp++; bp++; } } else if (nu->type == CU_BEZIER) { - - len= resolu*(nu->pntsu+ (nu->flagu & CU_NURB_CYCLIC) -1)+1; /* in case last point is not cyclic */ - bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelBPoints"); + /* in case last point is not cyclic */ + len = resolu * (nu->pntsu + (nu->flagu & CU_NURB_CYCLIC) - 1) + 1; + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelBPoints"); BLI_addtail(&(cu->bev), bl); - - if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; - else bl->poly= -1; - bevp= (BevPoint *)(bl+1); - - a= nu->pntsu-1; - bezt= nu->bezt; + + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; + else bl->poly = -1; + bevp = (BevPoint *)(bl + 1); + + a = nu->pntsu - 1; + bezt = nu->bezt; if (nu->flagu & CU_NURB_CYCLIC) { a++; - prevbezt= nu->bezt+(nu->pntsu-1); + prevbezt = nu->bezt + (nu->pntsu - 1); } else { - prevbezt= bezt; + prevbezt = bezt; bezt++; } - + while (a--) { - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) { + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { copy_v3_v3(bevp->vec, prevbezt->vec[1]); - bevp->alfa= prevbezt->alfa; - bevp->radius= prevbezt->radius; - bevp->weight= prevbezt->weight; - bevp->split_tag= TRUE; - bevp->dupe_tag= FALSE; + bevp->alfa = prevbezt->alfa; + bevp->radius = prevbezt->radius; + bevp->weight = prevbezt->weight; + bevp->split_tag = TRUE; + bevp->dupe_tag = FALSE; bevp++; bl->nr++; - bl->dupe_nr= 1; + bl->dupe_nr = 1; } else { /* always do all three, to prevent data hanging around */ int j; - + /* BevPoint must stay aligned to 4 so sizeof(BevPoint)/sizeof(float) works */ - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], bezt->vec[1][j], &(bevp->vec[j]), resolu, sizeof(BevPoint)); } - + /* if both arrays are NULL do nothiong */ alfa_bezpart(prevbezt, bezt, nu, - do_tilt ? &bevp->alfa : NULL, - do_radius ? &bevp->radius : NULL, - do_weight ? &bevp->weight : NULL, + do_tilt ? &bevp->alfa : NULL, + do_radius ? &bevp->radius : NULL, + do_weight ? &bevp->weight : NULL, resolu, sizeof(BevPoint)); - - if (cu->twist_mode==CU_TWIST_TANGENT) { + + if (cu->twist_mode == CU_TWIST_TANGENT) { forward_diff_bezier_cotangent(prevbezt->vec[1], prevbezt->vec[2], bezt->vec[0], bezt->vec[1], bevp->tan, resolu, sizeof(BevPoint)); } /* indicate with handlecodes double points */ - if (prevbezt->h1==prevbezt->h2) { - if (prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE; + if (prevbezt->h1 == prevbezt->h2) { + if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) + bevp->split_tag = TRUE; } else { - if (prevbezt->h1==0 || prevbezt->h1==HD_VECT) bevp->split_tag= TRUE; - else if (prevbezt->h2==0 || prevbezt->h2==HD_VECT) bevp->split_tag= TRUE; + if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) + bevp->split_tag = TRUE; + else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) + bevp->split_tag = TRUE; } - bl->nr+= resolu; - bevp+= resolu; + bl->nr += resolu; + bevp += resolu; } - prevbezt= bezt; + prevbezt = bezt; bezt++; } - - if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic: endpoint */ + + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic: endpoint */ copy_v3_v3(bevp->vec, prevbezt->vec[1]); - bevp->alfa= prevbezt->alfa; - bevp->radius= prevbezt->radius; - bevp->weight= prevbezt->weight; + bevp->alfa = prevbezt->alfa; + bevp->radius = prevbezt->radius; + bevp->weight = prevbezt->weight; bl->nr++; } } else if (nu->type == CU_NURBS) { - if (nu->pntsv==1) { - len= (resolu*SEGMENTSU(nu)); - - bl= MEM_callocN(sizeof(BevList)+len*sizeof(BevPoint), "makeBevelList3"); + if (nu->pntsv == 1) { + len = (resolu * SEGMENTSU(nu)); + + bl = MEM_callocN(sizeof(BevList) + len * sizeof(BevPoint), "makeBevelList3"); BLI_addtail(&(cu->bev), bl); - bl->nr= len; - bl->dupe_nr= 0; - if (nu->flagu & CU_NURB_CYCLIC) bl->poly= 0; - else bl->poly= -1; - bevp= (BevPoint *)(bl+1); - + bl->nr = len; + bl->dupe_nr = 0; + if (nu->flagu & CU_NURB_CYCLIC) bl->poly = 0; + else bl->poly = -1; + bevp = (BevPoint *)(bl + 1); + BKE_nurb_makeCurve(nu, &bevp->vec[0], do_tilt ? &bevp->alfa : NULL, do_radius ? &bevp->radius : NULL, @@ -2265,47 +2354,47 @@ void BKE_curve_bevelList_make(Object *ob) } } } - nu= nu->next; + nu = nu->next; } /* STEP 2: DOUBLE POINTS AND AUTOMATIC RESOLUTION, REDUCE DATABLOCKS */ - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { if (bl->nr) { /* null bevel items come from single points */ - nr= bl->nr; - bevp1= (BevPoint *)(bl+1); - bevp0= bevp1+(nr-1); + nr = bl->nr; + bevp1 = (BevPoint *)(bl + 1); + bevp0 = bevp1 + (nr - 1); nr--; while (nr--) { - if ( fabs(bevp0->vec[0]-bevp1->vec[0])<0.00001 ) { - if ( fabs(bevp0->vec[1]-bevp1->vec[1])<0.00001 ) { - if ( fabs(bevp0->vec[2]-bevp1->vec[2])<0.00001 ) { - bevp0->dupe_tag= TRUE; + if (fabs(bevp0->vec[0] - bevp1->vec[0]) < 0.00001) { + if (fabs(bevp0->vec[1] - bevp1->vec[1]) < 0.00001) { + if (fabs(bevp0->vec[2] - bevp1->vec[2]) < 0.00001) { + bevp0->dupe_tag = TRUE; bl->dupe_nr++; } } } - bevp0= bevp1; + bevp0 = bevp1; bevp1++; } } - bl= bl->next; + bl = bl->next; } - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { - blnext= bl->next; + blnext = bl->next; if (bl->nr && bl->dupe_nr) { - nr= bl->nr- bl->dupe_nr+1; /* +1 because vectorbezier sets flag too */ - blnew= MEM_mallocN(sizeof(BevList)+nr*sizeof(BevPoint), "makeBevelList4"); + nr = bl->nr - bl->dupe_nr + 1; /* +1 because vectorbezier sets flag too */ + blnew = MEM_mallocN(sizeof(BevList) + nr * sizeof(BevPoint), "makeBevelList4"); memcpy(blnew, bl, sizeof(BevList)); - blnew->nr= 0; + blnew->nr = 0; BLI_remlink(&(cu->bev), bl); - BLI_insertlinkbefore(&(cu->bev), blnext, blnew); /* to make sure bevlijst is tuned with nurblist */ - bevp0= (BevPoint *)(bl+1); - bevp1= (BevPoint *)(blnew+1); - nr= bl->nr; + BLI_insertlinkbefore(&(cu->bev), blnext, blnew); /* to make sure bevlijst is tuned with nurblist */ + bevp0 = (BevPoint *)(bl + 1); + bevp1 = (BevPoint *)(blnew + 1); + nr = bl->nr; while (nr--) { - if (bevp0->dupe_tag==0) { + if (bevp0->dupe_tag == 0) { memcpy(bevp1, bevp0, sizeof(BevPoint)); bevp1++; blnew->nr++; @@ -2313,84 +2402,90 @@ void BKE_curve_bevelList_make(Object *ob) bevp0++; } MEM_freeN(bl); - blnew->dupe_nr= 0; + blnew->dupe_nr = 0; } - bl= blnext; + bl = blnext; } /* STEP 3: POLYS COUNT AND AUTOHOLE */ - bl= cu->bev.first; - poly= 0; + bl = cu->bev.first; + poly = 0; while (bl) { - if (bl->nr && bl->poly>=0) { + if (bl->nr && bl->poly >= 0) { poly++; - bl->poly= poly; - bl->hole= 0; + bl->poly = poly; + bl->hole = 0; } - bl= bl->next; + bl = bl->next; } - /* find extreme left points, also test (turning) direction */ - if (poly>0) { - sd= sortdata= MEM_mallocN(sizeof(struct bevelsort)*poly, "makeBevelList5"); - bl= cu->bev.first; + if (poly > 0) { + sd = sortdata = MEM_mallocN(sizeof(struct bevelsort) * poly, "makeBevelList5"); + bl = cu->bev.first; while (bl) { - if (bl->poly>0) { + if (bl->poly > 0) { - min= 300000.0; - bevp= (BevPoint *)(bl+1); - nr= bl->nr; + min = 300000.0; + bevp = (BevPoint *)(bl + 1); + nr = bl->nr; while (nr--) { - if (min>bevp->vec[0]) { - min= bevp->vec[0]; - bevp1= bevp; + if (min > bevp->vec[0]) { + min = bevp->vec[0]; + bevp1 = bevp; } bevp++; } - sd->bl= bl; - sd->left= min; + sd->bl = bl; + sd->left = min; - bevp= (BevPoint *)(bl+1); - if (bevp1== bevp) bevp0= bevp+ (bl->nr-1); - else bevp0= bevp1-1; - bevp= bevp+ (bl->nr-1); - if (bevp1== bevp) bevp2= (BevPoint *)(bl+1); - else bevp2= bevp1+1; + bevp = (BevPoint *)(bl + 1); + if (bevp1 == bevp) + bevp0 = bevp + (bl->nr - 1); + else + bevp0 = bevp1 - 1; + bevp = bevp + (bl->nr - 1); + if (bevp1 == bevp) + bevp2 = (BevPoint *)(bl + 1); + else + bevp2 = bevp1 + 1; - inp= (bevp1->vec[0]- bevp0->vec[0]) * (bevp0->vec[1]- bevp2->vec[1]) + (bevp0->vec[1]- bevp1->vec[1]) * (bevp0->vec[0]- bevp2->vec[0]); + inp = (bevp1->vec[0] - bevp0->vec[0]) * (bevp0->vec[1] - bevp2->vec[1]) + + (bevp0->vec[1] - bevp1->vec[1]) * (bevp0->vec[0] - bevp2->vec[0]); - if (inp > 0.0f) sd->dir= 1; - else sd->dir= 0; + if (inp > 0.0f) + sd->dir = 1; + else + sd->dir = 0; sd++; } - bl= bl->next; + bl = bl->next; } qsort(sortdata, poly, sizeof(struct bevelsort), vergxcobev); - sd= sortdata+1; - for (a=1; abl; /* is bl a hole? */ - sd1= sortdata+ (a-1); - for (b=a-1; b>=0; b--, sd1--) { /* all polys to the left */ + sd = sortdata + 1; + for (a = 1; a < poly; a++, sd++) { + bl = sd->bl; /* is bl a hole? */ + sd1 = sortdata + (a - 1); + for (b = a - 1; b >= 0; b--, sd1--) { /* all polys to the left */ if (bevelinside(sd1->bl, bl)) { - bl->hole= 1- sd1->bl->hole; + bl->hole = 1 - sd1->bl->hole; break; } } } /* turning direction */ - if ((cu->flag & CU_3D)==0) { - sd= sortdata; - for (a=0; abl->hole==sd->dir) { - bl= sd->bl; - bevp1= (BevPoint *)(bl+1); - bevp2= bevp1+ (bl->nr-1); - nr= bl->nr/2; + if ((cu->flag & CU_3D) == 0) { + sd = sortdata; + for (a = 0; a < poly; a++, sd++) { + if (sd->bl->hole == sd->dir) { + bl = sd->bl; + bevp1 = (BevPoint *)(bl + 1); + bevp2 = bevp1 + (bl->nr - 1); + nr = bl->nr / 2; while (nr--) { SWAP(BevPoint, *bevp1, *bevp2); bevp1++; @@ -2403,40 +2498,40 @@ void BKE_curve_bevelList_make(Object *ob) } /* STEP 4: 2D-COSINES or 3D ORIENTATION */ - if ((cu->flag & CU_3D)==0) { + if ((cu->flag & CU_3D) == 0) { /* note: bevp->dir and bevp->quat are not needed for beveling but are * used when making a path from a 2D curve, therefor they need to be set - Campbell */ - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { if (bl->nr < 2) { /* do nothing */ } - else if (bl->nr==2) { /* 2 pnt, treat separate */ - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+1; + else if (bl->nr == 2) { /* 2 pnt, treat separate */ + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + 1; - x1= bevp1->vec[0]- bevp2->vec[0]; - y1= bevp1->vec[1]- bevp2->vec[1]; + x1 = bevp1->vec[0] - bevp2->vec[0]; + y1 = bevp1->vec[1] - bevp2->vec[1]; calc_bevel_sin_cos(x1, y1, -x1, -y1, &(bevp1->sina), &(bevp1->cosa)); - bevp2->sina= bevp1->sina; - bevp2->cosa= bevp1->cosa; + bevp2->sina = bevp1->sina; + bevp2->cosa = bevp1->cosa; /* fill in dir & quat */ make_bevel_list_segment_3D(bl); } else { - bevp2= (BevPoint *)(bl+1); - bevp1= bevp2+(bl->nr-1); - bevp0= bevp1-1; + bevp2 = (BevPoint *)(bl + 1); + bevp1 = bevp2 + (bl->nr - 1); + bevp0 = bevp1 - 1; - nr= bl->nr; + nr = bl->nr; while (nr--) { - x1= bevp1->vec[0]- bevp0->vec[0]; - x2= bevp1->vec[0]- bevp2->vec[0]; - y1= bevp1->vec[1]- bevp0->vec[1]; - y2= bevp1->vec[1]- bevp2->vec[1]; + x1 = bevp1->vec[0] - bevp0->vec[0]; + x2 = bevp1->vec[0] - bevp2->vec[0]; + y1 = bevp1->vec[1] - bevp0->vec[1]; + y2 = bevp1->vec[1] - bevp2->vec[1]; calc_bevel_sin_cos(x1, y1, x2, y2, &(bevp1->sina), &(bevp1->cosa)); @@ -2446,44 +2541,44 @@ void BKE_curve_bevelList_make(Object *ob) vec_to_quat(bevp1->quat, bevp1->dir, 5, 1); /* done with inline make_bevel_list_3D_zup */ - bevp0= bevp1; - bevp1= bevp2; + bevp0 = bevp1; + bevp1 = bevp2; bevp2++; } /* correct non-cyclic cases */ - if (bl->poly== -1) { - bevp= (BevPoint *)(bl+1); - bevp1= bevp+1; - bevp->sina= bevp1->sina; - bevp->cosa= bevp1->cosa; - bevp= (BevPoint *)(bl+1); - bevp+= (bl->nr-1); - bevp1= bevp-1; - bevp->sina= bevp1->sina; - bevp->cosa= bevp1->cosa; + if (bl->poly == -1) { + bevp = (BevPoint *)(bl + 1); + bevp1 = bevp + 1; + bevp->sina = bevp1->sina; + bevp->cosa = bevp1->cosa; + bevp = (BevPoint *)(bl + 1); + bevp += (bl->nr - 1); + bevp1 = bevp - 1; + bevp->sina = bevp1->sina; + bevp->cosa = bevp1->cosa; /* correct for the dir/quat, see above why its needed */ bevel_list_cyclic_fix_3D(bl); } } - bl= bl->next; + bl = bl->next; } } else { /* 3D Curves */ - bl= cu->bev.first; + bl = cu->bev.first; while (bl) { if (bl->nr < 2) { /* do nothing */ } - else if (bl->nr==2) { /* 2 pnt, treat separate */ + else if (bl->nr == 2) { /* 2 pnt, treat separate */ make_bevel_list_segment_3D(bl); } else { - make_bevel_list_3D(bl, (int)(resolu*cu->twist_smooth), cu->twist_mode); + make_bevel_list_3D(bl, (int)(resolu * cu->twist_smooth), cu->twist_mode); } - bl= bl->next; + bl = bl->next; } } } @@ -2501,111 +2596,113 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n float *p1, *p2, *p3, pt[3]; float dvec_a[3], dvec_b[3]; float len, len_a, len_b; - const float eps= 1e-5; + const float eps = 1e-5; - if (bezt->h1==0 && bezt->h2==0) { + if (bezt->h1 == 0 && bezt->h2 == 0) { return; } - p2= bezt->vec[1]; + p2 = bezt->vec[1]; - if (prev==NULL) { - p3= next->vec[1]; - pt[0]= 2.0f*p2[0] - p3[0]; - pt[1]= 2.0f*p2[1] - p3[1]; - pt[2]= 2.0f*p2[2] - p3[2]; - p1= pt; + if (prev == NULL) { + p3 = next->vec[1]; + pt[0] = 2.0f * p2[0] - p3[0]; + pt[1] = 2.0f * p2[1] - p3[1]; + pt[2] = 2.0f * p2[2] - p3[2]; + p1 = pt; } else { - p1= prev->vec[1]; + p1 = prev->vec[1]; } - if (next==NULL) { - pt[0]= 2.0f*p2[0] - p1[0]; - pt[1]= 2.0f*p2[1] - p1[1]; - pt[2]= 2.0f*p2[2] - p1[2]; - p3= pt; + if (next == NULL) { + pt[0] = 2.0f * p2[0] - p1[0]; + pt[1] = 2.0f * p2[1] - p1[1]; + pt[2] = 2.0f * p2[2] - p1[2]; + p3 = pt; } else { - p3= next->vec[1]; + p3 = next->vec[1]; } sub_v3_v3v3(dvec_a, p2, p1); sub_v3_v3v3(dvec_b, p3, p2); if (mode != 0) { - len_a= dvec_a[0]; - len_b= dvec_b[0]; + len_a = dvec_a[0]; + len_b = dvec_b[0]; } else { - len_a= len_v3(dvec_a); - len_b= len_v3(dvec_b); + len_a = len_v3(dvec_a); + len_b = len_v3(dvec_b); } - if (len_a==0.0f) len_a=1.0f; - if (len_b==0.0f) len_b=1.0f; + if (len_a == 0.0f) len_a = 1.0f; + if (len_b == 0.0f) len_b = 1.0f; if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) || ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ float tvec[3]; - tvec[0]= dvec_b[0]/len_b + dvec_a[0]/len_a; - tvec[1]= dvec_b[1]/len_b + dvec_a[1]/len_a; - tvec[2]= dvec_b[2]/len_b + dvec_a[2]/len_a; - len= len_v3(tvec) * 2.5614f; + tvec[0] = dvec_b[0] / len_b + dvec_a[0] / len_a; + tvec[1] = dvec_b[1] / len_b + dvec_a[1] / len_a; + tvec[2] = dvec_b[2] / len_b + dvec_a[2] / len_a; + len = len_v3(tvec) * 2.5614f; + + if (len != 0.0f) { + int leftviolate = 0, rightviolate = 0; /* for mode==2 */ + + if (len_a > 5.0f * len_b) + len_a = 5.0f * len_b; + if (len_b > 5.0f * len_a) + len_b = 5.0f * len_a; - if (len!=0.0f) { - int leftviolate=0, rightviolate=0; /* for mode==2 */ - - if (len_a>5.0f*len_b) len_a= 5.0f*len_b; - if (len_b>5.0f*len_a) len_b= 5.0f*len_a; - if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { - len_a/=len; - madd_v3_v3v3fl(p2-3, p2, tvec, -len_a); - - if ((bezt->h1==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ - float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; - float ydiff2= next->vec[1][1] - bezt->vec[1][1]; - if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { - bezt->vec[0][1]= bezt->vec[1][1]; + len_a /= len; + madd_v3_v3v3fl(p2 - 3, p2, tvec, -len_a); + + if ((bezt->h1 == HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ + float ydiff1 = prev->vec[1][1] - bezt->vec[1][1]; + float ydiff2 = next->vec[1][1] - bezt->vec[1][1]; + if ((ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f)) { + bezt->vec[0][1] = bezt->vec[1][1]; } else { /* handles should not be beyond y coord of two others */ if (ydiff1 <= 0.0f) { if (prev->vec[1][1] > bezt->vec[0][1]) { - bezt->vec[0][1]= prev->vec[1][1]; - leftviolate= 1; + bezt->vec[0][1] = prev->vec[1][1]; + leftviolate = 1; } } else { if (prev->vec[1][1] < bezt->vec[0][1]) { - bezt->vec[0][1]= prev->vec[1][1]; - leftviolate= 1; + bezt->vec[0][1] = prev->vec[1][1]; + leftviolate = 1; } } } } } if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { - len_b/=len; - madd_v3_v3v3fl(p2+3, p2, tvec, len_b); - - if ((bezt->h2==HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ - float ydiff1= prev->vec[1][1] - bezt->vec[1][1]; - float ydiff2= next->vec[1][1] - bezt->vec[1][1]; + len_b /= len; + madd_v3_v3v3fl(p2 + 3, p2, tvec, len_b); + + if ((bezt->h2 == HD_AUTO_ANIM) && next && prev) { /* keep horizontal if extrema */ + float ydiff1 = prev->vec[1][1] - bezt->vec[1][1]; + float ydiff2 = next->vec[1][1] - bezt->vec[1][1]; if ( (ydiff1 <= 0.0f && ydiff2 <= 0.0f) || (ydiff1 >= 0.0f && ydiff2 >= 0.0f) ) { - bezt->vec[2][1]= bezt->vec[1][1]; + bezt->vec[2][1] = bezt->vec[1][1]; } else { /* andles should not be beyond y coord of two others */ if (ydiff1 <= 0.0f) { if (next->vec[1][1] < bezt->vec[2][1]) { - bezt->vec[2][1]= next->vec[1][1]; - rightviolate= 1; + bezt->vec[2][1] = next->vec[1][1]; + rightviolate = 1; } } else { if (next->vec[1][1] > bezt->vec[2][1]) { - bezt->vec[2][1]= next->vec[1][1]; - rightviolate= 1; + bezt->vec[2][1] = next->vec[1][1]; + rightviolate = 1; } } } @@ -2614,33 +2711,32 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n if (leftviolate || rightviolate) { /* align left handle */ float h1[3], h2[3]; float dot; - - sub_v3_v3v3(h1, p2-3, p2); - sub_v3_v3v3(h2, p2, p2+3); - len_a= normalize_v3(h1); - len_b= normalize_v3(h2); + sub_v3_v3v3(h1, p2 - 3, p2); + sub_v3_v3v3(h2, p2, p2 + 3); - dot= dot_v3v3(h1, h2); + len_a = normalize_v3(h1); + len_b = normalize_v3(h2); + + dot = dot_v3v3(h1, h2); if (leftviolate) { mul_v3_fl(h1, dot * len_b); - sub_v3_v3v3(p2+3, p2, h1); + sub_v3_v3v3(p2 + 3, p2, h1); } else { mul_v3_fl(h2, dot * len_a); - add_v3_v3v3(p2-3, p2, h2); + add_v3_v3v3(p2 - 3, p2, h2); } } - } } - if (bezt->h1==HD_VECT) { /* vector */ - madd_v3_v3v3fl(p2-3, p2, dvec_a, -1.0f/3.0f); + if (bezt->h1 == HD_VECT) { /* vector */ + madd_v3_v3v3fl(p2 - 3, p2, dvec_a, -1.0f / 3.0f); } - if (bezt->h2==HD_VECT) { - madd_v3_v3v3fl(p2+3, p2, dvec_b, 1.0f/3.0f); + if (bezt->h2 == HD_VECT) { + madd_v3_v3v3fl(p2 + 3, p2, dvec_b, 1.0f / 3.0f); } if (skip_align) { @@ -2650,44 +2746,46 @@ static void calchandleNurb_intern(BezTriple *bezt, BezTriple *prev, BezTriple *n return; } - len_b= len_v3v3(p2, p2+3); - len_a= len_v3v3(p2, p2-3); - if (len_a==0.0f) len_a= 1.0f; - if (len_b==0.0f) len_b= 1.0f; + len_b = len_v3v3(p2, p2 + 3); + len_a = len_v3v3(p2, p2 - 3); + if (len_a == 0.0f) + len_a = 1.0f; + if (len_b == 0.0f) + len_b = 1.0f; if (bezt->f1 & SELECT) { /* order of calculation */ - if (bezt->h2==HD_ALIGN) { /* aligned */ - if (len_a>eps) { - len= len_b/len_a; - p2[3]= p2[0]+len*(p2[0] - p2[-3]); - p2[4]= p2[1]+len*(p2[1] - p2[-2]); - p2[5]= p2[2]+len*(p2[2] - p2[-1]); + if (bezt->h2 == HD_ALIGN) { /* aligned */ + if (len_a > eps) { + len = len_b / len_a; + p2[3] = p2[0] + len * (p2[0] - p2[-3]); + p2[4] = p2[1] + len * (p2[1] - p2[-2]); + p2[5] = p2[2] + len * (p2[2] - p2[-1]); } } - if (bezt->h1==HD_ALIGN) { - if (len_b>eps) { - len= len_a/len_b; - p2[-3]= p2[0]+len*(p2[0] - p2[3]); - p2[-2]= p2[1]+len*(p2[1] - p2[4]); - p2[-1]= p2[2]+len*(p2[2] - p2[5]); + if (bezt->h1 == HD_ALIGN) { + if (len_b > eps) { + len = len_a / len_b; + p2[-3] = p2[0] + len * (p2[0] - p2[3]); + p2[-2] = p2[1] + len * (p2[1] - p2[4]); + p2[-1] = p2[2] + len * (p2[2] - p2[5]); } } } else { - if (bezt->h1==HD_ALIGN) { - if (len_b>eps) { - len= len_a/len_b; - p2[-3]= p2[0]+len*(p2[0] - p2[3]); - p2[-2]= p2[1]+len*(p2[1] - p2[4]); - p2[-1]= p2[2]+len*(p2[2] - p2[5]); + if (bezt->h1 == HD_ALIGN) { + if (len_b > eps) { + len = len_a / len_b; + p2[-3] = p2[0] + len * (p2[0] - p2[3]); + p2[-2] = p2[1] + len * (p2[1] - p2[4]); + p2[-1] = p2[2] + len * (p2[2] - p2[5]); } } - if (bezt->h2==HD_ALIGN) { /* aligned */ - if (len_a>eps) { - len= len_b/len_a; - p2[3]= p2[0]+len*(p2[0] - p2[-3]); - p2[4]= p2[1]+len*(p2[1] - p2[-2]); - p2[5]= p2[2]+len*(p2[2] - p2[-1]); + if (bezt->h2 == HD_ALIGN) { /* aligned */ + if (len_a > eps) { + len = len_b / len_a; + p2[3] = p2[0] + len * (p2[0] - p2[-3]); + p2[4] = p2[1] + len * (p2[1] - p2[-2]); + p2[5] = p2[2] + len * (p2[2] - p2[-1]); } } } @@ -2698,23 +2796,28 @@ static void calchandlesNurb_intern(Nurb *nu, int skip_align) BezTriple *bezt, *prev, *next; short a; - if (nu->type != CU_BEZIER) return; - if (nu->pntsu<2) return; - - a= nu->pntsu; - bezt= nu->bezt; - if (nu->flagu & CU_NURB_CYCLIC) prev= bezt+(a-1); - else prev= NULL; - next= bezt+1; + if (nu->type != CU_BEZIER) + return; + if (nu->pntsu < 2) + return; + + a = nu->pntsu; + bezt = nu->bezt; + if (nu->flagu & CU_NURB_CYCLIC) prev = bezt + (a - 1); + else prev = NULL; + next = bezt + 1; while (a--) { calchandleNurb_intern(bezt, prev, next, 0, skip_align); - prev= bezt; - if (a==1) { - if (nu->flagu & CU_NURB_CYCLIC) next= nu->bezt; - else next= NULL; + prev = bezt; + if (a == 1) { + if (nu->flagu & CU_NURB_CYCLIC) + next = nu->bezt; + else + next = NULL; } - else next++; + else + next++; bezt++; } @@ -2745,100 +2848,105 @@ void BKE_nurb_handles_test(Nurb *nu) if (nu->type != CU_BEZIER) return; - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - flag= 0; - if (bezt->f1 & SELECT) flag++; - if (bezt->f2 & SELECT) flag += 2; - if (bezt->f3 & SELECT) flag += 4; - - if ( !(flag==0 || flag==7) ) { + flag = 0; + if (bezt->f1 & SELECT) + flag++; + if (bezt->f2 & SELECT) + flag += 2; + if (bezt->f3 & SELECT) + flag += 4; + + if (!(flag == 0 || flag == 7) ) { if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ - bezt->h1= HD_ALIGN; + bezt->h1 = HD_ALIGN; } if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* auto */ - bezt->h2= HD_ALIGN; + bezt->h2 = HD_ALIGN; } - - if (bezt->h1==HD_VECT) { /* vector */ - if (flag < 4) bezt->h1= 0; + + if (bezt->h1 == HD_VECT) { /* vector */ + if (flag < 4) bezt->h1 = 0; } - if (bezt->h2==HD_VECT) { /* vector */ - if ( flag > 3) bezt->h2= 0; + if (bezt->h2 == HD_VECT) { /* vector */ + if (flag > 3) bezt->h2 = 0; } } bezt++; } - + BKE_nurb_handles_calc(nu); } void BKE_nurb_handles_autocalc(Nurb *nu, int flag) { /* checks handle coordinates and calculates type */ - + BezTriple *bezt2, *bezt1, *bezt0; int i, align, leftsmall, rightsmall; - if (nu==NULL || nu->bezt==NULL) return; - + if (nu == NULL || nu->bezt == NULL) + return; + bezt2 = nu->bezt; - bezt1 = bezt2 + (nu->pntsu-1); + bezt1 = bezt2 + (nu->pntsu - 1); bezt0 = bezt1 - 1; i = nu->pntsu; while (i--) { - - align= leftsmall= rightsmall= 0; - + align = leftsmall = rightsmall = 0; + /* left handle: */ - if (flag==0 || (bezt1->f1 & flag) ) { - bezt1->h1= 0; + if (flag == 0 || (bezt1->f1 & flag) ) { + bezt1->h1 = 0; /* distance too short: vectorhandle */ if (len_v3v3(bezt1->vec[1], bezt0->vec[1]) < 0.0001f) { - bezt1->h1= HD_VECT; - leftsmall= 1; + bezt1->h1 = HD_VECT; + leftsmall = 1; } else { /* aligned handle? */ if (dist_to_line_v2(bezt1->vec[1], bezt1->vec[0], bezt1->vec[2]) < 0.0001f) { - align= 1; - bezt1->h1= HD_ALIGN; + align = 1; + bezt1->h1 = HD_ALIGN; } /* or vector handle? */ if (dist_to_line_v2(bezt1->vec[0], bezt1->vec[1], bezt0->vec[1]) < 0.0001f) - bezt1->h1= HD_VECT; - + bezt1->h1 = HD_VECT; } } /* right handle: */ - if (flag==0 || (bezt1->f3 & flag) ) { - bezt1->h2= 0; + if (flag == 0 || (bezt1->f3 & flag) ) { + bezt1->h2 = 0; /* distance too short: vectorhandle */ if (len_v3v3(bezt1->vec[1], bezt2->vec[1]) < 0.0001f) { - bezt1->h2= HD_VECT; - rightsmall= 1; + bezt1->h2 = HD_VECT; + rightsmall = 1; } else { /* aligned handle? */ - if (align) bezt1->h2= HD_ALIGN; + if (align) bezt1->h2 = HD_ALIGN; /* or vector handle? */ if (dist_to_line_v2(bezt1->vec[2], bezt1->vec[1], bezt2->vec[1]) < 0.0001f) - bezt1->h2= HD_VECT; - + bezt1->h2 = HD_VECT; } } - if (leftsmall && bezt1->h2==HD_ALIGN) bezt1->h2= 0; - if (rightsmall && bezt1->h1==HD_ALIGN) bezt1->h1= 0; - + if (leftsmall && bezt1->h2 == HD_ALIGN) + bezt1->h2 = 0; + if (rightsmall && bezt1->h1 == HD_ALIGN) + bezt1->h1 = 0; + /* undesired combination: */ - if (bezt1->h1==HD_ALIGN && bezt1->h2==HD_VECT) bezt1->h1= 0; - if (bezt1->h2==HD_ALIGN && bezt1->h1==HD_VECT) bezt1->h2= 0; - - bezt0= bezt1; - bezt1= bezt2; + if (bezt1->h1 == HD_ALIGN && bezt1->h2 == HD_VECT) + bezt1->h1 = 0; + if (bezt1->h2 == HD_ALIGN && bezt1->h1 == HD_VECT) + bezt1->h2 = 0; + + bezt0 = bezt1; + bezt1 = bezt2; bezt2++; } @@ -2848,11 +2956,11 @@ void BKE_nurb_handles_autocalc(Nurb *nu, int flag) void BKE_nurbList_handles_autocalc(ListBase *editnurb, int flag) { Nurb *nu; - - nu= editnurb->first; + + nu = editnurb->first; while (nu) { BKE_nurb_handles_autocalc(nu, flag); - nu= nu->next; + nu = nu->next; } } @@ -2866,34 +2974,37 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) /* code==6: Clear align, like 3 but no toggle */ Nurb *nu; BezTriple *bezt; - short a, ok=0; + short a, ok = 0; - if (code==1 || code==2) { - nu= editnurb->first; + if (code == 1 || code == 2) { + nu = editnurb->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= code; - if (bezt->f3 & SELECT) bezt->h2= code; - if (bezt->h1!=bezt->h2) { - if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO)) bezt->h1 = HD_FREE; - if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO)) bezt->h2 = HD_FREE; + if (bezt->f1 & SELECT) + bezt->h1 = code; + if (bezt->f3 & SELECT) + bezt->h2 = code; + if (bezt->h1 != bezt->h2) { + if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO)) + bezt->h1 = HD_FREE; + if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO)) + bezt->h2 = HD_FREE; } } bezt++; } BKE_nurb_handles_calc(nu); } - nu= nu->next; + nu = nu->next; } } else { /* there is 1 handle not FREE: FREE it all, else make ALIGNED */ - - nu= editnurb->first; + nu = editnurb->first; if (code == 5) { ok = HD_ALIGN; } @@ -2904,34 +3015,34 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) /* Toggle */ while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if ((bezt->f1 & SELECT) && bezt->h1) ok= 1; - if ((bezt->f3 & SELECT) && bezt->h2) ok= 1; + if ((bezt->f1 & SELECT) && bezt->h1) ok = 1; + if ((bezt->f3 & SELECT) && bezt->h2) ok = 1; if (ok) break; bezt++; } } - nu= nu->next; + nu = nu->next; } - if (ok) ok= HD_FREE; - else ok= HD_ALIGN; + if (ok) ok = HD_FREE; + else ok = HD_ALIGN; } - nu= editnurb->first; + nu = editnurb->first; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->f1 & SELECT) bezt->h1= ok; - if (bezt->f3 & SELECT) bezt->h2= ok; - + if (bezt->f1 & SELECT) bezt->h1 = ok; + if (bezt->f3 & SELECT) bezt->h2 = ok; + bezt++; } BKE_nurb_handles_calc(nu); } - nu= nu->next; + nu = nu->next; } } } @@ -2939,9 +3050,9 @@ void BKE_nurbList_handles_set(ListBase *editnurb, short code) static void swapdata(void *adr1, void *adr2, int len) { - if (len<=0) return; + if (len <= 0) return; - if (len<65) { + if (len < 65) { char adr[64]; memcpy(adr, adr1, len); @@ -2951,7 +3062,7 @@ static void swapdata(void *adr1, void *adr2, int len) else { char *adr; - adr= (char *)MEM_mallocN(len, "curve swap"); + adr = (char *)MEM_mallocN(len, "curve swap"); memcpy(adr, adr1, len); memcpy(adr1, adr2, len); memcpy(adr2, adr, len); @@ -2966,78 +3077,80 @@ void BKE_nurb_direction_switch(Nurb *nu) float *fp1, *fp2, *tempf; int a, b; - if (nu->pntsu==1 && nu->pntsv==1) return; + if (nu->pntsu == 1 && nu->pntsv == 1) return; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt1= nu->bezt; - bezt2= bezt1+(a-1); - if (a & 1) a+= 1; /* if odd, also swap middle content */ - a/= 2; - while (a>0) { - if (bezt1!=bezt2) SWAP(BezTriple, *bezt1, *bezt2); + a = nu->pntsu; + bezt1 = nu->bezt; + bezt2 = bezt1 + (a - 1); + if (a & 1) a += 1; /* if odd, also swap middle content */ + a /= 2; + while (a > 0) { + if (bezt1 != bezt2) + SWAP(BezTriple, *bezt1, *bezt2); swapdata(bezt1->vec[0], bezt1->vec[2], 12); - if (bezt1!=bezt2) swapdata(bezt2->vec[0], bezt2->vec[2], 12); + if (bezt1 != bezt2) + swapdata(bezt2->vec[0], bezt2->vec[2], 12); SWAP(char, bezt1->h1, bezt1->h2); SWAP(short, bezt1->f1, bezt1->f3); - - if (bezt1!=bezt2) { + + if (bezt1 != bezt2) { SWAP(char, bezt2->h1, bezt2->h2); SWAP(short, bezt2->f1, bezt2->f3); - bezt1->alfa= -bezt1->alfa; - bezt2->alfa= -bezt2->alfa; + bezt1->alfa = -bezt1->alfa; + bezt2->alfa = -bezt2->alfa; } a--; - bezt1++; + bezt1++; bezt2--; } } - else if (nu->pntsv==1) { - a= nu->pntsu; - bp1= nu->bp; - bp2= bp1+(a-1); - a/= 2; - while (bp1!=bp2 && a>0) { + else if (nu->pntsv == 1) { + a = nu->pntsu; + bp1 = nu->bp; + bp2 = bp1 + (a - 1); + a /= 2; + while (bp1 != bp2 && a > 0) { SWAP(BPoint, *bp1, *bp2); a--; - bp1->alfa= -bp1->alfa; - bp2->alfa= -bp2->alfa; - bp1++; + bp1->alfa = -bp1->alfa; + bp2->alfa = -bp2->alfa; + bp1++; bp2--; } if (nu->type == CU_NURBS) { /* no knots for too short paths */ if (nu->knotsu) { /* inverse knots */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2= fp1+(a-1); - a/= 2; - while (fp1!=fp2 && a>0) { + a = KNOTSU(nu); + fp1 = nu->knotsu; + fp2 = fp1 + (a - 1); + a /= 2; + while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; - fp1++; + fp1++; fp2--; } /* and make in increasing order again */ - a= KNOTSU(nu); - fp1= nu->knotsu; - fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); + a = KNOTSU(nu); + fp1 = nu->knotsu; + fp2 = tempf = MEM_mallocN(sizeof(float) * a, "switchdirect"); while (a--) { - fp2[0]= fabs(fp1[1]-fp1[0]); + fp2[0] = fabs(fp1[1] - fp1[0]); fp1++; fp2++; } - - a= KNOTSU(nu)-1; - fp1= nu->knotsu; - fp2= tempf; - fp1[0]= 0.0; + + a = KNOTSU(nu) - 1; + fp1 = nu->knotsu; + fp2 = tempf; + fp1[0] = 0.0; fp1++; while (a--) { - fp1[0]= fp1[-1]+fp2[0]; + fp1[0] = fp1[-1] + fp2[0]; fp1++; fp2++; } @@ -3046,18 +3159,16 @@ void BKE_nurb_direction_switch(Nurb *nu) } } else { - - for (b=0; bpntsv; b++) { - - bp1= nu->bp+b*nu->pntsu; - a= nu->pntsu; - bp2= bp1+(a-1); - a/= 2; - - while (bp1!=bp2 && a>0) { + for (b = 0; b < nu->pntsv; b++) { + bp1 = nu->bp + b * nu->pntsu; + a = nu->pntsu; + bp2 = bp1 + (a - 1); + a /= 2; + + while (bp1 != bp2 && a > 0) { SWAP(BPoint, *bp1, *bp2); a--; - bp1++; + bp1++; bp2--; } } @@ -3065,28 +3176,28 @@ void BKE_nurb_direction_switch(Nurb *nu) } -float (*BKE_curve_vertexCos_get(Curve *UNUSED(cu), ListBase *lb, int *numVerts_r))[3] +float (*BKE_curve_vertexCos_get(Curve * UNUSED(cu), ListBase * lb, int *numVerts_r))[3] { int i, numVerts = *numVerts_r = BKE_nurbList_verts_count(lb); - float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); + float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos) * numVerts, "cu_vcos"); Nurb *nu; co = cos[0]; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - copy_v3_v3(co, bezt->vec[0]); co+=3; - copy_v3_v3(co, bezt->vec[1]); co+=3; - copy_v3_v3(co, bezt->vec[2]); co+=3; + for (i = 0; i < nu->pntsu; i++, bezt++) { + copy_v3_v3(co, bezt->vec[0]); co += 3; + copy_v3_v3(co, bezt->vec[1]); co += 3; + copy_v3_v3(co, bezt->vec[2]); co += 3; } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - copy_v3_v3(co, bp->vec); co+=3; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + copy_v3_v3(co, bp->vec); co += 3; } } } @@ -3100,21 +3211,21 @@ void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos Nurb *nu; int i; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - copy_v3_v3(bezt->vec[0], co); co+=3; - copy_v3_v3(bezt->vec[1], co); co+=3; - copy_v3_v3(bezt->vec[2], co); co+=3; + for (i = 0; i < nu->pntsu; i++, bezt++) { + copy_v3_v3(bezt->vec[0], co); co += 3; + copy_v3_v3(bezt->vec[1], co); co += 3; + copy_v3_v3(bezt->vec[2], co); co += 3; } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - copy_v3_v3(bp->vec, co); co+=3; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + copy_v3_v3(bp->vec, co); co += 3; } } @@ -3122,29 +3233,29 @@ void BK_curve_vertexCos_apply(Curve *UNUSED(cu), ListBase *lb, float (*vertexCos } } -float (*BKE_curve_keyVertexCos_get(Curve *UNUSED(cu), ListBase *lb, float *key))[3] +float (*BKE_curve_keyVertexCos_get(Curve * UNUSED(cu), ListBase * lb, float *key))[3] { int i, numVerts = BKE_nurbList_verts_count(lb); - float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "cu_vcos"); + float *co, (*cos)[3] = MEM_mallocN(sizeof(*cos) * numVerts, "cu_vcos"); Nurb *nu; co = cos[0]; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - copy_v3_v3(co, key); co+=3; key+=3; - copy_v3_v3(co, key); co+=3; key+=3; - copy_v3_v3(co, key); co+=3; key+=3; - key+=3; /* skip tilt */ + for (i = 0; i < nu->pntsu; i++, bezt++) { + copy_v3_v3(co, key); co += 3; key += 3; + copy_v3_v3(co, key); co += 3; key += 3; + copy_v3_v3(co, key); co += 3; key += 3; + key += 3; /* skip tilt */ } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - copy_v3_v3(co, key); co+=3; key+=3; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + copy_v3_v3(co, key); co += 3; key += 3; key++; /* skip tilt */ } } @@ -3158,22 +3269,22 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) Nurb *nu; int i; - for (nu=lb->first; nu; nu=nu->next) { + for (nu = lb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { BezTriple *bezt = nu->bezt; - for (i=0; ipntsu; i++, bezt++) { - key+=3*3; - bezt->alfa= *key; - key+=3; + for (i = 0; i < nu->pntsu; i++, bezt++) { + key += 3 * 3; + bezt->alfa = *key; + key += 3; } } else { BPoint *bp = nu->bp; - for (i=0; ipntsu*nu->pntsv; i++, bp++) { - key+=3; - bp->alfa= *key; + for (i = 0; i < nu->pntsu * nu->pntsv; i++, bp++) { + key += 3; + bp->alfa = *key; key++; } } @@ -3182,31 +3293,46 @@ void BKE_curve_keyVertexTilts_apply(Curve *UNUSED(cu), ListBase *lb, float *key) int BKE_nurb_check_valid_u(struct Nurb *nu) { - if (nu==NULL) return 0; - if (nu->pntsu <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ - - if (nu->pntsu < nu->orderu) return 0; - if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ - if (nu->orderu==4) { - if (nu->pntsu < 5) return 0; /* bezier with 4 orderu needs 5 points */ + if (nu == NULL) + return 0; + if (nu->pntsu <= 1) + return 0; + if (nu->type != CU_NURBS) + return 1; /* not a nurb, lets assume its valid */ + + if (nu->pntsu < nu->orderu) return 0; + if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { /* Bezier U Endpoints */ + if (nu->orderu == 4) { + if (nu->pntsu < 5) + return 0; /* bezier with 4 orderu needs 5 points */ + } + else { + if (nu->orderu != 3) + return 0; /* order must be 3 or 4 */ } - else if (nu->orderu != 3) return 0; /* order must be 3 or 4 */ } return 1; } int BKE_nurb_check_valid_v(struct Nurb *nu) { - if (nu==NULL) return 0; - if (nu->pntsv <= 1) return 0; - if (nu->type != CU_NURBS) return 1; /* not a nurb, lets assume its valid */ - - if (nu->pntsv < nu->orderv) return 0; - if (((nu->flag & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ - if (nu->orderv==4) { - if (nu->pntsv < 5) return 0; /* bezier with 4 orderu needs 5 points */ + if (nu == NULL) + return 0; + if (nu->pntsv <= 1) + return 0; + if (nu->type != CU_NURBS) + return 1; /* not a nurb, lets assume its valid */ + + if (nu->pntsv < nu->orderv) + return 0; + if (((nu->flag & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { /* Bezier V Endpoints */ + if (nu->orderv == 4) { + if (nu->pntsv < 5) + return 0; /* bezier with 4 orderu needs 5 points */ + } + else { + if (nu->orderv != 3) + return 0; /* order must be 3 or 4 */ } - else if (nu->orderv != 3) return 0; /* order must be 3 or 4 */ } return 1; } @@ -3214,13 +3340,13 @@ int BKE_nurb_check_valid_v(struct Nurb *nu) int BKE_nurb_order_clamp_u(struct Nurb *nu) { int change = 0; - if (nu->pntsuorderu) { - nu->orderu= nu->pntsu; - change= 1; + if (nu->pntsu < nu->orderu) { + nu->orderu = nu->pntsu; + change = 1; } - if (((nu->flagu & CU_NURB_CYCLIC)==0) && (nu->flagu & CU_NURB_BEZIER)) { + if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (nu->flagu & CU_NURB_BEZIER)) { CLAMP(nu->orderu, 3, 4); - change= 1; + change = 1; } return change; } @@ -3228,13 +3354,13 @@ int BKE_nurb_order_clamp_u(struct Nurb *nu) int BKE_nurb_order_clamp_v(struct Nurb *nu) { int change = 0; - if (nu->pntsvorderv) { - nu->orderv= nu->pntsv; - change= 1; + if (nu->pntsv < nu->orderv) { + nu->orderv = nu->pntsv; + change = 1; } - if (((nu->flagv & CU_NURB_CYCLIC)==0) && (nu->flagv & CU_NURB_BEZIER)) { + if (((nu->flagv & CU_NURB_CYCLIC) == 0) && (nu->flagv & CU_NURB_BEZIER)) { CLAMP(nu->orderv, 3, 4); - change= 1; + change = 1; } return change; } @@ -3253,10 +3379,10 @@ ListBase *BKE_curve_nurbs_get(Curve *cu) /* basic vertex data functions */ int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) { - ListBase *nurb_lb= BKE_curve_nurbs_get(cu); + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; - for (nu= nurb_lb->first; nu; nu= nu->next) + for (nu = nurb_lb->first; nu; nu = nu->next) BKE_nurb_minmax(nu, min, max); return (nurb_lb->first != NULL); @@ -3264,20 +3390,20 @@ int BKE_curve_minmax(Curve *cu, float min[3], float max[3]) int BKE_curve_center_median(Curve *cu, float cent[3]) { - ListBase *nurb_lb= BKE_curve_nurbs_get(cu); + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; - int total= 0; + int total = 0; zero_v3(cent); - for (nu= nurb_lb->first; nu; nu= nu->next) { + for (nu = nurb_lb->first; nu; nu = nu->next) { int i; if (nu->type == CU_BEZIER) { BezTriple *bezt; - i= nu->pntsu; + i = nu->pntsu; total += i * 3; - for (bezt= nu->bezt; i--; bezt++) { + for (bezt = nu->bezt; i--; bezt++) { add_v3_v3(cent, bezt->vec[0]); add_v3_v3(cent, bezt->vec[1]); add_v3_v3(cent, bezt->vec[2]); @@ -3285,15 +3411,15 @@ int BKE_curve_center_median(Curve *cu, float cent[3]) } else { BPoint *bp; - i= nu->pntsu*nu->pntsv; + i = nu->pntsu * nu->pntsv; total += i; - for (bp= nu->bp; i--; bp++) { + for (bp = nu->bp; i--; bp++) { add_v3_v3(cent, bp->vec); } } } - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); return (total != 0); } @@ -3312,25 +3438,25 @@ int BKE_curve_center_bounds(Curve *cu, float cent[3]) void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) { - ListBase *nurb_lb= BKE_curve_nurbs_get(cu); + ListBase *nurb_lb = BKE_curve_nurbs_get(cu); Nurb *nu; int i; - for (nu= nurb_lb->first; nu; nu= nu->next) { + for (nu = nurb_lb->first; nu; nu = nu->next) { BezTriple *bezt; BPoint *bp; if (nu->type == CU_BEZIER) { - i= nu->pntsu; - for (bezt= nu->bezt; i--; bezt++) { + i = nu->pntsu; + for (bezt = nu->bezt; i--; bezt++) { add_v3_v3(bezt->vec[0], offset); add_v3_v3(bezt->vec[1], offset); add_v3_v3(bezt->vec[2], offset); } } else { - i= nu->pntsu*nu->pntsv; - for (bp= nu->bp; i--; bp++) { + i = nu->pntsu * nu->pntsv; + for (bp = nu->bp; i--; bp++) { add_v3_v3(bp->vec, offset); } } @@ -3338,9 +3464,9 @@ void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) if (do_keys && cu->key) { KeyBlock *kb; - for (kb=cu->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; - for (i= kb->totelem; i--; fp+=3) { + for (kb = cu->key->block.first; kb; kb = kb->next) { + float *fp = kb->data; + for (i = kb->totelem; i--; fp += 3) { add_v3_v3(fp, offset); } } @@ -3349,13 +3475,13 @@ void BKE_curve_translate(Curve *cu, float offset[3], int do_keys) void BKE_curve_delete_material_index(Curve *cu, int index) { - const int curvetype= BKE_curve_type_get(cu); + const int curvetype = BKE_curve_type_get(cu); if (curvetype == OB_FONT) { - struct CharInfo *info= cu->strinfo; + struct CharInfo *info = cu->strinfo; int i; - for (i= cu->len-1; i >= 0; i--, info++) { - if (info->mat_nr && info->mat_nr>=index) { + for (i = cu->len - 1; i >= 0; i--, info++) { + if (info->mat_nr && info->mat_nr >= index) { info->mat_nr--; } } @@ -3363,10 +3489,11 @@ void BKE_curve_delete_material_index(Curve *cu, int index) else { Nurb *nu; - for (nu= cu->nurb.first; nu; nu= nu->next) { - if (nu->mat_nr && nu->mat_nr>=index) { + for (nu = cu->nurb.first; nu; nu = nu->next) { + if (nu->mat_nr && nu->mat_nr >= index) { nu->mat_nr--; - if (curvetype == OB_CURVE) nu->charidx--; + if (curvetype == OB_CURVE) + nu->charidx--; } } } diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index e32182ed36e..5eab6aeccef 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -565,6 +565,38 @@ static size_t layerFilesize_mdisps(CDataFile *UNUSED(cdf), void *data, int count return size; } +static void layerCopy_grid_paint_mask(const void *source, void *dest, int count) +{ + int i; + const GridPaintMask *s = source; + GridPaintMask *d = dest; + + for(i = 0; i < count; ++i) { + if(s[i].data) { + d[i].data = MEM_dupallocN(s[i].data); + d[i].level = s[i].level; + } + else { + d[i].data = NULL; + d[i].level = 0; + } + + } +} + +static void layerFree_grid_paint_mask(void *data, int count, int UNUSED(size)) +{ + int i; + GridPaintMask *gpm = data; + + for(i = 0; i < count; ++i) { + if(gpm[i].data) + MEM_freeN(gpm[i].data); + gpm[i].data = NULL; + gpm[i].level = 0; + } +} + /* --------- */ static void layerCopyValue_mloopcol(void *source, void *dest) { @@ -1059,7 +1091,11 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = { /* END BMESH ONLY */ - + /* 34: CD_PAINT_MASK */ + {sizeof(float), "", 0, NULL, NULL, NULL, NULL, NULL, NULL}, + /* 35: CD_GRID_PAINT_MASK */ + {sizeof(GridPaintMask), "GridPaintMask", 1, NULL, layerCopy_grid_paint_mask, + layerFree_grid_paint_mask, NULL, NULL, NULL} }; /* note, numbers are from trunk and need updating for bmesh */ @@ -1073,7 +1109,9 @@ static const char *LAYERTYPENAMES[CD_NUMTYPES] = { /* BMESH ONLY */ /* 25-29 */ "CDMPoly", "CDMLoop", "CDShapeKeyIndex", "CDShapeKey", "CDBevelWeight", - /* 30-32 */ "CDSubSurfCrease", "CDOrigSpaceLoop", "CDPreviewLoopCol" + /* 30-34 */ "CDSubSurfCrease", "CDOrigSpaceLoop", "CDPreviewLoopCol", "CDBMElemPyPtr", "CDPaintMask", + /* 35 */ "CDGridPaintMask" + /* END BMESH ONLY */ }; @@ -1086,12 +1124,14 @@ const CustomDataMask CD_MASK_MESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | CD_MASK_MDISPS | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MPOLY | CD_MASK_MLOOP | - CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST; + CD_MASK_MTEXPOLY | CD_MASK_NORMAL | CD_MASK_RECAST | CD_MASK_PAINT_MASK | + CD_MASK_GRID_PAINT_MASK; const CustomDataMask CD_MASK_EDITMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MCOL|CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_PROP_STR | - CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST; + CD_MASK_MDISPS | CD_MASK_SHAPEKEY | CD_MASK_RECAST | CD_MASK_PAINT_MASK | + CD_MASK_GRID_PAINT_MASK; const CustomDataMask CD_MASK_DERIVEDMESH = CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | CD_MASK_CLOTH_ORCO | @@ -1101,7 +1141,9 @@ const CustomDataMask CD_MASK_DERIVEDMESH = CD_MASK_ORIGINDEX | CD_MASK_POLYINDEX; const CustomDataMask CD_MASK_BMESH = CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL | CD_MASK_MTEXPOLY | CD_MASK_MSTICKY | CD_MASK_MDEFORMVERT | CD_MASK_PROP_FLT | CD_MASK_PROP_INT | - CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS | CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST; + CD_MASK_PROP_STR | CD_MASK_SHAPEKEY | CD_MASK_SHAPE_KEYINDEX | CD_MASK_MDISPS | + CD_MASK_CREASE | CD_MASK_BWEIGHT | CD_MASK_RECAST | CD_MASK_PAINT_MASK | + CD_MASK_GRID_PAINT_MASK; const CustomDataMask CD_MASK_FACECORNERS = CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV | CD_MASK_MLOOPCOL; @@ -1915,8 +1957,7 @@ void CustomData_interp(const CustomData *source, CustomData *dest, void *src_data = source->layers[src_i].data; for (j = 0; j < count; ++j) - sources[j] = (char *)src_data - + typeInfo->size * src_indices[j]; + sources[j] = (char *)src_data + typeInfo->size * src_indices[j]; dest_offset = dest_index * typeInfo->size; diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c index 75e22195c6a..fc54ea6eed5 100644 --- a/source/blender/blenkernel/intern/depsgraph.c +++ b/source/blender/blenkernel/intern/depsgraph.c @@ -82,10 +82,10 @@ * the queue store a list of freenodes to avoid successive alloc/dealloc */ -DagNodeQueue * queue_create (int slots) +DagNodeQueue *queue_create(int slots) { - DagNodeQueue * queue; - DagNodeQueueElem * elem; + DagNodeQueue *queue; + DagNodeQueueElem *elem; int i; queue = MEM_mallocN(sizeof(DagNodeQueue), "DAG queue"); @@ -98,7 +98,7 @@ DagNodeQueue * queue_create (int slots) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i node = NULL; elem->next = NULL; @@ -111,7 +111,7 @@ DagNodeQueue * queue_create (int slots) void queue_raz(DagNodeQueue *queue) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; elem = queue->first; if (queue->freenodes->last) @@ -132,8 +132,8 @@ void queue_raz(DagNodeQueue *queue) void queue_delete(DagNodeQueue *queue) { - DagNodeQueueElem * elem; - DagNodeQueueElem * temp; + DagNodeQueueElem *elem; + DagNodeQueueElem *temp; elem = queue->first; while (elem) { @@ -156,7 +156,7 @@ void queue_delete(DagNodeQueue *queue) /* insert in queue, remove in front */ void push_queue(DagNodeQueue *queue, DagNode *node) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; int i; if (node == NULL) { @@ -168,7 +168,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node) elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; - if ( queue->freenodes->last == elem) { + if (queue->freenodes->last == elem) { queue->freenodes->last = NULL; queue->freenodes->first = NULL; } @@ -180,7 +180,7 @@ void push_queue(DagNodeQueue *queue, DagNode *node) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i node = NULL; elem->next = NULL; @@ -207,13 +207,13 @@ void push_queue(DagNodeQueue *queue, DagNode *node) /* insert in front, remove in front */ void push_stack(DagNodeQueue *queue, DagNode *node) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; int i; elem = queue->freenodes->first; if (elem != NULL) { queue->freenodes->first = elem->next; - if ( queue->freenodes->last == elem) { + if (queue->freenodes->last == elem) { queue->freenodes->last = NULL; queue->freenodes->first = NULL; } @@ -225,7 +225,7 @@ void push_stack(DagNodeQueue *queue, DagNode *node) elem->next = NULL; queue->freenodes->first = queue->freenodes->last = elem; - for (i = 1; i node = NULL; elem->next = NULL; @@ -246,24 +246,24 @@ void push_stack(DagNodeQueue *queue, DagNode *node) } -DagNode * pop_queue(DagNodeQueue *queue) +DagNode *pop_queue(DagNodeQueue *queue) { - DagNodeQueueElem * elem; + DagNodeQueueElem *elem; DagNode *node; elem = queue->first; if (elem) { queue->first = elem->next; if (queue->last == elem) { - queue->last=NULL; - queue->first=NULL; + queue->last = NULL; + queue->first = NULL; } queue->count--; if (queue->freenodes->last) - queue->freenodes->last->next=elem; - queue->freenodes->last=elem; + queue->freenodes->last->next = elem; + queue->freenodes->last = elem; if (queue->freenodes->first == NULL) - queue->freenodes->first=elem; + queue->freenodes->first = elem; node = elem->node; elem->node = NULL; elem->next = NULL; @@ -276,17 +276,17 @@ DagNode * pop_queue(DagNodeQueue *queue) } } -void *pop_ob_queue(struct DagNodeQueue *queue) +void *pop_ob_queue(struct DagNodeQueue *queue) { return(pop_queue(queue)->ob); } -DagNode * get_top_node_queue(DagNodeQueue *queue) +DagNode *get_top_node_queue(DagNodeQueue *queue) { return queue->first->node; } -int queue_count(struct DagNodeQueue *queue) +int queue_count(struct DagNodeQueue *queue) { return queue->count; } @@ -307,37 +307,37 @@ static void dag_add_driver_relation(AnimData *adt, DagForest *dag, DagNode *node FCurve *fcu; DagNode *node1; - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { - ChannelDriver *driver= fcu->driver; + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { + ChannelDriver *driver = fcu->driver; DriverVar *dvar; int isdata_fcu = isdata || (fcu->rna_path && strstr(fcu->rna_path, "modifiers[")); /* loop over variables to get the target relationships */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* only used targets */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id) { // FIXME: other data types need to be added here so that they can work! - if (GS(dtar->id->name)==ID_OB) { - Object *ob= (Object *)dtar->id; + if (GS(dtar->id->name) == ID_OB) { + Object *ob = (Object *)dtar->id; /* normal channel-drives-channel */ node1 = dag_get_node(dag, dtar->id); /* check if bone... */ - if ((ob->type==OB_ARMATURE) && - ( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) || - ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) )) + if ((ob->type == OB_ARMATURE) && + ( ((dtar->rna_path) && strstr(dtar->rna_path, "pose.bones[")) || + ((dtar->flag & DTAR_FLAG_STRUCT_REF) && (dtar->pchan_name[0])) )) { - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver"); } /* check if ob data */ else if (dtar->rna_path && strstr(dtar->rna_path, "data.")) - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_DATA_DATA:DAG_RL_DATA_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_DATA_DATA : DAG_RL_DATA_OB, "Driver"); /* normal */ else - dag_add_relation(dag, node1, node, isdata_fcu?DAG_RL_OB_DATA:DAG_RL_OB_OB, "Driver"); + dag_add_relation(dag, node1, node, isdata_fcu ? DAG_RL_OB_DATA : DAG_RL_OB_OB, "Driver"); } } } @@ -353,12 +353,12 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec // would be nice to have a list of colliders here // so for now walk all objects in scene check 'same layer rule' - for (base = scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->lay & ob->lay) && base->object->pd) { - Object *ob1= base->object; + Object *ob1 = base->object; if ((ob1->pd->deflect || ob1->pd->forcefield) && (ob1 != ob)) { node2 = dag_get_node(dag, ob1); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Field Collision"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Field Collision"); } } } @@ -367,16 +367,16 @@ static void dag_add_collision_field_relation(DagForest *dag, Scene *scene, Objec static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, Object *ob, int mask) { bConstraint *con; - DagNode * node; - DagNode * node2; - DagNode * node3; + DagNode *node; + DagNode *node2; + DagNode *node3; Key *key; ParticleSystem *psys; - int addtoroot= 1; + int addtoroot = 1; node = dag_get_node(dag, ob); - if ((ob->data) && (mask&DAG_RL_DATA)) { + if ((ob->data) && (mask & DAG_RL_DATA)) { node2 = dag_get_node(dag, ob->data); dag_add_relation(dag, node, node2, DAG_RL_DATA, "Object-Data Relation"); node2->first_ancestor = ob; @@ -384,34 +384,34 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* also build a custom data mask for dependencies that need certain layers */ - node->customdata_mask= 0; + node->customdata_mask = 0; if (ob->type == OB_ARMATURE) { if (ob->pose) { bPoseChannel *pchan; bConstraint *con; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar && ct->tar != ob) { // fprintf(stderr, "armature %s target :%s\n", ob->id.name, target->id.name); node3 = dag_get_node(dag, ct->tar); if (ct->subtarget[0]) { - dag_add_relation(dag, node3, node, DAG_RL_OB_DATA|DAG_RL_DATA_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, cti->name); if (ct->tar->type == OB_MESH) node3->customdata_mask |= CD_MASK_MDEFORMVERT; } else if (ELEM3(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO, CONSTRAINT_TYPE_SPLINEIK)) - dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, cti->name); + dag_add_relation(dag, node3, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, cti->name); else dag_add_relation(dag, node3, node, DAG_RL_OB_DATA, cti->name); } @@ -431,13 +431,13 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ob->nlastrips.first) { bActionStrip *strip; bActionChannel *chan; - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->modifiers.first) { bActionModifier *amod; - for (amod= strip->modifiers.first; amod; amod= amod->next) { + for (amod = strip->modifiers.first; amod; amod = amod->next) { if (amod->ob) { node2 = dag_get_node(dag, amod->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "NLA Strip Modifier"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "NLA Strip Modifier"); } } } @@ -445,16 +445,16 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } #endif // XXX old animation system if (ob->adt) - dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation + dag_add_driver_relation(ob->adt, dag, node, (ob->type == OB_ARMATURE)); // XXX isdata arg here doesn't give an accurate picture of situation - key= ob_get_key(ob); + key = ob_get_key(ob); if (key && key->adt) dag_add_driver_relation(key->adt, dag, node, 1); if (ob->modifiers.first) { ModifierData *md; - for (md=ob->modifiers.first; md; md=md->next) { + for (md = ob->modifiers.first; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->updateDepgraph) mti->updateDepgraph(md, dag, scene, ob, node); @@ -465,22 +465,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O switch (ob->partype) { case PARSKEL: - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Parent"); break; case PARVERT1: case PARVERT3: - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Vertex Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Vertex Parent"); node2->customdata_mask |= CD_MASK_ORIGINDEX; break; case PARBONE: - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Bone Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Bone Parent"); break; default: - if (ob->parent->type==OB_LATTICE) - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Lattice Parent"); - else if (ob->parent->type==OB_CURVE) { - Curve *cu= ob->parent->data; + if (ob->parent->type == OB_LATTICE) + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Lattice Parent"); + else if (ob->parent->type == OB_CURVE) { + Curve *cu = ob->parent->data; if (cu->flag & CU_PATH) - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, "Curve Parent"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, "Curve Parent"); else dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Curve Parent"); } @@ -488,22 +488,22 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Parent"); } /* exception case: parent is duplivert */ - if (ob->type==OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Duplivert"); + if (ob->type == OB_MBALL && (ob->parent->transflag & OB_DUPLIVERTS)) { + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Duplivert"); } addtoroot = 0; } if (ob->proxy) { node2 = dag_get_node(dag, ob->proxy); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_OB, "Proxy"); + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_OB, "Proxy"); /* inverted relation, so addtoroot shouldn't be set to zero */ } if (ob->transflag & OB_DUPLI) { if ((ob->transflag & OB_DUPLIGROUP) && ob->dup_group) { GroupObject *go; - for (go= ob->dup_group->gobject.first; go; go= go->next) { + for (go = ob->dup_group->gobject.first; go; go = go->next) { if (go->ob) { node2 = dag_get_node(dag, go->ob); /* node2 changes node1, this keeps animations updated in groups?? not logical? */ @@ -514,14 +514,14 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* softbody collision */ - if ((ob->type==OB_MESH) || (ob->type==OB_CURVE) || (ob->type==OB_LATTICE)) { + if ((ob->type == OB_MESH) || (ob->type == OB_CURVE) || (ob->type == OB_LATTICE)) { if (modifiers_isSoftbodyEnabled(ob) || modifiers_isClothEnabled(ob) || ob->particlesystem.first) - dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ + dag_add_collision_field_relation(dag, scene, ob, node); /* TODO: use effectorweight->group */ } /* object data drivers */ if (ob->data) { - AnimData *adt= BKE_animdata_from_id((ID *)ob->data); + AnimData *adt = BKE_animdata_from_id((ID *)ob->data); if (adt) dag_add_driver_relation(adt, dag, node, 1); } @@ -537,49 +537,49 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Camera DoF"); } } - break; + break; case OB_MBALL: { - Object *mom= BKE_metaball_basis_find(scene, ob); + Object *mom = BKE_mball_basis_find(scene, ob); - if (mom!=ob) { + if (mom != ob) { node2 = dag_get_node(dag, mom); - dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Metaball"); // mom depends on children! + dag_add_relation(dag, node, node2, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Metaball"); // mom depends on children! } } - break; + break; case OB_CURVE: case OB_FONT: { - Curve *cu= ob->data; + Curve *cu = ob->data; if (cu->bevobj) { node2 = dag_get_node(dag, cu->bevobj); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Bevel"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Bevel"); } if (cu->taperobj) { node2 = dag_get_node(dag, cu->taperobj); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Curve Taper"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Curve Taper"); } if (ob->type == OB_FONT) { if (cu->textoncurve) { node2 = dag_get_node(dag, cu->textoncurve); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Texture On Curve"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Texture On Curve"); } } } - break; + break; } /* particles */ - psys= ob->particlesystem.first; + psys = ob->particlesystem.first; if (psys) { GroupObject *go; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { BoidRule *rule = NULL; BoidState *state = NULL; - ParticleSettings *part= psys->part; + ParticleSettings *part = psys->part; ListBase *effectors = NULL; EffectorCache *eff; @@ -591,12 +591,12 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O if (ELEM(part->phystype, PART_PHYS_KEYED, PART_PHYS_BOIDS)) { ParticleTarget *pt = psys->targets.first; - for (; pt; pt=pt->next) { - if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys-1)) { + for (; pt; pt = pt->next) { + if (pt->ob && BLI_findlink(&pt->ob->particlesystem, pt->psys - 1)) { node2 = dag_get_node(dag, pt->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Targets"); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Targets"); } - } + } } if (part->ren_as == PART_DRAW_OB && part->dup_ob) { @@ -610,7 +610,7 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } if (part->ren_as == PART_DRAW_GR && part->dup_group) { - for (go=part->dup_group->gobject.first; go; go=go->next) { + for (go = part->dup_group->gobject.first; go; go = go->next) { node2 = dag_get_node(dag, go->ob); dag_add_relation(dag, node2, node, DAG_RL_OB_OB, "Particle Group Visualisation"); } @@ -618,23 +618,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O effectors = pdInitEffectors(scene, ob, psys, part->effector_weights); - if (effectors) for (eff = effectors->first; eff; eff=eff->next) { - if (eff->psys) { - node2 = dag_get_node(dag, eff->ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Particle Field"); + if (effectors) { + for (eff = effectors->first; eff; eff = eff->next) { + if (eff->psys) { + node2 = dag_get_node(dag, eff->ob); + dag_add_relation(dag, node2, node, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Particle Field"); + } } } pdEndEffectors(&effectors); if (part->boids) { - for (state = part->boids->states.first; state; state=state->next) { - for (rule = state->rules.first; rule; rule=rule->next) { + for (state = part->boids->states.first; state; state = state->next) { + for (rule = state->rules.first; rule; rule = rule->next) { Object *ruleob = NULL; - if (rule->type==eBoidRuleType_Avoid) - ruleob = ((BoidRuleGoalAvoid*)rule)->ob; - else if (rule->type==eBoidRuleType_FollowLeader) - ruleob = ((BoidRuleFollowLeader*)rule)->ob; + if (rule->type == eBoidRuleType_Avoid) + ruleob = ((BoidRuleGoalAvoid *)rule)->ob; + else if (rule->type == eBoidRuleType_FollowLeader) + ruleob = ((BoidRuleFollowLeader *)rule)->ob; if (ruleob) { node2 = dag_get_node(dag, ruleob); @@ -647,8 +649,8 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } /* object constraints */ - for (con = ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -657,25 +659,25 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O /* special case for camera tracking -- it doesn't use targets to define relations */ if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, CONSTRAINT_TYPE_OBJECTSOLVER)) { - int depends_on_camera= 0; + int depends_on_camera = 0; - if (cti->type==CONSTRAINT_TYPE_FOLLOWTRACK) { - bFollowTrackConstraint *data= (bFollowTrackConstraint *)con->data; + if (cti->type == CONSTRAINT_TYPE_FOLLOWTRACK) { + bFollowTrackConstraint *data = (bFollowTrackConstraint *)con->data; - if ((data->clip || data->flag&FOLLOWTRACK_ACTIVECLIP) && data->track[0]) - depends_on_camera= 1; + if ((data->clip || data->flag & FOLLOWTRACK_ACTIVECLIP) && data->track[0]) + depends_on_camera = 1; if (data->depth_ob) { node2 = dag_get_node(dag, data->depth_ob); - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); } } - else if (cti->type==CONSTRAINT_TYPE_OBJECTSOLVER) - depends_on_camera= 1; + else if (cti->type == CONSTRAINT_TYPE_OBJECTSOLVER) + depends_on_camera = 1; if (depends_on_camera && scene->camera) { node2 = dag_get_node(dag, scene->camera); - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); } dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); @@ -684,20 +686,20 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O else if (cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { Object *obt; if (ct->tar) - obt= ct->tar; + obt = ct->tar; else continue; node2 = dag_get_node(dag, obt); if (ELEM(con->type, CONSTRAINT_TYPE_FOLLOWPATH, CONSTRAINT_TYPE_CLAMPTO)) - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); else { if (ELEM3(obt->type, OB_ARMATURE, OB_MESH, OB_LATTICE) && (ct->subtarget[0])) { - dag_add_relation(dag, node2, node, DAG_RL_DATA_OB|DAG_RL_OB_OB, cti->name); + dag_add_relation(dag, node2, node, DAG_RL_DATA_OB | DAG_RL_OB_OB, cti->name); if (obt->type == OB_MESH) node2->customdata_mask |= CD_MASK_MDEFORMVERT; } @@ -712,12 +714,11 @@ static void build_dag_object(DagForest *dag, DagNode *scenenode, Scene *scene, O } } - if (addtoroot == 1 ) + if (addtoroot == 1) dag_add_relation(dag, scenenode, node, DAG_RL_SCENE, "Scene Relation"); } -struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) -{ +struct DagForest *build_dag(Main *bmain, Scene *sce, short mask){ Base *base; Object *ob; Group *group; @@ -728,8 +729,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) DagAdjList *itA; dag = sce->theDag; - sce->dagisvalid=1; - if ( dag) + sce->dagisvalid = 1; + if (dag) free_forest(dag); else { dag = dag_init(); @@ -740,8 +741,8 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) scenenode = dag_add_node(dag, sce); /* add current scene objects */ - for (base = sce->base.first; base; base= base->next) { - ob= base->object; + for (base = sce->base.first; base; base = base->next) { + ob = base->object; build_dag_object(dag, scenenode, sce, ob, mask); if (ob->proxy) @@ -753,9 +754,9 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) } /* add groups used in current scene objects */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { build_dag_object(dag, scenenode, sce, go->ob, mask); } group->id.flag &= ~LIB_DOIT; @@ -767,23 +768,23 @@ struct DagForest *build_dag(Main *bmain, Scene *sce, short mask) * the relation type has to be synced. One of the parents can change, and should give same event to child */ /* nodes were callocced, so we can use node->color for temporal storage */ - for (node = sce->theDag->DagNode.first; node; node= node->next) { - if (node->type==ID_OB) { - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { itA->node->color |= itA->type; } } /* also flush custom data mask */ - ((Object*)node->ob)->customdata_mask= node->customdata_mask; + ((Object *)node->ob)->customdata_mask = node->customdata_mask; } } /* now set relations equal, so that when only one parent changes, the correct recalcs are found */ - for (node = sce->theDag->DagNode.first; node; node= node->next) { - if (node->type==ID_OB) { - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { + if (node->type == ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { itA->type |= itA->node->color; } } @@ -825,14 +826,14 @@ void free_forest(DagForest *Dag) } BLI_ghash_free(Dag->nodeHash, NULL, NULL); - Dag->nodeHash= NULL; + Dag->nodeHash = NULL; Dag->DagNode.first = NULL; Dag->DagNode.last = NULL; Dag->numNodes = 0; } -DagNode * dag_find_node (DagForest *forest, void * fob) +DagNode *dag_find_node(DagForest *forest, void *fob) { if (forest->nodeHash) return BLI_ghash_lookup(forest->nodeHash, fob); @@ -840,11 +841,11 @@ DagNode * dag_find_node (DagForest *forest, void * fob) return NULL; } -static int ugly_hack_sorry= 1; // prevent type check -static int dag_print_dependencies= 0; // debugging +static int ugly_hack_sorry = 1; // prevent type check +static int dag_print_dependencies = 0; // debugging /* no checking of existence, use dag_find_node first or dag_get_node */ -DagNode * dag_add_node (DagForest *forest, void * fob) +DagNode *dag_add_node(DagForest *forest, void *fob) { DagNode *node; @@ -853,7 +854,7 @@ DagNode * dag_add_node (DagForest *forest, void * fob) node->ob = fob; node->color = DAG_WHITE; - if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting + if (ugly_hack_sorry) node->type = GS(((ID *) fob)->name); // sorry, done for pose sorting if (forest->numNodes) { ((DagNode *) forest->DagNode.last)->next = node; forest->DagNode.last = node; @@ -866,18 +867,18 @@ DagNode * dag_add_node (DagForest *forest, void * fob) } if (!forest->nodeHash) - forest->nodeHash= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); + forest->nodeHash = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dag_add_node gh"); BLI_ghash_insert(forest->nodeHash, fob, node); } return node; } -DagNode * dag_get_node (DagForest *forest, void * fob) +DagNode *dag_get_node(DagForest *forest, void *fob) { DagNode *node; - node = dag_find_node (forest, fob); + node = dag_find_node(forest, fob); if (!node) node = dag_add_node(forest, fob); return node; @@ -885,10 +886,10 @@ DagNode * dag_get_node (DagForest *forest, void * fob) -DagNode * dag_get_sub_node (DagForest *forest, void * fob) +DagNode *dag_get_sub_node(DagForest *forest, void *fob) { DagNode *node; - DagAdjList *mainchild, *prev=NULL; + DagAdjList *mainchild, *prev = NULL; mainchild = ((DagNode *) forest->DagNode.first)->child; /* remove from first node (scene) adj list if present */ @@ -908,7 +909,7 @@ DagNode * dag_get_sub_node (DagForest *forest, void * fob) prev = mainchild; mainchild = mainchild->next; } - node = dag_find_node (forest, fob); + node = dag_find_node(forest, fob); if (!node) node = dag_add_node(forest, fob); return node; @@ -966,9 +967,9 @@ static const char *dag_node_name(DagNode *node) if (node->ob == NULL) return "null"; else if (ugly_hack_sorry) - return ((ID*)(node->ob))->name+2; + return ((ID *)(node->ob))->name + 2; else - return ((bPoseChannel*)(node->ob))->name; + return ((bPoseChannel *)(node->ob))->name; } static void dag_node_print_dependencies(DagNode *node) @@ -977,7 +978,7 @@ static void dag_node_print_dependencies(DagNode *node) printf("%s depends on:\n", dag_node_name(node)); - for (itA= node->parent; itA; itA= itA->next) + for (itA = node->parent; itA; itA = itA->next) printf(" %s through %s\n", dag_node_name(itA->node), itA->name); printf("\n"); } @@ -989,12 +990,12 @@ static int dag_node_print_dependency_recurs(DagNode *node, DagNode *endnode) if (node->color == DAG_BLACK) return 0; - node->color= DAG_BLACK; + node->color = DAG_BLACK; if (node == endnode) return 1; - for (itA= node->parent; itA; itA= itA->next) { + for (itA = node->parent; itA; itA = itA->next) { if (dag_node_print_dependency_recurs(itA->node, endnode)) { printf(" %s depends on %s through %s.\n", dag_node_name(node), dag_node_name(itA->node), itA->name); return 1; @@ -1008,8 +1009,8 @@ static void dag_node_print_dependency_cycle(DagForest *dag, DagNode *startnode, { DagNode *node; - for (node = dag->DagNode.first; node; node= node->next) - node->color= DAG_WHITE; + for (node = dag->DagNode.first; node; node = node->next) + node->color = DAG_WHITE; printf(" %s depends on %s through %s.\n", dag_node_name(endnode), dag_node_name(startnode), name); dag_node_print_dependency_recurs(startnode, endnode); @@ -1021,16 +1022,16 @@ static int dag_node_recurs_level(DagNode *node, int level) DagAdjList *itA; int newlevel; - node->color= DAG_BLACK; /* done */ - newlevel= ++level; + node->color = DAG_BLACK; /* done */ + newlevel = ++level; - for (itA= node->parent; itA; itA= itA->next) { - if (itA->node->color==DAG_WHITE) { - itA->node->ancestor_count= dag_node_recurs_level(itA->node, level); - newlevel= MAX2(newlevel, level+itA->node->ancestor_count); + for (itA = node->parent; itA; itA = itA->next) { + if (itA->node->color == DAG_WHITE) { + itA->node->ancestor_count = dag_node_recurs_level(itA->node, level); + newlevel = MAX2(newlevel, level + itA->node->ancestor_count); } else - newlevel= MAX2(newlevel, level+itA->node->ancestor_count); + newlevel = MAX2(newlevel, level + itA->node->ancestor_count); } return newlevel; @@ -1043,22 +1044,22 @@ static void dag_check_cycle(DagForest *dag) /* debugging print */ if (dag_print_dependencies) - for (node = dag->DagNode.first; node; node= node->next) + for (node = dag->DagNode.first; node; node = node->next) dag_node_print_dependencies(node); /* tag nodes unchecked */ - for (node = dag->DagNode.first; node; node= node->next) - node->color= DAG_WHITE; + for (node = dag->DagNode.first; node; node = node->next) + node->color = DAG_WHITE; - for (node = dag->DagNode.first; node; node= node->next) { - if (node->color==DAG_WHITE) { - node->ancestor_count= dag_node_recurs_level(node, 0); + for (node = dag->DagNode.first; node; node = node->next) { + if (node->color == DAG_WHITE) { + node->ancestor_count = dag_node_recurs_level(node, 0); } } /* check relations, and print errors */ - for (node = dag->DagNode.first; node; node= node->next) { - for (itA= node->parent; itA; itA= itA->next) { + for (node = dag->DagNode.first; node; node = node->next) { + for (itA = node->parent; itA; itA = itA->next) { if (itA->node->ancestor_count > node->ancestor_count) { if (node->ob && itA->node->ob) { printf("Dependency cycle detected:\n"); @@ -1069,7 +1070,7 @@ static void dag_check_cycle(DagForest *dag) } /* parent relations are only needed for cycle checking, so free now */ - for (node = dag->DagNode.first; node; node= node->next) { + for (node = dag->DagNode.first; node; node = node->next) { while (node->parent) { itA = node->parent->next; MEM_freeN(node->parent); @@ -1082,7 +1083,7 @@ static void dag_check_cycle(DagForest *dag) * MainDAG is the DAG of all objects in current scene * used only for drawing there is one also in each scene */ -static DagForest * MainDag = NULL; +static DagForest *MainDag = NULL; DagForest *getMainDag(void) { @@ -1121,7 +1122,7 @@ void graph_bfs(void) /* fprintf(stderr, "starting BFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); - for ( i=0; i<50; i++) + for (i = 0; i < 50; i++) pos[i] = 0; /* Init @@ -1160,14 +1161,14 @@ void graph_bfs(void) itA = itA->next; } - if (pos[node->BFS_dist] > node->k ) { + if (pos[node->BFS_dist] > node->k) { pos[node->BFS_dist] += 1; node->k = (float) pos[node->BFS_dist]; } else { - pos[node->BFS_dist] = (int) node->k +1; + pos[node->BFS_dist] = (int) node->k + 1; } - set_node_xy(node, node->BFS_dist*DEPSX*2, pos[node->BFS_dist]*DEPSY*2); + set_node_xy(node, node->BFS_dist * DEPSX * 2, pos[node->BFS_dist] * DEPSY * 2); node->color = DAG_BLACK; // fprintf(stderr, "BFS node : %20s %i %5.0f %5.0f\n", ((ID *) node->ob)->name, node->BFS_dist, node->x, node->y); @@ -1190,7 +1191,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a DagNode *node; DagNodeQueue *nqueue; DagAdjList *itA; - int retval = 0; + int retval = 0; /* fprintf(stderr, "starting BFS\n ------------\n"); */ /* Init @@ -1238,7 +1239,7 @@ int pre_and_post_source_BFS(DagForest *dag, short mask, DagNode *source, graph_a } /* non recursive version of DFS, return queue -- outer loop present to catch odd cases (first level cycles)*/ -DagNodeQueue * graph_dfs(void) +DagNodeQueue *graph_dfs(void) { DagNode *node; DagNodeQueue *nqueue; @@ -1249,14 +1250,14 @@ DagNodeQueue * graph_dfs(void) int time; int skip = 0; int minheight; - int maxpos=0; + int maxpos = 0; /* int is_cycle = 0; */ /* UNUSED */ /* - *fprintf(stderr, "starting DFS\n ------------\n"); + *fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); retqueue = queue_create(MainDag->numNodes); - for ( i=0; i<50; i++) + for (i = 0; i < 50; i++) pos[i] = 0; /* Init @@ -1276,86 +1277,86 @@ DagNodeQueue * graph_dfs(void) node = MainDag->DagNode.first; do { - if (node->color == DAG_WHITE) { - node->color = DAG_GRAY; - node->DFS_dist = 1; - node->DFS_dvtm = time; - time++; - push_stack(nqueue, node); + if (node->color == DAG_WHITE) { + node->color = DAG_GRAY; + node->DFS_dist = 1; + node->DFS_dvtm = time; + time++; + push_stack(nqueue, node); - while (nqueue->count) { - //graph_print_queue(nqueue); + while (nqueue->count) { + //graph_print_queue(nqueue); - skip = 0; - node = get_top_node_queue(nqueue); + skip = 0; + node = get_top_node_queue(nqueue); - minheight = pos[node->DFS_dist]; + minheight = pos[node->DFS_dist]; - itA = node->child; - while (itA != NULL) { - if (itA->node->color == DAG_WHITE) { - itA->node->DFS_dvtm = time; - itA->node->color = DAG_GRAY; + itA = node->child; + while (itA != NULL) { + if (itA->node->color == DAG_WHITE) { + itA->node->DFS_dvtm = time; + itA->node->color = DAG_GRAY; - time++; - itA->node->DFS_dist = node->DFS_dist + 1; - itA->node->k = (float) minheight; - push_stack(nqueue, itA->node); - skip = 1; - break; - } - else { - if (itA->node->color == DAG_GRAY) { // back edge - fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); - /* is_cycle = 1; */ /* UNUSED */ + time++; + itA->node->DFS_dist = node->DFS_dist + 1; + itA->node->k = (float) minheight; + push_stack(nqueue, itA->node); + skip = 1; + break; } - else if (itA->node->color == DAG_BLACK) { - /* already processed node but we may want later to change distance either to shorter to longer. - * DFS_dist is the first encounter - */ + else { + if (itA->node->color == DAG_GRAY) { // back edge + fprintf(stderr, "dfs back edge :%15s %15s\n", ((ID *) node->ob)->name, ((ID *) itA->node->ob)->name); + /* is_cycle = 1; */ /* UNUSED */ + } + else if (itA->node->color == DAG_BLACK) { + /* already processed node but we may want later to change distance either to shorter to longer. + * DFS_dist is the first encounter + */ #if 0 - if (node->DFS_dist >= itA->node->DFS_dist) - itA->node->DFS_dist = node->DFS_dist + 1; + if (node->DFS_dist >= itA->node->DFS_dist) + itA->node->DFS_dist = node->DFS_dist + 1; fprintf(stderr, "dfs forward or cross edge :%15s %i-%i %15s %i-%i\n", - ((ID *) node->ob)->name, - node->DFS_dvtm, - node->DFS_fntm, - ((ID *) itA->node->ob)->name, - itA->node->DFS_dvtm, - itA->node->DFS_fntm); + ((ID *) node->ob)->name, + node->DFS_dvtm, + node->DFS_fntm, + ((ID *) itA->node->ob)->name, + itA->node->DFS_dvtm, + itA->node->DFS_fntm); #endif + } + else + fprintf(stderr, "dfs unknown edge\n"); } - else - fprintf(stderr, "dfs unknown edge\n"); + itA = itA->next; } - itA = itA->next; - } - if (!skip) { - node = pop_queue(nqueue); - node->color = DAG_BLACK; + if (!skip) { + node = pop_queue(nqueue); + node->color = DAG_BLACK; - node->DFS_fntm = time; - time++; - if (node->DFS_dist > maxpos) - maxpos = node->DFS_dist; - if (pos[node->DFS_dist] > node->k ) { - pos[node->DFS_dist] += 1; - node->k = (float) pos[node->DFS_dist]; - } - else { - pos[node->DFS_dist] = (int) node->k +1; - } - set_node_xy(node, node->DFS_dist*DEPSX*2, pos[node->DFS_dist]*DEPSY*2); + node->DFS_fntm = time; + time++; + if (node->DFS_dist > maxpos) + maxpos = node->DFS_dist; + if (pos[node->DFS_dist] > node->k) { + pos[node->DFS_dist] += 1; + node->k = (float) pos[node->DFS_dist]; + } + else { + pos[node->DFS_dist] = (int) node->k + 1; + } + set_node_xy(node, node->DFS_dist * DEPSX * 2, pos[node->DFS_dist] * DEPSY * 2); - // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); + // fprintf(stderr, "DFS node : %20s %i %i %i %i\n", ((ID *) node->ob)->name, node->BFS_dist, node->DFS_dist, node->DFS_dvtm, node->DFS_fntm ); - push_stack(retqueue, node); + push_stack(retqueue, node); + } } } - } node = node->next; } while (node); // fprintf(stderr, "i size : %i\n", maxpos); @@ -1382,7 +1383,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a int skip = 0; int retval = 0; /* - *fprintf(stderr, "starting DFS\n ------------\n"); + * fprintf(stderr, "starting DFS\n ------------\n"); */ nqueue = queue_create(DAGQUEUEALLOC); @@ -1429,7 +1430,7 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a break; } else { - if (itA->node->color == DAG_GRAY) {// back edge + if (itA->node->color == DAG_GRAY) { // back edge retval = 1; } // else if (itA->node->color == DAG_BLACK) { // cross or forward @@ -1457,14 +1458,13 @@ int pre_and_post_source_DFS(DagForest *dag, short mask, DagNode *source, graph_a // used to get the obs owning a datablock -struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) -{ - DagNode * node, *node1; +struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob){ + DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; node = dag_find_node(dag, ob); - if (node==NULL) { + if (node == NULL) { return NULL; } else if (node->ancestor_count == 1) { // simple case @@ -1491,9 +1491,8 @@ struct DagNodeQueue *get_obparents(struct DagForest *dag, void *ob) return nqueue; } -struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) -{ - DagNode * node, *node1; +struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob){ + DagNode *node, *node1; DagNodeQueue *nqueue; DagAdjList *itA; @@ -1520,8 +1519,7 @@ struct DagNodeQueue *get_first_ancestors(struct DagForest *dag, void *ob) } // standard DFS list -struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) -{ +struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob){ DagNode *node; DagNodeQueue *nqueue; DagNodeQueue *retqueue; @@ -1581,9 +1579,9 @@ struct DagNodeQueue *get_all_childs(struct DagForest *dag, void *ob) /* unused */ #if 0 -short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) +short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) { - DagNode * node; + DagNode *node; DagAdjList *itA; node = dag_find_node(dag, ob1); @@ -1599,7 +1597,7 @@ short are_obs_related(struct DagForest *dag, void *ob1, void *ob2) } #endif -int is_acyclic(DagForest *dag) +int is_acyclic(DagForest *dag) { return dag->is_acyclic; } @@ -1634,9 +1632,9 @@ void graph_print_queue_dist(DagNodeQueue *nqueue) count = 0; while (queueElem) { fprintf(stderr, "** %25s %2.2i-%2.2i ", ((ID *) queueElem->node->ob)->name, queueElem->node->DFS_dvtm, queueElem->node->DFS_fntm); - while (count < queueElem->node->DFS_dvtm-1) { fputc(' ', stderr); count++;} + while (count < queueElem->node->DFS_dvtm - 1) { fputc(' ', stderr); count++; } fputc('|', stderr); - while (count < queueElem->node->DFS_fntm-2) { fputc('-', stderr); count++;} + while (count < queueElem->node->DFS_fntm - 2) { fputc('-', stderr); count++; } fputc('|', stderr); fputc('\n', stderr); count = 0; @@ -1668,13 +1666,13 @@ void graph_print_adj_list(void) /* mechanism to allow editors to be informed of depsgraph updates, * to do their own updates based on changes... */ -static void (*EditorsUpdateIDCb)(Main *bmain, ID *id)= NULL; -static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated)= NULL; +static void (*EditorsUpdateIDCb)(Main *bmain, ID *id) = NULL; +static void (*EditorsUpdateSceneCb)(Main *bmain, Scene *scene, int updated) = NULL; void DAG_editors_update_cb(void (*id_func)(Main *bmain, ID *id), void (*scene_func)(Main *bmain, Scene *scene, int updated)) { - EditorsUpdateIDCb= id_func; - EditorsUpdateSceneCb= scene_func; + EditorsUpdateIDCb = id_func; + EditorsUpdateSceneCb = scene_func; } static void dag_editors_id_update(Main *bmain, ID *id) @@ -1698,37 +1696,37 @@ static void scene_sort_groups(Main *bmain, Scene *sce) Object *ob; /* test; are group objects all in this scene? */ - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ob->id.flag &= ~LIB_DOIT; - ob->id.newid= NULL; /* newid abuse for GroupObject */ + ob->id.newid = NULL; /* newid abuse for GroupObject */ } - for (base = sce->base.first; base; base= base->next) + for (base = sce->base.first; base; base = base->next) base->object->id.flag |= LIB_DOIT; - for (group= bmain->group.first; group; group= group->id.next) { - for (go= group->gobject.first; go; go= go->next) { - if ((go->ob->id.flag & LIB_DOIT)==0) + for (group = bmain->group.first; group; group = group->id.next) { + for (go = group->gobject.first; go; go = go->next) { + if ((go->ob->id.flag & LIB_DOIT) == 0) break; } /* this group is entirely in this scene */ - if (go==NULL) { - ListBase listb= {NULL, NULL}; + if (go == NULL) { + ListBase listb = {NULL, NULL}; - for (go= group->gobject.first; go; go= go->next) - go->ob->id.newid= (ID *)go; + for (go = group->gobject.first; go; go = go->next) + go->ob->id.newid = (ID *)go; /* in order of sorted bases we reinsert group objects */ - for (base = sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { if (base->object->id.newid) { - go= (GroupObject *)base->object->id.newid; - base->object->id.newid= NULL; + go = (GroupObject *)base->object->id.newid; + base->object->id.newid = NULL; BLI_remlink(&group->gobject, go); BLI_addtail(&listb, go); } } /* copy the newly sorted listbase */ - group->gobject= listb; + group->gobject = listb; } } } @@ -1744,7 +1742,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) ListBase tempbase; Base *base; - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; build_dag(bmain, sce, DAG_RL_ALL_BUT_DATA); @@ -1752,7 +1750,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) nqueue = queue_create(DAGQUEUEALLOC); - for (node = sce->theDag->DagNode.first; node; node= node->next) { + for (node = sce->theDag->DagNode.first; node; node = node->next) { node->color = DAG_WHITE; } @@ -1785,7 +1783,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == sce) // we are done + if (node->ob == sce) // we are done break; node->color = DAG_BLACK; @@ -1807,7 +1805,7 @@ void DAG_scene_sort(Main *bmain, Scene *sce) BLI_remlink(&sce->base, base); BLI_addhead(&tempbase, base); //if (G.debug & G_DEBUG) - printf("cyclic %s\n", base->object->id.name); + printf("cyclic %s\n", base->object->id.name); base = sce->base.first; } @@ -1819,12 +1817,12 @@ void DAG_scene_sort(Main *bmain, Scene *sce) if (G.debug & G_DEBUG) { printf("\nordered\n"); - for (base = sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { printf(" %s\n", base->object->id.name); } } /* temporal...? */ - sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ + sce->recalc |= SCE_PRV_CHANGED; /* test for 3d preview */ } static void lib_id_recalc_tag(Main *bmain, ID *id) @@ -1842,26 +1840,26 @@ static void lib_id_recalc_data_tag(Main *bmain, ID *id) /* node was checked to have lasttime != curtime and is if type ID_OB */ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) { - Main *bmain= G.main; + Main *bmain = G.main; DagAdjList *itA; Object *ob, *obc; - int oldflag, changed=0; + int oldflag, changed = 0; unsigned int all_layer; - node->lasttime= curtime; + node->lasttime = curtime; - ob= node->ob; + ob = node->ob; if (ob && (ob->recalc & OB_RECALC_ALL)) { - all_layer= node->scelay; + all_layer = node->scelay; /* got an object node that changes, now check relations */ - for (itA = node->child; itA; itA= itA->next) { + for (itA = node->child; itA; itA = itA->next) { all_layer |= itA->lay; /* the relationship is visible */ if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) - if (itA->node->type==ID_OB) { - obc= itA->node->ob; - oldflag= obc->recalc; + if (itA->node->type == ID_OB) { + obc = itA->node->ob; + oldflag = obc->recalc; /* got a ob->obc relation, now check if flag needs flush */ if (ob->recalc & OB_RECALC_OB) { @@ -1888,15 +1886,15 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) lib_id_recalc_data_tag(bmain, &obc->id); } } - if (oldflag!=obc->recalc) changed= 1; + if (oldflag != obc->recalc) changed = 1; } } } /* even nicer, we can clear recalc flags... */ - if ((all_layer & layer)==0) { // XXX && (ob != obedit)) { + if ((all_layer & layer) == 0) { // XXX && (ob != obedit)) { /* but existing displaylists or derivedmesh should be freed */ if (ob->recalc & OB_RECALC_DATA) - object_free_display(ob); + BKE_object_free_display(ob); ob->recalc &= ~OB_RECALC_ALL; } @@ -1905,15 +1903,15 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) /* check case where child changes and parent forcing obdata to change */ /* should be done regardless if this ob has recalc set */ /* could merge this in with loop above...? (ton) */ - for (itA = node->child; itA; itA= itA->next) { + for (itA = node->child; itA; itA = itA->next) { /* the relationship is visible */ - if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) - if (itA->node->type==ID_OB) { - obc= itA->node->ob; + if ((itA->lay & layer)) { // XXX || (itA->node->ob == obedit) + if (itA->node->type == ID_OB) { + obc = itA->node->ob; /* child moves */ - if ((obc->recalc & OB_RECALC_ALL)==OB_RECALC_OB) { + if ((obc->recalc & OB_RECALC_ALL) == OB_RECALC_OB) { /* parent has deforming info */ - if (itA->type & (DAG_RL_OB_DATA|DAG_RL_DATA_DATA)) { + if (itA->type & (DAG_RL_OB_DATA | DAG_RL_DATA_DATA)) { // printf("parent %s changes ob %s\n", ob->id.name, obc->id.name); obc->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obc->id); @@ -1924,8 +1922,8 @@ static void flush_update_node(DagNode *node, unsigned int layer, int curtime) } /* we only go deeper if node not checked or something changed */ - for (itA = node->child; itA; itA= itA->next) { - if (changed || itA->node->lasttime!=curtime) + for (itA = node->child; itA; itA = itA->next) { + if (changed || itA->node->lasttime != curtime) flush_update_node(itA->node, layer, curtime); } @@ -1936,15 +1934,15 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) { DagAdjList *itA; - node->lasttime= curtime; - node->lay= node->scelay; + node->lasttime = curtime; + node->lay = node->scelay; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { - if (itA->node->lasttime!=curtime) { - itA->lay= flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { + if (itA->node->lasttime != curtime) { + itA->lay = flush_layer_node(sce, itA->node, curtime); // lay is only set once for each relation } - else itA->lay= itA->node->lay; + else itA->lay = itA->node->lay; node->lay |= itA->lay; } @@ -1956,16 +1954,16 @@ static unsigned int flush_layer_node(Scene *sce, DagNode *node, int curtime) /* node was checked to have lasttime != curtime, and is of type ID_OB */ static void flush_pointcache_reset(Scene *scene, DagNode *node, int curtime, int reset) { - Main *bmain= G.main; + Main *bmain = G.main; DagAdjList *itA; Object *ob; - node->lasttime= curtime; + node->lasttime = curtime; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { - if (itA->node->lasttime!=curtime) { - ob= (Object*)(itA->node->ob); + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { + if (itA->node->lasttime != curtime) { + ob = (Object *)(itA->node->ob); if (reset || (ob->recalc & OB_RECALC_ALL)) { if (BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_DEPSGRAPH)) { @@ -1990,18 +1988,18 @@ static void dag_scene_flush_layers(Scene *sce, int lay) Base *base; int lasttime; - firstnode= sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; // always scene node - for (itA = firstnode->child; itA; itA= itA->next) - itA->lay= 0; + for (itA = firstnode->child; itA; itA = itA->next) + itA->lay = 0; - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; /* update layer flags in nodes */ - for (base= sce->base.first; base; base= base->next) { - node= dag_get_node(sce->theDag, base->object); - node->scelay= base->object->lay; + for (base = sce->base.first; base; base = base->next) { + node = dag_get_node(sce->theDag, base->object); + node->scelay = base->object->lay; } /* ensure cameras are set as if they are on a visible layer, because @@ -2009,7 +2007,7 @@ static void dag_scene_flush_layers(Scene *sce, int lay) * * XXX, this wont work for local view / unlocked camera's */ if (sce->camera) { - node= dag_get_node(sce->theDag, sce->camera); + node = dag_get_node(sce->theDag, sce->camera); node->scelay |= lay; } @@ -2017,9 +2015,9 @@ static void dag_scene_flush_layers(Scene *sce, int lay) { TimeMarker *m; - for (m= sce->markers.first; m; m= m->next) { + for (m = sce->markers.first; m; m = m->next) { if (m->camera) { - node= dag_get_node(sce->theDag, m->camera); + node = dag_get_node(sce->theDag, m->camera); node->scelay |= lay; } } @@ -2027,8 +2025,8 @@ static void dag_scene_flush_layers(Scene *sce, int lay) #endif /* flush layer nodes to dependencies */ - for (itA = firstnode->child; itA; itA= itA->next) - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) + for (itA = firstnode->child; itA; itA = itA->next) + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) flush_layer_node(sce, itA->node, lasttime); } @@ -2037,16 +2035,16 @@ static void dag_tag_renderlayers(Scene *sce, unsigned int lay) if (sce->nodetree) { bNode *node; Base *base; - unsigned int lay_changed= 0; + unsigned int lay_changed = 0; - for (base= sce->base.first; base; base= base->next) + for (base = sce->base.first; base; base = base->next) if (base->lay & lay) if (base->object->recalc) lay_changed |= base->lay; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==(ID *)sce) { - SceneRenderLayer *srl= BLI_findlink(&sce->r.layers, node->custom1); + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == (ID *)sce) { + SceneRenderLayer *srl = BLI_findlink(&sce->r.layers, node->custom1); if (srl && (srl->lay & lay_changed)) nodeUpdate(sce->nodetree, node); } @@ -2062,30 +2060,30 @@ void DAG_scene_flush_update(Main *bmain, Scene *sce, unsigned int lay, const sho Object *ob; int lasttime; - if (sce->theDag==NULL) { + if (sce->theDag == NULL) { printf("DAG zero... not allowed to happen!\n"); DAG_scene_sort(bmain, sce); } - firstnode= sce->theDag->DagNode.first; // always scene node + firstnode = sce->theDag->DagNode.first; // always scene node /* first we flush the layer flags */ dag_scene_flush_layers(sce, lay); /* then we use the relationships + layer info to flush update events */ - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; - for (itA = firstnode->child; itA; itA= itA->next) - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; + for (itA = firstnode->child; itA; itA = itA->next) + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) flush_update_node(itA->node, lay, lasttime); /* if update is not due to time change, do pointcache clears */ if (!time) { - sce->theDag->time++; // so we know which nodes were accessed - lasttime= sce->theDag->time; - for (itA = firstnode->child; itA; itA= itA->next) { - if (itA->node->lasttime!=lasttime && itA->node->type==ID_OB) { - ob= (Object*)(itA->node->ob); + sce->theDag->time++; // so we know which nodes were accessed + lasttime = sce->theDag->time; + for (itA = firstnode->child; itA; itA = itA->next) { + if (itA->node->lasttime != lasttime && itA->node->type == ID_OB) { + ob = (Object *)(itA->node->ob); if (ob->recalc & OB_RECALC_ALL) { if (BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH)) { @@ -2109,7 +2107,7 @@ static int object_modifiers_use_time(Object *ob) ModifierData *md; /* check if a modifier in modifier stack needs time input */ - for (md=ob->modifiers.first; md; md=md->next) + for (md = ob->modifiers.first; md; md = md->next) if (modifier_dependsOnTime(md)) return 1; @@ -2148,14 +2146,14 @@ static short animdata_use_time(AnimData *adt) { NlaTrack *nlt; - if (adt==NULL) return 0; + if (adt == NULL) return 0; /* check action - only if assigned, and it has anim curves */ if (adt->action && adt->action->curves.first) return 1; /* check NLA tracks + strips */ - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { if (nlt->strips.first) return 1; } @@ -2184,8 +2182,8 @@ static void dag_object_time_update_flags(Object *ob) { if (ob->constraints.first) { bConstraint *con; - for (con = ob->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -2197,7 +2195,7 @@ static void dag_object_time_update_flags(Object *ob) else if (cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar) { ob->recalc |= OB_RECALC_OB; break; @@ -2214,7 +2212,7 @@ static void dag_object_time_update_flags(Object *ob) if (ob->parent) { /* motion path or bone child */ - if (ob->parent->type==OB_CURVE || ob->parent->type==OB_ARMATURE) ob->recalc |= OB_RECALC_OB; + if (ob->parent->type == OB_CURVE || ob->parent->type == OB_ARMATURE) ob->recalc |= OB_RECALC_OB; } #if 0 // XXX old animation system @@ -2222,7 +2220,7 @@ static void dag_object_time_update_flags(Object *ob) if (ob->dup_group) { bActionStrip *strip; /* this case is for groups with nla, whilst nla target has no action or nla */ - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) strip->object->recalc |= OB_RECALC_ALL; } @@ -2235,20 +2233,20 @@ static void dag_object_time_update_flags(Object *ob) ob->adt->recalc |= ADT_RECALC_ANIM; } - if ((ob->adt) && (ob->type==OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA; + if ((ob->adt) && (ob->type == OB_ARMATURE)) ob->recalc |= OB_RECALC_DATA; if (object_modifiers_use_time(ob)) ob->recalc |= OB_RECALC_DATA; if ((ob->pose) && (ob->pose->flag & POSE_CONSTRAINTS_TIMEDEPEND)) ob->recalc |= OB_RECALC_DATA; { - AnimData *adt= BKE_animdata_from_id((ID *)ob->data); + AnimData *adt = BKE_animdata_from_id((ID *)ob->data); Mesh *me; Curve *cu; Lattice *lt; switch (ob->type) { case OB_MESH: - me= ob->data; + me = ob->data; if (me->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; @@ -2259,7 +2257,7 @@ static void dag_object_time_update_flags(Object *ob) break; case OB_CURVE: case OB_SURF: - cu= ob->data; + cu = ob->data; if (cu->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; @@ -2267,18 +2265,18 @@ static void dag_object_time_update_flags(Object *ob) } break; case OB_FONT: - cu= ob->data; - if (cu->nurb.first==NULL && cu->str && cu->vfont) + cu = ob->data; + if (cu->nurb.first == NULL && cu->str && cu->vfont) ob->recalc |= OB_RECALC_DATA; break; case OB_LATTICE: - lt= ob->data; + lt = ob->data; if (lt->key) { if (!(ob->shapeflag & OB_SHAPE_LOCK)) { ob->recalc |= OB_RECALC_DATA; } } - break; + break; case OB_MBALL: if (ob->transflag & OB_DUPLI) ob->recalc |= OB_RECALC_DATA; break; @@ -2290,9 +2288,9 @@ static void dag_object_time_update_flags(Object *ob) } if (ob->particlesystem.first) { - ParticleSystem *psys= ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { if (psys_check_enabled(ob, psys)) { ob->recalc |= OB_RECALC_DATA; break; @@ -2319,7 +2317,7 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s /* set ob flags where animated systems are */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (do_time) { /* now if DagNode were part of base, the node->lay could be checked... */ @@ -2334,22 +2332,22 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s if (do_time) { /* we do groups each once */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { dag_object_time_update_flags(go->ob); } } } } - for (sce_iter= scene; sce_iter; sce_iter= sce_iter->set) + for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) DAG_scene_flush_update(bmain, sce_iter, lay, 1); if (do_time) { /* test: set time flag, to disable baked systems to update */ for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; + ob = base->object; if (ob->recalc) ob->recalc |= OB_RECALC_TIME; } @@ -2360,10 +2358,10 @@ void DAG_scene_update_flags(Main *bmain, Scene *scene, unsigned int lay, const s } /* and store the info in groupobject */ - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { - go->recalc= go->ob->recalc; + for (go = group->gobject.first; go; go = go->next) { + go->recalc = go->ob->recalc; // printf("ob %s recalc %d\n", go->ob->id.name, go->recalc); } group->id.flag &= ~LIB_DOIT; @@ -2380,22 +2378,22 @@ static void dag_current_scene_layers(Main *bmain, Scene **sce, unsigned int *lay /* only one scene supported currently, making more scenes work * correctly requires changes beyond just the dependency graph */ - *sce= NULL; - *lay= 0; + *sce = NULL; + *lay = 0; - if ((wm= bmain->wm.first)) { + if ((wm = bmain->wm.first)) { /* if we have a windowmanager, look into windows */ - for (win=wm->windows.first; win; win=win->next) { + for (win = wm->windows.first; win; win = win->next) { if (win->screen) { - if (!*sce) *sce= win->screen->scene; + if (!*sce) *sce = win->screen->scene; *lay |= BKE_screen_visible_layers(win->screen, win->screen->scene); } } } else { /* if not, use the first sce */ - *sce= bmain->scene.first; - if (*sce) *lay= (*sce)->lay; + *sce = bmain->scene.first; + if (*sce) *lay = (*sce)->lay; /* XXX for background mode, we should get the scene * from somewhere, for the -S option, but it's in @@ -2435,9 +2433,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) dag_scene_flush_layers(scene, lay); for (SETLOOPER(scene, sce_iter, base)) { - ob= base->object; - node= (sce_iter->theDag)? dag_get_node(sce_iter->theDag, ob): NULL; - oblay= (node)? node->lay: ob->lay; + ob = base->object; + node = (sce_iter->theDag) ? dag_get_node(sce_iter->theDag, ob) : NULL; + oblay = (node) ? node->lay : ob->lay; if ((oblay & lay) & ~scene->lay_updated) { if (ELEM6(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) @@ -2447,9 +2445,9 @@ void DAG_on_visible_update(Main *bmain, const short do_time) } } - for (group= bmain->group.first; group; group= group->id.next) { + for (group = bmain->group.first; group; group = group->id.next) { if (group->id.flag & LIB_DOIT) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (ELEM6(go->ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_MBALL, OB_LATTICE)) go->ob->recalc |= OB_RECALC_DATA; if (go->ob->proxy_from) @@ -2473,7 +2471,7 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS { struct { ID *id; int is_dependent; } *data = userData; - if (*idpoin && GS((*idpoin)->name)==ID_TE) { + if (*idpoin && GS((*idpoin)->name) == ID_TE) { if (data->id == (*idpoin)) data->is_dependent = 1; } @@ -2481,8 +2479,8 @@ static void dag_id_flush_update__isDependentTexture(void *userData, Object *UNUS static void dag_id_flush_update(Scene *sce, ID *id) { - Main *bmain= G.main; - Object *obt, *ob= NULL; + Main *bmain = G.main; + Object *obt, *ob = NULL; short idtype; /* here we flush a few things before actual scene wide flush, mostly @@ -2490,27 +2488,27 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags & pointcache for object */ if (GS(id->name) == ID_OB) { - ob= (Object*)id; + ob = (Object *)id; BKE_ptcache_object_reset(sce, ob, PTCACHE_RESET_DEPSGRAPH); if (ob->recalc & OB_RECALC_DATA) { /* all users of this ob->data should be checked */ - id= ob->data; + id = ob->data; /* no point in trying in this cases */ if (id && id->us <= 1) { dag_editors_id_update(bmain, id); - id= NULL; + id = NULL; } } } /* set flags & pointcache for object data */ if (id) { - idtype= GS(id->name); + idtype = GS(id->name); if (ELEM8(idtype, ID_ME, ID_CU, ID_MB, ID_LA, ID_LT, ID_CA, ID_AR, ID_SPK)) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { if (!(ob && obt == ob) && obt->data == id) { obt->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obt->id); @@ -2521,10 +2519,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on textures - can influence depgraph via modifiers */ if (idtype == ID_TE) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { struct { ID *id; int is_dependent; } data; - data.id= id; - data.is_dependent= 0; + data.id = id; + data.is_dependent = 0; modifiers_foreachIDLink(obt, dag_id_flush_update__isDependentTexture, &data); if (data.is_dependent) { @@ -2537,11 +2535,11 @@ static void dag_id_flush_update(Scene *sce, ID *id) ParticleSystem *psys = obt->particlesystem.first; MTex **mtexp, *mtex; int a; - for (; psys; psys=psys->next) { + for (; psys; psys = psys->next) { mtexp = psys->part->mtex; - for (a=0; atex == (Tex*)id) { + if (mtex && mtex->tex == (Tex *)id) { obt->recalc |= OB_RECALC_DATA; lib_id_recalc_data_tag(bmain, &obt->id); @@ -2560,10 +2558,10 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on ShapeKey */ if (idtype == ID_KE) { - for (obt=bmain->object.first; obt; obt= obt->id.next) { - Key *key= ob_get_key(obt); + for (obt = bmain->object.first; obt; obt = obt->id.next) { + Key *key = ob_get_key(obt); if (!(ob && obt == ob) && ((ID *)key == id)) { - obt->flag |= (OB_RECALC_OB|OB_RECALC_DATA); + obt->flag |= (OB_RECALC_OB | OB_RECALC_DATA); lib_id_recalc_tag(bmain, &obt->id); lib_id_recalc_data_tag(bmain, &obt->id); BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); @@ -2574,8 +2572,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) /* set flags based on particle settings */ if (idtype == ID_PA) { ParticleSystem *psys; - for (obt=bmain->object.first; obt; obt= obt->id.next) - for (psys=obt->particlesystem.first; psys; psys=psys->next) + for (obt = bmain->object.first; obt; obt = obt->id.next) + for (psys = obt->particlesystem.first; psys; psys = psys->next) if (&psys->part->id == id) BKE_ptcache_object_reset(sce, obt, PTCACHE_RESET_DEPSGRAPH); } @@ -2585,12 +2583,12 @@ static void dag_id_flush_update(Scene *sce, ID *id) BKE_tracking_dopesheet_tag_update(&clip->tracking); - for (obt=bmain->object.first; obt; obt= obt->id.next) { + for (obt = bmain->object.first; obt; obt = obt->id.next) { bConstraint *con; - for (con = obt->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = obt->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); if (ELEM3(cti->type, CONSTRAINT_TYPE_FOLLOWTRACK, CONSTRAINT_TYPE_CAMERASOLVER, - CONSTRAINT_TYPE_OBJECTSOLVER)) + CONSTRAINT_TYPE_OBJECTSOLVER)) { obt->recalc |= OB_RECALC_OB; break; @@ -2601,8 +2599,8 @@ static void dag_id_flush_update(Scene *sce, ID *id) if (sce->nodetree) { bNode *node; - for (node= sce->nodetree->nodes.first; node; node= node->next) { - if (node->id==id) { + for (node = sce->nodetree->nodes.first; node; node = node->next) { + if (node->id == id) { nodeUpdate(sce->nodetree, node); } } @@ -2613,7 +2611,7 @@ static void dag_id_flush_update(Scene *sce, ID *id) * so it should happen tracking-related constraints recalculation * when camera is changing (sergey) */ if (sce->camera && &sce->camera->id == id) { - MovieClip *clip = object_get_movieclip(sce, sce->camera, 1); + MovieClip *clip = BKE_object_movieclip_get(sce, sce->camera, 1); if (clip) dag_id_flush_update(sce, &clip->id); @@ -2646,8 +2644,8 @@ void DAG_ids_flush_tagged(Main *bmain) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - for (; id; id=id->next) { - if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) { + for (; id; id = id->next) { + if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) { dag_id_flush_update(sce, id); do_flush = 1; } @@ -2675,7 +2673,7 @@ void DAG_ids_check_recalc(Main *bmain, Scene *scene, int time) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - updated= 1; + updated = 1; break; } } @@ -2698,9 +2696,9 @@ void DAG_ids_clear_recalc(Main *bmain) /* we tag based on first ID type character to avoid * looping over all ID's in case there are no tags */ if (id && bmain->id_tag_update[id->name[0]]) { - for (; id; id=id->next) - if (id->flag & (LIB_ID_RECALC|LIB_ID_RECALC_DATA)) - id->flag &= ~(LIB_ID_RECALC|LIB_ID_RECALC_DATA); + for (; id; id = id->next) + if (id->flag & (LIB_ID_RECALC | LIB_ID_RECALC_DATA)) + id->flag &= ~(LIB_ID_RECALC | LIB_ID_RECALC_DATA); } } @@ -2709,15 +2707,15 @@ void DAG_ids_clear_recalc(Main *bmain) void DAG_id_tag_update(ID *id, short flag) { - Main *bmain= G.main; + Main *bmain = G.main; - if (id==NULL) return; + if (id == NULL) return; /* tag ID for update */ if (flag) { if (flag & OB_RECALC_OB) lib_id_recalc_tag(bmain, id); - if (flag & (OB_RECALC_DATA|PSYS_RECALC)) + if (flag & (OB_RECALC_DATA | PSYS_RECALC)) lib_id_recalc_data_tag(bmain, id); } else @@ -2730,14 +2728,14 @@ void DAG_id_tag_update(ID *id, short flag) if (idtype == ID_OB) { /* only quick tag */ - ob = (Object*)id; + ob = (Object *)id; ob->recalc |= (flag & OB_RECALC_ALL); } else if (idtype == ID_PA) { ParticleSystem *psys; /* this is weak still, should be done delayed as well */ - for (ob=bmain->object.first; ob; ob=ob->id.next) { - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { if (&psys->part->id == id) { ob->recalc |= (flag & OB_RECALC_ALL); psys->recalc |= (flag & PSYS_RECALC); @@ -2757,12 +2755,12 @@ void DAG_id_tag_update(ID *id, short flag) void DAG_id_type_tag(struct Main *bmain, short idtype) { - bmain->id_tag_update[((char*)&idtype)[0]] = 1; + bmain->id_tag_update[((char *)&idtype)[0]] = 1; } int DAG_id_type_tagged(Main *bmain, short idtype) { - return bmain->id_tag_update[((char*)&idtype)[0]]; + return bmain->id_tag_update[((char *)&idtype)[0]]; } #if 0 // UNUSED @@ -2772,22 +2770,22 @@ static int parent_check_node(DagNode *node, int curtime) { DagAdjList *itA; - node->lasttime= curtime; + node->lasttime = curtime; - if (node->color==DAG_GRAY) + if (node->color == DAG_GRAY) return DAG_GRAY; - for (itA = node->child; itA; itA= itA->next) { - if (itA->node->type==ID_OB) { + for (itA = node->child; itA; itA = itA->next) { + if (itA->node->type == ID_OB) { - if (itA->node->color==DAG_GRAY) + if (itA->node->color == DAG_GRAY) return DAG_GRAY; /* descend if not done */ - if (itA->node->lasttime!=curtime) { - itA->node->color= parent_check_node(itA->node, curtime); + if (itA->node->lasttime != curtime) { + itA->node->color = parent_check_node(itA->node, curtime); - if (itA->node->color==DAG_GRAY) + if (itA->node->color == DAG_GRAY) return DAG_GRAY; } } @@ -2802,7 +2800,7 @@ static int parent_check_node(DagNode *node, int curtime) /* we assume its an armature with pose */ void DAG_pose_sort(Object *ob) { - bPose *pose= ob->pose; + bPose *pose = ob->pose; bPoseChannel *pchan; bConstraint *con; DagNode *node; @@ -2815,12 +2813,12 @@ void DAG_pose_sort(Object *ob) int skip = 0; dag = dag_init(); - ugly_hack_sorry= 0; // no ID structs + ugly_hack_sorry = 0; // no ID structs - rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL + rootnode = dag_add_node(dag, NULL); // node->ob becomes NULL /* we add the hierarchy and the constraints */ - for (pchan = pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { int addtoroot = 1; node = dag_get_node(dag, pchan); @@ -2830,40 +2828,40 @@ void DAG_pose_sort(Object *ob) dag_add_relation(dag, node2, node, 0, "Parent Relation"); addtoroot = 0; } - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { - if (ct->tar==ob && ct->subtarget[0]) { - bPoseChannel *target= get_pose_channel(ob->pose, ct->subtarget); + for (ct = targets.first; ct; ct = ct->next) { + if (ct->tar == ob && ct->subtarget[0]) { + bPoseChannel *target = BKE_pose_channel_find_name(ob->pose, ct->subtarget); if (target) { - node2= dag_get_node(dag, target); + node2 = dag_get_node(dag, target); dag_add_relation(dag, node2, node, 0, "Pose Constraint"); - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = (bKinematicConstraint *)con->data; bPoseChannel *parchan; - int segcount= 0; + int segcount = 0; /* exclude tip from chain? */ if (!(data->flag & CONSTRAINT_IK_TIP)) - parchan= pchan->parent; + parchan = pchan->parent; else - parchan= pchan; + parchan = pchan; /* Walk to the chain's root */ while (parchan) { - node3= dag_get_node(dag, parchan); + node3 = dag_get_node(dag, parchan); dag_add_relation(dag, node2, node3, 0, "IK Constraint"); segcount++; - if (segcount==data->rootbone || segcount>255) break; // 255 is weak - parchan= parchan->parent; + if (segcount == data->rootbone || segcount > 255) break; // 255 is weak + parchan = parchan->parent; } } } @@ -2874,7 +2872,7 @@ void DAG_pose_sort(Object *ob) cti->flush_constraint_targets(con, &targets, 1); } } - if (addtoroot == 1 ) { + if (addtoroot == 1) { dag_add_relation(dag, rootnode, node, 0, "Root Bone Relation"); } } @@ -2882,12 +2880,12 @@ void DAG_pose_sort(Object *ob) dag_check_cycle(dag); /* now we try to sort... */ - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; nqueue = queue_create(DAGQUEUEALLOC); /* tag nodes unchecked */ - for (node = dag->DagNode.first; node; node= node->next) + for (node = dag->DagNode.first; node; node = node->next) node->color = DAG_WHITE; rootnode->color = DAG_GRAY; @@ -2912,7 +2910,7 @@ void DAG_pose_sort(Object *ob) if (!skip) { if (node) { node = pop_queue(nqueue); - if (node->ob == NULL) // we are done + if (node->ob == NULL) // we are done break; node->color = DAG_BLACK; @@ -2925,7 +2923,7 @@ void DAG_pose_sort(Object *ob) /* temporal correction for circular dependencies */ while (pose->chanbase.first) { - pchan= pose->chanbase.first; + pchan = pose->chanbase.first; BLI_remlink(&pose->chanbase, pchan); BLI_addhead(&tempbase, pchan); @@ -2943,7 +2941,7 @@ void DAG_pose_sort(Object *ob) free_forest(dag); MEM_freeN(dag); - ugly_hack_sorry= 1; + ugly_hack_sorry = 1; } /* ************************ DAG DEBUGGING ********************* */ @@ -2951,17 +2949,17 @@ void DAG_pose_sort(Object *ob) void DAG_print_dependencies(Main *bmain, Scene *scene, Object *ob) { /* utility for debugging dependencies */ - dag_print_dependencies= 1; + dag_print_dependencies = 1; if (ob && (ob->mode & OB_MODE_POSE)) { - printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name+2); + printf("\nDEPENDENCY RELATIONS for %s\n\n", ob->id.name + 2); DAG_pose_sort(ob); } else { - printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name+2); + printf("\nDEPENDENCY RELATIONS for %s\n\n", scene->id.name + 2); DAG_scene_sort(bmain, scene); } - dag_print_dependencies= 0; + dag_print_dependencies = 0; } diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index cf7750520a3..0154a2fa1e5 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -64,7 +64,7 @@ static void boundbox_displist(Object *ob); -void free_disp_elem(DispList *dl) +void BKE_displist_elem_free(DispList *dl) { if (dl) { if (dl->verts) MEM_freeN(dl->verts); @@ -77,84 +77,87 @@ void free_disp_elem(DispList *dl) } } -void freedisplist(ListBase *lb) +void BKE_displist_free(ListBase *lb) { DispList *dl; - dl= lb->first; + dl = lb->first; while (dl) { BLI_remlink(lb, dl); - free_disp_elem(dl); - dl= lb->first; + BKE_displist_elem_free(dl); + dl = lb->first; } } -DispList *find_displist_create(ListBase *lb, int type) +DispList *BKE_displist_find_or_create(ListBase *lb, int type) { DispList *dl; - - dl= lb->first; + + dl = lb->first; while (dl) { - if (dl->type==type) return dl; - dl= dl->next; + if (dl->type == type) + return dl; + dl = dl->next; } - dl= MEM_callocN(sizeof(DispList), "find_disp"); - dl->type= type; + dl = MEM_callocN(sizeof(DispList), "find_disp"); + dl->type = type; BLI_addtail(lb, dl); return dl; } -DispList *find_displist(ListBase *lb, int type) +DispList *BKE_displist_find(ListBase *lb, int type) { DispList *dl; - - dl= lb->first; + + dl = lb->first; while (dl) { - if (dl->type==type) return dl; - dl= dl->next; + if (dl->type == type) + return dl; + dl = dl->next; } return NULL; } -int displist_has_faces(ListBase *lb) +int BKE_displist_has_faces(ListBase *lb) { DispList *dl; - for (dl= lb->first; dl; dl= dl->next) { + + for (dl = lb->first; dl; dl = dl->next) { if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) { - return 1; + return TRUE; } } - return 0; + + return FALSE; } -void copy_displist(ListBase *lbn, ListBase *lb) +void BKE_displist_copy(ListBase *lbn, ListBase *lb) { DispList *dln, *dl; - - freedisplist(lbn); - - dl= lb->first; + + BKE_displist_free(lbn); + + dl = lb->first; while (dl) { - - dln= MEM_dupallocN(dl); + dln = MEM_dupallocN(dl); BLI_addtail(lbn, dln); - dln->verts= MEM_dupallocN(dl->verts); - dln->nors= MEM_dupallocN(dl->nors); - dln->index= MEM_dupallocN(dl->index); - dln->col1= MEM_dupallocN(dl->col1); - dln->col2= MEM_dupallocN(dl->col2); + dln->verts = MEM_dupallocN(dl->verts); + dln->nors = MEM_dupallocN(dl->nors); + dln->index = MEM_dupallocN(dl->index); + dln->col1 = MEM_dupallocN(dl->col1); + dln->col2 = MEM_dupallocN(dl->col2); if (dl->bevelSplitFlag) - dln->bevelSplitFlag= MEM_dupallocN(dl->bevelSplitFlag); + dln->bevelSplitFlag = MEM_dupallocN(dl->bevelSplitFlag); - dl= dl->next; + dl = dl->next; } } -void addnormalsDispList(ListBase *lb) +void BKE_displist_normals_add(ListBase *lb) { DispList *dl = NULL; float *vdata, *ndata, nor[3]; @@ -162,117 +165,118 @@ void addnormalsDispList(ListBase *lb) float *n1, *n2, *n3, *n4; int a, b, p1, p2, p3, p4; + dl = lb->first; - dl= lb->first; - while (dl) { - if (dl->type==DL_INDEX3) { - if (dl->nors==NULL) { - dl->nors= MEM_callocN(sizeof(float)*3, "dlnors"); - if (dl->verts[2] < 0.0f) dl->nors[2]= -1.0f; - else dl->nors[2]= 1.0f; + if (dl->type == DL_INDEX3) { + if (dl->nors == NULL) { + dl->nors = MEM_callocN(sizeof(float) * 3, "dlnors"); + + if (dl->verts[2] < 0.0f) + dl->nors[2] = -1.0f; + else + dl->nors[2] = 1.0f; } } - else if (dl->type==DL_SURF) { - if (dl->nors==NULL) { - dl->nors= MEM_callocN(sizeof(float)*3*dl->nr*dl->parts, "dlnors"); - - vdata= dl->verts; - ndata= dl->nors; - - for (a=0; aparts; a++) { - - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + else if (dl->type == DL_SURF) { + if (dl->nors == NULL) { + dl->nors = MEM_callocN(sizeof(float) * 3 * dl->nr * dl->parts, "dlnors"); + + vdata = dl->verts; + ndata = dl->nors; + + for (a = 0; a < dl->parts; a++) { + + if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) break; - - v1= vdata+ 3*p1; - n1= ndata+ 3*p1; - v2= vdata+ 3*p2; - n2= ndata+ 3*p2; - v3= vdata+ 3*p3; - n3= ndata+ 3*p3; - v4= vdata+ 3*p4; - n4= ndata+ 3*p4; - - for (; bnr; b++) { - + + v1 = vdata + 3 * p1; + n1 = ndata + 3 * p1; + v2 = vdata + 3 * p2; + n2 = ndata + 3 * p2; + v3 = vdata + 3 * p3; + n3 = ndata + 3 * p3; + v4 = vdata + 3 * p4; + n4 = ndata + 3 * p4; + + for (; b < dl->nr; b++) { normal_quad_v3(nor, v1, v3, v4, v2); - + add_v3_v3(n1, nor); add_v3_v3(n2, nor); add_v3_v3(n3, nor); add_v3_v3(n4, nor); - - v2= v1; v1+= 3; - v4= v3; v3+= 3; - n2= n1; n1+= 3; - n4= n3; n3+= 3; + + v2 = v1; v1 += 3; + v4 = v3; v3 += 3; + n2 = n1; n1 += 3; + n4 = n3; n3 += 3; } } - a= dl->parts*dl->nr; - v1= ndata; + a = dl->parts * dl->nr; + v1 = ndata; while (a--) { normalize_v3(v1); - v1+= 3; + v1 += 3; } } } - dl= dl->next; + dl = dl->next; } } -void count_displist(ListBase *lb, int *totvert, int *totface) +void BKE_displist_count(ListBase *lb, int *totvert, int *totface) { DispList *dl; - - dl= lb->first; + + dl = lb->first; while (dl) { - switch (dl->type) { case DL_SURF: - *totvert+= dl->nr*dl->parts; - *totface+= (dl->nr-1)*(dl->parts-1); + *totvert += dl->nr * dl->parts; + *totface += (dl->nr - 1) * (dl->parts - 1); break; case DL_INDEX3: case DL_INDEX4: - *totvert+= dl->nr; - *totface+= dl->parts; + *totvert += dl->nr; + *totface += dl->parts; break; case DL_POLY: case DL_SEGM: - *totvert+= dl->nr*dl->parts; + *totvert += dl->nr * dl->parts; + break; } - - dl= dl->next; + + dl = dl->next; } } -int surfindex_displist(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) +int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4) { - if ((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) { + if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) { return 0; } - + if (dl->flag & DL_CYCL_U) { - (*p1)= dl->nr*a; - (*p2)= (*p1)+ dl->nr-1; - (*p3)= (*p1)+ dl->nr; - (*p4)= (*p2)+ dl->nr; - (*b)= 0; + (*p1) = dl->nr * a; + (*p2) = (*p1) + dl->nr - 1; + (*p3) = (*p1) + dl->nr; + (*p4) = (*p2) + dl->nr; + (*b) = 0; } else { - (*p2)= dl->nr*a; - (*p1)= (*p2)+1; - (*p4)= (*p2)+ dl->nr; - (*p3)= (*p1)+ dl->nr; - (*b)= 1; + (*p2) = dl->nr * a; + (*p1) = (*p2) + 1; + (*p4) = (*p2) + dl->nr; + (*p3) = (*p1) + dl->nr; + (*b) = 1; } - - if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) { - (*p3)-= dl->nr*dl->parts; - (*p4)-= dl->nr*dl->parts; + + if ((dl->flag & DL_CYCL_V) && a == dl->parts - 1) { + (*p3) -= dl->nr * dl->parts; + (*p4) -= dl->nr * dl->parts; } - + return 1; } @@ -286,237 +290,244 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i BPoint *bp; float *data; int a, len, resolu; - - nu= nubase->first; + + nu = nubase->first; while (nu) { - if (nu->hide==0) { - - if (forRender && cu->resolu_ren!=0) - resolu= cu->resolu_ren; + if (nu->hide == 0) { + if (forRender && cu->resolu_ren != 0) + resolu = cu->resolu_ren; else - resolu= nu->resolu; - - if (!BKE_nurb_check_valid_u(nu)); + resolu = nu->resolu; + + if (!BKE_nurb_check_valid_u(nu)) ; else if (nu->type == CU_BEZIER) { - /* count */ - len= 0; - a= nu->pntsu-1; + len = 0; + a = nu->pntsu - 1; if (nu->flagu & CU_NURB_CYCLIC) a++; - prevbezt= nu->bezt; - bezt= prevbezt+1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; while (a--) { - if (a==0 && (nu->flagu & CU_NURB_CYCLIC)) bezt= nu->bezt; - - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) len++; - else len+= resolu; - - if (a==0 && (nu->flagu & CU_NURB_CYCLIC)==0) len++; - - prevbezt= bezt; + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC)) + bezt = nu->bezt; + + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) + len++; + else + len += resolu; + + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) == 0) + len++; + + prevbezt = bezt; bezt++; } - - dl= MEM_callocN(sizeof(DispList), "makeDispListbez"); - /* len+1 because of 'forward_diff_bezier' function */ - dl->verts= MEM_callocN((len+1)*3*sizeof(float), "dlverts"); - BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; - data= dl->verts; + dl = MEM_callocN(sizeof(DispList), "makeDispListbez"); + /* len+1 because of 'forward_diff_bezier' function */ + dl->verts = MEM_callocN((len + 1) * 3 * sizeof(float), "dlverts"); + BLI_addtail(dispbase, dl); + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; + + data = dl->verts; if (nu->flagu & CU_NURB_CYCLIC) { - dl->type= DL_POLY; - a= nu->pntsu; + dl->type = DL_POLY; + a = nu->pntsu; } else { - dl->type= DL_SEGM; - a= nu->pntsu-1; + dl->type = DL_SEGM; + a = nu->pntsu - 1; } - - prevbezt= nu->bezt; - bezt= prevbezt+1; - + + prevbezt = nu->bezt; + bezt = prevbezt + 1; + while (a--) { - if (a==0 && dl->type== DL_POLY) bezt= nu->bezt; - - if (prevbezt->h2==HD_VECT && bezt->h1==HD_VECT) { + if (a == 0 && dl->type == DL_POLY) + bezt = nu->bezt; + + if (prevbezt->h2 == HD_VECT && bezt->h1 == HD_VECT) { copy_v3_v3(data, prevbezt->vec[1]); - data+= 3; + data += 3; } else { int j; - for (j=0; j<3; j++) { + for (j = 0; j < 3; j++) { BKE_curve_forward_diff_bezier(prevbezt->vec[1][j], prevbezt->vec[2][j], bezt->vec[0][j], bezt->vec[1][j], data + j, resolu, 3 * sizeof(float)); } - - data+= 3*resolu; + + data += 3 * resolu; } - - if (a==0 && dl->type==DL_SEGM) { + + if (a == 0 && dl->type == DL_SEGM) { copy_v3_v3(data, bezt->vec[1]); } - - prevbezt= bezt; + + prevbezt = bezt; bezt++; } } else if (nu->type == CU_NURBS) { - len= (resolu*SEGMENTSU(nu)); - - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + len = (resolu * SEGMENTSU(nu)); + + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - - dl->nr= len; - dl->col= nu->mat_nr; + dl->parts = 1; + + dl->nr = len; + dl->col = nu->mat_nr; dl->charidx = nu->charidx; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) + dl->type = DL_POLY; + else dl->type = DL_SEGM; + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } else if (nu->type == CU_POLY) { - len= nu->pntsu; - dl= MEM_callocN(sizeof(DispList), "makeDispListpoly"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + len = nu->pntsu; + dl = MEM_callocN(sizeof(DispList), "makeDispListpoly"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; dl->charidx = nu->charidx; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; - - a= len; - bp= nu->bp; + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; + + a = len; + bp = nu->bp; while (a--) { copy_v3_v3(data, bp->vec); bp++; - data+= 3; + data += 3; } } } - nu= nu->next; + nu = nu->next; } } -void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) +void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal) { ScanFillContext sf_ctx; ScanFillVert *eve, *v1, *vlast; ScanFillFace *efa; - DispList *dlnew=NULL, *dl; + DispList *dlnew = NULL, *dl; float *f1; - int colnr=0, charidx=0, cont=1, tot, a, *index, nextcol= 0; + int colnr = 0, charidx = 0, cont = 1, tot, a, *index, nextcol = 0; intptr_t totvert; - - if (dispbase==NULL) return; - if (dispbase->first==NULL) return; + + if (dispbase == NULL) + return; + if (dispbase->first == NULL) + return; while (cont) { - cont= 0; - totvert= 0; - nextcol= 0; - + cont = 0; + totvert = 0; + nextcol = 0; + BLI_scanfill_begin(&sf_ctx); - - dl= dispbase->first; + + dl = dispbase->first; while (dl) { - - if (dl->type==DL_POLY) { - if (charidxcharidx) cont= 1; - else if (charidx==dl->charidx) { /* character with needed index */ - if (colnr==dl->col) { + if (dl->type == DL_POLY) { + if (charidx < dl->charidx) + cont = 1; + else if (charidx == dl->charidx) { /* character with needed index */ + if (colnr == dl->col) { /* make editverts and edges */ - f1= dl->verts; - a= dl->nr; - eve= v1= NULL; - + f1 = dl->verts; + a = dl->nr; + eve = v1 = NULL; + while (a--) { - vlast= eve; + vlast = eve; eve = BLI_scanfill_vert_add(&sf_ctx, f1); totvert++; - if (vlast==NULL) v1= eve; + if (vlast == NULL) + v1 = eve; else { BLI_scanfill_edge_add(&sf_ctx, vlast, eve); } - f1+=3; + f1 += 3; } - if (eve!=NULL && v1!=NULL) { + if (eve != NULL && v1 != NULL) { BLI_scanfill_edge_add(&sf_ctx, eve, v1); } } - else if (colnrcol) { + else if (colnr < dl->col) { /* got poly with next material at current char */ - cont= 1; - nextcol= 1; + cont = 1; + nextcol = 1; } } } - dl= dl->next; + dl = dl->next; } - - if (totvert && (tot= BLI_scanfill_calc(&sf_ctx, FALSE))) { // XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { - if (tot) { - dlnew= MEM_callocN(sizeof(DispList), "filldisplist"); - dlnew->type= DL_INDEX3; - dlnew->col= colnr; - dlnew->nr= totvert; - dlnew->parts= tot; - dlnew->index= MEM_mallocN(tot*3*sizeof(int), "dlindex"); - dlnew->verts= MEM_mallocN(totvert*3*sizeof(float), "dlverts"); - + /* XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { */ + if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, FALSE))) { + if (tot) { + dlnew = MEM_callocN(sizeof(DispList), "filldisplist"); + dlnew->type = DL_INDEX3; + dlnew->col = colnr; + dlnew->nr = totvert; + dlnew->parts = tot; + + dlnew->index = MEM_mallocN(tot * 3 * sizeof(int), "dlindex"); + dlnew->verts = MEM_mallocN(totvert * 3 * sizeof(float), "dlverts"); + /* vert data */ - f1= dlnew->verts; - totvert= 0; - eve= sf_ctx.fillvertbase.first; + f1 = dlnew->verts; + totvert = 0; + eve = sf_ctx.fillvertbase.first; while (eve) { copy_v3_v3(f1, eve->co); - f1+= 3; - + f1 += 3; + /* index number */ eve->tmp.l = totvert; totvert++; - - eve= eve->next; + + eve = eve->next; } - + /* index data */ efa = sf_ctx.fillfacebase.first; - index= dlnew->index; + index = dlnew->index; while (efa) { - index[0]= (intptr_t)efa->v1->tmp.l; - index[1]= (intptr_t)efa->v2->tmp.l; - index[2]= (intptr_t)efa->v3->tmp.l; + index[0] = (intptr_t)efa->v1->tmp.l; + index[1] = (intptr_t)efa->v2->tmp.l; + index[2] = (intptr_t)efa->v3->tmp.l; if (flipnormal) SWAP(int, index[0], index[2]); - - index+= 3; - efa= efa->next; + + index += 3; + efa = efa->next; } } BLI_addhead(to, dlnew); - } BLI_scanfill_end(&sf_ctx); @@ -527,12 +538,11 @@ void filldisplist(ListBase *dispbase, ListBase *to, int flipnormal) else { /* switch to next char and start filling from first material */ charidx++; - colnr= 0; + colnr = 0; } } - + /* do not free polys, needed for wireframe display */ - } static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) @@ -541,77 +551,77 @@ static void bevels_to_filledpoly(Curve *cu, ListBase *dispbase) DispList *dl, *dlnew; float *fp, *fp1; int a, dpoly; - - front.first= front.last= back.first= back.last= NULL; - - dl= dispbase->first; + + front.first = front.last = back.first = back.last = NULL; + + dl = dispbase->first; while (dl) { - if (dl->type==DL_SURF) { - if ( (dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U)==0 ) { - if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE) ) { - dlnew= MEM_callocN(sizeof(DispList), "filldisp"); + if (dl->type == DL_SURF) { + if ((dl->flag & DL_CYCL_V) && (dl->flag & DL_CYCL_U) == 0) { + if ( (cu->flag & CU_BACK) && (dl->flag & DL_BACK_CURVE)) { + dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&front, dlnew); - dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1"); - dlnew->nr= dl->parts; - dlnew->parts= 1; - dlnew->type= DL_POLY; - dlnew->col= dl->col; + dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->nr = dl->parts; + dlnew->parts = 1; + dlnew->type = DL_POLY; + dlnew->col = dl->col; dlnew->charidx = dl->charidx; - - fp= dl->verts; - dpoly= 3*dl->nr; - - a= dl->parts; + + fp = dl->verts; + dpoly = 3 * dl->nr; + + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); - fp1+= 3; - fp+= dpoly; + fp1 += 3; + fp += dpoly; } } - if ( (cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE) ) { - dlnew= MEM_callocN(sizeof(DispList), "filldisp"); + if ((cu->flag & CU_FRONT) && (dl->flag & DL_FRONT_CURVE)) { + dlnew = MEM_callocN(sizeof(DispList), "filldisp"); BLI_addtail(&back, dlnew); - dlnew->verts= fp1= MEM_mallocN(sizeof(float)*3*dl->parts, "filldisp1"); - dlnew->nr= dl->parts; - dlnew->parts= 1; - dlnew->type= DL_POLY; - dlnew->col= dl->col; - dlnew->charidx= dl->charidx; - - fp= dl->verts+3*(dl->nr-1); - dpoly= 3*dl->nr; - - a= dl->parts; + dlnew->verts = fp1 = MEM_mallocN(sizeof(float) * 3 * dl->parts, "filldisp1"); + dlnew->nr = dl->parts; + dlnew->parts = 1; + dlnew->type = DL_POLY; + dlnew->col = dl->col; + dlnew->charidx = dl->charidx; + + fp = dl->verts + 3 * (dl->nr - 1); + dpoly = 3 * dl->nr; + + a = dl->parts; while (a--) { copy_v3_v3(fp1, fp); - fp1+= 3; - fp+= dpoly; + fp1 += 3; + fp += dpoly; } } } } - dl= dl->next; + dl = dl->next; } - filldisplist(&front, dispbase, 1); - filldisplist(&back, dispbase, 0); - - freedisplist(&front); - freedisplist(&back); + BKE_displist_fill(&front, dispbase, 1); + BKE_displist_fill(&back, dispbase, 0); - filldisplist(dispbase, dispbase, 0); - + BKE_displist_free(&front); + BKE_displist_free(&back); + + BKE_displist_fill(dispbase, dispbase, 0); } static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dispbase) { - if (cu->flag & CU_3D) return; + if (cu->flag & CU_3D) + return; - if (dispbase->first && ((DispList*) dispbase->first)->type==DL_SURF) { + if (dispbase->first && ((DispList *) dispbase->first)->type == DL_SURF) { bevels_to_filledpoly(cu, dispbase); } else { - filldisplist(dispbase, dispbase, 0); + BKE_displist_fill(dispbase, dispbase, 0); } } @@ -620,74 +630,77 @@ static void curve_to_filledpoly(Curve *cu, ListBase *UNUSED(nurb), ListBase *dis * - first point left, last point right * - based on subdivided points in original curve, not on points in taper curve (still) */ -float calc_taper(Scene *scene, Object *taperobj, int cur, int tot) +float BKE_displist_calc_taper(Scene *scene, Object *taperobj, int cur, int tot) { DispList *dl; - - if (taperobj==NULL || taperobj->type!=OB_CURVE) return 1.0; - - dl= taperobj->disp.first; - if (dl==NULL) { - makeDispListCurveTypes(scene, taperobj, 0); - dl= taperobj->disp.first; + + if (taperobj == NULL || taperobj->type != OB_CURVE) + return 1.0; + + dl = taperobj->disp.first; + if (dl == NULL) { + BKE_displist_make_curveTypes(scene, taperobj, 0); + dl = taperobj->disp.first; } if (dl) { - float fac= ((float)cur)/(float)(tot-1); + float fac = ((float)cur) / (float)(tot - 1); float minx, dx, *fp; int a; - + /* horizontal size */ - minx= dl->verts[0]; - dx= dl->verts[3*(dl->nr-1)] - minx; + minx = dl->verts[0]; + dx = dl->verts[3 * (dl->nr - 1)] - minx; if (dx > 0.0f) { - - fp= dl->verts; - for (a=0; anr; a++, fp+=3) { - if ( (fp[0]-minx)/dx >= fac) { + fp = dl->verts; + for (a = 0; a < dl->nr; a++, fp += 3) { + if ((fp[0] - minx) / dx >= fac) { /* interpolate with prev */ - if (a>0) { - float fac1= (fp[-3]-minx)/dx; - float fac2= (fp[0]-minx)/dx; - if (fac1!=fac2) - return fp[1]*(fac1-fac)/(fac1-fac2) + fp[-2]*(fac-fac2)/(fac1-fac2); + if (a > 0) { + float fac1 = (fp[-3] - minx) / dx; + float fac2 = (fp[0] - minx) / dx; + if (fac1 != fac2) + return fp[1] * (fac1 - fac) / (fac1 - fac2) + fp[-2] * (fac - fac2) / (fac1 - fac2); } return fp[1]; } } - return fp[-2]; // last y coord + return fp[-2]; // last y coord } } - + return 1.0; } -void makeDispListMBall(Scene *scene, Object *ob) +void BKE_displist_make_mball(Scene *scene, Object *ob) { - if (!ob || ob->type!=OB_MBALL) return; + if (!ob || ob->type != OB_MBALL) + return; - // XXX: mball stuff uses plenty of global variables - // while this is unchanged updating during render is unsafe - if (G.rendering) return; + /* XXX: mball stuff uses plenty of global variables + * while this is unchanged updating during render is unsafe + */ + if (G.rendering) + return; - freedisplist(&(ob->disp)); + BKE_displist_free(&(ob->disp)); - if (ob->type==OB_MBALL) { - if (ob==BKE_metaball_basis_find(scene, ob)) { - BKE_metaball_polygonize(scene, ob, &ob->disp); - BKE_metaball_tex_space_calc(ob); + if (ob->type == OB_MBALL) { + if (ob == BKE_mball_basis_find(scene, ob)) { + BKE_mball_polygonize(scene, ob, &ob->disp); + BKE_mball_texspace_calc(ob); object_deform_mball(ob, &ob->disp); } } - + boundbox_displist(ob); } -void makeDispListMBall_forRender(Scene *scene, Object *ob, ListBase *dispbase) +void BKE_displist_make_mball_forRender(Scene *scene, Object *ob, ListBase *dispbase) { - BKE_metaball_polygonize(scene, ob, dispbase); - BKE_metaball_tex_space_calc(ob); - + BKE_mball_polygonize(scene, ob, dispbase); + BKE_mball_texspace_calc(ob); + object_deform_mball(ob, dispbase); } @@ -697,27 +710,33 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo ModifierData *pretessellatePoint; int required_mode; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) + required_mode = eModifierMode_Render; + else + required_mode = eModifierMode_Realtime; - if (editmode) required_mode |= eModifierMode_Editmode; + if (editmode) + required_mode |= eModifierMode_Editmode; pretessellatePoint = NULL; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if (!modifier_isEnabled(scene, md, required_mode)) continue; - if (mti->type == eModifierTypeType_Constructive) return pretessellatePoint; + if (!modifier_isEnabled(scene, md, required_mode)) + continue; + if (mti->type == eModifierTypeType_Constructive) + return pretessellatePoint; if (ELEM3(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_MeshDeform)) { pretessellatePoint = md; /* this modifiers are moving point of tessellation automatically * (some of them even can't be applied on tessellated curve), set flag - * for incformation button in modifier's header */ + * for incformation button in modifier's header + */ md->mode |= eModifierMode_ApplyOnSpline; } - else if (md->mode&eModifierMode_ApplyOnSpline) { + else if (md->mode & eModifierMode_ApplyOnSpline) { pretessellatePoint = md; } } @@ -725,58 +744,70 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo return pretessellatePoint; } -static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, float (**originalVerts_r)[3], float (**deformedVerts_r)[3], int *numVerts_r) +static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, float (**originalVerts_r)[3], + float (**deformedVerts_r)[3], int *numVerts_r) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs_get(cu); + Curve *cu = ob->data; + ListBase *nurb = BKE_curve_nurbs_get(cu); int numVerts = 0; - int editmode = (!forRender && cu->editnurb); + const int editmode = (!forRender && cu->editnurb); + ModifierApplyFlag app_flag = 0; float (*originalVerts)[3] = NULL; float (*deformedVerts)[3] = NULL; - float *keyVerts= NULL; + float *keyVerts = NULL; int required_mode; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (editmode) + app_flag |= MOD_APPLY_USECACHE; + if (forRender) { + app_flag |= MOD_APPLY_RENDER; + required_mode = eModifierMode_Render; + } + else + required_mode = eModifierMode_Realtime; pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); - - if (editmode) required_mode |= eModifierMode_Editmode; - if (cu->editnurb==NULL) { - keyVerts= do_ob_key(scene, ob); + if (editmode) + required_mode |= eModifierMode_Editmode; + + if (cu->editnurb == NULL) { + keyVerts = do_ob_key(scene, ob); if (keyVerts) { /* split coords from key data, the latter also includes * tilts, which is passed through in the modifier stack. * this is also the reason curves do not use a virtual * shape key modifier yet. */ - deformedVerts= BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); - originalVerts= MEM_dupallocN(deformedVerts); - numVerts = BKE_nurbList_verts_count_without_handles(nurb); + deformedVerts = BKE_curve_keyVertexCos_get(cu, nurb, keyVerts); + originalVerts = MEM_dupallocN(deformedVerts); + numVerts = BKE_nurbList_verts_count(nurb); } } - + if (pretessellatePoint) { - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; - - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform) continue; + md->scene = scene; + + if ((md->mode & required_mode) != required_mode) + continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) + continue; + if (mti->type != eModifierTypeType_OnlyDeform) + continue; if (!deformedVerts) { deformedVerts = BKE_curve_vertexCos_get(cu, nurb, &numVerts); originalVerts = MEM_dupallocN(deformedVerts); } - mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, forRender, editmode); + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, app_flag); - if (md==pretessellatePoint) + if (md == pretessellatePoint) break; } } @@ -794,22 +825,22 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl *numVerts_r = numVerts; } -static float (*displist_get_allverts (ListBase *dispbase, int *totvert))[3] +static float (*displist_get_allverts(ListBase * dispbase, int *totvert))[3] { DispList *dl; float (*allverts)[3], *fp; - *totvert= 0; + *totvert = 0; - for (dl=dispbase->first; dl; dl=dl->next) - *totvert+= (dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr; + for (dl = dispbase->first; dl; dl = dl->next) + *totvert += (dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr; - allverts= MEM_mallocN((*totvert)*sizeof(float)*3, "displist_get_allverts allverts"); - fp= (float*)allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + allverts = MEM_mallocN((*totvert) * sizeof(float) * 3, "displist_get_allverts allverts"); + fp = (float *)allverts; + for (dl = dispbase->first; dl; dl = dl->next) { + int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); memcpy(fp, dl->verts, sizeof(float) * offs); - fp+= offs; + fp += offs; } return allverts; @@ -820,52 +851,63 @@ static void displist_apply_allverts(ListBase *dispbase, float (*allverts)[3]) DispList *dl; float *fp; - fp= (float*)allverts; - for (dl=dispbase->first; dl; dl=dl->next) { - int offs= 3 * ((dl->type==DL_INDEX3)?dl->nr:dl->parts*dl->nr); + fp = (float *)allverts; + for (dl = dispbase->first; dl; dl = dl->next) { + int offs = 3 * ((dl->type == DL_INDEX3) ? dl->nr : dl->parts * dl->nr); memcpy(dl->verts, fp, sizeof(float) * offs); - fp+= offs; + fp += offs; } } -static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) +static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispbase, DerivedMesh **derivedFinal, + int forRender, float (*originalVerts)[3], float (*deformedVerts)[3]) { ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; - ListBase *nurb= BKE_curve_nurbs_get(cu); + Curve *cu = ob->data; + ListBase *nurb = BKE_curve_nurbs_get(cu); int required_mode = 0, totvert = 0; int editmode = (!forRender && cu->editnurb); - DerivedMesh *dm= NULL, *ndm; + DerivedMesh *dm = NULL, *ndm; float (*vertCos)[3] = NULL; int useCache = !forRender; + ModifierApplyFlag app_flag = 0; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) { + app_flag |= MOD_APPLY_RENDER; + required_mode = eModifierMode_Render; + } + else + required_mode = eModifierMode_Realtime; pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); - - if (editmode) required_mode |= eModifierMode_Editmode; + + if (editmode) + required_mode |= eModifierMode_Editmode; if (pretessellatePoint) { md = pretessellatePoint->next; } if (derivedFinal && *derivedFinal) { - (*derivedFinal)->release (*derivedFinal); + (*derivedFinal)->release(*derivedFinal); } - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + ModifierApplyFlag appf = app_flag; - md->scene= scene; + md->scene = scene; - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; + if ((md->mode & required_mode) != required_mode) + continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) + continue; if (mti->type == eModifierTypeType_OnlyDeform || - (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { + (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { + if (editmode) + appf |= MOD_APPLY_USECACHE; if (dm) { if (!vertCos) { totvert = dm->getNumVerts(dm); @@ -873,21 +915,22 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba dm->getVertCos(dm, vertCos); } - mti->deformVerts(md, ob, dm, vertCos, totvert, forRender, editmode); + mti->deformVerts(md, ob, dm, vertCos, totvert, appf); } else { if (!vertCos) { - vertCos= displist_get_allverts(dispbase, &totvert); + vertCos = displist_get_allverts(dispbase, &totvert); } - mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode); + mti->deformVerts(md, ob, NULL, vertCos, totvert, appf); } } else { if (!derivedFinal) { - /* makeDisplistCurveTypes could be used for beveling, where derived mesh */ - /* is totally unnecessary, so we could stop modifiers applying */ - /* when we found constructive modifier but derived mesh is unwanted result */ + /* makeDisplistCurveTypes could be used for beveling, where derived mesh + * is totally unnecessary, so we could stop modifiers applying + * when we found constructive modifier but derived mesh is unwanted result + */ break; } @@ -910,7 +953,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba curve_to_filledpoly(cu, nurb, dispbase); } - dm= CDDM_from_curve_customDB(ob, dispbase); + dm = CDDM_from_curve_customDB(ob, dispbase); CDDM_calc_normals_mapping(dm); } @@ -918,16 +961,18 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if (vertCos) { /* Vertex coordinates were applied to necessary data, could free it */ MEM_freeN(vertCos); - vertCos= NULL; + vertCos = NULL; } - ndm = mti->applyModifier(md, ob, dm, forRender, useCache); + if (useCache) + appf |= MOD_APPLY_USECACHE; + ndm = mti->applyModifier(md, ob, dm, appf); if (ndm) { /* Modifier returned a new derived mesh */ if (dm && dm != ndm) /* Modifier */ - dm->release (dm); + dm->release(dm); dm = ndm; } } @@ -946,12 +991,13 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba else { displist_apply_allverts(dispbase, vertCos); MEM_freeN(vertCos); - vertCos= NULL; + vertCos = NULL; } } if (derivedFinal) { - if (dm) DM_ensure_tessface(dm); /* needed for drawing */ + if (dm) + DM_ensure_tessface(dm); /* needed for drawing */ (*derivedFinal) = dm; } @@ -966,42 +1012,40 @@ static void displist_surf_indices(DispList *dl) { int a, b, p1, p2, p3, p4; int *index; - - dl->totindex= 0; - - index=dl->index= MEM_mallocN(4*sizeof(int)*(dl->parts+1)*(dl->nr+1), "index array nurbs"); - - for (a=0; aparts; a++) { - - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) - break; - - for (; bnr; b++, index+=4) { - index[0]= p1; - index[1]= p2; - index[2]= p4; - index[3]= p3; - - dl->totindex++; - - p2= p1; p1++; - p4= p3; p3++; + dl->totindex = 0; + + index = dl->index = MEM_mallocN(4 * sizeof(int) * (dl->parts + 1) * (dl->nr + 1), "index array nurbs"); + + for (a = 0; a < dl->parts; a++) { + + if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4) == 0) + break; + + for (; b < dl->nr; b++, index += 4) { + index[0] = p1; + index[1] = p2; + index[2] = p4; + index[3] = p3; + + dl->totindex++; + + p2 = p1; p1++; + p4 = p3; p3++; } } - } static DerivedMesh *create_orco_dm(Scene *scene, Object *ob) { DerivedMesh *dm; - ListBase disp= {NULL, NULL}; + ListBase disp = {NULL, NULL}; /* OrcoDM should be created from underformed disp lists */ - makeDispListCurveTypes_forOrco(scene, ob, &disp); - dm= CDDM_from_curve_customDB(ob, &disp); + BKE_displist_make_curveTypes_forOrco(scene, ob, &disp); + dm = CDDM_from_curve_customDB(ob, &disp); - freedisplist(&disp); + BKE_displist_free(&disp); return dm; } @@ -1010,12 +1054,12 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * { float (*orco)[3], (*layerorco)[3]; int totvert, a; - Curve *cu= ob->data; + Curve *cu = ob->data; - totvert= dm->getNumVerts(dm); + totvert = dm->getNumVerts(dm); if (orcodm) { - orco= MEM_callocN(sizeof(float)*3*totvert, "dm orco"); + orco = MEM_callocN(sizeof(float) * 3 * totvert, "dm orco"); if (orcodm->getNumVerts(orcodm) == totvert) orcodm->getVertCos(orcodm, orco); @@ -1023,18 +1067,18 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * dm->getVertCos(dm, orco); } else { - orco= (float(*)[3])BKE_curve_make_orco(scene, ob); + orco = (float(*)[3])BKE_curve_make_orco(scene, ob); } - for (a=0; aloc[0])/cu->size[0]; - co[1] = (co[1]-cu->loc[1])/cu->size[1]; - co[2] = (co[2]-cu->loc[2])/cu->size[2]; + co[0] = (co[0] - cu->loc[0]) / cu->size[0]; + co[1] = (co[1] - cu->loc[1]) / cu->size[1]; + co[2] = (co[2] - cu->loc[2]) / cu->size[2]; } if ((layerorco = DM_get_vert_data_layer(dm, CD_ORCO))) { - memcpy(layerorco, orco, sizeof(float)*totvert); + memcpy(layerorco, orco, sizeof(float) * totvert); MEM_freeN(orco); } else @@ -1043,40 +1087,48 @@ static void add_orco_dm(Scene *scene, Object *ob, DerivedMesh *dm, DerivedMesh * static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) { - /* this function represents logic of mesh's orcodm calculation */ - /* for displist-based objects */ + /* this function represents logic of mesh's orcodm calculation + * for displist-based objects + */ ModifierData *md = modifiers_getVirtualModifierList(ob); ModifierData *pretessellatePoint; - Curve *cu= ob->data; + Curve *cu = ob->data; int required_mode; int editmode = (!forRender && cu->editnurb); - DerivedMesh *ndm, *orcodm= NULL; + DerivedMesh *ndm, *orcodm = NULL; + const ModifierApplyFlag app_flag = forRender ? MOD_APPLY_RENDER : 0; - if (forRender) required_mode = eModifierMode_Render; - else required_mode = eModifierMode_Realtime; + if (forRender) + required_mode = eModifierMode_Render; + else + required_mode = eModifierMode_Realtime; pretessellatePoint = curve_get_tessellate_point(scene, ob, forRender, editmode); - if (editmode) required_mode |= eModifierMode_Editmode; + if (editmode) + required_mode |= eModifierMode_Editmode; if (pretessellatePoint) { md = pretessellatePoint->next; } - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; - if ((md->mode & required_mode) != required_mode) continue; - if (mti->isDisabled && mti->isDisabled(md, forRender)) continue; - if (mti->type!=eModifierTypeType_Constructive) continue; + if ((md->mode & required_mode) != required_mode) + continue; + if (mti->isDisabled && mti->isDisabled(md, forRender)) + continue; + if (mti->type != eModifierTypeType_Constructive) + continue; if (!orcodm) - orcodm= create_orco_dm(scene, ob); + orcodm = create_orco_dm(scene, ob); - ndm = mti->applyModifier(md, ob, orcodm, forRender, 0); + ndm = mti->applyModifier(md, ob, orcodm, app_flag); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1094,8 +1146,8 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina orcodm->release(orcodm); } -void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) +void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forRender, int forOrco) { ListBase *nubase; Nurb *nu; @@ -1108,68 +1160,70 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, float (*deformedVerts)[3]; if (!forRender && cu->editnurb) - nubase= BKE_curve_editNurbs_get(cu); + nubase = BKE_curve_editNurbs_get(cu); else - nubase= &cu->nurb; + nubase = &cu->nurb; if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); - for (nu=nubase->first; nu; nu=nu->next) { - if (forRender || nu->hide==0) { - int resolu= nu->resolu, resolv= nu->resolv; + for (nu = nubase->first; nu; nu = nu->next) { + if (forRender || nu->hide == 0) { + int resolu = nu->resolu, resolv = nu->resolv; if (forRender) { - if (cu->resolu_ren) resolu= cu->resolu_ren; - if (cu->resolv_ren) resolv= cu->resolv_ren; + if (cu->resolu_ren) + resolu = cu->resolu_ren; + if (cu->resolv_ren) + resolv = cu->resolv_ren; } - if (nu->pntsv==1) { - len= SEGMENTSU(nu)*resolu; + if (nu->pntsv == 1) { + len = SEGMENTSU(nu) * resolu; - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->parts= 1; - dl->nr= len; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = len; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - data= dl->verts; - if (nu->flagu & CU_NURB_CYCLIC) dl->type= DL_POLY; - else dl->type= DL_SEGM; + data = dl->verts; + if (nu->flagu & CU_NURB_CYCLIC) dl->type = DL_POLY; + else dl->type = DL_SEGM; - BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3*sizeof(float)); + BKE_nurb_makeCurve(nu, data, NULL, NULL, NULL, resolu, 3 * sizeof(float)); } else { - len= (nu->pntsu*resolu) * (nu->pntsv*resolv); - - dl= MEM_callocN(sizeof(DispList), "makeDispListsurf"); - dl->verts= MEM_callocN(len*3*sizeof(float), "dlverts"); + len = (nu->pntsu * resolu) * (nu->pntsv * resolv); + + dl = MEM_callocN(sizeof(DispList), "makeDispListsurf"); + dl->verts = MEM_callocN(len * 3 * sizeof(float), "dlverts"); BLI_addtail(dispbase, dl); - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - data= dl->verts; - dl->type= DL_SURF; + data = dl->verts; + dl->type = DL_SURF; - dl->parts= (nu->pntsu*resolu); /* in reverse, because makeNurbfaces works that way */ - dl->nr= (nu->pntsv*resolv); - if (nu->flagv & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_U; /* reverse too! */ - if (nu->flagu & CU_NURB_CYCLIC) dl->flag|= DL_CYCL_V; + dl->parts = (nu->pntsu * resolu); /* in reverse, because makeNurbfaces works that way */ + dl->nr = (nu->pntsv * resolv); + if (nu->flagv & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_U; /* reverse too! */ + if (nu->flagu & CU_NURB_CYCLIC) dl->flag |= DL_CYCL_V; BKE_nurb_makeFaces(nu, data, 0, resolu, resolv); - + /* gl array drawing: using indices */ displist_surf_indices(dl); } @@ -1179,15 +1233,16 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase, /* make copy of 'undeformed" displist for texture space calculation * actually, it's not totally undeformed -- pre-tessellation modifiers are * already applied, thats how it worked for years, so keep for compatibility (sergey) */ - copy_displist(&cu->disp, dispbase); + BKE_displist_copy(&cu->disp, dispbase); if (!forRender) { - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); } - if (!forOrco) + if (!forOrco) { curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, - forRender, originalVerts, deformedVerts); + forRender, originalVerts, deformedVerts); + } } static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r) @@ -1196,24 +1251,24 @@ static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float wid int b; fp = dlb->verts; - for (b = 0; bnr; b++, fp += 3, data += 3) { + for (b = 0; b < dlb->nr; b++, fp += 3, data += 3) { if (cu->flag & CU_3D) { float vec[3]; - vec[0] = fp[1]+widfac; + vec[0] = fp[1] + widfac; vec[1] = fp[2]; - vec[2 ]= 0.0; + vec[2] = 0.0; mul_qt_v3(bevp->quat, vec); - data[0] = bevp->vec[0] + fac*vec[0]; - data[1] = bevp->vec[1] + fac*vec[1]; - data[2] = bevp->vec[2] + fac*vec[2]; + data[0] = bevp->vec[0] + fac * vec[0]; + data[1] = bevp->vec[1] + fac * vec[1]; + data[2] = bevp->vec[2] + fac * vec[2]; } else { - data[0] = bevp->vec[0] + fac*(widfac+fp[1])*bevp->sina; - data[1] = bevp->vec[1] + fac*(widfac+fp[1])*bevp->cosa; - data[2] = bevp->vec[2] + fac*fp[2]; + data[0] = bevp->vec[0] + fac * (widfac + fp[1]) * bevp->sina; + data[1] = bevp->vec[1] + fac * (widfac + fp[1]) * bevp->cosa; + data[2] = bevp->vec[2] + fac * fp[2]; } } @@ -1226,19 +1281,19 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp float *data; int b; - dl= MEM_callocN(sizeof(DispList), "makeDispListbev2"); - dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbev2"); + dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr, "dlverts"); - dl->type= DL_POLY; + dl->type = DL_POLY; - dl->parts= 1; - dl->nr= dlb->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = dlb->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; for (b = 0; b < dlb->nr; b++, prev_fp += 3, data += 3) copy_v3_v3(data, prev_fp); @@ -1247,15 +1302,15 @@ static void fillBevelCap(Nurb *nu, DispList *dlb, float *prev_fp, ListBase *disp } static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forRender, int forOrco) + DerivedMesh **derivedFinal, int forRender, int forOrco) { Curve *cu = ob->data; /* we do allow duplis... this is only displist on curve level */ if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; - if (ob->type==OB_SURF) { - makeDispListSurf(scene, ob, dispbase, derivedFinal, forRender, forOrco); + if (ob->type == OB_SURF) { + BKE_displist_make_surf(scene, ob, dispbase, derivedFinal, forRender, forOrco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { ListBase dlbev; @@ -1264,16 +1319,18 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba float (*deformedVerts)[3]; int numVerts; - nubase= BKE_curve_nurbs_get(cu); + nubase = BKE_curve_nurbs_get(cu); BLI_freelistN(&(cu->bev)); if (cu->path) free_path(cu->path); - cu->path= NULL; + cu->path = NULL; - if (ob->type==OB_FONT) BKE_text_to_curve(G.main, scene, ob, 0); + if (ob->type == OB_FONT) + BKE_vfont_to_curve(G.main, scene, ob, 0); - if (!forOrco) curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); + if (!forOrco) + curve_calc_modifiers_pre(scene, ob, forRender, &originalVerts, &deformedVerts, &numVerts); BKE_curve_bevelList_make(ob); @@ -1281,15 +1338,15 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba BKE_curve_bevel_make(scene, ob, &dlbev, forRender); /* no bevel or extrude, and no width correction? */ - if (!dlbev.first && cu->width==1.0f) { + if (!dlbev.first && cu->width == 1.0f) { curve_to_displist(cu, nubase, dispbase, forRender); } else { - float widfac= cu->width - 1.0f; - BevList *bl= cu->bev.first; - Nurb *nu= nubase->first; + float widfac = cu->width - 1.0f; + BevList *bl = cu->bev.first; + Nurb *nu = nubase->first; - for (; bl && nu; bl=bl->next, nu=nu->next) { + for (; bl && nu; bl = bl->next, nu = nu->next) { DispList *dl; float *data; BevPoint *bevp; @@ -1298,34 +1355,34 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (bl->nr) { /* blank bevel lists can happen */ /* exception handling; curve without bevel or extrude, with width correction */ - if (dlbev.first==NULL) { - dl= MEM_callocN(sizeof(DispList), "makeDispListbev"); - dl->verts= MEM_callocN(3*sizeof(float)*bl->nr, "dlverts"); + if (dlbev.first == NULL) { + dl = MEM_callocN(sizeof(DispList), "makeDispListbev"); + dl->verts = MEM_callocN(3 * sizeof(float) * bl->nr, "dlverts"); BLI_addtail(dispbase, dl); - if (bl->poly!= -1) dl->type= DL_POLY; - else dl->type= DL_SEGM; + if (bl->poly != -1) dl->type = DL_POLY; + else dl->type = DL_SEGM; - if (dl->type==DL_SEGM) dl->flag = (DL_FRONT_CURVE|DL_BACK_CURVE); + if (dl->type == DL_SEGM) dl->flag = (DL_FRONT_CURVE | DL_BACK_CURVE); - dl->parts= 1; - dl->nr= bl->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->parts = 1; + dl->nr = bl->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; - a= dl->nr; - bevp= (BevPoint *)(bl+1); - data= dl->verts; + a = dl->nr; + bevp = (BevPoint *)(bl + 1); + data = dl->verts; while (a--) { - data[0]= bevp->vec[0]+widfac*bevp->sina; - data[1]= bevp->vec[1]+widfac*bevp->cosa; - data[2]= bevp->vec[2]; + data[0] = bevp->vec[0] + widfac * bevp->sina; + data[1] = bevp->vec[1] + widfac * bevp->cosa; + data[2] = bevp->vec[2]; bevp++; - data+=3; + data += 3; } } else { @@ -1333,7 +1390,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba ListBase bottom_capbase = {NULL, NULL}; ListBase top_capbase = {NULL, NULL}; - for (dlb=dlbev.first; dlb; dlb=dlb->next) { + for (dlb = dlbev.first; dlb; dlb = dlb->next) { int i, start, steps; float bevfac1 = MIN2(cu->bevfac1, cu->bevfac2), bevfac2 = MAX2(cu->bevfac1, cu->bevfac2); float firstblend = 0.0f, lastblend = 0.0f; @@ -1341,10 +1398,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba if (cu->bevfac1 - cu->bevfac2 == 0.0f) continue; - start = (int)(bevfac1*(bl->nr-1)); - steps = 2+(int)((bevfac2)*(bl->nr-1)) - start; - firstblend = 1.0f - ((float)bevfac1*(bl->nr-1) - (int)((float)bevfac1*(bl->nr-1))); - lastblend = (float)bevfac2*(bl->nr-1) - (int)((float)bevfac2*(bl->nr-1)); + start = (int)(bevfac1 * (bl->nr - 1)); + steps = 2 + (int)((bevfac2) * (bl->nr - 1)) - start; + firstblend = 1.0f - ((float)bevfac1 * (bl->nr - 1) - (int)((float)bevfac1 * (bl->nr - 1))); + lastblend = (float)bevfac2 * (bl->nr - 1) - (int)((float)bevfac2 * (bl->nr - 1)); if (steps > bl->nr) { steps = bl->nr; @@ -1352,50 +1409,51 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } /* for each part of the bevel use a separate displblock */ - dl= MEM_callocN(sizeof(DispList), "makeDispListbev1"); - dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*steps, "dlverts"); + dl = MEM_callocN(sizeof(DispList), "makeDispListbev1"); + dl->verts = data = MEM_callocN(3 * sizeof(float) * dlb->nr * steps, "dlverts"); BLI_addtail(dispbase, dl); - - dl->type= DL_SURF; - - dl->flag= dlb->flag & (DL_FRONT_CURVE|DL_BACK_CURVE); - if (dlb->type==DL_POLY) dl->flag |= DL_CYCL_U; - if (bl->poly>=0) dl->flag |= DL_CYCL_V; - dl->parts= steps; - dl->nr= dlb->nr; - dl->col= nu->mat_nr; - dl->charidx= nu->charidx; + dl->type = DL_SURF; + + dl->flag = dlb->flag & (DL_FRONT_CURVE | DL_BACK_CURVE); + if (dlb->type == DL_POLY) dl->flag |= DL_CYCL_U; + if (bl->poly >= 0) dl->flag |= DL_CYCL_V; + + dl->parts = steps; + dl->nr = dlb->nr; + dl->col = nu->mat_nr; + dl->charidx = nu->charidx; /* dl->rt will be used as flag for render face and */ /* CU_2D conflicts with R_NOPUNOFLIP */ - dl->rt= nu->flag & ~CU_2D; + dl->rt = nu->flag & ~CU_2D; + + dl->bevelSplitFlag = MEM_callocN(sizeof(*dl->col2) * ((steps + 0x1F) >> 5), + "bevelSplitFlag"); - dl->bevelSplitFlag= MEM_callocN(sizeof(*dl->col2)*((steps+0x1F)>>5), "bevelSplitFlag"); - /* for each point of poly make a bevel piece */ - bevp= (BevPoint *)(bl+1) + start; - for (i=start, a=0; ataperobj==NULL) { - if ( (cu->bevobj!=NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) + if (cu->taperobj == NULL) { + if ( (cu->bevobj != NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) ) fac = bevp->radius; } else { - fac = calc_taper(scene, cu->taperobj, i, bl->nr); + fac = BKE_displist_calc_taper(scene, cu->taperobj, i, bl->nr); } if (bevp->split_tag) { - dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F); + dl->bevelSplitFlag[a >> 5] |= 1 << (a & 0x1F); } - + /* rotate bevel piece and write in data */ rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data); if (a == 1 || a == steps - 1) { - float *cur_fp = cur_data, *prev_fp = cur_data - 3*dlb->nr; + float *cur_fp = cur_data, *prev_fp = cur_data - 3 * dlb->nr; int b; for (b = 0; b < dlb->nr; b++, prev_fp += 3, cur_fp += 3) { @@ -1415,8 +1473,8 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (cu->bevobj && (cu->flag & CU_FILL_CAPS)) { - if (a == 1) - fillBevelCap(nu, dlb, cur_data - 3*dlb->nr, &bottom_capbase); + if (a == 1) + fillBevelCap(nu, dlb, cur_data - 3 * dlb->nr, &bottom_capbase); if (a == steps - 1) fillBevelCap(nu, dlb, cur_data, &top_capbase); } @@ -1427,34 +1485,36 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } if (bottom_capbase.first) { - filldisplist(&bottom_capbase, dispbase, 1); - filldisplist(&top_capbase, dispbase, 0); - freedisplist(&bottom_capbase); - freedisplist(&top_capbase); + BKE_displist_fill(&bottom_capbase, dispbase, 1); + BKE_displist_fill(&top_capbase, dispbase, 0); + BKE_displist_free(&bottom_capbase); + BKE_displist_free(&top_capbase); } } } } - freedisplist(&dlbev); + BKE_displist_free(&dlbev); } if (!(cu->flag & CU_DEFORM_FILL)) { curve_to_filledpoly(cu, nubase, dispbase); } - if ((cu->flag & CU_PATH) && !forOrco) calc_curvepath(ob); + if ((cu->flag & CU_PATH) && !forOrco) + calc_curvepath(ob); /* make copy of 'undeformed" displist for texture space calculation * actually, it's not totally undeformed -- pre-tessellation modifiers are * already applied, thats how it worked for years, so keep for compatibility (sergey) */ - copy_displist(&cu->disp, dispbase); + BKE_displist_copy(&cu->disp, dispbase); if (!forRender) { - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); } - if (!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); + if (!forOrco) + curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) { curve_to_filledpoly(cu, nubase, dispbase); @@ -1462,66 +1522,67 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba } } -void makeDispListCurveTypes(Scene *scene, Object *ob, int forOrco) +void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco) { - Curve *cu= ob->data; + Curve *cu = ob->data; ListBase *dispbase; /* The same check for duplis as in do_makeDispListCurveTypes. * Happens when curve used for constraint/bevel was converted to mesh. * check there is still needed for render displist and orco displists. */ - if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) return; + if (!ELEM3(ob->type, OB_SURF, OB_CURVE, OB_FONT)) + return; - freedisplist(&(ob->disp)); - dispbase= &(ob->disp); - freedisplist(dispbase); + BKE_displist_free(&(ob->disp)); + dispbase = &(ob->disp); + BKE_displist_free(dispbase); /* free displist used for textspace */ - freedisplist(&cu->disp); + BKE_displist_free(&cu->disp); do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco); if (ob->derivedFinal) { - DM_set_object_boundbox (ob, ob->derivedFinal); + DM_set_object_boundbox(ob, ob->derivedFinal); } else { - boundbox_displist (ob); + boundbox_displist(ob); /* if there is no derivedMesh, object's boundbox is unneeded */ if (ob->bb) { MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; } } } -void makeDispListCurveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, - DerivedMesh **derivedFinal, int forOrco) +void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase, + DerivedMesh **derivedFinal, int forOrco) { do_makeDispListCurveTypes(scene, ob, dispbase, derivedFinal, 1, forOrco); } -void makeDispListCurveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) +void BKE_displist_make_curveTypes_forOrco(struct Scene *scene, struct Object *ob, struct ListBase *dispbase) { do_makeDispListCurveTypes(scene, ob, dispbase, NULL, 1, 1); } /* add Orco layer to the displist object which has got derived mesh and return orco */ -float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) +float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int forRender) { float *orco; if (derivedFinal == NULL) - derivedFinal= ob->derivedFinal; + derivedFinal = ob->derivedFinal; if (!derivedFinal->getVertDataArray(derivedFinal, CD_ORCO)) { curve_calc_orcodm(scene, ob, derivedFinal, forRender); } - orco= derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); + orco = derivedFinal->getVertDataArray(derivedFinal, CD_ORCO); if (orco) { - orco= MEM_dupallocN(orco); + orco = MEM_dupallocN(orco); } return orco; @@ -1530,46 +1591,45 @@ float *makeOrcoDispList(Scene *scene, Object *ob, DerivedMesh *derivedFinal, int /* this is confusing, there's also min_max_object, appplying the obmat... */ static void boundbox_displist(Object *ob) { - BoundBox *bb=NULL; + BoundBox *bb = NULL; float min[3], max[3]; DispList *dl; float *vert; - int a, tot=0; - + int a, tot = 0; + INIT_MINMAX(min, max); if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - Curve *cu= ob->data; - int doit= 0; + Curve *cu = ob->data; + int doit = 0; - if (cu->bb==NULL) cu->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= cu->bb; - - dl= ob->disp.first; + if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = cu->bb; + + dl = ob->disp.first; while (dl) { - if (dl->type==DL_INDEX3) tot= dl->nr; - else tot= dl->nr*dl->parts; - - vert= dl->verts; - for (a=0; atype == DL_INDEX3) tot = dl->nr; + else tot = dl->nr * dl->parts; + + vert = dl->verts; + for (a = 0; a < tot; a++, vert += 3) { + doit = 1; DO_MINMAX(vert, min, max); } - dl= dl->next; + dl = dl->next; } - + if (!doit) { /* there's no geometry in displist, use zero-sized boundbox */ zero_v3(min); zero_v3(max); } - + } - + if (bb) { - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } } - diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6c5826c5bab..2bde31cfd63 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -540,11 +540,11 @@ static int subframe_updateObject(Scene *scene, Object *ob, int flags, float fram /* ignore cache clear during subframe updates * to not mess up cache validity */ object_cacheIgnoreClear(ob, 1); - object_handle_update(scene, ob); + BKE_object_handle_update(scene, ob); object_cacheIgnoreClear(ob, 0); } else - where_is_object_time(scene, ob, frame); + BKE_object_where_is_calc_time(scene, ob, frame); return 0; } @@ -3066,7 +3066,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); dm_p = CDDM_copy(brush->dm); numOfVerts_p = dm_p->getNumVerts(dm_p); mvert_p = dm_p->getVertArray(dm_p); @@ -3076,7 +3076,7 @@ static void dynamicPaint_brushMeshCalculateVelocity(Scene *scene, Object *ob, Dy scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); dm_c = brush->dm; numOfVerts_c = dm_c->getNumVerts(dm_c); mvert_c = dm_p->getVertArray(dm_c); @@ -3126,13 +3126,13 @@ static void dynamicPaint_brushObjectCalculateVelocity(Scene *scene, Object *ob, /* previous frame dm */ scene->r.cfra = prev_fra; scene->r.subframe = prev_sfra; - subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_scene_frame_get(scene)); copy_m4_m4(prev_obmat, ob->obmat); /* current frame dm */ scene->r.cfra = cur_fra; scene->r.subframe = cur_sfra; - subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_curframe(scene)); + subframe_updateObject(scene, ob, UPDATE_PARENTS, BKE_scene_frame_get(scene)); /* calculate speed */ mul_m4_v3(prev_obmat, prev_loc); @@ -4841,7 +4841,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su /* update object data on this subframe */ if (subframe) { scene_setSubframe(scene, subframe); - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); } /* Prepare materials if required */ if (brush_usesMaterial(brush, scene)) @@ -4854,7 +4854,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su psys_check_enabled(brushObj, brush->psys)) { /* Paint a particle system */ - BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt, BKE_curframe(scene), ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &brush->psys->part->id, brush->psys->part->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); dynamicPaint_paintParticles(surface, brush->psys, brush, timescale); } } @@ -4874,7 +4874,7 @@ static int dynamicPaint_doStep(Scene *scene, Object *ob, DynamicPaintSurface *su if (subframe) { scene->r.cfra = scene_frame; scene->r.subframe = scene_subframe; - subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_curframe(scene)); + subframe_updateObject(scene, brushObj, UPDATE_EVERYTHING, BKE_scene_frame_get(scene)); } /* process special brush effects, like smudge */ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 7fb0cf9f0fa..1d109d5f616 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -181,7 +181,7 @@ static void precalculate_effector(EffectorCache *eff) Curve *cu= eff->ob->data; if (cu->flag & CU_PATH) { if (cu->path==NULL || cu->path->data==NULL) - makeDispListCurveTypes(eff->scene, eff->ob, 0); + BKE_displist_make_curveTypes(eff->scene, eff->ob, 0); if (cu->path && cu->path->data) { where_on_path(eff->ob, 0.0, eff->guide_loc, eff->guide_dir, NULL, &eff->guide_radius, NULL); @@ -202,9 +202,9 @@ static void precalculate_effector(EffectorCache *eff) if (eff->ob) { float old_vel[3]; - where_is_object_time(eff->scene, eff->ob, cfra - 1.0f); + BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra - 1.0f); copy_v3_v3(old_vel, eff->ob->obmat[3]); - where_is_object_time(eff->scene, eff->ob, cfra); + BKE_object_where_is_calc_time(eff->scene, eff->ob, cfra); sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel); } } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 0414d69785f..9d878cd185f 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -107,19 +107,19 @@ void free_fcurves(ListBase *list) * as we store reference to next, and freeing only touches the curve * it's given */ - for (fcu= list->first; fcu; fcu= fcn) { - fcn= fcu->next; + for (fcu = list->first; fcu; fcu = fcn) { + fcn = fcu->next; free_fcurve(fcu); } /* clear pointers just in case */ - list->first= list->last= NULL; + list->first = list->last = NULL; } /* ---------------------- Copy --------------------------- */ /* duplicate an F-Curve */ -FCurve *copy_fcurve (FCurve *fcu) +FCurve *copy_fcurve(FCurve *fcu) { FCurve *fcu_d; @@ -128,20 +128,20 @@ FCurve *copy_fcurve (FCurve *fcu) return NULL; /* make a copy */ - fcu_d= MEM_dupallocN(fcu); + fcu_d = MEM_dupallocN(fcu); - fcu_d->next= fcu_d->prev= NULL; - fcu_d->grp= NULL; + fcu_d->next = fcu_d->prev = NULL; + fcu_d->grp = NULL; /* copy curve data */ - fcu_d->bezt= MEM_dupallocN(fcu_d->bezt); - fcu_d->fpt= MEM_dupallocN(fcu_d->fpt); + fcu_d->bezt = MEM_dupallocN(fcu_d->bezt); + fcu_d->fpt = MEM_dupallocN(fcu_d->fpt); /* copy rna-path */ - fcu_d->rna_path= MEM_dupallocN(fcu_d->rna_path); + fcu_d->rna_path = MEM_dupallocN(fcu_d->rna_path); /* copy driver */ - fcu_d->driver= fcurve_copy_driver(fcu_d->driver); + fcu_d->driver = fcurve_copy_driver(fcu_d->driver); /* copy modifiers */ copy_fmodifiers(&fcu_d->modifiers, &fcu->modifiers); @@ -160,11 +160,11 @@ void copy_fcurves(ListBase *dst, ListBase *src) return; /* clear destination list first */ - dst->first= dst->last= NULL; + dst->first = dst->last = NULL; /* copy one-by-one */ - for (sfcu= src->first; sfcu; sfcu= sfcu->next) { - dfcu= copy_fcurve(sfcu); + for (sfcu = src->first; sfcu; sfcu = sfcu->next) { + dfcu = copy_fcurve(sfcu); BLI_addtail(dst, dfcu); } } @@ -175,8 +175,8 @@ void copy_fcurves(ListBase *dst, ListBase *src) FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *prop_name, int index, char *driven) { /* anim vars */ - AnimData *adt= BKE_animdata_from_id(id); - FCurve *fcu= NULL; + AnimData *adt = BKE_animdata_from_id(id); + FCurve *fcu = NULL; /* rna vars */ PointerRNA ptr; @@ -194,16 +194,16 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro prop = RNA_struct_find_property(&ptr, prop_name); if (prop) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { /* animation takes priority over drivers */ if ((adt->action) && (adt->action->curves.first)) - fcu= list_find_fcurve(&adt->action->curves, path, index); + fcu = list_find_fcurve(&adt->action->curves, path, index); /* if not animated, check if driven */ if ((fcu == NULL) && (adt->drivers.first)) { - fcu= list_find_fcurve(&adt->drivers, path, index); + fcu = list_find_fcurve(&adt->drivers, path, index); if (fcu && driven) *driven = TRUE; fcu = NULL; @@ -218,16 +218,16 @@ FCurve *id_data_find_fcurve(ID *id, void *data, StructRNA *type, const char *pro /* Find the F-Curve affecting the given RNA-access path + index, in the list of F-Curves provided */ -FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array_index) +FCurve *list_find_fcurve(ListBase *list, const char rna_path[], const int array_index) { FCurve *fcu; /* sanity checks */ - if ( ELEM(NULL, list, rna_path) || (array_index < 0) ) + if (ELEM(NULL, list, rna_path) || (array_index < 0) ) return NULL; /* check paths of curves, then array indices... */ - for (fcu= list->first; fcu; fcu= fcu->next) { + for (fcu = list->first; fcu; fcu = fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { /* now check indices */ @@ -241,7 +241,7 @@ FCurve *list_find_fcurve (ListBase *list, const char rna_path[], const int array } /* quick way to loop over all fcurves of a given 'path' */ -FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) +FCurve *iter_step_fcurve(FCurve *fcu_iter, const char rna_path[]) { FCurve *fcu; @@ -250,7 +250,7 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) return NULL; /* check paths of curves, then array indices... */ - for (fcu= fcu_iter; fcu; fcu= fcu->next) { + for (fcu = fcu_iter; fcu; fcu = fcu->next) { /* simple string-compare (this assumes that they have the same root...) */ if (fcu->rna_path && !strcmp(fcu->rna_path, rna_path)) { return fcu; @@ -267,8 +267,8 @@ FCurve *iter_step_fcurve (FCurve *fcu_iter, const char rna_path[]) * List must be freed after use, and is assumed to be empty when passed. * - src: list of F-Curves to search through * Filters... - * - dataPrefix: i.e. 'pose.bones[' or 'nodes[' - * - dataName: name of entity within "" immediately following the prefix + * - dataPrefix: i.e. 'pose.bones[' or 'nodes[' + * - dataName: name of entity within "" immediately following the prefix */ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, const char *dataName) { @@ -282,17 +282,17 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, return 0; /* search each F-Curve one by one */ - for (fcu= src->first; fcu; fcu= fcu->next) { + for (fcu = src->first; fcu; fcu = fcu->next) { /* check if quoted string matches the path */ if ((fcu->rna_path) && strstr(fcu->rna_path, dataPrefix)) { - char *quotedName= BLI_getQuotedStr(fcu->rna_path, dataPrefix); + char *quotedName = BLI_getQuotedStr(fcu->rna_path, dataPrefix); if (quotedName) { /* check if the quoted name matches the required name */ if (strcmp(quotedName, dataName) == 0) { - LinkData *ld= MEM_callocN(sizeof(LinkData), "list_find_data_fcurves"); + LinkData *ld = MEM_callocN(sizeof(LinkData), "list_find_data_fcurves"); - ld->data= fcu; + ld->data = fcu; BLI_addtail(dst, ld); matches++; @@ -308,37 +308,37 @@ int list_find_data_fcurves(ListBase *dst, ListBase *src, const char *dataPrefix, return matches; } -FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) +FCurve *rna_get_fcurve(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bAction **action, int *driven) { - FCurve *fcu= NULL; + FCurve *fcu = NULL; - *driven= 0; + *driven = 0; /* there must be some RNA-pointer + property combon */ if (prop && ptr->id.data && RNA_property_animateable(ptr, prop)) { - AnimData *adt= BKE_animdata_from_id(ptr->id.data); + AnimData *adt = BKE_animdata_from_id(ptr->id.data); char *path; if (adt) { if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) { /* XXX this function call can become a performance bottleneck */ - path= RNA_path_from_ID_to_property(ptr, prop); + path = RNA_path_from_ID_to_property(ptr, prop); if (path) { /* animation takes priority over drivers */ if (adt->action && adt->action->curves.first) - fcu= list_find_fcurve(&adt->action->curves, path, rnaindex); + fcu = list_find_fcurve(&adt->action->curves, path, rnaindex); /* if not animated, check if driven */ if (!fcu && (adt->drivers.first)) { - fcu= list_find_fcurve(&adt->drivers, path, rnaindex); + fcu = list_find_fcurve(&adt->drivers, path, rnaindex); if (fcu) - *driven= 1; + *driven = 1; } if (fcu && action) - *action= adt->action; + *action = adt->action; MEM_freeN(path); } @@ -352,18 +352,18 @@ FCurve *rna_get_fcurve (PointerRNA *ptr, PropertyRNA *prop, int rnaindex, bActio /* ----------------- Finding Keyframes/Extents -------------------------- */ /* threshold for binary-searching keyframes - threshold here should be good enough for now, but should become userpref */ -#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ +#define BEZT_BINARYSEARCH_THRESH 0.01f /* was 0.00001, but giving errors */ /* Binary search algorithm for finding where to insert BezTriple. (for use by insert_bezt_fcurve) * Returns the index to insert at (data already at that index will be offset if replace is 0) */ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short *replace) { - int start=0, end=arraylen; - int loopbreaker= 0, maxloop= arraylen * 2; + int start = 0, end = arraylen; + int loopbreaker = 0, maxloop = arraylen * 2; /* initialize replace-flag first */ - *replace= 0; + *replace = 0; /* sneaky optimisations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds @@ -378,7 +378,7 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short float framenum; /* 'First' Keyframe (when only one keyframe, this case is used) */ - framenum= array[0].vec[1][0]; + framenum = array[0].vec[1][0]; if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) { *replace = 1; return 0; @@ -387,9 +387,9 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short return 0; /* 'Last' Keyframe */ - framenum= array[(arraylen-1)].vec[1][0]; + framenum = array[(arraylen - 1)].vec[1][0]; if (IS_EQT(frame, framenum, BEZT_BINARYSEARCH_THRESH)) { - *replace= 1; + *replace = 1; return (arraylen - 1); } else if (frame > framenum) @@ -400,10 +400,10 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* most of the time, this loop is just to find where to put it * 'loopbreaker' is just here to prevent infinite loops */ - for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { + for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { /* compute and get midpoint */ - int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ - float midfra= array[mid].vec[1][0]; + int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ + float midfra = array[mid].vec[1][0]; /* check if exactly equal to midpoint */ if (IS_EQT(frame, midfra, BEZT_BINARYSEARCH_THRESH)) { @@ -413,13 +413,13 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* repeat in upper/lower half */ if (frame > midfra) - start= mid + 1; + start = mid + 1; else if (frame < midfra) - end= mid - 1; + end = mid - 1; } /* print error if loop-limit exceeded */ - if (loopbreaker == (maxloop-1)) { + if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_bezt_index() was taking too long\n"); // include debug info @@ -433,8 +433,8 @@ int binarysearch_bezt_index(BezTriple array[], float frame, int arraylen, short /* ...................................... */ /* helper for calc_fcurve_* functions -> find first and last BezTriple to be used */ -static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple **last, - const short do_sel_only) +static void get_fcurve_end_keyframes(FCurve *fcu, BezTriple **first, BezTriple **last, + const short do_sel_only) { /* init outputs */ *first = NULL; @@ -451,18 +451,18 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple /* find first selected */ bezt = fcu->bezt; - for (i=0; i < fcu->totvert; bezt++, i++) { + for (i = 0; i < fcu->totvert; bezt++, i++) { if (BEZSELECTED(bezt)) { - *first= bezt; + *first = bezt; break; } } /* find last selected */ bezt = ARRAY_LAST_ITEM(fcu->bezt, BezTriple, sizeof(BezTriple), fcu->totvert); - for (i=0; i < fcu->totvert; bezt--, i++) { + for (i = 0; i < fcu->totvert; bezt--, i++) { if (BEZSELECTED(bezt)) { - *last= bezt; + *last = bezt; break; } } @@ -479,14 +479,14 @@ static void get_fcurve_end_keyframes (FCurve *fcu, BezTriple **first, BezTriple void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, float *ymax, const short do_sel_only) { - float xminv=999999999.0f, xmaxv=-999999999.0f; - float yminv=999999999.0f, ymaxv=-999999999.0f; - short foundvert= FALSE; + float xminv = 999999999.0f, xmaxv = -999999999.0f; + float yminv = 999999999.0f, ymaxv = -999999999.0f; + short foundvert = FALSE; unsigned int i; if (fcu->totvert) { if (fcu->bezt) { - BezTriple *bezt_first= NULL, *bezt_last= NULL; + BezTriple *bezt_first = NULL, *bezt_last = NULL; if (xmin || xmax) { /* get endpoint keyframes */ @@ -495,8 +495,8 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa if (bezt_first) { BLI_assert(bezt_last != NULL); - xminv= MIN2(xminv, bezt_first->vec[1][0]); - xmaxv= MAX2(xmaxv, bezt_last->vec[1][0]); + xminv = MIN2(xminv, bezt_first->vec[1][0]); + xmaxv = MAX2(xmaxv, bezt_last->vec[1][0]); } } @@ -504,13 +504,13 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa if (ymin || ymax) { BezTriple *bezt; - for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) { + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { if ((do_sel_only == 0) || BEZSELECTED(bezt)) { if (bezt->vec[1][1] < yminv) - yminv= bezt->vec[1][1]; + yminv = bezt->vec[1][1]; if (bezt->vec[1][1] > ymaxv) - ymaxv= bezt->vec[1][1]; - foundvert= TRUE; + ymaxv = bezt->vec[1][1]; + foundvert = TRUE; } } } @@ -518,42 +518,42 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa else if (fcu->fpt) { /* frame range can be directly calculated from end verts */ if (xmin || xmax) { - xminv= MIN2(xminv, fcu->fpt[0].vec[0]); - xmaxv= MAX2(xmaxv, fcu->fpt[fcu->totvert-1].vec[0]); + xminv = MIN2(xminv, fcu->fpt[0].vec[0]); + xmaxv = MAX2(xmaxv, fcu->fpt[fcu->totvert - 1].vec[0]); } /* only loop over keyframes to find extents for values if needed */ if (ymin || ymax) { FPoint *fpt; - for (fpt=fcu->fpt, i=0; i < fcu->totvert; fpt++, i++) { + for (fpt = fcu->fpt, i = 0; i < fcu->totvert; fpt++, i++) { if (fpt->vec[1] < yminv) - yminv= fpt->vec[1]; + yminv = fpt->vec[1]; if (fpt->vec[1] > ymaxv) - ymaxv= fpt->vec[1]; + ymaxv = fpt->vec[1]; - foundvert= TRUE; + foundvert = TRUE; } } } } if (foundvert) { - if (xmin) *xmin= xminv; - if (xmax) *xmax= xmaxv; + if (xmin) *xmin = xminv; + if (xmax) *xmax = xmaxv; - if (ymin) *ymin= yminv; - if (ymax) *ymax= ymaxv; + if (ymin) *ymin = yminv; + if (ymax) *ymax = ymaxv; } else { if (G.debug & G_DEBUG) printf("F-Curve calc bounds didn't find anything, so assuming minimum bounds of 1.0\n"); - if (xmin) *xmin= 0.0f; - if (xmax) *xmax= 1.0f; + if (xmin) *xmin = 0.0f; + if (xmax) *xmax = 1.0f; - if (ymin) *ymin= 0.0f; - if (ymax) *ymax= 1.0f; + if (ymin) *ymin = 0.0f; + if (ymax) *ymax = 1.0f; } } @@ -561,12 +561,12 @@ void calc_fcurve_bounds(FCurve *fcu, float *xmin, float *xmax, float *ymin, floa void calc_fcurve_range(FCurve *fcu, float *start, float *end, const short do_sel_only, const short do_min_length) { - float min=999999999.0f, max=-999999999.0f; - short foundvert= FALSE; + float min = 999999999.0f, max = -999999999.0f; + short foundvert = FALSE; if (fcu->totvert) { if (fcu->bezt) { - BezTriple *bezt_first= NULL, *bezt_last= NULL; + BezTriple *bezt_first = NULL, *bezt_last = NULL; /* get endpoint keyframes */ get_fcurve_end_keyframes(fcu, &bezt_first, &bezt_last, do_sel_only); @@ -574,23 +574,23 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end, if (bezt_first) { BLI_assert(bezt_last != NULL); - min= MIN2(min, bezt_first->vec[1][0]); - max= MAX2(max, bezt_last->vec[1][0]); + min = MIN2(min, bezt_first->vec[1][0]); + max = MAX2(max, bezt_last->vec[1][0]); - foundvert= TRUE; + foundvert = TRUE; } } else if (fcu->fpt) { - min= MIN2(min, fcu->fpt[0].vec[0]); - max= MAX2(max, fcu->fpt[fcu->totvert-1].vec[0]); + min = MIN2(min, fcu->fpt[0].vec[0]); + max = MAX2(max, fcu->fpt[fcu->totvert - 1].vec[0]); - foundvert= TRUE; + foundvert = TRUE; } } if (foundvert == FALSE) { - min= max= 0.0f; + min = max = 0.0f; } if (do_min_length) { @@ -600,8 +600,8 @@ void calc_fcurve_range(FCurve *fcu, float *start, float *end, } } - *start= min; - *end= max; + *start = min; + *end = max; } /* ----------------- Status Checks -------------------------- */ @@ -628,7 +628,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu) // TODO: optionally, only check modifier if it is the active one... for (fcm = fcu->modifiers.last; fcm; fcm = fcm->prev) { /* ignore if muted/disabled */ - if (fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) + if (fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) continue; /* type checks */ @@ -647,7 +647,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu) if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) return 0; } - break; + break; case FMODIFIER_TYPE_FN_GENERATOR: { FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; @@ -655,7 +655,7 @@ short fcurve_are_keyframes_usable(FCurve *fcu) if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) return 0; } - break; + break; /* always harmful - cannot allow */ default: @@ -692,10 +692,10 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt) { CfraElem *ce, *cen; - for (ce= lb->first; ce; ce= ce->next) { + for (ce = lb->first; ce; ce = ce->next) { /* double key? */ if (ce->cfra == bezt->vec[1][0]) { - if (bezt->f2 & SELECT) ce->sel= bezt->f2; + if (bezt->f2 & SELECT) ce->sel = bezt->f2; return; } /* should key be inserted before this column? */ @@ -703,12 +703,12 @@ void bezt_add_to_cfra_elem(ListBase *lb, BezTriple *bezt) } /* create a new column */ - cen= MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); + cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); if (ce) BLI_insertlinkbefore(lb, ce, cen); else BLI_addtail(lb, cen); - cen->cfra= bezt->vec[1][0]; - cen->sel= bezt->f2; + cen->cfra = bezt->vec[1][0]; + cen->sel = bezt->f2; } /* ***************************** Samples Utilities ******************************* */ @@ -748,12 +748,12 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample } /* set up sample data */ - fpt= new_fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "FPoint Samples"); + fpt = new_fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "FPoint Samples"); /* use the sampling callback at 1-frame intervals from start to end frames */ - for (cfra= start; cfra <= end; cfra++, fpt++) { - fpt->vec[0]= (float)cfra; - fpt->vec[1]= sample_cb(fcu, data, (float)cfra); + for (cfra = start; cfra <= end; cfra++, fpt++) { + fpt->vec[0] = (float)cfra; + fpt->vec[1] = sample_cb(fcu, data, (float)cfra); } /* free any existing sample/keyframe data on curve */ @@ -761,9 +761,9 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample if (fcu->fpt) MEM_freeN(fcu->fpt); /* store the samples */ - fcu->bezt= NULL; - fcu->fpt= new_fpt; - fcu->totvert= end - start + 1; + fcu->bezt = NULL; + fcu->fpt = new_fpt; + fcu->totvert = end - start + 1; } /* ***************************** F-Curve Sanity ********************************* */ @@ -778,7 +778,7 @@ void fcurve_store_samples(FCurve *fcu, void *data, int start, int end, FcuSample void calchandles_fcurve(FCurve *fcu) { BezTriple *bezt, *prev, *next; - int a= fcu->totvert; + int a = fcu->totvert; /* Error checking: * - need at least two points @@ -789,33 +789,33 @@ void calchandles_fcurve(FCurve *fcu) return; /* get initial pointers */ - bezt= fcu->bezt; - prev= NULL; - next= (bezt + 1); + bezt = fcu->bezt; + prev = NULL; + next = (bezt + 1); /* loop over all beztriples, adjusting handles */ while (a--) { /* clamp timing of handles to be on either side of beztriple */ - if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0]= bezt->vec[1][0]; - if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0]= bezt->vec[1][0]; + if (bezt->vec[0][0] > bezt->vec[1][0]) bezt->vec[0][0] = bezt->vec[1][0]; + if (bezt->vec[2][0] < bezt->vec[1][0]) bezt->vec[2][0] = bezt->vec[1][0]; /* calculate auto-handles */ - BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ + BKE_nurb_handle_calc(bezt, prev, next, 1); /* 1==special autohandle */ /* for automatic ease in and out */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* only do this on first or last beztriple */ - if ((a == 0) || (a == fcu->totvert-1)) { + if ((a == 0) || (a == fcu->totvert - 1)) { /* set both handles to have same horizontal value as keyframe */ if (fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) { - bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1]; + bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1]; } } } /* advance pointers for next iteration */ - prev= bezt; - if (a == 1) next= NULL; + prev = bezt; + if (a == 1) next = NULL; else next++; bezt++; } @@ -824,8 +824,8 @@ void calchandles_fcurve(FCurve *fcu) /* Use when F-Curve with handles has changed * It treats all BezTriples with the following rules: * - PHASE 1: do types have to be altered? - * -> Auto handles: become aligned when selection status is NOT(000 || 111) - * -> Vector handles: become 'nothing' when (one half selected AND other not) + * -> Auto handles: become aligned when selection status is NOT(000 || 111) + * -> Vector handles: become 'nothing' when (one half selected AND other not) * - PHASE 2: recalculate handles */ void testhandles_fcurve(FCurve *fcu, const short use_handle) @@ -838,41 +838,41 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle) return; /* loop over beztriples */ - for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) { - short flag= 0; + for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) { + short flag = 0; /* flag is initialized as selection status * of beztriple control-points (labelled 0,1,2) */ - if (bezt->f2 & SELECT) flag |= (1<<1); // == 2 + if (bezt->f2 & SELECT) flag |= (1 << 1); // == 2 if (use_handle == FALSE) { if (flag & 2) { - flag |= (1<<0) | (1<<2); + flag |= (1 << 0) | (1 << 2); } } else { - if (bezt->f1 & SELECT) flag |= (1<<0); // == 1 - if (bezt->f3 & SELECT) flag |= (1<<2); // == 4 + if (bezt->f1 & SELECT) flag |= (1 << 0); // == 1 + if (bezt->f3 & SELECT) flag |= (1 << 2); // == 4 } /* one or two handles selected only */ - if (ELEM(flag, 0, 7)==0) { + if (ELEM(flag, 0, 7) == 0) { /* auto handles become aligned */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM)) - bezt->h1= HD_ALIGN; + bezt->h1 = HD_ALIGN; if (ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) - bezt->h2= HD_ALIGN; + bezt->h2 = HD_ALIGN; /* vector handles become 'free' when only one half selected */ - if (bezt->h1==HD_VECT) { + if (bezt->h1 == HD_VECT) { /* only left half (1 or 2 or 1+2) */ if (flag < 4) - bezt->h1= 0; + bezt->h1 = 0; } - if (bezt->h2==HD_VECT) { + if (bezt->h2 == HD_VECT) { /* only right half (4 or 2+4) */ if (flag > 3) - bezt->h2= 0; + bezt->h2 = 0; } } } @@ -886,11 +886,11 @@ void testhandles_fcurve(FCurve *fcu, const short use_handle) */ void sort_time_fcurve(FCurve *fcu) { - short ok= 1; + short ok = 1; /* keep adjusting order of beztriples until nothing moves (bubble-sort) */ while (ok) { - ok= 0; + ok = 0; /* currently, will only be needed when there are beztriples */ if (fcu->bezt) { @@ -898,13 +898,13 @@ void sort_time_fcurve(FCurve *fcu) unsigned int a; /* loop over ALL points to adjust position in array and recalculate handles */ - for (a=0, bezt=fcu->bezt; a < fcu->totvert; a++, bezt++) { + for (a = 0, bezt = fcu->bezt; a < fcu->totvert; a++, bezt++) { /* check if thee's a next beztriple which we could try to swap with current */ - if (a < (fcu->totvert-1)) { + if (a < (fcu->totvert - 1)) { /* swap if one is after the other (and indicate that order has changed) */ - if (bezt->vec[1][0] > (bezt+1)->vec[1][0]) { - SWAP(BezTriple, *bezt, *(bezt+1)); - ok= 1; + if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) { + SWAP(BezTriple, *bezt, *(bezt + 1)); + ok = 1; } /* if either one of both of the points exceeds crosses over the keyframe time... */ @@ -916,9 +916,9 @@ void sort_time_fcurve(FCurve *fcu) else { /* clamp handles */ if (bezt->vec[0][0] > bezt->vec[1][0]) - bezt->vec[0][0]= bezt->vec[1][0]; + bezt->vec[0][0] = bezt->vec[1][0]; if (bezt->vec[2][0] < bezt->vec[1][0]) - bezt->vec[2][0]= bezt->vec[1][0]; + bezt->vec[2][0] = bezt->vec[1][0]; } } } @@ -940,8 +940,8 @@ short test_time_fcurve(FCurve *fcu) BezTriple *bezt; /* loop through all BezTriples, stopping when one exceeds the one after it */ - for (a=0, bezt= fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) { - if (bezt->vec[1][0] > (bezt+1)->vec[1][0]) + for (a = 0, bezt = fcu->bezt; a < (fcu->totvert - 1); a++, bezt++) { + if (bezt->vec[1][0] > (bezt + 1)->vec[1][0]) return 1; } } @@ -949,8 +949,8 @@ short test_time_fcurve(FCurve *fcu) FPoint *fpt; /* loop through all FPoints, stopping when one exceeds the one after it */ - for (a=0, fpt= fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) { - if (fpt->vec[0] > (fpt+1)->vec[0]) + for (a = 0, fpt = fcu->fpt; a < (fcu->totvert - 1); a++, fpt++) { + if (fpt->vec[0] > (fpt + 1)->vec[0]) return 1; } } @@ -969,9 +969,9 @@ typedef struct DriverVarTypeInfo { float (*get_value)(ChannelDriver *driver, DriverVar *dvar); /* allocation of target slots */ - int num_targets; /* number of target slots required */ - const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */ - int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */ + int num_targets; /* number of target slots required */ + const char *target_names[MAX_DRIVER_TARGETS]; /* UI names that should be given to the slots */ + int target_flags[MAX_DRIVER_TARGETS]; /* flags defining the requirements for each slot */ } DriverVarTypeInfo; /* Macro to begin definitions */ @@ -986,25 +986,25 @@ typedef struct DriverVarTypeInfo { static ID *dtar_id_ensure_proxy_from(ID *id) { - if (id && GS(id->name)==ID_OB && ((Object *)id)->proxy_from) + if (id && GS(id->name) == ID_OB && ((Object *)id)->proxy_from) return (ID *)(((Object *)id)->proxy_from); return id; } /* Helper function to obtain a value using RNA from the specified source (for evaluating drivers) */ -static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) +static float dtar_get_prop_val(ChannelDriver *driver, DriverTarget *dtar) { PointerRNA id_ptr, ptr; PropertyRNA *prop; ID *id; int index; - float value= 0.0f; + float value = 0.0f; /* sanity check */ if (ELEM(NULL, driver, dtar)) return 0.0f; - id= dtar_id_ensure_proxy_from(dtar->id); + id = dtar_id_ensure_proxy_from(dtar->id); /* error check for missing pointer... */ // TODO: tag the specific target too as having issues @@ -1024,37 +1024,37 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) /* array */ if (index < RNA_property_array_length(&ptr, prop)) { switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - value= (float)RNA_property_boolean_get_index(&ptr, prop, index); - break; - case PROP_INT: - value= (float)RNA_property_int_get_index(&ptr, prop, index); - break; - case PROP_FLOAT: - value= RNA_property_float_get_index(&ptr, prop, index); - break; - default: - break; + case PROP_BOOLEAN: + value = (float)RNA_property_boolean_get_index(&ptr, prop, index); + break; + case PROP_INT: + value = (float)RNA_property_int_get_index(&ptr, prop, index); + break; + case PROP_FLOAT: + value = RNA_property_float_get_index(&ptr, prop, index); + break; + default: + break; } } } else { /* not an array */ switch (RNA_property_type(prop)) { - case PROP_BOOLEAN: - value= (float)RNA_property_boolean_get(&ptr, prop); - break; - case PROP_INT: - value= (float)RNA_property_int_get(&ptr, prop); - break; - case PROP_FLOAT: - value= RNA_property_float_get(&ptr, prop); - break; - case PROP_ENUM: - value= (float)RNA_property_enum_get(&ptr, prop); - break; - default: - break; + case PROP_BOOLEAN: + value = (float)RNA_property_boolean_get(&ptr, prop); + break; + case PROP_INT: + value = (float)RNA_property_int_get(&ptr, prop); + break; + case PROP_FLOAT: + value = RNA_property_float_get(&ptr, prop); + break; + case PROP_ENUM: + value = (float)RNA_property_enum_get(&ptr, prop); + break; + default: + break; } } @@ -1071,21 +1071,21 @@ static float dtar_get_prop_val (ChannelDriver *driver, DriverTarget *dtar) } /* Helper function to obtain a pointer to a Pose Channel (for evaluating drivers) */ -static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dtar) +static bPoseChannel *dtar_get_pchan_ptr(ChannelDriver *driver, DriverTarget *dtar) { ID *id; /* sanity check */ if (ELEM(NULL, driver, dtar)) return NULL; - id= dtar_id_ensure_proxy_from(dtar->id); + id = dtar_id_ensure_proxy_from(dtar->id); /* check if the ID here is a valid object */ if (id && GS(id->name)) { - Object *ob= (Object *)id; + Object *ob = (Object *)id; /* get pose, and subsequently, posechannel */ - return get_pose_channel(ob->pose, dtar->pchan_name); + return BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); } else { /* cannot find a posechannel this way */ @@ -1096,21 +1096,21 @@ static bPoseChannel *dtar_get_pchan_ptr (ChannelDriver *driver, DriverTarget *dt /* ......... */ /* evaluate 'single prop' driver variable */ -static float dvar_eval_singleProp (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_singleProp(ChannelDriver *driver, DriverVar *dvar) { /* just evaluate the first target slot */ return dtar_get_prop_val(driver, &dvar->targets[0]); } /* evaluate 'rotation difference' driver variable */ -static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_rotDiff(ChannelDriver *driver, DriverVar *dvar) { bPoseChannel *pchan, *pchan2; float q1[4], q2[4], quat[4], angle; /* get pose channels, and check if we've got two */ - pchan= dtar_get_pchan_ptr(driver, &dvar->targets[0]); - pchan2= dtar_get_pchan_ptr(driver, &dvar->targets[1]); + pchan = dtar_get_pchan_ptr(driver, &dvar->targets[0]); + pchan2 = dtar_get_pchan_ptr(driver, &dvar->targets[1]); if (ELEM(NULL, pchan, pchan2)) { /* disable this driver, since it doesn't work correctly... */ @@ -1135,14 +1135,14 @@ static float dvar_eval_rotDiff (ChannelDriver *driver, DriverVar *dvar) invert_qt(q1); mul_qt_qtqt(quat, q1, q2); angle = 2.0f * (saacos(quat[0])); - angle= ABS(angle); + angle = ABS(angle); return (angle > (float)M_PI) ? (float)((2.0f * (float)M_PI) - angle) : (float)(angle); } /* evaluate 'location difference' driver variable */ // TODO: this needs to take into account space conversions... -static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_locDiff(ChannelDriver *driver, DriverVar *dvar) { float loc1[3] = {0.0f, 0.0f, 0.0f}; float loc2[3] = {0.0f, 0.0f, 0.0f}; @@ -1152,7 +1152,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) DRIVER_TARGETS_USED_LOOPER(dvar) { /* get pointer to loc values to store in */ - Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); + Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float tmp_loc[3]; @@ -1164,7 +1164,7 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) } /* try to get posechannel */ - pchan= get_pose_channel(ob->pose, dtar->pchan_name); + pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); /* check if object or bone */ if (pchan) { @@ -1234,14 +1234,14 @@ static float dvar_eval_locDiff (ChannelDriver *driver, DriverVar *dvar) } /* evaluate 'transform channel' driver variable */ -static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) +static float dvar_eval_transChan(ChannelDriver *driver, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; - Object *ob= (Object *)dtar_id_ensure_proxy_from(dtar->id); + DriverTarget *dtar = &dvar->targets[0]; + Object *ob = (Object *)dtar_id_ensure_proxy_from(dtar->id); bPoseChannel *pchan; float mat[4][4]; float oldEul[3] = {0.0f, 0.0f, 0.0f}; - short useEulers=0, rotOrder=ROT_MODE_EUL; + short useEulers = 0, rotOrder = ROT_MODE_EUL; /* check if this target has valid data */ if ((ob == NULL) || (GS(ob->id.name) != ID_OB)) { @@ -1251,7 +1251,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) } /* try to get posechannel */ - pchan= get_pose_channel(ob->pose, dtar->pchan_name); + pchan = BKE_pose_channel_find_name(ob->pose, dtar->pchan_name); /* check if object or bone, and get transform matrix accordingly * - "useEulers" code is used to prevent the problems associated with non-uniqueness @@ -1263,7 +1263,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* bone */ if (pchan->rotmode > 0) { copy_v3_v3(oldEul, pchan->eul); - rotOrder= pchan->rotmode; + rotOrder = pchan->rotmode; useEulers = 1; } @@ -1278,7 +1278,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) * since it stores delta transform of pose_mat so that deforms work * so it cannot be used here for "transform" space */ - pchan_to_mat4(pchan, mat); + BKE_pchan_to_mat4(pchan, mat); } } else { @@ -1290,7 +1290,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* object */ if (ob->rotmode > 0) { copy_v3_v3(oldEul, ob->rot); - rotOrder= ob->rotmode; + rotOrder = ob->rotmode; useEulers = 1; } @@ -1302,7 +1302,7 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) } else { /* transforms to matrix */ - object_to_mat4(ob, mat); + BKE_object_to_mat4(ob, mat); } } else { @@ -1353,36 +1353,36 @@ static float dvar_eval_transChan (ChannelDriver *driver, DriverVar *dvar) /* Table of Driver Varaiable Type Info Data */ static DriverVarTypeInfo dvar_types[MAX_DVAR_TYPES] = { BEGIN_DVAR_TYPEDEF(DVAR_TYPE_SINGLE_PROP) - dvar_eval_singleProp, /* eval callback */ - 1, /* number of targets used */ - {"Property"}, /* UI names for targets */ - {0} /* flags */ + dvar_eval_singleProp, /* eval callback */ + 1, /* number of targets used */ + {"Property"}, /* UI names for targets */ + {0} /* flags */ END_DVAR_TYPEDEF, BEGIN_DVAR_TYPEDEF(DVAR_TYPE_ROT_DIFF) - dvar_eval_rotDiff, /* eval callback */ - 2, /* number of targets used */ - {"Bone 1", "Bone 2"}, /* UI names for targets */ - {DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */ + dvar_eval_rotDiff, /* eval callback */ + 2, /* number of targets used */ + {"Bone 1", "Bone 2"}, /* UI names for targets */ + {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */ END_DVAR_TYPEDEF, BEGIN_DVAR_TYPEDEF(DVAR_TYPE_LOC_DIFF) - dvar_eval_locDiff, /* eval callback */ - 2, /* number of targets used */ - {"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */ - {DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */ + dvar_eval_locDiff, /* eval callback */ + 2, /* number of targets used */ + {"Object/Bone 1", "Object/Bone 2"}, /* UI names for targets */ + {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY, DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */ END_DVAR_TYPEDEF, BEGIN_DVAR_TYPEDEF(DVAR_TYPE_TRANSFORM_CHAN) - dvar_eval_transChan, /* eval callback */ - 1, /* number of targets used */ - {"Object/Bone"}, /* UI names for targets */ - {DTAR_FLAG_STRUCT_REF|DTAR_FLAG_ID_OB_ONLY} /* flags */ + dvar_eval_transChan, /* eval callback */ + 1, /* number of targets used */ + {"Object/Bone"}, /* UI names for targets */ + {DTAR_FLAG_STRUCT_REF | DTAR_FLAG_ID_OB_ONLY} /* flags */ END_DVAR_TYPEDEF, }; /* Get driver variable typeinfo */ -static DriverVarTypeInfo *get_dvar_typeinfo (int type) +static DriverVarTypeInfo *get_dvar_typeinfo(int type) { /* check if valid type */ if ((type >= 0) && (type < MAX_DVAR_TYPES)) @@ -1403,7 +1403,7 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) /* free target vars * - need to go over all of them, not just up to the ones that are used * currently, since there may be some lingering RNA paths from - * previous users needing freeing + * previous users needing freeing */ DRIVER_TARGETS_LOOPER(dvar) { @@ -1418,7 +1418,7 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ - if (driver->type==DRIVER_TYPE_PYTHON) + if (driver->type == DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif } @@ -1426,15 +1426,15 @@ void driver_free_variable(ChannelDriver *driver, DriverVar *dvar) /* Change the type of driver variable */ void driver_change_variable_type(DriverVar *dvar, int type) { - DriverVarTypeInfo *dvti= get_dvar_typeinfo(type); + DriverVarTypeInfo *dvti = get_dvar_typeinfo(type); /* sanity check */ if (ELEM(NULL, dvar, dvti)) return; /* set the new settings */ - dvar->type= type; - dvar->num_targets= dvti->num_targets; + dvar->type = type; + dvar->num_targets = dvti->num_targets; /* make changes to the targets based on the defines for these types * NOTE: only need to make sure the ones we're using here are valid... @@ -1448,13 +1448,13 @@ void driver_change_variable_type(DriverVar *dvar, int type) /* object ID types only, or idtype not yet initialized*/ if ((flags & DTAR_FLAG_ID_OB_ONLY) || (dtar->idtype == 0)) - dtar->idtype= ID_OB; + dtar->idtype = ID_OB; } DRIVER_TARGETS_LOOPER_END } /* Add a new driver variable */ -DriverVar *driver_add_new_variable (ChannelDriver *driver) +DriverVar *driver_add_new_variable(ChannelDriver *driver) { DriverVar *dvar; @@ -1463,7 +1463,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) return NULL; /* make a new variable */ - dvar= MEM_callocN(sizeof(DriverVar), "DriverVar"); + dvar = MEM_callocN(sizeof(DriverVar), "DriverVar"); BLI_addtail(&driver->variables, dvar); /* give the variable a 'unique' name */ @@ -1475,7 +1475,7 @@ DriverVar *driver_add_new_variable (ChannelDriver *driver) #ifdef WITH_PYTHON /* since driver variables are cached, the expression needs re-compiling too */ - if (driver->type==DRIVER_TYPE_PYTHON) + if (driver->type == DRIVER_TYPE_PYTHON) driver->flag |= DRIVER_FLAG_RENAMEVAR; #endif @@ -1492,11 +1492,11 @@ void fcurve_free_driver(FCurve *fcu) /* sanity checks */ if (ELEM(NULL, fcu, fcu->driver)) return; - driver= fcu->driver; + driver = fcu->driver; /* free driver targets */ - for (dvar= driver->variables.first; dvar; dvar= dvarn) { - dvarn= dvar->next; + for (dvar = driver->variables.first; dvar; dvar = dvarn) { + dvarn = dvar->next; driver_free_variable(driver, dvar); } @@ -1508,11 +1508,11 @@ void fcurve_free_driver(FCurve *fcu) /* free driver itself, then set F-Curve's point to this to NULL (as the curve may still be used) */ MEM_freeN(driver); - fcu->driver= NULL; + fcu->driver = NULL; } /* This makes a copy of the given driver */ -ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) +ChannelDriver *fcurve_copy_driver(ChannelDriver *driver) { ChannelDriver *ndriver; DriverVar *dvar; @@ -1522,14 +1522,14 @@ ChannelDriver *fcurve_copy_driver (ChannelDriver *driver) return NULL; /* copy all data */ - ndriver= MEM_dupallocN(driver); - ndriver->expr_comp= NULL; + ndriver = MEM_dupallocN(driver); + ndriver->expr_comp = NULL; /* copy variables */ - ndriver->variables.first= ndriver->variables.last= NULL; + ndriver->variables.first = ndriver->variables.last = NULL; BLI_duplicatelist(&ndriver->variables, &driver->variables); - for (dvar= ndriver->variables.first; dvar; dvar= dvar->next) { + for (dvar = ndriver->variables.first; dvar; dvar = dvar->next) { /* need to go over all targets so that we don't leave any dangling paths */ DRIVER_TARGETS_LOOPER(dvar) { @@ -1559,21 +1559,21 @@ float driver_get_variable_value(ChannelDriver *driver, DriverVar *dvar) * using the variable type info, storing the obtained value * in dvar->curval so that drivers can be debugged */ - dvti= get_dvar_typeinfo(dvar->type); + dvti = get_dvar_typeinfo(dvar->type); if (dvti && dvti->get_value) - dvar->curval= dvti->get_value(driver, dvar); + dvar->curval = dvti->get_value(driver, dvar); else - dvar->curval= 0.0f; + dvar->curval = 0.0f; return dvar->curval; } /* Evaluate an Channel-Driver to get a 'time' value to use instead of "evaltime" * - "evaltime" is the frame at which F-Curve is being evaluated - * - has to return a float value + * - has to return a float value */ -static float evaluate_driver (ChannelDriver *driver, const float evaltime) +static float evaluate_driver(ChannelDriver *driver, const float evaltime) { DriverVar *dvar; @@ -1588,8 +1588,8 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) /* check how many variables there are first (i.e. just one?) */ if (driver->variables.first == driver->variables.last) { /* just one target, so just use that */ - dvar= driver->variables.first; - driver->curval= driver_get_variable_value(driver, dvar); + dvar = driver->variables.first; + driver->curval = driver_get_variable_value(driver, dvar); } else { /* more than one target, so average the values of the targets */ @@ -1597,19 +1597,19 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) int tot = 0; /* loop through targets, adding (hopefully we don't get any overflow!) */ - for (dvar= driver->variables.first; dvar; dvar=dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { value += driver_get_variable_value(driver, dvar); tot++; } /* perform operations on the total if appropriate */ if (driver->type == DRIVER_TYPE_AVERAGE) - driver->curval= (value / (float)tot); + driver->curval = (value / (float)tot); else - driver->curval= value; + driver->curval = value; } } - break; + break; case DRIVER_TYPE_MIN: /* smallest value */ case DRIVER_TYPE_MAX: /* largest value */ @@ -1617,9 +1617,9 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) float value = 0.0f; /* loop through the variables, getting the values and comparing them to existing ones */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* get value */ - float tmp_val= driver_get_variable_value(driver, dvar); + float tmp_val = driver_get_variable_value(driver, dvar); /* store this value if appropriate */ if (dvar->prev) { @@ -1627,51 +1627,51 @@ static float evaluate_driver (ChannelDriver *driver, const float evaltime) if (driver->type == DRIVER_TYPE_MAX) { /* max? */ if (tmp_val > value) - value= tmp_val; + value = tmp_val; } else { /* min? */ if (tmp_val < value) - value= tmp_val; + value = tmp_val; } } else { /* first item - make this the baseline for comparisons */ - value= tmp_val; + value = tmp_val; } } /* store value in driver */ - driver->curval= value; + driver->curval = value; } - break; + break; case DRIVER_TYPE_PYTHON: /* expression */ { #ifdef WITH_PYTHON /* check for empty or invalid expression */ if ( (driver->expression[0] == '\0') || - (driver->flag & DRIVER_FLAG_INVALID) ) + (driver->flag & DRIVER_FLAG_INVALID) ) { - driver->curval= 0.0f; + driver->curval = 0.0f; } else { /* this evaluates the expression using Python, and returns its result: - * - on errors it reports, then returns 0.0f + * - on errors it reports, then returns 0.0f */ - driver->curval= BPY_driver_exec(driver, evaltime); + driver->curval = BPY_driver_exec(driver, evaltime); } #else /* WITH_PYTHON*/ - (void)evaltime; + (void)evaltime; #endif /* WITH_PYTHON*/ } - break; + break; default: { /* special 'hack' - just use stored value * This is currently used as the mechanism which allows animated settings to be able - * to be changed via the UI. + * to be changed via the UI. */ } } @@ -1691,127 +1691,127 @@ void correct_bezpart(float v1[2], float v2[2], float v3[2], float v4[2]) float h1[2], h2[2], len1, len2, len, fac; /* calculate handle deltas */ - h1[0]= v1[0] - v2[0]; - h1[1]= v1[1] - v2[1]; + h1[0] = v1[0] - v2[0]; + h1[1] = v1[1] - v2[1]; - h2[0]= v4[0] - v3[0]; - h2[1]= v4[1] - v3[1]; + h2[0] = v4[0] - v3[0]; + h2[1] = v4[1] - v3[1]; /* calculate distances: - * - len = span of time between keyframes + * - len = span of time between keyframes * - len1 = length of handle of start key - * - len2 = length of handle of end key + * - len2 = length of handle of end key */ - len= v4[0]- v1[0]; - len1= fabsf(h1[0]); - len2= fabsf(h2[0]); + len = v4[0] - v1[0]; + len1 = fabsf(h1[0]); + len2 = fabsf(h2[0]); /* if the handles have no length, no need to do any corrections */ - if ((len1+len2) == 0.0f) + if ((len1 + len2) == 0.0f) return; /* the two handles cross over each other, so force them * apart using the proportion they overlap */ - if ((len1+len2) > len) { - fac= len / (len1+len2); + if ((len1 + len2) > len) { + fac = len / (len1 + len2); - v2[0]= (v1[0] - fac*h1[0]); - v2[1]= (v1[1] - fac*h1[1]); + v2[0] = (v1[0] - fac * h1[0]); + v2[1] = (v1[1] - fac * h1[1]); - v3[0]= (v4[0] - fac*h2[0]); - v3[1]= (v4[1] - fac*h2[1]); + v3[0] = (v4[0] - fac * h2[0]); + v3[1] = (v4[1] - fac * h2[1]); } } /* find root ('zero') */ -static int findzero (float x, float q0, float q1, float q2, float q3, float *o) +static int findzero(float x, float q0, float q1, float q2, float q3, float *o) { double c0, c1, c2, c3, a, b, c, p, q, d, t, phi; - int nr= 0; + int nr = 0; - c0= q0 - x; - c1= 3.0f * (q1 - q0); - c2= 3.0f * (q0 - 2.0f*q1 + q2); - c3= q3 - q0 + 3.0f * (q1 - q2); + c0 = q0 - x; + c1 = 3.0f * (q1 - q0); + c2 = 3.0f * (q0 - 2.0f * q1 + q2); + c3 = q3 - q0 + 3.0f * (q1 - q2); if (c3 != 0.0) { - a= c2/c3; - b= c1/c3; - c= c0/c3; - a= a/3; - - p= b/3 - a*a; - q= (2*a*a*a - a*b + c) / 2; - d= q*q + p*p*p; + a = c2 / c3; + b = c1 / c3; + c = c0 / c3; + a = a / 3; + + p = b / 3 - a * a; + q = (2 * a * a * a - a * b + c) / 2; + d = q * q + p * p * p; if (d > 0.0) { - t= sqrt(d); - o[0]= (float)(sqrt3d(-q+t) + sqrt3d(-q-t) - a); + t = sqrt(d); + o[0] = (float)(sqrt3d(-q + t) + sqrt3d(-q - t) - a); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } else if (d == 0.0) { - t= sqrt3d(-q); - o[0]= (float)(2*t - a); + t = sqrt3d(-q); + o[0] = (float)(2 * t - a); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; - o[nr]= (float)(-t-a); + o[nr] = (float)(-t - a); - if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1; else return nr; } else { - phi= acos(-q / sqrt(-(p*p*p))); - t= sqrt(-p); - p= cos(phi/3); - q= sqrt(3 - 3*p*p); - o[0]= (float)(2*t*p - a); + phi = acos(-q / sqrt(-(p * p * p))); + t = sqrt(-p); + p = cos(phi / 3); + q = sqrt(3 - 3 * p * p); + o[0] = (float)(2 * t * p - a); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; - o[nr]= (float)(-t * (p + q) - a); + o[nr] = (float)(-t * (p + q) - a); if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) nr++; - o[nr]= (float)(-t * (p - q) - a); + o[nr] = (float)(-t * (p - q) - a); - if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1; else return nr; } } else { - a=c2; - b=c1; - c=c0; + a = c2; + b = c1; + c = c0; if (a != 0.0) { // discriminant - p= b*b - 4*a*c; + p = b * b - 4 * a * c; if (p > 0) { - p= sqrt(p); - o[0]= (float)((-b-p) / (2 * a)); + p = sqrt(p); + o[0] = (float)((-b - p) / (2 * a)); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) nr++; - o[nr]= (float)((-b+p)/(2*a)); + o[nr] = (float)((-b + p) / (2 * a)); - if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr+1; + if ((o[nr] >= (float)SMALL) && (o[nr] <= 1.000001f)) return nr + 1; else return nr; } else if (p == 0) { - o[0]= (float)(-b / (2 * a)); + o[0] = (float)(-b / (2 * a)); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } } else if (b != 0.0) { - o[0]= (float)(-c/b); + o[0] = (float)(-c / b); if ((o[0] >= (float)SMALL) && (o[0] <= 1.000001f)) return 1; else return 0; } else if (c == 0.0) { - o[0]= 0.0; + o[0] = 0.0; return 1; } @@ -1819,36 +1819,36 @@ static int findzero (float x, float q0, float q1, float q2, float q3, float *o) } } -static void berekeny (float f1, float f2, float f3, float f4, float *o, int b) +static void berekeny(float f1, float f2, float f3, float f4, float *o, int b) { float t, c0, c1, c2, c3; int a; - c0= f1; - c1= 3.0f * (f2 - f1); - c2= 3.0f * (f1 - 2.0f*f2 + f3); - c3= f4 - f1 + 3.0f * (f2 - f3); - - for (a=0; a < b; a++) { - t= o[a]; - o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3; + c0 = f1; + c1 = 3.0f * (f2 - f1); + c2 = 3.0f * (f1 - 2.0f * f2 + f3); + c3 = f4 - f1 + 3.0f * (f2 - f3); + + for (a = 0; a < b; a++) { + t = o[a]; + o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3; } } #if 0 -static void berekenx (float *f, float *o, int b) +static void berekenx(float *f, float *o, int b) { float t, c0, c1, c2, c3; int a; - c0= f[0]; - c1= 3.0f * (f[3] - f[0]); - c2= 3.0f * (f[0] - 2.0f*f[3] + f[6]); - c3= f[9] - f[0] + 3.0f * (f[3] - f[6]); - - for (a=0; a < b; a++) { - t= o[a]; - o[a]= c0 + t*c1 + t*t*c2 + t*t*t*c3; + c0 = f[0]; + c1 = 3.0f * (f[3] - f[0]); + c2 = 3.0f * (f[0] - 2.0f * f[3] + f[6]); + c3 = f[9] - f[0] + 3.0f * (f[3] - f[6]); + + for (a = 0; a < b; a++) { + t = o[a]; + o[a] = c0 + t * c1 + t * t * c2 + t * t * t * c3; } } #endif @@ -1857,7 +1857,7 @@ static void berekenx (float *f, float *o, int b) /* -------------------------- */ /* Calculate F-Curve value for 'evaltime' using BezTriple keyframes */ -static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltime) +static float fcurve_eval_keyframes(FCurve *fcu, BezTriple *bezts, float evaltime) { BezTriple *bezt, *prevbezt, *lastbezt; float v1[2], v2[2], v3[2], v4[2], opl[32], dx, fac; @@ -1866,37 +1866,37 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim float cvalue = 0.0f; /* get pointers */ - a= fcu->totvert-1; - prevbezt= bezts; - bezt= prevbezt+1; - lastbezt= prevbezt + a; + a = fcu->totvert - 1; + prevbezt = bezts; + bezt = prevbezt + 1; + lastbezt = prevbezt + a; /* evaluation time at or past endpoints? */ if (prevbezt->vec[1][0] >= evaltime) { /* before or on first keyframe */ if ( (fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (prevbezt->ipo != BEZT_IPO_CONST) && - !(fcu->flag & FCURVE_DISCRETE_VALUES) ) + !(fcu->flag & FCURVE_DISCRETE_VALUES) ) { /* linear or bezier interpolation */ - if (prevbezt->ipo==BEZT_IPO_LIN) { + if (prevbezt->ipo == BEZT_IPO_LIN) { /* Use the next center point instead of our own handle for * linear interpolated extrapolate */ if (fcu->totvert == 1) { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } else { - bezt = prevbezt+1; - dx= prevbezt->vec[1][0] - evaltime; - fac= bezt->vec[1][0] - prevbezt->vec[1][0]; + bezt = prevbezt + 1; + dx = prevbezt->vec[1][0] - evaltime; + fac = bezt->vec[1][0] - prevbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac; - cvalue= prevbezt->vec[1][1] - (fac * dx); + fac = (bezt->vec[1][1] - prevbezt->vec[1][1]) / fac; + cvalue = prevbezt->vec[1][1] - (fac * dx); } else { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } } @@ -1904,16 +1904,16 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* Use the first handle (earlier) of first BezTriple to calculate the * gradient and thus the value of the curve at evaltime */ - dx= prevbezt->vec[1][0] - evaltime; - fac= prevbezt->vec[1][0] - prevbezt->vec[0][0]; + dx = prevbezt->vec[1][0] - evaltime; + fac = prevbezt->vec[1][0] - prevbezt->vec[0][0]; /* prevent division by zero */ if (fac) { - fac= (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac; - cvalue= prevbezt->vec[1][1] - (fac * dx); + fac = (prevbezt->vec[1][1] - prevbezt->vec[0][1]) / fac; + cvalue = prevbezt->vec[1][1] - (fac * dx); } else { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } } @@ -1921,34 +1921,34 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation, * so just extend first keyframe's value */ - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } else if (lastbezt->vec[1][0] <= evaltime) { /* after or on last keyframe */ if ( (fcu->extend == FCURVE_EXTRAPOLATE_LINEAR) && (lastbezt->ipo != BEZT_IPO_CONST) && - !(fcu->flag & FCURVE_DISCRETE_VALUES) ) + !(fcu->flag & FCURVE_DISCRETE_VALUES) ) { /* linear or bezier interpolation */ - if (lastbezt->ipo==BEZT_IPO_LIN) { + if (lastbezt->ipo == BEZT_IPO_LIN) { /* Use the next center point instead of our own handle for * linear interpolated extrapolate */ if (fcu->totvert == 1) { - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } else { prevbezt = lastbezt - 1; - dx= evaltime - lastbezt->vec[1][0]; - fac= lastbezt->vec[1][0] - prevbezt->vec[1][0]; + dx = evaltime - lastbezt->vec[1][0]; + fac = lastbezt->vec[1][0] - prevbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac; - cvalue= lastbezt->vec[1][1] + (fac * dx); + fac = (lastbezt->vec[1][1] - prevbezt->vec[1][1]) / fac; + cvalue = lastbezt->vec[1][1] + (fac * dx); } else { - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } } } @@ -1956,16 +1956,16 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* Use the gradient of the second handle (later) of last BezTriple to calculate the * gradient and thus the value of the curve at evaltime */ - dx= evaltime - lastbezt->vec[1][0]; - fac= lastbezt->vec[2][0] - lastbezt->vec[1][0]; + dx = evaltime - lastbezt->vec[1][0]; + fac = lastbezt->vec[2][0] - lastbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac; - cvalue= lastbezt->vec[1][1] + (fac * dx); + fac = (lastbezt->vec[2][1] - lastbezt->vec[1][1]) / fac; + cvalue = lastbezt->vec[1][1] + (fac * dx); } else { - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } } } @@ -1973,57 +1973,57 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim /* constant (BEZT_IPO_HORIZ) extrapolation or constant interpolation, * so just extend last keyframe's value */ - cvalue= lastbezt->vec[1][1]; + cvalue = lastbezt->vec[1][1]; } } else { /* evaltime occurs somewhere in the middle of the curve */ - for (a=0; prevbezt && bezt && (a < fcu->totvert-1); a++, prevbezt=bezt, bezt++) { + for (a = 0; prevbezt && bezt && (a < fcu->totvert - 1); a++, prevbezt = bezt, bezt++) { /* use if the key is directly on the frame, rare cases this is needed else we get 0.0 instead. */ if (fabsf(bezt->vec[1][0] - evaltime) < SMALL_NUMBER) { - cvalue= bezt->vec[1][1]; + cvalue = bezt->vec[1][1]; } /* evaltime occurs within the interval defined by these two keyframes */ else if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) { /* value depends on interpolation mode */ if ((prevbezt->ipo == BEZT_IPO_CONST) || (fcu->flag & FCURVE_DISCRETE_VALUES)) { /* constant (evaltime not relevant, so no interpolation needed) */ - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } else if (prevbezt->ipo == BEZT_IPO_LIN) { /* linear - interpolate between values of the two keyframes */ - fac= bezt->vec[1][0] - prevbezt->vec[1][0]; + fac = bezt->vec[1][0] - prevbezt->vec[1][0]; /* prevent division by zero */ if (fac) { - fac= (evaltime - prevbezt->vec[1][0]) / fac; - cvalue= prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1])); + fac = (evaltime - prevbezt->vec[1][0]) / fac; + cvalue = prevbezt->vec[1][1] + (fac * (bezt->vec[1][1] - prevbezt->vec[1][1])); } else { - cvalue= prevbezt->vec[1][1]; + cvalue = prevbezt->vec[1][1]; } } else { /* bezier interpolation */ - /* v1,v2 are the first keyframe and its 2nd handle */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; - v2[0]= prevbezt->vec[2][0]; - v2[1]= prevbezt->vec[2][1]; - /* v3,v4 are the last keyframe's 1st handle + the last keyframe */ - v3[0]= bezt->vec[0][0]; - v3[1]= bezt->vec[0][1]; - v4[0]= bezt->vec[1][0]; - v4[1]= bezt->vec[1][1]; + /* v1,v2 are the first keyframe and its 2nd handle */ + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; + v2[0] = prevbezt->vec[2][0]; + v2[1] = prevbezt->vec[2][1]; + /* v3,v4 are the last keyframe's 1st handle + the last keyframe */ + v3[0] = bezt->vec[0][0]; + v3[1] = bezt->vec[0][1]; + v4[0] = bezt->vec[1][0]; + v4[1] = bezt->vec[1][1]; /* adjust handles so that they don't overlap (forming a loop) */ correct_bezpart(v1, v2, v3, v4); /* try to get a value for this position - if failure, try another set of points */ - b= findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl); + b = findzero(evaltime, v1[0], v2[0], v3[0], v4[0], opl); if (b) { berekeny(v1[1], v2[1], v3[1], v4[1], opl, 1); - cvalue= opl[0]; + cvalue = opl[0]; break; } } @@ -2036,35 +2036,35 @@ static float fcurve_eval_keyframes (FCurve *fcu, BezTriple *bezts, float evaltim } /* Calculate F-Curve value for 'evaltime' using FPoint samples */ -static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime) +static float fcurve_eval_samples(FCurve *fcu, FPoint *fpts, float evaltime) { FPoint *prevfpt, *lastfpt, *fpt; - float cvalue= 0.0f; + float cvalue = 0.0f; /* get pointers */ - prevfpt= fpts; - lastfpt= prevfpt + fcu->totvert-1; + prevfpt = fpts; + lastfpt = prevfpt + fcu->totvert - 1; /* evaluation time at or past endpoints? */ if (prevfpt->vec[0] >= evaltime) { /* before or on first sample, so just extend value */ - cvalue= prevfpt->vec[1]; + cvalue = prevfpt->vec[1]; } else if (lastfpt->vec[0] <= evaltime) { /* after or on last sample, so just extend value */ - cvalue= lastfpt->vec[1]; + cvalue = lastfpt->vec[1]; } else { - float t= (float)abs(evaltime - (int)evaltime); + float t = (float)abs(evaltime - (int)evaltime); /* find the one on the right frame (assume that these are spaced on 1-frame intervals) */ - fpt= prevfpt + (int)(evaltime - prevfpt->vec[0]); + fpt = prevfpt + (int)(evaltime - prevfpt->vec[0]); /* if not exactly on the frame, perform linear interpolation with the next one */ if (t != 0.0f) - cvalue= interpf(fpt->vec[1], (fpt+1)->vec[1], t); + cvalue = interpf(fpt->vec[1], (fpt + 1)->vec[1], t); else - cvalue= fpt->vec[1]; + cvalue = fpt->vec[1]; } /* return value */ @@ -2078,7 +2078,7 @@ static float fcurve_eval_samples (FCurve *fcu, FPoint *fpts, float evaltime) */ float evaluate_fcurve(FCurve *fcu, float evaltime) { - float cvalue= 0.0f; + float cvalue = 0.0f; float devaltime; /* if there is a driver (only if this F-Curve is acting as 'driver'), evaluate it to find value to use as "evaltime" @@ -2087,20 +2087,20 @@ float evaluate_fcurve(FCurve *fcu, float evaltime) */ if (fcu->driver) { /* evaltime now serves as input for the curve */ - evaltime= cvalue= evaluate_driver(fcu->driver, evaltime); + evaltime = cvalue = evaluate_driver(fcu->driver, evaltime); } /* evaluate modifiers which modify time to evaluate the base curve at */ - devaltime= evaluate_time_fmodifiers(&fcu->modifiers, fcu, cvalue, evaltime); + devaltime = evaluate_time_fmodifiers(&fcu->modifiers, fcu, cvalue, evaltime); /* evaluate curve-data * - 'devaltime' instead of 'evaltime', as this is the time that the last time-modifying * F-Curve modifier on the stack requested the curve to be evaluated at */ if (fcu->bezt) - cvalue= fcurve_eval_keyframes(fcu, fcu->bezt, devaltime); + cvalue = fcurve_eval_keyframes(fcu, fcu->bezt, devaltime); else if (fcu->fpt) - cvalue= fcurve_eval_samples(fcu, fcu->fpt, devaltime); + cvalue = fcurve_eval_samples(fcu, fcu->fpt, devaltime); /* evaluate modifiers */ evaluate_value_fmodifiers(&fcu->modifiers, fcu, &cvalue, evaltime); @@ -2109,7 +2109,7 @@ float evaluate_fcurve(FCurve *fcu, float evaltime) * here so that the curve can be sampled correctly */ if (fcu->flag & FCURVE_INT_VALUES) - cvalue= floorf(cvalue + 0.5f); + cvalue = floorf(cvalue + 0.5f); /* return evaluated value */ return cvalue; @@ -2125,7 +2125,7 @@ void calculate_fcurve(FCurve *fcu, float ctime) list_has_suitable_fmodifier(&fcu->modifiers, 0, FMI_TYPE_GENERATE_CURVE)) { /* calculate and set curval (evaluates driver too if necessary) */ - fcu->curval= evaluate_fcurve(fcu, ctime); + fcu->curval = evaluate_fcurve(fcu, ctime); } } diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c index 92c73b23239..59c8a529d85 100644 --- a/source/blender/blenkernel/intern/fmodifier.c +++ b/source/blender/blenkernel/intern/fmodifier.c @@ -68,14 +68,14 @@ */ /* Template for type-info data: - * - make a copy of this when creating new modifiers, and just change the functions - * pointed to as necessary - * - although the naming of functions doesn't matter, it would help for code - * readability, to follow the same naming convention as is presented here - * - any functions that a constraint doesn't need to define, don't define - * for such cases, just use NULL - * - these should be defined after all the functions have been defined, so that - * forward-definitions/prototypes don't need to be used! + * - make a copy of this when creating new modifiers, and just change the functions + * pointed to as necessary + * - although the naming of functions doesn't matter, it would help for code + * readability, to follow the same naming convention as is presented here + * - any functions that a constraint doesn't need to define, don't define + * for such cases, just use NULL + * - these should be defined after all the functions have been defined, so that + * forward-definitions/prototypes don't need to be used! * - keep this copy #if-def'd so that future constraints can get based off this */ #if 0 @@ -99,74 +99,74 @@ static FModifierTypeInfo FMI_MODNAME = { /* Generator F-Curve Modifier --------------------------- */ /* Generators available: - * 1) simple polynomial generator: + * 1) simple polynomial generator: * - Exanded form - (y = C[0]*(x^(n)) + C[1]*(x^(n-1)) + ... + C[n]) * - Factorized form - (y = (C[0][0]*x + C[0][1]) * (C[1][0]*x + C[1][1]) * ... * (C[n][0]*x + C[n][1])) */ -static void fcm_generator_free (FModifier *fcm) +static void fcm_generator_free(FModifier *fcm) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; /* free polynomial coefficients array */ if (data->coefficients) MEM_freeN(data->coefficients); } -static void fcm_generator_copy (FModifier *fcm, FModifier *src) +static void fcm_generator_copy(FModifier *fcm, FModifier *src) { - FMod_Generator *gen= (FMod_Generator *)fcm->data; - FMod_Generator *ogen= (FMod_Generator *)src->data; + FMod_Generator *gen = (FMod_Generator *)fcm->data; + FMod_Generator *ogen = (FMod_Generator *)src->data; /* copy coefficients array? */ if (ogen->coefficients) - gen->coefficients= MEM_dupallocN(ogen->coefficients); + gen->coefficients = MEM_dupallocN(ogen->coefficients); } -static void fcm_generator_new_data (void *mdata) +static void fcm_generator_new_data(void *mdata) { - FMod_Generator *data= (FMod_Generator *)mdata; + FMod_Generator *data = (FMod_Generator *)mdata; float *cp; /* set default generator to be linear 0-1 (gradient = 1, y-offset = 0) */ - data->poly_order= 1; - data->arraysize= 2; - cp= data->coefficients= MEM_callocN(sizeof(float)*2, "FMod_Generator_Coefs"); + data->poly_order = 1; + data->arraysize = 2; + cp = data->coefficients = MEM_callocN(sizeof(float) * 2, "FMod_Generator_Coefs"); cp[0] = 0; // y-offset cp[1] = 1; // gradient } -static void fcm_generator_verify (FModifier *fcm) +static void fcm_generator_verify(FModifier *fcm) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; /* requirements depend on mode */ switch (data->mode) { case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */ { /* arraysize needs to be order+1, so resize if not */ - if (data->arraysize != (data->poly_order+1)) { + if (data->arraysize != (data->poly_order + 1)) { float *nc; /* make new coefficients array, and copy over as much data as can fit */ - nc= MEM_callocN(sizeof(float)*(data->poly_order+1), "FMod_Generator_Coefs"); + nc = MEM_callocN(sizeof(float) * (data->poly_order + 1), "FMod_Generator_Coefs"); if (data->coefficients) { - if ((int)data->arraysize > (data->poly_order+1)) - memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order+1)); + if ((int)data->arraysize > (data->poly_order + 1)) + memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order + 1)); else - memcpy(nc, data->coefficients, sizeof(float)*data->arraysize); + memcpy(nc, data->coefficients, sizeof(float) * data->arraysize); /* free the old data */ MEM_freeN(data->coefficients); } /* set the new data */ - data->coefficients= nc; - data->arraysize= data->poly_order+1; + data->coefficients = nc; + data->arraysize = data->poly_order + 1; } } - break; + break; case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* expanded polynomial expression */ { @@ -175,30 +175,30 @@ static void fcm_generator_verify (FModifier *fcm) float *nc; /* make new coefficients array, and copy over as much data as can fit */ - nc= MEM_callocN(sizeof(float)*(data->poly_order*2), "FMod_Generator_Coefs"); + nc = MEM_callocN(sizeof(float) * (data->poly_order * 2), "FMod_Generator_Coefs"); if (data->coefficients) { if (data->arraysize > (unsigned int)(data->poly_order * 2)) - memcpy(nc, data->coefficients, sizeof(float)*(data->poly_order * 2)); + memcpy(nc, data->coefficients, sizeof(float) * (data->poly_order * 2)); else - memcpy(nc, data->coefficients, sizeof(float)*data->arraysize); + memcpy(nc, data->coefficients, sizeof(float) * data->arraysize); /* free the old data */ MEM_freeN(data->coefficients); } /* set the new data */ - data->coefficients= nc; - data->arraysize= data->poly_order * 2; + data->coefficients = nc; + data->arraysize = data->poly_order * 2; } } - break; + break; } } -static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; /* behavior depends on mode * NOTE: the data in its default state is fine too @@ -207,23 +207,23 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float * case FCM_GENERATOR_POLYNOMIAL: /* expanded polynomial expression */ { /* we overwrite cvalue with the sum of the polynomial */ - float *powers = MEM_callocN(sizeof(float)*data->arraysize, "Poly Powers"); - float value= 0.0f; + float *powers = MEM_callocN(sizeof(float) * data->arraysize, "Poly Powers"); + float value = 0.0f; unsigned int i; /* for each x^n, precalculate value based on previous one first... this should be * faster that calling pow() for each entry */ - for (i=0; i < data->arraysize; i++) { + for (i = 0; i < data->arraysize; i++) { /* first entry is x^0 = 1, otherwise, calculate based on previous */ if (i) - powers[i]= powers[i-1] * evaltime; + powers[i] = powers[i - 1] * evaltime; else - powers[0]= 1; + powers[0] = 1; } /* for each coefficient, add to value, which we'll write to *cvalue in one go */ - for (i=0; i < data->arraysize; i++) + for (i = 0; i < data->arraysize; i++) value += data->coefficients[i] * powers[i]; /* only if something changed, write *cvalue in one go */ @@ -231,33 +231,33 @@ static void fcm_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float * if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else - *cvalue= value; + *cvalue = value; } /* cleanup */ if (powers) MEM_freeN(powers); } - break; + break; case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial */ { - float value= 1.0f, *cp=NULL; + float value = 1.0f, *cp = NULL; unsigned int i; /* for each coefficient pair, solve for that bracket before accumulating in value by multiplying */ - for (cp=data->coefficients, i=0; (cp) && (i < (unsigned int)data->poly_order); cp+=2, i++) - value *= (cp[0]*evaltime + cp[1]); + for (cp = data->coefficients, i = 0; (cp) && (i < (unsigned int)data->poly_order); cp += 2, i++) + value *= (cp[0] * evaltime + cp[1]); /* only if something changed, write *cvalue in one go */ if (data->poly_order) { if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else - *cvalue= value; + *cvalue = value; } } - break; + break; } } @@ -279,7 +279,7 @@ static FModifierTypeInfo FMI_GENERATOR = { /* Built-In Function Generator F-Curve Modifier --------------------------- */ /* This uses the general equation for equations: - * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset + * y = amplitude * fn(phase_multiplier*x + phase_offset) + y_offset * * where amplitude, phase_multiplier/offset, y_offset are user-defined coefficients, * x is the evaluation 'time', and 'y' is the resultant value @@ -288,20 +288,20 @@ static FModifierTypeInfo FMI_GENERATOR = { * sin, cos, tan, sinc (normalised sin), natural log, square root */ -static void fcm_fn_generator_new_data (void *mdata) +static void fcm_fn_generator_new_data(void *mdata) { - FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)mdata; + FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)mdata; /* set amplitude and phase multiplier to 1.0f so that something is generated */ - data->amplitude= 1.0f; - data->phase_multiplier= 1.0f; + data->amplitude = 1.0f; + data->phase_multiplier = 1.0f; } /* Unary 'normalised sine' function - * y = sin(PI + x) / (PI * x), + * y = sin(PI + x) / (PI * x), * except for x = 0 when y = 1. */ -static double sinc (double x) +static double sinc(double x) { if (fabs(x) < 0.0001) return 1.0; @@ -309,10 +309,10 @@ static double sinc (double x) return sin(M_PI * x) / (M_PI * x); } -static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_fn_generator_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_FunctionGenerator *data= (FMod_FunctionGenerator *)fcm->data; - double arg= data->phase_multiplier*evaltime + data->phase_offset; + FMod_FunctionGenerator *data = (FMod_FunctionGenerator *)fcm->data; + double arg = data->phase_multiplier * evaltime + data->phase_offset; double (*fn)(double v) = NULL; /* get function pointer to the func to use: @@ -321,13 +321,13 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa switch (data->type) { /* simple ones */ case FCM_GENERATOR_FN_SIN: /* sine wave */ - fn= sin; + fn = sin; break; case FCM_GENERATOR_FN_COS: /* cosine wave */ - fn= cos; + fn = cos; break; case FCM_GENERATOR_FN_SINC: /* normalised sine wave */ - fn= sinc; + fn = sinc; break; /* validation required */ @@ -336,36 +336,36 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* check that argument is not on one of the discontinuities (i.e. 90deg, 270 deg, etc) */ if (IS_EQ(fmod((arg - M_PI_2), M_PI), 0.0)) { if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) - *cvalue = 0.0f; /* no value possible here */ + *cvalue = 0.0f; /* no value possible here */ } else - fn= tan; + fn = tan; } - break; + break; case FCM_GENERATOR_FN_LN: /* natural log */ { /* check that value is greater than 1? */ if (arg > 1.0) { - fn= log; + fn = log; } else { if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) - *cvalue = 0.0f; /* no value possible here */ + *cvalue = 0.0f; /* no value possible here */ } } - break; + break; case FCM_GENERATOR_FN_SQRT: /* square root */ { /* no negative numbers */ if (arg > 0.0) { - fn= sqrt; + fn = sqrt; } else { if ((data->flag & FCM_GENERATOR_ADDITIVE) == 0) - *cvalue = 0.0f; /* no value possible here */ + *cvalue = 0.0f; /* no value possible here */ } } - break; + break; default: printf("Invalid Function-Generator for F-Modifier - %d\n", data->type); @@ -373,12 +373,12 @@ static void fcm_fn_generator_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, floa /* execute function callback to set value if appropriate */ if (fn) { - float value= (float)(data->amplitude*(float)fn(arg) + data->value_offset); + float value = (float)(data->amplitude * (float)fn(arg) + data->value_offset); if (data->flag & FCM_GENERATOR_ADDITIVE) *cvalue += value; else - *cvalue= value; + *cvalue = value; } } @@ -399,37 +399,37 @@ static FModifierTypeInfo FMI_FN_GENERATOR = { /* Envelope F-Curve Modifier --------------------------- */ -static void fcm_envelope_free (FModifier *fcm) +static void fcm_envelope_free(FModifier *fcm) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; /* free envelope data array */ if (env->data) MEM_freeN(env->data); } -static void fcm_envelope_copy (FModifier *fcm, FModifier *src) +static void fcm_envelope_copy(FModifier *fcm, FModifier *src) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; - FMod_Envelope *oenv= (FMod_Envelope *)src->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; + FMod_Envelope *oenv = (FMod_Envelope *)src->data; /* copy envelope data array */ if (oenv->data) - env->data= MEM_dupallocN(oenv->data); + env->data = MEM_dupallocN(oenv->data); } -static void fcm_envelope_new_data (void *mdata) +static void fcm_envelope_new_data(void *mdata) { - FMod_Envelope *env= (FMod_Envelope *)mdata; + FMod_Envelope *env = (FMod_Envelope *)mdata; /* set default min/max ranges */ - env->min= -1.0f; - env->max= 1.0f; + env->min = -1.0f; + env->max = 1.0f; } -static void fcm_envelope_verify (FModifier *fcm) +static void fcm_envelope_verify(FModifier *fcm) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; /* if the are points, perform bubble-sort on them, as user may have changed the order */ if (env->data) { @@ -437,44 +437,44 @@ static void fcm_envelope_verify (FModifier *fcm) } } -static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_envelope_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed, *prevfed, *lastfed; - float min=0.0f, max=0.0f, fac=0.0f; + float min = 0.0f, max = 0.0f, fac = 0.0f; int a; /* get pointers */ if (env->data == NULL) return; - prevfed= env->data; - fed= prevfed + 1; - lastfed= prevfed + (env->totvert-1); + prevfed = env->data; + fed = prevfed + 1; + lastfed = prevfed + (env->totvert - 1); /* get min/max values for envelope at evaluation time (relative to mid-value) */ if (prevfed->time >= evaltime) { /* before or on first sample, so just extend value */ - min= prevfed->min; - max= prevfed->max; + min = prevfed->min; + max = prevfed->max; } else if (lastfed->time <= evaltime) { /* after or on last sample, so just extend value */ - min= lastfed->min; - max= lastfed->max; + min = lastfed->min; + max = lastfed->max; } else { /* evaltime occurs somewhere between segments */ // TODO: implement binary search for this to make it faster? - for (a=0; prevfed && fed && (a < env->totvert-1); a++, prevfed=fed, fed++) { + for (a = 0; prevfed && fed && (a < env->totvert - 1); a++, prevfed = fed, fed++) { /* evaltime occurs within the interval defined by these two envelope points */ if ((prevfed->time <= evaltime) && (fed->time >= evaltime)) { float afac, bfac, diff; - diff= fed->time - prevfed->time; - afac= (evaltime - prevfed->time) / diff; - bfac= (fed->time - evaltime) / diff; + diff = fed->time - prevfed->time; + afac = (evaltime - prevfed->time) / diff; + bfac = (fed->time - evaltime) / diff; - min= bfac*prevfed->min + afac*fed->min; - max= bfac*prevfed->max + afac*fed->max; + min = bfac * prevfed->min + afac * fed->min; + max = bfac * prevfed->max + afac * fed->max; break; } @@ -485,8 +485,8 @@ static void fcm_envelope_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *c * - fac is the ratio of how the current y-value corresponds to the reference range * - thus, the new value is found by mapping the old range to the new! */ - fac= (*cvalue - (env->midval + env->min)) / (env->max - env->min); - *cvalue= min + fac*(max - min); + fac = (*cvalue - (env->midval + env->min)) / (env->max - env->min); + *cvalue = min + fac * (max - min); } static FModifierTypeInfo FMI_ENVELOPE = { @@ -520,23 +520,23 @@ static FModifierTypeInfo FMI_ENVELOPE = { /* temp data used during evaluation */ typedef struct tFCMED_Cycles { - float cycyofs; /* y-offset to apply */ + float cycyofs; /* y-offset to apply */ } tFCMED_Cycles; -static void fcm_cycles_new_data (void *mdata) +static void fcm_cycles_new_data(void *mdata) { - FMod_Cycles *data= (FMod_Cycles *)mdata; + FMod_Cycles *data = (FMod_Cycles *)mdata; /* turn on cycles by default */ - data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC; + data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC; } -static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime) +static float fcm_cycles_time(FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime) { - FMod_Cycles *data= (FMod_Cycles *)fcm->data; - float prevkey[2], lastkey[2], cycyofs=0.0f; - short side=0, mode=0; - int cycles=0, ofs=0; + FMod_Cycles *data = (FMod_Cycles *)fcm->data; + float prevkey[2], lastkey[2], cycyofs = 0.0f; + short side = 0, mode = 0; + int cycles = 0, ofs = 0; /* check if modifier is first in stack, otherwise disable ourself... */ // FIXME... @@ -547,24 +547,24 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), /* calculate new evaltime due to cyclic interpolation */ if (fcu && fcu->bezt) { - BezTriple *prevbezt= fcu->bezt; - BezTriple *lastbezt= prevbezt + fcu->totvert-1; + BezTriple *prevbezt = fcu->bezt; + BezTriple *lastbezt = prevbezt + fcu->totvert - 1; - prevkey[0]= prevbezt->vec[1][0]; - prevkey[1]= prevbezt->vec[1][1]; + prevkey[0] = prevbezt->vec[1][0]; + prevkey[1] = prevbezt->vec[1][1]; - lastkey[0]= lastbezt->vec[1][0]; - lastkey[1]= lastbezt->vec[1][1]; + lastkey[0] = lastbezt->vec[1][0]; + lastkey[1] = lastbezt->vec[1][1]; } else if (fcu && fcu->fpt) { - FPoint *prevfpt= fcu->fpt; - FPoint *lastfpt= prevfpt + fcu->totvert-1; + FPoint *prevfpt = fcu->fpt; + FPoint *lastfpt = prevfpt + fcu->totvert - 1; - prevkey[0]= prevfpt->vec[0]; - prevkey[1]= prevfpt->vec[1]; + prevkey[0] = prevfpt->vec[0]; + prevkey[1] = prevfpt->vec[1]; - lastkey[0]= lastfpt->vec[0]; - lastkey[1]= lastfpt->vec[1]; + lastkey[0] = lastfpt->vec[0]; + lastkey[1] = lastfpt->vec[1]; } else return evaltime; @@ -575,18 +575,18 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), */ if (evaltime < prevkey[0]) { if (data->before_mode) { - side= -1; - mode= data->before_mode; - cycles= data->before_cycles; - ofs= prevkey[0]; + side = -1; + mode = data->before_mode; + cycles = data->before_cycles; + ofs = prevkey[0]; } } else if (evaltime > lastkey[0]) { if (data->after_mode) { - side= 1; - mode= data->after_mode; - cycles= data->after_cycles; - ofs= lastkey[0]; + side = 1; + mode = data->after_mode; + cycles = data->after_cycles; + ofs = lastkey[0]; } } if ((ELEM(0, side, mode))) @@ -594,22 +594,22 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), /* find relative place within a cycle */ { - float cycdx=0, cycdy=0; - float cycle= 0, cyct=0; + float cycdx = 0, cycdy = 0; + float cycle = 0, cyct = 0; /* calculate period and amplitude (total height) of a cycle */ - cycdx= lastkey[0] - prevkey[0]; - cycdy= lastkey[1] - prevkey[1]; + cycdx = lastkey[0] - prevkey[0]; + cycdy = lastkey[1] - prevkey[1]; /* check if cycle is infinitely small, to be point of being impossible to use */ if (cycdx == 0) return evaltime; /* calculate the 'number' of the cycle */ - cycle= ((float)side * (evaltime - ofs) / cycdx); + cycle = ((float)side * (evaltime - ofs) / cycdx); /* calculate the time inside the cycle */ - cyct= fmod(evaltime - ofs, cycdx); + cyct = fmod(evaltime - ofs, cycdx); /* check that cyclic is still enabled for the specified time */ if (cycles == 0) { @@ -641,19 +641,19 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), evaltime = (side == 1 ? prevkey[0] : lastkey[0]); } /* calculate where in the cycle we are (overwrite evaltime to reflect this) */ - else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle+1) % 2)) { + else if ((mode == FCM_EXTRAPOLATE_MIRROR) && ((int)(cycle + 1) % 2)) { /* when 'mirror' option is used and cycle number is odd, this cycle is played in reverse * - for 'before' extrapolation, we need to flip in a different way, otherwise values past * then end of the curve get referenced (result of fmod will be negative, and with different phase) */ if (side < 0) - evaltime= prevkey[0] - cyct; + evaltime = prevkey[0] - cyct; else - evaltime= lastkey[0] - cyct; + evaltime = lastkey[0] - cyct; } else { /* the cycle is played normally... */ - evaltime= prevkey[0] + cyct; + evaltime = prevkey[0] + cyct; } if (evaltime < prevkey[0]) evaltime += cycdx; } @@ -663,17 +663,17 @@ static float fcm_cycles_time (FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), tFCMED_Cycles *edata; /* for now, this is just a float, but we could get more stuff... */ - fcm->edata= edata= MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles"); - edata->cycyofs= cycyofs; + fcm->edata = edata = MEM_callocN(sizeof(tFCMED_Cycles), "tFCMED_Cycles"); + edata->cycyofs = cycyofs; } /* return the new frame to evaluate */ return evaltime; } -static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) +static void fcm_cycles_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { - tFCMED_Cycles *edata= (tFCMED_Cycles *)fcm->edata; + tFCMED_Cycles *edata = (tFCMED_Cycles *)fcm->edata; /* use temp data */ if (edata) { @@ -682,7 +682,7 @@ static void fcm_cycles_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cva /* free temp data */ MEM_freeN(edata); - fcm->edata= NULL; + fcm->edata = NULL; } } @@ -703,21 +703,21 @@ static FModifierTypeInfo FMI_CYCLES = { /* Noise F-Curve Modifier --------------------------- */ -static void fcm_noise_new_data (void *mdata) +static void fcm_noise_new_data(void *mdata) { - FMod_Noise *data= (FMod_Noise *)mdata; + FMod_Noise *data = (FMod_Noise *)mdata; /* defaults */ - data->size= 1.0f; - data->strength= 1.0f; - data->phase= 1.0f; + data->size = 1.0f; + data->strength = 1.0f; + data->phase = 1.0f; data->depth = 0; data->modification = FCM_NOISE_MODIF_REPLACE; } -static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) +static void fcm_noise_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float evaltime) { - FMod_Noise *data= (FMod_Noise *)fcm->data; + FMod_Noise *data = (FMod_Noise *)fcm->data; float noise; /* generate noise using good ol' Blender Noise @@ -729,17 +729,17 @@ static void fcm_noise_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cval /* combine the noise with existing motion data */ switch (data->modification) { case FCM_NOISE_MODIF_ADD: - *cvalue= *cvalue + noise * data->strength; + *cvalue = *cvalue + noise * data->strength; break; case FCM_NOISE_MODIF_SUBTRACT: - *cvalue= *cvalue - noise * data->strength; + *cvalue = *cvalue - noise * data->strength; break; case FCM_NOISE_MODIF_MULTIPLY: - *cvalue= *cvalue * noise * data->strength; + *cvalue = *cvalue * noise * data->strength; break; case FCM_NOISE_MODIF_REPLACE: default: - *cvalue= *cvalue + (noise - 0.5f) * data->strength; + *cvalue = *cvalue + (noise - 0.5f) * data->strength; break; } } @@ -781,25 +781,25 @@ static FModifierTypeInfo FMI_FILTER = { /* Python F-Curve Modifier --------------------------- */ -static void fcm_python_free (FModifier *fcm) +static void fcm_python_free(FModifier *fcm) { - FMod_Python *data= (FMod_Python *)fcm->data; + FMod_Python *data = (FMod_Python *)fcm->data; /* id-properties */ IDP_FreeProperty(data->prop); MEM_freeN(data->prop); } -static void fcm_python_new_data (void *mdata) +static void fcm_python_new_data(void *mdata) { - FMod_Python *data= (FMod_Python *)mdata; + FMod_Python *data = (FMod_Python *)mdata; /* everything should be set correctly by calloc, except for the prop->type constant.*/ data->prop = MEM_callocN(sizeof(IDProperty), "PyFModifierProps"); data->prop->type = IDP_GROUP; } -static void fcm_python_copy (FModifier *fcm, FModifier *src) +static void fcm_python_copy(FModifier *fcm, FModifier *src) { FMod_Python *pymod = (FMod_Python *)fcm->data; FMod_Python *opymod = (FMod_Python *)src->data; @@ -807,7 +807,7 @@ static void fcm_python_copy (FModifier *fcm, FModifier *src) pymod->prop = IDP_CopyProperty(opymod->prop); } -static void fcm_python_evaluate (FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime)) +static void fcm_python_evaluate(FCurve *UNUSED(fcu), FModifier *UNUSED(fcm), float *UNUSED(cvalue), float UNUSED(evaltime)) { #ifdef WITH_PYTHON //FMod_Python *data= (FMod_Python *)fcm->data; @@ -836,9 +836,9 @@ static FModifierTypeInfo FMI_PYTHON = { /* Limits F-Curve Modifier --------------------------- */ -static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) +static float fcm_limits_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { - FMod_Limits *data= (FMod_Limits *)fcm->data; + FMod_Limits *data = (FMod_Limits *)fcm->data; /* check for the time limits */ if ((data->flag & FCM_LIMIT_XMIN) && (evaltime < data->rect.xmin)) @@ -850,15 +850,15 @@ static float fcm_limits_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED( return evaltime; } -static void fcm_limits_evaluate (FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) +static void fcm_limits_evaluate(FCurve *UNUSED(fcu), FModifier *fcm, float *cvalue, float UNUSED(evaltime)) { - FMod_Limits *data= (FMod_Limits *)fcm->data; + FMod_Limits *data = (FMod_Limits *)fcm->data; /* value limits now */ if ((data->flag & FCM_LIMIT_YMIN) && (*cvalue < data->rect.ymin)) - *cvalue= data->rect.ymin; + *cvalue = data->rect.ymin; if ((data->flag & FCM_LIMIT_YMAX) && (*cvalue > data->rect.ymax)) - *cvalue= data->rect.ymax; + *cvalue = data->rect.ymax; } static FModifierTypeInfo FMI_LIMITS = { @@ -878,18 +878,18 @@ static FModifierTypeInfo FMI_LIMITS = { /* Stepped F-Curve Modifier --------------------------- */ -static void fcm_stepped_new_data (void *mdata) +static void fcm_stepped_new_data(void *mdata) { - FMod_Stepped *data= (FMod_Stepped *)mdata; + FMod_Stepped *data = (FMod_Stepped *)mdata; /* just need to set the step-size to 2-frames by default */ // XXX: or would 5 be more normal? data->step_size = 2.0f; } -static float fcm_stepped_time (FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) +static float fcm_stepped_time(FCurve *UNUSED(fcu), FModifier *fcm, float UNUSED(cvalue), float evaltime) { - FMod_Stepped *data= (FMod_Stepped *)fcm->data; + FMod_Stepped *data = (FMod_Stepped *)fcm->data; int snapblock; /* check range clamping to see if we should alter the timing to achieve the desired results */ @@ -936,27 +936,27 @@ static FModifierTypeInfo FMI_STEPPED = { /* These globals only ever get directly accessed in this file */ static FModifierTypeInfo *fmodifiersTypeInfo[FMODIFIER_NUM_TYPES]; -static short FMI_INIT= 1; /* when non-zero, the list needs to be updated */ +static short FMI_INIT = 1; /* when non-zero, the list needs to be updated */ /* This function only gets called when FMI_INIT is non-zero */ -static void fmods_init_typeinfo (void) +static void fmods_init_typeinfo(void) { - fmodifiersTypeInfo[0]= NULL; /* 'Null' F-Curve Modifier */ - fmodifiersTypeInfo[1]= &FMI_GENERATOR; /* Generator F-Curve Modifier */ - fmodifiersTypeInfo[2]= &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */ - fmodifiersTypeInfo[3]= &FMI_ENVELOPE; /* Envelope F-Curve Modifier */ - fmodifiersTypeInfo[4]= &FMI_CYCLES; /* Cycles F-Curve Modifier */ - fmodifiersTypeInfo[5]= &FMI_NOISE; /* Apply-Noise F-Curve Modifier */ - fmodifiersTypeInfo[6]= NULL/*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented - fmodifiersTypeInfo[7]= &FMI_PYTHON; /* Custom Python F-Curve Modifier */ - fmodifiersTypeInfo[8]= &FMI_LIMITS; /* Limits F-Curve Modifier */ - fmodifiersTypeInfo[9]= &FMI_STEPPED; /* Stepped F-Curve Modifier */ + fmodifiersTypeInfo[0] = NULL; /* 'Null' F-Curve Modifier */ + fmodifiersTypeInfo[1] = &FMI_GENERATOR; /* Generator F-Curve Modifier */ + fmodifiersTypeInfo[2] = &FMI_FN_GENERATOR; /* Built-In Function Generator F-Curve Modifier */ + fmodifiersTypeInfo[3] = &FMI_ENVELOPE; /* Envelope F-Curve Modifier */ + fmodifiersTypeInfo[4] = &FMI_CYCLES; /* Cycles F-Curve Modifier */ + fmodifiersTypeInfo[5] = &FMI_NOISE; /* Apply-Noise F-Curve Modifier */ + fmodifiersTypeInfo[6] = NULL /*&FMI_FILTER*/; /* Filter F-Curve Modifier */ // XXX unimplemented + fmodifiersTypeInfo[7] = &FMI_PYTHON; /* Custom Python F-Curve Modifier */ + fmodifiersTypeInfo[8] = &FMI_LIMITS; /* Limits F-Curve Modifier */ + fmodifiersTypeInfo[9] = &FMI_STEPPED; /* Stepped F-Curve Modifier */ } /* This function should be used for getting the appropriate type-info when only * a F-Curve modifier type is known */ -FModifierTypeInfo *get_fmodifier_typeinfo (int type) +FModifierTypeInfo *get_fmodifier_typeinfo(int type) { /* initialize the type-info list? */ if (FMI_INIT) { @@ -966,7 +966,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type) /* only return for valid types */ if ( (type >= FMODIFIER_TYPE_NULL) && - (type <= FMODIFIER_NUM_TYPES ) ) + (type <= FMODIFIER_NUM_TYPES) ) { /* there shouldn't be any segfaults here... */ return fmodifiersTypeInfo[type]; @@ -981,7 +981,7 @@ FModifierTypeInfo *get_fmodifier_typeinfo (int type) /* This function should always be used to get the appropriate type-info, as it * has checks which prevent segfaults in some weird cases. */ -FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm) +FModifierTypeInfo *fmodifier_get_typeinfo(FModifier *fcm) { /* only return typeinfo for valid modifiers */ if (fcm) @@ -993,9 +993,9 @@ FModifierTypeInfo *fmodifier_get_typeinfo (FModifier *fcm) /* API --------------------------- */ /* Add a new F-Curve Modifier to the given F-Curve of a certain type */ -FModifier *add_fmodifier (ListBase *modifiers, int type) +FModifier *add_fmodifier(ListBase *modifiers, int type) { - FModifierTypeInfo *fmi= get_fmodifier_typeinfo(type); + FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type); FModifier *fcm; /* sanity checks */ @@ -1011,7 +1011,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) } /* add modifier itself */ - fcm= MEM_callocN(sizeof(FModifier), "F-Curve Modifier"); + fcm = MEM_callocN(sizeof(FModifier), "F-Curve Modifier"); fcm->type = type; fcm->flag = FMODIFIER_FLAG_EXPANDED; fcm->influence = 1.0f; @@ -1022,7 +1022,7 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) fcm->flag |= FMODIFIER_FLAG_ACTIVE; /* add modifier's data */ - fcm->data= MEM_callocN(fmi->size, fmi->structName); + fcm->data = MEM_callocN(fmi->size, fmi->structName); /* init custom settings if necessary */ if (fmi->new_data) @@ -1033,9 +1033,9 @@ FModifier *add_fmodifier (ListBase *modifiers, int type) } /* Make a copy of the specified F-Modifier */ -FModifier *copy_fmodifier (FModifier *src) +FModifier *copy_fmodifier(FModifier *src) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(src); + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(src); FModifier *dst; /* sanity check */ @@ -1065,11 +1065,11 @@ void copy_fmodifiers(ListBase *dst, ListBase *src) if (ELEM(NULL, dst, src)) return; - dst->first= dst->last= NULL; + dst->first = dst->last = NULL; BLI_duplicatelist(dst, src); - for (fcm=dst->first, srcfcm=src->first; fcm && srcfcm; srcfcm=srcfcm->next, fcm=fcm->next) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + for (fcm = dst->first, srcfcm = src->first; fcm && srcfcm; srcfcm = srcfcm->next, fcm = fcm->next) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); /* make a new copy of the F-Modifier's data */ fcm->data = MEM_dupallocN(fcm->data); @@ -1083,7 +1083,7 @@ void copy_fmodifiers(ListBase *dst, ListBase *src) /* Remove and free the given F-Modifier from the given stack */ int remove_fmodifier(ListBase *modifiers, FModifier *fcm) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); /* sanity check */ if (fcm == NULL) @@ -1121,14 +1121,14 @@ void free_fmodifiers(ListBase *modifiers) return; /* free each modifier in order - modifier is unlinked from list and freed */ - for (fcm= modifiers->first; fcm; fcm= fmn) { - fmn= fcm->next; + for (fcm = modifiers->first; fcm; fcm = fmn) { + fmn = fcm->next; remove_fmodifier(modifiers, fcm); } } /* Find the active F-Modifier */ -FModifier *find_active_fmodifier (ListBase *modifiers) +FModifier *find_active_fmodifier(ListBase *modifiers) { FModifier *fcm; @@ -1137,7 +1137,7 @@ FModifier *find_active_fmodifier (ListBase *modifiers) return NULL; /* loop over modifiers until 'active' one is found */ - for (fcm= modifiers->first; fcm; fcm= fcm->next) { + for (fcm = modifiers->first; fcm; fcm = fcm->next) { if (fcm->flag & FMODIFIER_FLAG_ACTIVE) return fcm; } @@ -1156,7 +1156,7 @@ void set_active_fmodifier(ListBase *modifiers, FModifier *fcm) return; /* deactivate all, and set current one active */ - for (fm= modifiers->first; fm; fm= fm->next) + for (fm = modifiers->first; fm; fm = fm->next) fm->flag &= ~FMODIFIER_FLAG_ACTIVE; /* make given modifier active */ @@ -1181,15 +1181,15 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype) return 0; /* find the first mdifier fitting these criteria */ - for (fcm= modifiers->first; fcm; fcm= fcm->next) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); - short mOk=1, aOk=1; /* by default 1, so that when only one test, won't fail */ + for (fcm = modifiers->first; fcm; fcm = fcm->next) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); + short mOk = 1, aOk = 1; /* by default 1, so that when only one test, won't fail */ /* check if applicable ones are fullfilled */ if (mtype) - mOk= (fcm->type == mtype); + mOk = (fcm->type == mtype); if (acttype > -1) - aOk= (fmi->acttype == acttype); + aOk = (fmi->acttype == acttype); /* if both are ok, we've found a hit */ if (mOk && aOk) @@ -1203,7 +1203,7 @@ short list_has_suitable_fmodifier(ListBase *modifiers, int mtype, short acttype) /* Evaluation API --------------------------- */ /* helper function - calculate influence of FModifier */ -static float eval_fmodifier_influence (FModifier *fcm, float evaltime) +static float eval_fmodifier_influence(FModifier *fcm, float evaltime) { float influence; @@ -1270,8 +1270,8 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f * effect, which should get us the desired effects when using layered time manipulations * (such as multiple 'stepped' modifiers in sequence, causing different stepping rates) */ - for (fcm= modifiers->last; fcm; fcm= fcm->prev) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + for (fcm = modifiers->last; fcm; fcm = fcm->prev) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); if (fmi == NULL) continue; @@ -1279,12 +1279,12 @@ float evaluate_time_fmodifiers(ListBase *modifiers, FCurve *fcu, float cvalue, f /* if modifier cannot be applied on this frame (whatever scale it is on, it won't affect the results) * hence we shouldn't bother seeing what it would do given the chance */ - if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 || - ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) + if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) { /* only evaluate if there's a callback for this */ if (fmi->evaluate_modifier_time) { - if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) { + if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) { float influence = eval_fmodifier_influence(fcm, evaltime); float nval = fmi->evaluate_modifier_time(fcu, fcm, cvalue, evaltime); @@ -1310,18 +1310,18 @@ void evaluate_value_fmodifiers(ListBase *modifiers, FCurve *fcu, float *cvalue, return; /* evaluate modifiers */ - for (fcm= modifiers->first; fcm; fcm= fcm->next) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + for (fcm = modifiers->first; fcm; fcm = fcm->next) { + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); if (fmi == NULL) continue; /* only evaluate if there's a callback for this, and if F-Modifier can be evaluated on this frame */ - if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT)==0 || - ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) + if ((fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) == 0 || + ((fcm->sfra <= evaltime) && (fcm->efra >= evaltime)) ) { if (fmi->evaluate_modifier) { - if ((fcm->flag & (FMODIFIER_FLAG_DISABLED|FMODIFIER_FLAG_MUTED)) == 0) { + if ((fcm->flag & (FMODIFIER_FLAG_DISABLED | FMODIFIER_FLAG_MUTED)) == 0) { float influence = eval_fmodifier_influence(fcm, evaltime); float nval = *cvalue; @@ -1350,8 +1350,8 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end) } /* temporarily, disable driver while we sample, so that they don't influence the outcome */ - driver= fcu->driver; - fcu->driver= NULL; + driver = fcu->driver; + fcu->driver = NULL; /* bake the modifiers, by sampling the curve at each frame */ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve); @@ -1360,5 +1360,5 @@ void fcurve_bake_modifiers(FCurve *fcu, int start, int end) free_fmodifiers(&fcu->modifiers); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index a7f01393a02..fda078f5c42 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -60,10 +60,10 @@ #include "BKE_curve.h" #include "BKE_displist.h" -static ListBase ttfdata= {NULL, NULL}; +static ListBase ttfdata = {NULL, NULL}; /* The vfont code */ -void free_vfont(struct VFont *vf) +void BKE_vfont_free(struct VFont *vf) { if (vf == NULL) return; @@ -90,13 +90,13 @@ void free_vfont(struct VFont *vf) } } -static void *builtin_font_data= NULL; -static int builtin_font_size= 0; +static void *builtin_font_data = NULL; +static int builtin_font_size = 0; -void BKE_font_register_builtin(void *mem, int size) +void BKE_vfont_builtin_register(void *mem, int size) { - builtin_font_data= mem; - builtin_font_size= size; + builtin_font_data = mem; + builtin_font_size = size; } static PackedFile *get_builtin_packedfile(void) @@ -107,7 +107,7 @@ static PackedFile *get_builtin_packedfile(void) return NULL; } else { - void *mem= MEM_mallocN(builtin_font_size, "vfd_builtin"); + void *mem = MEM_mallocN(builtin_font_size, "vfd_builtin"); memcpy(mem, builtin_font_data, builtin_font_size); @@ -115,23 +115,23 @@ static PackedFile *get_builtin_packedfile(void) } } -void free_ttfont(void) +void BKE_vfont_free_global_ttf(void) { struct TmpFont *tf; - for (tf= ttfdata.first; tf; tf= tf->next) { - if (tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */ - tf->pf= NULL; - tf->vfont= NULL; + for (tf = ttfdata.first; tf; tf = tf->next) { + if (tf->pf) freePackedFile(tf->pf); /* NULL when the font file can't be found on disk */ + tf->pf = NULL; + tf->vfont = NULL; } BLI_freelistN(&ttfdata); } -struct TmpFont *vfont_find_tmpfont(VFont *vfont) +struct TmpFont *BKE_vfont_find_tmpfont(VFont *vfont) { struct TmpFont *tmpfnt = NULL; - if (vfont==NULL) return NULL; + if (vfont == NULL) return NULL; // Try finding the font from font list tmpfnt = ttfdata.first; @@ -148,46 +148,46 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) struct TmpFont *tmpfnt = NULL; PackedFile *tpf; - if (vfont==NULL) return NULL; + if (vfont == NULL) return NULL; // Try finding the font from font list - tmpfnt = vfont_find_tmpfont(vfont); + tmpfnt = BKE_vfont_find_tmpfont(vfont); // And then set the data if (!vfont->data) { PackedFile *pf; - if (strcmp(vfont->name, FO_BUILTIN_NAME)==0) { - pf= get_builtin_packedfile(); + if (strcmp(vfont->name, FO_BUILTIN_NAME) == 0) { + pf = get_builtin_packedfile(); } else { if (vfont->packedfile) { - pf= vfont->packedfile; + pf = vfont->packedfile; // We need to copy a tmp font to memory unless it is already there if (!tmpfnt) { - tpf= MEM_callocN(sizeof(*tpf), "PackedFile"); - tpf->data= MEM_mallocN(pf->size, "packFile"); - tpf->size= pf->size; + tpf = MEM_callocN(sizeof(*tpf), "PackedFile"); + tpf->data = MEM_mallocN(pf->size, "packFile"); + tpf->size = pf->size; memcpy(tpf->data, pf->data, pf->size); // Add temporary packed file to globals - tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf= tpf; - tmpfnt->vfont= vfont; + tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); + tmpfnt->pf = tpf; + tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); } } else { - pf= newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); + pf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); if (!tmpfnt) { - tpf= newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); + tpf = newPackedFile(NULL, vfont->name, ID_BLEND_PATH(bmain, &vfont->id)); // Add temporary packed file to globals - tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf= tpf; - tmpfnt->vfont= vfont; + tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); + tmpfnt->pf = tpf; + tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); } } @@ -195,12 +195,12 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) printf("Font file doesn't exist: %s\n", vfont->name); strcpy(vfont->name, FO_BUILTIN_NAME); - pf= get_builtin_packedfile(); + pf = get_builtin_packedfile(); } } if (pf) { - vfont->data= BLI_vfontdata_from_freetypefont(pf); + vfont->data = BLI_vfontdata_from_freetypefont(pf); if (pf != vfont->packedfile) { freePackedFile(pf); } @@ -210,20 +210,20 @@ static VFontData *vfont_get_data(Main *bmain, VFont *vfont) return vfont->data; } -VFont *load_vfont(Main *bmain, const char *name) +VFont *BKE_vfont_load(Main *bmain, const char *name) { char filename[FILE_MAXFILE]; - VFont *vfont= NULL; + VFont *vfont = NULL; PackedFile *pf; PackedFile *tpf = NULL; int is_builtin; struct TmpFont *tmpfnt; - if (strcmp(name, FO_BUILTIN_NAME)==0) { + if (strcmp(name, FO_BUILTIN_NAME) == 0) { BLI_strncpy(filename, name, sizeof(filename)); - pf= get_builtin_packedfile(); - is_builtin= 1; + pf = get_builtin_packedfile(); + is_builtin = 1; } else { char dir[FILE_MAXDIR]; @@ -231,23 +231,23 @@ VFont *load_vfont(Main *bmain, const char *name) BLI_strncpy(dir, name, sizeof(dir)); BLI_splitdirstring(dir, filename); - pf= newPackedFile(NULL, name, bmain->name); - tpf= newPackedFile(NULL, name, bmain->name); + pf = newPackedFile(NULL, name, bmain->name); + tpf = newPackedFile(NULL, name, bmain->name); - is_builtin= 0; + is_builtin = 0; } if (pf) { VFontData *vfd; - vfd= BLI_vfontdata_from_freetypefont(pf); + vfd = BLI_vfontdata_from_freetypefont(pf); if (vfd) { - vfont = alloc_libblock(&bmain->vfont, ID_VF, filename); + vfont = BKE_libblock_alloc(&bmain->vfont, ID_VF, filename); vfont->data = vfd; /* if there's a font name, use it for the ID name */ if (vfd->name[0] != '\0') { - BLI_strncpy(vfont->id.name+2, vfd->name, sizeof(vfont->id.name)-2); + BLI_strncpy(vfont->id.name + 2, vfd->name, sizeof(vfont->id.name) - 2); } BLI_strncpy(vfont->name, name, sizeof(vfont->name)); @@ -258,9 +258,9 @@ VFont *load_vfont(Main *bmain, const char *name) // Do not add FO_BUILTIN_NAME to temporary listbase if (strcmp(filename, FO_BUILTIN_NAME)) { - tmpfnt= (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); - tmpfnt->pf= tpf; - tmpfnt->vfont= vfont; + tmpfnt = (struct TmpFont *) MEM_callocN(sizeof(struct TmpFont), "temp_font"); + tmpfnt->pf = tpf; + tmpfnt->vfont = vfont; BLI_addtail(&ttfdata, tmpfnt); } } @@ -278,32 +278,32 @@ VFont *load_vfont(Main *bmain, const char *name) static VFont *which_vfont(Curve *cu, CharInfo *info) { - switch (info->flag & (CU_CHINFO_BOLD|CU_CHINFO_ITALIC)) { + switch (info->flag & (CU_CHINFO_BOLD | CU_CHINFO_ITALIC)) { case CU_CHINFO_BOLD: if (cu->vfontb) return(cu->vfontb); else return(cu->vfont); case CU_CHINFO_ITALIC: if (cu->vfonti) return(cu->vfonti); else return(cu->vfont); - case (CU_CHINFO_BOLD|CU_CHINFO_ITALIC): + case (CU_CHINFO_BOLD | CU_CHINFO_ITALIC): if (cu->vfontbi) return(cu->vfontbi); else return(cu->vfont); default: return(cu->vfont); } } -VFont *get_builtin_font(void) +VFont *BKE_vfont_builtin_get(void) { VFont *vf; - for (vf= G.main->vfont.first; vf; vf= vf->id.next) - if (strcmp(vf->name, FO_BUILTIN_NAME)==0) + for (vf = G.main->vfont.first; vf; vf = vf->id.next) + if (strcmp(vf->name, FO_BUILTIN_NAME) == 0) return vf; - return load_vfont(G.main, FO_BUILTIN_NAME); + return BKE_vfont_load(G.main, FO_BUILTIN_NAME); } static VChar *find_vfont_char(VFontData *vfd, intptr_t character) { - VChar *che= NULL; + VChar *che = NULL; for (che = vfd->characters.first; che; che = che->next) { if (che->index == character) @@ -317,21 +317,21 @@ static void build_underline(Curve *cu, float x1, float y1, float x2, float y2, i Nurb *nu2; BPoint *bp; - nu2 =(Nurb*) MEM_callocN(sizeof(Nurb), "underline_nurb"); + nu2 = (Nurb *) MEM_callocN(sizeof(Nurb), "underline_nurb"); if (nu2 == NULL) return; - nu2->resolu= cu->resolu; + nu2->resolu = cu->resolu; nu2->bezt = NULL; nu2->knotsu = nu2->knotsv = NULL; - nu2->flag= CU_2D; - nu2->charidx = charidx+1000; - if (mat_nr > 0) nu2->mat_nr= mat_nr-1; + nu2->flag = CU_2D; + nu2->charidx = charidx + 1000; + if (mat_nr > 0) nu2->mat_nr = mat_nr - 1; nu2->pntsu = 4; nu2->pntsv = 1; nu2->orderu = 4; nu2->orderv = 1; nu2->flagu = CU_NURB_CYCLIC; - bp = (BPoint*)MEM_callocN(4 * sizeof(BPoint), "underline_bp"); + bp = (BPoint *)MEM_callocN(4 * sizeof(BPoint), "underline_bp"); if (bp == NULL) { MEM_freeN(nu2); return; @@ -368,27 +368,27 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo VChar *che = NULL; int i; - vfd= vfont_get_data(bmain, which_vfont(cu, info)); + vfd = vfont_get_data(bmain, which_vfont(cu, info)); if (!vfd) return; #if 0 if (cu->selend < cu->selstart) { - if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart-2))) - sel= 1; + if ((charidx >= (cu->selend)) && (charidx <= (cu->selstart - 2))) + sel = 1; } else { - if ((charidx >= (cu->selstart-1)) && (charidx <= (cu->selend-1))) - sel= 1; + if ((charidx >= (cu->selstart - 1)) && (charidx <= (cu->selend - 1))) + sel = 1; } #endif /* make a copy at distance ofsx, ofsy with shear*/ - fsize= cu->fsize; - shear= cu->shear; - si= (float)sin(rot); - co= (float)cos(rot); + fsize = cu->fsize; + shear = cu->shear; + si = (float)sin(rot); + co = (float)cos(rot); - che= find_vfont_char(vfd, character); + che = find_vfont_char(vfd, character); // Select the glyph data if (che) @@ -398,25 +398,25 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo while (nu1) { bezt1 = nu1->bezt; if (bezt1) { - nu2 =(Nurb*) MEM_mallocN(sizeof(Nurb), "duplichar_nurb"); + nu2 = (Nurb *) MEM_mallocN(sizeof(Nurb), "duplichar_nurb"); if (nu2 == NULL) break; memcpy(nu2, nu1, sizeof(struct Nurb)); - nu2->resolu= cu->resolu; + nu2->resolu = cu->resolu; nu2->bp = NULL; nu2->knotsu = nu2->knotsv = NULL; - nu2->flag= CU_SMOOTH; + nu2->flag = CU_SMOOTH; nu2->charidx = charidx; if (info->mat_nr > 0) { - nu2->mat_nr= info->mat_nr-1; + nu2->mat_nr = info->mat_nr - 1; } else { - nu2->mat_nr= 0; + nu2->mat_nr = 0; } /* nu2->trim.first = 0; */ /* nu2->trim.last = 0; */ i = nu2->pntsu; - bezt2 = (BezTriple*)MEM_mallocN(i * sizeof(BezTriple), "duplichar_bezt2"); + bezt2 = (BezTriple *)MEM_mallocN(i * sizeof(BezTriple), "duplichar_bezt2"); if (bezt2 == NULL) { MEM_freeN(nu2); break; @@ -427,7 +427,7 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo if (shear != 0.0f) { bezt2 = nu2->bezt; - for (i= nu2->pntsu; i > 0; i--) { + for (i = nu2->pntsu; i > 0; i--) { bezt2->vec[0][0] += shear * bezt2->vec[0][1]; bezt2->vec[1][0] += shear * bezt2->vec[1][1]; bezt2->vec[2][0] += shear * bezt2->vec[2][1]; @@ -435,19 +435,19 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } } if (rot != 0.0f) { - bezt2= nu2->bezt; - for (i=nu2->pntsu; i > 0; i--) { - fp= bezt2->vec[0]; - - x= fp[0]; - fp[0]= co*x + si*fp[1]; - fp[1]= -si*x + co*fp[1]; - x= fp[3]; - fp[3]= co*x + si*fp[4]; - fp[4]= -si*x + co*fp[4]; - x= fp[6]; - fp[6]= co*x + si*fp[7]; - fp[7]= -si*x + co*fp[7]; + bezt2 = nu2->bezt; + for (i = nu2->pntsu; i > 0; i--) { + fp = bezt2->vec[0]; + + x = fp[0]; + fp[0] = co * x + si * fp[1]; + fp[1] = -si * x + co * fp[1]; + x = fp[3]; + fp[3] = co * x + si * fp[4]; + fp[4] = -si * x + co * fp[4]; + x = fp[6]; + fp[6] = co * x + si * fp[7]; + fp[7] = -si * x + co * fp[7]; bezt2++; } @@ -455,9 +455,9 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo bezt2 = nu2->bezt; if (info->flag & CU_CHINFO_SMALLCAPS_CHECK) { - const float sca= cu->smallcaps_scale; - for (i= nu2->pntsu; i > 0; i--) { - fp= bezt2->vec[0]; + const float sca = cu->smallcaps_scale; + for (i = nu2->pntsu; i > 0; i--) { + fp = bezt2->vec[0]; fp[0] *= sca; fp[1] *= sca; fp[3] *= sca; @@ -469,14 +469,14 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } bezt2 = nu2->bezt; - for (i= nu2->pntsu; i > 0; i--) { - fp= bezt2->vec[0]; - fp[0]= (fp[0]+ofsx)*fsize; - fp[1]= (fp[1]+ofsy)*fsize; - fp[3]= (fp[3]+ofsx)*fsize; - fp[4]= (fp[4]+ofsy)*fsize; - fp[6]= (fp[6]+ofsx)*fsize; - fp[7]= (fp[7]+ofsy)*fsize; + for (i = nu2->pntsu; i > 0; i--) { + fp = bezt2->vec[0]; + fp[0] = (fp[0] + ofsx) * fsize; + fp[1] = (fp[1] + ofsy) * fsize; + fp[3] = (fp[3] + ofsx) * fsize; + fp[4] = (fp[4] + ofsy) * fsize; + fp[6] = (fp[6] + ofsx) * fsize; + fp[7] = (fp[7] + ofsy) * fsize; bezt2++; } @@ -487,21 +487,21 @@ static void buildchar(Main *bmain, Curve *cu, unsigned long character, CharInfo } } -int BKE_font_getselection(Object *ob, int *start, int *end) +int BKE_vfont_select_get(Object *ob, int *start, int *end) { - Curve *cu= ob->data; + Curve *cu = ob->data; - if (cu->editfont==NULL || ob->type != OB_FONT) return 0; + if (cu->editfont == NULL || ob->type != OB_FONT) return 0; if (cu->selstart == 0) return 0; if (cu->selstart <= cu->selend) { - *start = cu->selstart-1; - *end = cu->selend-1; + *start = cu->selstart - 1; + *end = cu->selend - 1; return 1; } else { *start = cu->selend; - *end = cu->selstart-2; + *end = cu->selstart - 2; return -1; } } @@ -520,32 +520,31 @@ static float char_width(Curve *cu, VChar *che, CharInfo *info) } } -struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int mode) -{ +struct chartrans *BKE_vfont_to_curve(Main *bmain, Scene *scene, Object *ob, int mode){ VFont *vfont, *oldvfont; - VFontData *vfd= NULL; + VFontData *vfd = NULL; Curve *cu; CharInfo *info = NULL, *custrinfo; TextBox *tb; VChar *che; - struct chartrans *chartransdata=NULL, *ct; + struct chartrans *chartransdata = NULL, *ct; float *f, xof, yof, xtrax, linedist, *linedata, *linedata2, *linedata3, *linedata4; - float twidth, maxlen= 0; + float twidth, maxlen = 0; int i, slen, j; int curbox; int selstart, selend; int utf8len; - short cnr=0, lnr=0, wsnr= 0; + short cnr = 0, lnr = 0, wsnr = 0; wchar_t *mem, *tmp, ascii; /* renark: do calculations including the trailing '\0' of a string * because the cursor can be at that location */ - if (ob->type!=OB_FONT) return NULL; + if (ob->type != OB_FONT) return NULL; // Set font data - cu= (Curve *) ob->data; - vfont= cu->vfont; + cu = (Curve *) ob->data; + vfont = cu->vfont; if (cu->str == NULL) return NULL; if (vfont == NULL) return NULL; @@ -562,17 +561,17 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if (cu->ulheight == 0.0f) cu->ulheight = 0.05f; - if (cu->strinfo==NULL) /* old file */ - cu->strinfo = MEM_callocN((slen+4) * sizeof(CharInfo), "strinfo compat"); + if (cu->strinfo == NULL) /* old file */ + cu->strinfo = MEM_callocN((slen + 4) * sizeof(CharInfo), "strinfo compat"); - custrinfo= cu->strinfo; + custrinfo = cu->strinfo; if (cu->editfont) - custrinfo= cu->editfont->textbufinfo; + custrinfo = cu->editfont->textbufinfo; - if (cu->tb==NULL) - cu->tb= MEM_callocN(MAXTEXTBOX*sizeof(TextBox), "TextBox compat"); + if (cu->tb == NULL) + cu->tb = MEM_callocN(MAXTEXTBOX * sizeof(TextBox), "TextBox compat"); - vfd= vfont_get_data(bmain, vfont); + vfd = vfont_get_data(bmain, vfont); /* The VFont Data can not be found */ if (!vfd) { @@ -583,7 +582,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m /* calc offset and rotation of each char */ ct = chartransdata = - (struct chartrans*)MEM_callocN((slen+1)* sizeof(struct chartrans), "buildtext"); + (struct chartrans *)MEM_callocN((slen + 1) * sizeof(struct chartrans), "buildtext"); /* We assume the worst case: 1 character per line (is freed at end anyway) */ @@ -592,57 +591,57 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m linedata3 = MEM_callocN(sizeof(float) * (slen * 2 + 1), "buildtext4"); linedata4 = MEM_callocN(sizeof(float) * (slen * 2 + 1), "buildtext5"); - linedist= cu->linedist; + linedist = cu->linedist; - xof= cu->xof + (cu->tb[0].x/cu->fsize); - yof= cu->yof + (cu->tb[0].y/cu->fsize); + xof = cu->xof + (cu->tb[0].x / cu->fsize); + yof = cu->yof + (cu->tb[0].y / cu->fsize); - xtrax= 0.5f*cu->spacing-0.5f; + xtrax = 0.5f * cu->spacing - 0.5f; oldvfont = NULL; - for (i=0; iselboxes) MEM_freeN(cu->selboxes); cu->selboxes = NULL; - if (BKE_font_getselection(ob, &selstart, &selend)) - cu->selboxes = MEM_callocN((selend-selstart+1)*sizeof(SelBox), "font selboxes"); + if (BKE_vfont_select_get(ob, &selstart, &selend)) + cu->selboxes = MEM_callocN((selend - selstart + 1) * sizeof(SelBox), "font selboxes"); tb = &(cu->tb[0]); - curbox= 0; - for (i = 0 ; i<=slen ; i++) { - makebreak: + curbox = 0; + for (i = 0; i <= slen; i++) { +makebreak: // Characters in the list info = &(custrinfo[i]); ascii = mem[i]; if (info->flag & CU_CHINFO_SMALLCAPS) { ascii = towupper(ascii); if (mem[i] != ascii) { - mem[i]= ascii; + mem[i] = ascii; info->flag |= CU_CHINFO_SMALLCAPS_CHECK; } } vfont = which_vfont(cu, info); - if (vfont==NULL) break; + if (vfont == NULL) break; - che= find_vfont_char(vfd, ascii); + che = find_vfont_char(vfd, ascii); /* * The character wasn't in the current curve base so load it * But if the font is FO_BUILTIN_NAME then do not try loading since * whole font is in the memory already */ - if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { + if (che == NULL && strcmp(vfont->name, FO_BUILTIN_NAME)) { BLI_vfontchar_from_freetypefont(vfont, ascii); } /* Try getting the character again from the list */ - che= find_vfont_char(vfd, ascii); + che = find_vfont_char(vfd, ascii); /* No VFont found */ - if (vfont==NULL) { + if (vfont == NULL) { if (mem) MEM_freeN(mem); MEM_freeN(chartransdata); @@ -650,7 +649,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } if (vfont != oldvfont) { - vfd= vfont_get_data(bmain, vfont); + vfd = vfont_get_data(bmain, vfont); oldvfont = vfont; } @@ -665,24 +664,24 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m twidth = char_width(cu, che, info); // Calculate positions - if ((tb->w != 0.0f) && (ct->dobreak==0) && ((xof-(tb->x/cu->fsize)+twidth)*cu->fsize) > tb->w + cu->xof*cu->fsize) { - // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); - for (j=i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak==0); j--) { - if (mem[j]==' ' || mem[j]=='-') { - ct -= (i-(j-1)); - cnr -= (i-(j-1)); + if ((tb->w != 0.0f) && (ct->dobreak == 0) && ((xof - (tb->x / cu->fsize) + twidth) * cu->fsize) > tb->w + cu->xof * cu->fsize) { + // fprintf(stderr, "linewidth exceeded: %c%c%c...\n", mem[i], mem[i+1], mem[i+2]); + for (j = i; j && (mem[j] != '\n') && (mem[j] != '\r') && (chartransdata[j].dobreak == 0); j--) { + if (mem[j] == ' ' || mem[j] == '-') { + ct -= (i - (j - 1)); + cnr -= (i - (j - 1)); if (mem[j] == ' ') wsnr--; if (mem[j] == '-') wsnr++; - i = j-1; + i = j - 1; xof = ct->xof; ct[1].dobreak = 1; - custrinfo[i+1].flag |= CU_CHINFO_WRAP; + custrinfo[i + 1].flag |= CU_CHINFO_WRAP; goto makebreak; } if (chartransdata[j].dobreak) { - // fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]); - ct->dobreak= 1; - custrinfo[i+1].flag |= CU_CHINFO_WRAP; + // fprintf(stderr, "word too long: %c%c%c...\n", mem[j], mem[j+1], mem[j+2]); + ct->dobreak = 1; + custrinfo[i + 1].flag |= CU_CHINFO_WRAP; ct -= 1; cnr -= 1; i--; @@ -691,27 +690,27 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } } } - if (ascii== '\n' || ascii== '\r' || ascii==0 || ct->dobreak) { - ct->xof= xof; - ct->yof= yof; - ct->linenr= lnr; - ct->charnr= cnr; - - yof-= linedist; - - maxlen= MAX2(maxlen, (xof-tb->x/cu->fsize)); - linedata[lnr]= xof-tb->x/cu->fsize; - linedata2[lnr]= cnr; - linedata3[lnr]= tb->w/cu->fsize; - linedata4[lnr]= wsnr; + if (ascii == '\n' || ascii == '\r' || ascii == 0 || ct->dobreak) { + ct->xof = xof; + ct->yof = yof; + ct->linenr = lnr; + ct->charnr = cnr; + + yof -= linedist; + + maxlen = MAX2(maxlen, (xof - tb->x / cu->fsize)); + linedata[lnr] = xof - tb->x / cu->fsize; + linedata2[lnr] = cnr; + linedata3[lnr] = tb->w / cu->fsize; + linedata4[lnr] = wsnr; if ( (tb->h != 0.0f) && - ((-(yof-(tb->y/cu->fsize))) > ((tb->h/cu->fsize)-(linedist*cu->fsize)) - cu->yof) && - (cu->totbox > (curbox+1)) ) { - maxlen= 0; + ((-(yof - (tb->y / cu->fsize))) > ((tb->h / cu->fsize) - (linedist * cu->fsize)) - cu->yof) && + (cu->totbox > (curbox + 1)) ) { + maxlen = 0; tb++; curbox++; - yof= cu->yof + tb->y/cu->fsize; + yof = cu->yof + tb->y / cu->fsize; } /* XXX, has been unused for years, need to check if this is useful, r4613 r5282 - campbell */ @@ -719,43 +718,43 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if (ascii == '\n' || ascii == '\r') xof = cu->xof; else - xof= cu->xof + (tb->x/cu->fsize); + xof = cu->xof + (tb->x / cu->fsize); #else - xof= cu->xof + (tb->x/cu->fsize); + xof = cu->xof + (tb->x / cu->fsize); #endif lnr++; - cnr= 0; - wsnr= 0; + cnr = 0; + wsnr = 0; } - else if (ascii==9) { /* TAB */ + else if (ascii == 9) { /* TAB */ float tabfac; - ct->xof= xof; - ct->yof= yof; - ct->linenr= lnr; - ct->charnr= cnr++; + ct->xof = xof; + ct->yof = yof; + ct->linenr = lnr; + ct->charnr = cnr++; - tabfac= (xof-cu->xof+0.01f); - tabfac= 2.0f*ceilf(tabfac/2.0f); - xof= cu->xof+tabfac; + tabfac = (xof - cu->xof + 0.01f); + tabfac = 2.0f * ceilf(tabfac / 2.0f); + xof = cu->xof + tabfac; } else { - SelBox *sb= NULL; + SelBox *sb = NULL; float wsfac; - ct->xof= xof; - ct->yof= yof; - ct->linenr= lnr; - ct->charnr= cnr++; + ct->xof = xof; + ct->yof = yof; + ct->linenr = lnr; + ct->charnr = cnr++; - if (cu->selboxes && (i>=selstart) && (i<=selend)) { - sb = &(cu->selboxes[i-selstart]); - sb->y = yof*cu->fsize-linedist*cu->fsize*0.1f; - sb->h = linedist*cu->fsize; - sb->w = xof*cu->fsize; + if (cu->selboxes && (i >= selstart) && (i <= selend)) { + sb = &(cu->selboxes[i - selstart]); + sb->y = yof * cu->fsize - linedist * cu->fsize * 0.1f; + sb->h = linedist * cu->fsize; + sb->w = xof * cu->fsize; } - if (ascii==32) { + if (ascii == 32) { wsfac = cu->wordspace; wsnr++; } @@ -764,20 +763,20 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m // Set the width of the character twidth = char_width(cu, che, info); - xof += (twidth*wsfac*(1.0f+(info->kern/40.0f)) ) + xtrax; + xof += (twidth * wsfac * (1.0f + (info->kern / 40.0f)) ) + xtrax; if (sb) - sb->w = (xof*cu->fsize) - sb->w; + sb->w = (xof * cu->fsize) - sb->w; } ct++; } - cu->lines= 1; - ct= chartransdata; + cu->lines = 1; + ct = chartransdata; tmp = mem; - for (i= 0; i<=slen; i++, tmp++, ct++) { + for (i = 0; i <= slen; i++, tmp++, ct++) { ascii = *tmp; - if (ascii== '\n' || ascii== '\r' || ct->dobreak) cu->lines++; + if (ascii == '\n' || ascii == '\r' || ct->dobreak) cu->lines++; } // linedata is now: width of line @@ -785,55 +784,55 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m // linedata3 is now: maxlen of that line // linedata4 is now: number of whitespaces of line - if (cu->spacemode!=CU_LEFT) { - ct= chartransdata; + if (cu->spacemode != CU_LEFT) { + ct = chartransdata; - if (cu->spacemode==CU_RIGHT) { - for (i=0;ixof+= linedata[ct->linenr]; + if (cu->spacemode == CU_RIGHT) { + for (i = 0; i < lnr; i++) linedata[i] = linedata3[i] - linedata[i]; + for (i = 0; i <= slen; i++) { + ct->xof += linedata[ct->linenr]; ct++; } } - else if (cu->spacemode==CU_MIDDLE) { - for (i=0;ixof+= linedata[ct->linenr]; + else if (cu->spacemode == CU_MIDDLE) { + for (i = 0; i < lnr; i++) linedata[i] = (linedata3[i] - linedata[i]) / 2; + for (i = 0; i <= slen; i++) { + ct->xof += linedata[ct->linenr]; ct++; } } - else if ((cu->spacemode==CU_FLUSH) && - (cu->tb[0].w != 0.0f)) { - for (i=0;i1) - linedata[i]= (linedata3[i]-linedata[i])/(linedata2[i]-1); - for (i=0; i<=slen; i++) { - for (j=i; (!ELEM3(mem[j], '\0', '\n', '\r')) && (chartransdata[j].dobreak == 0) && (j < slen); j++) { + else if ((cu->spacemode == CU_FLUSH) && + (cu->tb[0].w != 0.0f)) { + for (i = 0; i < lnr; i++) + if (linedata2[i] > 1) + linedata[i] = (linedata3[i] - linedata[i]) / (linedata2[i] - 1); + for (i = 0; i <= slen; i++) { + for (j = i; (!ELEM3(mem[j], '\0', '\n', '\r')) && (chartransdata[j].dobreak == 0) && (j < slen); j++) { /* do nothing */ } // if ((mem[j]!='\r') && (mem[j]!='\n') && (mem[j])) { - ct->xof+= ct->charnr*linedata[ct->linenr]; + ct->xof += ct->charnr * linedata[ct->linenr]; // } ct++; } } - else if ((cu->spacemode==CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { + else if ((cu->spacemode == CU_JUSTIFY) && (cu->tb[0].w != 0.0f)) { float curofs = 0.0f; for (i = 0; i <= slen; i++) { - for (j=i; (mem[j]) && (mem[j]!='\n') && - (mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen); + for (j = i; (mem[j]) && (mem[j] != '\n') && + (mem[j] != '\r') && (chartransdata[j].dobreak == 0) && (j < slen); j++) { /* pass */ } - if ((mem[j]!='\r') && (mem[j]!='\n') && - ((chartransdata[j].dobreak!=0))) { - if (mem[i]==' ') curofs += (linedata3[ct->linenr]-linedata[ct->linenr])/linedata4[ct->linenr]; - ct->xof+= curofs; + if ((mem[j] != '\r') && (mem[j] != '\n') && + ((chartransdata[j].dobreak != 0))) { + if (mem[i] == ' ') curofs += (linedata3[ct->linenr] - linedata[ct->linenr]) / linedata4[ct->linenr]; + ct->xof += curofs; } - if (mem[i]=='\n' || mem[i]=='\r' || chartransdata[i].dobreak) curofs= 0; + if (mem[i] == '\n' || mem[i] == '\r' || chartransdata[i].dobreak) curofs = 0; ct++; } } @@ -841,13 +840,13 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m /* TEXT ON CURVE */ /* Note: Only OB_CURVE objects could have a path */ - if (cu->textoncurve && cu->textoncurve->type==OB_CURVE) { - Curve *cucu= cu->textoncurve->data; - int oldflag= cucu->flag; + if (cu->textoncurve && cu->textoncurve->type == OB_CURVE) { + Curve *cucu = cu->textoncurve->data; + int oldflag = cucu->flag; - cucu->flag |= (CU_PATH+CU_FOLLOW); + cucu->flag |= (CU_PATH + CU_FOLLOW); - if (cucu->path==NULL) makeDispListCurveTypes(scene, cu->textoncurve, 0); + if (cucu->path == NULL) BKE_displist_make_curveTypes(scene, cu->textoncurve, 0); if (cucu->path) { float distfac, imat[4][4], imat3[3][3], cmat[3][3]; float minx, maxx, miny, maxy; @@ -858,116 +857,116 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m copy_m3_m4(cmat, cu->textoncurve->obmat); mul_m3_m3m3(cmat, cmat, imat3); - sizefac= normalize_v3(cmat[0])/cu->fsize; + sizefac = normalize_v3(cmat[0]) / cu->fsize; - minx=miny= 1.0e20f; - maxx=maxy= -1.0e20f; - ct= chartransdata; - for (i=0; i<=slen; i++, ct++) { - if (minx>ct->xof) minx= ct->xof; - if (maxxxof) maxx= ct->xof; - if (miny>ct->yof) miny= ct->yof; - if (maxyyof) maxy= ct->yof; + minx = miny = 1.0e20f; + maxx = maxy = -1.0e20f; + ct = chartransdata; + for (i = 0; i <= slen; i++, ct++) { + if (minx > ct->xof) minx = ct->xof; + if (maxx < ct->xof) maxx = ct->xof; + if (miny > ct->yof) miny = ct->yof; + if (maxy < ct->yof) maxy = ct->yof; } /* we put the x-coordinaat exact at the curve, the y is rotated */ /* length correction */ - distfac= sizefac*cucu->path->totdist/(maxx-minx); - timeofs= 0.0f; + distfac = sizefac * cucu->path->totdist / (maxx - minx); + timeofs = 0.0f; if (distfac > 1.0f) { /* path longer than text: spacemode involves */ - distfac= 1.0f/distfac; + distfac = 1.0f / distfac; - if (cu->spacemode==CU_RIGHT) { - timeofs= 1.0f-distfac; + if (cu->spacemode == CU_RIGHT) { + timeofs = 1.0f - distfac; } - else if (cu->spacemode==CU_MIDDLE) { - timeofs= (1.0f-distfac)/2.0f; + else if (cu->spacemode == CU_MIDDLE) { + timeofs = (1.0f - distfac) / 2.0f; } - else if (cu->spacemode==CU_FLUSH) distfac= 1.0f; + else if (cu->spacemode == CU_FLUSH) distfac = 1.0f; } - else distfac= 1.0; + else distfac = 1.0; - distfac/= (maxx-minx); + distfac /= (maxx - minx); - timeofs+= distfac*cu->xof; /* not cyclic */ + timeofs += distfac * cu->xof; /* not cyclic */ - ct= chartransdata; - for (i=0; i<=slen; i++, ct++) { + ct = chartransdata; + for (i = 0; i <= slen; i++, ct++) { float ctime, dtime, vec[4], tvec[4], rotvec[3]; float si, co; /* rotate around center character */ ascii = mem[i]; - che= find_vfont_char(vfd, ascii); + che = find_vfont_char(vfd, ascii); twidth = char_width(cu, che, info); - dtime= distfac*0.5f*twidth; + dtime = distfac * 0.5f * twidth; - ctime= timeofs + distfac*( ct->xof - minx); + ctime = timeofs + distfac * (ct->xof - minx); CLAMP(ctime, 0.0f, 1.0f); /* calc the right loc AND the right rot separately */ /* vec, tvec need 4 items */ where_on_path(cu->textoncurve, ctime, vec, tvec, NULL, NULL, NULL); - where_on_path(cu->textoncurve, ctime+dtime, tvec, rotvec, NULL, NULL, NULL); + where_on_path(cu->textoncurve, ctime + dtime, tvec, rotvec, NULL, NULL, NULL); mul_v3_fl(vec, sizefac); - ct->rot= (float)(M_PI-atan2(rotvec[1], rotvec[0])); + ct->rot = (float)(M_PI - atan2(rotvec[1], rotvec[0])); - si= (float)sin(ct->rot); - co= (float)cos(ct->rot); + si = (float)sin(ct->rot); + co = (float)cos(ct->rot); - yof= ct->yof; + yof = ct->yof; - ct->xof= vec[0] + si*yof; - ct->yof= vec[1] + co*yof; + ct->xof = vec[0] + si * yof; + ct->yof = vec[1] + co * yof; } - cucu->flag= oldflag; + cucu->flag = oldflag; } } if (cu->selboxes) { - ct= chartransdata; - for (i=0; i<=selend; i++, ct++) { - if (i>=selstart) { - cu->selboxes[i-selstart].x = ct->xof*cu->fsize; - cu->selboxes[i-selstart].y = ct->yof*cu->fsize; + ct = chartransdata; + for (i = 0; i <= selend; i++, ct++) { + if (i >= selstart) { + cu->selboxes[i - selstart].x = ct->xof * cu->fsize; + cu->selboxes[i - selstart].y = ct->yof * cu->fsize; } } } - if (mode==FO_CURSUP || mode==FO_CURSDOWN || mode==FO_PAGEUP || mode==FO_PAGEDOWN) { + if (mode == FO_CURSUP || mode == FO_CURSDOWN || mode == FO_PAGEUP || mode == FO_PAGEDOWN) { /* 2: curs up * 3: curs down */ - ct= chartransdata+cu->pos; + ct = chartransdata + cu->pos; - if ((mode==FO_CURSUP || mode==FO_PAGEUP) && ct->linenr==0); - else if ((mode==FO_CURSDOWN || mode==FO_PAGEDOWN) && ct->linenr==lnr); + if ((mode == FO_CURSUP || mode == FO_PAGEUP) && ct->linenr == 0) ; + else if ((mode == FO_CURSDOWN || mode == FO_PAGEDOWN) && ct->linenr == lnr) ; else { switch (mode) { - case FO_CURSUP: lnr= ct->linenr-1; break; - case FO_CURSDOWN: lnr= ct->linenr+1; break; - case FO_PAGEUP: lnr= ct->linenr-10; break; - case FO_PAGEDOWN: lnr= ct->linenr+10; break; + case FO_CURSUP: lnr = ct->linenr - 1; break; + case FO_CURSDOWN: lnr = ct->linenr + 1; break; + case FO_PAGEUP: lnr = ct->linenr - 10; break; + case FO_PAGEDOWN: lnr = ct->linenr + 10; break; } - cnr= ct->charnr; + cnr = ct->charnr; /* seek for char with lnr en cnr */ - cu->pos= 0; - ct= chartransdata; - for (i= 0; ilinenr==lnr) { - if (ct->charnr==cnr) break; - if ( (ct+1)->charnr==0) break; + cu->pos = 0; + ct = chartransdata; + for (i = 0; i < slen; i++) { + if (ct->linenr == lnr) { + if (ct->charnr == cnr) break; + if ( (ct + 1)->charnr == 0) break; } - else if (ct->linenr>lnr) break; + else if (ct->linenr > lnr) break; cu->pos++; ct++; } @@ -978,23 +977,23 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m if (cu->editfont) { float si, co; - ct= chartransdata+cu->pos; - si= (float)sin(ct->rot); - co= (float)cos(ct->rot); + ct = chartransdata + cu->pos; + si = (float)sin(ct->rot); + co = (float)cos(ct->rot); - f= cu->editfont->textcurs[0]; + f = cu->editfont->textcurs[0]; - f[0]= cu->fsize*(-0.1f*co + ct->xof); - f[1]= cu->fsize*(0.1f*si + ct->yof); + f[0] = cu->fsize * (-0.1f * co + ct->xof); + f[1] = cu->fsize * (0.1f * si + ct->yof); - f[2]= cu->fsize*(0.1f*co + ct->xof); - f[3]= cu->fsize*(-0.1f*si + ct->yof); + f[2] = cu->fsize * (0.1f * co + ct->xof); + f[3] = cu->fsize * (-0.1f * si + ct->yof); - f[4]= cu->fsize*( 0.1f*co + 0.8f*si + ct->xof); - f[5]= cu->fsize*(-0.1f*si + 0.8f*co + ct->yof); + f[4] = cu->fsize * (0.1f * co + 0.8f * si + ct->xof); + f[5] = cu->fsize * (-0.1f * si + 0.8f * co + ct->yof); - f[6]= cu->fsize*(-0.1f*co + 0.8f*si + ct->xof); - f[7]= cu->fsize*( 0.1f*si + 0.8f*co + ct->yof); + f[6] = cu->fsize * (-0.1f * co + 0.8f * si + ct->xof); + f[7] = cu->fsize * (0.1f * si + 0.8f * co + ct->yof); } @@ -1013,9 +1012,9 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m /* make nurbdata */ BKE_nurbList_free(&cu->nurb); - ct= chartransdata; - if (cu->sepchar==0) { - for (i= 0; isepchar == 0) { + for (i = 0; i < slen; i++) { unsigned long cha = (uintptr_t) mem[i]; info = &(custrinfo[i]); if (info->mat_nr > (ob->totcol)) { @@ -1027,42 +1026,42 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m buildchar(bmain, cu, cha, info, ct->xof, ct->yof, ct->rot, i); if ((info->flag & CU_CHINFO_UNDERLINE) && (cu->textoncurve == NULL) && (cha != '\n') && (cha != '\r')) { - float ulwidth, uloverlap= 0.0f; + float ulwidth, uloverlap = 0.0f; - if ( (i<(slen-1)) && (mem[i+1] != '\n') && (mem[i+1] != '\r') && - ((mem[i+1] != ' ') || (custrinfo[i+1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i+1].flag & CU_CHINFO_WRAP)==0) - ) { + if ( (i < (slen - 1)) && (mem[i + 1] != '\n') && (mem[i + 1] != '\r') && + ((mem[i + 1] != ' ') || (custrinfo[i + 1].flag & CU_CHINFO_UNDERLINE)) && ((custrinfo[i + 1].flag & CU_CHINFO_WRAP) == 0) + ) { uloverlap = xtrax + 0.1f; } // Find the character, the characters has to be in the memory already // since character checking has been done earlier already. - che= find_vfont_char(vfd, cha); + che = find_vfont_char(vfd, cha); twidth = char_width(cu, che, info); - ulwidth = cu->fsize * ((twidth* (1.0f+(info->kern/40.0f)))+uloverlap); - build_underline(cu, ct->xof*cu->fsize, ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize, - ct->xof*cu->fsize + ulwidth, - ct->yof*cu->fsize + (cu->ulpos-0.05f)*cu->fsize - cu->ulheight*cu->fsize, - i, info->mat_nr); + ulwidth = cu->fsize * ((twidth * (1.0f + (info->kern / 40.0f))) + uloverlap); + build_underline(cu, ct->xof * cu->fsize, ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize, + ct->xof * cu->fsize + ulwidth, + ct->yof * cu->fsize + (cu->ulpos - 0.05f) * cu->fsize - cu->ulheight * cu->fsize, + i, info->mat_nr); } ct++; } } else { int outta = 0; - for (i= 0; (isepchar == (i+1)) { + if (cu->sepchar == (i + 1)) { float vecyo[3]; - vecyo[0]= ct->xof; - vecyo[1]= ct->yof; - vecyo[2]= 0.0f; + vecyo[0] = ct->xof; + vecyo[1] = ct->yof; + vecyo[2] = 0.0f; mem[0] = ascii; mem[1] = 0; - custrinfo[0]= *info; + custrinfo[0] = *info; cu->pos = 1; cu->len = 1; mul_v3_m4v3(ob->loc, ob->obmat, vecyo); @@ -1074,7 +1073,7 @@ struct chartrans *BKE_text_to_curve(Main *bmain, Scene *scene, Object *ob, int m } } - if (mode==FO_DUPLI) { + if (mode == FO_DUPLI) { MEM_freeN(mem); return chartransdata; } diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 9ea4eafdd73..6ec19018ab5 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -62,8 +62,8 @@ void free_gpencil_strokes(bGPDframe *gpf) if (gpf == NULL) return; /* free strokes */ - for (gps= gpf->strokes.first; gps; gps= gpsn) { - gpsn= gps->next; + for (gps = gpf->strokes.first; gps; gps = gpsn) { + gpsn = gps->next; /* free stroke memory arrays, then stroke itself */ if (gps->points) MEM_freeN(gps->points); @@ -80,8 +80,8 @@ void free_gpencil_frames(bGPDlayer *gpl) if (gpl == NULL) return; /* free frames */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; /* free strokes and their associated memory */ free_gpencil_strokes(gpf); @@ -98,8 +98,8 @@ void free_gpencil_layers(ListBase *list) if (list == NULL) return; /* delete layers*/ - for (gpl= list->first; gpl; gpl= gpln) { - gpln= gpl->next; + for (gpl = list->first; gpl; gpl = gpln) { + gpln = gpl->next; /* free layers and their data */ free_gpencil_frames(gpl); @@ -108,7 +108,7 @@ void free_gpencil_layers(ListBase *list) } /* Free all of GPencil datablock's related data, but not the block itself */ -void free_gpencil_data(bGPdata *gpd) +void BKE_gpencil_free(bGPdata *gpd) { /* free layers */ free_gpencil_layers(&gpd->layers); @@ -117,32 +117,32 @@ void free_gpencil_data(bGPdata *gpd) /* -------- Container Creation ---------- */ /* add a new gp-frame to the given layer */ -bGPDframe *gpencil_frame_addnew (bGPDlayer *gpl, int cframe) +bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe) { bGPDframe *gpf, *gf; - short state=0; + short state = 0; /* error checking */ if ((gpl == NULL) || (cframe <= 0)) return NULL; /* allocate memory for this frame */ - gpf= MEM_callocN(sizeof(bGPDframe), "bGPDframe"); - gpf->framenum= cframe; + gpf = MEM_callocN(sizeof(bGPDframe), "bGPDframe"); + gpf->framenum = cframe; /* find appropriate place to add frame */ if (gpl->frames.first) { - for (gf= gpl->frames.first; gf; gf= gf->next) { + for (gf = gpl->frames.first; gf; gf = gf->next) { /* check if frame matches one that is supposed to be added */ if (gf->framenum == cframe) { - state= -1; + state = -1; break; } /* if current frame has already exceeded the frame to add, add before */ if (gf->framenum > cframe) { BLI_insertlinkbefore(&gpl->frames, gf, gpf); - state= 1; + state = 1; break; } } @@ -163,7 +163,7 @@ bGPDframe *gpencil_frame_addnew (bGPDlayer *gpl, int cframe) } /* add a new gp-layer and make it the active layer */ -bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) +bGPDlayer *gpencil_layer_addnew(bGPdata *gpd) { bGPDlayer *gpl; @@ -172,13 +172,13 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) return NULL; /* allocate memory for frame and add to end of list */ - gpl= MEM_callocN(sizeof(bGPDlayer), "bGPDlayer"); + gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer"); /* add to datablock */ BLI_addtail(&gpd->layers, gpl); /* set basic settings */ - gpl->color[3]= 0.9f; + gpl->color[3] = 0.9f; gpl->thickness = 3; /* auto-name */ @@ -193,15 +193,15 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd) } /* add a new gp-datablock */ -bGPdata *gpencil_data_addnew (const char name[]) +bGPdata *gpencil_data_addnew(const char name[]) { bGPdata *gpd; /* allocate memory for a new block */ - gpd= alloc_libblock(&G.main->gpencil, ID_GD, name); + gpd = BKE_libblock_alloc(&G.main->gpencil, ID_GD, name); /* initial settings */ - gpd->flag = (GP_DATA_DISPINFO|GP_DATA_EXPAND); + gpd->flag = (GP_DATA_DISPINFO | GP_DATA_EXPAND); /* for now, stick to view is also enabled by default * since this is more useful... @@ -214,7 +214,7 @@ bGPdata *gpencil_data_addnew (const char name[]) /* -------- Data Duplication ---------- */ /* make a copy of a given gpencil frame */ -bGPDframe *gpencil_frame_duplicate (bGPDframe *src) +bGPDframe *gpencil_frame_duplicate(bGPDframe *src) { bGPDstroke *gps, *gpsd; bGPDframe *dst; @@ -224,15 +224,15 @@ bGPDframe *gpencil_frame_duplicate (bGPDframe *src) return NULL; /* make a copy of the source frame */ - dst= MEM_dupallocN(src); - dst->prev= dst->next= NULL; + dst = MEM_dupallocN(src); + dst->prev = dst->next = NULL; /* copy strokes */ - dst->strokes.first = dst->strokes.last= NULL; - for (gps= src->strokes.first; gps; gps= gps->next) { + dst->strokes.first = dst->strokes.last = NULL; + for (gps = src->strokes.first; gps; gps = gps->next) { /* make copy of source stroke, then adjust pointer to points too */ - gpsd= MEM_dupallocN(gps); - gpsd->points= MEM_dupallocN(gps->points); + gpsd = MEM_dupallocN(gps); + gpsd->points = MEM_dupallocN(gps->points); BLI_addtail(&dst->strokes, gpsd); } @@ -242,7 +242,7 @@ bGPDframe *gpencil_frame_duplicate (bGPDframe *src) } /* make a copy of a given gpencil layer */ -bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src) +bGPDlayer *gpencil_layer_duplicate(bGPDlayer *src) { bGPDframe *gpf, *gpfd; bGPDlayer *dst; @@ -252,19 +252,19 @@ bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src) return NULL; /* make a copy of source layer */ - dst= MEM_dupallocN(src); - dst->prev= dst->next= NULL; + dst = MEM_dupallocN(src); + dst->prev = dst->next = NULL; /* copy frames */ - dst->frames.first= dst->frames.last= NULL; - for (gpf= src->frames.first; gpf; gpf= gpf->next) { + dst->frames.first = dst->frames.last = NULL; + for (gpf = src->frames.first; gpf; gpf = gpf->next) { /* make a copy of source frame */ - gpfd= gpencil_frame_duplicate(gpf); + gpfd = gpencil_frame_duplicate(gpf); BLI_addtail(&dst->frames, gpfd); /* if source frame was the current layer's 'active' frame, reassign that too */ if (gpf == dst->actframe) - dst->actframe= gpfd; + dst->actframe = gpfd; } /* return new layer */ @@ -272,7 +272,7 @@ bGPDlayer *gpencil_layer_duplicate (bGPDlayer *src) } /* make a copy of a given gpencil datablock */ -bGPdata *gpencil_data_duplicate (bGPdata *src) +bGPdata *gpencil_data_duplicate(bGPdata *src) { bGPDlayer *gpl, *gpld; bGPdata *dst; @@ -282,13 +282,13 @@ bGPdata *gpencil_data_duplicate (bGPdata *src) return NULL; /* make a copy of the base-data */ - dst= MEM_dupallocN(src); + dst = MEM_dupallocN(src); /* copy layers */ - dst->layers.first= dst->layers.last= NULL; - for (gpl= src->layers.first; gpl; gpl= gpl->next) { + dst->layers.first = dst->layers.last = NULL; + for (gpl = src->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ - gpld= gpencil_layer_duplicate(gpl); + gpld = gpencil_layer_duplicate(gpl); BLI_addtail(&dst->layers, gpld); } @@ -301,7 +301,7 @@ bGPdata *gpencil_data_duplicate (bGPdata *src) /* delete the last stroke of the given frame */ void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf) { - bGPDstroke *gps= (gpf) ? gpf->strokes.last : NULL; + bGPDstroke *gps = (gpf) ? gpf->strokes.last : NULL; int cfra = (gpf) ? gpf->framenum : 0; /* assume that the current frame was not locked */ /* error checking */ @@ -325,7 +325,7 @@ void gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf) * - this sets the layer's actframe var (if allowed to) * - extension beyond range (if first gp-frame is after all frame in interest and cannot add) */ -bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) +bGPDframe *gpencil_layer_getframe(bGPDlayer *gpl, int cframe, short addnew) { bGPDframe *gpf = NULL; short found = 0; @@ -336,12 +336,12 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* check if there is already an active frame */ if (gpl->actframe) { - gpf= gpl->actframe; + gpf = gpl->actframe; /* do not allow any changes to layer's active frame if layer is locked from changes * or if the layer has been set to stay on the current frame */ - if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_FRAMELOCK)) + if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_FRAMELOCK)) return gpf; /* do not allow any changes to actframe if frame has painting tag attached to it */ if (gpf->flag & GP_FRAME_PAINT) @@ -349,13 +349,13 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* try to find matching frame */ if (gpf->framenum < cframe) { - for (; gpf; gpf= gpf->next) { + for (; gpf; gpf = gpf->next) { if (gpf->framenum == cframe) { - found= 1; + found = 1; break; } else if ((gpf->next) && (gpf->next->framenum > cframe)) { - found= 1; + found = 1; break; } } @@ -363,19 +363,19 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* set the appropriate frame */ if (addnew) { if ((found) && (gpf->framenum == cframe)) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); } else if (found) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpl->frames.last; + gpl->actframe = gpl->frames.last; } else { - for (; gpf; gpf= gpf->prev) { + for (; gpf; gpf = gpf->prev) { if (gpf->framenum <= cframe) { - found= 1; + found = 1; break; } } @@ -383,35 +383,35 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* set the appropriate frame */ if (addnew) { if ((found) && (gpf->framenum == cframe)) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); } else if (found) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpl->frames.first; + gpl->actframe = gpl->frames.first; } } else if (gpl->frames.first) { /* check which of the ends to start checking from */ - const int first= ((bGPDframe *)(gpl->frames.first))->framenum; - const int last= ((bGPDframe *)(gpl->frames.last))->framenum; + const int first = ((bGPDframe *)(gpl->frames.first))->framenum; + const int last = ((bGPDframe *)(gpl->frames.last))->framenum; - if (abs(cframe-first) > abs(cframe-last)) { + if (abs(cframe - first) > abs(cframe - last)) { /* find gp-frame which is less than or equal to cframe */ - for (gpf= gpl->frames.last; gpf; gpf= gpf->prev) { + for (gpf = gpl->frames.last; gpf; gpf = gpf->prev) { if (gpf->framenum <= cframe) { - found= 1; + found = 1; break; } } } else { /* find gp-frame which is less than or equal to cframe */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->framenum <= cframe) { - found= 1; + found = 1; break; } } @@ -420,12 +420,12 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) /* set the appropriate frame */ if (addnew) { if ((found) && (gpf->framenum == cframe)) - gpl->actframe= gpf; + gpl->actframe = gpf; else - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); } else if (found) - gpl->actframe= gpf; + gpl->actframe = gpf; else { /* unresolved errogenous situation! */ printf("Error: cannot find appropriate gp-frame\n"); @@ -435,7 +435,7 @@ bGPDframe *gpencil_layer_getframe (bGPDlayer *gpl, int cframe, short addnew) else { /* currently no frames (add if allowed to) */ if (addnew) - gpl->actframe= gpencil_frame_addnew(gpl, cframe); + gpl->actframe = gpencil_frame_addnew(gpl, cframe); else { /* don't do anything... this may be when no frames yet! */ /* gpl->actframe should still be NULL */ @@ -460,7 +460,7 @@ void gpencil_layer_delframe(bGPDlayer *gpl, bGPDframe *gpf) } /* get the active gp-layer for editing */ -bGPDlayer *gpencil_layer_getactive (bGPdata *gpd) +bGPDlayer *gpencil_layer_getactive(bGPdata *gpd) { bGPDlayer *gpl; @@ -469,7 +469,7 @@ bGPDlayer *gpencil_layer_getactive (bGPdata *gpd) return NULL; /* loop over layers until found (assume only one active) */ - for (gpl=gpd->layers.first; gpl; gpl=gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { if (gpl->flag & GP_LAYER_ACTIVE) return gpl; } @@ -488,7 +488,7 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active) return; /* loop over layers deactivating all */ - for (gpl=gpd->layers.first; gpl; gpl=gpl->next) + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) gpl->flag &= ~GP_LAYER_ACTIVE; /* set as active one */ @@ -498,7 +498,7 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active) /* delete the active gp-layer */ void gpencil_layer_delactive(bGPdata *gpd) { - bGPDlayer *gpl= gpencil_layer_getactive(gpd); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); /* error checking */ if (ELEM(NULL, gpd, gpl)) diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 204b2b08563..ceffe269e85 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -52,7 +52,7 @@ #include "BKE_library.h" #include "BKE_main.h" #include "BKE_object.h" -#include "BKE_scene.h" /* object_in_scene */ +#include "BKE_scene.h" /* BKE_scene_base_find */ static void free_group_object(GroupObject *go) { @@ -60,21 +60,21 @@ static void free_group_object(GroupObject *go) } -void free_group_objects(Group *group) +void BKE_group_free(Group *group) { /* don't free group itself */ GroupObject *go; while (group->gobject.first) { - go= group->gobject.first; + go = group->gobject.first; BLI_remlink(&group->gobject, go); free_group_object(go); } } -void unlink_group(Group *group) +void BKE_group_unlink(Group *group) { - Main *bmain= G.main; + Main *bmain = G.main; Material *ma; Object *ob; Scene *sce; @@ -82,28 +82,28 @@ void unlink_group(Group *group) FreestyleLineSet *lineset; ParticleSystem *psys; - for (ma= bmain->mat.first; ma; ma= ma->id.next) { - if (ma->group==group) - ma->group= NULL; + for (ma = bmain->mat.first; ma; ma = ma->id.next) { + if (ma->group == group) + ma->group = NULL; } - for (ma= bmain->mat.first; ma; ma= ma->id.next) { - if (ma->group==group) - ma->group= NULL; + for (ma = bmain->mat.first; ma; ma = ma->id.next) { + if (ma->group == group) + ma->group = NULL; } - for (sce= bmain->scene.first; sce; sce= sce->id.next) { - Base *base= sce->base.first; + for (sce = bmain->scene.first; sce; sce = sce->id.next) { + Base *base = sce->base.first; /* ensure objects are not in this group */ - for (; base; base= base->next) { - if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL)==NULL) { + for (; base; base = base->next) { + if (rem_from_group(group, base->object, sce, base) && find_group(base->object, NULL) == NULL) { base->object->flag &= ~OB_FROMGROUP; base->flag &= ~OB_FROMGROUP; } } - for (srl= sce->r.layers.first; srl; srl= srl->next) { - if (srl->light_override==group) - srl->light_override= NULL; + for (srl = sce->r.layers.first; srl; srl = srl->next) { + if (srl->light_override == group) + srl->light_override = NULL; for(lineset= srl->freestyleConfig.linesets.first; lineset; lineset= lineset->next) { if (lineset->group == group) @@ -112,51 +112,51 @@ void unlink_group(Group *group) } } - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (ob->dup_group==group) { - ob->dup_group= NULL; -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ + if (ob->dup_group == group) { + ob->dup_group = NULL; +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ { bActionStrip *strip; /* duplicator strips use a group object, we remove it */ - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) - strip->object= NULL; + strip->object = NULL; } } #endif } - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - if (psys->part->dup_group==group) - psys->part->dup_group= NULL; -#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ - if (psys->part->eff_group==group) - psys->part->eff_group= NULL; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part->dup_group == group) + psys->part->dup_group = NULL; +#if 0 /* not used anymore, only keps for readfile.c, no need to account for this */ + if (psys->part->eff_group == group) + psys->part->eff_group = NULL; #endif } } /* group stays in library, but no members */ - free_group_objects(group); - group->id.us= 0; + BKE_group_free(group); + group->id.us = 0; } Group *add_group(const char *name) { Group *group; - group = alloc_libblock(&G.main->group, ID_GR, name); - group->layer= (1<<20)-1; + group = BKE_libblock_alloc(&G.main->group, ID_GR, name); + group->layer = (1 << 20) - 1; return group; } -Group *copy_group(Group *group) +Group *BKE_group_copy(Group *group) { Group *groupn; - groupn= MEM_dupallocN(group); + groupn = MEM_dupallocN(group); BLI_duplicatelist(&groupn->gobject, &group->gobject); return groupn; @@ -167,17 +167,17 @@ static int add_to_group_internal(Group *group, Object *ob) { GroupObject *go; - if (group==NULL || ob==NULL) return 0; + if (group == NULL || ob == NULL) return 0; /* check if the object has been added already */ - for (go= group->gobject.first; go; go= go->next) { - if (go->ob==ob) return 0; + for (go = group->gobject.first; go; go = go->next) { + if (go->ob == ob) return 0; } - go= MEM_callocN(sizeof(GroupObject), "groupobject"); + go = MEM_callocN(sizeof(GroupObject), "groupobject"); BLI_addtail(&group->gobject, go); - go->ob= ob; + go->ob = ob; return 1; } @@ -185,10 +185,10 @@ static int add_to_group_internal(Group *group, Object *ob) int add_to_group(Group *group, Object *object, Scene *scene, Base *base) { if (add_to_group_internal(group, object)) { - if ((object->flag & OB_FROMGROUP)==0) { + if ((object->flag & OB_FROMGROUP) == 0) { - if (scene && base==NULL) - base= object_in_scene(object, scene); + if (scene && base == NULL) + base = BKE_scene_base_find(scene, object); object->flag |= OB_FROMGROUP; @@ -207,18 +207,18 @@ static int rem_from_group_internal(Group *group, Object *ob) { GroupObject *go, *gon; int removed = 0; - if (group==NULL) return 0; + if (group == NULL) return 0; - go= group->gobject.first; + go = group->gobject.first; while (go) { - gon= go->next; - if (go->ob==ob) { + gon = go->next; + if (go->ob == ob) { BLI_remlink(&group->gobject, go); free_group_object(go); removed = 1; /* should break here since an object being in a group twice cant happen? */ } - go= gon; + go = gon; } return removed; } @@ -228,8 +228,8 @@ int rem_from_group(Group *group, Object *object, Scene *scene, Base *base) if (rem_from_group_internal(group, object)) { /* object can be NULL */ if (object && find_group(object, NULL) == NULL) { - if (scene && base==NULL) - base= object_in_scene(object, scene); + if (scene && base == NULL) + base = BKE_scene_base_find(scene, object); object->flag &= ~OB_FROMGROUP; @@ -247,10 +247,10 @@ int object_in_group(Object *ob, Group *group) { GroupObject *go; - if (group==NULL || ob==NULL) return 0; + if (group == NULL || ob == NULL) return 0; - for (go= group->gobject.first; go; go= go->next) { - if (go->ob==ob) + for (go = group->gobject.first; go; go = go->next) { + if (go->ob == ob) return 1; } return 0; @@ -259,14 +259,14 @@ int object_in_group(Object *ob, Group *group) Group *find_group(Object *ob, Group *group) { if (group) - group= group->id.next; + group = group->id.next; else - group= G.main->group.first; + group = G.main->group.first; while (group) { if (object_in_group(ob, group)) return group; - group= group->id.next; + group = group->id.next; } return NULL; } @@ -275,11 +275,11 @@ void group_tag_recalc(Group *group) { GroupObject *go; - if (group==NULL) return; + if (group == NULL) return; - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; } } @@ -292,7 +292,7 @@ int group_is_animated(Object *UNUSED(parent), Group *group) return 1; #endif - for (go= group->gobject.first; go; go= go->next) + for (go = group->gobject.first; go; go = go->next) if (go->ob && go->ob->proxy) return 1; @@ -304,38 +304,38 @@ int group_is_animated(Object *UNUSED(parent), Group *group) /* keep checking nla.c though, in case internal structure of strip changes */ static void group_replaces_nla(Object *parent, Object *target, char mode) { - static ListBase nlastrips={NULL, NULL}; - static bAction *action= NULL; - static int done= 0; + static ListBase nlastrips = {NULL, NULL}; + static bAction *action = NULL; + static int done = 0; bActionStrip *strip, *nstrip; - if (mode=='s') { + if (mode == 's') { - for (strip= parent->nlastrips.first; strip; strip= strip->next) { - if (strip->object==target) { - if (done==0) { + for (strip = parent->nlastrips.first; strip; strip = strip->next) { + if (strip->object == target) { + if (done == 0) { /* clear nla & action from object */ - nlastrips= target->nlastrips; - target->nlastrips.first= target->nlastrips.last= NULL; - action= target->action; - target->action= NULL; + nlastrips = target->nlastrips; + target->nlastrips.first = target->nlastrips.last = NULL; + action = target->action; + target->action = NULL; target->nlaflag |= OB_NLA_OVERRIDE; - done= 1; + done = 1; } - nstrip= MEM_dupallocN(strip); + nstrip = MEM_dupallocN(strip); BLI_addtail(&target->nlastrips, nstrip); } } } - else if (mode=='e') { + else if (mode == 'e') { if (done) { BLI_freelistN(&target->nlastrips); - target->nlastrips= nlastrips; - target->action= action; + target->nlastrips = nlastrips; + target->action = action; - nlastrips.first= nlastrips.last= NULL; /* not needed, but yah... :) */ - action= NULL; - done= 0; + nlastrips.first = nlastrips.last = NULL; /* not needed, but yah... :) */ + action = NULL; + done = 0; } } } @@ -359,33 +359,33 @@ void group_handle_recalc_and_update(Scene *scene, Object *UNUSED(parent), Group int cfrao; /* switch to local time */ - cfrao= scene->r.cfra; + cfrao = scene->r.cfra; /* we need a DAG per group... */ - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob && go->recalc) { - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; group_replaces_nla(parent, go->ob, 's'); - object_handle_update(scene, go->ob); + BKE_object_handle_update(scene, go->ob); group_replaces_nla(parent, go->ob, 'e'); /* leave recalc tags in case group members are in normal scene */ - go->ob->recalc= go->recalc; + go->ob->recalc = go->recalc; } } /* restore */ - scene->r.cfra= cfrao; + scene->r.cfra = cfrao; } else #endif { /* only do existing tags, as set by regular depsgraph */ - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { if (go->ob->recalc) { - object_handle_update(scene, go->ob); + BKE_object_handle_update(scene, go->ob); } } } @@ -397,17 +397,17 @@ Object *group_get_member_with_action(Group *group, bAction *act) { GroupObject *go; - if (group==NULL || act==NULL) return NULL; + if (group == NULL || act == NULL) return NULL; - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { - if (go->ob->action==act) + if (go->ob->action == act) return go->ob; if (go->ob->nlastrips.first) { bActionStrip *strip; - for (strip= go->ob->nlastrips.first; strip; strip= strip->next) { - if (strip->act==act) + for (strip = go->ob->nlastrips.first; strip; strip = strip->next) { + if (strip->act == act) return go->ob; } } @@ -424,21 +424,21 @@ void group_relink_nla_objects(Object *ob) GroupObject *go; bActionStrip *strip; - if (ob==NULL || ob->dup_group==NULL) return; - group= ob->dup_group; + if (ob == NULL || ob->dup_group == NULL) return; + group = ob->dup_group; - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { if (strip->object) { - for (go= group->gobject.first; go; go= go->next) { + for (go = group->gobject.first; go; go = go->next) { if (go->ob) { - if (strcmp(go->ob->id.name, strip->object->id.name)==0) + if (strcmp(go->ob->id.name, strip->object->id.name) == 0) break; } } if (go) - strip->object= go->ob; + strip->object = go->ob; else - strip->object= NULL; + strip->object = NULL; } } diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index dfe73ae20db..e3735cfd374 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -47,16 +47,16 @@ static char idp_size_table[] = { 1, /*strings*/ sizeof(int), sizeof(float), - sizeof(float)*3, /*Vector type, deprecated*/ - sizeof(float)*16, /*Matrix type, deprecated*/ + sizeof(float) * 3, /*Vector type, deprecated*/ + sizeof(float) * 16, /*Matrix type, deprecated*/ 0, /*arrays don't have a fixed size*/ sizeof(ListBase), /*Group type*/ - sizeof(void*), + sizeof(void *), sizeof(double) }; /* ------------Property Array Type ----------- */ -#define GETPROP(prop, i) (((IDProperty*)(prop)->data.pointer)+(i)) +#define GETPROP(prop, i) (((IDProperty *)(prop)->data.pointer) + (i)) /* --------- property array type -------------*/ @@ -78,10 +78,10 @@ IDProperty *IDP_CopyIDPArray(IDProperty *array) IDProperty *narray = MEM_mallocN(sizeof(IDProperty), "IDP_CopyIDPArray"), *tmp; int i; - *narray= *array; + *narray = *array; narray->data.pointer = MEM_dupallocN(array->data.pointer); - for (i=0; ilen; i++) { + for (i = 0; i < narray->len; i++) { /* ok, the copy functions always allocate a new structure, * which doesn't work here. instead, simply copy the * contents of the new structure into the array cell, @@ -100,7 +100,7 @@ void IDP_FreeIDPArray(IDProperty *prop) { int i; - for (i=0; ilen; i++) + for (i = 0; i < prop->len; i++) IDP_FreeProperty(GETPROP(prop, i)); if (prop->data.pointer) @@ -124,22 +124,22 @@ IDProperty *IDP_GetIndexArray(IDProperty *prop, int index) IDProperty *IDP_AppendArray(IDProperty *prop, IDProperty *item) { - IDP_ResizeIDPArray(prop, prop->len+1); - IDP_SetIndexArray(prop, prop->len-1, item); + IDP_ResizeIDPArray(prop, prop->len + 1); + IDP_SetIndexArray(prop, prop->len - 1, item); return item; } void IDP_ResizeIDPArray(IDProperty *prop, int newlen) { void *newarr; - int newsize=newlen; + int newsize = newlen; /*first check if the array buffer size has room*/ /*if newlen is 200 chars less then totallen, reallocate anyway*/ if (newlen <= prop->totallen && prop->totallen - newlen < 200) { int i; - for (i=newlen; ilen; i++) + for (i = newlen; i < prop->len; i++) IDP_FreeProperty(GETPROP(prop, i)); prop->len = newlen; @@ -156,18 +156,18 @@ void IDP_ResizeIDPArray(IDProperty *prop, int newlen) */ newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize; - newarr = MEM_callocN(sizeof(IDProperty)*newsize, "idproperty array resized"); + newarr = MEM_callocN(sizeof(IDProperty) * newsize, "idproperty array resized"); if (newlen >= prop->len) { /* newlen is bigger*/ - memcpy(newarr, prop->data.pointer, prop->len*sizeof(IDProperty)); + memcpy(newarr, prop->data.pointer, prop->len * sizeof(IDProperty)); } else { int i; /* newlen is smaller*/ - for (i=newlen; ilen; i++) { + for (i = newlen; i < prop->len; i++) { IDP_FreeProperty(GETPROP(prop, i)); } - memcpy(newarr, prop->data.pointer, newlen*sizeof(IDProperty)); + memcpy(newarr, prop->data.pointer, newlen * sizeof(IDProperty)); } if (prop->data.pointer) @@ -185,21 +185,21 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr) if (newlen >= prop->len) { /* bigger */ - IDProperty **array= newarr; + IDProperty **array = newarr; IDPropertyTemplate val; int a; - for (a=prop->len; alen; a < newlen; a++) { val.i = 0; /* silence MSVC warning about uninitialized var when debugging */ - array[a]= IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group"); + array[a] = IDP_New(IDP_GROUP, &val, "IDP_ResizeArray group"); } } else { /* smaller */ - IDProperty **array= prop->data.pointer; + IDProperty **array = prop->data.pointer; int a; - for (a=newlen; alen; a++) { + for (a = newlen; a < prop->len; a++) { IDP_FreeProperty(array[a]); MEM_freeN(array[a]); } @@ -210,7 +210,7 @@ static void idp_resize_group_array(IDProperty *prop, int newlen, void *newarr) void IDP_ResizeArray(IDProperty *prop, int newlen) { void *newarr; - int newsize=newlen; + int newsize = newlen; /*first check if the array buffer size has room*/ /*if newlen is 200 chars less then totallen, reallocate anyway*/ @@ -230,16 +230,16 @@ void IDP_ResizeArray(IDProperty *prop, int newlen) */ newsize = (newsize >> 3) + (newsize < 9 ? 3 : 6) + newsize; - newarr = MEM_callocN(idp_size_table[(int)prop->subtype]*newsize, "idproperty array resized"); + newarr = MEM_callocN(idp_size_table[(int)prop->subtype] * newsize, "idproperty array resized"); if (newlen >= prop->len) { /* newlen is bigger*/ - memcpy(newarr, prop->data.pointer, prop->len*idp_size_table[(int)prop->subtype]); + memcpy(newarr, prop->data.pointer, prop->len * idp_size_table[(int)prop->subtype]); idp_resize_group_array(prop, newlen, newarr); } else { /* newlen is smaller*/ idp_resize_group_array(prop, newlen, newarr); - memcpy(newarr, prop->data.pointer, newlen*idp_size_table[(int)prop->subtype]); + memcpy(newarr, prop->data.pointer, newlen * idp_size_table[(int)prop->subtype]); } MEM_freeN(prop->data.pointer); @@ -257,8 +257,8 @@ void IDP_FreeArray(IDProperty *prop) } - static IDProperty *idp_generic_copy(IDProperty *prop) - { +static IDProperty *idp_generic_copy(IDProperty *prop) +{ IDProperty *newp = MEM_callocN(sizeof(IDProperty), "IDProperty array dup"); BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME); @@ -268,7 +268,7 @@ void IDP_FreeArray(IDProperty *prop) newp->data.val2 = prop->data.val2; return newp; - } +} static IDProperty *IDP_CopyArray(IDProperty *prop) { @@ -278,11 +278,11 @@ static IDProperty *IDP_CopyArray(IDProperty *prop) newp->data.pointer = MEM_dupallocN(prop->data.pointer); if (prop->type == IDP_GROUP) { - IDProperty **array= newp->data.pointer; + IDProperty **array = newp->data.pointer; int a; - for (a=0; alen; a++) - array[a]= IDP_CopyProperty(array[a]); + for (a = 0; a < prop->len; a++) + array[a] = IDP_CopyProperty(array[a]); } } newp->len = prop->len; @@ -294,12 +294,12 @@ static IDProperty *IDP_CopyArray(IDProperty *prop) /*taken from readfile.c*/ #define SWITCH_LONGINT(a) { \ - char s_i, *p_i; \ - p_i= (char *)&(a); \ - s_i=p_i[0]; p_i[0]=p_i[7]; p_i[7]=s_i; \ - s_i=p_i[1]; p_i[1]=p_i[6]; p_i[6]=s_i; \ - s_i=p_i[2]; p_i[2]=p_i[5]; p_i[5]=s_i; \ - s_i=p_i[3]; p_i[3]=p_i[4]; p_i[4]=s_i; } + char s_i, *p_i; \ + p_i = (char *)& (a); \ + s_i = p_i[0]; p_i[0] = p_i[7]; p_i[7] = s_i; \ + s_i = p_i[1]; p_i[1] = p_i[6]; p_i[6] = s_i; \ + s_i = p_i[2]; p_i[2] = p_i[5]; p_i[5] = s_i; \ + s_i = p_i[3]; p_i[3] = p_i[4]; p_i[4] = s_i; } @@ -350,7 +350,7 @@ void IDP_AssignString(IDProperty *prop, const char *st, int maxlen) int stlen = strlen(st); if (maxlen > 0 && maxlen < stlen) - stlen= maxlen; + stlen = maxlen; if (prop->subtype == IDP_STRING_SUB_BYTE) { IDP_ResizeArray(prop, stlen); @@ -396,14 +396,14 @@ void IDP_FreeString(IDProperty *prop) void IDP_LinkID(IDProperty *prop, ID *id) { - if (prop->data.pointer) ((ID*)prop->data.pointer)->us--; + if (prop->data.pointer) ((ID *)prop->data.pointer)->us--; prop->data.pointer = id; id_us_plus(id); } void IDP_UnlinkID(IDProperty *prop) { - ((ID*)prop->data.pointer)->us--; + ((ID *)prop->data.pointer)->us--; } /*-------- Group Functions -------*/ @@ -414,7 +414,7 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop) IDProperty *newp = idp_generic_copy(prop), *link; newp->len = prop->len; - for (link=prop->data.group.first; link; link=link->next) { + for (link = prop->data.group.first; link; link = link->next) { BLI_addtail(&newp->data.group, IDP_CopyProperty(link)); } @@ -426,22 +426,22 @@ static IDProperty *IDP_CopyGroup(IDProperty *prop) void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) { IDProperty *other, *prop; - for (prop=src->data.group.first; prop; prop=prop->next) { - other= BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name)); - if (other && prop->type==other->type) { + for (prop = src->data.group.first; prop; prop = prop->next) { + other = BLI_findstring(&dest->data.group, prop->name, offsetof(IDProperty, name)); + if (other && prop->type == other->type) { switch (prop->type) { case IDP_INT: case IDP_FLOAT: case IDP_DOUBLE: - other->data= prop->data; + other->data = prop->data; break; case IDP_GROUP: IDP_SyncGroupValues(other, prop); break; default: { - IDProperty *tmp= other; - IDProperty *copy= IDP_CopyProperty(prop); + IDProperty *tmp = other; + IDProperty *copy = IDP_CopyProperty(prop); BLI_insertlinkafter(&dest->data.group, other, copy); BLI_remlink(&dest->data.group, tmp); @@ -460,8 +460,8 @@ void IDP_SyncGroupValues(IDProperty *dest, IDProperty *src) void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) { IDProperty *loop, *prop; - for (prop=src->data.group.first; prop; prop=prop->next) { - for (loop=dest->data.group.first; loop; loop=loop->next) { + for (prop = src->data.group.first; prop; prop = prop->next) { + for (loop = dest->data.group.first; loop; loop = loop->next) { if (strcmp(loop->name, prop->name) == 0) { IDProperty *copy = IDP_CopyProperty(prop); @@ -489,7 +489,7 @@ void IDP_ReplaceGroupInGroup(IDProperty *dest, IDProperty *src) void IDP_ReplaceInGroup(IDProperty *group, IDProperty *prop) { IDProperty *loop; - if ((loop= IDP_GetPropertyFromGroup(group, prop->name))) { + if ((loop = IDP_GetPropertyFromGroup(group, prop->name))) { BLI_insertlink(&group->data.group, loop, prop); BLI_remlink(&group->data.group, loop); @@ -539,7 +539,7 @@ IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) IDProperty *IDP_GetPropertyTypeFromGroup(IDProperty *prop, const char *name, const char type) { - IDProperty *idprop= IDP_GetPropertyFromGroup(prop, name); + IDProperty *idprop = IDP_GetPropertyFromGroup(prop, name); return (idprop && idprop->type == type) ? idprop : NULL; } @@ -553,20 +553,20 @@ void *IDP_GetGroupIterator(IDProperty *prop) IDPIter *iter = MEM_callocN(sizeof(IDPIter), "IDPIter"); iter->next = prop->data.group.first; iter->parent = prop; - return (void*) iter; + return (void *) iter; } IDProperty *IDP_GroupIterNext(void *vself) { - IDPIter *self = (IDPIter*) vself; - Link *next = (Link*) self->next; + IDPIter *self = (IDPIter *) vself; + Link *next = (Link *) self->next; if (self->next == NULL) { MEM_freeN(self); return NULL; } self->next = next->next; - return (void*) next; + return (void *) next; } void IDP_FreeIterBeforeEnd(void *vself) @@ -581,7 +581,7 @@ void IDP_FreeIterBeforeEnd(void *vself) static void IDP_FreeGroup(IDProperty *prop) { IDProperty *loop; - for (loop=prop->data.group.first; loop; loop=loop->next) { + for (loop = prop->data.group.first; loop; loop = loop->next) { IDP_FreeProperty(loop); } BLI_freelistN(&prop->data.group); @@ -635,7 +635,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return ((prop1->len == prop2->len) && strncmp(IDP_String(prop1), IDP_String(prop2), prop1->len) == 0); else if (prop1->type == IDP_ARRAY) { if (prop1->len == prop2->len && prop1->subtype == prop2->subtype) - return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype]*prop1->len); + return memcmp(IDP_Array(prop1), IDP_Array(prop2), idp_size_table[(int)prop1->subtype] * prop1->len); else return 0; } @@ -645,8 +645,8 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) if (BLI_countlist(&prop1->data.group) != BLI_countlist(&prop2->data.group)) return 0; - for (link1=prop1->data.group.first; link1; link1=link1->next) { - link2= IDP_GetPropertyFromGroup(prop2, link1->name); + for (link1 = prop1->data.group.first; link1; link1 = link1->next) { + link2 = IDP_GetPropertyFromGroup(prop2, link1->name); if (!IDP_EqualsProperties(link1, link2)) return 0; @@ -655,14 +655,14 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) return 1; } else if (prop1->type == IDP_IDPARRAY) { - IDProperty *array1= IDP_IDPArray(prop1); - IDProperty *array2= IDP_IDPArray(prop2); + IDProperty *array1 = IDP_IDPArray(prop1); + IDProperty *array2 = IDP_IDPArray(prop2); int i; if (prop1->len != prop2->len) return 0; - for (i=0; ilen; i++) + for (i = 0; i < prop1->len; i++) if (!IDP_EqualsProperties(&array1[i], &array2[i])) return 0; } @@ -673,7 +673,7 @@ int IDP_EqualsProperties(IDProperty *prop1, IDProperty *prop2) /* 'val' is never NULL, don't check */ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *name) { - IDProperty *prop=NULL; + IDProperty *prop = NULL; switch (type) { case IDP_INT: @@ -682,11 +682,11 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n break; case IDP_FLOAT: prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); - *(float*)&prop->data.val = val->f; + *(float *)&prop->data.val = val->f; break; case IDP_DOUBLE: prop = MEM_callocN(sizeof(IDProperty), "IDProperty float"); - *(double*)&prop->data.val = val->d; + *(double *)&prop->data.val = val->d; break; case IDP_ARRAY: { @@ -699,7 +699,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n prop = MEM_callocN(sizeof(IDProperty), "IDProperty array"); prop->subtype = val->array.type; if (val->array.len) - prop->data.pointer = MEM_callocN(idp_size_table[val->array.type]*val->array.len, "id property array"); + prop->data.pointer = MEM_callocN(idp_size_table[val->array.type] * val->array.len, "id property array"); prop->len = prop->totallen = val->array.len; break; } @@ -724,7 +724,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n prop->len = prop->totallen = val->string.len; memcpy(prop->data.pointer, st, val->string.len); } - prop->subtype= IDP_STRING_SUB_BYTE; + prop->subtype = IDP_STRING_SUB_BYTE; } else { if (st == NULL) { @@ -738,7 +738,7 @@ IDProperty *IDP_New(const int type, const IDPropertyTemplate *val, const char *n prop->len = prop->totallen = stlen; memcpy(prop->data.pointer, st, stlen); } - prop->subtype= IDP_STRING_SUB_UTF8; + prop->subtype = IDP_STRING_SUB_UTF8; } break; } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 9c5c99592ed..aff1e65224b 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -92,18 +92,18 @@ #include "BLO_sys_types.h" // for intptr_t support /* max int, to indicate we don't store sequences in ibuf */ -#define IMA_NO_INDEX 0x7FEFEFEF +#define IMA_NO_INDEX 0x7FEFEFEF /* quick lookup: supports 1 million frames, thousand passes */ -#define IMA_MAKE_INDEX(frame, index) ((frame)<<10)+index -#define IMA_INDEX_FRAME(index) (index>>10) -#define IMA_INDEX_PASS(index) (index & ~1023) +#define IMA_MAKE_INDEX(frame, index) ((frame) << 10) + index +#define IMA_INDEX_FRAME(index) (index >> 10) +#define IMA_INDEX_PASS(index) (index & ~1023) /* ******** IMAGE PROCESSING ************* */ -static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ +static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ { - struct ImBuf * tbuf1, * tbuf2; + struct ImBuf *tbuf1, *tbuf2; if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; @@ -129,9 +129,9 @@ static void de_interlace_ng(struct ImBuf *ibuf) /* neogeo fields */ ibuf->y /= 2; } -static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ +static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ { - struct ImBuf * tbuf1, * tbuf2; + struct ImBuf *tbuf1, *tbuf2; if (ibuf == NULL) return; if (ibuf->flags & IB_fields) return; @@ -157,9 +157,9 @@ static void de_interlace_st(struct ImBuf *ibuf) /* standard fields */ ibuf->y /= 2; } -void image_de_interlace(Image *ima, int odd) +void BKE_image_de_interlace(Image *ima, int odd) { - ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL); + ImBuf *ibuf = BKE_image_get_ibuf(ima, NULL); if (ibuf) { if (odd) de_interlace_st(ibuf); @@ -185,20 +185,20 @@ static void image_free_buffers(Image *ima) } if (ima->anim) IMB_free_anim(ima->anim); - ima->anim= NULL; + ima->anim = NULL; if (ima->rr) { RE_FreeRenderResult(ima->rr); - ima->rr= NULL; + ima->rr = NULL; } GPU_free_image(ima); - ima->ok= IMA_OK; + ima->ok = IMA_OK; } /* called by library too, do not free ima itself */ -void free_image(Image *ima) +void BKE_image_free(Image *ima) { int a; @@ -212,10 +212,10 @@ void free_image(Image *ima) BKE_previewimg_free(&ima->preview); - for (a=0; arenders[a]) { RE_FreeRenderResult(ima->renders[a]); - ima->renders[a]= NULL; + ima->renders[a] = NULL; } } } @@ -225,17 +225,17 @@ static Image *image_alloc(const char *name, short source, short type) { Image *ima; - ima= alloc_libblock(&G.main->image, ID_IM, name); + ima = BKE_libblock_alloc(&G.main->image, ID_IM, name); if (ima) { - ima->ok= IMA_OK; + ima->ok = IMA_OK; - ima->xrep= ima->yrep= 1; - ima->aspx= ima->aspy= 1.0; - ima->gen_x= 1024; ima->gen_y= 1024; - ima->gen_type= 1; /* no defines yet? */ + ima->xrep = ima->yrep = 1; + ima->aspx = ima->aspy = 1.0; + ima->gen_x = 1024; ima->gen_y = 1024; + ima->gen_type = 1; /* no defines yet? */ - ima->source= source; - ima->type= type; + ima->source = source; + ima->type = type; } return ima; } @@ -246,14 +246,14 @@ static ImBuf *image_get_ibuf(Image *ima, int index, int frame) /* this function is intended to be thread safe. with IMA_NO_INDEX this * should be OK, but when iterating over the list this is more tricky * */ - if (index==IMA_NO_INDEX) + if (index == IMA_NO_INDEX) return ima->ibufs.first; else { ImBuf *ibuf; - index= IMA_MAKE_INDEX(frame, index); - for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) - if (ibuf->index==index) + index = IMA_MAKE_INDEX(frame, index); + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) + if (ibuf->index == index) return ibuf; return NULL; @@ -276,15 +276,15 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) if (ibuf) { ImBuf *link; - if (index!=IMA_NO_INDEX) - index= IMA_MAKE_INDEX(frame, index); + if (index != IMA_NO_INDEX) + index = IMA_MAKE_INDEX(frame, index); /* insert based on index */ - for (link= ima->ibufs.first; link; link= link->next) - if (link->index>=index) + for (link = ima->ibufs.first; link; link = link->next) + if (link->index >= index) break; - ibuf->index= index; + ibuf->index = index; if (ima->flag & IMA_CM_PREDIVIDE) ibuf->flags |= IB_cm_predivide; else @@ -294,29 +294,29 @@ static void image_assign_ibuf(Image *ima, ImBuf *ibuf, int index, int frame) BLI_insertlinkbefore(&ima->ibufs, link, ibuf); /* now we don't want copies? */ - if (link && ibuf->index==link->index) + if (link && ibuf->index == link->index) image_remove_ibuf(ima, link); } } /* empty image block, of similar type and filename */ -Image *copy_image(Image *ima) +Image *BKE_image_copy(Image *ima) { - Image *nima= image_alloc(ima->id.name+2, ima->source, ima->type); + Image *nima = image_alloc(ima->id.name + 2, ima->source, ima->type); BLI_strncpy(nima->name, ima->name, sizeof(ima->name)); - nima->flag= ima->flag; - nima->tpageflag= ima->tpageflag; + nima->flag = ima->flag; + nima->tpageflag = ima->tpageflag; - nima->gen_x= ima->gen_x; - nima->gen_y= ima->gen_y; - nima->gen_type= ima->gen_type; + nima->gen_x = ima->gen_x; + nima->gen_y = ima->gen_y; + nima->gen_type = ima->gen_type; - nima->animspeed= ima->animspeed; + nima->animspeed = ima->animspeed; - nima->aspx= ima->aspx; - nima->aspy= ima->aspy; + nima->aspx = ima->aspx; + nima->aspy = ima->aspy; return nima; } @@ -327,56 +327,56 @@ static void extern_local_image(Image *UNUSED(ima)) * match id_make_local pattern. */ } -void make_local_image(struct Image *ima) +void BKE_image_make_local(struct Image *ima) { - Main *bmain= G.main; + Main *bmain = G.main; Tex *tex; Brush *brush; Mesh *me; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (ima->id.lib==NULL) return; + if (ima->id.lib == NULL) return; /* Can't take short cut here: must check meshes at least because of bogus * texface ID refs. - z0r */ #if 0 - if (ima->id.us==1) { + if (ima->id.us == 1) { id_clear_lib_data(bmain, &ima->id); extern_local_image(ima); return; } #endif - for (tex= bmain->tex.first; tex; tex= tex->id.next) { + for (tex = bmain->tex.first; tex; tex = tex->id.next) { if (tex->ima == ima) { - if (tex->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (tex->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - for (brush= bmain->brush.first; brush; brush= brush->id.next) { + for (brush = bmain->brush.first; brush; brush = brush->id.next) { if (brush->clone.image == ima) { - if (brush->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (brush->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - for (me= bmain->mesh.first; me; me= me->id.next) { + for (me = bmain->mesh.first; me; me = me->id.next) { if (me->mtface) { MTFace *tface; int a, i; - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; + tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) { + for (a = 0; a < me->totface; a++, tface++) { if (tface->tpage == ima) { - if (me->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (me->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } @@ -387,14 +387,14 @@ void make_local_image(struct Image *ima) MTexPoly *mtpoly; int a, i; - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - mtpoly= (MTexPoly*)me->pdata.layers[i].data; + mtpoly = (MTexPoly *)me->pdata.layers[i].data; - for (a=0; atotpoly; a++, mtpoly++) { + for (a = 0; a < me->totpoly; a++, mtpoly++) { if (mtpoly->tpage == ima) { - if (me->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (me->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } @@ -408,55 +408,55 @@ void make_local_image(struct Image *ima) extern_local_image(ima); } else if (is_local && is_lib) { - Image *ima_new= copy_image(ima); + Image *ima_new = BKE_image_copy(ima); - ima_new->id.us= 0; + ima_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, ima->id.lib, &ima_new->id); - tex= bmain->tex.first; + tex = bmain->tex.first; while (tex) { - if (tex->id.lib==NULL) { - if (tex->ima==ima) { + if (tex->id.lib == NULL) { + if (tex->ima == ima) { tex->ima = ima_new; ima_new->id.us++; ima->id.us--; } } - tex= tex->id.next; + tex = tex->id.next; } - brush= bmain->brush.first; + brush = bmain->brush.first; while (brush) { - if (brush->id.lib==NULL) { - if (brush->clone.image==ima) { + if (brush->id.lib == NULL) { + if (brush->clone.image == ima) { brush->clone.image = ima_new; ima_new->id.us++; ima->id.us--; } } - brush= brush->id.next; + brush = brush->id.next; } /* Transfer references in texfaces. Texfaces don't add to image ID * user count *unless* there are no other users. See * readfile.c:lib_link_mtface. */ - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { if (me->mtface) { MTFace *tface; int a, i; - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; + tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) { + for (a = 0; a < me->totface; a++, tface++) { if (tface->tpage == ima) { tface->tpage = ima_new; if (ima_new->id.us == 0) { - tface->tpage->id.us= 1; + tface->tpage->id.us = 1; } - id_lib_extern((ID*)ima_new); + id_lib_extern((ID *)ima_new); } } } @@ -467,24 +467,24 @@ void make_local_image(struct Image *ima) MTexPoly *mtpoly; int a, i; - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - mtpoly= (MTexPoly*)me->pdata.layers[i].data; + mtpoly = (MTexPoly *)me->pdata.layers[i].data; - for (a=0; atotpoly; a++, mtpoly++) { + for (a = 0; a < me->totpoly; a++, mtpoly++) { if (mtpoly->tpage == ima) { mtpoly->tpage = ima_new; if (ima_new->id.us == 0) { - mtpoly->tpage->id.us= 1; + mtpoly->tpage->id.us = 1; } - id_lib_extern((ID*)ima_new); + id_lib_extern((ID *)ima_new); } } } } } - me= me->id.next; + me = me->id.next; } } } @@ -494,140 +494,149 @@ void BKE_image_merge(Image *dest, Image *source) ImBuf *ibuf; /* sanity check */ - if (dest && source && dest!=source) { + if (dest && source && dest != source) { - while ((ibuf= source->ibufs.first)) { + while ((ibuf = source->ibufs.first)) { BLI_remlink(&source->ibufs, ibuf); image_assign_ibuf(dest, ibuf, IMA_INDEX_PASS(ibuf->index), IMA_INDEX_FRAME(ibuf->index)); } - free_libblock(&G.main->image, source); + BKE_libblock_free(&G.main->image, source); } } +Image *BKE_image_load(const char *filepath) +{ + Image *ima; + int file, len; + const char *libname; + char str[FILE_MAX]; + + BLI_strncpy(str, filepath, sizeof(str)); + BLI_path_abs(str, G.main->name); + + /* exists? */ + file = BLI_open(str, O_BINARY | O_RDONLY, 0); + if (file == -1) return NULL; + close(file); + + /* create a short library name */ + len = strlen(filepath); + + while (len > 0 && filepath[len - 1] != '/' && filepath[len - 1] != '\\') len--; + libname = filepath + len; + + ima = image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); + BLI_strncpy(ima->name, filepath, sizeof(ima->name)); + + if (BLI_testextensie_array(filepath, imb_ext_movie)) + ima->source = IMA_SRC_MOVIE; + + return ima; +} /* checks if image was already loaded, then returns same image */ /* otherwise creates new. */ /* does not load ibuf itself */ /* pass on optional frame for #name images */ -Image *BKE_add_image_file(const char *name) +Image *BKE_image_load_exists(const char *filepath) { Image *ima; - int file, len; - const char *libname; char str[FILE_MAX], strtest[FILE_MAX]; - BLI_strncpy(str, name, sizeof(str)); + BLI_strncpy(str, filepath, sizeof(str)); BLI_path_abs(str, G.main->name); - - /* exists? */ - file= BLI_open(str, O_BINARY|O_RDONLY, 0); - if (file== -1) return NULL; - close(file); - + /* first search an identical image */ - for (ima= G.main->image.first; ima; ima= ima->id.next) { - if (ima->source!=IMA_SRC_VIEWER && ima->source!=IMA_SRC_GENERATED) { + for (ima = G.main->image.first; ima; ima = ima->id.next) { + if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { BLI_strncpy(strtest, ima->name, sizeof(ima->name)); BLI_path_abs(strtest, G.main->name); - if (BLI_path_cmp(strtest, str)==0) { - if (ima->anim==NULL || ima->id.us==0) { - BLI_strncpy(ima->name, name, sizeof(ima->name)); /* for stringcode */ - ima->id.us++; /* officially should not, it doesn't link here! */ - if (ima->ok==0) - ima->ok= IMA_OK; + if (BLI_path_cmp(strtest, str) == 0) { + if (ima->anim == NULL || ima->id.us == 0) { + BLI_strncpy(ima->name, filepath, sizeof(ima->name)); /* for stringcode */ + ima->id.us++; /* officially should not, it doesn't link here! */ + if (ima->ok == 0) + ima->ok = IMA_OK; /* RETURN! */ return ima; } } } } - /* add new image */ - - /* create a short library name */ - len= strlen(name); - - while (len > 0 && name[len - 1] != '/' && name[len - 1] != '\\') len--; - libname= name+len; - - ima= image_alloc(libname, IMA_SRC_FILE, IMA_TYPE_IMAGE); - BLI_strncpy(ima->name, name, sizeof(ima->name)); - - if (BLI_testextensie_array(name, imb_ext_movie)) - ima->source= IMA_SRC_MOVIE; - - return ima; + + return BKE_image_load(filepath); } static ImBuf *add_ibuf_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { ImBuf *ibuf; - unsigned char *rect= NULL; - float *rect_float= NULL; + unsigned char *rect = NULL; + float *rect_float = NULL; if (floatbuf) { - ibuf= IMB_allocImBuf(width, height, depth, IB_rectfloat); - rect_float= (float*)ibuf->rect_float; + ibuf = IMB_allocImBuf(width, height, depth, IB_rectfloat); + rect_float = (float *)ibuf->rect_float; } else { - ibuf= IMB_allocImBuf(width, height, depth, IB_rect); - rect= (unsigned char*)ibuf->rect; + ibuf = IMB_allocImBuf(width, height, depth, IB_rect); + rect = (unsigned char *)ibuf->rect; } BLI_strncpy(ibuf->name, name, sizeof(ibuf->name)); ibuf->userflags |= IB_BITMAPDIRTY; switch (uvtestgrid) { - case 1: - BKE_image_buf_fill_checker(rect, rect_float, width, height); - break; - case 2: - BKE_image_buf_fill_checker_color(rect, rect_float, width, height); - break; - default: - BKE_image_buf_fill_color(rect, rect_float, width, height, color); + case 1: + BKE_image_buf_fill_checker(rect, rect_float, width, height); + break; + case 2: + BKE_image_buf_fill_checker_color(rect, rect_float, width, height); + break; + default: + BKE_image_buf_fill_color(rect, rect_float, width, height, color); } return ibuf; } /* adds new image block, creates ImBuf and initializes color */ -Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) +Image *BKE_image_add_generated(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]) { /* on save, type is changed to FILE in editsima.c */ - Image *ima= image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); + Image *ima = image_alloc(name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST); if (ima) { ImBuf *ibuf; /* BLI_strncpy(ima->name, name, FILE_MAX); */ /* don't do this, this writes in ain invalid filepath! */ - ima->gen_x= width; - ima->gen_y= height; - ima->gen_type= uvtestgrid; + ima->gen_x = width; + ima->gen_y = height; + ima->gen_type = uvtestgrid; ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0); - ibuf= add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); + ibuf = add_ibuf_size(width, height, ima->name, depth, floatbuf, uvtestgrid, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } return ima; } /* creates an image image owns the imbuf passed */ -Image *BKE_add_image_imbuf(ImBuf *ibuf) +Image *BKE_image_add_from_imbuf(ImBuf *ibuf) { /* on save, type is changed to FILE in editsima.c */ Image *ima; - ima= image_alloc(BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); + ima = image_alloc(BLI_path_basename(ibuf->name), IMA_SRC_FILE, IMA_TYPE_IMAGE); if (ima) { BLI_strncpy(ima->name, ibuf->name, FILE_MAX); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } return ima; @@ -636,20 +645,20 @@ Image *BKE_add_image_imbuf(ImBuf *ibuf) /* packs rect from memory as PNG */ void BKE_image_memorypack(Image *ima) { - ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ImBuf *ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); - if (ibuf==NULL) + if (ibuf == NULL) return; if (ima->packedfile) { freePackedFile(ima->packedfile); ima->packedfile = NULL; } - ibuf->ftype= PNG; - ibuf->planes= R_IMF_PLANES_RGBA; + ibuf->ftype = PNG; + ibuf->planes = R_IMF_PLANES_RGBA; IMB_saveiff(ibuf, ibuf->name, IB_rect | IB_mem); - if (ibuf->encodedbuffer==NULL) { + if (ibuf->encodedbuffer == NULL) { printf("memory save for pack error\n"); } else { @@ -657,19 +666,19 @@ void BKE_image_memorypack(Image *ima) pf->data = ibuf->encodedbuffer; pf->size = ibuf->encodedsize; - ima->packedfile= pf; - ibuf->encodedbuffer= NULL; - ibuf->encodedsize= 0; + ima->packedfile = pf; + ibuf->encodedbuffer = NULL; + ibuf->encodedsize = 0; ibuf->userflags &= ~IB_BITMAPDIRTY; - if (ima->source==IMA_SRC_GENERATED) { - ima->source= IMA_SRC_FILE; - ima->type= IMA_TYPE_IMAGE; + if (ima->source == IMA_SRC_GENERATED) { + ima->source = IMA_SRC_FILE; + ima->type = IMA_TYPE_IMAGE; } } } -void tag_image_time(Image *ima) +void BKE_image_tag_time(Image *ima) { if (ima) ima->lastused = (int)PIL_check_seconds_timer(); @@ -681,7 +690,7 @@ static void tag_all_images_time() Image *ima; int ctime = (int)PIL_check_seconds_timer(); - ima= G.main->image.first; + ima = G.main->image.first; while (ima) { if (ima->bindcode || ima->repbind || ima->ibufs.first) { ima->lastused = ctime; @@ -709,9 +718,9 @@ void free_old_images(void) lasttime = ctime; - ima= G.main->image.first; + ima = G.main->image.first; while (ima) { - if ((ima->flag & IMA_NOCOLLECT)==0 && ctime - ima->lastused > U.textimeout) { + if ((ima->flag & IMA_NOCOLLECT) == 0 && ctime - ima->lastused > U.textimeout) { /* If it's in GL memory, deallocate and set time tag to current time * This gives textures a "second chance" to be used before dying. */ if (ima->bindcode || ima->repbind) { @@ -733,18 +742,18 @@ static uintptr_t image_mem_size(Image *ima) int level; uintptr_t size = 0; - size= 0; + size = 0; /* viewers have memory depending on other rules, has no valid rect pointer */ - if (ima->source==IMA_SRC_VIEWER) + if (ima->source == IMA_SRC_VIEWER) return 0; - for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) { + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { if (ibuf->rect) size += MEM_allocN_len(ibuf->rect); else if (ibuf->rect_float) size += MEM_allocN_len(ibuf->rect_float); - for (level=0; levelmipmap[level]; + for (level = 0; level < IB_MIPMAP_LEVELS; level++) { + ibufm = ibuf->mipmap[level]; if (ibufm) { if (ibufm->rect) size += MEM_allocN_len(ibufm->rect); else if (ibufm->rect_float) size += MEM_allocN_len(ibufm->rect_float); @@ -758,18 +767,18 @@ static uintptr_t image_mem_size(Image *ima) void BKE_image_print_memlist(void) { Image *ima; - uintptr_t size, totsize= 0; + uintptr_t size, totsize = 0; - for (ima= G.main->image.first; ima; ima= ima->id.next) + for (ima = G.main->image.first; ima; ima = ima->id.next) totsize += image_mem_size(ima); - printf("\ntotal image memory len: %.3f MB\n", (double)totsize/(double)(1024*1024)); + printf("\ntotal image memory len: %.3f MB\n", (double)totsize / (double)(1024 * 1024)); - for (ima= G.main->image.first; ima; ima= ima->id.next) { - size= image_mem_size(ima); + for (ima = G.main->image.first; ima; ima = ima->id.next) { + size = image_mem_size(ima); if (size) - printf("%s len: %.3f MB\n", ima->id.name+2, (double)size/(double)(1024*1024)); + printf("%s len: %.3f MB\n", ima->id.name + 2, (double)size / (double)(1024 * 1024)); } } @@ -779,30 +788,30 @@ void BKE_image_free_all_textures(void) Image *ima; /* unsigned int totsize= 0; */ - for (ima= G.main->image.first; ima; ima= ima->id.next) + for (ima = G.main->image.first; ima; ima = ima->id.next) ima->id.flag &= ~LIB_DOIT; - for (tex= G.main->tex.first; tex; tex= tex->id.next) + for (tex = G.main->tex.first; tex; tex = tex->id.next) if (tex->ima) tex->ima->id.flag |= LIB_DOIT; - for (ima= G.main->image.first; ima; ima= ima->id.next) { + for (ima = G.main->image.first; ima; ima = ima->id.next) { if (ima->ibufs.first && (ima->id.flag & LIB_DOIT)) { ImBuf *ibuf; - for (ibuf= ima->ibufs.first; ibuf; ibuf= ibuf->next) { + for (ibuf = ima->ibufs.first; ibuf; ibuf = ibuf->next) { /* escape when image is painted on */ if (ibuf->userflags & IB_BITMAPDIRTY) break; #if 0 if (ibuf->mipmap[0]) - totsize+= 1.33*ibuf->x*ibuf->y*4; + totsize += 1.33 * ibuf->x * ibuf->y * 4; else - totsize+= ibuf->x*ibuf->y*4; + totsize += ibuf->x * ibuf->y * 4; #endif } - if (ibuf==NULL) + if (ibuf == NULL) image_free_buffers(ima); } } @@ -814,13 +823,13 @@ void BKE_image_free_anim_ibufs(Image *ima, int except_frame) { ImBuf *ibuf, *nbuf; - for (ibuf= ima->ibufs.first; ibuf; ibuf= nbuf) { - nbuf= ibuf->next; + for (ibuf = ima->ibufs.first; ibuf; ibuf = nbuf) { + nbuf = ibuf->next; if (ibuf->userflags & IB_BITMAPDIRTY) continue; - if (ibuf->index==IMA_NO_INDEX) + if (ibuf->index == IMA_NO_INDEX) continue; - if (except_frame!=IMA_INDEX_FRAME(ibuf->index)) { + if (except_frame != IMA_INDEX_FRAME(ibuf->index)) { BLI_remlink(&ima->ibufs, ibuf); if (ibuf->userdata) { @@ -836,7 +845,7 @@ void BKE_image_all_free_anim_ibufs(int cfra) { Image *ima; - for (ima= G.main->image.first; ima; ima= ima->id.next) + for (ima = G.main->image.first; ima; ima = ima->id.next) if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) BKE_image_free_anim_ibufs(ima, cfra); } @@ -846,47 +855,47 @@ void BKE_image_all_free_anim_ibufs(int cfra) int BKE_imtype_to_ftype(const char imtype) { - if (imtype==R_IMF_IMTYPE_TARGA) + if (imtype == R_IMF_IMTYPE_TARGA) return TGA; - else if (imtype==R_IMF_IMTYPE_RAWTGA) + else if (imtype == R_IMF_IMTYPE_RAWTGA) return RAWTGA; - else if (imtype== R_IMF_IMTYPE_IRIS) + else if (imtype == R_IMF_IMTYPE_IRIS) return IMAGIC; #ifdef WITH_HDR - else if (imtype==R_IMF_IMTYPE_RADHDR) + else if (imtype == R_IMF_IMTYPE_RADHDR) return RADHDR; #endif - else if (imtype==R_IMF_IMTYPE_PNG) + else if (imtype == R_IMF_IMTYPE_PNG) return PNG; #ifdef WITH_DDS - else if (imtype==R_IMF_IMTYPE_DDS) + else if (imtype == R_IMF_IMTYPE_DDS) return DDS; #endif - else if (imtype==R_IMF_IMTYPE_BMP) + else if (imtype == R_IMF_IMTYPE_BMP) return BMP; #ifdef WITH_TIFF - else if (imtype==R_IMF_IMTYPE_TIFF) + else if (imtype == R_IMF_IMTYPE_TIFF) return TIF; #endif - else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) + else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) return OPENEXR; #ifdef WITH_CINEON - else if (imtype==R_IMF_IMTYPE_CINEON) + else if (imtype == R_IMF_IMTYPE_CINEON) return CINEON; - else if (imtype==R_IMF_IMTYPE_DPX) + else if (imtype == R_IMF_IMTYPE_DPX) return DPX; #endif #ifdef WITH_OPENJPEG - else if (imtype==R_IMF_IMTYPE_JP2) + else if (imtype == R_IMF_IMTYPE_JP2) return JP2; #endif else - return JPG|90; + return JPG | 90; } char BKE_ftype_to_imtype(const int ftype) { - if (ftype==0) + if (ftype == 0) return R_IMF_IMTYPE_TARGA; else if (ftype == IMAGIC) return R_IMF_IMTYPE_IRIS; @@ -930,15 +939,15 @@ char BKE_ftype_to_imtype(const int ftype) int BKE_imtype_is_movie(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_AVIRAW: - case R_IMF_IMTYPE_AVIJPEG: - case R_IMF_IMTYPE_AVICODEC: - case R_IMF_IMTYPE_QUICKTIME: - case R_IMF_IMTYPE_FFMPEG: - case R_IMF_IMTYPE_H264: - case R_IMF_IMTYPE_THEORA: - case R_IMF_IMTYPE_XVID: - case R_IMF_IMTYPE_FRAMESERVER: + case R_IMF_IMTYPE_AVIRAW: + case R_IMF_IMTYPE_AVIJPEG: + case R_IMF_IMTYPE_AVICODEC: + case R_IMF_IMTYPE_QUICKTIME: + case R_IMF_IMTYPE_FFMPEG: + case R_IMF_IMTYPE_H264: + case R_IMF_IMTYPE_THEORA: + case R_IMF_IMTYPE_XVID: + case R_IMF_IMTYPE_FRAMESERVER: return 1; } return 0; @@ -947,8 +956,8 @@ int BKE_imtype_is_movie(const char imtype) int BKE_imtype_supports_zbuf(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_IRIZ: - case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ + case R_IMF_IMTYPE_IRIZ: + case R_IMF_IMTYPE_OPENEXR: /* but not R_IMF_IMTYPE_MULTILAYER */ return 1; } return 0; @@ -957,7 +966,7 @@ int BKE_imtype_supports_zbuf(const char imtype) int BKE_imtype_supports_compress(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_PNG: + case R_IMF_IMTYPE_PNG: return 1; } return 0; @@ -966,9 +975,9 @@ int BKE_imtype_supports_compress(const char imtype) int BKE_imtype_supports_quality(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_JPEG90: - case R_IMF_IMTYPE_JP2: - case R_IMF_IMTYPE_AVIJPEG: + case R_IMF_IMTYPE_JPEG90: + case R_IMF_IMTYPE_JP2: + case R_IMF_IMTYPE_AVIJPEG: return 1; } return 0; @@ -976,32 +985,32 @@ int BKE_imtype_supports_quality(const char imtype) char BKE_imtype_valid_channels(const char imtype) { - char chan_flag= IMA_CHAN_FLAG_RGB; /* assume all support rgb */ + char chan_flag = IMA_CHAN_FLAG_RGB; /* assume all support rgb */ /* alpha */ switch (imtype) { - case R_IMF_IMTYPE_TARGA: - case R_IMF_IMTYPE_IRIS: - case R_IMF_IMTYPE_PNG: - /* case R_IMF_IMTYPE_BMP: */ /* read but not write */ - case R_IMF_IMTYPE_RADHDR: - case R_IMF_IMTYPE_TIFF: - case R_IMF_IMTYPE_OPENEXR: - case R_IMF_IMTYPE_MULTILAYER: - case R_IMF_IMTYPE_DDS: - case R_IMF_IMTYPE_JP2: - case R_IMF_IMTYPE_QUICKTIME: + case R_IMF_IMTYPE_TARGA: + case R_IMF_IMTYPE_IRIS: + case R_IMF_IMTYPE_PNG: + /* case R_IMF_IMTYPE_BMP: */ /* read but not write */ + case R_IMF_IMTYPE_RADHDR: + case R_IMF_IMTYPE_TIFF: + case R_IMF_IMTYPE_OPENEXR: + case R_IMF_IMTYPE_MULTILAYER: + case R_IMF_IMTYPE_DDS: + case R_IMF_IMTYPE_JP2: + case R_IMF_IMTYPE_QUICKTIME: chan_flag |= IMA_CHAN_FLAG_ALPHA; } /* bw */ switch (imtype) { - case R_IMF_IMTYPE_PNG: - case R_IMF_IMTYPE_JPEG90: - case R_IMF_IMTYPE_TARGA: - case R_IMF_IMTYPE_RAWTGA: - case R_IMF_IMTYPE_TIFF: - case R_IMF_IMTYPE_IRIS: + case R_IMF_IMTYPE_PNG: + case R_IMF_IMTYPE_JPEG90: + case R_IMF_IMTYPE_TARGA: + case R_IMF_IMTYPE_RAWTGA: + case R_IMF_IMTYPE_TIFF: + case R_IMF_IMTYPE_IRIS: chan_flag |= IMA_CHAN_FLAG_BW; } @@ -1011,23 +1020,23 @@ char BKE_imtype_valid_channels(const char imtype) char BKE_imtype_valid_depths(const char imtype) { switch (imtype) { - case R_IMF_IMTYPE_RADHDR: - return R_IMF_CHAN_DEPTH_32; - case R_IMF_IMTYPE_TIFF: - return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16; - case R_IMF_IMTYPE_OPENEXR: - return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32; - case R_IMF_IMTYPE_MULTILAYER: - return R_IMF_CHAN_DEPTH_32; - /* eeh, cineone does some strange 10bits per channel */ - case R_IMF_IMTYPE_DPX: - case R_IMF_IMTYPE_CINEON: - return R_IMF_CHAN_DEPTH_12; - case R_IMF_IMTYPE_JP2: - return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; - /* most formats are 8bit only */ - default: - return R_IMF_CHAN_DEPTH_8; + case R_IMF_IMTYPE_RADHDR: + return R_IMF_CHAN_DEPTH_32; + case R_IMF_IMTYPE_TIFF: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_16; + case R_IMF_IMTYPE_OPENEXR: + return R_IMF_CHAN_DEPTH_16 | R_IMF_CHAN_DEPTH_32; + case R_IMF_IMTYPE_MULTILAYER: + return R_IMF_CHAN_DEPTH_32; + /* eeh, cineone does some strange 10bits per channel */ + case R_IMF_IMTYPE_DPX: + case R_IMF_IMTYPE_CINEON: + return R_IMF_CHAN_DEPTH_12; + case R_IMF_IMTYPE_JP2: + return R_IMF_CHAN_DEPTH_8 | R_IMF_CHAN_DEPTH_12 | R_IMF_CHAN_DEPTH_16; + /* most formats are 8bit only */ + default: + return R_IMF_CHAN_DEPTH_8; } } @@ -1074,78 +1083,78 @@ char BKE_imtype_from_arg(const char *imtype_arg) int BKE_add_image_extension(char *string, const char imtype) { - const char *extension= NULL; + const char *extension = NULL; - if (imtype== R_IMF_IMTYPE_IRIS) { + if (imtype == R_IMF_IMTYPE_IRIS) { if (!BLI_testextensie(string, ".rgb")) - extension= ".rgb"; + extension = ".rgb"; } - else if (imtype==R_IMF_IMTYPE_IRIZ) { + else if (imtype == R_IMF_IMTYPE_IRIZ) { if (!BLI_testextensie(string, ".rgb")) - extension= ".rgb"; + extension = ".rgb"; } #ifdef WITH_HDR - else if (imtype==R_IMF_IMTYPE_RADHDR) { + else if (imtype == R_IMF_IMTYPE_RADHDR) { if (!BLI_testextensie(string, ".hdr")) - extension= ".hdr"; + extension = ".hdr"; } #endif else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) { if (!BLI_testextensie(string, ".png")) - extension= ".png"; + extension = ".png"; } #ifdef WITH_DDS - else if (imtype==R_IMF_IMTYPE_DDS) { + else if (imtype == R_IMF_IMTYPE_DDS) { if (!BLI_testextensie(string, ".dds")) - extension= ".dds"; + extension = ".dds"; } #endif - else if (imtype==R_IMF_IMTYPE_RAWTGA) { + else if (imtype == R_IMF_IMTYPE_RAWTGA) { if (!BLI_testextensie(string, ".tga")) - extension= ".tga"; + extension = ".tga"; } - else if (imtype==R_IMF_IMTYPE_BMP) { + else if (imtype == R_IMF_IMTYPE_BMP) { if (!BLI_testextensie(string, ".bmp")) - extension= ".bmp"; + extension = ".bmp"; } #ifdef WITH_TIFF - else if (imtype==R_IMF_IMTYPE_TIFF) { + else if (imtype == R_IMF_IMTYPE_TIFF) { if (!BLI_testextensie(string, ".tif") && !BLI_testextensie(string, ".tiff")) { - extension= ".tif"; + extension = ".tif"; } } #endif #ifdef WITH_OPENEXR else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { if (!BLI_testextensie(string, ".exr")) - extension= ".exr"; + extension = ".exr"; } #endif #ifdef WITH_CINEON - else if (imtype==R_IMF_IMTYPE_CINEON) { + else if (imtype == R_IMF_IMTYPE_CINEON) { if (!BLI_testextensie(string, ".cin")) - extension= ".cin"; + extension = ".cin"; } - else if (imtype==R_IMF_IMTYPE_DPX) { + else if (imtype == R_IMF_IMTYPE_DPX) { if (!BLI_testextensie(string, ".dpx")) - extension= ".dpx"; + extension = ".dpx"; } #endif - else if (imtype==R_IMF_IMTYPE_TARGA) { + else if (imtype == R_IMF_IMTYPE_TARGA) { if (!BLI_testextensie(string, ".tga")) - extension= ".tga"; + extension = ".tga"; } #ifdef WITH_OPENJPEG - else if (imtype==R_IMF_IMTYPE_JP2) { + else if (imtype == R_IMF_IMTYPE_JP2) { if (!BLI_testextensie(string, ".jp2")) - extension= ".jp2"; + extension = ".jp2"; } #endif else { // R_IMF_IMTYPE_AVICODEC, R_IMF_IMTYPE_AVIRAW, R_IMF_IMTYPE_AVIJPEG, R_IMF_IMTYPE_JPEG90, R_IMF_IMTYPE_QUICKTIME etc if (!(BLI_testextensie(string, ".jpg") || BLI_testextensie(string, ".jpeg"))) - extension= ".jpg"; + extension = ".jpg"; } if (extension) { @@ -1177,17 +1186,17 @@ void BKE_imformat_defaults(ImageFormatData *im_format) /* could allow access externally - 512 is for long names, 64 is for id names */ typedef struct StampData { - char file[512]; - char note[512]; - char date[512]; - char marker[512]; - char time[512]; - char frame[512]; - char camera[64]; - char cameralens[64]; - char scene[64]; - char strip[64]; - char rendertime[64]; + char file[512]; + char note[512]; + char date[512]; + char marker[512]; + char time[512]; + char frame[512]; + char camera[64]; + char cameralens[64]; + char scene[64]; + char strip[64]; + char rendertime[64]; } StampData; static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int do_prefix) @@ -1197,7 +1206,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d time_t t; if (scene->r.stamp & R_STAMP_FILENAME) { - BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s":"%s", G.relbase_valid ? G.main->name:""); + BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s" : "%s", G.relbase_valid ? G.main->name : ""); } else { stamp_data->file[0] = '\0'; @@ -1214,20 +1223,20 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_DATE) { t = time(NULL); tl = localtime(&t); - BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); - BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s":"%s", text); + BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year + 1900, tl->tm_mon + 1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec); + BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s" : "%s", text); } else { stamp_data->date[0] = '\0'; } if (scene->r.stamp & R_STAMP_MARKER) { - char *name = scene_find_last_marker_name(scene, CFRA); + char *name = BKE_scene_find_last_marker_name(scene, CFRA); - if (name) BLI_strncpy(text, name, sizeof(text)); - else BLI_strncpy(text, "", sizeof(text)); + if (name) BLI_strncpy(text, name, sizeof(text)); + else BLI_strncpy(text, "", sizeof(text)); - BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text); + BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s" : "%s", text); } else { stamp_data->marker[0] = '\0'; @@ -1236,8 +1245,8 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_TIME) { int f = (int)(scene->r.cfra % scene->r.frs_sec); int s = (int)(scene->r.cfra / scene->r.frs_sec); - int h= 0; - int m= 0; + int h = 0; + int m = 0; if (s) { m = (int)(s / 60); @@ -1254,7 +1263,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d else BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f); - BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s":"%s", text); + BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s" : "%s", text); } else { stamp_data->time[0] = '\0'; @@ -1262,20 +1271,20 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (scene->r.stamp & R_STAMP_FRAME) { char fmtstr[32]; - int digits= 1; + int digits = 1; - if (scene->r.efra>9) - digits= 1 + (int) log10(scene->r.efra); + if (scene->r.efra > 9) + digits = 1 + (int) log10(scene->r.efra); - BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di":"%%0%di", digits); - BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra); + BLI_snprintf(fmtstr, sizeof(fmtstr), do_prefix ? "Frame %%0%di" : "%%0%di", digits); + BLI_snprintf(stamp_data->frame, sizeof(stamp_data->frame), fmtstr, scene->r.cfra); } else { stamp_data->frame[0] = '\0'; } if (scene->r.stamp & R_STAMP_CAMERA) { - BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", camera ? camera->id.name+2 : ""); + BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s" : "%s", camera ? camera->id.name + 2 : ""); } else { stamp_data->camera[0] = '\0'; @@ -1285,41 +1294,41 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d if (camera && camera->type == OB_CAMERA) { BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens); } - else BLI_strncpy(text, "", sizeof(text)); + else BLI_strncpy(text, "", sizeof(text)); - BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text); + BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s" : "%s", text); } else { stamp_data->cameralens[0] = '\0'; } if (scene->r.stamp & R_STAMP_SCENE) { - BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s":"%s", scene->id.name+2); + BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s" : "%s", scene->id.name + 2); } else { stamp_data->scene[0] = '\0'; } if (scene->r.stamp & R_STAMP_SEQSTRIP) { - Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra); + Sequence *seq = seq_foreground_frame_get(scene, scene->r.cfra); - if (seq) BLI_strncpy(text, seq->name+2, sizeof(text)); - else BLI_strncpy(text, "", sizeof(text)); + if (seq) BLI_strncpy(text, seq->name + 2, sizeof(text)); + else BLI_strncpy(text, "", sizeof(text)); - BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text); + BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s" : "%s", text); } else { stamp_data->strip[0] = '\0'; } { - Render *re= RE_GetRender(scene->id.name); - RenderStats *stats= re ? RE_GetStats(re):NULL; + Render *re = RE_GetRender(scene->id.name); + RenderStats *stats = re ? RE_GetStats(re) : NULL; if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) { BLI_timestr(stats->lastframetime, text); - BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s":"%s", text); + BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s" : "%s", text); } else { stamp_data->rendertime[0] = '\0'; @@ -1333,7 +1342,7 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec float w, h, pad; int x, y, y_ofs; float h_fixed; - const int mono= blf_mono_font_render; // XXX + const int mono = blf_mono_font_render; // XXX #define BUFF_MARGIN_X 2 #define BUFF_MARGIN_Y 1 @@ -1345,29 +1354,29 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* TODO, do_versions */ if (scene->r.stamp_font_id < 8) - scene->r.stamp_font_id= 12; + scene->r.stamp_font_id = 12; /* set before return */ BLF_size(mono, scene->r.stamp_font_id, 72); BLF_buffer(mono, rectf, rect, width, height, channels); BLF_buffer_col(mono, scene->r.fg_stamp[0], scene->r.fg_stamp[1], scene->r.fg_stamp[2], 1.0); - pad= BLF_width_max(mono); + pad = BLF_width_max(mono); /* use 'h_fixed' rather than 'h', aligns better */ - h_fixed= BLF_height_max(mono); + h_fixed = BLF_height_max(mono); y_ofs = -BLF_descender(mono); - x= 0; - y= height; + x = 0; + y = height; if (stamp_data.file[0]) { /* Top left corner */ - BLF_width_and_height(mono, stamp_data.file, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.file, &w, &h); h = h_fixed; y -= h; /* also a little of space to the background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and draw the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1379,11 +1388,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Top left corner, below File */ if (stamp_data.note[0]) { - BLF_width_and_height(mono, stamp_data.note, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.note, &w, &h); h = h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.note); @@ -1394,11 +1403,11 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Top left corner, below File (or Note) */ if (stamp_data.date[0]) { - BLF_width_and_height(mono, stamp_data.date, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.date, &w, &h); h = h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.date); @@ -1409,25 +1418,25 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Top left corner, below File, Date or Note */ if (stamp_data.rendertime[0]) { - BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.rendertime, &w, &h); h = h_fixed; y -= h; /* and space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, 0, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.rendertime); } - x= 0; - y= 0; + x = 0; + y = 0; /* Bottom left corner, leaving space for timing */ if (stamp_data.marker[0]) { - BLF_width_and_height(mono, stamp_data.marker, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.marker, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1439,10 +1448,10 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec /* Left bottom corner */ if (stamp_data.time[0]) { - BLF_width_and_height(mono, stamp_data.time, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.time, &w, &h); h = h_fixed; /* extra space for background */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1453,10 +1462,10 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } if (stamp_data.frame[0]) { - BLF_width_and_height(mono, stamp_data.frame, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.frame, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ BLF_position(mono, x, y + y_ofs, 0.0); @@ -1467,10 +1476,10 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } if (stamp_data.camera[0]) { - BLF_width_and_height(mono, stamp_data.camera, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.camera, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.camera); @@ -1479,37 +1488,37 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec } if (stamp_data.cameralens[0]) { - BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.cameralens, &w, &h); h = h_fixed; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.cameralens); } if (stamp_data.scene[0]) { - BLF_width_and_height(mono, stamp_data.scene, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.scene, &w, &h); h = h_fixed; /* Bottom right corner, with an extra space because blenfont is too strict! */ - x= width - w - 2; + x = width - w - 2; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); /* and pad the text. */ - BLF_position(mono, x, y+y_ofs, 0.0); + BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.scene); } if (stamp_data.strip[0]) { - BLF_width_and_height(mono, stamp_data.strip, &w, &h); h= h_fixed; + BLF_width_and_height(mono, stamp_data.strip, &w, &h); h = h_fixed; /* Top right corner, with an extra space because blenfont is too strict! */ - x= width - w - pad; - y= height - h; + x = width - w - pad; + y = height - h; /* extra space for background. */ - buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x-BUFF_MARGIN_X, y-BUFF_MARGIN_Y, x+w+BUFF_MARGIN_X, y+h+BUFF_MARGIN_Y); + buf_rectfill_area(rect, rectf, width, height, scene->r.bg_stamp, x - BUFF_MARGIN_X, y - BUFF_MARGIN_Y, x + w + BUFF_MARGIN_X, y + h + BUFF_MARGIN_Y); BLF_position(mono, x, y + y_ofs, 0.0); BLF_draw_buffer(mono, stamp_data.strip); @@ -1522,42 +1531,42 @@ void BKE_stamp_buf(Scene *scene, Object *camera, unsigned char *rect, float *rec #undef BUFF_MARGIN_Y } -void BKE_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) +void BKE_imbuf_stamp_info(Scene *scene, Object *camera, struct ImBuf *ibuf) { struct StampData stamp_data; - if (!ibuf) return; + if (!ibuf) return; /* fill all the data values, no prefix */ stampdata(scene, camera, &stamp_data, 0); - if (stamp_data.file[0]) IMB_metadata_change_field (ibuf, "File", stamp_data.file); - if (stamp_data.note[0]) IMB_metadata_change_field (ibuf, "Note", stamp_data.note); - if (stamp_data.date[0]) IMB_metadata_change_field (ibuf, "Date", stamp_data.date); - if (stamp_data.marker[0]) IMB_metadata_change_field (ibuf, "Marker", stamp_data.marker); - if (stamp_data.time[0]) IMB_metadata_change_field (ibuf, "Time", stamp_data.time); - if (stamp_data.frame[0]) IMB_metadata_change_field (ibuf, "Frame", stamp_data.frame); - if (stamp_data.camera[0]) IMB_metadata_change_field (ibuf, "Camera", stamp_data.camera); - if (stamp_data.cameralens[0]) IMB_metadata_change_field (ibuf, "Lens", stamp_data.cameralens); - if (stamp_data.scene[0]) IMB_metadata_change_field (ibuf, "Scene", stamp_data.scene); - if (stamp_data.strip[0]) IMB_metadata_change_field (ibuf, "Strip", stamp_data.strip); - if (stamp_data.rendertime[0]) IMB_metadata_change_field (ibuf, "RenderTime", stamp_data.rendertime); + if (stamp_data.file[0]) IMB_metadata_change_field(ibuf, "File", stamp_data.file); + if (stamp_data.note[0]) IMB_metadata_change_field(ibuf, "Note", stamp_data.note); + if (stamp_data.date[0]) IMB_metadata_change_field(ibuf, "Date", stamp_data.date); + if (stamp_data.marker[0]) IMB_metadata_change_field(ibuf, "Marker", stamp_data.marker); + if (stamp_data.time[0]) IMB_metadata_change_field(ibuf, "Time", stamp_data.time); + if (stamp_data.frame[0]) IMB_metadata_change_field(ibuf, "Frame", stamp_data.frame); + if (stamp_data.camera[0]) IMB_metadata_change_field(ibuf, "Camera", stamp_data.camera); + if (stamp_data.cameralens[0]) IMB_metadata_change_field(ibuf, "Lens", stamp_data.cameralens); + if (stamp_data.scene[0]) IMB_metadata_change_field(ibuf, "Scene", stamp_data.scene); + if (stamp_data.strip[0]) IMB_metadata_change_field(ibuf, "Strip", stamp_data.strip); + if (stamp_data.rendertime[0]) IMB_metadata_change_field(ibuf, "RenderTime", stamp_data.rendertime); } -int BKE_alphatest_ibuf(ImBuf *ibuf) +int BKE_imbuf_alpha_test(ImBuf *ibuf) { int tot; if (ibuf->rect_float) { - float *buf= ibuf->rect_float; - for (tot= ibuf->x * ibuf->y; tot--; buf+=4) { + float *buf = ibuf->rect_float; + for (tot = ibuf->x * ibuf->y; tot--; buf += 4) { if (buf[3] < 1.0f) { return TRUE; } } } else if (ibuf->rect) { - unsigned char *buf= (unsigned char *)ibuf->rect; - for (tot= ibuf->x * ibuf->y; tot--; buf+=4) { + unsigned char *buf = (unsigned char *)ibuf->rect; + for (tot = ibuf->x * ibuf->y; tot--; buf += 4) { if (buf[3] != 255) { return TRUE; } @@ -1569,75 +1578,75 @@ int BKE_alphatest_ibuf(ImBuf *ibuf) /* note: imf->planes is ignored here, its assumed the image channels * are already set */ -int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) +int BKE_imbuf_write(ImBuf *ibuf, const char *name, ImageFormatData *imf) { - char imtype= imf->imtype; - char compress= imf->compress; - char quality= imf->quality; + char imtype = imf->imtype; + char compress = imf->compress; + char quality = imf->quality; int ok; - if (imtype== R_IMF_IMTYPE_IRIS) { - ibuf->ftype= IMAGIC; + if (imtype == R_IMF_IMTYPE_IRIS) { + ibuf->ftype = IMAGIC; } #ifdef WITH_HDR - else if (imtype==R_IMF_IMTYPE_RADHDR) { - ibuf->ftype= RADHDR; + else if (imtype == R_IMF_IMTYPE_RADHDR) { + ibuf->ftype = RADHDR; } #endif else if (ELEM5(imtype, R_IMF_IMTYPE_PNG, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_THEORA, R_IMF_IMTYPE_XVID)) { - ibuf->ftype= PNG; + ibuf->ftype = PNG; - if (imtype==R_IMF_IMTYPE_PNG) + if (imtype == R_IMF_IMTYPE_PNG) ibuf->ftype |= compress; } #ifdef WITH_DDS - else if (imtype==R_IMF_IMTYPE_DDS) { - ibuf->ftype= DDS; + else if (imtype == R_IMF_IMTYPE_DDS) { + ibuf->ftype = DDS; } #endif - else if (imtype==R_IMF_IMTYPE_BMP) { - ibuf->ftype= BMP; + else if (imtype == R_IMF_IMTYPE_BMP) { + ibuf->ftype = BMP; } #ifdef WITH_TIFF - else if (imtype==R_IMF_IMTYPE_TIFF) { - ibuf->ftype= TIF; + else if (imtype == R_IMF_IMTYPE_TIFF) { + ibuf->ftype = TIF; if (imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= TIF_16BIT; } #endif #ifdef WITH_OPENEXR - else if (imtype==R_IMF_IMTYPE_OPENEXR || imtype==R_IMF_IMTYPE_MULTILAYER) { - ibuf->ftype= OPENEXR; + else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) { + ibuf->ftype = OPENEXR; if (imf->depth == R_IMF_CHAN_DEPTH_16) ibuf->ftype |= OPENEXR_HALF; ibuf->ftype |= (imf->exr_codec & OPENEXR_COMPRESS); if (!(imf->flag & R_IMF_FLAG_ZBUF)) - ibuf->zbuf_float = NULL; /* signal for exr saving */ + ibuf->zbuf_float = NULL; /* signal for exr saving */ } #endif #ifdef WITH_CINEON - else if (imtype==R_IMF_IMTYPE_CINEON) { + else if (imtype == R_IMF_IMTYPE_CINEON) { ibuf->ftype = CINEON; } - else if (imtype==R_IMF_IMTYPE_DPX) { + else if (imtype == R_IMF_IMTYPE_DPX) { ibuf->ftype = DPX; } #endif - else if (imtype==R_IMF_IMTYPE_TARGA) { - ibuf->ftype= TGA; + else if (imtype == R_IMF_IMTYPE_TARGA) { + ibuf->ftype = TGA; } - else if (imtype==R_IMF_IMTYPE_RAWTGA) { - ibuf->ftype= RAWTGA; + else if (imtype == R_IMF_IMTYPE_RAWTGA) { + ibuf->ftype = RAWTGA; } #ifdef WITH_OPENJPEG - else if (imtype==R_IMF_IMTYPE_JP2) { - if (quality < 10) quality= 90; - ibuf->ftype= JP2|quality; + else if (imtype == R_IMF_IMTYPE_JP2) { + if (quality < 10) quality = 90; + ibuf->ftype = JP2 | quality; if (imf->depth == R_IMF_CHAN_DEPTH_16) { ibuf->ftype |= JP2_16BIT; @@ -1659,8 +1668,8 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) #endif else { /* R_IMF_IMTYPE_JPEG90, etc. default we save jpegs */ - if (quality < 10) quality= 90; - ibuf->ftype= JPG|quality; + if (quality < 10) quality = 90; + ibuf->ftype = JPG | quality; } BLI_make_existing_file(name); @@ -1673,42 +1682,42 @@ int BKE_write_ibuf(ImBuf *ibuf, const char *name, ImageFormatData *imf) return(ok); } -/* same as BKE_write_ibuf() but crappy workaround not to perminantly modify +/* same as BKE_imbuf_write() but crappy workaround not to perminantly modify * _some_, values in the imbuf */ -int BKE_write_ibuf_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, - const short save_copy) +int BKE_imbuf_write_as(ImBuf *ibuf, const char *name, ImageFormatData *imf, + const short save_copy) { - ImBuf ibuf_back= *ibuf; + ImBuf ibuf_back = *ibuf; int ok; /* all data is rgba anyway, * this just controls how to save for some formats */ - ibuf->planes= imf->planes; + ibuf->planes = imf->planes; - ok= BKE_write_ibuf(ibuf, name, imf); + ok = BKE_imbuf_write(ibuf, name, imf); if (save_copy) { /* note that we are not restoring _all_ settings */ - ibuf->planes= ibuf_back.planes; - ibuf->ftype= ibuf_back.ftype; + ibuf->planes = ibuf_back.planes; + ibuf->ftype = ibuf_back.ftype; } return ok; } -int BKE_write_ibuf_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf) +int BKE_imbuf_write_stamp(Scene *scene, struct Object *camera, ImBuf *ibuf, const char *name, struct ImageFormatData *imf) { if (scene && scene->r.stamp & R_STAMP_ALL) - BKE_stamp_info(scene, camera, ibuf); + BKE_imbuf_stamp_info(scene, camera, ibuf); - return BKE_write_ibuf(ibuf, name, imf); + return BKE_imbuf_write(ibuf, name, imf); } void BKE_makepicstring(char *string, const char *base, const char *relbase, int frame, const char imtype, const short use_ext, const short use_frames) { - if (string==NULL) return; - BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ + if (string == NULL) return; + BLI_strncpy(string, base, FILE_MAX - 10); /* weak assumption */ BLI_path_abs(string, relbase); if (use_frames) @@ -1720,8 +1729,7 @@ void BKE_makepicstring(char *string, const char *base, const char *relbase, int } /* used by sequencer too */ -struct anim *openanim(const char *name, int flags, int streamindex) -{ +struct anim *openanim(const char *name, int flags, int streamindex){ struct anim *anim; struct ImBuf *ibuf; @@ -1769,16 +1777,16 @@ Image *BKE_image_verify_viewer(int type, const char *name) { Image *ima; - for (ima=G.main->image.first; ima; ima= ima->id.next) - if (ima->source==IMA_SRC_VIEWER) - if (ima->type==type) + for (ima = G.main->image.first; ima; ima = ima->id.next) + if (ima->source == IMA_SRC_VIEWER) + if (ima->type == type) break; - if (ima==NULL) - ima= image_alloc(name, IMA_SRC_VIEWER, type); + if (ima == NULL) + ima = image_alloc(name, IMA_SRC_VIEWER, type); /* happens on reload, imagewindow cannot be image user when hidden*/ - if (ima->id.us==0) + if (ima->id.us == 0) id_us_plus(&ima->id); return ima; @@ -1791,78 +1799,78 @@ void BKE_image_assign_ibuf(Image *ima, ImBuf *ibuf) void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) { - if (ima==NULL) + if (ima == NULL) return; switch (signal) { - case IMA_SIGNAL_FREE: - image_free_buffers(ima); - if (iuser) - iuser->ok= 1; - break; - case IMA_SIGNAL_SRC_CHANGE: - if (ima->type == IMA_TYPE_UV_TEST) - if (ima->source != IMA_SRC_GENERATED) - ima->type= IMA_TYPE_IMAGE; + case IMA_SIGNAL_FREE: + image_free_buffers(ima); + if (iuser) + iuser->ok = 1; + break; + case IMA_SIGNAL_SRC_CHANGE: + if (ima->type == IMA_TYPE_UV_TEST) + if (ima->source != IMA_SRC_GENERATED) + ima->type = IMA_TYPE_IMAGE; - if (ima->source==IMA_SRC_GENERATED) { - if (ima->gen_x==0 || ima->gen_y==0) { - ImBuf *ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); - if (ibuf) { - ima->gen_x= ibuf->x; - ima->gen_y= ibuf->y; + if (ima->source == IMA_SRC_GENERATED) { + if (ima->gen_x == 0 || ima->gen_y == 0) { + ImBuf *ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); + if (ibuf) { + ima->gen_x = ibuf->x; + ima->gen_y = ibuf->y; + } } } - } - /* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */ - if (ima->type!=IMA_TYPE_MULTILAYER) - image_free_buffers(ima); - - ima->ok= 1; - if (iuser) - iuser->ok= 1; - break; - - case IMA_SIGNAL_RELOAD: - /* try to repack file */ - if (ima->packedfile) { - PackedFile *pf; - pf = newPackedFile(NULL, ima->name, ID_BLEND_PATH(G.main, &ima->id)); - if (pf) { - freePackedFile(ima->packedfile); - ima->packedfile = pf; + /* force reload on first use, but not for multilayer, that makes nodes and buttons in ui drawing fail */ + if (ima->type != IMA_TYPE_MULTILAYER) image_free_buffers(ima); - } - else { - printf("ERROR: Image not available. Keeping packed image\n"); - } - } - else - image_free_buffers(ima); - - if (iuser) - iuser->ok= 1; - - break; - case IMA_SIGNAL_USER_NEW_IMAGE: - if (iuser) { - iuser->ok= 1; - if (ima->source==IMA_SRC_FILE || ima->source==IMA_SRC_SEQUENCE) { - if (ima->type==IMA_TYPE_MULTILAYER) { - iuser->multi_index= 0; - iuser->layer= iuser->pass= 0; + + ima->ok = 1; + if (iuser) + iuser->ok = 1; + break; + + case IMA_SIGNAL_RELOAD: + /* try to repack file */ + if (ima->packedfile) { + PackedFile *pf; + pf = newPackedFile(NULL, ima->name, ID_BLEND_PATH(G.main, &ima->id)); + if (pf) { + freePackedFile(ima->packedfile); + ima->packedfile = pf; + image_free_buffers(ima); + } + else { + printf("ERROR: Image not available. Keeping packed image\n"); } } - } - break; + else + image_free_buffers(ima); + + if (iuser) + iuser->ok = 1; + + break; + case IMA_SIGNAL_USER_NEW_IMAGE: + if (iuser) { + iuser->ok = 1; + if (ima->source == IMA_SRC_FILE || ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_MULTILAYER) { + iuser->multi_index = 0; + iuser->layer = iuser->pass = 0; + } + } + } + break; } /* don't use notifiers because they are not 100% sure to succeeded * this also makes sure all scenes are accounted for. */ { Scene *scene; - for (scene= G.main->scene.first; scene; scene= scene->id.next) { + for (scene = G.main->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { nodeUpdateID(scene->nodetree, &ima->id); } @@ -1876,32 +1884,32 @@ void BKE_image_signal(Image *ima, ImageUser *iuser, int signal) RenderPass *BKE_image_multilayer_index(RenderResult *rr, ImageUser *iuser) { RenderLayer *rl; - RenderPass *rpass= NULL; + RenderPass *rpass = NULL; - if (rr==NULL) + if (rr == NULL) return NULL; if (iuser) { - short index= 0, rl_index= 0, rp_index; + short index = 0, rl_index = 0, rp_index; - for (rl= rr->layers.first; rl; rl= rl->next, rl_index++) { - rp_index= 0; - for (rpass= rl->passes.first; rpass; rpass= rpass->next, index++, rp_index++) - if (iuser->layer==rl_index && iuser->pass==rp_index) + for (rl = rr->layers.first; rl; rl = rl->next, rl_index++) { + rp_index = 0; + for (rpass = rl->passes.first; rpass; rpass = rpass->next, index++, rp_index++) + if (iuser->layer == rl_index && iuser->pass == rp_index) break; if (rpass) break; } if (rpass) - iuser->multi_index= index; + iuser->multi_index = index; else - iuser->multi_index= 0; + iuser->multi_index = 0; } - if (rpass==NULL) { - rl= rr->layers.first; + if (rpass == NULL) { + rl = rr->layers.first; if (rl) - rpass= rl->passes.first; + rpass = rl->passes.first; } return rpass; @@ -1912,7 +1920,7 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima) if (ima->rr) { return ima->rr; } - else if (ima->type==IMA_TYPE_R_RESULT) { + else if (ima->type == IMA_TYPE_R_RESULT) { if (ima->render_slot == ima->last_render_slot) return RE_AcquireResultRead(RE_GetRender(scene->id.name)); else @@ -1924,8 +1932,8 @@ RenderResult *BKE_image_acquire_renderresult(Scene *scene, Image *ima) void BKE_image_release_renderresult(Scene *scene, Image *ima) { - if (ima->rr); - else if (ima->type==IMA_TYPE_R_RESULT) { + if (ima->rr) ; + else if (ima->type == IMA_TYPE_R_RESULT) { if (ima->render_slot == ima->last_render_slot) RE_ReleaseResult(RE_GetRender(scene->id.name)); } @@ -1935,20 +1943,20 @@ void BKE_image_backup_render(Scene *scene, Image *ima) { /* called right before rendering, ima->renders contains render * result pointers for everything but the current render */ - Render *re= RE_GetRender(scene->id.name); - int slot= ima->render_slot, last= ima->last_render_slot; + Render *re = RE_GetRender(scene->id.name); + int slot = ima->render_slot, last = ima->last_render_slot; if (slot != last) { if (ima->renders[slot]) { RE_FreeRenderResult(ima->renders[slot]); - ima->renders[slot]= NULL; + ima->renders[slot] = NULL; } - ima->renders[last]= NULL; + ima->renders[last] = NULL; RE_SwapResult(re, &ima->renders[last]); } - ima->last_render_slot= slot; + ima->last_render_slot = slot; } /* after imbuf load, openexr type can return with a exrhandle open */ @@ -1956,22 +1964,22 @@ void BKE_image_backup_render(Scene *scene, Image *ima) static void image_create_multilayer(Image *ima, ImBuf *ibuf, int framenr) { - ima->rr= RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); + ima->rr = RE_MultilayerConvert(ibuf->userdata, ibuf->x, ibuf->y); #ifdef WITH_OPENEXR IMB_exr_close(ibuf->userdata); #endif - ibuf->userdata= NULL; + ibuf->userdata = NULL; if (ima->rr) - ima->rr->framenr= framenr; + ima->rr->framenr = framenr; } /* common stuff to do with images after loading */ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) { /* preview is NULL when it has never been used as an icon before */ - if (G.background==0 && ima->preview==NULL) + if (G.background == 0 && ima->preview == NULL) BKE_icon_changed(BKE_icon_getid(&ima->id)); /* fields */ @@ -1982,7 +1990,7 @@ static void image_initialize_after_load(Image *ima, ImBuf *ibuf) /* timer */ ima->lastused = clock() / CLOCKS_PER_SEC; - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } @@ -1997,14 +2005,14 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) if (ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; - ima->lastframe= frame; + ima->lastframe = frame; BLI_strncpy(name, ima->name, sizeof(name)); BLI_stringdec(name, head, tail, &numlen); BLI_stringenc(name, head, tail, numlen, frame); BLI_path_abs(name, ID_BLEND_PATH(G.main, &ima->id)); - flag= IB_rect|IB_multilayer; + flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; @@ -2013,21 +2021,21 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) #if 0 if (ibuf) { - printf(AT" loaded %s\n", name); + printf(AT " loaded %s\n", name); } else { - printf(AT" missed %s\n", name); + printf(AT " missed %s\n", name); } #endif if (ibuf) { #ifdef WITH_OPENEXR /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ - if (ibuf->ftype==OPENEXR && ibuf->userdata) { + if (ibuf->ftype == OPENEXR && ibuf->userdata) { image_create_multilayer(ima, ibuf, frame); - ima->type= IMA_TYPE_MULTILAYER; + ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); - ibuf= NULL; + ibuf = NULL; } else { image_initialize_after_load(ima, ibuf); @@ -2039,30 +2047,30 @@ static ImBuf *image_load_sequence_file(Image *ima, ImageUser *iuser, int frame) #endif } else - ima->ok= 0; + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int frame) { - struct ImBuf *ibuf= NULL; + struct ImBuf *ibuf = NULL; /* either we load from RenderResult, or we have to load a new one */ /* check for new RenderResult */ - if (ima->rr==NULL || frame!=ima->rr->framenr) { + if (ima->rr == NULL || frame != ima->rr->framenr) { /* copy to survive not found multilayer image */ - RenderResult *oldrr= ima->rr; + RenderResult *oldrr = ima->rr; - ima->rr= NULL; + ima->rr = NULL; ibuf = image_load_sequence_file(ima, iuser, frame); if (ibuf) { /* actually an error */ - ima->type= IMA_TYPE_IMAGE; + ima->type = IMA_TYPE_IMAGE; printf("error, multi is normal image\n"); } // printf("loaded new result %p\n", ima->rr); @@ -2072,34 +2080,34 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f if (oldrr) RE_FreeRenderResult(oldrr); } else { - ima->rr= oldrr; + ima->rr = oldrr; } } if (ima->rr) { - RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser); + RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); if (rpass) { // printf("load from pass %s\n", rpass->name); /* since we free render results, we copy the rect */ - ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); - ibuf->rect_float= MEM_dupallocN(rpass->rect); + ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); + ibuf->rect_float = MEM_dupallocN(rpass->rect); ibuf->flags |= IB_rectfloat; - ibuf->mall= IB_rectfloat; - ibuf->channels= rpass->channels; + ibuf->mall = IB_rectfloat; + ibuf->channels = rpass->channels; ibuf->profile = IB_PROFILE_LINEAR_RGB; image_initialize_after_load(ima, ibuf); - image_assign_ibuf(ima, ibuf, iuser?iuser->multi_index:0, frame); + image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : 0, frame); } // else printf("pass not found\n"); } else - ima->ok= 0; + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } @@ -2107,11 +2115,11 @@ static ImBuf *image_load_sequence_multilayer(Image *ima, ImageUser *iuser, int f static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) { - struct ImBuf *ibuf= NULL; + struct ImBuf *ibuf = NULL; - ima->lastframe= frame; + ima->lastframe = frame; - if (ima->anim==NULL) { + if (ima->anim == NULL) { char str[FILE_MAX]; BLI_strncpy(str, ima->name, FILE_MAX); @@ -2121,35 +2129,35 @@ static ImBuf *image_load_movie_file(Image *ima, ImageUser *iuser, int frame) ima->anim = openanim(str, IB_rect, 0); /* let's initialize this user */ - if (ima->anim && iuser && iuser->frames==0) - iuser->frames= IMB_anim_get_duration(ima->anim, - IMB_TC_RECORD_RUN); + if (ima->anim && iuser && iuser->frames == 0) + iuser->frames = IMB_anim_get_duration(ima->anim, + IMB_TC_RECORD_RUN); } if (ima->anim) { int dur = IMB_anim_get_duration(ima->anim, - IMB_TC_RECORD_RUN); - int fra= frame-1; + IMB_TC_RECORD_RUN); + int fra = frame - 1; - if (fra<0) fra = 0; - if (fra>(dur-1)) fra= dur-1; + if (fra < 0) fra = 0; + if (fra > (dur - 1)) fra = dur - 1; ibuf = IMB_makeSingleUser( - IMB_anim_absolute(ima->anim, fra, - IMB_TC_RECORD_RUN, - IMB_PROXY_NONE)); + IMB_anim_absolute(ima->anim, fra, + IMB_TC_RECORD_RUN, + IMB_PROXY_NONE)); if (ibuf) { image_initialize_after_load(ima, ibuf); image_assign_ibuf(ima, ibuf, 0, frame); } else - ima->ok= 0; + ima->ok = 0; } else - ima->ok= 0; + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } @@ -2166,13 +2174,13 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) /* is there a PackedFile with this image ? */ if (ima->packedfile) { - flag = IB_rect|IB_multilayer; + flag = IB_rect | IB_multilayer; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; - ibuf = IMB_ibImageFromMemory((unsigned char*)ima->packedfile->data, ima->packedfile->size, flag, ""); + ibuf = IMB_ibImageFromMemory((unsigned char *)ima->packedfile->data, ima->packedfile->size, flag, ""); } else { - flag= IB_rect|IB_multilayer|IB_metadata; + flag = IB_rect | IB_multilayer | IB_metadata; if (ima->flag & IMA_DO_PREMUL) flag |= IB_premul; @@ -2186,15 +2194,15 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) if (ibuf) { /* handle multilayer case, don't assign ibuf. will be handled in BKE_image_get_ibuf */ - if (ibuf->ftype==OPENEXR && ibuf->userdata) { + if (ibuf->ftype == OPENEXR && ibuf->userdata) { image_create_multilayer(ima, ibuf, cfra); - ima->type= IMA_TYPE_MULTILAYER; + ima->type = IMA_TYPE_MULTILAYER; IMB_freeImBuf(ibuf); - ibuf= NULL; + ibuf = NULL; } else { image_initialize_after_load(ima, ibuf); - assign= 1; + assign = 1; /* check if the image is a font image... */ detectBitmapFont(ibuf); @@ -2205,49 +2213,49 @@ static ImBuf *image_load_image_file(Image *ima, ImageUser *iuser, int cfra) } } else - ima->ok= 0; + ima->ok = 0; if (assign) image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } static ImBuf *image_get_ibuf_multilayer(Image *ima, ImageUser *iuser) { - ImBuf *ibuf= NULL; + ImBuf *ibuf = NULL; - if (ima->rr==NULL) { + if (ima->rr == NULL) { ibuf = image_load_image_file(ima, iuser, 0); if (ibuf) { /* actually an error */ - ima->type= IMA_TYPE_IMAGE; + ima->type = IMA_TYPE_IMAGE; return ibuf; } } if (ima->rr) { - RenderPass *rpass= BKE_image_multilayer_index(ima->rr, iuser); + RenderPass *rpass = BKE_image_multilayer_index(ima->rr, iuser); if (rpass) { - ibuf= IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); + ibuf = IMB_allocImBuf(ima->rr->rectx, ima->rr->recty, 32, 0); image_initialize_after_load(ima, ibuf); - ibuf->rect_float= rpass->rect; + ibuf->rect_float = rpass->rect; ibuf->flags |= IB_rectfloat; - ibuf->channels= rpass->channels; + ibuf->channels = rpass->channels; ibuf->profile = IB_PROFILE_LINEAR_RGB; - image_assign_ibuf(ima, ibuf, iuser?iuser->multi_index:IMA_NO_INDEX, 0); + image_assign_ibuf(ima, ibuf, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } } - if (ibuf==NULL) - ima->ok= 0; + if (ibuf == NULL) + ima->ok = 0; if (iuser) - iuser->ok= ima->ok; + iuser->ok = ima->ok; return ibuf; } @@ -2265,7 +2273,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ float dither; int channels, layer, pass; ImBuf *ibuf; - int from_render= (ima->render_slot == ima->last_render_slot); + int from_render = (ima->render_slot == ima->last_render_slot); if (!(iuser && iuser->scene)) return NULL; @@ -2274,18 +2282,18 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ if (!lock_r) return NULL; - re= RE_GetRender(iuser->scene->id.name); + re = RE_GetRender(iuser->scene->id.name); - channels= 4; - layer= (iuser)? iuser->layer: 0; - pass= (iuser)? iuser->pass: 0; + channels = 4; + layer = (iuser) ? iuser->layer : 0; + pass = (iuser) ? iuser->pass : 0; if (from_render) { RE_AcquireResultImage(re, &rres); } else if (ima->renders[ima->render_slot]) { - rres= *(ima->renders[ima->render_slot]); - rres.have_combined= rres.rectf != NULL; + rres = *(ima->renders[ima->render_slot]); + rres.have_combined = rres.rectf != NULL; } else memset(&rres, 0, sizeof(RenderResult)); @@ -2299,83 +2307,83 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ /* release is done in BKE_image_release_ibuf using lock_r */ if (from_render) { BLI_lock_thread(LOCK_VIEWER); - *lock_r= re; + *lock_r = re; } /* this gives active layer, composite or seqence result */ - rect= (unsigned int *)rres.rect32; - rectf= rres.rectf; - rectz= rres.rectz; - dither= iuser->scene->r.dither_intensity; + rect = (unsigned int *)rres.rect32; + rectf = rres.rectf; + rectz = rres.rectz; + dither = iuser->scene->r.dither_intensity; /* combined layer gets added as first layer */ - if (rres.have_combined && layer==0); + if (rres.have_combined && layer == 0) ; else if (rres.layers.first) { - RenderLayer *rl= BLI_findlink(&rres.layers, layer-(rres.have_combined?1:0)); + RenderLayer *rl = BLI_findlink(&rres.layers, layer - (rres.have_combined ? 1 : 0)); if (rl) { RenderPass *rpass; /* there's no combined pass, is in renderlayer itself */ - if (pass==0) { - rectf= rl->rectf; + if (pass == 0) { + rectf = rl->rectf; } else { - rpass= BLI_findlink(&rl->passes, pass-1); + rpass = BLI_findlink(&rl->passes, pass - 1); if (rpass) { - channels= rpass->channels; - rectf= rpass->rect; - dither= 0.0f; /* don't dither passes */ + channels = rpass->channels; + rectf = rpass->rect; + dither = 0.0f; /* don't dither passes */ } } - for (rpass= rl->passes.first; rpass; rpass= rpass->next) + for (rpass = rl->passes.first; rpass; rpass = rpass->next) if (rpass->passtype == SCE_PASS_Z) - rectz= rpass->rect; + rectz = rpass->rect; } } - ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); /* make ibuf if needed, and initialize it */ - if (ibuf==NULL) { - ibuf= IMB_allocImBuf(rres.rectx, rres.recty, 32, 0); + if (ibuf == NULL) { + ibuf = IMB_allocImBuf(rres.rectx, rres.recty, 32, 0); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); } - ibuf->x= rres.rectx; - ibuf->y= rres.recty; + ibuf->x = rres.rectx; + ibuf->y = rres.recty; /* free rect buffer if float buffer changes, so it can be recreated with * the updated result, and also in case we got byte buffer from sequencer, * so we don't keep reference to freed buffer */ - if (ibuf->rect_float!=rectf || rect || !rectf) + if (ibuf->rect_float != rectf || rect || !rectf) imb_freerectImBuf(ibuf); if (rect) - ibuf->rect= rect; + ibuf->rect = rect; if (rectf) { - ibuf->rect_float= rectf; + ibuf->rect_float = rectf; ibuf->flags |= IB_rectfloat; - ibuf->channels= channels; + ibuf->channels = channels; } else { - ibuf->rect_float= NULL; + ibuf->rect_float = NULL; ibuf->flags &= ~IB_rectfloat; } if (rectz) { - ibuf->zbuf_float= rectz; + ibuf->zbuf_float = rectz; ibuf->flags |= IB_zbuffloat; } else { - ibuf->zbuf_float= NULL; + ibuf->zbuf_float = NULL; ibuf->flags &= ~IB_zbuffloat; } /* since its possible to access the buffer from the image directly, set the profile [#25073] */ - ibuf->profile= (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; - ibuf->dither= dither; + ibuf->profile = (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT) ? IB_PROFILE_LINEAR_RGB : IB_PROFILE_NONE; + ibuf->dither = dither; if (iuser->scene->r.color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE) { ibuf->flags |= IB_cm_predivide; @@ -2386,7 +2394,7 @@ static ImBuf *image_get_render_result(Image *ima, ImageUser *iuser, void **lock_ ima->flag &= ~IMA_CM_PREDIVIDE; } - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; return ibuf; } @@ -2397,18 +2405,18 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame int frame = 0, index = 0; /* see if we already have an appropriate ibuf, with image source and type */ - if (ima->source==IMA_SRC_MOVIE) { - frame= iuser?iuser->framenr:ima->lastframe; - ibuf= image_get_ibuf(ima, 0, frame); + if (ima->source == IMA_SRC_MOVIE) { + frame = iuser ? iuser->framenr : ima->lastframe; + ibuf = image_get_ibuf(ima, 0, frame); /* XXX temp stuff? */ if (ima->lastframe != frame) ima->tpageflag |= IMA_TPAGE_REFRESH; ima->lastframe = frame; } - else if (ima->source==IMA_SRC_SEQUENCE) { - if (ima->type==IMA_TYPE_IMAGE) { - frame= iuser?iuser->framenr:ima->lastframe; - ibuf= image_get_ibuf(ima, 0, frame); + else if (ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_IMAGE) { + frame = iuser ? iuser->framenr : ima->lastframe; + ibuf = image_get_ibuf(ima, 0, frame); /* XXX temp stuff? */ if (ima->lastframe != frame) { @@ -2416,20 +2424,20 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame } ima->lastframe = frame; } - else if (ima->type==IMA_TYPE_MULTILAYER) { - frame= iuser?iuser->framenr:ima->lastframe; - index= iuser?iuser->multi_index:IMA_NO_INDEX; - ibuf= image_get_ibuf(ima, index, frame); + else if (ima->type == IMA_TYPE_MULTILAYER) { + frame = iuser ? iuser->framenr : ima->lastframe; + index = iuser ? iuser->multi_index : IMA_NO_INDEX; + ibuf = image_get_ibuf(ima, index, frame); } } - else if (ima->source==IMA_SRC_FILE) { - if (ima->type==IMA_TYPE_IMAGE) - ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); - else if (ima->type==IMA_TYPE_MULTILAYER) - ibuf= image_get_ibuf(ima, iuser?iuser->multi_index:IMA_NO_INDEX, 0); + else if (ima->source == IMA_SRC_FILE) { + if (ima->type == IMA_TYPE_IMAGE) + ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); + else if (ima->type == IMA_TYPE_MULTILAYER) + ibuf = image_get_ibuf(ima, iuser ? iuser->multi_index : IMA_NO_INDEX, 0); } else if (ima->source == IMA_SRC_GENERATED) { - ibuf= image_get_ibuf(ima, IMA_NO_INDEX, 0); + ibuf = image_get_ibuf(ima, IMA_NO_INDEX, 0); } else if (ima->source == IMA_SRC_VIEWER) { /* always verify entirely, not that this shouldn't happen @@ -2448,9 +2456,9 @@ static ImBuf *image_get_ibuf_threadsafe(Image *ima, ImageUser *iuser, int *frame * if not, use BKE_image_get_ibuf which doesn't require a release */ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) { - ImBuf *ibuf= NULL; + ImBuf *ibuf = NULL; float color[] = {0, 0, 0, 1}; - int frame= 0, index= 0; + int frame = 0, index = 0; /* This function is intended to be thread-safe. It postpones the mutex lock * until it needs to load the image, if the image is already there it @@ -2464,20 +2472,20 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) * 2) set ima/iuser->ok to 0 to IMA_OK_LOADED */ if (lock_r) - *lock_r= NULL; + *lock_r = NULL; /* quick reject tests */ - if (ima==NULL) + if (ima == NULL) return NULL; if (iuser) { - if (iuser->ok==0) + if (iuser->ok == 0) return NULL; } - else if (ima->ok==0) + else if (ima->ok == 0) return NULL; /* try to get the ibuf without locking */ - ibuf= image_get_ibuf_threadsafe(ima, iuser, &frame, &index); + ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); if (ibuf == NULL) { /* couldn't get ibuf and image is not ok, so let's lock and try to @@ -2487,75 +2495,75 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) /* need to check ok flag and loading ibuf again, because the situation * might have changed in the meantime */ if (iuser) { - if (iuser->ok==0) { + if (iuser->ok == 0) { BLI_unlock_thread(LOCK_IMAGE); return NULL; } } - else if (ima->ok==0) { + else if (ima->ok == 0) { BLI_unlock_thread(LOCK_IMAGE); return NULL; } - ibuf= image_get_ibuf_threadsafe(ima, iuser, &frame, &index); + ibuf = image_get_ibuf_threadsafe(ima, iuser, &frame, &index); if (ibuf == NULL) { /* we are sure we have to load the ibuf, using source and type */ - if (ima->source==IMA_SRC_MOVIE) { + if (ima->source == IMA_SRC_MOVIE) { /* source is from single file, use flipbook to store ibuf */ - ibuf= image_load_movie_file(ima, iuser, frame); + ibuf = image_load_movie_file(ima, iuser, frame); } - else if (ima->source==IMA_SRC_SEQUENCE) { - if (ima->type==IMA_TYPE_IMAGE) { + else if (ima->source == IMA_SRC_SEQUENCE) { + if (ima->type == IMA_TYPE_IMAGE) { /* regular files, ibufs in flipbook, allows saving */ - ibuf= image_load_sequence_file(ima, iuser, frame); + ibuf = image_load_sequence_file(ima, iuser, frame); } /* no else; on load the ima type can change */ - if (ima->type==IMA_TYPE_MULTILAYER) { + if (ima->type == IMA_TYPE_MULTILAYER) { /* only 1 layer/pass stored in imbufs, no exrhandle anim storage, no saving */ - ibuf= image_load_sequence_multilayer(ima, iuser, frame); + ibuf = image_load_sequence_multilayer(ima, iuser, frame); } } - else if (ima->source==IMA_SRC_FILE) { + else if (ima->source == IMA_SRC_FILE) { - if (ima->type==IMA_TYPE_IMAGE) - ibuf= image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ + if (ima->type == IMA_TYPE_IMAGE) + ibuf = image_load_image_file(ima, iuser, frame); /* cfra only for '#', this global is OK */ /* no else; on load the ima type can change */ - if (ima->type==IMA_TYPE_MULTILAYER) + if (ima->type == IMA_TYPE_MULTILAYER) /* keeps render result, stores ibufs in listbase, allows saving */ - ibuf= image_get_ibuf_multilayer(ima, iuser); + ibuf = image_get_ibuf_multilayer(ima, iuser); } else if (ima->source == IMA_SRC_GENERATED) { /* generated is: ibuf is allocated dynamically */ /* UV testgrid or black or solid etc */ - if (ima->gen_x==0) ima->gen_x= 1024; - if (ima->gen_y==0) ima->gen_y= 1024; - ibuf= add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color); + if (ima->gen_x == 0) ima->gen_x = 1024; + if (ima->gen_y == 0) ima->gen_y = 1024; + ibuf = add_ibuf_size(ima->gen_x, ima->gen_y, ima->name, 24, (ima->gen_flag & IMA_GEN_FLOAT) != 0, ima->gen_type, color); image_assign_ibuf(ima, ibuf, IMA_NO_INDEX, 0); - ima->ok= IMA_OK_LOADED; + ima->ok = IMA_OK_LOADED; } else if (ima->source == IMA_SRC_VIEWER) { - if (ima->type==IMA_TYPE_R_RESULT) { + if (ima->type == IMA_TYPE_R_RESULT) { /* always verify entirely, and potentially * returns pointer to release later */ - ibuf= image_get_render_result(ima, iuser, lock_r); + ibuf = image_get_render_result(ima, iuser, lock_r); } - else if (ima->type==IMA_TYPE_COMPOSITE) { + else if (ima->type == IMA_TYPE_COMPOSITE) { /* requires lock/unlock, otherwise don't return image */ if (lock_r) { /* unlock in BKE_image_release_ibuf */ BLI_lock_thread(LOCK_VIEWER); - *lock_r= ima; + *lock_r = ima; /* XXX anim play for viewer nodes not yet supported */ - frame= 0; // XXX iuser?iuser->framenr:0; - ibuf= image_get_ibuf(ima, 0, frame); + frame = 0; // XXX iuser?iuser->framenr:0; + ibuf = image_get_ibuf(ima, 0, frame); if (!ibuf) { /* Composite Viewer, all handled in compositor */ /* fake ibuf, will be filled in compositor */ - ibuf= IMB_allocImBuf(256, 256, 32, IB_rect); + ibuf = IMB_allocImBuf(256, 256, 32, IB_rect); image_assign_ibuf(ima, ibuf, 0, frame); } } @@ -2566,7 +2574,7 @@ ImBuf *BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **lock_r) BLI_unlock_thread(LOCK_IMAGE); } - tag_image_time(ima); + BKE_image_tag_time(ima); return ibuf; } @@ -2590,57 +2598,57 @@ ImBuf *BKE_image_get_ibuf(Image *ima, ImageUser *iuser) return BKE_image_acquire_ibuf(ima, iuser, NULL); } -int BKE_image_user_get_frame(const ImageUser *iuser, int cfra, int fieldnr) +int BKE_image_user_frame_get(const ImageUser *iuser, int cfra, int fieldnr) { - const int len= (iuser->fie_ima*iuser->frames)/2; + const int len = (iuser->fie_ima * iuser->frames) / 2; - if (len==0) { + if (len == 0) { return 0; } else { int framenr; - cfra= cfra - iuser->sfra+1; + cfra = cfra - iuser->sfra + 1; /* cyclic */ if (iuser->cycl) { - cfra= ((cfra) % len); - if (cfra < 0) cfra+= len; - if (cfra==0) cfra= len; + cfra = ((cfra) % len); + if (cfra < 0) cfra += len; + if (cfra == 0) cfra = len; } - if (cfra<0) cfra= 0; - else if (cfra>len) cfra= len; + if (cfra < 0) cfra = 0; + else if (cfra > len) cfra = len; /* convert current frame to current field */ - cfra= 2*(cfra); + cfra = 2 * (cfra); if (fieldnr) cfra++; /* transform to images space */ - framenr= (cfra+iuser->fie_ima-2)/iuser->fie_ima; - if (framenr>iuser->frames) framenr= iuser->frames; - framenr+= iuser->offset; + framenr = (cfra + iuser->fie_ima - 2) / iuser->fie_ima; + if (framenr > iuser->frames) framenr = iuser->frames; + framenr += iuser->offset; if (iuser->cycl) { - framenr= ((framenr) % len); - while (framenr < 0) framenr+= len; - if (framenr==0) framenr= len; + framenr = ((framenr) % len); + while (framenr < 0) framenr += len; + if (framenr == 0) framenr = len; } return framenr; } } -void BKE_image_user_calc_frame(ImageUser *iuser, int cfra, int fieldnr) +void BKE_image_user_frame_calc(ImageUser *iuser, int cfra, int fieldnr) { - const int framenr= BKE_image_user_get_frame(iuser, cfra, fieldnr); + const int framenr = BKE_image_user_frame_get(iuser, cfra, fieldnr); /* allows image users to handle redraws */ if (iuser->flag & IMA_ANIM_ALWAYS) - if (framenr!=iuser->framenr) + if (framenr != iuser->framenr) iuser->flag |= IMA_ANIM_REFRESHED; - iuser->framenr= framenr; - if (iuser->ok==0) iuser->ok= 1; + iuser->framenr = framenr; + if (iuser->ok == 0) iuser->ok = 1; } int BKE_image_has_alpha(struct Image *image) @@ -2649,8 +2657,8 @@ int BKE_image_has_alpha(struct Image *image) void *lock; int planes; - ibuf= BKE_image_acquire_ibuf(image, NULL, &lock); - planes = (ibuf?ibuf->planes:0); + ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); + planes = (ibuf ? ibuf->planes : 0); BKE_image_release_ibuf(image, lock); if (planes == 32) diff --git a/source/blender/blenkernel/intern/image_gen.c b/source/blender/blenkernel/intern/image_gen.c index 1441bd7b12b..4579e6f92aa 100644 --- a/source/blender/blenkernel/intern/image_gen.c +++ b/source/blender/blenkernel/intern/image_gen.c @@ -39,10 +39,10 @@ void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, /* blank image */ if (rect_float) { - for (y= 0; y 0) { - rect_float[0]= rect_float[1]= rect_float[2]= 0.25f; - rect_float[3]= 1.0f; + rect_float[0] = rect_float[1] = rect_float[2] = 0.25f; + rect_float[3] = 1.0f; } else { - rect_float[0]= rect_float[1]= rect_float[2]= 0.58f; - rect_float[3]= 1.0f; + rect_float[0] = rect_float[1] = rect_float[2] = 0.58f; + rect_float[3] = 1.0f; } - rect_float+= 4; + rect_float += 4; } else { if (dark > 0) { - rect[0]= rect[1]= rect[2]= 64; - rect[3]= 255; + rect[0] = rect[1] = rect[2] = 64; + rect[3] = 255; } else { - rect[0]= rect[1]= rect[2]= 150; - rect[3]= 255; + rect[0] = rect[1] = rect[2] = 150; + rect[3] = 255; } - rect+= 4; + rect += 4; } } } - rect= rect_orig; - rect_float= rect_float_orig; + rect = rect_orig; + rect_float = rect_float_orig; /* 2nd pass, colored + */ - for (y= 0; ycurve.first; icu; icu= icn) { - icn= icu->next; + for (icu = ipo->curve.first; icu; icu = icn) { + icn = icu->next; n++; if (icu->bezt) MEM_freeN(icu->bezt); @@ -98,7 +98,7 @@ void free_ipo(Ipo *ipo) } if (G.debug & G_DEBUG) - printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name+2); + printf("Freed %d (Unconverted) Ipo-Curves from IPO '%s'\n", n, ipo->id.name + 2); } /* *************************************************** */ @@ -115,35 +115,35 @@ typedef struct AdrBit2Path { /* Mapping Tables to use bits <-> RNA paths */ /* Object layers */ -static AdrBit2Path ob_layer_bits[]= { - {(1<<0), "layers", 0}, - {(1<<1), "layers", 1}, - {(1<<2), "layers", 2}, - {(1<<3), "layers", 3}, - {(1<<4), "layers", 4}, - {(1<<5), "layers", 5}, - {(1<<6), "layers", 6}, - {(1<<7), "layers", 7}, - {(1<<8), "layers", 8}, - {(1<<9), "layers", 9}, - {(1<<10), "layers", 10}, - {(1<<11), "layers", 11}, - {(1<<12), "layers", 12}, - {(1<<13), "layers", 13}, - {(1<<14), "layers", 14}, - {(1<<15), "layers", 15}, - {(1<<16), "layers", 16}, - {(1<<17), "layers", 17}, - {(1<<18), "layers", 18}, - {(1<<19), "layers", 19} +static AdrBit2Path ob_layer_bits[] = { + {(1 << 0), "layers", 0}, + {(1 << 1), "layers", 1}, + {(1 << 2), "layers", 2}, + {(1 << 3), "layers", 3}, + {(1 << 4), "layers", 4}, + {(1 << 5), "layers", 5}, + {(1 << 6), "layers", 6}, + {(1 << 7), "layers", 7}, + {(1 << 8), "layers", 8}, + {(1 << 9), "layers", 9}, + {(1 << 10), "layers", 10}, + {(1 << 11), "layers", 11}, + {(1 << 12), "layers", 12}, + {(1 << 13), "layers", 13}, + {(1 << 14), "layers", 14}, + {(1 << 15), "layers", 15}, + {(1 << 16), "layers", 16}, + {(1 << 17), "layers", 17}, + {(1 << 18), "layers", 18}, + {(1 << 19), "layers", 19} }; /* Material mode */ -static AdrBit2Path ma_mode_bits[]= { +static AdrBit2Path ma_mode_bits[] = { // {MA_TRACEBLE, "traceable", 0}, -// {MA_SHADOW, "shadow", 0}, +// {MA_SHADOW, "shadow", 0}, // {MA_SHLESS, "shadeless", 0}, -// ... +// ... {MA_RAYTRANSP, "transparency", 0}, {MA_RAYMIRROR, "raytrace_mirror.enabled", 0}, // {MA_HALO, "type", MA_TYPE_HALO} @@ -154,99 +154,99 @@ static AdrBit2Path ma_mode_bits[]= { /* quick macro for returning the appropriate array for adrcode_bitmaps_to_paths() */ #define RET_ABP(items) \ { \ - *tot= sizeof(items)/sizeof(AdrBit2Path); \ + *tot = sizeof(items) / sizeof(AdrBit2Path); \ return items; \ } /* This function checks if a Blocktype+Adrcode combo, returning a mapping table */ -static AdrBit2Path *adrcode_bitmaps_to_paths (int blocktype, int adrcode, int *tot) +static AdrBit2Path *adrcode_bitmaps_to_paths(int blocktype, int adrcode, int *tot) { /* Object layers */ if ((blocktype == ID_OB) && (adrcode == OB_LAY)) RET_ABP(ob_layer_bits) - else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) - RET_ABP(ma_mode_bits) - // XXX TODO: add other types... + else if ((blocktype == ID_MA) && (adrcode == MA_MODE)) + RET_ABP(ma_mode_bits) + // XXX TODO: add other types... - /* Normal curve */ - return NULL; + /* Normal curve */ + return NULL; } /* *************************************************** */ /* ADRCODE to RNA-Path Conversion Code - Standard */ /* Object types */ -static const char *ob_adrcodes_to_paths (int adrcode, int *array_index) +static const char *ob_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case OB_LOC_X: - *array_index= 0; return "location"; + *array_index = 0; return "location"; case OB_LOC_Y: - *array_index= 1; return "location"; + *array_index = 1; return "location"; case OB_LOC_Z: - *array_index= 2; return "location"; + *array_index = 2; return "location"; case OB_DLOC_X: - *array_index= 0; return "delta_location"; + *array_index = 0; return "delta_location"; case OB_DLOC_Y: - *array_index= 1; return "delta_location"; + *array_index = 1; return "delta_location"; case OB_DLOC_Z: - *array_index= 2; return "delta_location"; + *array_index = 2; return "delta_location"; case OB_ROT_X: - *array_index= 0; return "rotation_euler"; + *array_index = 0; return "rotation_euler"; case OB_ROT_Y: - *array_index= 1; return "rotation_euler"; + *array_index = 1; return "rotation_euler"; case OB_ROT_Z: - *array_index= 2; return "rotation_euler"; + *array_index = 2; return "rotation_euler"; case OB_DROT_X: - *array_index= 0; return "delta_rotation_euler"; + *array_index = 0; return "delta_rotation_euler"; case OB_DROT_Y: - *array_index= 1; return "delta_rotation_euler"; + *array_index = 1; return "delta_rotation_euler"; case OB_DROT_Z: - *array_index= 2; return "delta_rotation_euler"; + *array_index = 2; return "delta_rotation_euler"; case OB_SIZE_X: - *array_index= 0; return "scale"; + *array_index = 0; return "scale"; case OB_SIZE_Y: - *array_index= 1; return "scale"; + *array_index = 1; return "scale"; case OB_SIZE_Z: - *array_index= 2; return "scale"; + *array_index = 2; return "scale"; case OB_DSIZE_X: - *array_index= 0; return "delta_scale"; + *array_index = 0; return "delta_scale"; case OB_DSIZE_Y: - *array_index= 1; return "delta_scale"; + *array_index = 1; return "delta_scale"; case OB_DSIZE_Z: - *array_index= 2; return "delta_scale"; + *array_index = 2; return "delta_scale"; case OB_COL_R: - *array_index= 0; return "color"; + *array_index = 0; return "color"; case OB_COL_G: - *array_index= 1; return "color"; + *array_index = 1; return "color"; case OB_COL_B: - *array_index= 2; return "color"; + *array_index = 2; return "color"; case OB_COL_A: - *array_index= 3; return "color"; + *array_index = 3; return "color"; #if 0 case OB_PD_FSTR: - if (ob->pd) poin= &(ob->pd->f_strength); + if (ob->pd) poin = &(ob->pd->f_strength); break; case OB_PD_FFALL: - if (ob->pd) poin= &(ob->pd->f_power); + if (ob->pd) poin = &(ob->pd->f_power); break; case OB_PD_SDAMP: - if (ob->pd) poin= &(ob->pd->pdef_damp); + if (ob->pd) poin = &(ob->pd->pdef_damp); break; case OB_PD_RDAMP: - if (ob->pd) poin= &(ob->pd->pdef_rdamp); + if (ob->pd) poin = &(ob->pd->pdef_rdamp); break; case OB_PD_PERM: - if (ob->pd) poin= &(ob->pd->pdef_perm); + if (ob->pd) poin = &(ob->pd->pdef_perm); break; case OB_PD_FMAXD: - if (ob->pd) poin= &(ob->pd->maxdist); + if (ob->pd) poin = &(ob->pd->maxdist); break; #endif } @@ -257,42 +257,42 @@ static const char *ob_adrcodes_to_paths (int adrcode, int *array_index) /* PoseChannel types * NOTE: pchan name comes from 'actname' added earlier... */ -static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index) +static const char *pchan_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case AC_QUAT_W: - *array_index= 0; return "rotation_quaternion"; + *array_index = 0; return "rotation_quaternion"; case AC_QUAT_X: - *array_index= 1; return "rotation_quaternion"; + *array_index = 1; return "rotation_quaternion"; case AC_QUAT_Y: - *array_index= 2; return "rotation_quaternion"; + *array_index = 2; return "rotation_quaternion"; case AC_QUAT_Z: - *array_index= 3; return "rotation_quaternion"; + *array_index = 3; return "rotation_quaternion"; case AC_EUL_X: - *array_index= 0; return "rotation_euler"; + *array_index = 0; return "rotation_euler"; case AC_EUL_Y: - *array_index= 1; return "rotation_euler"; + *array_index = 1; return "rotation_euler"; case AC_EUL_Z: - *array_index= 2; return "rotation_euler"; + *array_index = 2; return "rotation_euler"; case AC_LOC_X: - *array_index= 0; return "location"; + *array_index = 0; return "location"; case AC_LOC_Y: - *array_index= 1; return "location"; + *array_index = 1; return "location"; case AC_LOC_Z: - *array_index= 2; return "location"; + *array_index = 2; return "location"; case AC_SIZE_X: - *array_index= 0; return "scale"; + *array_index = 0; return "scale"; case AC_SIZE_Y: - *array_index= 1; return "scale"; + *array_index = 1; return "scale"; case AC_SIZE_Z: - *array_index= 2; return "scale"; + *array_index = 2; return "scale"; } /* for debugging only */ @@ -301,16 +301,16 @@ static const char *pchan_adrcodes_to_paths (int adrcode, int *array_index) } /* Constraint types */ -static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) +static const char *constraint_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case CO_ENFORCE: return "influence"; - case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid + case CO_HEADTAIL: // XXX this needs to be wrapped in RNA.. probably then this path will be invalid return "data.head_tail"; } @@ -321,7 +321,7 @@ static const char *constraint_adrcodes_to_paths (int adrcode, int *array_index) * NOTE: as we don't have access to the keyblock where the data comes from (for now), * we'll just use numerical indices for now... */ -static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) +static char *shapekey_adrcodes_to_paths(int adrcode, int *UNUSED(array_index)) { static char buf[128]; @@ -338,64 +338,64 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) } /* MTex (Texture Slot) types */ -static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index)) +static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index)) { - const char *base=NULL, *prop=NULL; + const char *base = NULL, *prop = NULL; static char buf[128]; /* base part of path */ - if (adrcode & MA_MAP1) base= "textures[0]"; - else if (adrcode & MA_MAP2) base= "textures[1]"; - else if (adrcode & MA_MAP3) base= "textures[2]"; - else if (adrcode & MA_MAP4) base= "textures[3]"; - else if (adrcode & MA_MAP5) base= "textures[4]"; - else if (adrcode & MA_MAP6) base= "textures[5]"; - else if (adrcode & MA_MAP7) base= "textures[6]"; - else if (adrcode & MA_MAP8) base= "textures[7]"; - else if (adrcode & MA_MAP9) base= "textures[8]"; - else if (adrcode & MA_MAP10) base= "textures[9]"; - else if (adrcode & MA_MAP11) base= "textures[10]"; - else if (adrcode & MA_MAP12) base= "textures[11]"; - else if (adrcode & MA_MAP13) base= "textures[12]"; - else if (adrcode & MA_MAP14) base= "textures[13]"; - else if (adrcode & MA_MAP15) base= "textures[14]"; - else if (adrcode & MA_MAP16) base= "textures[15]"; - else if (adrcode & MA_MAP17) base= "textures[16]"; - else if (adrcode & MA_MAP18) base= "textures[17]"; + if (adrcode & MA_MAP1) base = "textures[0]"; + else if (adrcode & MA_MAP2) base = "textures[1]"; + else if (adrcode & MA_MAP3) base = "textures[2]"; + else if (adrcode & MA_MAP4) base = "textures[3]"; + else if (adrcode & MA_MAP5) base = "textures[4]"; + else if (adrcode & MA_MAP6) base = "textures[5]"; + else if (adrcode & MA_MAP7) base = "textures[6]"; + else if (adrcode & MA_MAP8) base = "textures[7]"; + else if (adrcode & MA_MAP9) base = "textures[8]"; + else if (adrcode & MA_MAP10) base = "textures[9]"; + else if (adrcode & MA_MAP11) base = "textures[10]"; + else if (adrcode & MA_MAP12) base = "textures[11]"; + else if (adrcode & MA_MAP13) base = "textures[12]"; + else if (adrcode & MA_MAP14) base = "textures[13]"; + else if (adrcode & MA_MAP15) base = "textures[14]"; + else if (adrcode & MA_MAP16) base = "textures[15]"; + else if (adrcode & MA_MAP17) base = "textures[16]"; + else if (adrcode & MA_MAP18) base = "textures[17]"; /* property identifier for path */ - adrcode= (adrcode & (MA_MAP1-1)); + adrcode = (adrcode & (MA_MAP1 - 1)); switch (adrcode) { #if 0 // XXX these are not wrapped in RNA yet! case MAP_OFS_X: - poin= &(mtex->ofs[0]); break; + poin = &(mtex->ofs[0]); break; case MAP_OFS_Y: - poin= &(mtex->ofs[1]); break; + poin = &(mtex->ofs[1]); break; case MAP_OFS_Z: - poin= &(mtex->ofs[2]); break; + poin = &(mtex->ofs[2]); break; case MAP_SIZE_X: - poin= &(mtex->size[0]); break; + poin = &(mtex->size[0]); break; case MAP_SIZE_Y: - poin= &(mtex->size[1]); break; + poin = &(mtex->size[1]); break; case MAP_SIZE_Z: - poin= &(mtex->size[2]); break; + poin = &(mtex->size[2]); break; case MAP_R: - poin= &(mtex->r); break; + poin = &(mtex->r); break; case MAP_G: - poin= &(mtex->g); break; + poin = &(mtex->g); break; case MAP_B: - poin= &(mtex->b); break; + poin = &(mtex->b); break; case MAP_DVAR: - poin= &(mtex->def_var); break; + poin = &(mtex->def_var); break; case MAP_COLF: - poin= &(mtex->colfac); break; + poin = &(mtex->colfac); break; case MAP_NORF: - poin= &(mtex->norfac); break; + poin = &(mtex->norfac); break; case MAP_VARF: - poin= &(mtex->varfac); break; + poin = &(mtex->varfac); break; #endif case MAP_DISP: - prop= "warp_factor"; break; + prop = "warp_factor"; break; } /* only build and return path if there's a property */ @@ -408,10 +408,10 @@ static const char *mtex_adrcodes_to_paths (int adrcode, int *UNUSED(array_index) } /* Texture types */ -static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) +static const char *texture_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -420,7 +420,7 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) case TE_TURB: return "turbulence"; - case TE_NDEPTH: // XXX texture RNA undefined + case TE_NDEPTH: // XXX texture RNA undefined //poin= &(tex->noisedepth); *type= IPO_SHORT; break; break; case TE_NTYPE: // XXX texture RNA undefined @@ -432,15 +432,15 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) case TE_N_BAS2: return "noise_basis"; // XXX this is not yet defined in RNA... - /* voronoi */ + /* voronoi */ case TE_VNW1: - *array_index= 0; return "feature_weights"; + *array_index = 0; return "feature_weights"; case TE_VNW2: - *array_index= 1; return "feature_weights"; + *array_index = 1; return "feature_weights"; case TE_VNW3: - *array_index= 2; return "feature_weights"; + *array_index = 2; return "feature_weights"; case TE_VNW4: - *array_index= 3; return "feature_weights"; + *array_index = 3; return "feature_weights"; case TE_VNMEXP: return "minkovsky_exponent"; case TE_VN_DISTM: @@ -448,17 +448,17 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) case TE_VN_COLT: return "color_type"; - /* distorted noise / voronoi */ + /* distorted noise / voronoi */ case TE_ISCA: return "noise_intensity"; - /* distorted noise */ + /* distorted noise */ case TE_DISTA: return "distortion_amount"; - /* musgrave */ + /* musgrave */ case TE_MG_TYP: // XXX texture RNA undefined - // poin= &(tex->stype); *type= IPO_SHORT; break; + // poin= &(tex->stype); *type= IPO_SHORT; break; break; case TE_MGH: return "highest_dimension"; @@ -472,11 +472,11 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) return "gain"; case TE_COL_R: - *array_index= 0; return "rgb_factor"; + *array_index = 0; return "rgb_factor"; case TE_COL_G: - *array_index= 1; return "rgb_factor"; + *array_index = 1; return "rgb_factor"; case TE_COL_B: - *array_index= 2; return "rgb_factor"; + *array_index = 2; return "rgb_factor"; case TE_BRIGHT: return "brightness"; @@ -488,33 +488,33 @@ static const char *texture_adrcodes_to_paths (int adrcode, int *array_index) } /* Material Types */ -static const char *material_adrcodes_to_paths (int adrcode, int *array_index) +static const char *material_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case MA_COL_R: - *array_index= 0; return "diffuse_color"; + *array_index = 0; return "diffuse_color"; case MA_COL_G: - *array_index= 1; return "diffuse_color"; + *array_index = 1; return "diffuse_color"; case MA_COL_B: - *array_index= 2; return "diffuse_color"; + *array_index = 2; return "diffuse_color"; case MA_SPEC_R: - *array_index= 0; return "specular_color"; + *array_index = 0; return "specular_color"; case MA_SPEC_G: - *array_index= 1; return "specular_color"; + *array_index = 1; return "specular_color"; case MA_SPEC_B: - *array_index= 2; return "specular_color"; + *array_index = 2; return "specular_color"; case MA_MIR_R: - *array_index= 0; return "mirror_color"; + *array_index = 0; return "mirror_color"; case MA_MIR_G: - *array_index= 1; return "mirror_color"; + *array_index = 1; return "mirror_color"; case MA_MIR_B: - *array_index= 2; return "mirror_color"; + *array_index = 2; return "mirror_color"; case MA_ALPHA: return "alpha"; @@ -572,10 +572,10 @@ static const char *material_adrcodes_to_paths (int adrcode, int *array_index) } /* Camera Types */ -static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) +static const char *camera_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -596,9 +596,9 @@ static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) #if 0 // XXX these are not defined in RNA case CAM_YF_APERT: - poin= &(ca->YF_aperture); break; + poin = &(ca->YF_aperture); break; case CAM_YF_FDIST: - poin= &(ca->YF_dofdist); break; + poin = &(ca->YF_dofdist); break; #endif // XXX these are not defined in RNA case CAM_SHIFT_X: @@ -612,10 +612,10 @@ static const char *camera_adrcodes_to_paths (int adrcode, int *array_index) } /* Lamp Types */ -static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) +static const char *lamp_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -623,11 +623,11 @@ static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) return "energy"; case LA_COL_R: - *array_index= 0; return "color"; + *array_index = 0; return "color"; case LA_COL_G: - *array_index= 1; return "color"; + *array_index = 1; return "color"; case LA_COL_B: - *array_index= 2; return "color"; + *array_index = 2; return "color"; case LA_DIST: return "distance"; @@ -654,10 +654,10 @@ static const char *lamp_adrcodes_to_paths (int adrcode, int *array_index) } /* Sound Types */ -static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) +static const char *sound_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -665,7 +665,7 @@ static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) return "volume"; case SND_PITCH: return "pitch"; - /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */ + /* XXX Joshua -- I had wrapped panning in rna, but someone commented out, calling it "unused" */ #if 0 case SND_PANNING: return "panning"; @@ -679,25 +679,25 @@ static const char *sound_adrcodes_to_paths (int adrcode, int *array_index) } /* World Types */ -static const char *world_adrcodes_to_paths (int adrcode, int *array_index) +static const char *world_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { case WO_HOR_R: - *array_index= 0; return "horizon_color"; + *array_index = 0; return "horizon_color"; case WO_HOR_G: - *array_index= 1; return "horizon_color"; + *array_index = 1; return "horizon_color"; case WO_HOR_B: - *array_index= 2; return "horizon_color"; + *array_index = 2; return "horizon_color"; case WO_ZEN_R: - *array_index= 0; return "zenith_color"; + *array_index = 0; return "zenith_color"; case WO_ZEN_G: - *array_index= 1; return "zenith_color"; + *array_index = 1; return "zenith_color"; case WO_ZEN_B: - *array_index= 2; return "zenith_color"; + *array_index = 2; return "zenith_color"; case WO_EXPOS: return "exposure"; @@ -724,16 +724,16 @@ static const char *world_adrcodes_to_paths (int adrcode, int *array_index) default: /* for now, we assume that the others were MTex channels */ return mtex_adrcodes_to_paths(adrcode, array_index); - } + } return NULL; } /* Particle Types */ -static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) +static const char *particle_adrcodes_to_paths(int adrcode, int *array_index) { /* set array index like this in-case nothing sets it correctly */ - *array_index= 0; + *array_index = 0; /* result depends on adrcode */ switch (adrcode) { @@ -752,11 +752,11 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) case PART_LENGTH: return "settings.length"; case PART_GRAV_X: - *array_index= 0; return "settings.acceleration"; + *array_index = 0; return "settings.acceleration"; case PART_GRAV_Y: - *array_index= 1; return "settings.acceleration"; + *array_index = 1; return "settings.acceleration"; case PART_GRAV_Z: - *array_index= 2; return "settings.acceleration"; + *array_index = 2; return "settings.acceleration"; case PART_KINK_AMP: return "settings.kink_amplitude"; case PART_KINK_FREQ: @@ -773,22 +773,22 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) * as the similar object forces */ #if 0 case PART_PD_FSTR: - if (part->pd) poin= &(part->pd->f_strength); + if (part->pd) poin = &(part->pd->f_strength); break; case PART_PD_FFALL: - if (part->pd) poin= &(part->pd->f_power); + if (part->pd) poin = &(part->pd->f_power); break; case PART_PD_FMAXD: - if (part->pd) poin= &(part->pd->maxdist); + if (part->pd) poin = &(part->pd->maxdist); break; case PART_PD2_FSTR: - if (part->pd2) poin= &(part->pd2->f_strength); + if (part->pd2) poin = &(part->pd2->f_strength); break; case PART_PD2_FFALL: - if (part->pd2) poin= &(part->pd2->f_power); + if (part->pd2) poin = &(part->pd2->f_power); break; case PART_PD2_FMAXD: - if (part->pd2) poin= &(part->pd2->maxdist); + if (part->pd2) poin = &(part->pd2->maxdist); break; #endif @@ -807,84 +807,84 @@ static const char *particle_adrcodes_to_paths (int adrcode, int *array_index) * - array_index - index in property's array (if applicable) to use * - return - the allocated path... */ -static char *get_rna_access (int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index) +static char *get_rna_access(int blocktype, int adrcode, char actname[], char constname[], Sequence *seq, int *array_index) { - DynStr *path= BLI_dynstr_new(); - const char *propname=NULL; - char *rpath=NULL; + DynStr *path = BLI_dynstr_new(); + const char *propname = NULL; + char *rpath = NULL; char buf[512]; - int dummy_index= 0; + int dummy_index = 0; /* hack: if constname is set, we can only be dealing with an Constraint curve */ if (constname) - blocktype= ID_CO; + blocktype = ID_CO; /* get property name based on blocktype */ switch (blocktype) { case ID_OB: /* object */ - propname= ob_adrcodes_to_paths(adrcode, &dummy_index); + propname = ob_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_PO: /* pose channel */ - propname= pchan_adrcodes_to_paths(adrcode, &dummy_index); + propname = pchan_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_KE: /* shapekeys */ - propname= shapekey_adrcodes_to_paths(adrcode, &dummy_index); + propname = shapekey_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_CO: /* constraint */ - propname= constraint_adrcodes_to_paths(adrcode, &dummy_index); + propname = constraint_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_TE: /* texture */ - propname= texture_adrcodes_to_paths(adrcode, &dummy_index); + propname = texture_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_MA: /* material */ - propname= material_adrcodes_to_paths(adrcode, &dummy_index); + propname = material_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_CA: /* camera */ - propname= camera_adrcodes_to_paths(adrcode, &dummy_index); + propname = camera_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_LA: /* lamp */ - propname= lamp_adrcodes_to_paths(adrcode, &dummy_index); + propname = lamp_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_SO: /* sound */ - propname= sound_adrcodes_to_paths(adrcode, &dummy_index); + propname = sound_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_WO: /* world */ - propname= world_adrcodes_to_paths(adrcode, &dummy_index); + propname = world_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_PA: /* particle */ - propname= particle_adrcodes_to_paths(adrcode, &dummy_index); + propname = particle_adrcodes_to_paths(adrcode, &dummy_index); break; case ID_CU: /* curve */ /* this used to be a 'dummy' curve which got evaluated on the fly... * now we've got real var for this! */ - propname= "eval_time"; + propname = "eval_time"; break; /* XXX problematic blocktypes */ case ID_SEQ: /* sequencer strip */ //SEQ_FAC1: switch (adrcode) { - case SEQ_FAC1: - propname= "effect_fader"; - break; - case SEQ_FAC_SPEED: - propname= "speed_fader"; - break; - case SEQ_FAC_OPACITY: - propname= "blend_opacity"; - break; + case SEQ_FAC1: + propname = "effect_fader"; + break; + case SEQ_FAC_SPEED: + propname = "speed_fader"; + break; + case SEQ_FAC_OPACITY: + propname = "blend_opacity"; + break; } // poin= &(seq->facf0); // XXX this doesn't seem to be included anywhere in sequencer RNA... break; @@ -906,7 +906,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co if ((propname == NULL) && (blocktype > 0)) { /* nothing was found, so exit */ if (array_index) - *array_index= 0; + *array_index = 0; BLI_dynstr_free(path); @@ -914,7 +914,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else { if (array_index) - *array_index= dummy_index; + *array_index = dummy_index; } /* 'buf' _must_ be initialized in this block */ @@ -925,11 +925,11 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname); } else if (actname && actname[0]) { - if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) { + if ((blocktype == ID_OB) && strcmp(actname, "Object") == 0) { /* Actionified "Object" IPO's... no extra path stuff needed */ - buf[0]= '\0'; /* empty string */ + buf[0] = '\0'; /* empty string */ } - else if ((blocktype == ID_KE) && strcmp(actname, "Shape")==0) { + else if ((blocktype == ID_KE) && strcmp(actname, "Shape") == 0) { /* Actionified "Shape" IPO's - these are forced onto object level via the action container there... */ strcpy(buf, "data.shape_keys"); } @@ -944,10 +944,10 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } else if (seq) { /* Sequence names in Scene */ - BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name+2); + BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name + 2); } else { - buf[0]= '\0'; /* empty string */ + buf[0] = '\0'; /* empty string */ } BLI_dynstr_append(path, buf); @@ -966,7 +966,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co } /* convert to normal MEM_malloc'd string */ - rpath= BLI_dynstr_get_cstring(path); + rpath = BLI_dynstr_get_cstring(path); BLI_dynstr_free(path); /* return path... */ @@ -977,7 +977,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co /* Conversion Utilities */ /* Convert adrcodes to driver target transform channel types */ -static short adrcode_to_dtar_transchan (short adrcode) +static short adrcode_to_dtar_transchan(short adrcode) { switch (adrcode) { case OB_LOC_X: @@ -1007,12 +1007,12 @@ static short adrcode_to_dtar_transchan (short adrcode) } /* Convert IpoDriver to ChannelDriver - will free the old data (i.e. the old driver) */ -static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) +static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver) { ChannelDriver *cdriver; /* allocate memory for new driver */ - cdriver= MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); + cdriver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); /* if 'pydriver', just copy data across */ if (idriver->type == IPO_DRIVER_TYPE_PYTHON) { @@ -1027,54 +1027,54 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) DriverTarget *dtar = NULL; /* this should be ok for all types here... */ - cdriver->type= DRIVER_TYPE_AVERAGE; + cdriver->type = DRIVER_TYPE_AVERAGE; /* what to store depends on the 'blocktype' - object or posechannel */ if (idriver->blocktype == ID_AR) { /* PoseChannel */ if (idriver->adrcode == OB_ROT_DIFF) { /* Rotational Difference requires a special type of variable */ - dvar= driver_add_new_variable(cdriver); + dvar = driver_add_new_variable(cdriver); driver_change_variable_type(dvar, DVAR_TYPE_ROT_DIFF); - /* first bone target */ - dtar= &dvar->targets[0]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; + /* first bone target */ + dtar = &dvar->targets[0]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); - /* second bone target (name was stored in same var as the first one) */ - dtar= &dvar->targets[1]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; + /* second bone target (name was stored in same var as the first one) */ + dtar = &dvar->targets[1]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; if (idriver->name[0]) // xxx... for safety - BLI_strncpy(dtar->pchan_name, idriver->name+DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); + BLI_strncpy(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); } else { /* only a single variable, of type 'transform channel' */ - dvar= driver_add_new_variable(cdriver); + dvar = driver_add_new_variable(cdriver); driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); /* only requires a single target */ - dtar= &dvar->targets[0]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; + dtar = &dvar->targets[0]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; if (idriver->name[0]) BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); - dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); + dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode); dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */ } } else { /* Object */ - /* only a single variable, of type 'transform channel' */ - dvar= driver_add_new_variable(cdriver); + /* only a single variable, of type 'transform channel' */ + dvar = driver_add_new_variable(cdriver); driver_change_variable_type(dvar, DVAR_TYPE_TRANSFORM_CHAN); - /* only requires single target */ - dtar= &dvar->targets[0]; - dtar->id= (ID *)idriver->ob; - dtar->idtype= ID_OB; - dtar->transChan= adrcode_to_dtar_transchan(idriver->adrcode); + /* only requires single target */ + dtar = &dvar->targets[0]; + dtar->id = (ID *)idriver->ob; + dtar->idtype = ID_OB; + dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode); } } @@ -1085,7 +1085,7 @@ static ChannelDriver *idriver_to_cdriver (IpoDriver *idriver) /* Add F-Curve to the correct list * - grpname is needed to be used as group name where relevant, and is usually derived from actname */ -static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo) +static void fcurve_add_to_list(ListBase *groups, ListBase *list, FCurve *fcu, char *grpname, int muteipo) { /* If we're adding to an action, we will have groups to write to... */ if (groups && grpname) { @@ -1093,22 +1093,22 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * and extract the resultant lists... */ bAction tmp_act; - bActionGroup *agrp= NULL; + bActionGroup *agrp = NULL; /* init the temp action */ memset(&tmp_act, 0, sizeof(bAction)); // XXX only enable this line if we get errors - tmp_act.groups.first= groups->first; - tmp_act.groups.last= groups->last; - tmp_act.curves.first= list->first; - tmp_act.curves.last= list->last; + tmp_act.groups.first = groups->first; + tmp_act.groups.last = groups->last; + tmp_act.curves.first = list->first; + tmp_act.curves.last = list->last; /* ... xxx, the other vars don't need to be filled in */ /* get the group to use */ - agrp= action_groups_find_named(&tmp_act, grpname); + agrp = BKE_action_group_find_name(&tmp_act, grpname); /* no matching group, so add one */ if (agrp == NULL) { /* Add a new group, and make it active */ - agrp= MEM_callocN(sizeof(bActionGroup), "bActionGroup"); + agrp = MEM_callocN(sizeof(bActionGroup), "bActionGroup"); agrp->flag = AGRP_SELECTED; if (muteipo) agrp->flag |= AGRP_MUTED; @@ -1127,10 +1127,10 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c fcu->flag |= FCURVE_MUTED; /* set the output lists based on the ones in the temp action */ - groups->first= tmp_act.groups.first; - groups->last= tmp_act.groups.last; - list->first= tmp_act.curves.first; - list->last= tmp_act.curves.last; + groups->first = tmp_act.groups.first; + groups->last = tmp_act.groups.last; + list->first = tmp_act.curves.first; + list->last = tmp_act.curves.last; } else { /* simply add the F-Curve to the end of the given list */ @@ -1144,18 +1144,18 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c * constname: name of Constraint-Channel (if applicable) that IPO-Curve's IPO-block belonged to * seq: sequencer-strip (if applicable) that IPO-Curve's IPO-block belonged to */ -static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence * seq, int muteipo) +static void icu_to_fcurves(ID *id, ListBase *groups, ListBase *list, IpoCurve *icu, char *actname, char *constname, Sequence *seq, int muteipo) { AdrBit2Path *abp; FCurve *fcu; int totbits; /* allocate memory for a new F-Curve */ - fcu= MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = MEM_callocN(sizeof(FCurve), "FCurve"); /* convert driver */ if (icu->driver) - fcu->driver= idriver_to_cdriver(icu->driver); + fcu->driver = idriver_to_cdriver(icu->driver); /* copy flags */ if (icu->flag & IPO_VISIBLE) fcu->flag |= FCURVE_VISIBLE; @@ -1170,9 +1170,9 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * case IPO_DIR: /* linear extrapolation */ { /* just copy, as the new defines match the old ones... */ - fcu->extend= icu->extrap; + fcu->extend = icu->extrap; } - break; + break; case IPO_CYCL: /* cyclic extrapolation */ case IPO_CYCLX: /* cyclic extrapolation + offset */ @@ -1180,22 +1180,22 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* Add a new FModifier (Cyclic) instead of setting extend value * as that's the new equivalent of that option. */ - FModifier *fcm= add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); - FMod_Cycles *data= (FMod_Cycles *)fcm->data; + FModifier *fcm = add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES); + FMod_Cycles *data = (FMod_Cycles *)fcm->data; /* if 'offset' one is in use, set appropriate settings */ if (icu->extrap == IPO_CYCLX) - data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC_OFFSET; + data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC_OFFSET; else - data->before_mode= data->after_mode= FCM_EXTRAPOLATE_CYCLIC; + data->before_mode = data->after_mode = FCM_EXTRAPOLATE_CYCLIC; } - break; + break; } /* -------- */ /* get adrcode <-> bitflags mapping to handle nasty bitflag curves? */ - abp= adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits); + abp = adrcode_bitmaps_to_paths(icu->blocktype, icu->adrcode, &totbits); if (abp && totbits) { FCurve *fcurve; int b; @@ -1203,49 +1203,49 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * if (G.debug & G_DEBUG) printf("\tconvert bitflag ipocurve, totbits = %d\n", totbits); /* add the 'only int values' flag */ - fcu->flag |= (FCURVE_INT_VALUES|FCURVE_DISCRETE_VALUES); + fcu->flag |= (FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES); /* for each bit we have to remap + check for: * 1) we need to make copy the existing F-Curve data (fcu -> fcurve), - * except for the last one which will use the original + * except for the last one which will use the original * 2) copy the relevant path info across * 3) filter the keyframes for the flag of interest */ - for (b=0; b < totbits; b++, abp++) { - unsigned int i=0; + for (b = 0; b < totbits; b++, abp++) { + unsigned int i = 0; /* make a copy of existing base-data if not the last curve */ - if (b < (totbits-1)) - fcurve= copy_fcurve(fcu); + if (b < (totbits - 1)) + fcurve = copy_fcurve(fcu); else - fcurve= fcu; + fcurve = fcu; /* set path */ - fcurve->rna_path= BLI_strdup(abp->path); - fcurve->array_index= abp->array_index; + fcurve->rna_path = BLI_strdup(abp->path); + fcurve->array_index = abp->array_index; /* convert keyframes * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet) */ - fcurve->totvert= icu->totvert; + fcurve->totvert = icu->totvert; if (icu->bezt) { BezTriple *dst, *src; /* allocate new array for keyframes/beztriples */ - fcurve->bezt= MEM_callocN(sizeof(BezTriple)*fcurve->totvert, "BezTriples"); + fcurve->bezt = MEM_callocN(sizeof(BezTriple) * fcurve->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcurve->bezt, src=icu->bezt, i=0; i < fcurve->totvert; i++, dst++, src++) { + for (dst = fcurve->bezt, src = icu->bezt, i = 0; i < fcurve->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ - *dst= *src; + *dst = *src; /* interpolation can only be constant... */ - dst->ipo= BEZT_IPO_CONST; + dst->ipo = BEZT_IPO_CONST; /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ - dst->hide= BEZT_KEYTYPE_KEYFRAME; + dst->hide = BEZT_KEYTYPE_KEYFRAME; /* auto-handles - per curve to per handle */ if (icu->flag & IPO_AUTO_HORIZ) { @@ -1255,9 +1255,9 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct values, by checking if the flag of interest is set */ if ( ((int)(dst->vec[1][1])) & (abp->bit) ) - dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 1.0f; + dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 1.0f; else - dst->vec[0][1]= dst->vec[1][1]= dst->vec[2][1] = 0.0f; + dst->vec[0][1] = dst->vec[1][1] = dst->vec[2][1] = 0.0f; } } else if (icu->bp) { @@ -1271,12 +1271,12 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * } } else { - unsigned int i=0; + unsigned int i = 0; /* get rna-path * - we will need to set the 'disabled' flag if no path is able to be made (for now) */ - fcu->rna_path= get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index); + fcu->rna_path = get_rna_access(icu->blocktype, icu->adrcode, actname, constname, seq, &fcu->array_index); if (fcu->rna_path == NULL) fcu->flag |= FCURVE_DISABLED; @@ -1284,25 +1284,25 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * - beztriples and bpoints are mutually exclusive, so we won't have both at the same time * - beztriples are more likely to be encountered as they are keyframes (the other type wasn't used yet) */ - fcu->totvert= icu->totvert; + fcu->totvert = icu->totvert; if (icu->bezt) { BezTriple *dst, *src; /* allocate new array for keyframes/beztriples */ - fcu->bezt= MEM_callocN(sizeof(BezTriple)*fcu->totvert, "BezTriples"); + fcu->bezt = MEM_callocN(sizeof(BezTriple) * fcu->totvert, "BezTriples"); /* loop through copying all BezTriples individually, as we need to modify a few things */ - for (dst=fcu->bezt, src=icu->bezt, i=0; i < fcu->totvert; i++, dst++, src++) { + for (dst = fcu->bezt, src = icu->bezt, i = 0; i < fcu->totvert; i++, dst++, src++) { /* firstly, copy BezTriple data */ - *dst= *src; + *dst = *src; /* now copy interpolation from curve (if not already set) */ if (icu->ipo != IPO_MIXED) - dst->ipo= icu->ipo; + dst->ipo = icu->ipo; /* 'hide' flag is now used for keytype - only 'keyframes' existed before */ - dst->hide= BEZT_KEYTYPE_KEYFRAME; + dst->hide = BEZT_KEYTYPE_KEYFRAME; /* auto-handles - per curve to per handle */ if (icu->flag & IPO_AUTO_HORIZ) { @@ -1315,9 +1315,9 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * - we need radians for RNA to do the right thing */ if ( ((icu->blocktype == ID_OB) && ELEM3(icu->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) || - ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) ) + ((icu->blocktype == ID_PO) && ELEM3(icu->adrcode, AC_EUL_X, AC_EUL_Y, AC_EUL_Z)) ) { - const float fac= (float)M_PI / 18.0f; //10.0f * M_PI/180.0f; + const float fac = (float)M_PI / 18.0f; //10.0f * M_PI/180.0f; dst->vec[0][1] *= fac; dst->vec[1][1] *= fac; @@ -1329,7 +1329,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * - we now need as 'frames' */ if ( (id) && (icu->blocktype == GS(id->name)) && - (fcu->rna_path && strcmp(fcu->rna_path, "eval_time")==0) ) + (fcu->rna_path && strcmp(fcu->rna_path, "eval_time") == 0) ) { Curve *cu = (Curve *)id; @@ -1340,15 +1340,15 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct times for rotation drivers * - need to go from degrees to radians... - * - there's only really 1 target to worry about + * - there's only really 1 target to worry about * - were also degrees/10 */ if (fcu->driver && fcu->driver->variables.first) { - DriverVar *dvar= fcu->driver->variables.first; - DriverTarget *dtar= &dvar->targets[0]; + DriverVar *dvar = fcu->driver->variables.first; + DriverTarget *dtar = &dvar->targets[0]; if (ELEM3(dtar->transChan, DTAR_TRANSCHAN_ROTX, DTAR_TRANSCHAN_ROTY, DTAR_TRANSCHAN_ROTZ)) { - const float fac= (float)M_PI / 18.0f; + const float fac = (float)M_PI / 18.0f; dst->vec[0][0] *= fac; dst->vec[1][0] *= fac; @@ -1358,8 +1358,8 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * /* correct values for sequencer curves, that were not locked to frame */ if (seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) { - double mul= (seq->enddisp-seq->startdisp)/100.0f; - double offset= seq->startdisp; + double mul = (seq->enddisp - seq->startdisp) / 100.0f; + double offset = seq->startdisp; dst->vec[0][0] *= mul; dst->vec[0][0] += offset; @@ -1389,7 +1389,7 @@ static void icu_to_fcurves (ID *id, ListBase *groups, ListBase *list, IpoCurve * * This does not assume that any ID or AnimData uses it, but does assume that * it is given two lists, which it will perform driver/animation-data separation. */ -static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) +static void ipo_to_animato(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq, ListBase *animgroups, ListBase *anim, ListBase *drivers) { IpoCurve *icu; @@ -1407,13 +1407,13 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], */ if (actname) { if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Object") == 0)) - actname= NULL; + actname = NULL; else if ((ipo->blocktype == ID_OB) && (strcmp(actname, "Shape") == 0)) - actname= NULL; + actname = NULL; } /* loop over IPO-Curves, freeing as we progress */ - for (icu= ipo->curve.first; icu; icu= icu->next) { + for (icu = ipo->curve.first; icu; icu = icu->next) { /* Since an IPO-Curve may end up being made into many F-Curves (i.e. bitflag curves), * we figure out the best place to put the channel, then tell the curve-converter to just dump there */ @@ -1424,7 +1424,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], } else { MEM_freeN(icu->driver); - icu->driver= NULL; + icu->driver = NULL; } } else @@ -1436,8 +1436,8 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], if (ID_REAL_USERS(ipo) <= 0) { IpoCurve *icn; - for (icu= ipo->curve.first; icu; icu= icn) { - icn= icu->next; + for (icu = ipo->curve.first; icu; icu = icn) { + icn = icu->next; /* free driver */ if (icu->driver) @@ -1458,7 +1458,7 @@ static void ipo_to_animato (ID *id, Ipo *ipo, char actname[], char constname[], * to Objects, where ob->ipo and ob->action need to be combined). * NOTE: we need to be careful here, as same data-structs are used for new system too! */ -static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) +static void action_to_animato(ID *id, bAction *act, ListBase *groups, ListBase *curves, ListBase *drivers) { bActionChannel *achan, *achann; bConstraintChannel *conchan, *conchann; @@ -1473,27 +1473,27 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase BLI_freelistN(&act->groups); /* loop through Action-Channels, converting data, freeing as we go */ - for (achan= act->chanbase.first; achan; achan= achann) { + for (achan = act->chanbase.first; achan; achan = achann) { /* get pointer to next Action Channel */ - achann= achan->next; + achann = achan->next; /* convert Action Channel's IPO data */ if (achan->ipo) { ipo_to_animato(id, achan->ipo, achan->name, NULL, NULL, groups, curves, drivers); achan->ipo->id.us--; - achan->ipo= NULL; + achan->ipo = NULL; } /* convert constraint channel IPO-data */ - for (conchan= achan->constraintChannels.first; conchan; conchan= conchann) { + for (conchan = achan->constraintChannels.first; conchan; conchan = conchann) { /* get pointer to next Constraint Channel */ - conchann= conchan->next; + conchann = conchan->next; /* convert Constraint Channel's IPO data */ if (conchan->ipo) { ipo_to_animato(id, conchan->ipo, achan->name, conchan->name, NULL, groups, curves, drivers); conchan->ipo->id.us--; - conchan->ipo= NULL; + conchan->ipo = NULL; } /* free Constraint Channel */ @@ -1512,9 +1512,9 @@ static void action_to_animato (ID *id, bAction *act, ListBase *groups, ListBase * This assumes that AnimData has been added already. Separation of drivers * from animation data is accomplished here too... */ -static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) +static void ipo_to_animdata(ID *id, Ipo *ipo, char actname[], char constname[], Sequence *seq) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); ListBase anim = {NULL, NULL}; ListBase drivers = {NULL, NULL}; @@ -1528,8 +1528,8 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (G.debug & G_DEBUG) { printf("ipo to animdata - ID:%s, IPO:%s, actname:%s constname:%s seqname:%s curves:%d\n", - id->name+2, ipo->id.name+2, (actname)?actname:"", (constname)?constname:"", (seq)?(seq->name+2):"", - BLI_countlist(&ipo->curve)); + id->name + 2, ipo->id.name + 2, (actname) ? actname : "", (constname) ? constname : "", (seq) ? (seq->name + 2) : "", + BLI_countlist(&ipo->curve)); } /* Convert curves to animato system (separated into separate lists of F-Curves for animation and drivers), @@ -1545,9 +1545,9 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], if (adt->action == NULL) { char nameBuf[MAX_ID_NAME]; - BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name+2); + BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2); - adt->action= add_empty_action(nameBuf); + adt->action = add_empty_action(nameBuf); if (G.debug & G_DEBUG) printf("\t\tadded new action - '%s'\n", nameBuf); } @@ -1566,9 +1566,9 @@ static void ipo_to_animdata (ID *id, Ipo *ipo, char actname[], char constname[], /* Convert Action-block to new system * NOTE: we need to be careful here, as same data-structs are used for new system too! */ -static void action_to_animdata (ID *id, bAction *act) +static void action_to_animdata(ID *id, bAction *act) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* only continue if there are Action Channels (indicating unconverted data) */ if (ELEM(NULL, adt, act->chanbase.first)) @@ -1578,7 +1578,7 @@ static void action_to_animdata (ID *id, bAction *act) if (adt->action == NULL) { /* set this Action as AnimData's Action */ if (G.debug & G_DEBUG) printf("act_to_adt - set adt action to act\n"); - adt->action= act; + adt->action = act; } /* convert Action data */ @@ -1592,16 +1592,16 @@ static void action_to_animdata (ID *id, bAction *act) // - NLA curve/stride modifiers... /* Convert NLA-Strip to new system */ -static void nlastrips_to_animdata (ID *id, ListBase *strips) +static void nlastrips_to_animdata(ID *id, ListBase *strips) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); NlaTrack *nlt = NULL; NlaStrip *strip; bActionStrip *as, *asn; /* for each one of the original strips, convert to a new strip and free the old... */ - for (as= strips->first; as; as= asn) { - asn= as->next; + for (as = strips->first; as; as = asn) { + asn = as->next; /* this old strip is only worth something if it had an action... */ if (as->act) { @@ -1614,36 +1614,36 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) * - no need to muck around with the user-counts, since this is just * passing over the ref to the new owner, not creating an additional ref */ - strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); - strip->act= as->act; + strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); + strip->act = as->act; - /* endpoints */ - strip->start= as->start; - strip->end= as->end; - strip->actstart= as->actstart; - strip->actend= as->actend; - - /* action reuse */ - strip->repeat= as->repeat; - strip->scale= as->scale; - if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH; - - /* blending */ - strip->blendin= as->blendin; - strip->blendout= as->blendout; - strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE; - if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS; - - /* assorted setting flags */ - if (as->flag & ACTSTRIP_SELECT) strip->flag |= NLASTRIP_FLAG_SELECT; - if (as->flag & ACTSTRIP_ACTIVE) strip->flag |= NLASTRIP_FLAG_ACTIVE; - - if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED; - if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE; - - /* by default, we now always extrapolate, while in the past this was optional */ - if ((as->flag & ACTSTRIP_HOLDLASTFRAME)==0) - strip->extendmode= NLASTRIP_EXTEND_NOTHING; + /* endpoints */ + strip->start = as->start; + strip->end = as->end; + strip->actstart = as->actstart; + strip->actend = as->actend; + + /* action reuse */ + strip->repeat = as->repeat; + strip->scale = as->scale; + if (as->flag & ACTSTRIP_LOCK_ACTION) strip->flag |= NLASTRIP_FLAG_SYNC_LENGTH; + + /* blending */ + strip->blendin = as->blendin; + strip->blendout = as->blendout; + strip->blendmode = (as->mode == ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE; + if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS; + + /* assorted setting flags */ + if (as->flag & ACTSTRIP_SELECT) strip->flag |= NLASTRIP_FLAG_SELECT; + if (as->flag & ACTSTRIP_ACTIVE) strip->flag |= NLASTRIP_FLAG_ACTIVE; + + if (as->flag & ACTSTRIP_MUTE) strip->flag |= NLASTRIP_FLAG_MUTED; + if (as->flag & ACTSTRIP_REVERSE) strip->flag |= NLASTRIP_FLAG_REVERSE; + + /* by default, we now always extrapolate, while in the past this was optional */ + if ((as->flag & ACTSTRIP_HOLDLASTFRAME) == 0) + strip->extendmode = NLASTRIP_EXTEND_NOTHING; } /* try to add this strip to the current NLA-Track (i.e. the 'last' one on the stack atm) */ @@ -1651,7 +1651,7 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt= add_nlatrack(adt, NULL); + nlt = add_nlatrack(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } } @@ -1701,13 +1701,13 @@ void do_versions_ipos_to_animato(Main *main) /* ----------- Animation Attached to Data -------------- */ /* objects */ - for (id= main->object.first; id; id= id->next) { - Object *ob= (Object *)id; + for (id = main->object.first; id; id = id->next) { + Object *ob = (Object *)id; bPoseChannel *pchan; bConstraint *con; bConstraintChannel *conchan, *conchann; - if (G.debug & G_DEBUG) printf("\tconverting ob %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting ob %s\n", id->name + 2); /* check if object has any animation data */ if (ob->nlastrips.first) { @@ -1719,7 +1719,7 @@ void do_versions_ipos_to_animato(Main *main) ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; - ob->ipo= NULL; + ob->ipo = NULL; } /* Action is skipped since it'll be used by some strip in the NLA anyway, @@ -1727,7 +1727,7 @@ void do_versions_ipos_to_animato(Main *main) */ if (ob->action) { ob->action->id.us--; - ob->action= NULL; + ob->action = NULL; } /* finally NLA */ @@ -1735,7 +1735,7 @@ void do_versions_ipos_to_animato(Main *main) } else if ((ob->ipo) || (ob->action)) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Action first - so that Action name get conserved */ if (ob->action) { @@ -1744,7 +1744,7 @@ void do_versions_ipos_to_animato(Main *main) /* only decrease usercount if this Action isn't now being used by AnimData */ if (ob->action != adt->action) { ob->action->id.us--; - ob->action= NULL; + ob->action = NULL; } } @@ -1752,7 +1752,7 @@ void do_versions_ipos_to_animato(Main *main) if (ob->ipo) { ipo_to_animdata(id, ob->ipo, NULL, NULL, NULL); ob->ipo->id.us--; - ob->ipo= NULL; + ob->ipo = NULL; } } @@ -1761,8 +1761,8 @@ void do_versions_ipos_to_animato(Main *main) /* Verify if there's AnimData block */ BKE_id_add_animdata(id); - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { /* if constraint has own IPO, convert add these to Object * (NOTE: they're most likely to be drivers too) */ @@ -1772,14 +1772,14 @@ void do_versions_ipos_to_animato(Main *main) */ ipo_to_animdata(id, con->ipo, pchan->name, con->name, NULL); con->ipo->id.us--; - con->ipo= NULL; + con->ipo = NULL; } } } } /* check constraints for local IPO's */ - for (con= ob->constraints.first; con; con= con->next) { + for (con = ob->constraints.first; con; con = con->next) { /* if constraint has own IPO, convert add these to Object * (NOTE: they're most likely to be drivers too) */ @@ -1792,7 +1792,7 @@ void do_versions_ipos_to_animato(Main *main) */ ipo_to_animdata(id, con->ipo, NULL, con->name, NULL); con->ipo->id.us--; - con->ipo= NULL; + con->ipo = NULL; } /* check for Action Constraint */ @@ -1804,15 +1804,15 @@ void do_versions_ipos_to_animato(Main *main) /* Verify if there's AnimData block */ BKE_id_add_animdata(id); - for (conchan= ob->constraintChannels.first; conchan; conchan= conchann) { + for (conchan = ob->constraintChannels.first; conchan; conchan = conchann) { /* get pointer to next Constraint Channel */ - conchann= conchan->next; + conchann = conchan->next; /* convert Constraint Channel's IPO data */ if (conchan->ipo) { ipo_to_animdata(id, conchan->ipo, NULL, conchan->name, NULL); conchan->ipo->id.us--; - conchan->ipo= NULL; + conchan->ipo = NULL; } /* free Constraint Channel */ @@ -1822,17 +1822,17 @@ void do_versions_ipos_to_animato(Main *main) /* object's action will always be object-rooted */ { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); if (adt && adt->action) adt->action->idroot = ID_OB; } } /* shapekeys */ - for (id= main->key.first; id; id= id->next) { - Key *key= (Key *)id; + for (id = main->key.first; id; id = id->next) { + Key *key = (Key *)id; - if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting key %s\n", id->name + 2); /* we're only interested in the IPO * NOTE: for later, it might be good to port these over to Object instead, as many of these @@ -1840,7 +1840,7 @@ void do_versions_ipos_to_animato(Main *main) */ if (key->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Shapekey data... */ ipo_to_animdata(id, key->ipo, NULL, NULL, NULL); @@ -1849,20 +1849,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = key->ipo->blocktype; key->ipo->id.us--; - key->ipo= NULL; + key->ipo = NULL; } } /* materials */ - for (id= main->mat.first; id; id= id->next) { - Material *ma= (Material *)id; + for (id = main->mat.first; id; id = id->next) { + Material *ma = (Material *)id; - if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting material %s\n", id->name + 2); /* we're only interested in the IPO */ if (ma->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Material data... */ ipo_to_animdata(id, ma->ipo, NULL, NULL, NULL); @@ -1871,20 +1871,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = ma->ipo->blocktype; ma->ipo->id.us--; - ma->ipo= NULL; + ma->ipo = NULL; } } /* worlds */ - for (id= main->world.first; id; id= id->next) { - World *wo= (World *)id; + for (id = main->world.first; id; id = id->next) { + World *wo = (World *)id; - if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting world %s\n", id->name + 2); /* we're only interested in the IPO */ if (wo->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert World data... */ ipo_to_animdata(id, wo->ipo, NULL, NULL, NULL); @@ -1893,26 +1893,26 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = wo->ipo->blocktype; wo->ipo->id.us--; - wo->ipo= NULL; + wo->ipo = NULL; } } /* sequence strips */ - for (id= main->scene.first; id; id= id->next) { + for (id = main->scene.first; id; id = id->next) { Scene *scene = (Scene *)id; - Editing * ed = scene->ed; + Editing *ed = scene->ed; if (ed && ed->seqbasep) { - Sequence * seq; + Sequence *seq; - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); - SEQ_BEGIN (ed, seq) + SEQ_BEGIN(ed, seq) { IpoCurve *icu = (seq->ipo) ? seq->ipo->curve.first : NULL; short adrcode = SEQ_FAC1; if (G.debug & G_DEBUG) - printf("\tconverting sequence strip %s\n", seq->name+2); + printf("\tconverting sequence strip %s\n", seq->name + 2); if (ELEM(NULL, seq->ipo, icu)) { seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; @@ -1941,7 +1941,7 @@ void do_versions_ipos_to_animato(Main *main) ipo_to_animdata((ID *)scene, seq->ipo, NULL, NULL, seq); if (adt->action) - adt->action->idroot = ID_SCE; /* scene-rooted */ + adt->action->idroot = ID_SCE; /* scene-rooted */ seq->ipo->id.us--; seq->ipo = NULL; @@ -1952,15 +1952,15 @@ void do_versions_ipos_to_animato(Main *main) /* textures */ - for (id= main->tex.first; id; id= id->next) { - Tex *te= (Tex *)id; + for (id = main->tex.first; id; id = id->next) { + Tex *te = (Tex *)id; - if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting texture %s\n", id->name + 2); /* we're only interested in the IPO */ if (te->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Texture data... */ ipo_to_animdata(id, te->ipo, NULL, NULL, NULL); @@ -1969,20 +1969,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = te->ipo->blocktype; te->ipo->id.us--; - te->ipo= NULL; + te->ipo = NULL; } } /* cameras */ - for (id= main->camera.first; id; id= id->next) { - Camera *ca= (Camera *)id; + for (id = main->camera.first; id; id = id->next) { + Camera *ca = (Camera *)id; - if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting camera %s\n", id->name + 2); /* we're only interested in the IPO */ if (ca->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Camera data... */ ipo_to_animdata(id, ca->ipo, NULL, NULL, NULL); @@ -1991,20 +1991,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = ca->ipo->blocktype; ca->ipo->id.us--; - ca->ipo= NULL; + ca->ipo = NULL; } } /* lamps */ - for (id= main->lamp.first; id; id= id->next) { - Lamp *la= (Lamp *)id; + for (id = main->lamp.first; id; id = id->next) { + Lamp *la = (Lamp *)id; - if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting lamp %s\n", id->name + 2); /* we're only interested in the IPO */ if (la->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Lamp data... */ ipo_to_animdata(id, la->ipo, NULL, NULL, NULL); @@ -2013,20 +2013,20 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = la->ipo->blocktype; la->ipo->id.us--; - la->ipo= NULL; + la->ipo = NULL; } } /* curves */ - for (id= main->curve.first; id; id= id->next) { - Curve *cu= (Curve *)id; + for (id = main->curve.first; id; id = id->next) { + Curve *cu = (Curve *)id; - if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting curve %s\n", id->name + 2); /* we're only interested in the IPO */ if (cu->ipo) { /* Add AnimData block */ - AnimData *adt= BKE_id_add_animdata(id); + AnimData *adt = BKE_id_add_animdata(id); /* Convert Curve data... */ ipo_to_animdata(id, cu->ipo, NULL, NULL, NULL); @@ -2035,7 +2035,7 @@ void do_versions_ipos_to_animato(Main *main) adt->action->idroot = cu->ipo->blocktype; cu->ipo->id.us--; - cu->ipo= NULL; + cu->ipo = NULL; } } @@ -2051,10 +2051,10 @@ void do_versions_ipos_to_animato(Main *main) */ /* actions */ - for (id= main->action.first; id; id= id->next) { - bAction *act= (bAction *)id; + for (id = main->action.first; id; id = id->next) { + bAction *act = (bAction *)id; - if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting action %s\n", id->name + 2); /* if old action, it will be object-only... */ if (act->chanbase.first) @@ -2065,23 +2065,23 @@ void do_versions_ipos_to_animato(Main *main) } /* ipo's */ - for (id= main->ipo.first; id; id= id->next) { - Ipo *ipo= (Ipo *)id; + for (id = main->ipo.first; id; id = id->next) { + Ipo *ipo = (Ipo *)id; - if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name+2); + if (G.debug & G_DEBUG) printf("\tconverting ipo %s\n", id->name + 2); /* most likely this IPO has already been processed, so check if any curves left to convert */ if (ipo->curve.first) { bAction *new_act; /* add a new action for this, and convert all data into that action */ - new_act= add_empty_action("ConvIPO_Action"); // XXX need a better name... + new_act = add_empty_action("ConvIPO_Action"); // XXX need a better name... ipo_to_animato(NULL, ipo, NULL, NULL, NULL, NULL, &new_act->curves, &drivers); new_act->idroot = ipo->blocktype; } /* clear fake-users, and set user-count to zero to make sure it is cleared on file-save */ - ipo->id.us= 0; + ipo->id.us = 0; ipo->id.flag &= ~LIB_FAKEUSER; } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 54a2613991a..e36e7bf6cf3 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -78,7 +78,7 @@ int slurph_opt = 1; -void free_key(Key *key) +void BKE_key_free(Key *key) { KeyBlock *kb; @@ -126,7 +126,7 @@ Key *add_key(ID *id) /* common function */ Key *key; char *el; - key = alloc_libblock(&G.main->key, ID_KE, "Key"); + key = BKE_libblock_alloc(&G.main->key, ID_KE, "Key"); key->type = KEY_NORMAL; key->from = id; @@ -170,14 +170,14 @@ Key *add_key(ID *id) /* common function */ return key; } -Key *copy_key(Key *key) +Key *BKE_key_copy(Key *key) { Key *keyn; KeyBlock *kbn, *kb; if (key == NULL) return NULL; - keyn = copy_libblock(&key->id); + keyn = BKE_libblock_copy(&key->id); BLI_duplicatelist(&keyn->block, &key->block); @@ -223,7 +223,7 @@ Key *copy_key_nolib(Key *key) return keyn; } -void make_local_key(Key *key) +void BKE_key_make_local(Key *key) { /* - only lib users: do nothing diff --git a/source/blender/blenkernel/intern/lamp.c b/source/blender/blenkernel/intern/lamp.c index 11c3269ad37..20e3edc7044 100644 --- a/source/blender/blenkernel/intern/lamp.c +++ b/source/blender/blenkernel/intern/lamp.c @@ -51,34 +51,34 @@ #include "BKE_main.h" #include "BKE_node.h" -void *add_lamp(const char *name) +void *BKE_lamp_add(const char *name) { Lamp *la; - la= alloc_libblock(&G.main->lamp, ID_LA, name); + la = BKE_libblock_alloc(&G.main->lamp, ID_LA, name); - la->r= la->g= la->b= la->k= 1.0f; - la->haint= la->energy= 1.0f; - la->dist= 25.0f; - la->spotsize= 45.0f; - la->spotblend= 0.15f; - la->att2= 1.0f; - la->mode= LA_SHAD_BUF; - la->bufsize= 512; - la->clipsta= 0.5f; - la->clipend= 40.0f; - la->shadspotsize= 45.0f; - la->samp= 3; - la->bias= 1.0f; - la->soft= 3.0f; - la->compressthresh= 0.05f; - la->ray_samp= la->ray_sampy= la->ray_sampz= 1; - la->area_size=la->area_sizey=la->area_sizez= 1.0f; - la->buffers= 1; - la->buftype= LA_SHADBUF_HALFWAY; + la->r = la->g = la->b = la->k = 1.0f; + la->haint = la->energy = 1.0f; + la->dist = 25.0f; + la->spotsize = 45.0f; + la->spotblend = 0.15f; + la->att2 = 1.0f; + la->mode = LA_SHAD_BUF; + la->bufsize = 512; + la->clipsta = 0.5f; + la->clipend = 40.0f; + la->shadspotsize = 45.0f; + la->samp = 3; + la->bias = 1.0f; + la->soft = 3.0f; + la->compressthresh = 0.05f; + la->ray_samp = la->ray_sampy = la->ray_sampz = 1; + la->area_size = la->area_sizey = la->area_sizez = 1.0f; + la->buffers = 1; + la->buftype = LA_SHADBUF_HALFWAY; la->ray_samp_method = LA_SAMP_HALTON; la->adapt_thresh = 0.001f; - la->preview=NULL; + la->preview = NULL; la->falloff_type = LA_FALLOFF_INVSQUARE; la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); la->sun_effect_type = 0; @@ -92,26 +92,26 @@ void *add_lamp(const char *name) la->atm_extinction_factor = 1.0f; la->atm_distance_factor = 1.0f; la->sun_intensity = 1.0f; - la->skyblendtype= MA_RAMP_ADD; - la->skyblendfac= 1.0f; - la->sky_colorspace= BLI_XYZ_CIE; - la->sky_exposure= 1.0f; - la->shadow_frustum_size= 10.0f; + la->skyblendtype = MA_RAMP_ADD; + la->skyblendfac = 1.0f; + la->sky_colorspace = BLI_XYZ_CIE; + la->sky_exposure = 1.0f; + la->shadow_frustum_size = 10.0f; curvemapping_initialize(la->curfalloff); return la; } -Lamp *copy_lamp(Lamp *la) +Lamp *BKE_lamp_copy(Lamp *la) { Lamp *lan; int a; - lan= copy_libblock(&la->id); + lan = BKE_libblock_copy(&la->id); - for (a=0; amtex[a]) { - lan->mtex[a]= MEM_mallocN(sizeof(MTex), "copylamptex"); + lan->mtex[a] = MEM_mallocN(sizeof(MTex), "copylamptex"); memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex)); id_us_plus((ID *)lan->mtex[a]->tex); } @@ -120,7 +120,7 @@ Lamp *copy_lamp(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); if (la->nodetree) - lan->nodetree= ntreeCopyTree(la->nodetree); + lan->nodetree = ntreeCopyTree(la->nodetree); if (la->preview) lan->preview = BKE_previewimg_copy(la->preview); @@ -133,12 +133,12 @@ Lamp *localize_lamp(Lamp *la) Lamp *lan; int a; - lan= copy_libblock(&la->id); + lan = BKE_libblock_copy(&la->id); BLI_remlink(&G.main->lamp, lan); - for (a=0; amtex[a]) { - lan->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_lamp"); + lan->mtex[a] = MEM_mallocN(sizeof(MTex), "localize_lamp"); memcpy(lan->mtex[a], la->mtex[a], sizeof(MTex)); /* free lamp decrements */ id_us_plus((ID *)lan->mtex[a]->tex); @@ -148,71 +148,71 @@ Lamp *localize_lamp(Lamp *la) lan->curfalloff = curvemapping_copy(la->curfalloff); if (la->nodetree) - lan->nodetree= ntreeLocalize(la->nodetree); + lan->nodetree = ntreeLocalize(la->nodetree); - lan->preview= NULL; + lan->preview = NULL; return lan; } -void make_local_lamp(Lamp *la) +void BKE_lamp_make_local(Lamp *la) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (la->id.lib==NULL) return; - if (la->id.us==1) { + if (la->id.lib == NULL) return; + if (la->id.us == 1) { id_clear_lib_data(bmain, &la->id); return; } - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==la) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->data == la) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } - ob= ob->id.next; + ob = ob->id.next; } if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &la->id); } else if (is_local && is_lib) { - Lamp *la_new= copy_lamp(la); - la_new->id.us= 0; + Lamp *la_new = BKE_lamp_copy(la); + la_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, la->id.lib, &la_new->id); - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==la) { + if (ob->data == la) { - if (ob->id.lib==NULL) { - ob->data= la_new; + if (ob->id.lib == NULL) { + ob->data = la_new; la_new->id.us++; la->id.us--; } } - ob= ob->id.next; + ob = ob->id.next; } } } -void free_lamp(Lamp *la) +void BKE_lamp_free(Lamp *la) { MTex *mtex; int a; - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = la->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index e78da48d153..c6f2bb75858 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -69,71 +69,71 @@ void calc_lat_fudu(int flag, int res, float *fu, float *du) { - if (res==1) { - *fu= 0.0; - *du= 0.0; + if (res == 1) { + *fu = 0.0; + *du = 0.0; } else if (flag & LT_GRID) { - *fu= -0.5f*(res-1); - *du= 1.0f; + *fu = -0.5f * (res - 1); + *du = 1.0f; } else { - *fu= -1.0f; - *du= 2.0f/(res-1); + *fu = -1.0f; + *du = 2.0f / (res - 1); } } -void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) +void BKE_lattice_resize(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) { BPoint *bp; int i, u, v, w; - float fu, fv, fw, uc, vc, wc, du=0.0, dv=0.0, dw=0.0; + float fu, fv, fw, uc, vc, wc, du = 0.0, dv = 0.0, dw = 0.0; float *co, (*vertexCos)[3] = NULL; /* vertex weight groups are just freed all for now */ if (lt->dvert) { - free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); - lt->dvert= NULL; + free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); + lt->dvert = NULL; } - while (uNew*vNew*wNew > 32000) { - if ( uNew>=vNew && uNew>=wNew) uNew--; - else if ( vNew>=uNew && vNew>=wNew) vNew--; + while (uNew * vNew * wNew > 32000) { + if (uNew >= vNew && uNew >= wNew) uNew--; + else if (vNew >= uNew && vNew >= wNew) vNew--; else wNew--; } - vertexCos = MEM_mallocN(sizeof(*vertexCos)*uNew*vNew*wNew, "tmp_vcos"); + vertexCos = MEM_mallocN(sizeof(*vertexCos) * uNew * vNew * wNew, "tmp_vcos"); calc_lat_fudu(lt->flag, uNew, &fu, &du); calc_lat_fudu(lt->flag, vNew, &fv, &dv); calc_lat_fudu(lt->flag, wNew, &fw, &dw); - /* If old size is different then resolution changed in interface, - * try to do clever reinit of points. Pretty simply idea, we just - * deform new verts by old lattice, but scaling them to match old - * size first. - */ + /* If old size is different then resolution changed in interface, + * try to do clever reinit of points. Pretty simply idea, we just + * deform new verts by old lattice, but scaling them to match old + * size first. + */ if (ltOb) { - if (uNew!=1 && lt->pntsu!=1) { + if (uNew != 1 && lt->pntsu != 1) { fu = lt->fu; - du = (lt->pntsu-1)*lt->du/(uNew-1); + du = (lt->pntsu - 1) * lt->du / (uNew - 1); } - if (vNew!=1 && lt->pntsv!=1) { + if (vNew != 1 && lt->pntsv != 1) { fv = lt->fv; - dv = (lt->pntsv-1)*lt->dv/(vNew-1); + dv = (lt->pntsv - 1) * lt->dv / (vNew - 1); } - if (wNew!=1 && lt->pntsw!=1) { + if (wNew != 1 && lt->pntsw != 1) { fw = lt->fw; - dw = (lt->pntsw-1)*lt->dw/(wNew-1); + dw = (lt->pntsw - 1) * lt->dw / (wNew - 1); } } co = vertexCos[0]; - for (w=0, wc=fw; wtypeu, typev = lt->typev, typew = lt->typew; - /* works best if we force to linear type (endpoints match) */ + /* works best if we force to linear type (endpoints match) */ lt->typeu = lt->typev = lt->typew = KEY_LINEAR; - /* prevent using deformed locations */ - freedisplist(<Ob->disp); + /* prevent using deformed locations */ + BKE_displist_free(<Ob->disp); copy_m4_m4(mat, ltOb->obmat); unit_m4(ltOb->obmat); - lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL, 1.0f); + lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew * vNew * wNew, NULL, 1.0f); copy_m4_m4(ltOb->obmat, mat); lt->typeu = typeu; @@ -173,63 +173,63 @@ void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb) lt->pntsw = wNew; MEM_freeN(lt->def); - lt->def= MEM_callocN(lt->pntsu*lt->pntsv*lt->pntsw*sizeof(BPoint), "lattice bp"); + lt->def = MEM_callocN(lt->pntsu * lt->pntsv * lt->pntsw * sizeof(BPoint), "lattice bp"); - bp= lt->def; + bp = lt->def; - for (i=0; ipntsu*lt->pntsv*lt->pntsw; i++, bp++) { + for (i = 0; i < lt->pntsu * lt->pntsv * lt->pntsw; i++, bp++) { copy_v3_v3(bp->vec, vertexCos[i]); } MEM_freeN(vertexCos); } -Lattice *add_lattice(const char *name) +Lattice *BKE_lattice_add(const char *name) { Lattice *lt; - lt= alloc_libblock(&G.main->latt, ID_LT, name); + lt = BKE_libblock_alloc(&G.main->latt, ID_LT, name); - lt->flag= LT_GRID; + lt->flag = LT_GRID; - lt->typeu= lt->typev= lt->typew= KEY_BSPLINE; + lt->typeu = lt->typev = lt->typew = KEY_BSPLINE; - lt->def= MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ - resizelattice(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ + lt->def = MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */ + BKE_lattice_resize(lt, 2, 2, 2, NULL); /* creates a uniform lattice */ return lt; } -Lattice *copy_lattice(Lattice *lt) +Lattice *BKE_lattice_copy(Lattice *lt) { Lattice *ltn; - ltn= copy_libblock(<->id); - ltn->def= MEM_dupallocN(lt->def); + ltn = BKE_libblock_copy(<->id); + ltn->def = MEM_dupallocN(lt->def); - ltn->key= copy_key(ltn->key); - if (ltn->key) ltn->key->from= (ID *)ltn; + ltn->key = BKE_key_copy(ltn->key); + if (ltn->key) ltn->key->from = (ID *)ltn; if (lt->dvert) { - int tot= lt->pntsu*lt->pntsv*lt->pntsw; - ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert"); + int tot = lt->pntsu * lt->pntsv * lt->pntsw; + ltn->dvert = MEM_mallocN(sizeof (MDeformVert) * tot, "Lattice MDeformVert"); copy_dverts(ltn->dvert, lt->dvert, tot); } - ltn->editlatt= NULL; + ltn->editlatt = NULL; return ltn; } -void free_lattice(Lattice *lt) +void BKE_lattice_free(Lattice *lt) { if (lt->def) MEM_freeN(lt->def); - if (lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); + if (lt->dvert) free_dverts(lt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); if (lt->editlatt) { - Lattice *editlt= lt->editlatt->latt; + Lattice *editlt = lt->editlatt->latt; if (editlt->def) MEM_freeN(editlt->def); - if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw); + if (editlt->dvert) free_dverts(editlt->dvert, lt->pntsu * lt->pntsv * lt->pntsw); MEM_freeN(editlt); MEM_freeN(lt->editlatt); @@ -238,49 +238,49 @@ void free_lattice(Lattice *lt) /* free animation data */ if (lt->adt) { BKE_free_animdata(<->id); - lt->adt= NULL; + lt->adt = NULL; } } -void make_local_lattice(Lattice *lt) +void BKE_lattice_make_local(Lattice *lt) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (lt->id.lib==NULL) return; - if (lt->id.us==1) { + if (lt->id.lib == NULL) return; + if (lt->id.us == 1) { id_clear_lib_data(bmain, <->id); return; } - for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) { - if (ob->data==lt) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (ob = bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob = ob->id.next) { + if (ob->data == lt) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - if (is_local && is_lib==FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, <->id); } else if (is_local && is_lib) { - Lattice *lt_new= copy_lattice(lt); - lt_new->id.us= 0; + Lattice *lt_new = BKE_lattice_copy(lt); + lt_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, lt->id.lib, <_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { - if (ob->data==lt) { - if (ob->id.lib==NULL) { - ob->data= lt_new; + for (ob = bmain->object.first; ob; ob = ob->id.next) { + if (ob->data == lt) { + if (ob->id.lib == NULL) { + ob->data = lt_new; lt_new->id.us++; lt->id.us--; } @@ -291,22 +291,22 @@ void make_local_lattice(Lattice *lt) void init_latt_deform(Object *oblatt, Object *ob) { - /* we make an array with all differences */ - Lattice *lt= oblatt->data; + /* we make an array with all differences */ + Lattice *lt = oblatt->data; BPoint *bp; - DispList *dl = find_displist(&oblatt->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; + DispList *dl = BKE_displist_find(&oblatt->disp, DL_VERTS); + float *co = dl ? dl->verts : NULL; float *fp, imat[4][4]; float fu, fv, fw; int u, v, w; - if (lt->editlatt) lt= lt->editlatt->latt; + if (lt->editlatt) lt = lt->editlatt->latt; bp = lt->def; - fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata"); + fp = lt->latticedata = MEM_mallocN(sizeof(float) * 3 * lt->pntsu * lt->pntsv * lt->pntsw, "latticedata"); - /* for example with a particle system: ob==0 */ - if (ob==NULL) { + /* for example with a particle system: ob==0 */ + if (ob == NULL) { /* in deformspace, calc matrix */ invert_m4_m4(lt->latmat, oblatt->obmat); @@ -322,9 +322,9 @@ void init_latt_deform(Object *oblatt, Object *ob) invert_m4_m4(imat, lt->latmat); } - for (w=0, fw=lt->fw; wpntsw; w++, fw+=lt->dw) { - for (v=0, fv=lt->fv; vpntsv; v++, fv+=lt->dv) { - for (u=0, fu=lt->fu; upntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) { + for (w = 0, fw = lt->fw; w < lt->pntsw; w++, fw += lt->dw) { + for (v = 0, fv = lt->fv; v < lt->pntsv; v++, fv += lt->dv) { + for (u = 0, fu = lt->fu; u < lt->pntsu; u++, bp++, co += 3, fp += 3, fu += lt->du) { if (dl) { fp[0] = co[0] - fu; fp[1] = co[1] - fv; @@ -344,23 +344,23 @@ void init_latt_deform(Object *oblatt, Object *ob) void calc_latt_deform(Object *ob, float co[3], float weight) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; float u, v, w, tu[4], tv[4], tw[4]; float vec[3]; int idx_w, idx_v, idx_u; int ui, vi, wi, uu, vv, ww; /* vgroup influence */ - int defgroup_nr= -1; - float co_prev[3], weight_blend= 0.0f; - MDeformVert *dvert= lattice_get_deform_verts(ob); + int defgroup_nr = -1; + float co_prev[3], weight_blend = 0.0f; + MDeformVert *dvert = BKE_lattice_deform_verts_get(ob); - if (lt->editlatt) lt= lt->editlatt->latt; - if (lt->latticedata==NULL) return; + if (lt->editlatt) lt = lt->editlatt->latt; + if (lt->latticedata == NULL) return; if (lt->vgroup[0] && dvert) { - defgroup_nr= defgroup_name_index(ob, lt->vgroup); + defgroup_nr = defgroup_name_index(ob, lt->vgroup); copy_v3_v3(co_prev, co); } @@ -369,68 +369,68 @@ void calc_latt_deform(Object *ob, float co[3], float weight) /* u v w coords */ - if (lt->pntsu>1) { - u= (vec[0]-lt->fu)/lt->du; - ui= (int)floor(u); + if (lt->pntsu > 1) { + u = (vec[0] - lt->fu) / lt->du; + ui = (int)floor(u); u -= ui; key_curve_position_weights(u, tu, lt->typeu); } else { - tu[0]= tu[2]= tu[3]= 0.0; tu[1]= 1.0; - ui= 0; + tu[0] = tu[2] = tu[3] = 0.0; tu[1] = 1.0; + ui = 0; } - if (lt->pntsv>1) { - v= (vec[1]-lt->fv)/lt->dv; - vi= (int)floor(v); + if (lt->pntsv > 1) { + v = (vec[1] - lt->fv) / lt->dv; + vi = (int)floor(v); v -= vi; key_curve_position_weights(v, tv, lt->typev); } else { - tv[0]= tv[2]= tv[3]= 0.0; tv[1]= 1.0; - vi= 0; + tv[0] = tv[2] = tv[3] = 0.0; tv[1] = 1.0; + vi = 0; } - if (lt->pntsw>1) { - w= (vec[2]-lt->fw)/lt->dw; - wi= (int)floor(w); + if (lt->pntsw > 1) { + w = (vec[2] - lt->fw) / lt->dw; + wi = (int)floor(w); w -= wi; key_curve_position_weights(w, tw, lt->typew); } else { - tw[0]= tw[2]= tw[3]= 0.0; tw[1]= 1.0; - wi= 0; + tw[0] = tw[2] = tw[3] = 0.0; tw[1] = 1.0; + wi = 0; } - for (ww= wi-1; ww<=wi+2; ww++) { - w= tw[ww-wi+1]; + for (ww = wi - 1; ww <= wi + 2; ww++) { + w = tw[ww - wi + 1]; if (w != 0.0f) { - if (ww>0) { - if (wwpntsw) idx_w= ww*lt->pntsu*lt->pntsv; - else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv; + if (ww > 0) { + if (ww < lt->pntsw) idx_w = ww * lt->pntsu * lt->pntsv; + else idx_w = (lt->pntsw - 1) * lt->pntsu * lt->pntsv; } - else idx_w= 0; + else idx_w = 0; - for (vv= vi-1; vv<=vi+2; vv++) { - v= w*tv[vv-vi+1]; + for (vv = vi - 1; vv <= vi + 2; vv++) { + v = w * tv[vv - vi + 1]; if (v != 0.0f) { - if (vv>0) { - if (vvpntsv) idx_v= idx_w + vv*lt->pntsu; - else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu; + if (vv > 0) { + if (vv < lt->pntsv) idx_v = idx_w + vv * lt->pntsu; + else idx_v = idx_w + (lt->pntsv - 1) * lt->pntsu; } - else idx_v= idx_w; + else idx_v = idx_w; - for (uu= ui-1; uu<=ui+2; uu++) { - u= weight*v*tu[uu-ui+1]; + for (uu = ui - 1; uu <= ui + 2; uu++) { + u = weight * v * tu[uu - ui + 1]; if (u != 0.0f) { - if (uu>0) { - if (uupntsu) idx_u= idx_v + uu; - else idx_u= idx_v + (lt->pntsu-1); + if (uu > 0) { + if (uu < lt->pntsu) idx_u = idx_v + uu; + else idx_u = idx_v + (lt->pntsu - 1); } - else idx_u= idx_v; + else idx_u = idx_v; madd_v3_v3fl(co, <->latticedata[idx_u * 3], u); @@ -450,18 +450,18 @@ void calc_latt_deform(Object *ob, float co[3], float weight) void end_latt_deform(Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; - if (lt->editlatt) lt= lt->editlatt->latt; + if (lt->editlatt) lt = lt->editlatt->latt; if (lt->latticedata) MEM_freeN(lt->latticedata); - lt->latticedata= NULL; + lt->latticedata = NULL; } - /* calculations is in local space of deformed object - * so we store in latmat transform from path coord inside object - */ +/* calculations is in local space of deformed object + * so we store in latmat transform from path coord inside object + */ typedef struct { float dmin[3], dmax[3]; float curvespace[4][4], objectspace[4][4], objectspace3[3][3]; @@ -474,7 +474,7 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd) mult_m4_m4m4(cd->objectspace, ob->imat, par->obmat); invert_m4_m4(cd->curvespace, cd->objectspace); copy_m3_m4(cd->objectspace3, cd->objectspace); - cd->no_rot_axis= 0; + cd->no_rot_axis = 0; } /* this makes sure we can extend for non-cyclic. @@ -483,41 +483,41 @@ static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd) */ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir[3], float quat[4], float *radius) { - Curve *cu= ob->data; + Curve *cu = ob->data; BevList *bl; float ctime1; - int cycl=0; + int cycl = 0; /* test for cyclic */ - bl= cu->bev.first; + bl = cu->bev.first; if (!bl->nr) return 0; - if (bl && bl->poly> -1) cycl= 1; + if (bl && bl->poly > -1) cycl = 1; - if (cycl==0) { - ctime1= CLAMPIS(ctime, 0.0f, 1.0f); + if (cycl == 0) { + ctime1 = CLAMPIS(ctime, 0.0f, 1.0f); } - else ctime1= ctime; + else ctime1 = ctime; /* vec needs 4 items */ if (where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) { - if (cycl==0) { - Path *path= cu->path; + if (cycl == 0) { + Path *path = cu->path; float dvec[3]; if (ctime < 0.0f) { sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec); - mul_v3_fl(dvec, ctime*(float)path->len); + mul_v3_fl(dvec, ctime * (float)path->len); add_v3_v3(vec, dvec); if (quat) copy_qt_qt(quat, path->data[0].quat); - if (radius) *radius= path->data[0].radius; + if (radius) *radius = path->data[0].radius; } else if (ctime > 1.0f) { - sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec); - mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len); + sub_v3_v3v3(dvec, path->data[path->len - 1].vec, path->data[path->len - 2].vec); + mul_v3_fl(dvec, (ctime - 1.0f) * (float)path->len); add_v3_v3(vec, dvec); - if (quat) copy_qt_qt(quat, path->data[path->len-1].quat); - if (radius) *radius= path->data[path->len-1].radius; + if (quat) copy_qt_qt(quat, path->data[path->len - 1].quat); + if (radius) *radius = path->data[path->len - 1].radius; /* weight - not used but could be added */ } } @@ -534,43 +534,43 @@ static int where_on_path_deform(Object *ob, float ctime, float vec[4], float dir static int calc_curve_deform(Scene *scene, Object *par, float co[3], const short axis, CurveDeform *cd, float quat_r[4]) { - Curve *cu= par->data; + Curve *cu = par->data; float fac, loc[4], dir[3], new_quat[4], radius; short index; const int is_neg_axis = (axis > 2); /* to be sure, mostly after file load */ - if (cu->path==NULL) { - makeDispListCurveTypes(scene, par, 0); - if (cu->path==NULL) return 0; // happens on append... + if (cu->path == NULL) { + BKE_displist_make_curveTypes(scene, par, 0); + if (cu->path == NULL) return 0; // happens on append... } /* options */ if (is_neg_axis) { index = axis - 3; if (cu->flag & CU_STRETCH) - fac= (-co[index]-cd->dmax[index])/(cd->dmax[index] - cd->dmin[index]); + fac = (-co[index] - cd->dmax[index]) / (cd->dmax[index] - cd->dmin[index]); else - fac= - (co[index]-cd->dmax[index])/(cu->path->totdist); + fac = -(co[index] - cd->dmax[index]) / (cu->path->totdist); } else { index = axis; if (cu->flag & CU_STRETCH) - fac= (co[index]-cd->dmin[index])/(cd->dmax[index] - cd->dmin[index]); + fac = (co[index] - cd->dmin[index]) / (cd->dmax[index] - cd->dmin[index]); else - fac= + (co[index]-cd->dmin[index])/(cu->path->totdist); + fac = +(co[index] - cd->dmin[index]) / (cu->path->totdist); } - if ( where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */ + if (where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */ float quat[4], cent[3]; - if (cd->no_rot_axis) { /* set by caller */ + if (cd->no_rot_axis) { /* set by caller */ /* this is not exactly the same as 2.4x, since the axis is having rotation removed rather than * changing the axis before calculating the tilt but serves much the same purpose */ - float dir_flat[3]={0, 0, 0}, q[4]; + float dir_flat[3] = {0, 0, 0}, q[4]; copy_v3_v3(dir_flat, dir); - dir_flat[cd->no_rot_axis-1]= 0.0f; + dir_flat[cd->no_rot_axis - 1] = 0.0f; normalize_v3(dir); normalize_v3(dir_flat); @@ -598,9 +598,9 @@ static int calc_curve_deform(Scene *scene, Object *par, float co[3], /* zero the axis which is not used, * the big block of text above now applies to these 3 lines */ - quat_apply_track(quat, axis, (axis == 0 || axis == 2) ? 1:0); /* up flag is a dummy, set so no rotation is done */ + quat_apply_track(quat, axis, (axis == 0 || axis == 2) ? 1 : 0); /* up flag is a dummy, set so no rotation is done */ vec_apply_track(cent, axis); - cent[index]= 0.0f; + cent[index] = 0.0f; /* scale if enabled */ @@ -637,26 +637,26 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, cu = cuOb->data; flag = cu->flag; - cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist + cu->flag |= (CU_PATH | CU_FOLLOW); // needed for path & bevlist init_curve_deform(cuOb, target, &cd); /* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */ if (is_neg_axis == FALSE) { - cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f; - cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f; + cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = 0.0f; + cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 1.0f; } else { /* negative, these bounds give a good rest position */ - cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f; - cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f; + cd.dmin[0] = cd.dmin[1] = cd.dmin[2] = -1.0f; + cd.dmax[0] = cd.dmax[1] = cd.dmax[2] = 0.0f; } /* check whether to use vertex groups (only possible if target is a Mesh) * we want either a Mesh with no derived data, or derived data with * deformverts */ - if (target && target->type==OB_MESH) { + if (target && target->type == OB_MESH) { /* if there's derived data without deformverts, don't use vgroups */ if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT)) use_vgroups = 0; @@ -668,8 +668,8 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, } if (vgroup && vgroup[0] && use_vgroups) { - Mesh *me= target->data; - int index= defgroup_name_index(target, vgroup); + Mesh *me = target->data; + int index = defgroup_name_index(target, vgroup); if (index != -1 && (me->dvert || dm)) { MDeformVert *dvert = me->dvert; @@ -681,7 +681,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, dvert = me->dvert; for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight= defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, index); if (weight > 0.0f) { mul_m4_v3(cd.curvespace, vertexCos[a]); @@ -709,7 +709,7 @@ void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight= defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, index); if (weight > 0.0f) { /* already in 'cd.curvespace', prev for loop */ @@ -764,7 +764,7 @@ void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, } init_curve_deform(cuOb, target, &cd); - cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */ + cd.no_rot_axis = no_rot_axis; /* option to only rotate for XY, for example */ copy_v3_v3(cd.dmin, orco); copy_v3_v3(cd.dmax, orco); @@ -799,7 +799,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, * we want either a Mesh with no derived data, or derived data with * deformverts */ - if (target && target->type==OB_MESH) { + if (target && target->type == OB_MESH) { /* if there's derived data without deformverts, don't use vgroups */ if (dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT)) use_vgroups = 0; @@ -821,7 +821,7 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, for (a = 0; a < numVerts; a++, dvert++) { if (dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT); - weight= defvert_find_weight(dvert, index); + weight = defvert_find_weight(dvert, index); if (weight > 0.0f) calc_latt_deform(laOb, vertexCos[a], weight * fac); @@ -838,12 +838,12 @@ void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm, int object_deform_mball(Object *ob, ListBase *dispbase) { - if (ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + if (ob->parent && ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) { DispList *dl; - for (dl=dispbase->first; dl; dl=dl->next) { + for (dl = dispbase->first; dl; dl = dl->next) { lattice_deform_verts(ob->parent, ob, NULL, - (float(*)[3]) dl->verts, dl->nr, NULL, 1.0f); + (float(*)[3])dl->verts, dl->nr, NULL, 1.0f); } return 1; @@ -862,52 +862,52 @@ void outside_lattice(Lattice *lt) { BPoint *bp, *bp1, *bp2; int u, v, w; - float fac1, du=0.0, dv=0.0, dw=0.0; + float fac1, du = 0.0, dv = 0.0, dw = 0.0; if (lt->flag & LT_OUTSIDE) { - bp= lt->def; + bp = lt->def; - if (lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1); - if (lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1); - if (lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1); + if (lt->pntsu > 1) du = 1.0f / ((float)lt->pntsu - 1); + if (lt->pntsv > 1) dv = 1.0f / ((float)lt->pntsv - 1); + if (lt->pntsw > 1) dw = 1.0f / ((float)lt->pntsw - 1); - for (w=0; wpntsw; w++) { + for (w = 0; w < lt->pntsw; w++) { - for (v=0; vpntsv; v++) { + for (v = 0; v < lt->pntsv; v++) { - for (u=0; upntsu; u++, bp++) { - if (u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1); + for (u = 0; u < lt->pntsu; u++, bp++) { + if (u == 0 || v == 0 || w == 0 || u == lt->pntsu - 1 || v == lt->pntsv - 1 || w == lt->pntsw - 1) ; else { - bp->hide= 1; + bp->hide = 1; bp->f1 &= ~SELECT; /* u extrema */ - bp1= latt_bp(lt, 0, v, w); - bp2= latt_bp(lt, lt->pntsu-1, v, w); + bp1 = latt_bp(lt, 0, v, w); + bp2 = latt_bp(lt, lt->pntsu - 1, v, w); - fac1= du*u; - bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0]; - bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; - bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; + fac1 = du * u; + bp->vec[0] = (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0]; + bp->vec[1] = (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; + bp->vec[2] = (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; /* v extrema */ - bp1= latt_bp(lt, u, 0, w); - bp2= latt_bp(lt, u, lt->pntsv-1, w); + bp1 = latt_bp(lt, u, 0, w); + bp2 = latt_bp(lt, u, lt->pntsv - 1, w); - fac1= dv*v; - bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0]; - bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; - bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; + fac1 = dv * v; + bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0]; + bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; + bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; /* w extrema */ - bp1= latt_bp(lt, u, v, 0); - bp2= latt_bp(lt, u, v, lt->pntsw-1); + bp1 = latt_bp(lt, u, v, 0); + bp2 = latt_bp(lt, u, v, lt->pntsw - 1); - fac1= dw*w; - bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0]; - bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1]; - bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2]; + fac1 = dw * w; + bp->vec[0] += (1.0f - fac1) * bp1->vec[0] + fac1 * bp2->vec[0]; + bp->vec[1] += (1.0f - fac1) * bp1->vec[1] + fac1 * bp2->vec[1]; + bp->vec[2] += (1.0f - fac1) * bp1->vec[2] + fac1 * bp2->vec[2]; mul_v3_fl(bp->vec, 0.3333333f); @@ -919,84 +919,84 @@ void outside_lattice(Lattice *lt) } } else { - bp= lt->def; + bp = lt->def; - for (w=0; wpntsw; w++) - for (v=0; vpntsv; v++) - for (u=0; upntsu; u++, bp++) - bp->hide= 0; + for (w = 0; w < lt->pntsw; w++) + for (v = 0; v < lt->pntsv; v++) + for (u = 0; u < lt->pntsu; u++, bp++) + bp->hide = 0; } } -float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3] +float (*BKE_lattice_vertexcos_get(struct Object *ob, int *numVerts_r))[3] { Lattice *lt = ob->data; int i, numVerts; float (*vertexCos)[3]; - if (lt->editlatt) lt= lt->editlatt->latt; - numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw; + if (lt->editlatt) lt = lt->editlatt->latt; + numVerts = *numVerts_r = lt->pntsu * lt->pntsv * lt->pntsw; - vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts, "lt_vcos"); + vertexCos = MEM_mallocN(sizeof(*vertexCos) * numVerts, "lt_vcos"); - for (i=0; idef[i].vec); } return vertexCos; } -void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3]) +void BKE_lattice_vertexcos_apply(struct Object *ob, float (*vertexCos)[3]) { Lattice *lt = ob->data; - int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw; + int i, numVerts = lt->pntsu * lt->pntsv * lt->pntsw; - for (i=0; idef[i].vec, vertexCos[i]); } } -void lattice_calc_modifiers(Scene *scene, Object *ob) +void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) { - Lattice *lt= ob->data; + Lattice *lt = ob->data; ModifierData *md = modifiers_getVirtualModifierList(ob); float (*vertexCos)[3] = NULL; - int numVerts, editmode = (lt->editlatt!=NULL); + int numVerts, editmode = (lt->editlatt != NULL); - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; - if (!(md->mode&eModifierMode_Realtime)) continue; - if (editmode && !(md->mode&eModifierMode_Editmode)) continue; + if (!(md->mode & eModifierMode_Realtime)) continue; + if (editmode && !(md->mode & eModifierMode_Editmode)) continue; if (mti->isDisabled && mti->isDisabled(md, 0)) continue; - if (mti->type!=eModifierTypeType_OnlyDeform) continue; + if (mti->type != eModifierTypeType_OnlyDeform) continue; - if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts); - mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); + if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); + mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0); } /* always displist to make this work like derivedmesh */ - if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts); + if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); { DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl"); dl->type = DL_VERTS; dl->parts = 1; dl->nr = numVerts; - dl->verts = (float*) vertexCos; + dl->verts = (float *) vertexCos; BLI_addtail(&ob->disp, dl); } } -struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt) +struct MDeformVert *BKE_lattice_deform_verts_get(struct Object *oblatt) { - Lattice *lt = (Lattice*)oblatt->data; + Lattice *lt = (Lattice *)oblatt->data; BLI_assert(oblatt->type == OB_LATTICE); - if (lt->editlatt) lt= lt->editlatt->latt; + if (lt->editlatt) lt = lt->editlatt->latt; return lt->dvert; } diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index 52c92034367..6a43c48c32b 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -116,14 +116,14 @@ #include "BPY_extern.h" #endif -#define MAX_IDPUP 60 /* was 24 */ +#define MAX_IDPUP 60 /* was 24 */ /* GS reads the memory pointed at in a specific ordering. * only use this definition, makes little and big endian systems * work fine, in conjunction with MAKE_ID */ /* from blendef: */ -#define GS(a) (*((short *)(a))) +#define GS(a) (*((short *)(a))) /* ************* general ************************ */ @@ -134,12 +134,12 @@ * also note that the id _must_ have a library - campbell */ void BKE_id_lib_local_paths(Main *bmain, Library *lib, ID *id) { - char *bpath_user_data[2]= {bmain->name, lib->filepath}; + char *bpath_user_data[2] = {bmain->name, lib->filepath}; BLI_bpath_traverse_id(bmain, id, - BLI_bpath_relocate_visitor, - BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, - bpath_user_data); + BLI_bpath_relocate_visitor, + BLI_BPATH_TRAVERSE_SKIP_MULTIFILE, + bpath_user_data); } void id_lib_extern(ID *id) @@ -167,7 +167,7 @@ void id_us_min(ID *id) { if (id) { if (id->us < 2 && (id->flag & LIB_FAKEUSER)) { - id->us= 1; + id->us = 1; } else if (id->us <= 0) { printf("ID user decrement error: %s\n", id->name); @@ -189,54 +189,54 @@ int id_make_local(ID *id, int test) case ID_LI: return 0; /* can't be linked */ case ID_OB: - if (!test) make_local_object((Object*)id); + if (!test) BKE_object_make_local((Object *)id); return 1; case ID_ME: if (!test) { - make_local_mesh((Mesh*)id); - make_local_key(((Mesh*)id)->key); + BKE_mesh_make_local((Mesh *)id); + BKE_key_make_local(((Mesh *)id)->key); } return 1; case ID_CU: if (!test) { - BKE_curve_make_local((Curve*)id); - make_local_key(((Curve*)id)->key); + BKE_curve_make_local((Curve *)id); + BKE_key_make_local(((Curve *)id)->key); } return 1; case ID_MB: - if (!test) BKE_metaball_make_local((MetaBall*)id); + if (!test) BKE_mball_make_local((MetaBall *)id); return 1; case ID_MA: - if (!test) make_local_material((Material*)id); + if (!test) BKE_material_make_local((Material *)id); return 1; case ID_TE: - if (!test) make_local_texture((Tex*)id); + if (!test) BKE_texture_make_local((Tex *)id); return 1; case ID_IM: - if (!test) make_local_image((Image*)id); + if (!test) BKE_image_make_local((Image *)id); return 1; case ID_LT: if (!test) { - make_local_lattice((Lattice*)id); - make_local_key(((Lattice*)id)->key); + BKE_lattice_make_local((Lattice *)id); + BKE_key_make_local(((Lattice *)id)->key); } return 1; case ID_LA: - if (!test) make_local_lamp((Lamp*)id); + if (!test) BKE_lamp_make_local((Lamp *)id); return 1; case ID_CA: - if (!test) BKE_camera_make_local((Camera*)id); + if (!test) BKE_camera_make_local((Camera *)id); return 1; case ID_SPK: - if (!test) make_local_speaker((Speaker*)id); + if (!test) BKE_speaker_make_local((Speaker *)id); return 1; case ID_IP: return 0; /* deprecated */ case ID_KE: - if (!test) make_local_key((Key*)id); + if (!test) BKE_key_make_local((Key *)id); return 1; case ID_WO: - if (!test) make_local_world((World*)id); + if (!test) BKE_world_make_local((World *)id); return 1; case ID_SCR: return 0; /* can't be linked */ @@ -251,18 +251,18 @@ int id_make_local(ID *id, int test) case ID_GR: return 0; /* not implemented */ case ID_AR: - if (!test) make_local_armature((bArmature*)id); + if (!test) BKE_armature_make_local((bArmature *)id); return 1; case ID_AC: - if (!test) make_local_action((bAction*)id); + if (!test) BKE_action_make_local((bAction *)id); return 1; case ID_NT: return 0; /* not implemented */ case ID_BR: - if (!test) BKE_brush_make_local((Brush*)id); + if (!test) BKE_brush_make_local((Brush *)id); return 1; case ID_PA: - if (!test) make_local_particlesettings((ParticleSettings*)id); + if (!test) BKE_particlesettings_make_local((ParticleSettings *)id); return 1; case ID_WM: return 0; /* can't be linked */ @@ -277,7 +277,7 @@ int id_make_local(ID *id, int test) int id_copy(ID *id, ID **newid, int test) { - if (!test) *newid= NULL; + if (!test) *newid = NULL; /* conventions: * - make shallow copy, only this ID block @@ -288,74 +288,74 @@ int id_copy(ID *id, ID **newid, int test) case ID_LI: return 0; /* can't be copied from here */ case ID_OB: - if (!test) *newid= (ID*)copy_object((Object*)id); + if (!test) *newid = (ID *)BKE_object_copy((Object *)id); return 1; case ID_ME: - if (!test) *newid= (ID*)copy_mesh((Mesh*)id); + if (!test) *newid = (ID *)BKE_mesh_copy((Mesh *)id); return 1; case ID_CU: - if (!test) *newid= (ID*)BKE_curve_copy((Curve*)id); + if (!test) *newid = (ID *)BKE_curve_copy((Curve *)id); return 1; case ID_MB: - if (!test) *newid= (ID*)BKE_metaball_copy((MetaBall*)id); + if (!test) *newid = (ID *)BKE_mball_copy((MetaBall *)id); return 1; case ID_MA: - if (!test) *newid= (ID*)copy_material((Material*)id); + if (!test) *newid = (ID *)BKE_material_copy((Material *)id); return 1; case ID_TE: - if (!test) *newid= (ID*)copy_texture((Tex*)id); + if (!test) *newid = (ID *)BKE_texture_copy((Tex *)id); return 1; case ID_IM: - if (!test) *newid= (ID*)copy_image((Image*)id); + if (!test) *newid = (ID *)BKE_image_copy((Image *)id); return 1; case ID_LT: - if (!test) *newid= (ID*)copy_lattice((Lattice*)id); + if (!test) *newid = (ID *)BKE_lattice_copy((Lattice *)id); return 1; case ID_LA: - if (!test) *newid= (ID*)copy_lamp((Lamp*)id); + if (!test) *newid = (ID *)BKE_lamp_copy((Lamp *)id); return 1; case ID_SPK: - if (!test) *newid= (ID*)copy_speaker((Speaker*)id); + if (!test) *newid = (ID *)BKE_speaker_copy((Speaker *)id); return 1; case ID_CA: - if (!test) *newid= (ID*)BKE_camera_copy((Camera*)id); + if (!test) *newid = (ID *)BKE_camera_copy((Camera *)id); return 1; case ID_IP: return 0; /* deprecated */ case ID_KE: - if (!test) *newid= (ID*)copy_key((Key*)id); + if (!test) *newid = (ID *)BKE_key_copy((Key *)id); return 1; case ID_WO: - if (!test) *newid= (ID*)copy_world((World*)id); + if (!test) *newid = (ID *)BKE_world_copy((World *)id); return 1; case ID_SCR: return 0; /* can't be copied from here */ case ID_VF: return 0; /* not implemented */ case ID_TXT: - if (!test) *newid= (ID*)copy_text((Text*)id); + if (!test) *newid = (ID *)BKE_text_copy((Text *)id); return 1; case ID_SCRIPT: return 0; /* deprecated */ case ID_SO: return 0; /* not implemented */ case ID_GR: - if (!test) *newid= (ID*)copy_group((Group*)id); + if (!test) *newid = (ID *)BKE_group_copy((Group *)id); return 1; case ID_AR: - if (!test) *newid= (ID*)copy_armature((bArmature*)id); + if (!test) *newid = (ID *)BKE_armature_copy((bArmature *)id); return 1; case ID_AC: - if (!test) *newid= (ID*)copy_action((bAction*)id); + if (!test) *newid = (ID *)BKE_action_copy((bAction *)id); return 1; case ID_NT: - if (!test) *newid= (ID*)ntreeCopyTree((bNodeTree*)id); + if (!test) *newid = (ID *)ntreeCopyTree((bNodeTree *)id); return 1; case ID_BR: - if (!test) *newid= (ID*)BKE_brush_copy((Brush*)id); + if (!test) *newid = (ID *)BKE_brush_copy((Brush *)id); return 1; case ID_PA: - if (!test) *newid= (ID*)psys_copy_settings((ParticleSettings*)id); + if (!test) *newid = (ID *)BKE_particlesettings_copy((ParticleSettings *)id); return 1; case ID_WM: return 0; /* can't be copied from here */ @@ -371,29 +371,29 @@ int id_copy(ID *id, ID **newid, int test) int id_unlink(ID *id, int test) { - Main *mainlib= G.main; + Main *mainlib = G.main; ListBase *lb; switch (GS(id->name)) { case ID_TXT: if (test) return 1; - unlink_text(mainlib, (Text*)id); + BKE_text_unlink(mainlib, (Text *)id); break; case ID_GR: if (test) return 1; - unlink_group((Group*)id); + BKE_group_unlink((Group *)id); break; case ID_OB: if (test) return 1; - unlink_object((Object*)id); + BKE_object_unlink((Object *)id); break; } if (id->us == 0) { if (test) return 1; - lb= which_libbase(mainlib, GS(id->name)); - free_libblock(lb, id); + lb = which_libbase(mainlib, GS(id->name)); + BKE_libblock_free(lb, id); return 1; } @@ -431,7 +431,7 @@ int id_single_user(bContext *C, ID *id, PointerRNA *ptr, PropertyRNA *prop) ListBase *which_libbase(Main *mainlib, short type) { - switch ( type ) { + switch (type) { case ID_SCE: return &(mainlib->scene); case ID_LI: @@ -503,11 +503,11 @@ void flag_listbase_ids(ListBase *lb, short flag, short value) { ID *id; if (value) { - for (id= lb->first; id; id= id->next) id->flag |= flag; + for (id = lb->first; id; id = id->next) id->flag |= flag; } else { flag = ~flag; - for (id= lb->first; id; id= id->next) id->flag &= flag; + for (id = lb->first; id; id = id->next) id->flag &= flag; } } @@ -516,8 +516,8 @@ void flag_all_listbases_ids(short flag, short value) { ListBase *lbarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(G.main, lbarray); - while (a--) flag_listbase_ids(lbarray[a], flag, value); + a = set_listbasepointers(G.main, lbarray); + while (a--) flag_listbase_ids(lbarray[a], flag, value); } void recalc_all_library_objects(Main *main) @@ -525,9 +525,9 @@ void recalc_all_library_objects(Main *main) Object *ob; /* flag for full recalc */ - for (ob=main->object.first; ob; ob=ob->id.next) + for (ob = main->object.first; ob; ob = ob->id.next) if (ob->id.lib) - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } /* note: MAX_LIBARRAY define should match this code */ @@ -538,132 +538,132 @@ int set_listbasepointers(Main *main, ListBase **lb) /* BACKWARDS! also watch order of free-ing! (mesh<->mat), first items freed last. * This is important because freeing data decreases usercounts of other datablocks, * if this data is its self freed it can crash. */ - lb[a++]= &(main->ipo); - lb[a++]= &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith) - lb[a++]= &(main->key); - lb[a++]= &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */ - lb[a++]= &(main->nodetree); - lb[a++]= &(main->image); - lb[a++]= &(main->tex); - lb[a++]= &(main->mat); - lb[a++]= &(main->vfont); + lb[a++] = &(main->ipo); + lb[a++] = &(main->action); // xxx moved here to avoid problems when freeing with animato (aligorith) + lb[a++] = &(main->key); + lb[a++] = &(main->gpencil); /* referenced by nodes, objects, view, scene etc, before to free after. */ + lb[a++] = &(main->nodetree); + lb[a++] = &(main->image); + lb[a++] = &(main->tex); + lb[a++] = &(main->mat); + lb[a++] = &(main->vfont); /* Important!: When adding a new object type, * the specific data should be inserted here */ - lb[a++]= &(main->armature); + lb[a++] = &(main->armature); - lb[a++]= &(main->mesh); - lb[a++]= &(main->curve); - lb[a++]= &(main->mball); + lb[a++] = &(main->mesh); + lb[a++] = &(main->curve); + lb[a++] = &(main->mball); - lb[a++]= &(main->latt); - lb[a++]= &(main->lamp); - lb[a++]= &(main->camera); + lb[a++] = &(main->latt); + lb[a++] = &(main->lamp); + lb[a++] = &(main->camera); - lb[a++]= &(main->text); - lb[a++]= &(main->sound); - lb[a++]= &(main->group); - lb[a++]= &(main->brush); - lb[a++]= &(main->script); - lb[a++]= &(main->particle); - lb[a++]= &(main->speaker); + lb[a++] = &(main->text); + lb[a++] = &(main->sound); + lb[a++] = &(main->group); + lb[a++] = &(main->brush); + lb[a++] = &(main->script); + lb[a++] = &(main->particle); + lb[a++] = &(main->speaker); - lb[a++]= &(main->world); - lb[a++]= &(main->screen); - lb[a++]= &(main->object); - lb[a++]= &(main->scene); - lb[a++]= &(main->library); - lb[a++]= &(main->wm); - lb[a++]= &(main->movieclip); + lb[a++] = &(main->world); + lb[a++] = &(main->screen); + lb[a++] = &(main->object); + lb[a++] = &(main->scene); + lb[a++] = &(main->library); + lb[a++] = &(main->wm); + lb[a++] = &(main->movieclip); lb[a++]= &(main->linestyle); - lb[a]= NULL; + lb[a] = NULL; return a; } /* *********** ALLOC AND FREE ***************** * - * free_libblock(ListBase *lb, ID *id ) + * BKE_libblock_free(ListBase *lb, ID *id ) * provide a list-basis and datablock, but only ID is read * - * void *alloc_libblock(ListBase *lb, type, name) + * void *BKE_libblock_alloc(ListBase *lb, type, name) * inserts in list and returns a new ID * * **************************** */ static ID *alloc_libblock_notest(short type) { - ID *id= NULL; + ID *id = NULL; - switch ( type ) { + switch (type) { case ID_SCE: - id= MEM_callocN(sizeof(Scene), "scene"); + id = MEM_callocN(sizeof(Scene), "scene"); break; case ID_LI: - id= MEM_callocN(sizeof(Library), "library"); + id = MEM_callocN(sizeof(Library), "library"); break; case ID_OB: - id= MEM_callocN(sizeof(Object), "object"); + id = MEM_callocN(sizeof(Object), "object"); break; case ID_ME: - id= MEM_callocN(sizeof(Mesh), "mesh"); + id = MEM_callocN(sizeof(Mesh), "mesh"); break; case ID_CU: - id= MEM_callocN(sizeof(Curve), "curve"); + id = MEM_callocN(sizeof(Curve), "curve"); break; case ID_MB: - id= MEM_callocN(sizeof(MetaBall), "mball"); + id = MEM_callocN(sizeof(MetaBall), "mball"); break; case ID_MA: - id= MEM_callocN(sizeof(Material), "mat"); + id = MEM_callocN(sizeof(Material), "mat"); break; case ID_TE: - id= MEM_callocN(sizeof(Tex), "tex"); + id = MEM_callocN(sizeof(Tex), "tex"); break; case ID_IM: - id= MEM_callocN(sizeof(Image), "image"); + id = MEM_callocN(sizeof(Image), "image"); break; case ID_LT: - id= MEM_callocN(sizeof(Lattice), "latt"); + id = MEM_callocN(sizeof(Lattice), "latt"); break; case ID_LA: - id= MEM_callocN(sizeof(Lamp), "lamp"); + id = MEM_callocN(sizeof(Lamp), "lamp"); break; case ID_CA: - id= MEM_callocN(sizeof(Camera), "camera"); + id = MEM_callocN(sizeof(Camera), "camera"); break; case ID_IP: - id= MEM_callocN(sizeof(Ipo), "ipo"); + id = MEM_callocN(sizeof(Ipo), "ipo"); break; case ID_KE: - id= MEM_callocN(sizeof(Key), "key"); + id = MEM_callocN(sizeof(Key), "key"); break; case ID_WO: - id= MEM_callocN(sizeof(World), "world"); + id = MEM_callocN(sizeof(World), "world"); break; case ID_SCR: - id= MEM_callocN(sizeof(bScreen), "screen"); + id = MEM_callocN(sizeof(bScreen), "screen"); break; case ID_VF: - id= MEM_callocN(sizeof(VFont), "vfont"); + id = MEM_callocN(sizeof(VFont), "vfont"); break; case ID_TXT: - id= MEM_callocN(sizeof(Text), "text"); + id = MEM_callocN(sizeof(Text), "text"); break; case ID_SCRIPT: //XXX id= MEM_callocN(sizeof(Script), "script"); break; case ID_SPK: - id= MEM_callocN(sizeof(Speaker), "speaker"); + id = MEM_callocN(sizeof(Speaker), "speaker"); break; case ID_SO: - id= MEM_callocN(sizeof(bSound), "sound"); + id = MEM_callocN(sizeof(bSound), "sound"); break; case ID_GR: - id= MEM_callocN(sizeof(Group), "group"); + id = MEM_callocN(sizeof(Group), "group"); break; case ID_AR: id = MEM_callocN(sizeof(bArmature), "armature"); @@ -697,16 +697,16 @@ static ID *alloc_libblock_notest(short type) } /* used everywhere in blenkernel and text.c */ -void *alloc_libblock(ListBase *lb, short type, const char *name) +void *BKE_libblock_alloc(ListBase *lb, short type, const char *name) { - ID *id= NULL; + ID *id = NULL; - id= alloc_libblock_notest(type); + id = alloc_libblock_notest(type); if (id) { BLI_addtail(lb, id); - id->us= 1; + id->us = 1; id->icon_id = 0; - *( (short *)id->name )= type; + *( (short *)id->name) = type; new_id(lb, id, name); /* alphabetic insterion: is in new_id */ } @@ -717,16 +717,16 @@ void *alloc_libblock(ListBase *lb, short type, const char *name) /* and, trust that BKE_animdata_from_id() will only find AnimData for valid ID-types */ static void id_copy_animdata(ID *id, const short do_action) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); if (adt) { IdAdtTemplate *iat = (IdAdtTemplate *)id; - iat->adt= BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ + iat->adt = BKE_copy_animdata(iat->adt, do_action); /* could be set to FALSE, need to investigate */ } } /* material nodes use this since they are not treated as libdata */ -void copy_libblock_data(ID *id, const ID *id_from, const short do_action) +void BKE_libblock_copy_data(ID *id, const ID *id_from, const short do_action) { if (id_from->properties) id->properties = IDP_CopyProperty(id_from->properties); @@ -736,43 +736,43 @@ void copy_libblock_data(ID *id, const ID *id_from, const short do_action) } /* used everywhere in blenkernel */ -void *copy_libblock(ID *id) +void *BKE_libblock_copy(ID *id) { ID *idn; ListBase *lb; size_t idn_len; - lb= which_libbase(G.main, GS(id->name)); - idn= alloc_libblock(lb, GS(id->name), id->name+2); + lb = which_libbase(G.main, GS(id->name)); + idn = BKE_libblock_alloc(lb, GS(id->name), id->name + 2); assert(idn != NULL); - idn_len= MEM_allocN_len(idn); + idn_len = MEM_allocN_len(idn); if ((int)idn_len - (int)sizeof(ID) > 0) { /* signed to allow neg result */ - const char *cp= (const char *)id; - char *cpn= (char *)idn; + const char *cp = (const char *)id; + char *cpn = (char *)idn; - memcpy(cpn+sizeof(ID), cp+sizeof(ID), idn_len - sizeof(ID)); + memcpy(cpn + sizeof(ID), cp + sizeof(ID), idn_len - sizeof(ID)); } - id->newid= idn; + id->newid = idn; idn->flag |= LIB_NEW; - copy_libblock_data(idn, id, FALSE); + BKE_libblock_copy_data(idn, id, FALSE); return idn; } -static void free_library(Library *UNUSED(lib)) +static void BKE_library_free(Library *UNUSED(lib)) { /* no freeing needed for libraries yet */ } -static void (*free_windowmanager_cb)(bContext *, wmWindowManager *)= NULL; +static void (*free_windowmanager_cb)(bContext *, wmWindowManager *) = NULL; void set_free_windowmanager_cb(void (*func)(bContext *C, wmWindowManager *) ) { - free_windowmanager_cb= func; + free_windowmanager_cb = func; } static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata) @@ -781,16 +781,16 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata FCurve *fcu; /* find the driver this belongs to and update it */ - for (fcu=adt->drivers.first; fcu; fcu=fcu->next) { - driver= fcu->driver; + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { + driver = fcu->driver; if (driver) { DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { DRIVER_TARGETS_USED_LOOPER(dvar) { if (dtar->id == userdata) - dtar->id= NULL; + dtar->id = NULL; } DRIVER_TARGETS_LOOPER_END } @@ -800,86 +800,86 @@ static void animdata_dtar_clear_cb(ID *UNUSED(id), AnimData *adt, void *userdata /* used in headerbuttons.c image.c mesh.c screen.c sound.c and library.c */ -void free_libblock(ListBase *lb, void *idv) +void BKE_libblock_free(ListBase *lb, void *idv) { - ID *id= idv; + ID *id = idv; #ifdef WITH_PYTHON BPY_id_release(id); #endif - switch ( GS(id->name) ) { /* GetShort from util.h */ + switch (GS(id->name) ) { /* GetShort from util.h */ case ID_SCE: - free_scene((Scene *)id); + BKE_scene_free((Scene *)id); break; case ID_LI: - free_library((Library *)id); + BKE_library_free((Library *)id); break; case ID_OB: - free_object((Object *)id); + BKE_object_free((Object *)id); break; case ID_ME: - free_mesh((Mesh *)id, 1); + BKE_mesh_free((Mesh *)id, 1); break; case ID_CU: BKE_curve_free((Curve *)id); break; case ID_MB: - BKE_metaball_free((MetaBall *)id); + BKE_mball_free((MetaBall *)id); break; case ID_MA: - free_material((Material *)id); + BKE_material_free((Material *)id); break; case ID_TE: - free_texture((Tex *)id); + BKE_texture_free((Tex *)id); break; case ID_IM: - free_image((Image *)id); + BKE_image_free((Image *)id); break; case ID_LT: - free_lattice((Lattice *)id); + BKE_lattice_free((Lattice *)id); break; case ID_LA: - free_lamp((Lamp *)id); + BKE_lamp_free((Lamp *)id); break; case ID_CA: - BKE_camera_free((Camera*) id); + BKE_camera_free((Camera *) id); break; case ID_IP: - free_ipo((Ipo *)id); + BKE_ipo_free((Ipo *)id); break; case ID_KE: - free_key((Key *)id); + BKE_key_free((Key *)id); break; case ID_WO: - free_world((World *)id); + BKE_world_free((World *)id); break; case ID_SCR: - free_screen((bScreen *)id); + BKE_screen_free((bScreen *)id); break; case ID_VF: - free_vfont((VFont *)id); + BKE_vfont_free((VFont *)id); break; case ID_TXT: - free_text((Text *)id); + BKE_text_free((Text *)id); break; case ID_SCRIPT: //XXX free_script((Script *)id); break; case ID_SPK: - free_speaker((Speaker *)id); + BKE_speaker_free((Speaker *)id); break; case ID_SO: - sound_free((bSound*)id); + BKE_sound_free((bSound *)id); break; case ID_GR: - free_group_objects((Group *)id); + BKE_group_free((Group *)id); break; case ID_AR: - free_armature((bArmature *)id); + BKE_armature_free((bArmature *)id); break; case ID_AC: - free_action((bAction *)id); + BKE_action_free((bAction *)id); break; case ID_NT: ntreeFreeTree((bNodeTree *)id); @@ -888,14 +888,14 @@ void free_libblock(ListBase *lb, void *idv) BKE_brush_free((Brush *)id); break; case ID_PA: - psys_free_settings((ParticleSettings *)id); + BKE_particlesettings_free((ParticleSettings *)id); break; case ID_WM: if (free_windowmanager_cb) free_windowmanager_cb(NULL, (wmWindowManager *)id); break; case ID_GD: - free_gpencil_data((bGPdata *)id); + BKE_gpencil_free((bGPdata *)id); break; case ID_MC: BKE_movieclip_free((MovieClip *)id); @@ -918,20 +918,20 @@ void free_libblock(ListBase *lb, void *idv) MEM_freeN(id); } -void free_libblock_us(ListBase *lb, void *idv) /* test users */ +void BKE_libblock_free_us(ListBase *lb, void *idv) /* test users */ { - ID *id= idv; + ID *id = idv; id->us--; - if (id->us<0) { + if (id->us < 0) { if (id->lib) printf("ERROR block %s %s users %d\n", id->lib->name, id->name, id->us); else printf("ERROR block %s users %d\n", id->name, id->us); } - if (id->us==0) { - if ( GS(id->name)==ID_OB ) unlink_object((Object *)id); + if (id->us == 0) { + if (GS(id->name) == ID_OB) BKE_object_unlink((Object *)id); - free_libblock(lb, id); + BKE_libblock_free(lb, id); } } @@ -942,13 +942,13 @@ void free_main(Main *mainvar) ListBase *lbarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(mainvar, lbarray); + a = set_listbasepointers(mainvar, lbarray); while (a--) { - ListBase *lb= lbarray[a]; + ListBase *lb = lbarray[a]; ID *id; - while ( (id= lb->first) ) { - free_libblock(lb, id); + while ( (id = lb->first) ) { + BKE_libblock_free(lb, id); } } @@ -958,84 +958,85 @@ void free_main(Main *mainvar) /* ***************** ID ************************ */ -ID *find_id(const char *type, const char *name) /* type: "OB" or "MA" etc */ +ID *BKE_libblock_find_name(const short type, const char *name) /* type: "OB" or "MA" etc */ { - ListBase *lb= which_libbase(G.main, GS(type)); + ListBase *lb = which_libbase(G.main, type); + BLI_assert(lb != NULL); return BLI_findstring(lb, name, offsetof(ID, name) + 2); } static void get_flags_for_id(ID *id, char *buf) { - int isfake= id->flag & LIB_FAKEUSER; - int isnode=0; - /* Writeout the flags for the entry, note there - * is a small hack that writes 5 spaces instead - * of 4 if no flags are displayed... this makes - * things usually line up ok - better would be - * to have that explicit, oh well - zr - */ + int isfake = id->flag & LIB_FAKEUSER; + int isnode = 0; + /* Writeout the flags for the entry, note there + * is a small hack that writes 5 spaces instead + * of 4 if no flags are displayed... this makes + * things usually line up ok - better would be + * to have that explicit, oh well - zr + */ - if (GS(id->name)==ID_MA) - isnode= ((Material *)id)->use_nodes; - if (GS(id->name)==ID_TE) - isnode= ((Tex *)id)->use_nodes; + if (GS(id->name) == ID_MA) + isnode = ((Material *)id)->use_nodes; + if (GS(id->name) == ID_TE) + isnode = ((Tex *)id)->use_nodes; - if (id->us<0) + if (id->us < 0) strcpy(buf, "-1W "); else if (!id->lib && !isfake && id->us && !isnode) strcpy(buf, " "); else if (isnode) - sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); + sprintf(buf, "%c%cN%c ", id->lib ? 'L' : ' ', isfake ? 'F' : ' ', (id->us == 0) ? 'O' : ' '); else - sprintf(buf, "%c%c%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); + sprintf(buf, "%c%c%c ", id->lib ? 'L' : ' ', isfake ? 'F' : ' ', (id->us == 0) ? 'O' : ' '); } #define IDPUP_NO_VIEWER 1 static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, short *nr, int hideflag) { - int i, nids= BLI_countlist(lb); + int i, nids = BLI_countlist(lb); - if (nr) *nr= -1; + if (nr) *nr = -1; - if (nr && nids>MAX_IDPUP) { + if (nr && nids > MAX_IDPUP) { BLI_dynstr_append(pupds, "DataBrowse %x-2"); - *nr= -2; + *nr = -2; } else { ID *id; - for (i=0, id= lb->first; id; id= id->next, i++) { + for (i = 0, id = lb->first; id; id = id->next, i++) { char numstr[32]; - if (nr && id==link) *nr= i+1; + if (nr && id == link) *nr = i + 1; - if (U.uiflag & USER_HIDE_DOT && id->name[2]=='.') + if (U.uiflag & USER_HIDE_DOT && id->name[2] == '.') continue; if (hideflag & IDPUP_NO_VIEWER) - if (GS(id->name)==ID_IM) - if ( ((Image *)id)->source==IMA_SRC_VIEWER ) + if (GS(id->name) == ID_IM) + if ( ((Image *)id)->source == IMA_SRC_VIEWER) continue; get_flags_for_id(id, numstr); BLI_dynstr_append(pupds, numstr); - BLI_dynstr_append(pupds, id->name+2); - BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i+1); + BLI_dynstr_append(pupds, id->name + 2); + BLI_snprintf(numstr, sizeof(numstr), "%%x%d", i + 1); BLI_dynstr_append(pupds, numstr); /* icon */ switch (GS(id->name)) { - case ID_MA: /* fall through */ - case ID_TE: /* fall through */ - case ID_IM: /* fall through */ - case ID_WO: /* fall through */ - case ID_LA: /* fall through */ - BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id)); - BLI_dynstr_append(pupds, numstr); - break; - default: - break; + case ID_MA: /* fall through */ + case ID_TE: /* fall through */ + case ID_IM: /* fall through */ + case ID_WO: /* fall through */ + case ID_LA: /* fall through */ + BLI_snprintf(numstr, sizeof(numstr), "%%i%d", BKE_icon_getid(id)); + BLI_dynstr_append(pupds, numstr); + break; + default: + break; } if (id->next) @@ -1049,7 +1050,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor /* if nr==NULL no MAX_IDPUP, this for non-header browsing */ void IDnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { - DynStr *pupds= BLI_dynstr_new(); + DynStr *pupds = BLI_dynstr_new(); if (title) { BLI_dynstr_append(pupds, title); @@ -1064,7 +1065,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra IDnames_to_dyn_pupstring(pupds, lb, link, nr, 0); - *str= BLI_dynstr_get_cstring(pupds); + *str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); } @@ -1072,7 +1073,7 @@ void IDnames_to_pupstring(const char **str, const char *title, const char *extra #if 0 /* unused */ void IMAnames_to_pupstring(const char **str, const char *title, const char *extraops, ListBase *lb, ID *link, short *nr) { - DynStr *pupds= BLI_dynstr_new(); + DynStr *pupds = BLI_dynstr_new(); if (title) { BLI_dynstr_append(pupds, title); @@ -1087,7 +1088,7 @@ void IMAnames_to_pupstring(const char **str, const char *title, const char *extr IDnames_to_dyn_pupstring(pupds, lb, link, nr, IDPUP_NO_VIEWER); - *str= BLI_dynstr_get_cstring(pupds); + *str = BLI_dynstr_get_cstring(pupds); BLI_dynstr_free(pupds); } #endif @@ -1097,19 +1098,19 @@ void id_sort_by_name(ListBase *lb, ID *id) ID *idtest; /* insert alphabetically */ - if (lb->first!=lb->last) { + if (lb->first != lb->last) { BLI_remlink(lb, id); - idtest= lb->first; + idtest = lb->first; while (idtest) { - if (BLI_strcasecmp(idtest->name, id->name)>0 || (idtest->lib && !id->lib)) { + if (BLI_strcasecmp(idtest->name, id->name) > 0 || (idtest->lib && !id->lib)) { BLI_insertlinkbefore(lb, idtest, id); break; } - idtest= idtest->next; + idtest = idtest->next; } /* as last */ - if (idtest==NULL) { + if (idtest == NULL) { BLI_addtail(lb, id); } } @@ -1122,15 +1123,15 @@ void id_sort_by_name(ListBase *lb, ID *id) */ static ID *is_dupid(ListBase *lb, ID *id, const char *name) { - ID *idtest=NULL; + ID *idtest = NULL; - for ( idtest = lb->first; idtest; idtest = idtest->next ) { + for (idtest = lb->first; idtest; idtest = idtest->next) { /* if idtest is not a lib */ - if ( id != idtest && idtest->lib == NULL ) { + if (id != idtest && idtest->lib == NULL) { /* do not test alphabetic! */ /* optimized */ - if ( idtest->name[2] == name[0] ) { - if (strcmp(name, idtest->name+2)==0) break; + if (idtest->name[2] == name[0]) { + if (strcmp(name, idtest->name + 2) == 0) break; } } } @@ -1151,7 +1152,7 @@ static ID *is_dupid(ListBase *lb, ID *id, const char *name) static int check_for_dupid(ListBase *lb, ID *id, char *name) { ID *idtest; - int nr= 0, nrtest, a, left_len; + int nr = 0, nrtest, a, left_len; char in_use[64]; /* use as a boolean array, unrelated to name length */ char left[MAX_ID_NAME + 8], leftest[MAX_ID_NAME + 8]; @@ -1166,43 +1167,44 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) idtest = is_dupid(lb, id, name); /* if there is no double, done */ - if ( idtest == NULL ) return 0; + if (idtest == NULL) return 0; /* we have a dup; need to make a new name */ /* quick check so we can reuse one of first 64 ids if vacant */ memset(in_use, 0, sizeof(in_use)); /* get name portion, number portion ("name.number") */ - left_len= BLI_split_name_num(left, &nr, name, '.'); + left_len = BLI_split_name_num(left, &nr, name, '.'); /* if new name will be too long, truncate it */ if (nr > 999 && left_len > (MAX_ID_NAME - 8)) { - left[MAX_ID_NAME - 8]= 0; - left_len= MAX_ID_NAME - 8; + left[MAX_ID_NAME - 8] = 0; + left_len = MAX_ID_NAME - 8; } else if (left_len > (MAX_ID_NAME - 7)) { - left[MAX_ID_NAME - 7]= 0; - left_len= MAX_ID_NAME - 7; + left[MAX_ID_NAME - 7] = 0; + left_len = MAX_ID_NAME - 7; } - for (idtest= lb->first; idtest; idtest= idtest->next) { - if ( (id != idtest) && - (idtest->lib == NULL) && - (*name == *(idtest->name+2)) && - (strncmp(name, idtest->name+2, left_len)==0) && - (BLI_split_name_num(leftest, &nrtest, idtest->name+2, '.') == left_len) - ) { + for (idtest = lb->first; idtest; idtest = idtest->next) { + if ( (id != idtest) && + (idtest->lib == NULL) && + (*name == *(idtest->name + 2)) && + (strncmp(name, idtest->name + 2, left_len) == 0) && + (BLI_split_name_num(leftest, &nrtest, idtest->name + 2, '.') == left_len) + ) + { if (nrtest < sizeof(in_use)) - in_use[nrtest]= 1; /* mark as used */ + in_use[nrtest] = 1; /* mark as used */ if (nr <= nrtest) - nr= nrtest+1; /* track largest unused */ + nr = nrtest + 1; /* track largest unused */ } } /* decide which value of nr to use */ - for (a=0; a < sizeof(in_use); a++) { - if (a>=nr) break; /* stop when we've check up to biggest */ - if ( in_use[a]==0 ) { /* found an unused value */ + for (a = 0; a < sizeof(in_use); a++) { + if (a >= nr) break; /* stop when we've check up to biggest */ + if (in_use[a] == 0) { /* found an unused value */ nr = a; break; } @@ -1212,13 +1214,13 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) * rather than just chopping and adding numbers, * shave off the end chars until we have a unique name. * Check the null terminators match as well so we don't get Cube.000 -> Cube.00 */ - if (nr==0 && name[left_len]== '\0') { - int len = left_len-1; - idtest= is_dupid(lb, id, name); + if (nr == 0 && name[left_len] == '\0') { + int len = left_len - 1; + idtest = is_dupid(lb, id, name); - while (idtest && len> 1) { + while (idtest && len > 1) { name[len--] = '\0'; - idtest= is_dupid(lb, id, name); + idtest = is_dupid(lb, id, name); } if (idtest == NULL) return 1; /* otherwise just continue and use a number suffix */ @@ -1248,24 +1250,24 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name) int new_id(ListBase *lb, ID *id, const char *tname) { int result; - char name[MAX_ID_NAME-2]; + char name[MAX_ID_NAME - 2]; /* if library, don't rename */ if (id->lib) return 0; /* if no libdata given, look up based on ID */ - if (lb==NULL) lb= which_libbase(G.main, GS(id->name)); + if (lb == NULL) lb = which_libbase(G.main, GS(id->name)); /* if no name given, use name of current ID * else make a copy (tname args can be const) */ - if (tname==NULL) - tname= id->name+2; + if (tname == NULL) + tname = id->name + 2; - strncpy(name, tname, sizeof(name)-1); + strncpy(name, tname, sizeof(name) - 1); /* if result > MAX_ID_NAME-3, strncpy don't put the final '\0' to name. * easier to assign each time then to check if its needed */ - name[sizeof(name)-1]= 0; + name[sizeof(name) - 1] = 0; if (name[0] == '\0') { /* disallow empty names */ @@ -1278,14 +1280,14 @@ int new_id(ListBase *lb, ID *id, const char *tname) } result = check_for_dupid(lb, id, name); - strcpy(id->name+2, name); + strcpy(id->name + 2, name); /* This was in 2.43 and previous releases * however all data in blender should be sorted, not just duplicate names * sorting should not hurt, but noting just incause it alters the way other * functions work, so sort every time */ #if 0 - if ( result ) + if (result) id_sort_by_name(lb, id); #endif @@ -1300,8 +1302,8 @@ void id_clear_lib_data(Main *bmain, ID *id) { BKE_id_lib_local_paths(bmain, id->lib, id); - id->lib= NULL; - id->flag= LIB_LOCAL; + id->lib = NULL; + id->flag = LIB_LOCAL; new_id(which_libbase(bmain, GS(id->name)), id, NULL); } @@ -1312,18 +1314,18 @@ void clear_id_newpoins(void) ID *id; int a; - a= set_listbasepointers(G.main, lbarray); + a = set_listbasepointers(G.main, lbarray); while (a--) { - id= lbarray[a]->first; + id = lbarray[a]->first; while (id) { - id->newid= NULL; + id->newid = NULL; id->flag &= ~LIB_NEW; - id= id->next; + id = id->next; } } } -#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &=~LIB_INDIRECT; a->id.flag |= LIB_EXTERN;} +#define LIBTAG(a) if (a && a->id.lib) {a->id.flag &= ~LIB_INDIRECT; a->id.flag |= LIB_EXTERN; } static void lib_indirect_test_id(ID *id, Library *lib) { @@ -1337,17 +1339,17 @@ static void lib_indirect_test_id(ID *id, Library *lib) return; } - if (GS(id->name)==ID_OB) { - Object *ob= (Object *)id; + if (GS(id->name) == ID_OB) { + Object *ob = (Object *)id; Mesh *me; int a; -#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ +#if 0 /* XXX OLD ANIMSYS, NLASTRIPS ARE NO LONGER USED */ // XXX old animation system! -------------------------------------- { bActionStrip *strip; - for (strip=ob->nlastrips.first; strip; strip=strip->next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { LIBTAG(strip->object); LIBTAG(strip->act); LIBTAG(strip->ipo); @@ -1356,14 +1358,14 @@ static void lib_indirect_test_id(ID *id, Library *lib) // XXX: new animation system needs something like this? #endif - for (a=0; atotcol; a++) { + for (a = 0; a < ob->totcol; a++) { LIBTAG(ob->mat[a]); } LIBTAG(ob->dup_group); LIBTAG(ob->proxy); - me= ob->data; + me = ob->data; LIBTAG(me); } } @@ -1372,12 +1374,12 @@ void tag_main_lb(ListBase *lb, const short tag) { ID *id; if (tag) { - for (id= lb->first; id; id= id->next) { + for (id = lb->first; id; id = id->next) { id->flag |= LIB_DOIT; } } else { - for (id= lb->first; id; id= id->next) { + for (id = lb->first; id; id = id->next) { id->flag &= ~LIB_DOIT; } } @@ -1385,7 +1387,7 @@ void tag_main_lb(ListBase *lb, const short tag) void tag_main_idcode(struct Main *mainvar, const short type, const short tag) { - ListBase *lb= which_libbase(mainvar, type); + ListBase *lb = which_libbase(mainvar, type); tag_main_lb(lb, tag); } @@ -1395,7 +1397,7 @@ void tag_main(struct Main *mainvar, const short tag) ListBase *lbarray[MAX_LIBARRAY]; int a; - a= set_listbasepointers(mainvar, lbarray); + a = set_listbasepointers(mainvar, lbarray); while (a--) { tag_main_lb(lbarray[a], tag); } @@ -1405,27 +1407,27 @@ void tag_main(struct Main *mainvar, const short tag) * bmain is almost certainly G.main */ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) { - ListBase *lbarray[MAX_LIBARRAY], tempbase={NULL, NULL}; + ListBase *lbarray[MAX_LIBARRAY], tempbase = {NULL, NULL}; ID *id, *idn; int a; - a= set_listbasepointers(bmain, lbarray); + a = set_listbasepointers(bmain, lbarray); while (a--) { - id= lbarray[a]->first; + id = lbarray[a]->first; while (id) { - id->newid= NULL; - idn= id->next; /* id is possibly being inserted again */ + id->newid = NULL; + idn = id->next; /* id is possibly being inserted again */ /* The check on the second line (LIB_PRE_EXISTING) is done so its * possible to tag data you don't want to be made local, used for * appending data, so any libdata already linked wont become local * (very nasty to discover all your links are lost after appending) * */ - if (id->flag & (LIB_EXTERN|LIB_INDIRECT|LIB_NEW) && - (untagged_only==0 || !(id->flag & LIB_PRE_EXISTING))) + if (id->flag & (LIB_EXTERN | LIB_INDIRECT | LIB_NEW) && + (untagged_only == 0 || !(id->flag & LIB_PRE_EXISTING))) { - if (lib==NULL || id->lib==lib) { + if (lib == NULL || id->lib == lib) { if (id->lib) { id_clear_lib_data(bmain, id); /* sets 'id->flag' */ @@ -1434,15 +1436,15 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) id_sort_by_name(lbarray[a], id); } else { - id->flag &= ~(LIB_EXTERN|LIB_INDIRECT|LIB_NEW); + id->flag &= ~(LIB_EXTERN | LIB_INDIRECT | LIB_NEW); } } } - id= idn; + id = idn; } /* patch2: make it aphabetically */ - while ( (id=tempbase.first) ) { + while ( (id = tempbase.first) ) { BLI_remlink(&tempbase, id); BLI_addtail(lbarray[a], id); new_id(lbarray[a], id, NULL); @@ -1450,9 +1452,9 @@ void BKE_library_make_local(Main *bmain, Library *lib, int untagged_only) } /* patch 3: make sure library data isn't indirect falsely... */ - a= set_listbasepointers(bmain, lbarray); + a = set_listbasepointers(bmain, lbarray); while (a--) { - for (id= lbarray[a]->first; id; id=id->next) + for (id = lbarray[a]->first; id; id = id->next) lib_indirect_test_id(id, lib); } } @@ -1465,34 +1467,34 @@ void test_idbutton(char *name) ID *idtest; - lb= which_libbase(G.main, GS(name-2) ); - if (lb==NULL) return; + lb = which_libbase(G.main, GS(name - 2) ); + if (lb == NULL) return; /* search for id */ - idtest= BLI_findstring(lb, name, offsetof(ID, name) + 2); + idtest = BLI_findstring(lb, name, offsetof(ID, name) + 2); - if (idtest) if ( new_id(lb, idtest, name)==0 ) id_sort_by_name(lb, idtest); + if (idtest) if (new_id(lb, idtest, name) == 0) id_sort_by_name(lb, idtest); } void text_idbutton(struct ID *id, char *text) { if (id) { - if (GS(id->name)==ID_SCE) + if (GS(id->name) == ID_SCE) strcpy(text, "SCE: "); - else if (GS(id->name)==ID_SCR) + else if (GS(id->name) == ID_SCR) strcpy(text, "SCR: "); - else if (GS(id->name)==ID_MA && ((Material*)id)->use_nodes) + else if (GS(id->name) == ID_MA && ((Material *)id)->use_nodes) strcpy(text, "NT: "); else { - text[0]= id->name[0]; - text[1]= id->name[1]; - text[2]= ':'; - text[3]= ' '; - text[4]= 0; + text[0] = id->name[0]; + text[1] = id->name[1]; + text[2] = ':'; + text[3] = ' '; + text[4] = 0; } } else { - text[0]= '\0'; + text[0] = '\0'; } } @@ -1500,19 +1502,19 @@ void rename_id(ID *id, const char *name) { ListBase *lb; - BLI_strncpy(id->name+2, name, sizeof(id->name)-2); - lb= which_libbase(G.main, GS(id->name) ); + BLI_strncpy(id->name + 2, name, sizeof(id->name) - 2); + lb = which_libbase(G.main, GS(id->name) ); new_id(lb, id, name); } void name_uiprefix_id(char *name, ID *id) { - name[0] = id->lib ? 'L':' '; - name[1] = id->flag & LIB_FAKEUSER ? 'F': (id->us==0)?'0':' '; + name[0] = id->lib ? 'L' : ' '; + name[1] = id->flag & LIB_FAKEUSER ? 'F' : (id->us == 0) ? '0' : ' '; name[2] = ' '; - strcpy(name+3, id->name+2); + strcpy(name + 3, id->name + 2); } void BKE_library_filepath_set(Library *lib, const char *filepath) @@ -1533,7 +1535,7 @@ void BKE_library_filepath_set(Library *lib, const char *filepath) * outliner, and its not really supported but allow from here for now * since making local could cause this to be directly linked - campbell */ - const char *basepath= lib->parent ? lib->parent->filepath : G.main->name; + const char *basepath = lib->parent ? lib->parent->filepath : G.main->name; BLI_path_abs(lib->filepath, basepath); } } diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index b2c2cb27e31..0ed1b02d3c9 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -102,7 +102,7 @@ FreestyleLineStyle *FRS_new_linestyle(char *name, struct Main *main) if (!main) main = G.main; - linestyle = (FreestyleLineStyle *)alloc_libblock(&main->linestyle, ID_LS, name); + linestyle = (FreestyleLineStyle *)BKE_libblock_alloc(&main->linestyle, ID_LS, name); default_linestyle_settings(linestyle); diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index c76eb3c2fb3..9e1b45a7479 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -77,13 +77,13 @@ void init_def_material(void) } /* not material itself */ -void free_material(Material *ma) +void BKE_material_free(Material *ma) { MTex *mtex; int a; - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = ma->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -95,7 +95,7 @@ void free_material(Material *ma) if (ma->preview) BKE_previewimg_free(&ma->preview); - BKE_icon_delete((struct ID*)ma); + BKE_icon_delete((struct ID *)ma); ma->id.icon_id = 0; /* is no lib link block, but material extension */ @@ -110,68 +110,68 @@ void free_material(Material *ma) void init_material(Material *ma) { - ma->r= ma->g= ma->b= ma->ref= 0.8; - ma->specr= ma->specg= ma->specb= 1.0; - ma->mirr= ma->mirg= ma->mirb= 1.0; - ma->spectra= 1.0; - ma->amb= 1.0; - ma->alpha= 1.0; - ma->spec= ma->hasize= 0.5; - ma->har= 50; - ma->starc= ma->ringc= 4; - ma->linec= 12; - ma->flarec= 1; - ma->flaresize= ma->subsize= 1.0; - ma->flareboost= 1; - ma->seed2= 6; - ma->friction= 0.5; - ma->refrac= 4.0; - ma->roughness= 0.5; - ma->param[0]= 0.5; - ma->param[1]= 0.1; - ma->param[2]= 0.5; - ma->param[3]= 0.1; - ma->rms= 0.1; - ma->darkness= 1.0; + ma->r = ma->g = ma->b = ma->ref = 0.8; + ma->specr = ma->specg = ma->specb = 1.0; + ma->mirr = ma->mirg = ma->mirb = 1.0; + ma->spectra = 1.0; + ma->amb = 1.0; + ma->alpha = 1.0; + ma->spec = ma->hasize = 0.5; + ma->har = 50; + ma->starc = ma->ringc = 4; + ma->linec = 12; + ma->flarec = 1; + ma->flaresize = ma->subsize = 1.0; + ma->flareboost = 1; + ma->seed2 = 6; + ma->friction = 0.5; + ma->refrac = 4.0; + ma->roughness = 0.5; + ma->param[0] = 0.5; + ma->param[1] = 0.1; + ma->param[2] = 0.5; + ma->param[3] = 0.1; + ma->rms = 0.1; + ma->darkness = 1.0; + + ma->strand_sta = ma->strand_end = 1.0f; + + ma->ang = 1.0; + ma->ray_depth = 2; + ma->ray_depth_tra = 2; + ma->fresnel_mir = 0.0; + ma->fresnel_tra = 0.0; + ma->fresnel_tra_i = 1.25; + ma->fresnel_mir_i = 1.25; + ma->tx_limit = 0.0; + ma->tx_falloff = 1.0; + ma->shad_alpha = 1.0f; + ma->vcol_alpha = 0; - ma->strand_sta= ma->strand_end= 1.0f; - - ma->ang= 1.0; - ma->ray_depth= 2; - ma->ray_depth_tra= 2; - ma->fresnel_mir= 0.0; - ma->fresnel_tra= 0.0; - ma->fresnel_tra_i= 1.25; - ma->fresnel_mir_i= 1.25; - ma->tx_limit= 0.0; - ma->tx_falloff= 1.0; - ma->shad_alpha= 1.0f; - ma->vcol_alpha= 0; - - ma->gloss_mir = ma->gloss_tra= 1.0; - ma->samp_gloss_mir = ma->samp_gloss_tra= 18; + ma->gloss_mir = ma->gloss_tra = 1.0; + ma->samp_gloss_mir = ma->samp_gloss_tra = 18; ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005; ma->dist_mir = 0.0; ma->fadeto_mir = MA_RAYMIR_FADETOSKY; - ma->rampfac_col= 1.0; - ma->rampfac_spec= 1.0; - ma->pr_lamp= 3; /* two lamps, is bits */ - ma->pr_type= MA_SPHERE; + ma->rampfac_col = 1.0; + ma->rampfac_spec = 1.0; + ma->pr_lamp = 3; /* two lamps, is bits */ + ma->pr_type = MA_SPHERE; - ma->sss_radius[0]= 1.0f; - ma->sss_radius[1]= 1.0f; - ma->sss_radius[2]= 1.0f; - ma->sss_col[0]= 1.0f; - ma->sss_col[1]= 1.0f; - ma->sss_col[2]= 1.0f; - ma->sss_error= 0.05f; - ma->sss_scale= 0.1f; - ma->sss_ior= 1.3f; - ma->sss_colfac= 1.0f; - ma->sss_texfac= 0.0f; - ma->sss_front= 1.0f; - ma->sss_back= 1.0f; + ma->sss_radius[0] = 1.0f; + ma->sss_radius[1] = 1.0f; + ma->sss_radius[2] = 1.0f; + ma->sss_col[0] = 1.0f; + ma->sss_col[1] = 1.0f; + ma->sss_col[2] = 1.0f; + ma->sss_error = 0.05f; + ma->sss_scale = 0.1f; + ma->sss_ior = 1.3f; + ma->sss_colfac = 1.0f; + ma->sss_texfac = 0.0f; + ma->sss_front = 1.0f; + ma->sss_back = 1.0f; ma->vol.density = 1.0f; ma->vol.emission = 0.0f; @@ -192,19 +192,19 @@ void init_material(Material *ma) ma->vol.ms_intensity = 1.f; ma->game.flag = GEMAT_BACKCULL; - ma->game.alpha_blend=0; - ma->game.face_orientation=0; + ma->game.alpha_blend = 0; + ma->game.face_orientation = 0; - ma->mode= MA_TRACEBLE|MA_SHADBUF|MA_SHADOW|MA_RAYBIAS|MA_TANGENT_STR|MA_ZTRANSP; - ma->shade_flag= MA_APPROX_OCCLUSION; + ma->mode = MA_TRACEBLE | MA_SHADBUF | MA_SHADOW | MA_RAYBIAS | MA_TANGENT_STR | MA_ZTRANSP; + ma->shade_flag = MA_APPROX_OCCLUSION; ma->preview = NULL; } -Material *add_material(const char *name) +Material *BKE_material_add(const char *name) { Material *ma; - ma= alloc_libblock(&G.main->mat, ID_MA, name); + ma = BKE_libblock_alloc(&G.main->mat, ID_MA, name); init_material(ma); @@ -212,33 +212,33 @@ Material *add_material(const char *name) } /* XXX keep synced with next function */ -Material *copy_material(Material *ma) +Material *BKE_material_copy(Material *ma) { Material *man; int a; - man= copy_libblock(&ma->id); + man = BKE_libblock_copy(&ma->id); id_lib_extern((ID *)man->group); - for (a=0; amtex[a]) { - man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial"); + man->mtex[a] = MEM_mallocN(sizeof(MTex), "copymaterial"); memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex)); id_us_plus((ID *)man->mtex[a]->tex); } } - if (ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); - if (ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); + if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col); + if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec); if (ma->preview) man->preview = BKE_previewimg_copy(ma->preview); if (ma->nodetree) { - man->nodetree= ntreeCopyTree(ma->nodetree); /* 0 == full new tree */ + man->nodetree = ntreeCopyTree(ma->nodetree); /* 0 == full new tree */ } - man->gpumaterial.first= man->gpumaterial.last= NULL; + man->gpumaterial.first = man->gpumaterial.last = NULL; return man; } @@ -249,26 +249,26 @@ Material *localize_material(Material *ma) Material *man; int a; - man= copy_libblock(&ma->id); + man = BKE_libblock_copy(&ma->id); BLI_remlink(&G.main->mat, man); /* no increment for texture ID users, in previewrender.c it prevents decrement */ - for (a=0; amtex[a]) { - man->mtex[a]= MEM_mallocN(sizeof(MTex), "copymaterial"); + man->mtex[a] = MEM_mallocN(sizeof(MTex), "copymaterial"); memcpy(man->mtex[a], ma->mtex[a], sizeof(MTex)); } } - if (ma->ramp_col) man->ramp_col= MEM_dupallocN(ma->ramp_col); - if (ma->ramp_spec) man->ramp_spec= MEM_dupallocN(ma->ramp_spec); + if (ma->ramp_col) man->ramp_col = MEM_dupallocN(ma->ramp_col); + if (ma->ramp_spec) man->ramp_spec = MEM_dupallocN(ma->ramp_spec); man->preview = NULL; if (ma->nodetree) - man->nodetree= ntreeLocalize(ma->nodetree); + man->nodetree = ntreeLocalize(ma->nodetree); - man->gpumaterial.first= man->gpumaterial.last= NULL; + man->gpumaterial.first = man->gpumaterial.last = NULL; return man; } @@ -276,29 +276,29 @@ Material *localize_material(Material *ma) static void extern_local_material(Material *ma) { int i; - for (i=0; i < MAX_MTEX; i++) { + for (i = 0; i < MAX_MTEX; i++) { if (ma->mtex[i]) id_lib_extern((ID *)ma->mtex[i]->tex); } } -void make_local_material(Material *ma) +void BKE_material_make_local(Material *ma) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; Mesh *me; Curve *cu; MetaBall *mb; - int a, is_local= FALSE, is_lib= FALSE; + int a, is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (ma->id.lib==NULL) return; + if (ma->id.lib == NULL) return; /* One local user; set flag and return. */ - if (ma->id.us==1) { + if (ma->id.us == 1) { id_clear_lib_data(bmain, &ma->id); extern_local_material(ma); return; @@ -307,56 +307,56 @@ void make_local_material(Material *ma) /* Check which other IDs reference this one to determine if it's used by * lib or local */ /* test objects */ - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { if (ob->mat) { - for (a=0; atotcol; a++) { - if (ob->mat[a]==ma) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < ob->totcol; a++) { + if (ob->mat[a] == ma) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - ob= ob->id.next; + ob = ob->id.next; } /* test meshes */ - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { if (me->mat) { - for (a=0; atotcol; a++) { - if (me->mat[a]==ma) { - if (me->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < me->totcol; a++) { + if (me->mat[a] == ma) { + if (me->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - me= me->id.next; + me = me->id.next; } /* test curves */ - cu= bmain->curve.first; + cu = bmain->curve.first; while (cu) { if (cu->mat) { - for (a=0; atotcol; a++) { - if (cu->mat[a]==ma) { - if (cu->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < cu->totcol; a++) { + if (cu->mat[a] == ma) { + if (cu->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - cu= cu->id.next; + cu = cu->id.next; } /* test mballs */ - mb= bmain->mball.first; + mb = bmain->mball.first; while (mb) { if (mb->mat) { - for (a=0; atotcol; a++) { - if (mb->mat[a]==ma) { - if (mb->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < mb->totcol; a++) { + if (mb->mat[a] == ma) { + if (mb->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - mb= mb->id.next; + mb = mb->id.next; } /* Only local users. */ @@ -366,76 +366,76 @@ void make_local_material(Material *ma) } /* Both user and local, so copy. */ else if (is_local && is_lib) { - Material *ma_new= copy_material(ma); + Material *ma_new = BKE_material_copy(ma); - ma_new->id.us= 0; + ma_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, ma->id.lib, &ma_new->id); /* do objects */ - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { if (ob->mat) { - for (a=0; atotcol; a++) { - if (ob->mat[a]==ma) { - if (ob->id.lib==NULL) { - ob->mat[a]= ma_new; + for (a = 0; a < ob->totcol; a++) { + if (ob->mat[a] == ma) { + if (ob->id.lib == NULL) { + ob->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - ob= ob->id.next; + ob = ob->id.next; } /* do meshes */ - me= bmain->mesh.first; + me = bmain->mesh.first; while (me) { if (me->mat) { - for (a=0; atotcol; a++) { - if (me->mat[a]==ma) { - if (me->id.lib==NULL) { - me->mat[a]= ma_new; + for (a = 0; a < me->totcol; a++) { + if (me->mat[a] == ma) { + if (me->id.lib == NULL) { + me->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - me= me->id.next; + me = me->id.next; } /* do curves */ - cu= bmain->curve.first; + cu = bmain->curve.first; while (cu) { if (cu->mat) { - for (a=0; atotcol; a++) { - if (cu->mat[a]==ma) { - if (cu->id.lib==NULL) { - cu->mat[a]= ma_new; + for (a = 0; a < cu->totcol; a++) { + if (cu->mat[a] == ma) { + if (cu->id.lib == NULL) { + cu->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - cu= cu->id.next; + cu = cu->id.next; } /* do mballs */ - mb= bmain->mball.first; + mb = bmain->mball.first; while (mb) { if (mb->mat) { - for (a=0; atotcol; a++) { - if (mb->mat[a]==ma) { - if (mb->id.lib==NULL) { - mb->mat[a]= ma_new; + for (a = 0; a < mb->totcol; a++) { + if (mb->mat[a] == ma) { + if (mb->id.lib == NULL) { + mb->mat[a] = ma_new; ma_new->id.us++; ma->id.us--; } } } } - mb= mb->id.next; + mb = mb->id.next; } } } @@ -444,7 +444,7 @@ void make_local_material(Material *ma) void extern_local_matarar(struct Material **matar, short totcol) { short i; - for (i= 0; i < totcol; i++) { + for (i = 0; i < totcol; i++) { id_lib_extern((ID *)matar[i]); } } @@ -455,16 +455,16 @@ Material ***give_matarar(Object *ob) Curve *cu; MetaBall *mb; - if (ob->type==OB_MESH) { - me= ob->data; + if (ob->type == OB_MESH) { + me = ob->data; return &(me->mat); } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { - cu= ob->data; + cu = ob->data; return &(cu->mat); } - else if (ob->type==OB_MBALL) { - mb= ob->data; + else if (ob->type == OB_MBALL) { + mb = ob->data; return &(mb->mat); } return NULL; @@ -476,16 +476,16 @@ short *give_totcolp(Object *ob) Curve *cu; MetaBall *mb; - if (ob->type==OB_MESH) { - me= ob->data; + if (ob->type == OB_MESH) { + me = ob->data; return &(me->totcol); } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { - cu= ob->data; + cu = ob->data; return &(cu->totcol); } - else if (ob->type==OB_MBALL) { - mb= ob->data; + else if (ob->type == OB_MBALL) { + mb = ob->data; return &(mb->totcol); } return NULL; @@ -495,15 +495,15 @@ short *give_totcolp(Object *ob) Material ***give_matarar_id(ID *id) { switch (GS(id->name)) { - case ID_ME: - return &(((Mesh *)id)->mat); - break; - case ID_CU: - return &(((Curve *)id)->mat); - break; - case ID_MB: - return &(((MetaBall *)id)->mat); - break; + case ID_ME: + return &(((Mesh *)id)->mat); + break; + case ID_CU: + return &(((Curve *)id)->mat); + break; + case ID_MB: + return &(((MetaBall *)id)->mat); + break; } return NULL; } @@ -511,15 +511,15 @@ Material ***give_matarar_id(ID *id) short *give_totcolp_id(ID *id) { switch (GS(id->name)) { - case ID_ME: - return &(((Mesh *)id)->totcol); - break; - case ID_CU: - return &(((Curve *)id)->totcol); - break; - case ID_MB: - return &(((MetaBall *)id)->totcol); - break; + case ID_ME: + return &(((Mesh *)id)->totcol); + break; + case ID_CU: + return &(((Curve *)id)->totcol); + break; + case ID_MB: + return &(((MetaBall *)id)->totcol); + break; } return NULL; } @@ -527,29 +527,29 @@ short *give_totcolp_id(ID *id) static void data_delete_material_index_id(ID *id, short index) { switch (GS(id->name)) { - case ID_ME: - mesh_delete_material_index((Mesh *)id, index); - break; - case ID_CU: - BKE_curve_delete_material_index((Curve *)id, index); - break; - case ID_MB: - /* meta-elems don't have materials atm */ - break; + case ID_ME: + BKE_mesh_delete_material_index((Mesh *)id, index); + break; + case ID_CU: + BKE_curve_delete_material_index((Curve *)id, index); + break; + case ID_MB: + /* meta-elems don't have materials atm */ + break; } } void material_append_id(ID *id, Material *ma) { Material ***matar; - if ((matar= give_matarar_id(id))) { - short *totcol= give_totcolp_id(id); - Material **mat= MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar"); + if ((matar = give_matarar_id(id))) { + short *totcol = give_totcolp_id(id); + Material **mat = MEM_callocN(sizeof(void *) * ((*totcol) + 1), "newmatar"); if (*totcol) memcpy(mat, *matar, sizeof(void *) * (*totcol)); if (*matar) MEM_freeN(*matar); - *matar= mat; - (*matar)[(*totcol)++]= ma; + *matar = mat; + (*matar)[(*totcol)++] = ma; id_us_plus((ID *)ma); test_object_materials(id); @@ -558,33 +558,33 @@ void material_append_id(ID *id, Material *ma) Material *material_pop_id(ID *id, int index_i, int remove_material_slot) { - short index= (short)index_i; - Material *ret= NULL; + short index = (short)index_i; + Material *ret = NULL; Material ***matar; - if ((matar= give_matarar_id(id))) { - short *totcol= give_totcolp_id(id); + if ((matar = give_matarar_id(id))) { + short *totcol = give_totcolp_id(id); if (index >= 0 && index < (*totcol)) { - ret= (*matar)[index]; + ret = (*matar)[index]; id_us_min((ID *)ret); if (remove_material_slot) { if (*totcol <= 1) { - *totcol= 0; + *totcol = 0; MEM_freeN(*matar); - *matar= NULL; + *matar = NULL; } else { Material **mat; if (index + 1 != (*totcol)) - memmove((*matar)+index, (*matar)+(index+1), sizeof(void *) * ((*totcol) - (index + 1))); + memmove((*matar) + index, (*matar) + (index + 1), sizeof(void *) * ((*totcol) - (index + 1))); (*totcol)--; - mat= MEM_callocN(sizeof(void *) * (*totcol), "newmatar"); + mat = MEM_callocN(sizeof(void *) * (*totcol), "newmatar"); memcpy(mat, *matar, sizeof(void *) * (*totcol)); MEM_freeN(*matar); - *matar= mat; + *matar = mat; test_object_materials(id); } @@ -594,7 +594,7 @@ Material *material_pop_id(ID *id, int index_i, int remove_material_slot) /* don't remove material slot, only clear it*/ else - (*matar)[index]= NULL; + (*matar)[index] = NULL; } } @@ -606,33 +606,33 @@ Material *give_current_material(Object *ob, short act) Material ***matarar, *ma; short *totcolp; - if (ob==NULL) return NULL; + if (ob == NULL) return NULL; /* if object cannot have material, totcolp==NULL */ - totcolp= give_totcolp(ob); - if (totcolp==NULL || ob->totcol==0) return NULL; + totcolp = give_totcolp(ob); + if (totcolp == NULL || ob->totcol == 0) return NULL; - if (act<0) { + if (act < 0) { printf("no!\n"); } - if (act>ob->totcol) act= ob->totcol; - else if (act<=0) act= 1; + if (act > ob->totcol) act = ob->totcol; + else if (act <= 0) act = 1; - if (ob->matbits && ob->matbits[act-1]) { /* in object */ - ma= ob->mat[act-1]; + if (ob->matbits && ob->matbits[act - 1]) { /* in object */ + ma = ob->mat[act - 1]; } - else { /* in data */ + else { /* in data */ /* check for inconsistency */ if (*totcolp < ob->totcol) - ob->totcol= *totcolp; - if (act>ob->totcol) act= ob->totcol; + ob->totcol = *totcolp; + if (act > ob->totcol) act = ob->totcol; - matarar= give_matarar(ob); + matarar = give_matarar(ob); - if (matarar && *matarar) ma= (*matarar)[act-1]; - else ma= NULL; + if (matarar && *matarar) ma = (*matarar)[act - 1]; + else ma = NULL; } @@ -642,19 +642,19 @@ Material *give_current_material(Object *ob, short act) ID *material_from(Object *ob, short act) { - if (ob==NULL) return NULL; + if (ob == NULL) return NULL; - if (ob->totcol==0) return ob->data; - if (act==0) act= 1; + if (ob->totcol == 0) return ob->data; + if (act == 0) act = 1; - if (ob->matbits[act-1]) return (ID *)ob; + if (ob->matbits[act - 1]) return (ID *)ob; else return ob->data; } Material *give_node_material(Material *ma) { if (ma && ma->use_nodes && ma->nodetree) { - bNode *node= nodeGetActiveID(ma->nodetree, ID_MA); + bNode *node = nodeGetActiveID(ma->nodetree, ID_MA); if (node) return (Material *)node->id; @@ -671,7 +671,7 @@ Material *give_node_material(Material *ma) * well. I expect we'll sort it out soon... */ /* from blendef: */ -#define GS(a) (*((short *)(a))) +#define GS(a) (*((short *)(a))) /* from misc_util: flip the bytes from x */ /* #define GS(x) (((unsigned char *)(x))[0] << 8 | ((unsigned char *)(x))[1]) */ @@ -681,29 +681,29 @@ void resize_object_material(Object *ob, const short totcol) Material **newmatar; char *newmatbits; - if (totcol==0) { + if (totcol == 0) { if (ob->totcol) { MEM_freeN(ob->mat); MEM_freeN(ob->matbits); - ob->mat= NULL; - ob->matbits= NULL; + ob->mat = NULL; + ob->matbits = NULL; } } - else if (ob->totcoltotcol < totcol) { + newmatar = MEM_callocN(sizeof(void *) * totcol, "newmatar"); + newmatbits = MEM_callocN(sizeof(char) * totcol, "newmatbits"); if (ob->totcol) { - memcpy(newmatar, ob->mat, sizeof(void *)*ob->totcol); - memcpy(newmatbits, ob->matbits, sizeof(char)*ob->totcol); + memcpy(newmatar, ob->mat, sizeof(void *) * ob->totcol); + memcpy(newmatbits, ob->matbits, sizeof(char) * ob->totcol); MEM_freeN(ob->mat); MEM_freeN(ob->matbits); } - ob->mat= newmatar; - ob->matbits= newmatbits; + ob->mat = newmatar; + ob->matbits = newmatbits; } - ob->totcol= totcol; - if (ob->totcol && ob->actcol==0) ob->actcol= 1; - if (ob->actcol>ob->totcol) ob->actcol= ob->totcol; + ob->totcol = totcol; + if (ob->totcol && ob->actcol == 0) ob->actcol = 1; + if (ob->actcol > ob->totcol) ob->actcol = ob->totcol; } void test_object_materials(ID *id) @@ -712,12 +712,12 @@ void test_object_materials(ID *id) Object *ob; short *totcol; - if (id==NULL || (totcol=give_totcolp_id(id))==NULL) { + if (id == NULL || (totcol = give_totcolp_id(id)) == NULL) { return; } - for (ob= G.main->object.first; ob; ob= ob->id.next) { - if (ob->data==id) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { + if (ob->data == id) { resize_object_material(ob, *totcol); } } @@ -728,8 +728,8 @@ void assign_material_id(ID *id, Material *ma, short act) Material *mao, **matar, ***matarar; short *totcolp; - if (act>MAXMAT) return; - if (act<1) act= 1; + if (act > MAXMAT) return; + if (act < 1) act = 1; /* prevent crashing when using accidentally */ BLI_assert(id->lib == NULL); @@ -737,27 +737,27 @@ void assign_material_id(ID *id, Material *ma, short act) /* test arraylens */ - totcolp= give_totcolp_id(id); - matarar= give_matarar_id(id); + totcolp = give_totcolp_id(id); + matarar = give_matarar_id(id); - if (totcolp==NULL || matarar==NULL) return; + if (totcolp == NULL || matarar == NULL) return; if (act > *totcolp) { - matar= MEM_callocN(sizeof(void *)*act, "matarray1"); + matar = MEM_callocN(sizeof(void *) * act, "matarray1"); if (*totcolp) { - memcpy(matar, *matarar, sizeof(void *)*(*totcolp)); + memcpy(matar, *matarar, sizeof(void *) * (*totcolp)); MEM_freeN(*matarar); } - *matarar= matar; - *totcolp= act; + *matarar = matar; + *totcolp = act; } /* in data */ - mao= (*matarar)[act-1]; + mao = (*matarar)[act - 1]; if (mao) mao->id.us--; - (*matarar)[act-1]= ma; + (*matarar)[act - 1] = ma; if (ma) id_us_plus((ID *)ma); @@ -771,8 +771,8 @@ void assign_material(Object *ob, Material *ma, short act) char *matbits; short *totcolp; - if (act>MAXMAT) return; - if (act<1) act= 1; + if (act > MAXMAT) return; + if (act < 1) act = 1; /* prevent crashing when using accidentally */ BLI_assert(ob->id.lib == NULL); @@ -780,54 +780,54 @@ void assign_material(Object *ob, Material *ma, short act) /* test arraylens */ - totcolp= give_totcolp(ob); - matarar= give_matarar(ob); + totcolp = give_totcolp(ob); + matarar = give_matarar(ob); - if (totcolp==NULL || matarar==NULL) return; + if (totcolp == NULL || matarar == NULL) return; if (act > *totcolp) { - matar= MEM_callocN(sizeof(void *)*act, "matarray1"); + matar = MEM_callocN(sizeof(void *) * act, "matarray1"); if (*totcolp) { - memcpy(matar, *matarar, sizeof(void *)*(*totcolp)); + memcpy(matar, *matarar, sizeof(void *) * (*totcolp)); MEM_freeN(*matarar); } - *matarar= matar; - *totcolp= act; + *matarar = matar; + *totcolp = act; } if (act > ob->totcol) { - matar= MEM_callocN(sizeof(void *)*act, "matarray2"); - matbits= MEM_callocN(sizeof(char)*act, "matbits1"); - if ( ob->totcol) { + matar = MEM_callocN(sizeof(void *) * act, "matarray2"); + matbits = MEM_callocN(sizeof(char) * act, "matbits1"); + if (ob->totcol) { memcpy(matar, ob->mat, sizeof(void *) * ob->totcol); - memcpy(matbits, ob->matbits, sizeof(char)*(*totcolp)); + memcpy(matbits, ob->matbits, sizeof(char) * (*totcolp)); MEM_freeN(ob->mat); MEM_freeN(ob->matbits); } - ob->mat= matar; - ob->matbits= matbits; - ob->totcol= act; + ob->mat = matar; + ob->matbits = matbits; + ob->totcol = act; /* copy object/mesh linking, or assign based on userpref */ if (ob->actcol) - ob->matbits[act-1]= ob->matbits[ob->actcol-1]; + ob->matbits[act - 1] = ob->matbits[ob->actcol - 1]; else - ob->matbits[act-1]= (U.flag & USER_MAT_ON_OB)? 1: 0; + ob->matbits[act - 1] = (U.flag & USER_MAT_ON_OB) ? 1 : 0; } /* do it */ - if (ob->matbits[act-1]) { /* in object */ - mao= ob->mat[act-1]; + if (ob->matbits[act - 1]) { /* in object */ + mao = ob->mat[act - 1]; if (mao) mao->id.us--; - ob->mat[act-1]= ma; + ob->mat[act - 1] = ma; } - else { /* in data */ - mao= (*matarar)[act-1]; + else { /* in data */ + mao = (*matarar)[act - 1]; if (mao) mao->id.us--; - (*matarar)[act-1]= ma; + (*matarar)[act - 1] = ma; } if (ma) @@ -838,19 +838,19 @@ void assign_material(Object *ob, Material *ma, short act) /* XXX - this calls many more update calls per object then are needed, could be optimized */ void assign_matarar(struct Object *ob, struct Material ***matar, short totcol) { - int actcol_orig= ob->actcol; + int actcol_orig = ob->actcol; short i; while (object_remove_material_slot(ob)) {}; /* now we have the right number of slots */ - for (i=0; i ob->totcol) - actcol_orig= ob->totcol; + actcol_orig = ob->totcol; - ob->actcol= actcol_orig; + ob->actcol = actcol_orig; } @@ -859,45 +859,45 @@ short find_material_index(Object *ob, Material *ma) Material ***matarar; short a, *totcolp; - if (ma==NULL) return 0; + if (ma == NULL) return 0; - totcolp= give_totcolp(ob); - matarar= give_matarar(ob); + totcolp = give_totcolp(ob); + matarar = give_matarar(ob); - if (totcolp==NULL || matarar==NULL) return 0; + if (totcolp == NULL || matarar == NULL) return 0; - for (a=0; a<*totcolp; a++) - if ((*matarar)[a]==ma) - break; - if (a<*totcolp) - return a+1; + for (a = 0; a < *totcolp; a++) + if ((*matarar)[a] == ma) + break; + if (a < *totcolp) + return a + 1; return 0; } int object_add_material_slot(Object *ob) { - if (ob==NULL) return FALSE; - if (ob->totcol>=MAXMAT) return FALSE; + if (ob == NULL) return FALSE; + if (ob->totcol >= MAXMAT) return FALSE; - assign_material(ob, NULL, ob->totcol+1); - ob->actcol= ob->totcol; + assign_material(ob, NULL, ob->totcol + 1); + ob->actcol = ob->totcol; return TRUE; } static void do_init_render_material(Material *ma, int r_mode, float *amb) { MTex *mtex; - int a, needuv=0, needtang=0; + int a, needuv = 0, needtang = 0; - if (ma->flarec==0) ma->flarec= 1; + if (ma->flarec == 0) ma->flarec = 1; /* add all texcoflags from mtex, texco and mapto were cleared in advance */ - for (a=0; aseptex & (1<septex & (1 << a)) continue; - mtex= ma->mtex[a]; + mtex = ma->mtex[a]; if (mtex && mtex->tex && (mtex->tex->type | (mtex->tex->use_nodes && mtex->tex->nodetree) )) { ma->texco |= mtex->texco; @@ -905,41 +905,41 @@ static void do_init_render_material(Material *ma, int r_mode, float *amb) /* always get derivatives for these textures */ if (ELEM3(mtex->tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP)) ma->texco |= TEXCO_OSA; - else if (mtex->texflag & (MTEX_COMPAT_BUMP|MTEX_3TAP_BUMP|MTEX_5TAP_BUMP|MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA; + else if (mtex->texflag & (MTEX_COMPAT_BUMP | MTEX_3TAP_BUMP | MTEX_5TAP_BUMP | MTEX_BICUBIC_BUMP)) ma->texco |= TEXCO_OSA; - if (ma->texco & (TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM|TEXCO_STRAND|TEXCO_STRESS)) needuv= 1; - else if (ma->texco & (TEXCO_GLOB|TEXCO_UV|TEXCO_OBJECT|TEXCO_SPEED)) needuv= 1; - else if (ma->texco & (TEXCO_LAVECTOR|TEXCO_VIEW|TEXCO_STICKY)) needuv= 1; + if (ma->texco & (TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM | TEXCO_STRAND | TEXCO_STRESS)) needuv = 1; + else if (ma->texco & (TEXCO_GLOB | TEXCO_UV | TEXCO_OBJECT | TEXCO_SPEED)) needuv = 1; + else if (ma->texco & (TEXCO_LAVECTOR | TEXCO_VIEW | TEXCO_STICKY)) needuv = 1; if ((ma->mapto & MAP_NORM) && (mtex->normapspace == MTEX_NSPACE_TANGENT)) - needtang= 1; + needtang = 1; } } if (needtang) ma->mode |= MA_NORMAP_TANG; else ma->mode &= ~MA_NORMAP_TANG; - if (ma->mode & (MA_VERTEXCOL|MA_VERTEXCOLP|MA_FACETEXTURE)) { - needuv= 1; - if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */ + if (ma->mode & (MA_VERTEXCOL | MA_VERTEXCOLP | MA_FACETEXTURE)) { + needuv = 1; + if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; /* for texfaces */ } if (needuv) ma->texco |= NEED_UV; /* since the raytracer doesnt recalc O structs for each ray, we have to preset them all */ if (r_mode & R_RAYTRACE) { - if ((ma->mode & (MA_RAYMIRROR|MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { - ma->texco |= NEED_UV|TEXCO_ORCO|TEXCO_REFL|TEXCO_NORM; + if ((ma->mode & (MA_RAYMIRROR | MA_SHADOW_TRA)) || ((ma->mode & MA_TRANSP) && (ma->mode & MA_RAYTRANSP))) { + ma->texco |= NEED_UV | TEXCO_ORCO | TEXCO_REFL | TEXCO_NORM; if (r_mode & R_OSA) ma->texco |= TEXCO_OSA; } } if (amb) { - ma->ambr= ma->amb*amb[0]; - ma->ambg= ma->amb*amb[1]; - ma->ambb= ma->amb*amb[2]; + ma->ambr = ma->amb * amb[0]; + ma->ambg = ma->amb * amb[1]; + ma->ambb = ma->amb * amb[2]; } /* will become or-ed result of all node modes */ - ma->mode_l= ma->mode; + ma->mode_l = ma->mode; ma->mode_l &= ~MA_SHLESS; if (ma->strand_surfnor > 0.0f) @@ -954,17 +954,17 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode { bNode *node; - for (node=ntree->nodes.first; node; node= node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->id) { - if (GS(node->id->name)==ID_MA) { - Material *ma= (Material *)node->id; - if (ma!=basemat) { + if (GS(node->id->name) == ID_MA) { + Material *ma = (Material *)node->id; + if (ma != basemat) { do_init_render_material(ma, r_mode, amb); basemat->texco |= ma->texco; - basemat->mode_l |= ma->mode_l & ~(MA_TRANSP|MA_ZTRANSP|MA_RAYTRANSP); + basemat->mode_l |= ma->mode_l & ~(MA_TRANSP | MA_ZTRANSP | MA_RAYTRANSP); } } - else if (node->type==NODE_GROUP) + else if (node->type == NODE_GROUP) init_render_nodetree((bNodeTree *)node->id, basemat, r_mode, amb); } } @@ -990,15 +990,15 @@ void init_render_materials(Main *bmain, int r_mode, float *amb) /* clear these flags before going over materials, to make sure they * are cleared only once, otherwise node materials contained in other * node materials can go wrong */ - for (ma= bmain->mat.first; ma; ma= ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { if (ma->id.us) { - ma->texco= 0; - ma->mapto= 0; + ma->texco = 0; + ma->mapto = 0; } } /* two steps, first initialize, then or the flags for layers */ - for (ma= bmain->mat.first; ma; ma= ma->id.next) { + for (ma = bmain->mat.first; ma; ma = ma->id.next) { /* is_used flag comes back in convertblender.c */ ma->flag &= ~MA_IS_USED; if (ma->id.us) @@ -1020,7 +1020,7 @@ void end_render_material(Material *mat) void end_render_materials(Main *bmain) { Material *ma; - for (ma= bmain->mat.first; ma; ma= ma->id.next) + for (ma = bmain->mat.first; ma; ma = ma->id.next) if (ma->id.us) end_render_material(ma); } @@ -1029,13 +1029,13 @@ static int material_in_nodetree(bNodeTree *ntree, Material *mat) { bNode *node; - for (node=ntree->nodes.first; node; node= node->next) { - if (node->id && GS(node->id->name)==ID_MA) { - if (node->id==(ID*)mat) + for (node = ntree->nodes.first; node; node = node->next) { + if (node->id && GS(node->id->name) == ID_MA) { + if (node->id == (ID *)mat) return 1; } - else if (node->type==NODE_GROUP) - if (material_in_nodetree((bNodeTree*)node->id, mat)) + else if (node->type == NODE_GROUP) + if (material_in_nodetree((bNodeTree *)node->id, mat)) return 1; } @@ -1044,7 +1044,7 @@ static int material_in_nodetree(bNodeTree *ntree, Material *mat) int material_in_material(Material *parmat, Material *mat) { - if (parmat==mat) + if (parmat == mat) return 1; else if (parmat->nodetree && parmat->use_nodes) return material_in_nodetree(parmat->nodetree, mat); @@ -1087,15 +1087,15 @@ void automatname(Material *ma) int nr, r, g, b; float ref; - if (ma==NULL) return; - if (ma->mode & MA_SHLESS) ref= 1.0; - else ref= ma->ref; - - r= (int)(4.99f*(ref*ma->r)); - g= (int)(4.99f*(ref*ma->g)); - b= (int)(4.99f*(ref*ma->b)); - nr= r + 5*g + 25*b; - if (nr>124) nr= 124; + if (ma == NULL) return; + if (ma->mode & MA_SHLESS) ref = 1.0; + else ref = ma->ref; + + r = (int)(4.99f * (ref * ma->r)); + g = (int)(4.99f * (ref * ma->g)); + b = (int)(4.99f * (ref * ma->b)); + nr = r + 5 * g + 25 * b; + if (nr > 124) nr = 124; new_id(&G.main->mat, (ID *)ma, colname_array[nr]); } @@ -1108,7 +1108,7 @@ int object_remove_material_slot(Object *ob) short *totcolp; short a, actcol; - if (ob==NULL || ob->totcol==0) { + if (ob == NULL || ob->totcol == 0) { return FALSE; } @@ -1125,55 +1125,55 @@ int object_remove_material_slot(Object *ob) * after that check indices in mesh/curve/mball!!! */ - totcolp= give_totcolp(ob); - matarar= give_matarar(ob); + totcolp = give_totcolp(ob); + matarar = give_matarar(ob); - if (*matarar==NULL) return FALSE; + if (*matarar == NULL) return FALSE; /* we delete the actcol */ - mao= (*matarar)[ob->actcol-1]; + mao = (*matarar)[ob->actcol - 1]; if (mao) mao->id.us--; - for (a=ob->actcol; atotcol; a++) - (*matarar)[a-1]= (*matarar)[a]; + for (a = ob->actcol; a < ob->totcol; a++) + (*matarar)[a - 1] = (*matarar)[a]; (*totcolp)--; - if (*totcolp==0) { + if (*totcolp == 0) { MEM_freeN(*matarar); - *matarar= NULL; + *matarar = NULL; } - actcol= ob->actcol; - obt= G.main->object.first; + actcol = ob->actcol; + obt = G.main->object.first; while (obt) { - if (obt->data==ob->data) { + if (obt->data == ob->data) { /* WATCH IT: do not use actcol from ob or from obt (can become zero) */ - mao= obt->mat[actcol-1]; + mao = obt->mat[actcol - 1]; if (mao) mao->id.us--; - for (a=actcol; atotcol; a++) { - obt->mat[a-1]= obt->mat[a]; - obt->matbits[a-1]= obt->matbits[a]; + for (a = actcol; a < obt->totcol; a++) { + obt->mat[a - 1] = obt->mat[a]; + obt->matbits[a - 1] = obt->matbits[a]; } obt->totcol--; - if (obt->actcol > obt->totcol) obt->actcol= obt->totcol; + if (obt->actcol > obt->totcol) obt->actcol = obt->totcol; - if (obt->totcol==0) { + if (obt->totcol == 0) { MEM_freeN(obt->mat); MEM_freeN(obt->matbits); - obt->mat= NULL; - obt->matbits= NULL; + obt->mat = NULL; + obt->matbits = NULL; } } - obt= obt->id.next; + obt = obt->id.next; } /* check indices from mesh */ if (ELEM4(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) { - data_delete_material_index_id((ID *)ob->data, actcol-1); - freedisplist(&ob->disp); + data_delete_material_index_id((ID *)ob->data, actcol - 1); + BKE_displist_free(&ob->disp); } return TRUE; @@ -1183,253 +1183,253 @@ int object_remove_material_slot(Object *ob) /* r_col = current value, col = new value, fac==0 is no change */ void ramp_blend(int type, float r_col[3], const float fac, const float col[3]) { - float tmp, facm= 1.0f-fac; + float tmp, facm = 1.0f - fac; switch (type) { case MA_RAMP_BLEND: - r_col[0] = facm*(r_col[0]) + fac*col[0]; - r_col[1] = facm*(r_col[1]) + fac*col[1]; - r_col[2] = facm*(r_col[2]) + fac*col[2]; + r_col[0] = facm * (r_col[0]) + fac * col[0]; + r_col[1] = facm * (r_col[1]) + fac * col[1]; + r_col[2] = facm * (r_col[2]) + fac * col[2]; break; case MA_RAMP_ADD: - r_col[0] += fac*col[0]; - r_col[1] += fac*col[1]; - r_col[2] += fac*col[2]; + r_col[0] += fac * col[0]; + r_col[1] += fac * col[1]; + r_col[2] += fac * col[2]; break; case MA_RAMP_MULT: - r_col[0] *= (facm + fac*col[0]); - r_col[1] *= (facm + fac*col[1]); - r_col[2] *= (facm + fac*col[2]); + r_col[0] *= (facm + fac * col[0]); + r_col[1] *= (facm + fac * col[1]); + r_col[2] *= (facm + fac * col[2]); break; case MA_RAMP_SCREEN: - r_col[0] = 1.0f - (facm + fac*(1.0f - col[0])) * (1.0f - r_col[0]); - r_col[1] = 1.0f - (facm + fac*(1.0f - col[1])) * (1.0f - r_col[1]); - r_col[2] = 1.0f - (facm + fac*(1.0f - col[2])) * (1.0f - r_col[2]); + r_col[0] = 1.0f - (facm + fac * (1.0f - col[0])) * (1.0f - r_col[0]); + r_col[1] = 1.0f - (facm + fac * (1.0f - col[1])) * (1.0f - r_col[1]); + r_col[2] = 1.0f - (facm + fac * (1.0f - col[2])) * (1.0f - r_col[2]); break; case MA_RAMP_OVERLAY: if (r_col[0] < 0.5f) - r_col[0] *= (facm + 2.0f*fac*col[0]); + r_col[0] *= (facm + 2.0f * fac * col[0]); else - r_col[0] = 1.0f - (facm + 2.0f*fac*(1.0f - col[0])) * (1.0f - r_col[0]); + r_col[0] = 1.0f - (facm + 2.0f * fac * (1.0f - col[0])) * (1.0f - r_col[0]); if (r_col[1] < 0.5f) - r_col[1] *= (facm + 2.0f*fac*col[1]); + r_col[1] *= (facm + 2.0f * fac * col[1]); else - r_col[1] = 1.0f - (facm + 2.0f*fac*(1.0f - col[1])) * (1.0f - r_col[1]); + r_col[1] = 1.0f - (facm + 2.0f * fac * (1.0f - col[1])) * (1.0f - r_col[1]); if (r_col[2] < 0.5f) - r_col[2] *= (facm + 2.0f*fac*col[2]); + r_col[2] *= (facm + 2.0f * fac * col[2]); else - r_col[2] = 1.0f - (facm + 2.0f*fac*(1.0f - col[2])) * (1.0f - r_col[2]); + r_col[2] = 1.0f - (facm + 2.0f * fac * (1.0f - col[2])) * (1.0f - r_col[2]); break; case MA_RAMP_SUB: - r_col[0] -= fac*col[0]; - r_col[1] -= fac*col[1]; - r_col[2] -= fac*col[2]; + r_col[0] -= fac * col[0]; + r_col[1] -= fac * col[1]; + r_col[2] -= fac * col[2]; break; case MA_RAMP_DIV: - if (col[0]!=0.0f) - r_col[0] = facm*(r_col[0]) + fac*(r_col[0])/col[0]; - if (col[1]!=0.0f) - r_col[1] = facm*(r_col[1]) + fac*(r_col[1])/col[1]; - if (col[2]!=0.0f) - r_col[2] = facm*(r_col[2]) + fac*(r_col[2])/col[2]; + if (col[0] != 0.0f) + r_col[0] = facm * (r_col[0]) + fac * (r_col[0]) / col[0]; + if (col[1] != 0.0f) + r_col[1] = facm * (r_col[1]) + fac * (r_col[1]) / col[1]; + if (col[2] != 0.0f) + r_col[2] = facm * (r_col[2]) + fac * (r_col[2]) / col[2]; break; case MA_RAMP_DIFF: - r_col[0] = facm*(r_col[0]) + fac*fabsf(r_col[0]-col[0]); - r_col[1] = facm*(r_col[1]) + fac*fabsf(r_col[1]-col[1]); - r_col[2] = facm*(r_col[2]) + fac*fabsf(r_col[2]-col[2]); + r_col[0] = facm * (r_col[0]) + fac *fabsf(r_col[0] - col[0]); + r_col[1] = facm * (r_col[1]) + fac *fabsf(r_col[1] - col[1]); + r_col[2] = facm * (r_col[2]) + fac *fabsf(r_col[2] - col[2]); break; case MA_RAMP_DARK: - tmp=col[0]+((1-col[0])*facm); - if (tmp < r_col[0]) r_col[0]= tmp; - tmp=col[1]+((1-col[1])*facm); - if (tmp < r_col[1]) r_col[1]= tmp; - tmp=col[2]+((1-col[2])*facm); - if (tmp < r_col[2]) r_col[2]= tmp; + tmp = col[0] + ((1 - col[0]) * facm); + if (tmp < r_col[0]) r_col[0] = tmp; + tmp = col[1] + ((1 - col[1]) * facm); + if (tmp < r_col[1]) r_col[1] = tmp; + tmp = col[2] + ((1 - col[2]) * facm); + if (tmp < r_col[2]) r_col[2] = tmp; break; case MA_RAMP_LIGHT: - tmp= fac*col[0]; - if (tmp > r_col[0]) r_col[0]= tmp; - tmp= fac*col[1]; - if (tmp > r_col[1]) r_col[1]= tmp; - tmp= fac*col[2]; - if (tmp > r_col[2]) r_col[2]= tmp; - break; + tmp = fac * col[0]; + if (tmp > r_col[0]) r_col[0] = tmp; + tmp = fac * col[1]; + if (tmp > r_col[1]) r_col[1] = tmp; + tmp = fac * col[2]; + if (tmp > r_col[2]) r_col[2] = tmp; + break; case MA_RAMP_DODGE: if (r_col[0] != 0.0f) { - tmp = 1.0f - fac*col[0]; + tmp = 1.0f - fac * col[0]; if (tmp <= 0.0f) r_col[0] = 1.0f; - else if ((tmp = (r_col[0]) / tmp)> 1.0f) + else if ((tmp = (r_col[0]) / tmp) > 1.0f) r_col[0] = 1.0f; else r_col[0] = tmp; } if (r_col[1] != 0.0f) { - tmp = 1.0f - fac*col[1]; - if (tmp <= 0.0f ) + tmp = 1.0f - fac * col[1]; + if (tmp <= 0.0f) r_col[1] = 1.0f; - else if ((tmp = (r_col[1]) / tmp) > 1.0f ) + else if ((tmp = (r_col[1]) / tmp) > 1.0f) r_col[1] = 1.0f; else r_col[1] = tmp; } if (r_col[2] != 0.0f) { - tmp = 1.0f - fac*col[2]; + tmp = 1.0f - fac * col[2]; if (tmp <= 0.0f) r_col[2] = 1.0f; - else if ((tmp = (r_col[2]) / tmp) > 1.0f ) + else if ((tmp = (r_col[2]) / tmp) > 1.0f) r_col[2] = 1.0f; else r_col[2] = tmp; } break; case MA_RAMP_BURN: - tmp = facm + fac*col[0]; + tmp = facm + fac * col[0]; if (tmp <= 0.0f) r_col[0] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[0])) / tmp )) < 0.0f) - r_col[0] = 0.0f; + else if ((tmp = (1.0f - (1.0f - (r_col[0])) / tmp)) < 0.0f) + r_col[0] = 0.0f; else if (tmp > 1.0f) - r_col[0]=1.0f; + r_col[0] = 1.0f; else r_col[0] = tmp; - tmp = facm + fac*col[1]; + tmp = facm + fac * col[1]; if (tmp <= 0.0f) r_col[1] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[1])) / tmp )) < 0.0f ) - r_col[1] = 0.0f; - else if (tmp >1.0f) - r_col[1]=1.0f; + else if ((tmp = (1.0f - (1.0f - (r_col[1])) / tmp)) < 0.0f) + r_col[1] = 0.0f; + else if (tmp > 1.0f) + r_col[1] = 1.0f; else r_col[1] = tmp; - tmp = facm + fac*col[2]; - if (tmp <= 0.0f) + tmp = facm + fac * col[2]; + if (tmp <= 0.0f) r_col[2] = 0.0f; - else if (( tmp = (1.0f - (1.0f - (r_col[2])) / tmp )) < 0.0f ) - r_col[2] = 0.0f; - else if (tmp >1.0f) - r_col[2]= 1.0f; + else if ((tmp = (1.0f - (1.0f - (r_col[2])) / tmp)) < 0.0f) + r_col[2] = 0.0f; + else if (tmp > 1.0f) + r_col[2] = 1.0f; else r_col[2] = tmp; break; case MA_RAMP_HUE: - { - float rH, rS, rV; - float colH, colS, colV; - float tmpr, tmpg, tmpb; - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - if (colS != 0) { - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb); - r_col[0] = facm*(r_col[0]) + fac*tmpr; - r_col[1] = facm*(r_col[1]) + fac*tmpg; - r_col[2] = facm*(r_col[2]) + fac*tmpb; - } + { + float rH, rS, rV; + float colH, colS, colV; + float tmpr, tmpg, tmpb; + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + if (colS != 0) { + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + hsv_to_rgb(colH, rS, rV, &tmpr, &tmpg, &tmpb); + r_col[0] = facm * (r_col[0]) + fac * tmpr; + r_col[1] = facm * (r_col[1]) + fac * tmpg; + r_col[2] = facm * (r_col[2]) + fac * tmpb; } - break; + } + break; case MA_RAMP_SAT: - { - float rH, rS, rV; - float colH, colS, colV; - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - if (rS != 0) { - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - hsv_to_rgb(rH, (facm*rS +fac*colS), rV, r_col+0, r_col+1, r_col+2); - } + { + float rH, rS, rV; + float colH, colS, colV; + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + if (rS != 0) { + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + hsv_to_rgb(rH, (facm * rS + fac * colS), rV, r_col + 0, r_col + 1, r_col + 2); } - break; + } + break; case MA_RAMP_VAL: - { - float rH, rS, rV; - float colH, colS, colV; - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - hsv_to_rgb(rH, rS, (facm*rV +fac*colV), r_col+0, r_col+1, r_col+2); - } - break; + { + float rH, rS, rV; + float colH, colS, colV; + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + hsv_to_rgb(rH, rS, (facm * rV + fac * colV), r_col + 0, r_col + 1, r_col + 2); + } + break; case MA_RAMP_COLOR: - { - float rH, rS, rV; - float colH, colS, colV; - float tmpr, tmpg, tmpb; - rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); - if (colS != 0) { - rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); - hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb); - r_col[0] = facm*(r_col[0]) + fac*tmpr; - r_col[1] = facm*(r_col[1]) + fac*tmpg; - r_col[2] = facm*(r_col[2]) + fac*tmpb; - } + { + float rH, rS, rV; + float colH, colS, colV; + float tmpr, tmpg, tmpb; + rgb_to_hsv(col[0], col[1], col[2], &colH, &colS, &colV); + if (colS != 0) { + rgb_to_hsv(r_col[0], r_col[1], r_col[2], &rH, &rS, &rV); + hsv_to_rgb(colH, colS, rV, &tmpr, &tmpg, &tmpb); + r_col[0] = facm * (r_col[0]) + fac * tmpr; + r_col[1] = facm * (r_col[1]) + fac * tmpg; + r_col[2] = facm * (r_col[2]) + fac * tmpb; } - break; + } + break; case MA_RAMP_SOFT: - { - float scr, scg, scb; + { + float scr, scg, scb; - /* first calculate non-fac based Screen mix */ - scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]); - scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]); - scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]); + /* first calculate non-fac based Screen mix */ + scr = 1.0f - (1.0f - col[0]) * (1.0f - r_col[0]); + scg = 1.0f - (1.0f - col[1]) * (1.0f - r_col[1]); + scb = 1.0f - (1.0f - col[2]) * (1.0f - r_col[2]); - r_col[0] = facm*(r_col[0]) + fac*(((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr)); - r_col[1] = facm*(r_col[1]) + fac*(((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg)); - r_col[2] = facm*(r_col[2]) + fac*(((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb)); - } - break; + r_col[0] = facm * (r_col[0]) + fac * (((1.0f - r_col[0]) * col[0] * (r_col[0])) + (r_col[0] * scr)); + r_col[1] = facm * (r_col[1]) + fac * (((1.0f - r_col[1]) * col[1] * (r_col[1])) + (r_col[1] * scg)); + r_col[2] = facm * (r_col[2]) + fac * (((1.0f - r_col[2]) * col[2] * (r_col[2])) + (r_col[2] * scb)); + } + break; case MA_RAMP_LINEAR: if (col[0] > 0.5f) - r_col[0] = r_col[0] + fac*(2.0f*(col[0]-0.5f)); + r_col[0] = r_col[0] + fac * (2.0f * (col[0] - 0.5f)); else - r_col[0] = r_col[0] + fac*(2.0f*(col[0]) - 1.0f); + r_col[0] = r_col[0] + fac * (2.0f * (col[0]) - 1.0f); if (col[1] > 0.5f) - r_col[1] = r_col[1] + fac*(2.0f*(col[1]-0.5f)); + r_col[1] = r_col[1] + fac * (2.0f * (col[1] - 0.5f)); else - r_col[1] = r_col[1] + fac*(2.0f*(col[1]) -1.0f); + r_col[1] = r_col[1] + fac * (2.0f * (col[1]) - 1.0f); if (col[2] > 0.5f) - r_col[2] = r_col[2] + fac*(2.0f*(col[2]-0.5f)); + r_col[2] = r_col[2] + fac * (2.0f * (col[2] - 0.5f)); else - r_col[2] = r_col[2] + fac*(2.0f*(col[2]) - 1.0f); + r_col[2] = r_col[2] + fac * (2.0f * (col[2]) - 1.0f); break; } } /* copy/paste buffer, if we had a propper py api that would be better */ static Material matcopybuf; -static short matcopied= 0; +static short matcopied = 0; void clear_matcopybuf(void) { memset(&matcopybuf, 0, sizeof(Material)); - matcopied= 0; + matcopied = 0; } void free_matcopybuf(void) { int a; - for (a=0; anodetree); - matcopybuf.preview= NULL; - matcopybuf.gpumaterial.first= matcopybuf.gpumaterial.last= NULL; - matcopied= 1; + matcopybuf.nodetree = ntreeCopyTree(ma->nodetree); + matcopybuf.preview = NULL; + matcopybuf.gpumaterial.first = matcopybuf.gpumaterial.last = NULL; + matcopied = 1; } void paste_matcopybuf(Material *ma) @@ -1462,13 +1462,13 @@ void paste_matcopybuf(Material *ma) MTex *mtex; ID id; - if (matcopied==0) + if (matcopied == 0) return; /* free current mat */ if (ma->ramp_col) MEM_freeN(ma->ramp_col); if (ma->ramp_spec) MEM_freeN(ma->ramp_spec); - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = ma->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -1480,22 +1480,22 @@ void paste_matcopybuf(Material *ma) GPU_material_free(ma); - id= (ma->id); + id = (ma->id); memcpy(ma, &matcopybuf, sizeof(Material)); - (ma->id)= id; + (ma->id) = id; - if (matcopybuf.ramp_col) ma->ramp_col= MEM_dupallocN(matcopybuf.ramp_col); - if (matcopybuf.ramp_spec) ma->ramp_spec= MEM_dupallocN(matcopybuf.ramp_spec); + if (matcopybuf.ramp_col) ma->ramp_col = MEM_dupallocN(matcopybuf.ramp_col); + if (matcopybuf.ramp_spec) ma->ramp_spec = MEM_dupallocN(matcopybuf.ramp_spec); - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = ma->mtex[a]; if (mtex) { - ma->mtex[a]= MEM_dupallocN(mtex); + ma->mtex[a] = MEM_dupallocN(mtex); if (mtex->tex) id_us_plus((ID *)mtex->tex); } } - ma->nodetree= ntreeCopyTree(matcopybuf.nodetree); + ma->nodetree = ntreeCopyTree(matcopybuf.nodetree); } @@ -1531,7 +1531,7 @@ static int encode_tfaceflag(MTFace *tf, int convertall) static void decode_tfaceflag(Material *ma, int flag, int convertall) { int alphablend; - GameSettings *game= &ma->game; + GameSettings *game = &ma->game; /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ flag -= 1; @@ -1540,7 +1540,7 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) (*game).flag = 0; /* General Material Options */ - if ((flag & TF_DYNAMIC)==0) (*game).flag |= GEMAT_NOPHYSICS; + if ((flag & TF_DYNAMIC) == 0) (*game).flag |= GEMAT_NOPHYSICS; /* Material Offline Rendering Properties */ if (convertall) { @@ -1548,8 +1548,8 @@ static void decode_tfaceflag(Material *ma, int flag, int convertall) } /* Special Face Properties */ - if ((flag & TF_TWOSIDE)==0) (*game).flag |= GEMAT_BACKCULL; - if (flag & TF_INVISIBLE)(*game).flag |= GEMAT_INVISIBLE; + if ((flag & TF_TWOSIDE) == 0) (*game).flag |= GEMAT_BACKCULL; + if (flag & TF_INVISIBLE) (*game).flag |= GEMAT_INVISIBLE; if (flag & TF_BMFONT) (*game).flag |= GEMAT_TEXT; /* Face Orientation */ @@ -1571,7 +1571,7 @@ static int check_tfaceneedmaterial(int flag) // also if only flags are visible and collision see if all objects using this mesh have this option in physics /* flag is shifted in 1 to make 0 != no flag yet (see encode_tfaceflag) */ - flag -=1; + flag -= 1; // deprecated flags flag &= ~TF_OBCOL; @@ -1598,11 +1598,11 @@ static int check_tfaceneedmaterial(int flag) // XXX to be optmized or replaced by an equivalent blender internal function static int integer_getdigits(int number) { - int i=0; + int i = 0; if (number == 0) return 1; while (number != 0) { - number = (int)(number/10); + number = (int)(number / 10); i++; } return i; @@ -1616,7 +1616,7 @@ static void calculate_tface_materialname(char *matname, char *newname, int flag) int digits = integer_getdigits(flag); /* clamp the old name, remove the MA prefix and add the .TF.flag suffix * e.g. matname = "MALoooooooooooooongName"; newname = "Loooooooooooooon.TF.2" */ - BLI_snprintf(newname, MAX_ID_NAME, "%.*s.TF.%0*d", MAX_ID_NAME-(digits+5), matname, digits, flag); + BLI_snprintf(newname, MAX_ID_NAME, "%.*s.TF.%0*d", MAX_ID_NAME - (digits + 5), matname, digits, flag); } /* returns -1 if no match */ @@ -1624,7 +1624,7 @@ static short mesh_getmaterialnumber(Mesh *me, Material *ma) { short a; - for (a=0; atotcol; a++) { + for (a = 0; a < me->totcol; a++) { if (me->mat[a] == ma) { return a; } @@ -1637,11 +1637,11 @@ static short mesh_getmaterialnumber(Mesh *me, Material *ma) static short mesh_addmaterial(Mesh *me, Material *ma) { material_append_id(&me->id, NULL); - me->mat[me->totcol-1]= ma; + me->mat[me->totcol - 1] = ma; id_us_plus(&ma->id); - return me->totcol-1; + return me->totcol - 1; } static void set_facetexture_flags(Material *ma, Image *image) @@ -1660,26 +1660,26 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) { Material *ma; char idname[MAX_ID_NAME]; - short mat_nr= -1; + short mat_nr = -1; /* new material, the name uses the flag*/ BLI_snprintf(idname, sizeof(idname), "MAMaterial.TF.%0*d", integer_getdigits(flag), flag); - if ((ma= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) { - mat_nr= mesh_getmaterialnumber(me, ma); + if ((ma = BLI_findstring(&main->mat, idname + 2, offsetof(ID, name) + 2))) { + mat_nr = mesh_getmaterialnumber(me, ma); /* assign the material to the mesh */ - if (mat_nr == -1) mat_nr= mesh_addmaterial(me, ma); + if (mat_nr == -1) mat_nr = mesh_addmaterial(me, ma); /* if needed set "Face Textures [Alpha]" Material options */ set_facetexture_flags(ma, tf->tpage); } /* create a new material */ else { - ma= add_material(idname+2); + ma = BKE_material_add(idname + 2); if (ma) { - printf("TexFace Convert: Material \"%s\" created.\n", idname+2); - mat_nr= mesh_addmaterial(me, ma); + printf("TexFace Convert: Material \"%s\" created.\n", idname + 2); + mat_nr = mesh_addmaterial(me, ma); /* if needed set "Face Textures [Alpha]" Material options */ set_facetexture_flags(ma, tf->tpage); @@ -1691,7 +1691,7 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag) ma->game.flag = -flag; id_us_min((ID *)ma); } - else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname+2, me->id.name+2); + else printf("Error: Unable to create Material \"%s\" for Mesh \"%s\".", idname + 2, me->id.name + 2); } /* set as converted, no need to go bad to this face */ @@ -1712,49 +1712,49 @@ static void convert_tfacematerial(Main *main, Material *ma) CustomDataLayer *cdl; char idname[MAX_ID_NAME]; - for (me=main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { /* check if this mesh uses this material */ - for (a=0;atotcol;a++) + for (a = 0; a < me->totcol; a++) if (me->mat[a] == ma) break; /* no material found */ if (a == me->totcol) continue; /* get the active tface layer */ - index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - cdl= (index == -1)? NULL: &me->fdata.layers[index]; + index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl = (index == -1) ? NULL : &me->fdata.layers[index]; if (!cdl) continue; /* loop over all the faces and stop at the ones that use the material*/ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (me->mat[mf->mat_nr] != ma) continue; /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; + tf = ((MTFace *)cdl->data) + a; flag = encode_tfaceflag(tf, 1); /* the name of the new material */ calculate_tface_materialname(ma->id.name, (char *)&idname, flag); - if ((mat_new= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) { + if ((mat_new = BLI_findstring(&main->mat, idname + 2, offsetof(ID, name) + 2))) { /* material already existent, see if the mesh has it */ mat_nr = mesh_getmaterialnumber(me, mat_new); /* material is not in the mesh, add it */ - if (mat_nr == -1) mat_nr= mesh_addmaterial(me, mat_new); + if (mat_nr == -1) mat_nr = mesh_addmaterial(me, mat_new); } /* create a new material */ else { - mat_new=copy_material(ma); + mat_new = BKE_material_copy(ma); if (mat_new) { /* rename the material*/ strcpy(mat_new->id.name, idname); id_us_min((ID *)mat_new); - mat_nr= mesh_addmaterial(me, mat_new); + mat_nr = mesh_addmaterial(me, mat_new); decode_tfaceflag(mat_new, flag, 1); } else { - printf("Error: Unable to create Material \"%s\" for Mesh \"%s.", idname+2, me->id.name+2); + printf("Error: Unable to create Material \"%s\" for Mesh \"%s.", idname + 2, me->id.name + 2); mat_nr = mf->mat_nr; continue; } @@ -1771,8 +1771,8 @@ static void convert_tfacematerial(Main *main, Material *ma) mf->mat_nr = mat_nr; } /* remove material from mesh */ - for (a=0;atotcol;) - if (me->mat[a] == ma) material_pop_id(&me->id, a, 1);else a++; + for (a = 0; a < me->totcol; ) + if (me->mat[a] == ma) material_pop_id(&me->id, a, 1); else a++; } } @@ -1806,20 +1806,20 @@ int do_version_tface(Main *main, int fileload) */ /* 1st part: marking mesh materials to update */ - for (me=main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { if (me->id.lib) continue; /* get the active tface layer */ - index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - cdl= (index == -1)? NULL: &me->fdata.layers[index]; + index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl = (index == -1) ? NULL : &me->fdata.layers[index]; if (!cdl) continue; - nomaterialslots = (me->totcol==0?1:0); + nomaterialslots = (me->totcol == 0 ? 1 : 0); /* loop over all the faces*/ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; + tf = ((MTFace *)cdl->data) + a; /* conversion should happen only once */ if (fileload) @@ -1835,7 +1835,7 @@ int do_version_tface(Main *main, int fileload) /* create/find a new material and assign to the face */ if (check_tfaceneedmaterial(flag)) { - mf->mat_nr= convert_tfacenomaterial(main, me, tf, flag); + mf->mat_nr = convert_tfacenomaterial(main, me, tf, flag); } /* else mark them as no-material to be reverted to 0 later */ else { @@ -1843,7 +1843,7 @@ int do_version_tface(Main *main, int fileload) } } else if (mf->mat_nr < me->totcol) { - ma= me->mat[mf->mat_nr]; + ma = me->mat[mf->mat_nr]; /* no material create one if necessary */ if (!ma) { @@ -1852,7 +1852,7 @@ int do_version_tface(Main *main, int fileload) /* create/find a new material and assign to the face */ if (check_tfaceneedmaterial(flag)) - mf->mat_nr= convert_tfacenomaterial(main, me, tf, flag); + mf->mat_nr = convert_tfacenomaterial(main, me, tf, flag); continue; } @@ -1870,11 +1870,11 @@ int do_version_tface(Main *main, int fileload) /* found a material */ else { - flag = encode_tfaceflag(tf, ((fileload)?0:1)); + flag = encode_tfaceflag(tf, ((fileload) ? 0 : 1)); /* first time changing this material */ if (ma->game.flag == 0) - ma->game.flag= -flag; + ma->game.flag = -flag; /* mark material as disputed */ else if (ma->game.flag != -flag) { @@ -1903,18 +1903,18 @@ int do_version_tface(Main *main, int fileload) /* if we didn't have material slot and now we do, we need to * make sure the materials are correct */ if (nomaterialslots) { - if (me->totcol>0) { - for (a=0, mf=me->mface; atotface; a++, mf++) { + if (me->totcol > 0) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (mf->mat_nr == -1) { /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; - mf->mat_nr= convert_tfacenomaterial(main, me, tf, encode_tfaceflag(tf, 1)); + tf = ((MTFace *)cdl->data) + a; + mf->mat_nr = convert_tfacenomaterial(main, me, tf, encode_tfaceflag(tf, 1)); } } } else { - for (a=0, mf=me->mface; atotface; a++, mf++) { - mf->mat_nr=0; + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { + mf->mat_nr = 0; } } } @@ -1925,14 +1925,14 @@ int do_version_tface(Main *main, int fileload) /* skip library files */ /* we shouldn't loop through the materials created in the loop. make the loop stop at its original length) */ - for (ma= main->mat.first, a=0; ma; ma= ma->id.next, a++) { + for (ma = main->mat.first, a = 0; ma; ma = ma->id.next, a++) { if (ma->id.lib) continue; /* disputed material */ if (ma->game.flag == MAT_BGE_DISPUTED) { ma->game.flag = 0; if (fileload) { - printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name+2); + printf("Warning: material \"%s\" skipped - to convert old game texface to material go to the Help menu.\n", ma->id.name + 2); nowarning = 0; } else @@ -1948,24 +1948,24 @@ int do_version_tface(Main *main, int fileload) /* material is good make sure all faces using * this material are set to converted */ if (fileload) { - for (me=main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { /* check if this mesh uses this material */ - for (a=0;atotcol;a++) + for (a = 0; a < me->totcol; a++) if (me->mat[a] == ma) break; /* no material found */ if (a == me->totcol) continue; /* get the active tface layer */ - index= CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); - cdl= (index == -1)? NULL: &me->fdata.layers[index]; + index = CustomData_get_active_layer_index(&me->fdata, CD_MTFACE); + cdl = (index == -1) ? NULL : &me->fdata.layers[index]; if (!cdl) continue; /* loop over all the faces and stop at the ones that use the material*/ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (me->mat[mf->mat_nr] == ma) { /* texface data for this face */ - tf = ((MTFace*)cdl->data) + a; + tf = ((MTFace *)cdl->data) + a; tf->mode |= TF_CONVERTED; } } diff --git a/source/blender/blenkernel/intern/mball.c b/source/blender/blenkernel/intern/mball.c index 8b2e66812c7..8075aaa21d3 100644 --- a/source/blender/blenkernel/intern/mball.c +++ b/source/blender/blenkernel/intern/mball.c @@ -67,67 +67,67 @@ /* Data types */ -typedef struct point { /* a three-dimensional point */ - float x, y, z; /* its coordinates */ +typedef struct point { /* a three-dimensional point */ + float x, y, z; /* its coordinates */ } MB_POINT; -typedef struct vertex { /* surface vertex */ - MB_POINT position, normal; /* position and surface normal */ +typedef struct vertex { /* surface vertex */ + MB_POINT position, normal; /* position and surface normal */ } VERTEX; -typedef struct vertices { /* list of vertices in polygonization */ - int count, max; /* # vertices, max # allowed */ - VERTEX *ptr; /* dynamically allocated */ +typedef struct vertices { /* list of vertices in polygonization */ + int count, max; /* # vertices, max # allowed */ + VERTEX *ptr; /* dynamically allocated */ } VERTICES; -typedef struct corner { /* corner of a cube */ - int i, j, k; /* (i, j, k) is index within lattice */ - float x, y, z, value; /* location and function value */ +typedef struct corner { /* corner of a cube */ + int i, j, k; /* (i, j, k) is index within lattice */ + float x, y, z, value; /* location and function value */ struct corner *next; } CORNER; -typedef struct cube { /* partitioning cell (cube) */ - int i, j, k; /* lattice location of cube */ - CORNER *corners[8]; /* eight corners */ +typedef struct cube { /* partitioning cell (cube) */ + int i, j, k; /* lattice location of cube */ + CORNER *corners[8]; /* eight corners */ } CUBE; -typedef struct cubes { /* linked list of cubes acting as stack */ - CUBE cube; /* a single cube */ - struct cubes *next; /* remaining elements */ +typedef struct cubes { /* linked list of cubes acting as stack */ + CUBE cube; /* a single cube */ + struct cubes *next; /* remaining elements */ } CUBES; -typedef struct centerlist { /* list of cube locations */ - int i, j, k; /* cube location */ - struct centerlist *next; /* remaining elements */ +typedef struct centerlist { /* list of cube locations */ + int i, j, k; /* cube location */ + struct centerlist *next; /* remaining elements */ } CENTERLIST; -typedef struct edgelist { /* list of edges */ - int i1, j1, k1, i2, j2, k2; /* edge corner ids */ - int vid; /* vertex id */ - struct edgelist *next; /* remaining elements */ +typedef struct edgelist { /* list of edges */ + int i1, j1, k1, i2, j2, k2; /* edge corner ids */ + int vid; /* vertex id */ + struct edgelist *next; /* remaining elements */ } EDGELIST; -typedef struct intlist { /* list of integers */ - int i; /* an integer */ - struct intlist *next; /* remaining elements */ +typedef struct intlist { /* list of integers */ + int i; /* an integer */ + struct intlist *next; /* remaining elements */ } INTLIST; -typedef struct intlists { /* list of list of integers */ - INTLIST *list; /* a list of integers */ - struct intlists *next; /* remaining elements */ +typedef struct intlists { /* list of list of integers */ + INTLIST *list; /* a list of integers */ + struct intlists *next; /* remaining elements */ } INTLISTS; -typedef struct process { /* parameters, function, storage */ +typedef struct process { /* parameters, function, storage */ /* what happens here? floats, I think. */ /* float (*function)(void); */ /* implicit surface function */ float (*function)(float, float, float); - float size, delta; /* cube size, normal delta */ - int bounds; /* cube range within lattice */ - CUBES *cubes; /* active cubes */ - VERTICES vertices; /* surface vertices */ - CENTERLIST **centers; /* cube center hash table */ - CORNER **corners; /* corner value hash table */ - EDGELIST **edges; /* edge and vertex id hash table */ + float size, delta; /* cube size, normal delta */ + int bounds; /* cube range within lattice */ + CUBES *cubes; /* active cubes */ + VERTICES vertices; /* surface vertices */ + CENTERLIST **centers; /* cube center hash table */ + CORNER **corners; /* corner value hash table */ + EDGELIST **edges; /* edge and vertex id hash table */ } PROCESS; /* dividing scene using octal tree makes polygonisation faster */ @@ -137,20 +137,20 @@ typedef struct ml_pointer { } ml_pointer; typedef struct octal_node { - struct octal_node *nodes[8]; /* children of current node */ - struct octal_node *parent; /* parent of current node */ - struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ - float x_min, y_min, z_min; /* 1st border point */ - float x_max, y_max, z_max; /* 7th border point */ - float x, y, z; /* center of node */ - int pos, neg; /* number of positive and negative MetaElements in the node */ - int count; /* number of MetaElems, which belongs to the node */ + struct octal_node *nodes[8];/* children of current node */ + struct octal_node *parent; /* parent of current node */ + struct ListBase elems; /* ListBase of MetaElem pointers (ml_pointer) */ + float x_min, y_min, z_min; /* 1st border point */ + float x_max, y_max, z_max; /* 7th border point */ + float x, y, z; /* center of node */ + int pos, neg; /* number of positive and negative MetaElements in the node */ + int count; /* number of MetaElems, which belongs to the node */ } octal_node; typedef struct octal_tree { - struct octal_node *first; /* first node */ - int pos, neg; /* number of positive and negative MetaElements in the scene */ - short depth; /* number of scene subdivision */ + struct octal_node *first; /* first node */ + int pos, neg; /* number of positive and negative MetaElements in the scene */ + short depth; /* number of scene subdivision */ } octal_tree; struct pgn_elements { @@ -161,33 +161,33 @@ struct pgn_elements { /* Forward declarations */ static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb); static int setcenter(CENTERLIST *table[], int i, int j, int k); -static CORNER *setcorner(PROCESS* p, int i, int j, int k); -static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, - float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f); +static CORNER *setcorner(PROCESS *p, int i, int j, int k); +static void converge(MB_POINT *p1, MB_POINT *p2, float v1, float v2, + float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f); /* Global variables */ -static float thresh= 0.6f; -static int totelem=0; +static float thresh = 0.6f; +static int totelem = 0; static MetaElem **mainb; static octal_tree *metaball_tree = NULL; /* Functions */ -void BKE_metaball_unlink(MetaBall *mb) +void BKE_mball_unlink(MetaBall *mb) { int a; - for (a=0; atotcol; a++) { + for (a = 0; a < mb->totcol; a++) { if (mb->mat[a]) mb->mat[a]->id.us--; - mb->mat[a]= NULL; + mb->mat[a] = NULL; } } /* do not free mball itself */ -void BKE_metaball_free(MetaBall *mb) +void BKE_mball_free(MetaBall *mb) { - BKE_metaball_unlink(mb); + BKE_mball_unlink(mb); if (mb->adt) { BKE_free_animdata((ID *)mb); @@ -196,42 +196,42 @@ void BKE_metaball_free(MetaBall *mb) if (mb->mat) MEM_freeN(mb->mat); if (mb->bb) MEM_freeN(mb->bb); BLI_freelistN(&mb->elems); - if (mb->disp.first) freedisplist(&mb->disp); + if (mb->disp.first) BKE_displist_free(&mb->disp); } -MetaBall *BKE_metaball_add(const char *name) +MetaBall *BKE_mball_add(const char *name) { MetaBall *mb; - mb= alloc_libblock(&G.main->mball, ID_MB, name); + mb = BKE_libblock_alloc(&G.main->mball, ID_MB, name); - mb->size[0]= mb->size[1]= mb->size[2]= 1.0; - mb->texflag= MB_AUTOSPACE; + mb->size[0] = mb->size[1] = mb->size[2] = 1.0; + mb->texflag = MB_AUTOSPACE; - mb->wiresize= 0.4f; - mb->rendersize= 0.2f; - mb->thresh= 0.6f; + mb->wiresize = 0.4f; + mb->rendersize = 0.2f; + mb->thresh = 0.6f; return mb; } -MetaBall *BKE_metaball_copy(MetaBall *mb) +MetaBall *BKE_mball_copy(MetaBall *mb) { MetaBall *mbn; int a; - mbn= copy_libblock(&mb->id); + mbn = BKE_libblock_copy(&mb->id); BLI_duplicatelist(&mbn->elems, &mb->elems); - mbn->mat= MEM_dupallocN(mb->mat); - for (a=0; atotcol; a++) { + mbn->mat = MEM_dupallocN(mb->mat); + for (a = 0; a < mbn->totcol; a++) { id_us_plus((ID *)mbn->mat[a]); } - mbn->bb= MEM_dupallocN(mb->bb); + mbn->bb = MEM_dupallocN(mb->bb); - mbn->editelems= NULL; - mbn->lastelem= NULL; + mbn->editelems = NULL; + mbn->lastelem = NULL; return mbn; } @@ -243,29 +243,29 @@ static void extern_local_mball(MetaBall *mb) } } -void BKE_metaball_make_local(MetaBall *mb) +void BKE_mball_make_local(MetaBall *mb) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (mb->id.lib==NULL) return; - if (mb->id.us==1) { + if (mb->id.lib == NULL) return; + if (mb->id.us == 1) { id_clear_lib_data(bmain, &mb->id); extern_local_mball(mb); return; } - for (ob= G.main->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + for (ob = G.main->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { if (ob->data == mb) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -274,16 +274,16 @@ void BKE_metaball_make_local(MetaBall *mb) extern_local_mball(mb); } else if (is_local && is_lib) { - MetaBall *mb_new= BKE_metaball_copy(mb); - mb_new->id.us= 0; + MetaBall *mb_new = BKE_mball_copy(mb); + mb_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, mb->id.lib, &mb_new->id); - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { if (ob->data == mb) { - if (ob->id.lib==NULL) { - ob->data= mb_new; + if (ob->id.lib == NULL) { + ob->data = mb_new; mb_new->id.us++; mb->id.us--; } @@ -294,46 +294,46 @@ void BKE_metaball_make_local(MetaBall *mb) /* most simple meta-element adding function * don't do context manipulation here (rna uses) */ -MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) +MetaElem *BKE_mball_element_add(MetaBall *mb, const int type) { - MetaElem *ml= MEM_callocN(sizeof(MetaElem), "metaelem"); + MetaElem *ml = MEM_callocN(sizeof(MetaElem), "metaelem"); unit_qt(ml->quat); - ml->rad= 2.0; - ml->s= 2.0; - ml->flag= MB_SCALE_RAD; + ml->rad = 2.0; + ml->s = 2.0; + ml->flag = MB_SCALE_RAD; switch (type) { - case MB_BALL: - ml->type = MB_BALL; - ml->expx= ml->expy= ml->expz= 1.0; + case MB_BALL: + ml->type = MB_BALL; + ml->expx = ml->expy = ml->expz = 1.0; - break; - case MB_TUBE: - ml->type = MB_TUBE; - ml->expx= ml->expy= ml->expz= 1.0; + break; + case MB_TUBE: + ml->type = MB_TUBE; + ml->expx = ml->expy = ml->expz = 1.0; - break; - case MB_PLANE: - ml->type = MB_PLANE; - ml->expx= ml->expy= ml->expz= 1.0; + break; + case MB_PLANE: + ml->type = MB_PLANE; + ml->expx = ml->expy = ml->expz = 1.0; - break; - case MB_ELIPSOID: - ml->type = MB_ELIPSOID; - ml->expx= 1.2f; - ml->expy= 0.8f; - ml->expz= 1.0; - - break; - case MB_CUBE: - ml->type = MB_CUBE; - ml->expx= ml->expy= ml->expz= 1.0; + break; + case MB_ELIPSOID: + ml->type = MB_ELIPSOID; + ml->expx = 1.2f; + ml->expy = 0.8f; + ml->expz = 1.0; - break; - default: - break; + break; + case MB_CUBE: + ml->type = MB_CUBE; + ml->expx = ml->expy = ml->expz = 1.0; + + break; + default: + break; } BLI_addtail(&mb->elems, ml); @@ -346,32 +346,32 @@ MetaElem *BKE_metaball_element_add(MetaBall *mb, const int type) * basic MetaBall (usually with name Meta). All other MetaBalls (with * names Meta.001, Meta.002, etc) are included in this Bounding Box. */ -void BKE_metaball_tex_space_calc(Object *ob) +void BKE_mball_texspace_calc(Object *ob) { DispList *dl; BoundBox *bb; float *data, min[3], max[3] /*, loc[3], size[3] */; - int tot, doit=0; + int tot, doit = 0; - if (ob->bb==NULL) ob->bb= MEM_callocN(sizeof(BoundBox), "mb boundbox"); - bb= ob->bb; + if (ob->bb == NULL) ob->bb = MEM_callocN(sizeof(BoundBox), "mb boundbox"); + bb = ob->bb; /* Weird one, this. */ -/* INIT_MINMAX(min, max); */ - (min)[0]= (min)[1]= (min)[2]= 1.0e30f; - (max)[0]= (max)[1]= (max)[2]= -1.0e30f; +/* INIT_MINMAX(min, max); */ + (min)[0] = (min)[1] = (min)[2] = 1.0e30f; + (max)[0] = (max)[1] = (max)[2] = -1.0e30f; - dl= ob->disp.first; + dl = ob->disp.first; while (dl) { - tot= dl->nr; - if (tot) doit= 1; - data= dl->verts; + tot = dl->nr; + if (tot) doit = 1; + data = dl->verts; while (tot--) { /* Also weird... but longer. From utildefines. */ DO_MINMAX(data, min, max); - data+= 3; + data += 3; } - dl= dl->next; + dl = dl->next; } if (!doit) { @@ -379,18 +379,18 @@ void BKE_metaball_tex_space_calc(Object *ob) max[0] = max[1] = max[2] = 1.0f; } #if 0 - loc[0]= (min[0]+max[0])/2.0f; - loc[1]= (min[1]+max[1])/2.0f; - loc[2]= (min[2]+max[2])/2.0f; - - size[0]= (max[0]-min[0])/2.0f; - size[1]= (max[1]-min[1])/2.0f; - size[2]= (max[2]-min[2])/2.0f; + loc[0] = (min[0] + max[0]) / 2.0f; + loc[1] = (min[1] + max[1]) / 2.0f; + loc[2] = (min[2] + max[2]) / 2.0f; + + size[0] = (max[0] - min[0]) / 2.0f; + size[1] = (max[1] - min[1]) / 2.0f; + size[2] = (max[2] - min[2]) / 2.0f; #endif - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } -float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) +float *BKE_mball_make_orco(Object *ob, ListBase *dispbase) { BoundBox *bb; DispList *dl; @@ -399,27 +399,27 @@ float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) int a; /* restore size and loc */ - bb= ob->bb; - loc[0]= (bb->vec[0][0]+bb->vec[4][0])/2.0f; - size[0]= bb->vec[4][0]-loc[0]; - loc[1]= (bb->vec[0][1]+bb->vec[2][1])/2.0f; - size[1]= bb->vec[2][1]-loc[1]; - loc[2]= (bb->vec[0][2]+bb->vec[1][2])/2.0f; - size[2]= bb->vec[1][2]-loc[2]; + bb = ob->bb; + loc[0] = (bb->vec[0][0] + bb->vec[4][0]) / 2.0f; + size[0] = bb->vec[4][0] - loc[0]; + loc[1] = (bb->vec[0][1] + bb->vec[2][1]) / 2.0f; + size[1] = bb->vec[2][1] - loc[1]; + loc[2] = (bb->vec[0][2] + bb->vec[1][2]) / 2.0f; + size[2] = bb->vec[1][2] - loc[2]; - dl= dispbase->first; - orcodata= MEM_mallocN(sizeof(float)*3*dl->nr, "MballOrco"); + dl = dispbase->first; + orcodata = MEM_mallocN(sizeof(float) * 3 * dl->nr, "MballOrco"); - data= dl->verts; - orco= orcodata; - a= dl->nr; + data = dl->verts; + orco = orcodata; + a = dl->nr; while (a--) { - orco[0]= (data[0]-loc[0])/size[0]; - orco[1]= (data[1]-loc[1])/size[1]; - orco[2]= (data[2]-loc[2])/size[2]; + orco[0] = (data[0] - loc[0]) / size[0]; + orco[1] = (data[1] - loc[1]) / size[1]; + orco[2] = (data[2] - loc[2]) / size[2]; - data+= 3; - orco+= 3; + data += 3; + orco += 3; } return orcodata; @@ -442,26 +442,26 @@ float *BKE_metaball_make_orco(Object *ob, ListBase *dispbase) * It test last character of Object ID name. If last character * is digit it return 0, else it return 1. */ -int BKE_metaball_is_basis(Object *ob) +int BKE_mball_is_basis(Object *ob) { int len; /* just a quick test */ - len= strlen(ob->id.name); - if ( isdigit(ob->id.name[len-1]) ) return 0; + len = strlen(ob->id.name); + if (isdigit(ob->id.name[len - 1]) ) return 0; return 1; } /* return nonzero if ob1 is a basis mball for ob */ -int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) +int BKE_mball_is_basis_for(Object *ob1, Object *ob2) { int basis1nr, basis2nr; char basis1name[MAX_ID_NAME], basis2name[MAX_ID_NAME]; - BLI_split_name_num(basis1name, &basis1nr, ob1->id.name+2, '.'); - BLI_split_name_num(basis2name, &basis2nr, ob2->id.name+2, '.'); + BLI_split_name_num(basis1name, &basis1nr, ob1->id.name + 2, '.'); + BLI_split_name_num(basis2name, &basis2nr, ob2->id.name + 2, '.'); - if (!strcmp(basis1name, basis2name)) return BKE_metaball_is_basis(ob1); + if (!strcmp(basis1name, basis2name)) return BKE_mball_is_basis(ob1); else return 0; } @@ -471,36 +471,36 @@ int BKE_metaball_is_basis_for(Object *ob1, Object *ob2) * are copied to all metaballs in same "group" (metaballs with same base name: MBall, * MBall.001, MBall.002, etc). The most important is to copy properties to the base metaball, * because this metaball influence polygonisation of metaballs. */ -void BKE_metaball_properties_copy(Scene *scene, Object *active_object) +void BKE_mball_properties_copy(Scene *scene, Object *active_object) { - Scene *sce_iter= scene; + Scene *sce_iter = scene; Base *base; Object *ob; - MetaBall *active_mball = (MetaBall*)active_object->data; + MetaBall *active_mball = (MetaBall *)active_object->data; int basisnr, obnr; char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; - BLI_split_name_num(basisname, &basisnr, active_object->id.name+2, '.'); + BLI_split_name_num(basisname, &basisnr, active_object->id.name + 2, '.'); - /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL)) + /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */ + if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL)) return; - while (next_object(&sce_iter, 1, &base, &ob)) { - if (ob->type==OB_MBALL) { + while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) { + if (ob->type == OB_MBALL) { if (ob != active_object) { - BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); + BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* Object ob has to be in same "group" ... it means, that it has to have * same base of its name */ - if (strcmp(obname, basisname)==0) { - MetaBall *mb= ob->data; + if (strcmp(obname, basisname) == 0) { + MetaBall *mb = ob->data; /* Copy properties from selected/edited metaball */ - mb->wiresize= active_mball->wiresize; - mb->rendersize= active_mball->rendersize; - mb->thresh= active_mball->thresh; - mb->flag= active_mball->flag; + mb->wiresize = active_mball->wiresize; + mb->rendersize = active_mball->rendersize; + mb->thresh = active_mball->thresh; + mb->flag = active_mball->flag; } } } @@ -516,52 +516,52 @@ void BKE_metaball_properties_copy(Scene *scene, Object *active_object) * * warning!, is_basis_mball() can fail on returned object, see long note above. */ -Object *BKE_metaball_basis_find(Scene *scene, Object *basis) +Object *BKE_mball_basis_find(Scene *scene, Object *basis) { - Scene *sce_iter= scene; + Scene *sce_iter = scene; Base *base; - Object *ob, *bob= basis; - MetaElem *ml=NULL; + Object *ob, *bob = basis; + MetaElem *ml = NULL; int basisnr, obnr; char basisname[MAX_ID_NAME], obname[MAX_ID_NAME]; - BLI_split_name_num(basisname, &basisnr, basis->id.name+2, '.'); - totelem= 0; + BLI_split_name_num(basisname, &basisnr, basis->id.name + 2, '.'); + totelem = 0; - /* XXX recursion check, see scene.c, just too simple code this next_object() */ - if (F_ERROR==next_object(&sce_iter, 0, NULL, NULL)) + /* XXX recursion check, see scene.c, just too simple code this BKE_scene_base_iter_next() */ + if (F_ERROR == BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL)) return NULL; - while (next_object(&sce_iter, 1, &base, &ob)) { + while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &ob)) { - if (ob->type==OB_MBALL) { - if (ob==bob) { - MetaBall *mb= ob->data; + if (ob->type == OB_MBALL) { + if (ob == bob) { + MetaBall *mb = ob->data; /* if bob object is in edit mode, then dynamic list of all MetaElems * is stored in editelems */ - if (mb->editelems) ml= mb->editelems->first; + if (mb->editelems) ml = mb->editelems->first; /* if bob object is in object mode */ - else ml= mb->elems.first; + else ml = mb->elems.first; } else { - BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); + BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* object ob has to be in same "group" ... it means, that it has to have * same base of its name */ - if (strcmp(obname, basisname)==0) { - MetaBall *mb= ob->data; + if (strcmp(obname, basisname) == 0) { + MetaBall *mb = ob->data; /* if object is in edit mode, then dynamic list of all MetaElems * is stored in editelems */ - if (mb->editelems) ml= mb->editelems->first; + if (mb->editelems) ml = mb->editelems->first; /* if bob object is in object mode */ - else ml= mb->elems.first; + else ml = mb->elems.first; if (obnr < basisnr) { if (!(ob->flag & OB_FROMDUPLI)) { - basis= ob; - basisnr= obnr; + basis = ob; + basisnr = obnr; } } } @@ -569,7 +569,7 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) while (ml) { if (!(ml->flag & MB_HIDE)) totelem++; - ml= ml->next; + ml = ml->next; } } } @@ -591,33 +591,33 @@ Object *BKE_metaball_basis_find(Scene *scene, Object *basis) * Permission is granted to reproduce, use and distribute this code for * any and all purposes, provided that this notice appears in all copies. */ -#define RES 12 /* # converge iterations */ +#define RES 12 /* # converge iterations */ -#define L 0 /* left direction: -x, -i */ -#define R 1 /* right direction: +x, +i */ -#define B 2 /* bottom direction: -y, -j */ -#define T 3 /* top direction: +y, +j */ -#define N 4 /* near direction: -z, -k */ -#define F 5 /* far direction: +z, +k */ -#define LBN 0 /* left bottom near corner */ -#define LBF 1 /* left bottom far corner */ -#define LTN 2 /* left top near corner */ -#define LTF 3 /* left top far corner */ -#define RBN 4 /* right bottom near corner */ -#define RBF 5 /* right bottom far corner */ -#define RTN 6 /* right top near corner */ -#define RTF 7 /* right top far corner */ +#define L 0 /* left direction: -x, -i */ +#define R 1 /* right direction: +x, +i */ +#define B 2 /* bottom direction: -y, -j */ +#define T 3 /* top direction: +y, +j */ +#define N 4 /* near direction: -z, -k */ +#define F 5 /* far direction: +z, +k */ +#define LBN 0 /* left bottom near corner */ +#define LBF 1 /* left bottom far corner */ +#define LTN 2 /* left top near corner */ +#define LTF 3 /* left top far corner */ +#define RBN 4 /* right bottom near corner */ +#define RBF 5 /* right bottom far corner */ +#define RTN 6 /* right top near corner */ +#define RTF 7 /* right top far corner */ /* the LBN corner of cube (i, j, k), corresponds with location * (i-0.5)*size, (j-0.5)*size, (k-0.5)*size) */ -#define HASHBIT (5) -#define HASHSIZE (size_t)(1<<(3*HASHBIT)) /*! < hash table size (32768) */ +#define HASHBIT (5) +#define HASHSIZE (size_t)(1 << (3 * HASHBIT)) /*! < hash table size (32768) */ -#define HASH(i, j, k) ((((( (i) & 31)<<5) | ( (j) & 31))<<5 ) | ( (k) & 31) ) +#define HASH(i, j, k) ((((( (i) & 31) << 5) | ( (j) & 31)) << 5) | ( (k) & 31) ) -#define MB_BIT(i, bit) (((i)>>(bit))&1) -#define FLIP(i, bit) ((i)^1<<(bit)) /* flip the given bit of i */ +#define MB_BIT(i, bit) (((i) >> (bit)) & 1) +#define FLIP(i, bit) ((i) ^ 1 << (bit)) /* flip the given bit of i */ /* **************** POLYGONIZATION ************************ */ @@ -634,78 +634,78 @@ static float densfunc(MetaElem *ball, float x, float y, float z) float dist2 = 0.0, dx, dy, dz; float vec[3]; - vec[0]= x; - vec[1]= y; - vec[2]= z; + vec[0] = x; + vec[1] = y; + vec[2] = z; mul_m4_v3((float (*)[4])ball->imat, vec); - dx= vec[0]; - dy= vec[1]; - dz= vec[2]; - - if (ball->type==MB_BALL) { + dx = vec[0]; + dy = vec[1]; + dz = vec[2]; + + if (ball->type == MB_BALL) { } - else if (ball->type==MB_TUBEX) { - if ( dx > ball->len) dx-= ball->len; - else if (dx< -ball->len) dx+= ball->len; - else dx= 0.0; + else if (ball->type == MB_TUBEX) { + if (dx > ball->len) dx -= ball->len; + else if (dx < -ball->len) dx += ball->len; + else dx = 0.0; } - else if (ball->type==MB_TUBEY) { - if ( dy > ball->len) dy-= ball->len; - else if (dy< -ball->len) dy+= ball->len; - else dy= 0.0; + else if (ball->type == MB_TUBEY) { + if (dy > ball->len) dy -= ball->len; + else if (dy < -ball->len) dy += ball->len; + else dy = 0.0; } - else if (ball->type==MB_TUBEZ) { - if ( dz > ball->len) dz-= ball->len; - else if (dz< -ball->len) dz+= ball->len; - else dz= 0.0; + else if (ball->type == MB_TUBEZ) { + if (dz > ball->len) dz -= ball->len; + else if (dz < -ball->len) dz += ball->len; + else dz = 0.0; } - else if (ball->type==MB_TUBE) { - if ( dx > ball->expx) dx-= ball->expx; - else if (dx< -ball->expx) dx+= ball->expx; - else dx= 0.0; + else if (ball->type == MB_TUBE) { + if (dx > ball->expx) dx -= ball->expx; + else if (dx < -ball->expx) dx += ball->expx; + else dx = 0.0; } - else if (ball->type==MB_PLANE) { - if ( dx > ball->expx) dx-= ball->expx; - else if (dx< -ball->expx) dx+= ball->expx; - else dx= 0.0; - if ( dy > ball->expy) dy-= ball->expy; - else if (dy< -ball->expy) dy+= ball->expy; - else dy= 0.0; + else if (ball->type == MB_PLANE) { + if (dx > ball->expx) dx -= ball->expx; + else if (dx < -ball->expx) dx += ball->expx; + else dx = 0.0; + if (dy > ball->expy) dy -= ball->expy; + else if (dy < -ball->expy) dy += ball->expy; + else dy = 0.0; } - else if (ball->type==MB_ELIPSOID) { - dx *= 1/ball->expx; - dy *= 1/ball->expy; - dz *= 1/ball->expz; + else if (ball->type == MB_ELIPSOID) { + dx *= 1 / ball->expx; + dy *= 1 / ball->expy; + dz *= 1 / ball->expz; } - else if (ball->type==MB_CUBE) { - if ( dx > ball->expx) dx-= ball->expx; - else if (dx< -ball->expx) dx+= ball->expx; - else dx= 0.0; - if ( dy > ball->expy) dy-= ball->expy; - else if (dy< -ball->expy) dy+= ball->expy; - else dy= 0.0; - if ( dz > ball->expz) dz-= ball->expz; - else if (dz< -ball->expz) dz+= ball->expz; - else dz= 0.0; + else if (ball->type == MB_CUBE) { + if (dx > ball->expx) dx -= ball->expx; + else if (dx < -ball->expx) dx += ball->expx; + else dx = 0.0; + if (dy > ball->expy) dy -= ball->expy; + else if (dy < -ball->expy) dy += ball->expy; + else dy = 0.0; + if (dz > ball->expz) dz -= ball->expz; + else if (dz < -ball->expz) dz += ball->expz; + else dz = 0.0; } - dist2= (dx*dx + dy*dy + dz*dz); + dist2 = (dx * dx + dy * dy + dz * dz); if (ball->flag & MB_NEGATIVE) { - dist2= 1.0f-(dist2/ball->rad2); + dist2 = 1.0f - (dist2 / ball->rad2); if (dist2 < 0.0f) return 0.5f; - return 0.5f-ball->s*dist2*dist2*dist2; + return 0.5f - ball->s * dist2 * dist2 * dist2; } else { - dist2= 1.0f-(dist2/ball->rad2); + dist2 = 1.0f - (dist2 / ball->rad2); if (dist2 < 0.0f) return -0.5f; - return ball->s*dist2*dist2*dist2 -0.5f; + return ball->s * dist2 * dist2 * dist2 - 0.5f; } } -static octal_node* find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth) +static octal_node *find_metaball_octal_node(octal_node *node, float x, float y, float z, short depth) { if (!depth) return node; @@ -778,24 +778,24 @@ static float metaball(float x, float y, float z) { struct octal_node *node; struct ml_pointer *ml_p; - float dens=0; + float dens = 0; int a; if (totelem > 1) { - node= find_metaball_octal_node(metaball_tree->first, x, y, z, metaball_tree->depth); + node = find_metaball_octal_node(metaball_tree->first, x, y, z, metaball_tree->depth); if (node) { - ml_p= node->elems.first; + ml_p = node->elems.first; while (ml_p) { - dens+=densfunc(ml_p->ml, x, y, z); - ml_p= ml_p->next; + dens += densfunc(ml_p->ml, x, y, z); + ml_p = ml_p->next; } - dens+= -0.5f*(metaball_tree->pos - node->pos); - dens+= 0.5f*(metaball_tree->neg - node->neg); + dens += -0.5f * (metaball_tree->pos - node->pos); + dens += 0.5f * (metaball_tree->neg - node->neg); } else { - for (a=0; a10000 || size==0) { + if (size > 10000 || size == 0) { printf("incorrect use of new_pgn_element\n"); } - else if (size== -1) { - cur= lb.first; + else if (size == -1) { + cur = lb.first; while (cur) { MEM_freeN(cur->data); - cur= cur->next; + cur = cur->next; } BLI_freelistN(&lb); return NULL; } - size= 4*( (size+3)/4 ); + size = 4 * ( (size + 3) / 4); if (cur) { - if (size+offs < blocksize) { - adr= (void *) (cur->data+offs); - offs+= size; + if (size + offs < blocksize) { + adr = (void *) (cur->data + offs); + offs += size; return adr; } } - cur= MEM_callocN(sizeof(struct pgn_elements), "newpgn"); - cur->data= MEM_callocN(blocksize, "newpgn"); + cur = MEM_callocN(sizeof(struct pgn_elements), "newpgn"); + cur->data = MEM_callocN(blocksize, "newpgn"); BLI_addtail(&lb, cur); - offs= size; + offs = size; return cur->data; } @@ -902,31 +902,35 @@ static void freepolygonize(PROCESS *p) /**** Cubical Polygonization (optional) ****/ -#define LB 0 /* left bottom edge */ -#define LT 1 /* left top edge */ -#define LN 2 /* left near edge */ -#define LF 3 /* left far edge */ -#define RB 4 /* right bottom edge */ -#define RT 5 /* right top edge */ -#define RN 6 /* right near edge */ -#define RF 7 /* right far edge */ -#define BN 8 /* bottom near edge */ -#define BF 9 /* bottom far edge */ -#define TN 10 /* top near edge */ -#define TF 11 /* top far edge */ +#define LB 0 /* left bottom edge */ +#define LT 1 /* left top edge */ +#define LN 2 /* left near edge */ +#define LF 3 /* left far edge */ +#define RB 4 /* right bottom edge */ +#define RT 5 /* right top edge */ +#define RN 6 /* right near edge */ +#define RF 7 /* right far edge */ +#define BN 8 /* bottom near edge */ +#define BF 9 /* bottom far edge */ +#define TN 10 /* top near edge */ +#define TF 11 /* top far edge */ static INTLISTS *cubetable[256]; /* edge: LB, LT, LN, LF, RB, RT, RN, RF, BN, BF, TN, TF */ -static int corner1[12] = { - LBN, LTN, LBN, LBF, RBN, RTN, RBN, RBF, LBN, LBF, LTN, LTF}; -static int corner2[12] = { - LBF, LTF, LTN, LTF, RBF, RTF, RTN, RTF, RBN, RBF, RTN, RTF}; -static int leftface[12] = { - B, L, L, F, R, T, N, R, N, B, T, F}; +static int corner1[12] = { + LBN, LTN, LBN, LBF, RBN, RTN, RBN, RBF, LBN, LBF, LTN, LTF +}; +static int corner2[12] = { + LBF, LTF, LTN, LTF, RBF, RTF, RTN, RTF, RBN, RBF, RTN, RTF +}; +static int leftface[12] = { + B, L, L, F, R, T, N, R, N, B, T, F +}; /* face on left when going corner1 to corner2 */ -static int rightface[12] = { - L, T, N, L, B, R, R, F, B, F, N, T}; +static int rightface[12] = { + L, T, N, L, B, R, R, F, B, F, N, T +}; /* face on right when going corner1 to corner2 */ @@ -938,7 +942,7 @@ static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) CORNER *c1, *c2; int i, index = 0, count, indexar[8]; - for (i = 0; i < 8; i++) if (cube->corners[i]->value > 0.0f) index += (1<corners[i]->value > 0.0f) index += (1 << i); for (polys = cubetable[index]; polys; polys = polys->next) { INTLIST *edges; @@ -952,44 +956,44 @@ static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) indexar[count] = vertid(c1, c2, p, mb); count++; } - if (count>2) { + if (count > 2) { switch (count) { - case 3: - accum_mballfaces(indexar[2], indexar[1], indexar[0], 0); - break; - case 4: - if (indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); - break; - case 5: - if (indexar[0]==0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + case 3: + accum_mballfaces(indexar[2], indexar[1], indexar[0], 0); + break; + case 4: + if (indexar[0] == 0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + break; + case 5: + if (indexar[0] == 0) accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + else accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + + accum_mballfaces(indexar[4], indexar[3], indexar[0], 0); + break; + case 6: + if (indexar[0] == 0) { + accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); + } + else { + accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); + } + break; + case 7: + if (indexar[0] == 0) { + accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); + accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); + } + else { + accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); + accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); + } + + accum_mballfaces(indexar[6], indexar[5], indexar[0], 0); - accum_mballfaces(indexar[4], indexar[3], indexar[0], 0); - break; - case 6: - if (indexar[0]==0) { - accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); - } - else { - accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); - accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); - } - break; - case 7: - if (indexar[0]==0) { - accum_mballfaces(indexar[0], indexar[3], indexar[2], indexar[1]); - accum_mballfaces(indexar[0], indexar[5], indexar[4], indexar[3]); - } - else { - accum_mballfaces(indexar[3], indexar[2], indexar[1], indexar[0]); - accum_mballfaces(indexar[5], indexar[4], indexar[3], indexar[0]); - } - - accum_mballfaces(indexar[6], indexar[5], indexar[0], 0); - - break; + break; } } } @@ -1000,17 +1004,17 @@ static void docube(CUBE *cube, PROCESS *p, MetaBall *mb) * if surface crosses face, compute other four corners of adjacent cube * and add new cube to cube stack */ -static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, int c3, int c4, PROCESS *p) +static void testface(int i, int j, int k, CUBE *old, int bit, int c1, int c2, int c3, int c4, PROCESS *p) { CUBE newc; CUBES *oldcubes = p->cubes; CORNER *corn1, *corn2, *corn3, *corn4; int n, pos; - corn1= old->corners[c1]; - corn2= old->corners[c2]; - corn3= old->corners[c3]; - corn4= old->corners[c4]; + corn1 = old->corners[c1]; + corn2 = old->corners[c2]; + corn3 = old->corners[c3]; + corn4 = old->corners[c4]; pos = corn1->value > 0.0f ? 1 : 0; @@ -1036,22 +1040,22 @@ static void testface(int i, int j, int k, CUBE* old, int bit, int c1, int c2, in newc.corners[FLIP(c3, bit)] = corn3; newc.corners[FLIP(c4, bit)] = corn4; - if (newc.corners[0]==NULL) newc.corners[0] = setcorner(p, i, j, k); - if (newc.corners[1]==NULL) newc.corners[1] = setcorner(p, i, j, k+1); - if (newc.corners[2]==NULL) newc.corners[2] = setcorner(p, i, j+1, k); - if (newc.corners[3]==NULL) newc.corners[3] = setcorner(p, i, j+1, k+1); - if (newc.corners[4]==NULL) newc.corners[4] = setcorner(p, i+1, j, k); - if (newc.corners[5]==NULL) newc.corners[5] = setcorner(p, i+1, j, k+1); - if (newc.corners[6]==NULL) newc.corners[6] = setcorner(p, i+1, j+1, k); - if (newc.corners[7]==NULL) newc.corners[7] = setcorner(p, i+1, j+1, k+1); + if (newc.corners[0] == NULL) newc.corners[0] = setcorner(p, i, j, k); + if (newc.corners[1] == NULL) newc.corners[1] = setcorner(p, i, j, k + 1); + if (newc.corners[2] == NULL) newc.corners[2] = setcorner(p, i, j + 1, k); + if (newc.corners[3] == NULL) newc.corners[3] = setcorner(p, i, j + 1, k + 1); + if (newc.corners[4] == NULL) newc.corners[4] = setcorner(p, i + 1, j, k); + if (newc.corners[5] == NULL) newc.corners[5] = setcorner(p, i + 1, j, k + 1); + if (newc.corners[6] == NULL) newc.corners[6] = setcorner(p, i + 1, j + 1, k); + if (newc.corners[7] == NULL) newc.corners[7] = setcorner(p, i + 1, j + 1, k + 1); - p->cubes->cube= newc; + p->cubes->cube = newc; } /* setcorner: return corner with the given lattice location * set (and cache) its function value */ -static CORNER *setcorner (PROCESS* p, int i, int j, int k) +static CORNER *setcorner(PROCESS *p, int i, int j, int k) { /* for speed, do corner value caching here */ CORNER *c; @@ -1070,11 +1074,11 @@ static CORNER *setcorner (PROCESS* p, int i, int j, int k) c = (CORNER *) new_pgn_element(sizeof(CORNER)); c->i = i; - c->x = ((float)i-0.5f)*p->size; + c->x = ((float)i - 0.5f) * p->size; c->j = j; - c->y = ((float)j-0.5f)*p->size; + c->y = ((float)j - 0.5f) * p->size; c->k = k; - c->z = ((float)k-0.5f)*p->size; + c->z = ((float)k - 0.5f) * p->size; c->value = p->function(c->x, c->y, c->z); c->next = p->corners[index]; @@ -1086,33 +1090,33 @@ static CORNER *setcorner (PROCESS* p, int i, int j, int k) /* nextcwedge: return next clockwise edge from given edge around given face */ -static int nextcwedge (int edge, int face) +static int nextcwedge(int edge, int face) { switch (edge) { - case LB: - return (face == L)? LF : BN; - case LT: - return (face == L)? LN : TF; - case LN: - return (face == L)? LB : TN; - case LF: - return (face == L)? LT : BF; - case RB: - return (face == R)? RN : BF; - case RT: - return (face == R)? RF : TN; - case RN: - return (face == R)? RT : BN; - case RF: - return (face == R)? RB : TF; - case BN: - return (face == B)? RB : LN; - case BF: - return (face == B)? LB : RF; - case TN: - return (face == T)? LT : RN; - case TF: - return (face == T)? RT : LF; + case LB: + return (face == L) ? LF : BN; + case LT: + return (face == L) ? LN : TF; + case LN: + return (face == L) ? LB : TN; + case LF: + return (face == L) ? LT : BF; + case RB: + return (face == R) ? RN : BF; + case RT: + return (face == R) ? RF : TN; + case RN: + return (face == R) ? RT : BN; + case RF: + return (face == R) ? RB : TF; + case BN: + return (face == B) ? RB : LN; + case BF: + return (face == B) ? LB : RF; + case TN: + return (face == T) ? LT : RN; + case TF: + return (face == T) ? RT : LF; } return 0; } @@ -1120,22 +1124,22 @@ static int nextcwedge (int edge, int face) /* otherface: return face adjoining edge that is not the given face */ -static int otherface (int edge, int face) +static int otherface(int edge, int face) { int other = leftface[edge]; - return face == other? rightface[edge] : other; + return face == other ? rightface[edge] : other; } /* makecubetable: create the 256 entry table for cubical polygonization */ -static void makecubetable (void) +static void makecubetable(void) { - static int isdone= 0; + static int isdone = 0; int i, e, c, done[12], pos[8]; if (isdone) return; - isdone= 1; + isdone = 1; for (i = 0; i < 256; i++) { for (e = 0; e < 12; e++) done[e] = 0; @@ -1147,7 +1151,7 @@ static void makecubetable (void) int start = e, edge = e; /* get face that is to right of edge from pos to neg corner: */ - int face = pos[corner1[e]]? rightface[e] : leftface[e]; + int face = pos[corner1[e]] ? rightface[e] : leftface[e]; while (1) { edge = nextcwedge(edge, face); @@ -1170,28 +1174,28 @@ static void makecubetable (void) } } -void BKE_metaball_cubeTable_free(void) +void BKE_mball_cubeTable_free(void) { int i; INTLISTS *lists, *nlists; INTLIST *ints, *nints; for (i = 0; i < 256; i++) { - lists= cubetable[i]; + lists = cubetable[i]; while (lists) { - nlists= lists->next; + nlists = lists->next; - ints= lists->list; + ints = lists->list; while (ints) { - nints= ints->next; + nints = ints->next; MEM_freeN(ints); - ints= nints; + ints = nints; } MEM_freeN(lists); - lists= nlists; + lists = nlists; } - cubetable[i]= NULL; + cubetable[i] = NULL; } } @@ -1205,8 +1209,8 @@ static int setcenter(CENTERLIST *table[], int i, int j, int k) int index; CENTERLIST *newc, *l, *q; - index= HASH(i, j, k); - q= table[index]; + index = HASH(i, j, k); + q = table[index]; for (l = q; l != NULL; l = l->next) { if (l->i == i && l->j == j && l->k == k) return 1; @@ -1225,25 +1229,25 @@ static int setcenter(CENTERLIST *table[], int i, int j, int k) /* setedge: set vertex id for edge */ -static void setedge (EDGELIST *table[], - int i1, int j1, - int k1, int i2, - int j2, int k2, - int vid) +static void setedge(EDGELIST *table[], + int i1, int j1, + int k1, int i2, + int j2, int k2, + int vid) { unsigned int index; EDGELIST *newe; - if (i1>i2 || (i1==i2 && (j1>j2 || (j1==j2 && k1>k2)))) { - int t=i1; - i1=i2; - i2=t; - t=j1; - j1=j2; - j2=t; - t=k1; - k1=k2; - k2=t; + if (i1 > i2 || (i1 == i2 && (j1 > j2 || (j1 == j2 && k1 > k2)))) { + int t = i1; + i1 = i2; + i2 = t; + t = j1; + j1 = j2; + j2 = t; + t = k1; + k1 = k2; + k2 = t; } index = HASH(i1, j1, k1) + HASH(i2, j2, k2); newe = (EDGELIST *) new_pgn_element(sizeof(EDGELIST)); @@ -1261,27 +1265,27 @@ static void setedge (EDGELIST *table[], /* getedge: return vertex id for edge; return -1 if not set */ -static int getedge (EDGELIST *table[], - int i1, int j1, int k1, - int i2, int j2, int k2) +static int getedge(EDGELIST *table[], + int i1, int j1, int k1, + int i2, int j2, int k2) { EDGELIST *q; - if (i1>i2 || (i1==i2 && (j1>j2 || (j1==j2 && k1>k2)))) { - int t=i1; - i1=i2; - i2=t; - t=j1; - j1=j2; - j2=t; - t=k1; - k1=k2; - k2=t; + if (i1 > i2 || (i1 == i2 && (j1 > j2 || (j1 == j2 && k1 > k2)))) { + int t = i1; + i1 = i2; + i2 = t; + t = j1; + j1 = j2; + j2 = t; + t = k1; + k1 = k2; + k2 = t; } - q = table[HASH(i1, j1, k1)+HASH(i2, j2, k2)]; + q = table[HASH(i1, j1, k1) + HASH(i2, j2, k2)]; for (; q != NULL; q = q->next) { if (q->i1 == i1 && q->j1 == j1 && q->k1 == k1 && - q->i2 == i2 && q->j2 == j2 && q->k2 == k2) + q->i2 == i2 && q->j2 == j2 && q->k2 == k2) { return q->vid; } @@ -1302,12 +1306,12 @@ static int getedge (EDGELIST *table[], /* addtovertices: add v to sequence of vertices */ -static void addtovertices (VERTICES *vertices, VERTEX v) +static void addtovertices(VERTICES *vertices, VERTEX v) { if (vertices->count == vertices->max) { int i; VERTEX *newv; - vertices->max = vertices->count == 0 ? 10 : 2*vertices->count; + vertices->max = vertices->count == 0 ? 10 : 2 * vertices->count; newv = (VERTEX *) MEM_callocN(vertices->max * sizeof(VERTEX), "addtovertices"); for (i = 0; i < vertices->count; i++) newv[i] = vertices->ptr[i]; @@ -1320,15 +1324,15 @@ static void addtovertices (VERTICES *vertices, VERTEX v) /* vnormal: compute unit length surface normal at point */ -static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) +static void vnormal(MB_POINT *point, PROCESS *p, MB_POINT *v) { - float delta= 0.2f*p->delta; + float delta = 0.2f * p->delta; float f = p->function(point->x, point->y, point->z); - v->x = p->function(point->x+delta, point->y, point->z)-f; - v->y = p->function(point->x, point->y+delta, point->z)-f; - v->z = p->function(point->x, point->y, point->z+delta)-f; - f = sqrtf(v->x*v->x + v->y*v->y + v->z*v->z); + v->x = p->function(point->x + delta, point->y, point->z) - f; + v->y = p->function(point->x, point->y + delta, point->z) - f; + v->z = p->function(point->x, point->y, point->z + delta) - f; + f = sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); if (f != 0.0f) { v->x /= f; @@ -1343,21 +1347,21 @@ static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) f = p->function(point->x, point->y, point->z); - temp.x = p->function(point->x+delta, point->y, point->z)-f; - temp.y = p->function(point->x, point->y+delta, point->z)-f; - temp.z = p->function(point->x, point->y, point->z+delta)-f; - f = sqrtf(temp.x*temp.x + temp.y*temp.y + temp.z*temp.z); + temp.x = p->function(point->x + delta, point->y, point->z) - f; + temp.y = p->function(point->x, point->y + delta, point->z) - f; + temp.z = p->function(point->x, point->y, point->z + delta) - f; + f = sqrtf(temp.x * temp.x + temp.y * temp.y + temp.z * temp.z); if (f != 0.0f) { temp.x /= f; temp.y /= f; temp.z /= f; - v->x+= temp.x; - v->y+= temp.y; - v->z+= temp.z; + v->x += temp.x; + v->y += temp.y; + v->z += temp.z; - f = sqrtf(v->x*v->x + v->y*v->y + v->z*v->z); + f = sqrtf(v->x * v->x + v->y * v->y + v->z * v->z); if (f != 0.0f) { v->x /= f; @@ -1370,13 +1374,13 @@ static void vnormal (MB_POINT *point, PROCESS *p, MB_POINT *v) } -static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) +static int vertid(CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) { VERTEX v; MB_POINT a, b; int vid = getedge(p->edges, c1->i, c1->j, c1->k, c2->i, c2->j, c2->k); - if (vid != -1) return vid; /* previously computed */ + if (vid != -1) return vid; /* previously computed */ a.x = c1->x; a.y = c1->y; a.z = c1->z; @@ -1387,8 +1391,8 @@ static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) converge(&a, &b, c1->value, c2->value, p->function, &v.position, mb, 1); /* position */ vnormal(&v.position, p, &v.normal); - addtovertices(&p->vertices, v); /* save vertex */ - vid = p->vertices.count-1; + addtovertices(&p->vertices, v); /* save vertex */ + vid = p->vertices.count - 1; setedge(p->edges, c1->i, c1->j, c1->k, c2->i, c2->j, c2->k, vid); return vid; @@ -1399,8 +1403,8 @@ static int vertid (CORNER *c1, CORNER *c2, PROCESS *p, MetaBall *mb) /* converge: from two points of differing sign, converge to zero crossing */ /* watch it: p1 and p2 are used to calculate */ -static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, - float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f) +static void converge(MB_POINT *p1, MB_POINT *p2, float v1, float v2, + float (*function)(float, float, float), MB_POINT *p, MetaBall *mb, int f) { int i = 0; MB_POINT pos, neg; @@ -1408,14 +1412,14 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, float dx = 0.0f, dy = 0.0f, dz = 0.0f; if (v1 < 0) { - pos= *p2; - neg= *p1; + pos = *p2; + neg = *p1; positive = v2; negative = v1; } else { - pos= *p1; - neg= *p2; + pos = *p1; + neg = *p2; positive = v1; negative = v2; } @@ -1426,25 +1430,25 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, /* Approximation by linear interpolation is faster then binary subdivision, * but it results sometimes (mb->thresh < 0.2) into the strange results */ - if ((mb->thresh > 0.2f) && (f==1)) { - if ((dy == 0.0f) && (dz == 0.0f)) { - p->x = neg.x - negative*dx/(positive-negative); - p->y = neg.y; - p->z = neg.z; - return; - } - if ((dx == 0.0f) && (dz == 0.0f)) { - p->x = neg.x; - p->y = neg.y - negative*dy/(positive-negative); - p->z = neg.z; - return; - } - if ((dx == 0.0f) && (dy == 0.0f)) { - p->x = neg.x; - p->y = neg.y; - p->z = neg.z - negative*dz/(positive-negative); - return; - } + if ((mb->thresh > 0.2f) && (f == 1)) { + if ((dy == 0.0f) && (dz == 0.0f)) { + p->x = neg.x - negative * dx / (positive - negative); + p->y = neg.y; + p->z = neg.z; + return; + } + if ((dx == 0.0f) && (dz == 0.0f)) { + p->x = neg.x; + p->y = neg.y - negative * dy / (positive - negative); + p->z = neg.z; + return; + } + if ((dx == 0.0f) && (dy == 0.0f)) { + p->x = neg.x; + p->y = neg.y; + p->z = neg.z - negative * dz / (positive - negative); + return; + } } if ((dy == 0.0f) && (dz == 0.0f)) { @@ -1452,8 +1456,8 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->z = neg.z; while (1) { if (i++ == RES) return; - p->x = 0.5f*(pos.x + neg.x); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; + p->x = 0.5f * (pos.x + neg.x); + if ((function(p->x, p->y, p->z)) > 0.0f) pos.x = p->x; else neg.x = p->x; } } @@ -1462,26 +1466,26 @@ static void converge (MB_POINT *p1, MB_POINT *p2, float v1, float v2, p->z = neg.z; while (1) { if (i++ == RES) return; - p->y = 0.5f*(pos.y + neg.y); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; + p->y = 0.5f * (pos.y + neg.y); + if ((function(p->x, p->y, p->z)) > 0.0f) pos.y = p->y; else neg.y = p->y; } - } + } if ((dx == 0.0f) && (dy == 0.0f)) { p->x = neg.x; p->y = neg.y; while (1) { if (i++ == RES) return; - p->z = 0.5f*(pos.z + neg.z); - if ((function(p->x, p->y, p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; + p->z = 0.5f * (pos.z + neg.z); + if ((function(p->x, p->y, p->z)) > 0.0f) pos.z = p->z; else neg.z = p->z; } } /* This is necessary to find start point */ while (1) { - p->x = 0.5f*(pos.x + neg.x); - p->y = 0.5f*(pos.y + neg.y); - p->z = 0.5f*(pos.z + neg.z); + p->x = 0.5f * (pos.x + neg.x); + p->y = 0.5f * (pos.y + neg.y); + p->z = 0.5f * (pos.z + neg.z); if (i++ == RES) return; @@ -1507,23 +1511,23 @@ static void add_cube(PROCESS *mbproc, int i, int j, int k, int count) /* hmmm, not only one, but eight cube will be added on the stack * ... */ - for (a=i-1; acenters, a, b, c)==0 ) { + if (setcenter(mbproc->centers, a, b, c) == 0) { /* push cube on stack: */ - ncube= (CUBES *) new_pgn_element(sizeof(CUBES)); - ncube->next= mbproc->cubes; - mbproc->cubes= ncube; + ncube = (CUBES *) new_pgn_element(sizeof(CUBES)); + ncube->next = mbproc->cubes; + mbproc->cubes = ncube; - ncube->cube.i= a; - ncube->cube.j= b; - ncube->cube.k= c; + ncube->cube.i = a; + ncube->cube.j = b; + ncube->cube.k = c; /* set corners of initial cube: */ for (n = 0; n < 8; n++) - ncube->cube.corners[n] = setcorner(mbproc, a+MB_BIT(n, 2), b+MB_BIT(n, 1), c+MB_BIT(n, 0)); + ncube->cube.corners[n] = setcorner(mbproc, a + MB_BIT(n, 2), b + MB_BIT(n, 1), c + MB_BIT(n, 0)); } } } @@ -1534,64 +1538,64 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) MB_POINT IN, in, OUT, out; /*point;*/ MetaElem *ml; int i, j, k, c_i, c_j, c_k; - int index[3]={1, 0, -1}; - float f =0.0f; + int index[3] = {1, 0, -1}; + float f = 0.0f; float in_v /*, out_v*/; MB_POINT workp; float tmp_v, workp_v, max_len, len, dx, dy, dz, nx, ny, nz, MAXN; ml = mainb[a]; - f = 1-(mb->thresh/ml->s); + f = 1 - (mb->thresh / ml->s); /* Skip, when Stiffness of MetaElement is too small ... MetaElement can't be * visible alone ... but still can influence others MetaElements :-) */ if (f > 0.0f) { - OUT.x = IN.x = in.x= 0.0; - OUT.y = IN.y = in.y= 0.0; - OUT.z = IN.z = in.z= 0.0; + OUT.x = IN.x = in.x = 0.0; + OUT.y = IN.y = in.y = 0.0; + OUT.z = IN.z = in.z = 0.0; calc_mballco(ml, (float *)&in); in_v = mbproc->function(in.x, in.y, in.z); - for (i=0;i<3;i++) { + for (i = 0; i < 3; i++) { switch (ml->type) { case MB_BALL: - OUT.x = out.x= IN.x + index[i]*ml->rad; + OUT.x = out.x = IN.x + index[i] * ml->rad; break; case MB_TUBE: case MB_PLANE: case MB_ELIPSOID: case MB_CUBE: - OUT.x = out.x= IN.x + index[i]*(ml->expx + ml->rad); + OUT.x = out.x = IN.x + index[i] * (ml->expx + ml->rad); break; } - for (j=0;j<3;j++) { + for (j = 0; j < 3; j++) { switch (ml->type) { case MB_BALL: - OUT.y = out.y= IN.y + index[j]*ml->rad; + OUT.y = out.y = IN.y + index[j] * ml->rad; break; case MB_TUBE: case MB_PLANE: case MB_ELIPSOID: case MB_CUBE: - OUT.y = out.y= IN.y + index[j]*(ml->expy + ml->rad); + OUT.y = out.y = IN.y + index[j] * (ml->expy + ml->rad); break; } - for (k=0;k<3;k++) { + for (k = 0; k < 3; k++) { out.x = OUT.x; out.y = OUT.y; switch (ml->type) { case MB_BALL: case MB_TUBE: case MB_PLANE: - out.z= IN.z + index[k]*ml->rad; + out.z = IN.z + index[k] * ml->rad; break; case MB_ELIPSOID: case MB_CUBE: - out.z= IN.z + index[k]*(ml->expz + ml->rad); + out.z = IN.z + index[k] * (ml->expz + ml->rad); break; } @@ -1604,32 +1608,32 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) workp.y = in.y; workp.z = in.z; workp_v = in_v; - max_len = sqrtf((out.x-in.x)*(out.x-in.x) + (out.y-in.y)*(out.y-in.y) + (out.z-in.z)*(out.z-in.z)); + max_len = sqrtf((out.x - in.x) * (out.x - in.x) + (out.y - in.y) * (out.y - in.y) + (out.z - in.z) * (out.z - in.z)); - nx = abs((out.x - in.x)/mbproc->size); - ny = abs((out.y - in.y)/mbproc->size); - nz = abs((out.z - in.z)/mbproc->size); + nx = abs((out.x - in.x) / mbproc->size); + ny = abs((out.y - in.y) / mbproc->size); + nz = abs((out.z - in.z) / mbproc->size); MAXN = MAX3(nx, ny, nz); - if (MAXN!=0.0f) { - dx = (out.x - in.x)/MAXN; - dy = (out.y - in.y)/MAXN; - dz = (out.z - in.z)/MAXN; + if (MAXN != 0.0f) { + dx = (out.x - in.x) / MAXN; + dy = (out.y - in.y) / MAXN; + dz = (out.z - in.z) / MAXN; len = 0.0; - while (len<=max_len) { + while (len <= max_len) { workp.x += dx; workp.y += dy; workp.z += dz; /* compute value of implicite function */ tmp_v = mbproc->function(workp.x, workp.y, workp.z); /* add cube to the stack, when value of implicite function crosses zero value */ - if ((tmp_v<0.0f && workp_v>=0.0f)||(tmp_v>0.0f && workp_v<=0.0f)) { + if ((tmp_v < 0.0f && workp_v >= 0.0f) || (tmp_v > 0.0f && workp_v <= 0.0f)) { /* indexes of CUBE, which includes "first point" */ - c_i= (int)floor(workp.x/mbproc->size); - c_j= (int)floor(workp.y/mbproc->size); - c_k= (int)floor(workp.z/mbproc->size); + c_i = (int)floor(workp.x / mbproc->size); + c_j = (int)floor(workp.y / mbproc->size); + c_k = (int)floor(workp.z / mbproc->size); /* add CUBE (with indexes c_i, c_j, c_k) to the stack, * this cube includes found point of Implicit Surface */ @@ -1638,7 +1642,7 @@ static void find_first_points(PROCESS *mbproc, MetaBall *mb, int a) else add_cube(mbproc, c_i, c_j, c_k, 1); } - len = sqrtf((workp.x-in.x)*(workp.x-in.x) + (workp.y-in.y)*(workp.y-in.y) + (workp.z-in.z)*(workp.z-in.z)); + len = sqrtf((workp.x - in.x) * (workp.x - in.x) + (workp.y - in.y) * (workp.y - in.y) + (workp.z - in.z) * (workp.z - in.z)); workp_v = tmp_v; } @@ -1660,10 +1664,10 @@ static void polygonize(PROCESS *mbproc, MetaBall *mb) /* allocate hash tables and build cube polygon table: */ mbproc->centers = MEM_callocN(HASHSIZE * sizeof(CENTERLIST *), "mbproc->centers"); mbproc->corners = MEM_callocN(HASHSIZE * sizeof(CORNER *), "mbproc->corners"); - mbproc->edges = MEM_callocN(2*HASHSIZE * sizeof(EDGELIST *), "mbproc->edges"); + mbproc->edges = MEM_callocN(2 * HASHSIZE * sizeof(EDGELIST *), "mbproc->edges"); makecubetable(); - for (a=0; acubes = mbproc->cubes->next; /* test six face directions, maybe add to stack: */ - testface(c.i-1, c.j, c.k, &c, 2, LBN, LBF, LTN, LTF, mbproc); - testface(c.i+1, c.j, c.k, &c, 2, RBN, RBF, RTN, RTF, mbproc); - testface(c.i, c.j-1, c.k, &c, 1, LBN, LBF, RBN, RBF, mbproc); - testface(c.i, c.j+1, c.k, &c, 1, LTN, LTF, RTN, RTF, mbproc); - testface(c.i, c.j, c.k-1, &c, 0, LBN, LTN, RBN, RTN, mbproc); - testface(c.i, c.j, c.k+1, &c, 0, LBF, LTF, RBF, RTF, mbproc); + testface(c.i - 1, c.j, c.k, &c, 2, LBN, LBF, LTN, LTF, mbproc); + testface(c.i + 1, c.j, c.k, &c, 2, RBN, RBF, RTN, RTF, mbproc); + testface(c.i, c.j - 1, c.k, &c, 1, LBN, LBF, RBN, RBF, mbproc); + testface(c.i, c.j + 1, c.k, &c, 1, LTN, LTF, RTN, RTF, mbproc); + testface(c.i, c.j, c.k - 1, &c, 0, LBN, LTN, RBN, RTN, mbproc); + testface(c.i, c.j, c.k + 1, &c, 0, LBF, LTF, RBF, RTF, mbproc); } } -static float init_meta(Scene *scene, Object *ob) /* return totsize */ +static float init_meta(Scene *scene, Object *ob) /* return totsize */ { - Scene *sce_iter= scene; + Scene *sce_iter = scene; Base *base; Object *bob; MetaBall *mb; MetaElem *ml; float size, totsize, obinv[4][4], obmat[4][4], vec[3]; //float max=0.0; - int a, obnr, zero_size=0; + int a, obnr, zero_size = 0; char obname[MAX_ID_NAME]; - copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from next_object */ + copy_m4_m4(obmat, ob->obmat); /* to cope with duplicators from BKE_scene_base_iter_next */ invert_m4_m4(obinv, ob->obmat); - a= 0; + a = 0; - BLI_split_name_num(obname, &obnr, ob->id.name+2, '.'); + BLI_split_name_num(obname, &obnr, ob->id.name + 2, '.'); /* make main array */ - next_object(&sce_iter, 0, NULL, NULL); - while (next_object(&sce_iter, 1, &base, &bob)) { + BKE_scene_base_iter_next(&sce_iter, 0, NULL, NULL); + while (BKE_scene_base_iter_next(&sce_iter, 1, &base, &bob)) { - if (bob->type==OB_MBALL) { - zero_size= 0; - ml= NULL; + if (bob->type == OB_MBALL) { + zero_size = 0; + ml = NULL; - if (bob==ob && (base->flag & OB_FROMDUPLI)==0) { - mb= ob->data; + if (bob == ob && (base->flag & OB_FROMDUPLI) == 0) { + mb = ob->data; - if (mb->editelems) ml= mb->editelems->first; - else ml= mb->elems.first; + if (mb->editelems) ml = mb->editelems->first; + else ml = mb->elems.first; } else { char name[MAX_ID_NAME]; int nr; - BLI_split_name_num(name, &nr, bob->id.name+2, '.'); - if ( strcmp(obname, name)==0 ) { - mb= bob->data; + BLI_split_name_num(name, &nr, bob->id.name + 2, '.'); + if (strcmp(obname, name) == 0) { + mb = bob->data; - if (mb->editelems) ml= mb->editelems->first; - else ml= mb->elems.first; + if (mb->editelems) ml = mb->editelems->first; + else ml = mb->elems.first; } } /* when metaball object has zero scale, then MetaElem to this MetaBall * will not be put to mainb array */ - if (bob->size[0]==0.0f || bob->size[1]==0.0f || bob->size[2]==0.0f) { - zero_size= 1; + if (bob->size[0] == 0.0f || bob->size[1] == 0.0f || bob->size[2] == 0.0f) { + zero_size = 1; } else if (bob->parent) { - struct Object *pob=bob->parent; + struct Object *pob = bob->parent; while (pob) { - if (pob->size[0]==0.0f || pob->size[1]==0.0f || pob->size[2]==0.0f) { - zero_size= 1; + if (pob->size[0] == 0.0f || pob->size[1] == 0.0f || pob->size[2] == 0.0f) { + zero_size = 1; break; } - pob= pob->parent; + pob = pob->parent; } } if (zero_size) { - unsigned int ml_count=0; + unsigned int ml_count = 0; while (ml) { ml_count++; - ml= ml->next; + ml = ml->next; } totelem -= ml_count; } else { - while (ml) { - if (!(ml->flag & MB_HIDE)) { - int i; - float temp1[4][4], temp2[4][4], temp3[4][4]; - float (*mat)[4] = NULL, (*imat)[4] = NULL; - float max_x, max_y, max_z, min_x, min_y, min_z; + while (ml) { + if (!(ml->flag & MB_HIDE)) { + int i; + float temp1[4][4], temp2[4][4], temp3[4][4]; + float (*mat)[4] = NULL, (*imat)[4] = NULL; + float max_x, max_y, max_z, min_x, min_y, min_z; - max_x = max_y = max_z = -3.4e38; - min_x = min_y = min_z = 3.4e38; + max_x = max_y = max_z = -3.4e38; + min_x = min_y = min_z = 3.4e38; - /* too big stiffness seems only ugly due to linear interpolation - * no need to have possibility for too big stiffness */ - if (ml->s > 10.0f) ml->s = 10.0f; + /* too big stiffness seems only ugly due to linear interpolation + * no need to have possibility for too big stiffness */ + if (ml->s > 10.0f) ml->s = 10.0f; + + /* Rotation of MetaElem is stored in quat */ + quat_to_mat4(temp3, ml->quat); + + /* Translation of MetaElem */ + unit_m4(temp2); + temp2[3][0] = ml->x; + temp2[3][1] = ml->y; + temp2[3][2] = ml->z; + + mult_m4_m4m4(temp1, temp2, temp3); + + /* make a copy because of duplicates */ + mainb[a] = new_pgn_element(sizeof(MetaElem)); + *(mainb[a]) = *ml; + mainb[a]->bb = new_pgn_element(sizeof(BoundBox)); + + mat = new_pgn_element(4 * 4 * sizeof(float)); + imat = new_pgn_element(4 * 4 * sizeof(float)); + + /* mat is the matrix to transform from mball into the basis-mball */ + invert_m4_m4(obinv, obmat); + mult_m4_m4m4(temp2, obinv, bob->obmat); + /* MetaBall transformation */ + mult_m4_m4m4(mat, temp2, temp1); + + invert_m4_m4(imat, mat); + + mainb[a]->rad2 = ml->rad * ml->rad; + + mainb[a]->mat = (float *) mat; + mainb[a]->imat = (float *) imat; + + /* untransformed Bounding Box of MetaElem */ + /* 0 */ + mainb[a]->bb->vec[0][0] = -ml->expx; + mainb[a]->bb->vec[0][1] = -ml->expy; + mainb[a]->bb->vec[0][2] = -ml->expz; + /* 1 */ + mainb[a]->bb->vec[1][0] = ml->expx; + mainb[a]->bb->vec[1][1] = -ml->expy; + mainb[a]->bb->vec[1][2] = -ml->expz; + /* 2 */ + mainb[a]->bb->vec[2][0] = ml->expx; + mainb[a]->bb->vec[2][1] = ml->expy; + mainb[a]->bb->vec[2][2] = -ml->expz; + /* 3 */ + mainb[a]->bb->vec[3][0] = -ml->expx; + mainb[a]->bb->vec[3][1] = ml->expy; + mainb[a]->bb->vec[3][2] = -ml->expz; + /* 4 */ + mainb[a]->bb->vec[4][0] = -ml->expx; + mainb[a]->bb->vec[4][1] = -ml->expy; + mainb[a]->bb->vec[4][2] = ml->expz; + /* 5 */ + mainb[a]->bb->vec[5][0] = ml->expx; + mainb[a]->bb->vec[5][1] = -ml->expy; + mainb[a]->bb->vec[5][2] = ml->expz; + /* 6 */ + mainb[a]->bb->vec[6][0] = ml->expx; + mainb[a]->bb->vec[6][1] = ml->expy; + mainb[a]->bb->vec[6][2] = ml->expz; + /* 7 */ + mainb[a]->bb->vec[7][0] = -ml->expx; + mainb[a]->bb->vec[7][1] = ml->expy; + mainb[a]->bb->vec[7][2] = ml->expz; + + /* transformation of Metalem bb */ + for (i = 0; i < 8; i++) + mul_m4_v3((float (*)[4])mat, mainb[a]->bb->vec[i]); + + /* find max and min of transformed bb */ + for (i = 0; i < 8; i++) { + /* find maximums */ + if (mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0]; + if (mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1]; + if (mainb[a]->bb->vec[i][2] > max_z) max_z = mainb[a]->bb->vec[i][2]; + /* find minimums */ + if (mainb[a]->bb->vec[i][0] < min_x) min_x = mainb[a]->bb->vec[i][0]; + if (mainb[a]->bb->vec[i][1] < min_y) min_y = mainb[a]->bb->vec[i][1]; + if (mainb[a]->bb->vec[i][2] < min_z) min_z = mainb[a]->bb->vec[i][2]; + } - /* Rotation of MetaElem is stored in quat */ - quat_to_mat4(temp3, ml->quat); + /* create "new" bb, only point 0 and 6, which are + * necessary for octal tree filling */ + mainb[a]->bb->vec[0][0] = min_x - ml->rad; + mainb[a]->bb->vec[0][1] = min_y - ml->rad; + mainb[a]->bb->vec[0][2] = min_z - ml->rad; - /* Translation of MetaElem */ - unit_m4(temp2); - temp2[3][0]= ml->x; - temp2[3][1]= ml->y; - temp2[3][2]= ml->z; + mainb[a]->bb->vec[6][0] = max_x + ml->rad; + mainb[a]->bb->vec[6][1] = max_y + ml->rad; + mainb[a]->bb->vec[6][2] = max_z + ml->rad; - mult_m4_m4m4(temp1, temp2, temp3); - - /* make a copy because of duplicates */ - mainb[a]= new_pgn_element(sizeof(MetaElem)); - *(mainb[a])= *ml; - mainb[a]->bb = new_pgn_element(sizeof(BoundBox)); - - mat= new_pgn_element(4*4*sizeof(float)); - imat= new_pgn_element(4*4*sizeof(float)); - - /* mat is the matrix to transform from mball into the basis-mball */ - invert_m4_m4(obinv, obmat); - mult_m4_m4m4(temp2, obinv, bob->obmat); - /* MetaBall transformation */ - mult_m4_m4m4(mat, temp2, temp1); - - invert_m4_m4(imat, mat); - - mainb[a]->rad2= ml->rad*ml->rad; - - mainb[a]->mat= (float*) mat; - mainb[a]->imat= (float*) imat; - - /* untransformed Bounding Box of MetaElem */ - /* 0 */ - mainb[a]->bb->vec[0][0]= -ml->expx; - mainb[a]->bb->vec[0][1]= -ml->expy; - mainb[a]->bb->vec[0][2]= -ml->expz; - /* 1 */ - mainb[a]->bb->vec[1][0]= ml->expx; - mainb[a]->bb->vec[1][1]= -ml->expy; - mainb[a]->bb->vec[1][2]= -ml->expz; - /* 2 */ - mainb[a]->bb->vec[2][0]= ml->expx; - mainb[a]->bb->vec[2][1]= ml->expy; - mainb[a]->bb->vec[2][2]= -ml->expz; - /* 3 */ - mainb[a]->bb->vec[3][0]= -ml->expx; - mainb[a]->bb->vec[3][1]= ml->expy; - mainb[a]->bb->vec[3][2]= -ml->expz; - /* 4 */ - mainb[a]->bb->vec[4][0]= -ml->expx; - mainb[a]->bb->vec[4][1]= -ml->expy; - mainb[a]->bb->vec[4][2]= ml->expz; - /* 5 */ - mainb[a]->bb->vec[5][0]= ml->expx; - mainb[a]->bb->vec[5][1]= -ml->expy; - mainb[a]->bb->vec[5][2]= ml->expz; - /* 6 */ - mainb[a]->bb->vec[6][0]= ml->expx; - mainb[a]->bb->vec[6][1]= ml->expy; - mainb[a]->bb->vec[6][2]= ml->expz; - /* 7 */ - mainb[a]->bb->vec[7][0]= -ml->expx; - mainb[a]->bb->vec[7][1]= ml->expy; - mainb[a]->bb->vec[7][2]= ml->expz; - - /* transformation of Metalem bb */ - for (i=0; i<8; i++) - mul_m4_v3((float (*)[4])mat, mainb[a]->bb->vec[i]); - - /* find max and min of transformed bb */ - for (i=0; i<8; i++) { - /* find maximums */ - if (mainb[a]->bb->vec[i][0] > max_x) max_x = mainb[a]->bb->vec[i][0]; - if (mainb[a]->bb->vec[i][1] > max_y) max_y = mainb[a]->bb->vec[i][1]; - if (mainb[a]->bb->vec[i][2] > max_z) max_z = mainb[a]->bb->vec[i][2]; - /* find minimums */ - if (mainb[a]->bb->vec[i][0] < min_x) min_x = mainb[a]->bb->vec[i][0]; - if (mainb[a]->bb->vec[i][1] < min_y) min_y = mainb[a]->bb->vec[i][1]; - if (mainb[a]->bb->vec[i][2] < min_z) min_z = mainb[a]->bb->vec[i][2]; + a++; } - - /* create "new" bb, only point 0 and 6, which are - * necessary for octal tree filling */ - mainb[a]->bb->vec[0][0] = min_x - ml->rad; - mainb[a]->bb->vec[0][1] = min_y - ml->rad; - mainb[a]->bb->vec[0][2] = min_z - ml->rad; - - mainb[a]->bb->vec[6][0] = max_x + ml->rad; - mainb[a]->bb->vec[6][1] = max_y + ml->rad; - mainb[a]->bb->vec[6][2] = max_z + ml->rad; - - a++; + ml = ml->next; } - ml= ml->next; - } } } } /* totsize (= 'manhattan' radius) */ - totsize= 0.0; - for (a=0; ax + mainb[a]->rad + mainb[a]->expx; - vec[1]= mainb[a]->y + mainb[a]->rad + mainb[a]->expy; - vec[2]= mainb[a]->z + mainb[a]->rad + mainb[a]->expz; + vec[0] = mainb[a]->x + mainb[a]->rad + mainb[a]->expx; + vec[1] = mainb[a]->y + mainb[a]->rad + mainb[a]->expy; + vec[2] = mainb[a]->z + mainb[a]->rad + mainb[a]->expz; calc_mballco(mainb[a], vec); - size= fabsf(vec[0]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[1]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[2]); - if ( size > totsize ) totsize= size; + size = fabsf(vec[0]); + if (size > totsize) totsize = size; + size = fabsf(vec[1]); + if (size > totsize) totsize = size; + size = fabsf(vec[2]); + if (size > totsize) totsize = size; - vec[0]= mainb[a]->x - mainb[a]->rad; - vec[1]= mainb[a]->y - mainb[a]->rad; - vec[2]= mainb[a]->z - mainb[a]->rad; + vec[0] = mainb[a]->x - mainb[a]->rad; + vec[1] = mainb[a]->y - mainb[a]->rad; + vec[2] = mainb[a]->z - mainb[a]->rad; calc_mballco(mainb[a], vec); - size= fabsf(vec[0]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[1]); - if ( size > totsize ) totsize= size; - size= fabsf(vec[2]); - if ( size > totsize ) totsize= size; + size = fabsf(vec[0]); + if (size > totsize) totsize = size; + size = fabsf(vec[1]); + if (size > totsize) totsize = size; + size = fabsf(vec[2]); + if (size > totsize) totsize = size; } - for (a=0; aml= ml; + ml_p = MEM_mallocN(sizeof(ml_pointer), "ml_pointer"); + ml_p->ml = ml; BLI_addtail(&(node->nodes[i]->elems), ml_p); node->count++; @@ -1955,16 +1959,16 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float int a, i; /* create new nodes */ - for (a=0;a<8;a++) { - node->nodes[a]= MEM_mallocN(sizeof(octal_node), "octal_node"); - for (i=0;i<8;i++) - node->nodes[a]->nodes[i]= NULL; - node->nodes[a]->parent= node; - node->nodes[a]->elems.first= NULL; - node->nodes[a]->elems.last= NULL; - node->nodes[a]->count= 0; - node->nodes[a]->neg= 0; - node->nodes[a]->pos= 0; + for (a = 0; a < 8; a++) { + node->nodes[a] = MEM_mallocN(sizeof(octal_node), "octal_node"); + for (i = 0; i < 8; i++) + node->nodes[a]->nodes[i] = NULL; + node->nodes[a]->parent = node; + node->nodes[a]->elems.first = NULL; + node->nodes[a]->elems.last = NULL; + node->nodes[a]->count = 0; + node->nodes[a]->neg = 0; + node->nodes[a]->pos = 0; } size_x /= 2; @@ -1980,64 +1984,64 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float node->nodes[0]->x_min = node->x_min; node->nodes[0]->y_min = node->y_min; node->nodes[0]->z_min = node->z_min; - node->nodes[0]->x = node->nodes[0]->x_min + size_x/2; - node->nodes[0]->y = node->nodes[0]->y_min + size_y/2; - node->nodes[0]->z = node->nodes[0]->z_min + size_z/2; + node->nodes[0]->x = node->nodes[0]->x_min + size_x / 2; + node->nodes[0]->y = node->nodes[0]->y_min + size_y / 2; + node->nodes[0]->z = node->nodes[0]->z_min + size_z / 2; node->nodes[1]->x_min = x; node->nodes[1]->y_min = node->y_min; node->nodes[1]->z_min = node->z_min; - node->nodes[1]->x = node->nodes[1]->x_min + size_x/2; - node->nodes[1]->y = node->nodes[1]->y_min + size_y/2; - node->nodes[1]->z = node->nodes[1]->z_min + size_z/2; + node->nodes[1]->x = node->nodes[1]->x_min + size_x / 2; + node->nodes[1]->y = node->nodes[1]->y_min + size_y / 2; + node->nodes[1]->z = node->nodes[1]->z_min + size_z / 2; node->nodes[2]->x_min = x; node->nodes[2]->y_min = y; node->nodes[2]->z_min = node->z_min; - node->nodes[2]->x = node->nodes[2]->x_min + size_x/2; - node->nodes[2]->y = node->nodes[2]->y_min + size_y/2; - node->nodes[2]->z = node->nodes[2]->z_min + size_z/2; + node->nodes[2]->x = node->nodes[2]->x_min + size_x / 2; + node->nodes[2]->y = node->nodes[2]->y_min + size_y / 2; + node->nodes[2]->z = node->nodes[2]->z_min + size_z / 2; node->nodes[3]->x_min = node->x_min; node->nodes[3]->y_min = y; node->nodes[3]->z_min = node->z_min; - node->nodes[3]->x = node->nodes[3]->x_min + size_x/2; - node->nodes[3]->y = node->nodes[3]->y_min + size_y/2; - node->nodes[3]->z = node->nodes[3]->z_min + size_z/2; + node->nodes[3]->x = node->nodes[3]->x_min + size_x / 2; + node->nodes[3]->y = node->nodes[3]->y_min + size_y / 2; + node->nodes[3]->z = node->nodes[3]->z_min + size_z / 2; node->nodes[4]->x_min = node->x_min; node->nodes[4]->y_min = node->y_min; node->nodes[4]->z_min = z; - node->nodes[4]->x = node->nodes[4]->x_min + size_x/2; - node->nodes[4]->y = node->nodes[4]->y_min + size_y/2; - node->nodes[4]->z = node->nodes[4]->z_min + size_z/2; + node->nodes[4]->x = node->nodes[4]->x_min + size_x / 2; + node->nodes[4]->y = node->nodes[4]->y_min + size_y / 2; + node->nodes[4]->z = node->nodes[4]->z_min + size_z / 2; node->nodes[5]->x_min = x; node->nodes[5]->y_min = node->y_min; node->nodes[5]->z_min = z; - node->nodes[5]->x = node->nodes[5]->x_min + size_x/2; - node->nodes[5]->y = node->nodes[5]->y_min + size_y/2; - node->nodes[5]->z = node->nodes[5]->z_min + size_z/2; + node->nodes[5]->x = node->nodes[5]->x_min + size_x / 2; + node->nodes[5]->y = node->nodes[5]->y_min + size_y / 2; + node->nodes[5]->z = node->nodes[5]->z_min + size_z / 2; node->nodes[6]->x_min = x; node->nodes[6]->y_min = y; node->nodes[6]->z_min = z; - node->nodes[6]->x = node->nodes[6]->x_min + size_x/2; - node->nodes[6]->y = node->nodes[6]->y_min + size_y/2; - node->nodes[6]->z = node->nodes[6]->z_min + size_z/2; + node->nodes[6]->x = node->nodes[6]->x_min + size_x / 2; + node->nodes[6]->y = node->nodes[6]->y_min + size_y / 2; + node->nodes[6]->z = node->nodes[6]->z_min + size_z / 2; node->nodes[7]->x_min = node->x_min; node->nodes[7]->y_min = y; node->nodes[7]->z_min = z; - node->nodes[7]->x = node->nodes[7]->x_min + size_x/2; - node->nodes[7]->y = node->nodes[7]->y_min + size_y/2; - node->nodes[7]->z = node->nodes[7]->z_min + size_z/2; + node->nodes[7]->x = node->nodes[7]->x_min + size_x / 2; + node->nodes[7]->y = node->nodes[7]->y_min + size_y / 2; + node->nodes[7]->z = node->nodes[7]->z_min + size_z / 2; - ml_p= node->elems.first; + ml_p = node->elems.first; /* setting up references of MetaElems for new nodes */ while (ml_p) { - ml= ml_p->ml; + ml = ml_p->ml; if (ml->bb->vec[0][2] < z) { if (ml->bb->vec[0][1] < y) { /* vec[0][0] lies in first octant */ @@ -2187,7 +2191,7 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float fill_metaball_octal_node(node, ml, 6); } } - ml_p= ml_p->next; + ml_p = ml_p->next; } /* free references of MetaElems for curent node (it is not needed anymore) */ @@ -2195,8 +2199,8 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float depth--; - if (depth>0) { - for (a=0;a<8;a++) { + if (depth > 0) { + for (a = 0; a < 8; a++) { if (node->nodes[a]->count > 0) /* if node is not empty, then it is subdivided */ subdivide_metaball_octal_node(node->nodes[a], size_x, size_y, size_z, depth); } @@ -2207,8 +2211,8 @@ static void subdivide_metaball_octal_node(octal_node *node, float size_x, float static void free_metaball_octal_node(octal_node *node) { int a; - for (a=0;a<8;a++) { - if (node->nodes[a]!=NULL) free_metaball_octal_node(node->nodes[a]); + for (a = 0; a < 8; a++) { + if (node->nodes[a] != NULL) free_metaball_octal_node(node->nodes[a]); } BLI_freelistN(&node->elems); MEM_freeN(node); @@ -2222,36 +2226,36 @@ static void init_metaball_octal_tree(int depth) float size[3]; int a; - metaball_tree= MEM_mallocN(sizeof(octal_tree), "metaball_octal_tree"); - metaball_tree->first= node= MEM_mallocN(sizeof(octal_node), "metaball_octal_node"); + metaball_tree = MEM_mallocN(sizeof(octal_tree), "metaball_octal_tree"); + metaball_tree->first = node = MEM_mallocN(sizeof(octal_node), "metaball_octal_node"); /* maximal depth of octree */ - metaball_tree->depth= depth; + metaball_tree->depth = depth; - metaball_tree->neg= node->neg=0; - metaball_tree->pos= node->pos=0; + metaball_tree->neg = node->neg = 0; + metaball_tree->pos = node->pos = 0; - node->elems.first= NULL; - node->elems.last= NULL; - node->count=0; + node->elems.first = NULL; + node->elems.last = NULL; + node->count = 0; - for (a=0;a<8;a++) - node->nodes[a]=NULL; + for (a = 0; a < 8; a++) + node->nodes[a] = NULL; - node->x_min= node->y_min= node->z_min= FLT_MAX; - node->x_max= node->y_max= node->z_max= -FLT_MAX; + node->x_min = node->y_min = node->z_min = FLT_MAX; + node->x_max = node->y_max = node->z_max = -FLT_MAX; /* size of octal tree scene */ - for (a=0;abb->vec[0][0] < node->x_min) node->x_min= mainb[a]->bb->vec[0][0]; - if (mainb[a]->bb->vec[0][1] < node->y_min) node->y_min= mainb[a]->bb->vec[0][1]; - if (mainb[a]->bb->vec[0][2] < node->z_min) node->z_min= mainb[a]->bb->vec[0][2]; - - if (mainb[a]->bb->vec[6][0] > node->x_max) node->x_max= mainb[a]->bb->vec[6][0]; - if (mainb[a]->bb->vec[6][1] > node->y_max) node->y_max= mainb[a]->bb->vec[6][1]; - if (mainb[a]->bb->vec[6][2] > node->z_max) node->z_max= mainb[a]->bb->vec[6][2]; + for (a = 0; a < totelem; a++) { + if (mainb[a]->bb->vec[0][0] < node->x_min) node->x_min = mainb[a]->bb->vec[0][0]; + if (mainb[a]->bb->vec[0][1] < node->y_min) node->y_min = mainb[a]->bb->vec[0][1]; + if (mainb[a]->bb->vec[0][2] < node->z_min) node->z_min = mainb[a]->bb->vec[0][2]; - ml_p= MEM_mallocN(sizeof(ml_pointer), "ml_pointer"); - ml_p->ml= mainb[a]; + if (mainb[a]->bb->vec[6][0] > node->x_max) node->x_max = mainb[a]->bb->vec[6][0]; + if (mainb[a]->bb->vec[6][1] > node->y_max) node->y_max = mainb[a]->bb->vec[6][1]; + if (mainb[a]->bb->vec[6][2] > node->z_max) node->z_max = mainb[a]->bb->vec[6][2]; + + ml_p = MEM_mallocN(sizeof(ml_pointer), "ml_pointer"); + ml_p->ml = mainb[a]; BLI_addtail(&node->elems, ml_p); if (mainb[a]->flag & MB_NEGATIVE) { @@ -2265,15 +2269,15 @@ static void init_metaball_octal_tree(int depth) } /* size of first node */ - size[0]= node->x_max - node->x_min; - size[1]= node->y_max - node->y_min; - size[2]= node->z_max - node->z_min; + size[0] = node->x_max - node->x_min; + size[1] = node->y_max - node->y_min; + size[2] = node->z_max - node->z_min; /* first node is subdivided recursively */ subdivide_metaball_octal_node(node, size[0], size[1], size[2], metaball_tree->depth); } -void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) +void BKE_mball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) { PROCESS mbproc; MetaBall *mb; @@ -2281,41 +2285,41 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) int a, nr_cubes; float *ve, *no, totsize, width; - mb= ob->data; + mb = ob->data; - if (totelem==0) return; - if (!(G.rendering) && (mb->flag==MB_UPDATE_NEVER)) return; - if (G.moving && mb->flag==MB_UPDATE_FAST) return; + if (totelem == 0) return; + if (!(G.rendering) && (mb->flag == MB_UPDATE_NEVER)) return; + if (G.moving && mb->flag == MB_UPDATE_FAST) return; - curindex= totindex= 0; - indices= NULL; - thresh= mb->thresh; + curindex = totindex = 0; + indices = NULL; + thresh = mb->thresh; /* total number of MetaElems (totelem) is precomputed in find_basis_mball() function */ - mainb= MEM_mallocN(sizeof(void *)*totelem, "mainb"); + mainb = MEM_mallocN(sizeof(void *) * totelem, "mainb"); /* initialize all mainb (MetaElems) */ - totsize= init_meta(scene, ob); + totsize = init_meta(scene, ob); if (metaball_tree) { free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); - metaball_tree= NULL; + metaball_tree = NULL; } /* if scene includes more then one MetaElem, then octal tree optimalisation is used */ if ((totelem > 1) && (totelem <= 64)) init_metaball_octal_tree(1); if ((totelem > 64) && (totelem <= 128)) init_metaball_octal_tree(2); - if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3); + if ((totelem > 128) && (totelem <= 512)) init_metaball_octal_tree(3); if ((totelem > 512) && (totelem <= 1024)) init_metaball_octal_tree(4); if (totelem > 1024) init_metaball_octal_tree(5); /* don't polygonize metaballs with too high resolution (base mball to small) * note: Eps was 0.0001f but this was giving problems for blood animation for durian, using 0.00001f */ if (metaball_tree) { - if ( ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) || - ob->size[1] <= 0.00001f * (metaball_tree->first->y_max - metaball_tree->first->y_min) || - ob->size[2] <= 0.00001f * (metaball_tree->first->z_max - metaball_tree->first->z_min)) + if (ob->size[0] <= 0.00001f * (metaball_tree->first->x_max - metaball_tree->first->x_min) || + ob->size[1] <= 0.00001f * (metaball_tree->first->y_max - metaball_tree->first->y_min) || + ob->size[2] <= 0.00001f * (metaball_tree->first->z_max - metaball_tree->first->z_min)) { new_pgn_element(-1); /* free values created by init_meta */ @@ -2324,27 +2328,27 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) /* free tree */ free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); - metaball_tree= NULL; + metaball_tree = NULL; return; } } /* width is size per polygonize cube */ - if (G.rendering) width= mb->rendersize; + if (G.rendering) width = mb->rendersize; else { - width= mb->wiresize; - if (G.moving && mb->flag==MB_UPDATE_HALFRES) width*= 2; + width = mb->wiresize; + if (G.moving && mb->flag == MB_UPDATE_HALFRES) width *= 2; } /* nr_cubes is just for safety, minimum is totsize */ - nr_cubes= (int)(0.5f+totsize/width); + nr_cubes = (int)(0.5f + totsize / width); /* init process */ mbproc.function = metaball; mbproc.size = width; mbproc.bounds = nr_cubes; - mbproc.cubes= NULL; - mbproc.delta = width/(float)(RES*RES); + mbproc.cubes = NULL; + mbproc.delta = width / (float)(RES * RES); polygonize(&mbproc, mb); @@ -2354,31 +2358,31 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) if (totelem > 1) { free_metaball_octal_node(metaball_tree->first); MEM_freeN(metaball_tree); - metaball_tree= NULL; + metaball_tree = NULL; } if (curindex) { - dl= MEM_callocN(sizeof(DispList), "mbaldisp"); + dl = MEM_callocN(sizeof(DispList), "mbaldisp"); BLI_addtail(dispbase, dl); - dl->type= DL_INDEX4; - dl->nr= mbproc.vertices.count; - dl->parts= curindex; + dl->type = DL_INDEX4; + dl->nr = mbproc.vertices.count; + dl->parts = curindex; - dl->index= indices; - indices= NULL; - - a= mbproc.vertices.count; - dl->verts= ve= MEM_mallocN(sizeof(float)*3*a, "mballverts"); - dl->nors= no= MEM_mallocN(sizeof(float)*3*a, "mballnors"); + dl->index = indices; + indices = NULL; - for (a=0; averts = ve = MEM_mallocN(sizeof(float) * 3 * a, "mballverts"); + dl->nors = no = MEM_mallocN(sizeof(float) * 3 * a, "mballnors"); - no[0]= mbproc.vertices.ptr[a].normal.x; - no[1]= mbproc.vertices.ptr[a].normal.y; - no[2]= mbproc.vertices.ptr[a].normal.z; + for (a = 0; a < mbproc.vertices.count; a++, no += 3, ve += 3) { + ve[0] = mbproc.vertices.ptr[a].position.x; + ve[1] = mbproc.vertices.ptr[a].position.y; + ve[2] = mbproc.vertices.ptr[a].position.z; + + no[0] = mbproc.vertices.ptr[a].normal.x; + no[1] = mbproc.vertices.ptr[a].normal.y; + no[2] = mbproc.vertices.ptr[a].normal.z; } } @@ -2386,7 +2390,7 @@ void BKE_metaball_polygonize(Scene *scene, Object *ob, ListBase *dispbase) } /* basic vertex data functions */ -int BKE_metaball_minmax(MetaBall *mb, float min[3], float max[3]) +int BKE_mball_minmax(MetaBall *mb, float min[3], float max[3]) { MetaElem *ml; @@ -2399,10 +2403,10 @@ int BKE_metaball_minmax(MetaBall *mb, float min[3], float max[3]) return (mb->elems.first != NULL); } -int BKE_metaball_center_median(MetaBall *mb, float cent[3]) +int BKE_mball_center_median(MetaBall *mb, float cent[3]) { MetaElem *ml; - int total= 0; + int total = 0; zero_v3(cent); @@ -2411,16 +2415,16 @@ int BKE_metaball_center_median(MetaBall *mb, float cent[3]) } if (total) - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); return (total != 0); } -int BKE_metaball_center_bounds(MetaBall *mb, float cent[3]) +int BKE_mball_center_bounds(MetaBall *mb, float cent[3]) { float min[3], max[3]; - if (BKE_metaball_minmax(mb, min, max)) { + if (BKE_mball_minmax(mb, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } @@ -2428,7 +2432,7 @@ int BKE_metaball_center_bounds(MetaBall *mb, float cent[3]) return 0; } -void BKE_metaball_translate(MetaBall *mb, float offset[3]) +void BKE_mball_translate(MetaBall *mb, float offset[3]) { MetaElem *ml; diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 4b14c2aec4b..944f06cf740 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -97,28 +97,28 @@ static const char *cmpcode_to_str(int code) case MESHCMP_DVERT_WEIGHTMISMATCH: return "Vertex Weight Mismatch"; case MESHCMP_DVERT_GROUPMISMATCH: - return "Vertex Group Mismatch"; + return "Vertex Group Mismatch"; case MESHCMP_DVERT_TOTGROUPMISMATCH: - return "Vertex Doesn't Belong To Same Number Of Groups"; + return "Vertex Doesn't Belong To Same Number Of Groups"; case MESHCMP_LOOPCOLMISMATCH: - return "Vertex Color Mismatch"; + return "Vertex Color Mismatch"; case MESHCMP_LOOPUVMISMATCH: - return "UV Mismatch"; + return "UV Mismatch"; case MESHCMP_LOOPMISMATCH: - return "Loop Mismatch"; + return "Loop Mismatch"; case MESHCMP_POLYVERTMISMATCH: - return "Loop Vert Mismatch In Poly Test"; + return "Loop Vert Mismatch In Poly Test"; case MESHCMP_POLYMISMATCH: - return "Loop Vert Mismatch"; + return "Loop Vert Mismatch"; case MESHCMP_EDGEUNKNOWN: - return "Edge Mismatch"; + return "Edge Mismatch"; case MESHCMP_VERTCOMISMATCH: - return "Vertex Coordinate Mismatch"; + return "Vertex Coordinate Mismatch"; case MESHCMP_CDLAYERS_MISMATCH: - return "CustomData Layer Count Mismatch"; + return "CustomData Layer Count Mismatch"; default: - return "Mesh Comparison Code Unknown"; - } + return "Mesh Comparison Code Unknown"; + } } /* thresh is threshold for comparing vertices, uvs, vertex colors, @@ -126,7 +126,7 @@ static const char *cmpcode_to_str(int code) static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2, float thresh) { CustomDataLayer *l1, *l2; - int i, i1=0, i2=0, tot, j; + int i, i1 = 0, i2 = 0, tot, j; for (i = 0; i < c1->totlayer; i++) { if (ELEM7(c1->layers[i].type, CD_MVERT, CD_MEDGE, CD_MPOLY, @@ -150,7 +150,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 l1 = c1->layers; l2 = c2->layers; tot = i1; i1 = 0; i2 = 0; - for (i=0; i < tot; i++) { + for (i = 0; i < tot; i++) { while (i1 < c1->totlayer && !ELEM7(l1->type, CD_MVERT, CD_MEDGE, CD_MPOLY, CD_MLOOPUV, CD_MLOOPCOL, CD_MTEXPOLY, CD_MDEFORMVERT)) { @@ -168,7 +168,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MVert *v2 = l2->data; int vtot = m1->totvert; - for (j=0; jco, v2->co) > thresh) return MESHCMP_VERTCOMISMATCH; /*I don't care about normals, let's just do coodinates*/ @@ -182,11 +182,11 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 EdgeHash *eh = BLI_edgehash_new(); int etot = m1->totedge; - for (j=0; jv1, e1->v2, e1); } - for (j=0; jv1, e2->v2)) return MESHCMP_EDGEUNKNOWN; } @@ -198,7 +198,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MPoly *p2 = l2->data; int ptot = m1->totpoly; - for (j=0; jmloop + p1->loopstart; lp2 = m2->mloop + p2->loopstart; - for (k=0; ktotloop; k++, lp1++, lp2++) { + for (k = 0; k < p1->totloop; k++, lp1++, lp2++) { if (lp1->v != lp2->v) return MESHCMP_POLYVERTMISMATCH; } @@ -219,7 +219,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MLoop *lp2 = l2->data; int ltot = m1->totloop; - for (j=0; jv != lp2->v) return MESHCMP_LOOPMISMATCH; } @@ -229,7 +229,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MLoopUV *lp2 = l2->data; int ltot = m1->totloop; - for (j=0; juv, lp2->uv) > thresh) return MESHCMP_LOOPUVMISMATCH; } @@ -240,7 +240,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MLoopCol *lp2 = l2->data; int ltot = m1->totloop; - for (j=0; jr - lp2->r) > thresh || ABS(lp1->g - lp2->g) > thresh || ABS(lp1->b - lp2->b) > thresh || @@ -256,14 +256,14 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 MDeformVert *dv2 = l2->data; int dvtot = m1->totvert; - for (j=0; jdw, *dw2=dv2->dw; + MDeformWeight *dw1 = dv1->dw, *dw2 = dv2->dw; if (dv1->totweight != dv2->totweight) return MESHCMP_DVERT_TOTGROUPMISMATCH; - for (k=0; ktotweight; k++, dw1++, dw2++) { + for (k = 0; k < dv1->totweight; k++, dw1++, dw2++) { if (dw1->def_nr != dw2->def_nr) return MESHCMP_DVERT_GROUPMISMATCH; if (ABS(dw1->weight - dw2->weight) > thresh) @@ -277,7 +277,7 @@ static int customdata_compare(CustomData *c1, CustomData *c2, Mesh *m1, Mesh *m2 } /*used for testing. returns an error string the two meshes don't match*/ -const char *mesh_cmp(Mesh *me1, Mesh *me2, float thresh) +const char *BKE_mesh_cmp(Mesh *me1, Mesh *me2, float thresh) { int c; @@ -293,7 +293,7 @@ const char *mesh_cmp(Mesh *me1, Mesh *me2, float thresh) if (me1->totpoly != me2->totpoly) return "Number of faces don't match"; - if (me1->totloop !=me2->totloop) + if (me1->totloop != me2->totloop) return "Number of loops don't match"; if ((c = customdata_compare(&me1->vdata, &me2->vdata, me1, me2, thresh))) @@ -327,7 +327,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) const int totcol_tessface = CustomData_number_of_layers(&me->fdata, CD_MCOL); if (tottex_tessface != tottex_original || - totcol_tessface != totcol_original ) + totcol_tessface != totcol_original) { BKE_mesh_tessface_clear(me); @@ -340,8 +340,8 @@ static void mesh_ensure_tessellation_customdata(Mesh *me) * and check if there was any data to begin with, for now just print the warning with * some info to help troubleshoot whats going on - campbell */ printf("%s: warning! Tessellation uvs or vcol data got out of sync, " - "had to reset!\n CD_MTFACE: %d != CD_MTEXPOLY: %d || CD_MCOL: %d != CD_MLOOPCOL: %d\n", - __func__, tottex_tessface, tottex_original, totcol_tessface, totcol_original); + "had to reset!\n CD_MTFACE: %d != CD_MTEXPOLY: %d || CD_MCOL: %d != CD_MLOOPCOL: %d\n", + __func__, tottex_tessface, tottex_original, totcol_tessface, totcol_original); } } } @@ -392,30 +392,30 @@ void mesh_update_customdata_pointers(Mesh *me, const short do_ensure_tess_cd) * we need a more generic method, like the expand() functions in * readfile.c */ -void unlink_mesh(Mesh *me) +void BKE_mesh_unlink(Mesh *me) { int a; - if (me==NULL) return; + if (me == NULL) return; - for (a=0; atotcol; a++) { + for (a = 0; a < me->totcol; a++) { if (me->mat[a]) me->mat[a]->id.us--; - me->mat[a]= NULL; + me->mat[a] = NULL; } if (me->key) { me->key->id.us--; } - me->key= NULL; + me->key = NULL; - if (me->texcomesh) me->texcomesh= NULL; + if (me->texcomesh) me->texcomesh = NULL; } /* do not free mesh itself */ -void free_mesh(Mesh *me, int unlink) +void BKE_mesh_free(Mesh *me, int unlink) { if (unlink) - unlink_mesh(me); + BKE_mesh_unlink(me); CustomData_free(&me->vdata, me->totvert); CustomData_free(&me->edata, me->totedge); @@ -425,7 +425,7 @@ void free_mesh(Mesh *me, int unlink) if (me->adt) { BKE_free_animdata(&me->id); - me->adt= NULL; + me->adt = NULL; } if (me->mat) MEM_freeN(me->mat); @@ -443,12 +443,12 @@ void copy_dverts(MDeformVert *dst, MDeformVert *src, int copycount) if (!src || !dst) return; - memcpy (dst, src, copycount * sizeof(MDeformVert)); + memcpy(dst, src, copycount * sizeof(MDeformVert)); - for (i=0; ifdata, 0, sizeof(mesh->fdata)); } -Mesh *add_mesh(const char *name) +Mesh *BKE_mesh_add(const char *name) { Mesh *me; - me= alloc_libblock(&G.main->mesh, ID_ME, name); + me = BKE_libblock_alloc(&G.main->mesh, ID_ME, name); - me->size[0]= me->size[1]= me->size[2]= 1.0; - me->smoothresh= 30; - me->texflag= ME_AUTOSPACE; - me->flag= ME_TWOSIDED; - me->bb= unit_boundbox(); - me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; + me->size[0] = me->size[1] = me->size[2] = 1.0; + me->smoothresh = 30; + me->texflag = ME_AUTOSPACE; + me->flag = ME_TWOSIDED; + me->drawflag = ME_DRAWEDGES | ME_DRAWFACES | ME_DRAWCREASES; return me; } -Mesh *copy_mesh(Mesh *me) +Mesh *BKE_mesh_copy(Mesh *me) { Mesh *men; MTFace *tface; @@ -508,10 +507,10 @@ Mesh *copy_mesh(Mesh *me) int a, i; const int do_tessface = ((me->totface != 0) && (me->totpoly == 0)); /* only do tessface if we have no polys */ - men= copy_libblock(&me->id); + men = BKE_libblock_copy(&me->id); - men->mat= MEM_dupallocN(me->mat); - for (a=0; atotcol; a++) { + men->mat = MEM_dupallocN(me->mat); + for (a = 0; a < men->totcol; a++) { id_us_plus((ID *)men->mat[a]); } id_us_plus((ID *)men->texcomesh); @@ -530,33 +529,33 @@ Mesh *copy_mesh(Mesh *me) mesh_update_customdata_pointers(men, do_tessface); /* ensure indirect linked data becomes lib-extern */ - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - tface= (MTFace*)me->fdata.layers[i].data; + tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) + for (a = 0; a < me->totface; a++, tface++) if (tface->tpage) - id_lib_extern((ID*)tface->tpage); + id_lib_extern((ID *)tface->tpage); } } - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - txface= (MTexPoly*)me->pdata.layers[i].data; + txface = (MTexPoly *)me->pdata.layers[i].data; - for (a=0; atotpoly; a++, txface++) + for (a = 0; a < me->totpoly; a++, txface++) if (txface->tpage) - id_lib_extern((ID*)txface->tpage); + id_lib_extern((ID *)txface->tpage); } } - men->mselect= NULL; - men->edit_btmesh= NULL; + men->mselect = NULL; + men->edit_btmesh = NULL; - men->bb= MEM_dupallocN(men->bb); + men->bb = MEM_dupallocN(men->bb); - men->key= copy_key(me->key); - if (men->key) men->key->from= (ID *)men; + men->key = BKE_key_copy(me->key); + if (men->key) men->key->from = (ID *)men; return men; } @@ -579,11 +578,11 @@ static void expand_local_mesh(Mesh *me) if (me->mtface || me->mtpoly) { int a, i; - for (i=0; ipdata.totlayer; i++) { + for (i = 0; i < me->pdata.totlayer; i++) { if (me->pdata.layers[i].type == CD_MTEXPOLY) { - MTexPoly *txface= (MTexPoly*)me->fdata.layers[i].data; + MTexPoly *txface = (MTexPoly *)me->fdata.layers[i].data; - for (a=0; atotpoly; a++, txface++) { + for (a = 0; a < me->totpoly; a++, txface++) { /* special case: ima always local immediately */ if (txface->tpage) { id_lib_extern((ID *)txface->tpage); @@ -592,11 +591,11 @@ static void expand_local_mesh(Mesh *me) } } - for (i=0; ifdata.totlayer; i++) { + for (i = 0; i < me->fdata.totlayer; i++) { if (me->fdata.layers[i].type == CD_MTFACE) { - MTFace *tface= (MTFace*)me->fdata.layers[i].data; + MTFace *tface = (MTFace *)me->fdata.layers[i].data; - for (a=0; atotface; a++, tface++) { + for (a = 0; a < me->totface; a++, tface++) { /* special case: ima always local immediately */ if (tface->tpage) { id_lib_extern((ID *)tface->tpage); @@ -611,28 +610,28 @@ static void expand_local_mesh(Mesh *me) } } -void make_local_mesh(Mesh *me) +void BKE_mesh_make_local(Mesh *me) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (me->id.lib==NULL) return; - if (me->id.us==1) { + if (me->id.lib == NULL) return; + if (me->id.us == 1) { id_clear_lib_data(bmain, &me->id); expand_local_mesh(me); return; } - for (ob= bmain->object.first; ob && ELEM(0, is_lib, is_local); ob= ob->id.next) { + for (ob = bmain->object.first; ob && ELEM(0, is_lib, is_local); ob = ob->id.next) { if (me == ob->data) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -641,16 +640,16 @@ void make_local_mesh(Mesh *me) expand_local_mesh(me); } else if (is_local && is_lib) { - Mesh *me_new= copy_mesh(me); - me_new->id.us= 0; + Mesh *me_new = BKE_mesh_copy(me); + me_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, me->id.lib, &me_new->id); - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { if (me == ob->data) { - if (ob->id.lib==NULL) { + if (ob->id.lib == NULL) { set_mesh(ob, me_new); } } @@ -658,45 +657,45 @@ void make_local_mesh(Mesh *me) } } -void boundbox_mesh(Mesh *me, float *loc, float *size) +void BKE_mesh_boundbox_calc(Mesh *me, float r_loc[3], float r_size[3]) { BoundBox *bb; float min[3], max[3]; float mloc[3], msize[3]; - if (me->bb==NULL) me->bb= MEM_callocN(sizeof(BoundBox), "boundbox"); - bb= me->bb; + if (me->bb == NULL) me->bb = MEM_callocN(sizeof(BoundBox), "boundbox"); + bb = me->bb; - if (!loc) loc= mloc; - if (!size) size= msize; + if (!r_loc) r_loc = mloc; + if (!r_size) r_size = msize; INIT_MINMAX(min, max); - if (!minmax_mesh(me, min, max)) { + if (!BKE_mesh_minmax(me, min, max)) { min[0] = min[1] = min[2] = -1.0f; max[0] = max[1] = max[2] = 1.0f; } - mid_v3_v3v3(loc, min, max); + mid_v3_v3v3(r_loc, min, max); - size[0]= (max[0]-min[0])/2.0f; - size[1]= (max[1]-min[1])/2.0f; - size[2]= (max[2]-min[2])/2.0f; + r_size[0] = (max[0] - min[0]) / 2.0f; + r_size[1] = (max[1] - min[1]) / 2.0f; + r_size[2] = (max[2] - min[2]) / 2.0f; - boundbox_set_from_min_max(bb, min, max); + BKE_boundbox_init_from_minmax(bb, min, max); } -void tex_space_mesh(Mesh *me) +void BKE_mesh_texspace_calc(Mesh *me) { float loc[3], size[3]; int a; - boundbox_mesh(me, loc, size); + BKE_mesh_boundbox_calc(me, loc, size); if (me->texflag & ME_AUTOSPACE) { - for (a=0; a<3; a++) { - if (size[a]==0.0f) size[a]= 1.0f; - else if (size[a]>0.0f && size[a]<0.00001f) size[a]= 0.00001f; - else if (size[a]<0.0f && size[a]> -0.00001f) size[a]= -0.00001f; + for (a = 0; a < 3; a++) { + if (size[a] == 0.0f) size[a] = 1.0f; + else if (size[a] > 0.0f && size[a] < 0.00001f) size[a] = 0.00001f; + else if (size[a] < 0.0f && size[a] > -0.00001f) size[a] = -0.00001f; } copy_v3_v3(me->loc, loc); @@ -705,69 +704,69 @@ void tex_space_mesh(Mesh *me) } } -BoundBox *mesh_get_bb(Object *ob) +BoundBox *BKE_mesh_boundbox_get(Object *ob) { - Mesh *me= ob->data; + Mesh *me = ob->data; if (ob->bb) return ob->bb; if (!me->bb) - tex_space_mesh(me); + BKE_mesh_texspace_calc(me); return me->bb; } -void mesh_get_texspace(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]) +void BKE_mesh_texspace_get(Mesh *me, float r_loc[3], float r_rot[3], float r_size[3]) { if (!me->bb) { - tex_space_mesh(me); + BKE_mesh_texspace_calc(me); } - if (r_loc) copy_v3_v3(r_loc, me->loc); - if (r_rot) copy_v3_v3(r_rot, me->rot); + if (r_loc) copy_v3_v3(r_loc, me->loc); + if (r_rot) copy_v3_v3(r_rot, me->rot); if (r_size) copy_v3_v3(r_size, me->size); } -float *get_mesh_orco_verts(Object *ob) +float *BKE_mesh_orco_verts_get(Object *ob) { Mesh *me = ob->data; MVert *mvert = NULL; - Mesh *tme = me->texcomesh?me->texcomesh:me; + Mesh *tme = me->texcomesh ? me->texcomesh : me; int a, totvert; float (*vcos)[3] = NULL; /* Get appropriate vertex coordinates */ - vcos = MEM_callocN(sizeof(*vcos)*me->totvert, "orco mesh"); + vcos = MEM_callocN(sizeof(*vcos) * me->totvert, "orco mesh"); mvert = tme->mvert; totvert = MIN2(tme->totvert, me->totvert); - for (a=0; aco); } - return (float*)vcos; + return (float *)vcos; } -void transform_mesh_orco_verts(Mesh *me, float (*orco)[3], int totvert, int invert) +void BKE_mesh_orco_verts_transform(Mesh *me, float (*orco)[3], int totvert, int invert) { float loc[3], size[3]; int a; - mesh_get_texspace(me->texcomesh?me->texcomesh:me, loc, NULL, size); + BKE_mesh_texspace_get(me->texcomesh ? me->texcomesh : me, loc, NULL, size); if (invert) { - for (a=0; av3 || nr==4) && mface->v3==mface->v4) { - mface->v4= 0; + if ((mface->v3 || nr == 4) && mface->v3 == mface->v4) { + mface->v4 = 0; nr--; } - if ((mface->v2 || mface->v4) && mface->v2==mface->v3) { - mface->v3= mface->v4; - mface->v4= 0; + if ((mface->v2 || mface->v4) && mface->v2 == mface->v3) { + mface->v3 = mface->v4; + mface->v4 = 0; nr--; } - if (mface->v1==mface->v2) { - mface->v2= mface->v3; - mface->v3= mface->v4; - mface->v4= 0; + if (mface->v1 == mface->v2) { + mface->v2 = mface->v3; + mface->v3 = mface->v4; + mface->v4 = 0; nr--; } /* check corrupt cases, bowtie geometry, cant handle these because edge data wont exist so just return 0 */ - if (nr==3) { + if (nr == 3) { if ( - /* real edges */ - mface->v1==mface->v2 || - mface->v2==mface->v3 || - mface->v3==mface->v1 - ) { + /* real edges */ + mface->v1 == mface->v2 || + mface->v2 == mface->v3 || + mface->v3 == mface->v1) + { return 0; } } - else if (nr==4) { + else if (nr == 4) { if ( - /* real edges */ - mface->v1==mface->v2 || - mface->v2==mface->v3 || - mface->v3==mface->v4 || - mface->v4==mface->v1 || - /* across the face */ - mface->v1==mface->v3 || - mface->v2==mface->v4 - ) { + /* real edges */ + mface->v1 == mface->v2 || + mface->v2 == mface->v3 || + mface->v3 == mface->v4 || + mface->v4 == mface->v1 || + /* across the face */ + mface->v1 == mface->v3 || + mface->v2 == mface->v4 + ) { return 0; } } /* prevent a zero at wrong index location */ - if (nr==3) { - if (mface->v3==0) { + if (nr == 3) { + if (mface->v3 == 0) { static int corner_indices[4] = {1, 2, 0, 3}; SWAP(unsigned int, mface->v1, mface->v2); @@ -831,8 +830,8 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) CustomData_swap(fdata, mfindex, corner_indices); } } - else if (nr==4) { - if (mface->v3==0 || mface->v4==0) { + else if (nr == 4) { + if (mface->v3 == 0 || mface->v4 == 0) { static int corner_indices[4] = {2, 3, 0, 1}; SWAP(unsigned int, mface->v1, mface->v3); @@ -846,27 +845,27 @@ int test_index_face(MFace *mface, CustomData *fdata, int mfindex, int nr) return nr; } -Mesh *get_mesh(Object *ob) +Mesh *BKE_mesh_from_object(Object *ob) { - if (ob==NULL) return NULL; - if (ob->type==OB_MESH) return ob->data; + if (ob == NULL) return NULL; + if (ob->type == OB_MESH) return ob->data; else return NULL; } void set_mesh(Object *ob, Mesh *me) { - Mesh *old=NULL; + Mesh *old = NULL; multires_force_update(ob); - if (ob==NULL) return; + if (ob == NULL) return; - if (ob->type==OB_MESH) { - old= ob->data; + if (ob->type == OB_MESH) { + old = ob->data; if (old) old->id.us--; - ob->data= me; + ob->data = me; id_us_plus((ID *)me); } @@ -887,24 +886,24 @@ static void to_edgesort(struct edgesort *ed, unsigned int v1, unsigned int v2, short is_loose, short is_draw) { - if (v1v1= v1; ed->v2= v2; + if (v1 < v2) { + ed->v1 = v1; ed->v2 = v2; } else { - ed->v1= v2; ed->v2= v1; + ed->v1 = v2; ed->v2 = v1; } - ed->is_loose= is_loose; - ed->is_draw= is_draw; + ed->is_loose = is_loose; + ed->is_draw = is_draw; } static int vergedgesort(const void *v1, const void *v2) { - const struct edgesort *x1=v1, *x2=v2; + const struct edgesort *x1 = v1, *x2 = v2; - if ( x1->v1 > x2->v1) return 1; - else if ( x1->v1 < x2->v1) return -1; - else if ( x1->v2 > x2->v2) return 1; - else if ( x1->v2 < x2->v2) return -1; + if (x1->v1 > x2->v1) return 1; + else if (x1->v1 < x2->v1) return -1; + else if (x1->v2 > x2->v2) return 1; + else if (x1->v2 < x2->v2) return -1; return 0; } @@ -912,8 +911,8 @@ static int vergedgesort(const void *v1, const void *v2) /* Create edges based on known verts and faces */ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *allloop, - MPoly *allpoly, int UNUSED(totvert), int totface, int UNUSED(totloop), int totpoly, - int old, MEdge **alledge, int *_totedge) + MPoly *allpoly, int UNUSED(totvert), int totface, int UNUSED(totloop), int totpoly, + int old, MEdge **alledge, int *_totedge) { MPoly *mpoly; MLoop *mloop; @@ -921,26 +920,26 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll MEdge *medge; EdgeHash *hash = BLI_edgehash_new(); struct edgesort *edsort, *ed; - int a, b, totedge=0, final=0; + int a, b, totedge = 0, final = 0; /* we put all edges in array, sort them, and detect doubles that way */ - for (a= totface, mface= allface; a>0; a--, mface++) { - if (mface->v4) totedge+=4; - else if (mface->v3) totedge+=3; - else totedge+=1; + for (a = totface, mface = allface; a > 0; a--, mface++) { + if (mface->v4) totedge += 4; + else if (mface->v3) totedge += 3; + else totedge += 1; } - if (totedge==0) { + if (totedge == 0) { /* flag that mesh has edges */ - (*alledge)= MEM_callocN(0, "make mesh edges"); + (*alledge) = MEM_callocN(0, "make mesh edges"); (*_totedge) = 0; return; } - ed= edsort= MEM_mallocN(totedge*sizeof(struct edgesort), "edgesort"); + ed = edsort = MEM_mallocN(totedge * sizeof(struct edgesort), "edgesort"); - for (a= totface, mface= allface; a>0; a--, mface++) { + for (a = totface, mface = allface; a > 0; a--, mface++) { to_edgesort(ed++, mface->v1, mface->v2, !mface->v3, mface->edcode & ME_V1V2); if (mface->v4) { to_edgesort(ed++, mface->v2, mface->v3, 0, mface->edcode & ME_V2V3); @@ -956,54 +955,54 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll qsort(edsort, totedge, sizeof(struct edgesort), vergedgesort); /* count final amount */ - for (a=totedge, ed=edsort; a>1; a--, ed++) { + for (a = totedge, ed = edsort; a > 1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ - if (ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) final++; + if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) final++; } final++; - (*alledge)= medge= MEM_callocN(sizeof (MEdge) * final, "make_edges mdge"); - (*_totedge)= final; + (*alledge) = medge = MEM_callocN(sizeof (MEdge) * final, "BKE_mesh_make_edges mdge"); + (*_totedge) = final; - for (a=totedge, ed=edsort; a>1; a--, ed++) { + for (a = totedge, ed = edsort; a > 1; a--, ed++) { /* edge is unique when it differs from next edge, or is last */ - if (ed->v1 != (ed+1)->v1 || ed->v2 != (ed+1)->v2) { - medge->v1= ed->v1; - medge->v2= ed->v2; - if (old==0 || ed->is_draw) medge->flag= ME_EDGEDRAW|ME_EDGERENDER; - if (ed->is_loose) medge->flag|= ME_LOOSEEDGE; + if (ed->v1 != (ed + 1)->v1 || ed->v2 != (ed + 1)->v2) { + medge->v1 = ed->v1; + medge->v2 = ed->v2; + if (old == 0 || ed->is_draw) medge->flag = ME_EDGEDRAW | ME_EDGERENDER; + if (ed->is_loose) medge->flag |= ME_LOOSEEDGE; /* order is swapped so extruding this edge as a surface wont flip face normals * with cyclic curves */ - if (ed->v1+1 != ed->v2) { + if (ed->v1 + 1 != ed->v2) { SWAP(unsigned int, medge->v1, medge->v2); } medge++; } else { /* equal edge, we merge the drawflag */ - (ed+1)->is_draw |= ed->is_draw; + (ed + 1)->is_draw |= ed->is_draw; } } /* last edge */ - medge->v1= ed->v1; - medge->v2= ed->v2; - medge->flag= ME_EDGEDRAW; - if (ed->is_loose) medge->flag|= ME_LOOSEEDGE; + medge->v1 = ed->v1; + medge->v2 = ed->v2; + medge->flag = ME_EDGEDRAW; + if (ed->is_loose) medge->flag |= ME_LOOSEEDGE; medge->flag |= ME_EDGERENDER; MEM_freeN(edsort); /*set edge members of mloops*/ - medge= *alledge; - for (a=0; a<*_totedge; a++, medge++) { + medge = *alledge; + for (a = 0; a < *_totedge; a++, medge++) { BLI_edgehash_insert(hash, medge->v1, medge->v2, SET_INT_IN_POINTER(a)); } mpoly = allpoly; - for (a=0; aloopstart; - for (b=0; btotloop; b++) { + for (b = 0; b < mpoly->totloop; b++) { int v1, v2; v1 = mloop[b].v; @@ -1015,28 +1014,28 @@ static void make_edges_mdata(MVert *UNUSED(allvert), MFace *allface, MLoop *alll BLI_edgehash_free(hash, NULL); } -void make_edges(Mesh *me, int old) +void BKE_mesh_make_edges(Mesh *me, int old) { MEdge *medge; - int totedge=0; + int totedge = 0; make_edges_mdata(me->mvert, me->mface, me->mloop, me->mpoly, me->totvert, me->totface, me->totloop, me->totpoly, old, &medge, &totedge); - if (totedge==0) { + if (totedge == 0) { /* flag that mesh has edges */ me->medge = medge; me->totedge = 0; return; } - medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); - me->medge= medge; - me->totedge= totedge; + medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, medge, totedge); + me->medge = medge; + me->totedge = totedge; - mesh_strip_loose_faces(me); + BKE_mesh_strip_loose_faces(me); } /* We need to keep this for edge creation (for now?), and some old readfile code... */ -void mesh_strip_loose_faces(Mesh *me) +void BKE_mesh_strip_loose_faces(Mesh *me) { MFace *f; int a, b; @@ -1060,7 +1059,7 @@ void mesh_strip_loose_faces(Mesh *me) /* Note: It won't try to guess which loops of an invalid poly to remove! * this is the work of the caller, to mark those loops... * See e.g. BKE_mesh_validate_arrays(). */ -void mesh_strip_loose_polysloops(Mesh *me) +void BKE_mesh_strip_loose_polysloops(Mesh *me) { MPoly *p; MLoop *l; @@ -1131,7 +1130,7 @@ void mesh_strip_loose_polysloops(Mesh *me) MEM_freeN(new_idx); } -void mesh_strip_loose_edges(Mesh *me) +void BKE_mesh_strip_loose_edges(Mesh *me) { MEdge *e; MLoop *l; @@ -1166,7 +1165,7 @@ void mesh_strip_loose_edges(Mesh *me) MEM_freeN(new_idx); } -void mball_to_mesh(ListBase *lb, Mesh *me) +void BKE_mesh_from_metaball(ListBase *lb, Mesh *me) { DispList *dl; MVert *mvert; @@ -1175,55 +1174,55 @@ void mball_to_mesh(ListBase *lb, Mesh *me) float *nors, *verts; int a, *index; - dl= lb->first; - if (dl==NULL) return; + dl = lb->first; + if (dl == NULL) return; - if (dl->type==DL_INDEX4) { - mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, dl->nr); - allloop= mloop= CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, dl->parts * 4); - mpoly= CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, dl->parts); - me->mvert= mvert; - me->mloop= mloop; - me->mpoly= mpoly; - me->totvert= dl->nr; - me->totpoly= dl->parts; + if (dl->type == DL_INDEX4) { + mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_CALLOC, NULL, dl->nr); + allloop = mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_CALLOC, NULL, dl->parts * 4); + mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_CALLOC, NULL, dl->parts); + me->mvert = mvert; + me->mloop = mloop; + me->mpoly = mpoly; + me->totvert = dl->nr; + me->totpoly = dl->parts; - a= dl->nr; - nors= dl->nors; - verts= dl->verts; + a = dl->nr; + nors = dl->nors; + verts = dl->verts; while (a--) { copy_v3_v3(mvert->co, verts); normal_float_to_short_v3(mvert->no, nors); mvert++; - nors+= 3; - verts+= 3; + nors += 3; + verts += 3; } - a= dl->parts; - index= dl->index; + a = dl->parts; + index = dl->index; while (a--) { - int count= index[2] != index[3] ? 4 : 3; + int count = index[2] != index[3] ? 4 : 3; - mloop[0].v= index[0]; - mloop[1].v= index[1]; - mloop[2].v= index[2]; + mloop[0].v = index[0]; + mloop[1].v = index[1]; + mloop[2].v = index[2]; if (count == 4) - mloop[3].v= index[3]; + mloop[3].v = index[3]; - mpoly->totloop= count; - mpoly->loopstart= (int)(mloop - allloop); - mpoly->flag= ME_SMOOTH; + mpoly->totloop = count; + mpoly->loopstart = (int)(mloop - allloop); + mpoly->flag = ME_SMOOTH; mpoly++; - mloop+= count; - me->totloop+= count; - index+= 4; + mloop += count; + me->totloop += count; + index += 4; } mesh_update_customdata_pointers(me, TRUE); - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); BKE_mesh_calc_edges(me, TRUE); } @@ -1231,15 +1230,15 @@ void mball_to_mesh(ListBase *lb, Mesh *me) /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* return non-zero on error */ -int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, - MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly, - int *totloop, int *totpoly) +int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, + MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly, + int *totloop, int *totpoly) { - return nurbs_to_mdata_customdb(ob, &ob->disp, - allvert, totvert, - alledge, totedge, - allloop, allpoly, - totloop, totpoly); + return BKE_mesh_nurbs_to_mdata_customdb(ob, &ob->disp, + allvert, totvert, + alledge, totedge, + allloop, allpoly, + totloop, totpoly); } /* BMESH: this doesn't calculate all edges from polygons, @@ -1247,11 +1246,11 @@ int nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert, /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* use specified dispbase */ -int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, - MVert **allvert, int *_totvert, - MEdge **alledge, int *_totedge, - MLoop **allloop, MPoly **allpoly, - int *_totloop, int *_totpoly) +int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, + MVert **allvert, int *_totvert, + MEdge **alledge, int *_totedge, + MLoop **allloop, MPoly **allpoly, + int *_totloop, int *_totpoly) { DispList *dl; Curve *cu; @@ -1260,46 +1259,46 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, MLoop *mloop; MEdge *medge; float *data; - int a, b, ofs, vertcount, startvert, totvert=0, totedge=0, totloop=0, totvlak=0; + int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totvlak = 0; int p1, p2, p3, p4, *index; - int conv_polys= 0; + int conv_polys = 0; - cu= ob->data; + cu = ob->data; - conv_polys|= cu->flag & CU_3D; /* 2d polys are filled with DL_INDEX3 displists */ - conv_polys|= ob->type == OB_SURF; /* surf polys are never filled */ + conv_polys |= cu->flag & CU_3D; /* 2d polys are filled with DL_INDEX3 displists */ + conv_polys |= ob->type == OB_SURF; /* surf polys are never filled */ /* count */ - dl= dispbase->first; + dl = dispbase->first; while (dl) { - if (dl->type==DL_SEGM) { - totvert+= dl->parts*dl->nr; - totedge+= dl->parts*(dl->nr-1); + if (dl->type == DL_SEGM) { + totvert += dl->parts * dl->nr; + totedge += dl->parts * (dl->nr - 1); } - else if (dl->type==DL_POLY) { + else if (dl->type == DL_POLY) { if (conv_polys) { - totvert+= dl->parts*dl->nr; - totedge+= dl->parts*dl->nr; + totvert += dl->parts * dl->nr; + totedge += dl->parts * dl->nr; } } - else if (dl->type==DL_SURF) { + else if (dl->type == DL_SURF) { int tot; - totvert+= dl->parts*dl->nr; - tot = (dl->parts-1+((dl->flag & DL_CYCL_V)==2))*(dl->nr-1+(dl->flag & DL_CYCL_U)); + totvert += dl->parts * dl->nr; + tot = (dl->parts - 1 + ((dl->flag & DL_CYCL_V) == 2)) * (dl->nr - 1 + (dl->flag & DL_CYCL_U)); totvlak += tot; totloop += tot * 4; } - else if (dl->type==DL_INDEX3) { + else if (dl->type == DL_INDEX3) { int tot; - totvert+= dl->nr; + totvert += dl->nr; tot = dl->parts; - totvlak+= tot; + totvlak += tot; totloop += tot * 3; } - dl= dl->next; + dl = dl->next; } - if (totvert==0) { + if (totvert == 0) { /* error("can't convert"); */ /* Make Sure you check ob->data is a curve */ return -1; @@ -1311,28 +1310,28 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, *allpoly = mpoly = MEM_callocN(sizeof(MPoly) * totvlak, "nurbs_init mloop"); /* verts and faces */ - vertcount= 0; + vertcount = 0; - dl= dispbase->first; + dl = dispbase->first; while (dl) { - int smooth= dl->rt & CU_SMOOTH ? 1 : 0; + int smooth = dl->rt & CU_SMOOTH ? 1 : 0; - if (dl->type==DL_SEGM) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; + if (dl->type == DL_SEGM) { + startvert = vertcount; + a = dl->parts * dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - for (a=0; aparts; a++) { - ofs= a*dl->nr; - for (b=1; bnr; b++) { - medge->v1= startvert+ofs+b-1; - medge->v2= startvert+ofs+b; + for (a = 0; a < dl->parts; a++) { + ofs = a * dl->nr; + for (b = 1; b < dl->nr; b++) { + medge->v1 = startvert + ofs + b - 1; + medge->v2 = startvert + ofs + b; medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; medge++; @@ -1340,122 +1339,122 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, } } - else if (dl->type==DL_POLY) { + else if (dl->type == DL_POLY) { if (conv_polys) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; + startvert = vertcount; + a = dl->parts * dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - for (a=0; aparts; a++) { - ofs= a*dl->nr; - for (b=0; bnr; b++) { - medge->v1= startvert+ofs+b; - if (b==dl->nr-1) medge->v2= startvert+ofs; - else medge->v2= startvert+ofs+b+1; + for (a = 0; a < dl->parts; a++) { + ofs = a * dl->nr; + for (b = 0; b < dl->nr; b++) { + medge->v1 = startvert + ofs + b; + if (b == dl->nr - 1) medge->v2 = startvert + ofs; + else medge->v2 = startvert + ofs + b + 1; medge->flag = ME_LOOSEEDGE | ME_EDGERENDER | ME_EDGEDRAW; medge++; } } } } - else if (dl->type==DL_INDEX3) { - startvert= vertcount; - a= dl->nr; - data= dl->verts; + else if (dl->type == DL_INDEX3) { + startvert = vertcount; + a = dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - a= dl->parts; - index= dl->index; + a = dl->parts; + index = dl->index; while (a--) { - mloop[0].v = startvert+index[0]; - mloop[1].v = startvert+index[2]; - mloop[2].v = startvert+index[1]; + mloop[0].v = startvert + index[0]; + mloop[1].v = startvert + index[2]; + mloop[2].v = startvert + index[1]; mpoly->loopstart = (int)(mloop - (*allloop)); mpoly->totloop = 3; mpoly->mat_nr = dl->col; if (smooth) mpoly->flag |= ME_SMOOTH; mpoly++; - mloop+= 3; - index+= 3; + mloop += 3; + index += 3; } } - else if (dl->type==DL_SURF) { - startvert= vertcount; - a= dl->parts*dl->nr; - data= dl->verts; + else if (dl->type == DL_SURF) { + startvert = vertcount; + a = dl->parts * dl->nr; + data = dl->verts; while (a--) { copy_v3_v3(mvert->co, data); - data+=3; + data += 3; vertcount++; mvert++; } - for (a=0; aparts; a++) { + for (a = 0; a < dl->parts; a++) { - if ( (dl->flag & DL_CYCL_V)==0 && a==dl->parts-1) break; + if ( (dl->flag & DL_CYCL_V) == 0 && a == dl->parts - 1) break; - if (dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */ - p1= startvert+ dl->nr*a; /* p4 -> p3 -> */ - p2= p1+ dl->nr-1; /* -----> next row */ - p3= p1+ dl->nr; - p4= p2+ dl->nr; - b= 0; + if (dl->flag & DL_CYCL_U) { /* p2 -> p1 -> */ + p1 = startvert + dl->nr * a; /* p4 -> p3 -> */ + p2 = p1 + dl->nr - 1; /* -----> next row */ + p3 = p1 + dl->nr; + p4 = p2 + dl->nr; + b = 0; } else { - p2= startvert+ dl->nr*a; - p1= p2+1; - p4= p2+ dl->nr; - p3= p1+ dl->nr; - b= 1; + p2 = startvert + dl->nr * a; + p1 = p2 + 1; + p4 = p2 + dl->nr; + p3 = p1 + dl->nr; + b = 1; } - if ( (dl->flag & DL_CYCL_V) && a==dl->parts-1) { - p3-= dl->parts*dl->nr; - p4-= dl->parts*dl->nr; + if ( (dl->flag & DL_CYCL_V) && a == dl->parts - 1) { + p3 -= dl->parts * dl->nr; + p4 -= dl->parts * dl->nr; } - for (; bnr; b++) { - mloop[0].v= p1; - mloop[1].v= p3; - mloop[2].v= p4; - mloop[3].v= p2; + for (; b < dl->nr; b++) { + mloop[0].v = p1; + mloop[1].v = p3; + mloop[2].v = p4; + mloop[3].v = p2; mpoly->loopstart = (int)(mloop - (*allloop)); mpoly->totloop = 4; mpoly->mat_nr = dl->col; if (smooth) mpoly->flag |= ME_SMOOTH; mpoly++; - mloop+= 4; + mloop += 4; - p4= p3; + p4 = p3; p3++; - p2= p1; + p2 = p1; p1++; } } } - dl= dl->next; + dl = dl->next; } - *_totpoly= totvlak; - *_totloop= totloop; - *_totedge= totedge; - *_totvert= totvert; + *_totpoly = totvlak; + *_totloop = totloop; + *_totedge = totedge; + *_totvert = totvert; /* not uded for bmesh */ #if 0 @@ -1467,72 +1466,75 @@ int nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase, } /* this may fail replacing ob->data, be sure to check ob->type */ -void nurbs_to_mesh(Object *ob) +void BKE_mesh_from_nurbs(Object *ob) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob1; - DerivedMesh *dm= ob->derivedFinal; + DerivedMesh *dm = ob->derivedFinal; Mesh *me; Curve *cu; - MVert *allvert= NULL; - MEdge *alledge= NULL; + MVert *allvert = NULL; + MEdge *alledge = NULL; MLoop *allloop = NULL; MPoly *allpoly = NULL; int totvert, totedge, totloop, totpoly; - cu= ob->data; + cu = ob->data; if (dm == NULL) { - if (nurbs_to_mdata(ob, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, &totloop, &totpoly) != 0) { + if (BKE_mesh_nurbs_to_mdata(ob, &allvert, &totvert, + &alledge, &totedge, &allloop, + &allpoly, &totloop, &totpoly) != 0) + { /* Error initializing */ return; } /* make mesh */ - me= add_mesh("Mesh"); - me->totvert= totvert; - me->totedge= totedge; + me = BKE_mesh_add("Mesh"); + me->totvert = totvert; + me->totedge = totedge; me->totloop = totloop; me->totpoly = totpoly; - me->mvert= CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert); - me->medge= CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge); - me->mloop= CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop); - me->mpoly= CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly); + me->mvert = CustomData_add_layer(&me->vdata, CD_MVERT, CD_ASSIGN, allvert, me->totvert); + me->medge = CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, alledge, me->totedge); + me->mloop = CustomData_add_layer(&me->ldata, CD_MLOOP, CD_ASSIGN, allloop, me->totloop); + me->mpoly = CustomData_add_layer(&me->pdata, CD_MPOLY, CD_ASSIGN, allpoly, me->totpoly); - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); BKE_mesh_calc_edges(me, TRUE); } else { - me= add_mesh("Mesh"); + me = BKE_mesh_add("Mesh"); DM_to_mesh(dm, me, ob); } - me->totcol= cu->totcol; - me->mat= cu->mat; + me->totcol = cu->totcol; + me->mat = cu->mat; - tex_space_mesh(me); + BKE_mesh_texspace_calc(me); - cu->mat= NULL; - cu->totcol= 0; + cu->mat = NULL; + cu->totcol = 0; if (ob->data) { - free_libblock(&bmain->curve, ob->data); + BKE_libblock_free(&bmain->curve, ob->data); } - ob->data= me; - ob->type= OB_MESH; + ob->data = me; + ob->type = OB_MESH; /* other users */ - ob1= bmain->object.first; + ob1 = bmain->object.first; while (ob1) { - if (ob1->data==cu) { - ob1->type= OB_MESH; + if (ob1->data == cu) { + ob1->type = OB_MESH; - ob1->data= ob->data; + ob1->data = ob->data; id_us_plus((ID *)ob->data); } - ob1= ob1->id.next; + ob1 = ob1->id.next; } } @@ -1548,26 +1550,26 @@ typedef struct VertLink { static void prependPolyLineVert(ListBase *lb, unsigned int index) { - VertLink *vl= MEM_callocN(sizeof(VertLink), "VertLink"); + VertLink *vl = MEM_callocN(sizeof(VertLink), "VertLink"); vl->index = index; BLI_addhead(lb, vl); } static void appendPolyLineVert(ListBase *lb, unsigned int index) { - VertLink *vl= MEM_callocN(sizeof(VertLink), "VertLink"); + VertLink *vl = MEM_callocN(sizeof(VertLink), "VertLink"); vl->index = index; BLI_addtail(lb, vl); } -void mesh_to_curve(Scene *scene, Object *ob) +void BKE_mesh_from_curve(Scene *scene, Object *ob) { /* make new mesh data from the original copy */ - DerivedMesh *dm= mesh_get_derived_final(scene, ob, CD_MASK_MESH); + DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); - MVert *mverts= dm->getVertArray(dm); - MEdge *med, *medge= dm->getEdgeArray(dm); - MFace *mf, *mface= dm->getTessFaceArray(dm); + MVert *mverts = dm->getVertArray(dm); + MEdge *med, *medge = dm->getEdgeArray(dm); + MFace *mf, *mface = dm->getTessFaceArray(dm); int totedge = dm->getNumEdges(dm); int totface = dm->getNumTessFaces(dm); @@ -1582,7 +1584,7 @@ void mesh_to_curve(Scene *scene, Object *ob) ListBase edges = {NULL, NULL}; /* create edges from all faces (so as to find edges not in any faces) */ - mf= mface; + mf = mface; for (i = 0; i < totface; i++, mf++) { if (!BLI_edgehash_haskey(eh, mf->v1, mf->v2)) BLI_edgehash_insert(eh, mf->v1, mf->v2, NULL); @@ -1601,22 +1603,22 @@ void mesh_to_curve(Scene *scene, Object *ob) } } - med= medge; - for (i=0; iv1, med->v2)) { - EdgeLink *edl= MEM_callocN(sizeof(EdgeLink), "EdgeLink"); + EdgeLink *edl = MEM_callocN(sizeof(EdgeLink), "EdgeLink"); BLI_edgehash_insert(eh_edge, med->v1, med->v2, NULL); - edl->edge= med; + edl->edge = med; - BLI_addtail(&edges, edl); totedges++; + BLI_addtail(&edges, edl); totedges++; } } BLI_edgehash_free(eh_edge, NULL); BLI_edgehash_free(eh, NULL); if (edges.first) { - Curve *cu = BKE_curve_add(ob->id.name+2, OB_CURVE); + Curve *cu = BKE_curve_add(ob->id.name + 2, OB_CURVE); cu->flag |= CU_3D; while (edges.first) { @@ -1624,55 +1626,55 @@ void mesh_to_curve(Scene *scene, Object *ob) ListBase polyline = {NULL, NULL}; /* store a list of VertLink's */ int closed = FALSE; - int totpoly= 0; - MEdge *med_current= ((EdgeLink *)edges.last)->edge; - unsigned int startVert= med_current->v1; - unsigned int endVert= med_current->v2; - int ok= TRUE; + int totpoly = 0; + MEdge *med_current = ((EdgeLink *)edges.last)->edge; + unsigned int startVert = med_current->v1; + unsigned int endVert = med_current->v2; + int ok = TRUE; - appendPolyLineVert(&polyline, startVert); totpoly++; - appendPolyLineVert(&polyline, endVert); totpoly++; - BLI_freelinkN(&edges, edges.last); totedges--; + appendPolyLineVert(&polyline, startVert); totpoly++; + appendPolyLineVert(&polyline, endVert); totpoly++; + BLI_freelinkN(&edges, edges.last); totedges--; while (ok) { /* while connected edges are found... */ ok = FALSE; - i= totedges; + i = totedges; while (i) { EdgeLink *edl; - i-=1; - edl= BLI_findlink(&edges, i); - med= edl->edge; + i -= 1; + edl = BLI_findlink(&edges, i); + med = edl->edge; - if (med->v1==endVert) { + if (med->v1 == endVert) { endVert = med->v2; - appendPolyLineVert(&polyline, med->v2); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + appendPolyLineVert(&polyline, med->v2); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } - else if (med->v2==endVert) { + else if (med->v2 == endVert) { endVert = med->v1; - appendPolyLineVert(&polyline, endVert); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + appendPolyLineVert(&polyline, endVert); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } - else if (med->v1==startVert) { + else if (med->v1 == startVert) { startVert = med->v2; - prependPolyLineVert(&polyline, startVert); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + prependPolyLineVert(&polyline, startVert); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } - else if (med->v2==startVert) { + else if (med->v2 == startVert) { startVert = med->v1; - prependPolyLineVert(&polyline, startVert); totpoly++; - BLI_freelinkN(&edges, edl); totedges--; - ok= TRUE; + prependPolyLineVert(&polyline, startVert); totpoly++; + BLI_freelinkN(&edges, edl); totedges--; + ok = TRUE; } } } /* Now we have a polyline, make into a curve */ - if (startVert==endVert) { + if (startVert == endVert) { BLI_freelinkN(&polyline, polyline.last); totpoly--; closed = TRUE; @@ -1687,19 +1689,19 @@ void mesh_to_curve(Scene *scene, Object *ob) /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "MeshNurb"); - nu->pntsu= totpoly; - nu->pntsv= 1; - nu->orderu= 4; - nu->flagu= CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC:0); /* endpoint */ - nu->resolu= 12; + nu->pntsu = totpoly; + nu->pntsv = 1; + nu->orderu = 4; + nu->flagu = CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC : 0); /* endpoint */ + nu->resolu = 12; - nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*totpoly, "bpoints"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * totpoly, "bpoints"); /* add points */ - vl= polyline.first; - for (i=0, bp=nu->bp; i < totpoly; i++, bp++, vl=(VertLink *)vl->next) { + vl = polyline.first; + for (i = 0, bp = nu->bp; i < totpoly; i++, bp++, vl = (VertLink *)vl->next) { copy_v3_v3(bp->vec, mverts[vl->index].co); - bp->f1= SELECT; + bp->f1 = SELECT; bp->radius = bp->weight = 1.0; } BLI_freelistN(&polyline); @@ -1711,11 +1713,11 @@ void mesh_to_curve(Scene *scene, Object *ob) } ((Mesh *)ob->data)->id.us--; - ob->data= cu; - ob->type= OB_CURVE; + ob->data = cu; + ob->type = OB_CURVE; /* curve objects can't contain DM in usual cases, we could free memory */ - needsFree= 1; + needsFree = 1; } dm->needsFree = needsFree; @@ -1727,35 +1729,35 @@ void mesh_to_curve(Scene *scene, Object *ob) /* curve object could have got bounding box only in special cases */ if (ob->bb) { MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; } } } -void mesh_delete_material_index(Mesh *me, short index) +void BKE_mesh_delete_material_index(Mesh *me, short index) { int i; - for (i=0; itotpoly; i++) { - MPoly *mp = &((MPoly*) me->mpoly)[i]; - if (mp->mat_nr && mp->mat_nr>=index) + for (i = 0; i < me->totpoly; i++) { + MPoly *mp = &((MPoly *) me->mpoly)[i]; + if (mp->mat_nr && mp->mat_nr >= index) mp->mat_nr--; } - for (i=0; itotface; i++) { - MFace *mf = &((MFace*) me->mface)[i]; - if (mf->mat_nr && mf->mat_nr>=index) + for (i = 0; i < me->totface; i++) { + MFace *mf = &((MFace *) me->mface)[i]; + if (mf->mat_nr && mf->mat_nr >= index) mf->mat_nr--; } } -void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) +void BKE_mesh_smooth_flag_set(Object *meshOb, int enableSmooth) { Mesh *me = meshOb->data; int i; - for (i=0; itotpoly; i++) { - MPoly *mp = &((MPoly*) me->mpoly)[i]; + for (i = 0; i < me->totpoly; i++) { + MPoly *mp = &((MPoly *) me->mpoly)[i]; if (enableSmooth) { mp->flag |= ME_SMOOTH; @@ -1765,8 +1767,8 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) } } - for (i=0; itotface; i++) { - MFace *mf = &((MFace*) me->mface)[i]; + for (i = 0; i < me->totface; i++) { + MFace *mf = &((MFace *) me->mface)[i]; if (enableSmooth) { mf->flag |= ME_SMOOTH; @@ -1777,20 +1779,20 @@ void mesh_set_smooth_flag(Object *meshOb, int enableSmooth) } } -void mesh_calc_normals_mapping(MVert *mverts, int numVerts, - MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], - MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]) +void BKE_mesh_calc_normals_mapping(MVert *mverts, int numVerts, + MLoop *mloop, MPoly *mpolys, int numLoops, int numPolys, float (*polyNors_r)[3], + MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3]) { - mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, - numLoops, numPolys, polyNors_r, mfaces, numFaces, - origIndexFace, faceNors_r, FALSE); + BKE_mesh_calc_normals_mapping_ex(mverts, numVerts, mloop, mpolys, + numLoops, numPolys, polyNors_r, mfaces, numFaces, + origIndexFace, faceNors_r, FALSE); } -void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, - MLoop *mloop, MPoly *mpolys, - int numLoops, int numPolys, float (*polyNors_r)[3], - MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], - const short only_face_normals) +void BKE_mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, + MLoop *mloop, MPoly *mpolys, + int numLoops, int numPolys, float (*polyNors_r)[3], + MFace *mfaces, int numFaces, int *origIndexFace, float (*faceNors_r)[3], + const short only_face_normals) { float (*pnors)[3] = polyNors_r, (*fnors)[3] = faceNors_r; int i; @@ -1814,29 +1816,29 @@ void mesh_calc_normals_mapping_ex(MVert *mverts, int numVerts, if (only_face_normals == FALSE) { /* vertex normals are optional, they require some extra calculations, * so make them optional */ - mesh_calc_normals(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors); + BKE_mesh_calc_normals(mverts, numVerts, mloop, mpolys, numLoops, numPolys, pnors); } else { /* only calc poly normals */ mp = mpolys; - for (i=0; iloopstart, mverts, pnors[i]); + for (i = 0; i < numPolys; i++, mp++) { + mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]); } } - if ( origIndexFace && - /* fnors==faceNors_r */ /* NO NEED TO ALLOC YET */ - fnors != NULL && - numFaces) + if (origIndexFace && + /* fnors==faceNors_r */ /* NO NEED TO ALLOC YET */ + fnors != NULL && + numFaces) { mf = mfaces; - for (i=0; iloopstart, mverts, pnors[i]); + for (i = 0; i < numPolys; i++, mp++) { + mesh_calc_poly_normal(mp, mloop + mp->loopstart, mverts, pnors[i]); ml = mloop + mp->loopstart; BLI_array_empty(vertcos); @@ -1878,7 +1880,7 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, BLI_array_grow_items(vertcos, mp->totloop); BLI_array_grow_items(vertnos, mp->totloop); - for (j=0; j < mp->totloop; j++) { + for (j = 0; j < mp->totloop; j++) { int vindex = ml[j].v; vertcos[j] = mverts[vindex].co; vertnos[j] = tnorms[vindex]; @@ -1895,9 +1897,9 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, BLI_array_free(edgevecbuf); /* following Mesh convention; we use vertex coordinate itself for normal in this case */ - for (i=0; ico); @@ -1910,17 +1912,17 @@ void mesh_calc_normals(MVert *mverts, int numVerts, MLoop *mloop, MPoly *mpolys, if (pnors != polyNors_r) MEM_freeN(pnors); } -void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3]) +void BKE_mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int numFaces, float (*faceNors_r)[3]) { - float (*tnorms)[3]= MEM_callocN(numVerts*sizeof(*tnorms), "tnorms"); - float (*fnors)[3]= (faceNors_r)? faceNors_r: MEM_callocN(sizeof(*fnors)*numFaces, "meshnormals"); + float (*tnorms)[3] = MEM_callocN(numVerts * sizeof(*tnorms), "tnorms"); + float (*fnors)[3] = (faceNors_r) ? faceNors_r : MEM_callocN(sizeof(*fnors) * numFaces, "meshnormals"); int i; - for (i=0; iv4)? tnorms[mf->v4]: NULL; - float *c4 = (mf->v4)? mverts[mf->v4].co: NULL; + for (i = 0; i < numFaces; i++) { + MFace *mf = &mfaces[i]; + float *f_no = fnors[i]; + float *n4 = (mf->v4) ? tnorms[mf->v4] : NULL; + float *c4 = (mf->v4) ? mverts[mf->v4].co : NULL; if (mf->v4) normal_quad_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, mverts[mf->v4].co); @@ -1928,13 +1930,13 @@ void mesh_calc_normals_tessface(MVert *mverts, int numVerts, MFace *mfaces, int normal_tri_v3(f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co); accumulate_vertex_normals(tnorms[mf->v1], tnorms[mf->v2], tnorms[mf->v3], n4, - f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); + f_no, mverts[mf->v1].co, mverts[mf->v2].co, mverts[mf->v3].co, c4); } /* following Mesh convention; we use vertex coordinate itself for normal in this case */ - for (i=0; ico); @@ -1961,7 +1963,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, mf = me->mface + findex; - for (i=0; i < numTex; i++) { + for (i = 0; i < numTex; i++) { texface = CustomData_get_n(&me->fdata, CD_MTFACE, findex, i); texpoly = CustomData_get_n(&me->pdata, CD_MTEXPOLY, findex, i); @@ -1977,7 +1979,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, } } - for (i=0; i < numCol; i++) { + for (i = 0; i < numCol; i++) { mloopcol = CustomData_get_n(&me->ldata, CD_MLOOPCOL, loopstart, i); mcol = CustomData_get_n(&me->fdata, CD_MCOL, findex, i); @@ -1998,7 +2000,7 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, if (CustomData_external_test(&me->fdata, CD_MDISPS)) { CustomData_external_add(&me->ldata, &me->id, CD_MDISPS, - me->totloop, me->fdata.external->filename); + me->totloop, me->fdata.external->filename); } corners = multires_mdisp_corners(fd); @@ -2012,16 +2014,16 @@ static void bm_corners_to_loops(Mesh *me, int findex, int loopstart, int numTex, else { side = sqrt(fd->totdisp / corners); - for (i=0; itotdisp = side*side; + for (i = 0; i < tot; i++, disps += side * side, ld++) { + ld->totdisp = side * side; ld->level = (int)(logf(side - 1.0f) / (float)M_LN2) + 1; if (ld->disps) MEM_freeN(ld->disps); - ld->disps = MEM_callocN(sizeof(float)*3*side*side, "converted loop mdisps"); + ld->disps = MEM_callocN(sizeof(float) * 3 * side * side, "converted loop mdisps"); if (fd->disps) { - memcpy(ld->disps, disps, sizeof(float)*3*side*side); + memcpy(ld->disps, disps, sizeof(float) * 3 * side * side); } } } @@ -2045,7 +2047,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) memset(&mesh->pdata, 0, sizeof(mesh->pdata)); mesh->totpoly = mesh->totface; - mesh->mpoly = MEM_callocN(sizeof(MPoly)*mesh->totpoly, "mpoly converted"); + mesh->mpoly = MEM_callocN(sizeof(MPoly) * mesh->totpoly, "mpoly converted"); CustomData_add_layer(&mesh->pdata, CD_MPOLY, CD_ASSIGN, mesh->mpoly, mesh->totpoly); numTex = CustomData_number_of_layers(&mesh->fdata, CD_MTFACE); @@ -2053,16 +2055,16 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) totloop = 0; mf = mesh->mface; - for (i=0; itotface; i++, mf++) { + for (i = 0; i < mesh->totface; i++, mf++) { totloop += mf->v4 ? 4 : 3; } mesh->totloop = totloop; - mesh->mloop = MEM_callocN(sizeof(MLoop)*mesh->totloop, "mloop converted"); + mesh->mloop = MEM_callocN(sizeof(MLoop) * mesh->totloop, "mloop converted"); CustomData_add_layer(&mesh->ldata, CD_MLOOP, CD_ASSIGN, mesh->mloop, totloop); CustomData_to_bmeshpoly(&mesh->fdata, &mesh->pdata, &mesh->ldata, - mesh->totloop, mesh->totpoly); + mesh->totloop, mesh->totpoly); /* ensure external data is transferred */ CustomData_external_read(&mesh->fdata, &mesh->id, CD_MASK_MDISPS, mesh->totface); @@ -2082,7 +2084,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) ml = mesh->mloop; mf = mesh->mface; mp = mesh->mpoly; - for (i=0; itotface; i++, mf++, mp++) { + for (i = 0; i < mesh->totface; i++, mf++, mp++) { mp->loopstart = j; mp->totloop = mf->v4 ? 4 : 3; @@ -2090,7 +2092,8 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) mp->mat_nr = mf->mat_nr; mp->flag = mf->flag; -# define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++;} +# define ML(v1, v2) {ml->v = mf->v1; ml->e = GET_INT_FROM_POINTER(BLI_edgehash_lookup(eh, mf->v1, mf->v2)); ml++; j++; \ +} ML(v1, v2); ML(v2, v3); @@ -2102,7 +2105,7 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) ML(v3, v1); } -# undef ML +# undef ML bm_corners_to_loops(mesh, i, mp->loopstart, numTex, numCol); } @@ -2115,13 +2118,13 @@ void BKE_mesh_convert_mfaces_to_mpolys(Mesh *mesh) BLI_edgehash_free(eh, NULL); } -float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3] +float (*mesh_getVertexCos(Mesh * me, int *numVerts_r))[3] { int i, numVerts = me->totvert; - float (*cos)[3] = MEM_mallocN(sizeof(*cos)*numVerts, "vertexcos1"); + float (*cos)[3] = MEM_mallocN(sizeof(*cos) * numVerts, "vertexcos1"); if (numVerts_r) *numVerts_r = numVerts; - for (i=0; imvert[i].co); return cos; @@ -2132,103 +2135,103 @@ float (*mesh_getVertexCos(Mesh *me, int *numVerts_r))[3] /* this replaces the non bmesh function (in trunk) which takes MTFace's, if we ever need it back we could * but for now this replaces it because its unused. */ -UvVertMap *make_uv_vert_map(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, float *limit) +UvVertMap *BKE_mesh_uv_vert_map_make(struct MPoly *mpoly, struct MLoop *mloop, struct MLoopUV *mloopuv, unsigned int totpoly, unsigned int totvert, int selected, float *limit) { UvVertMap *vmap; UvMapVert *buf; MPoly *mp; unsigned int a; - int i, totuv, nverts; + int i, totuv, nverts; totuv = 0; /* generate UvMapVert array */ - mp= mpoly; - for (a=0; aflag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) totuv += mp->totloop; - if (totuv==0) + if (totuv == 0) return NULL; - vmap= (UvVertMap*)MEM_callocN(sizeof(*vmap), "UvVertMap"); + vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap"); if (!vmap) return NULL; - vmap->vert= (UvMapVert**)MEM_callocN(sizeof(*vmap->vert)*totvert, "UvMapVert*"); - buf= vmap->buf= (UvMapVert*)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvMapVert"); + vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*"); + buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); return NULL; } - mp= mpoly; - for (a=0; aflag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) { - nverts= mp->totloop; + nverts = mp->totloop; - for (i=0; itfindex= i; - buf->f= a; + for (i = 0; i < nverts; i++) { + buf->tfindex = i; + buf->f = a; buf->separate = 0; - buf->next= vmap->vert[mloop[mp->loopstart + i].v]; - vmap->vert[mloop[mp->loopstart + i].v]= buf; + buf->next = vmap->vert[mloop[mp->loopstart + i].v]; + vmap->vert[mloop[mp->loopstart + i].v] = buf; buf++; } } } /* sort individual uvs for each vert */ - for (a=0; avert[a]; + for (a = 0; a < totvert; a++) { + UvMapVert *newvlist = NULL, *vlist = vmap->vert[a]; UvMapVert *iterv, *v, *lastv, *next; float *uv, *uv2, uvdiff[2]; while (vlist) { - v= vlist; - vlist= vlist->next; - v->next= newvlist; - newvlist= v; + v = vlist; + vlist = vlist->next; + v->next = newvlist; + newvlist = v; - uv= mloopuv[mpoly[v->f].loopstart + v->tfindex].uv; - lastv= NULL; - iterv= vlist; + uv = mloopuv[mpoly[v->f].loopstart + v->tfindex].uv; + lastv = NULL; + iterv = vlist; while (iterv) { - next= iterv->next; + next = iterv->next; - uv2= mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv; + uv2 = mloopuv[mpoly[iterv->f].loopstart + iterv->tfindex].uv; sub_v2_v2v2(uvdiff, uv2, uv); - if (fabsf(uv[0]-uv2[0]) < limit[0] && fabsf(uv[1]-uv2[1]) < limit[1]) { - if (lastv) lastv->next= next; - else vlist= next; - iterv->next= newvlist; - newvlist= iterv; + if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1]) { + if (lastv) lastv->next = next; + else vlist = next; + iterv->next = newvlist; + newvlist = iterv; } else - lastv=iterv; + lastv = iterv; - iterv= next; + iterv = next; } newvlist->separate = 1; } - vmap->vert[a]= newvlist; + vmap->vert[a] = newvlist; } return vmap; } -UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v) +UvMapVert *BKE_mesh_uv_vert_map_get_vert(UvVertMap *vmap, unsigned int v) { return vmap->vert[v]; } -void free_uv_vert_map(UvVertMap *vmap) +void BKE_mesh_uv_vert_map_free(UvVertMap *vmap) { if (vmap) { if (vmap->vert) MEM_freeN(vmap->vert); @@ -2297,22 +2300,22 @@ void create_vert_edge_map(ListBase **map, IndexNode **mem, const MEdge *medge, c for (i = 0; i < totedge; ++i) { for (j = 0; j < 2; ++j, ++node) { node->index = i; - BLI_addtail(&(*map)[((unsigned int*)(&medge[i].v1))[j]], node); + BLI_addtail(&(*map)[((unsigned int *)(&medge[i].v1))[j]], node); } } } -void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, - CustomData *pdata, int lindex[4], int findex, - const int polyindex, - const int mf_len, /* 3 or 4 */ +void BKE_mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, + CustomData *pdata, int lindex[4], int findex, + const int polyindex, + const int mf_len, /* 3 or 4 */ - /* cache values to avoid lookups every time */ - const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */ - const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */ - const int hasPCol, /* CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL) */ - const int hasOrigSpace /* CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP) */ - ) + /* cache values to avoid lookups every time */ + const int numTex, /* CustomData_number_of_layers(pdata, CD_MTEXPOLY) */ + const int numCol, /* CustomData_number_of_layers(ldata, CD_MLOOPCOL) */ + const int hasPCol, /* CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL) */ + const int hasOrigSpace /* CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP) */ + ) { MTFace *texface; MTexPoly *texpoly; @@ -2321,22 +2324,22 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, MLoopUV *mloopuv; int i, j; - for (i=0; i < numTex; i++) { + for (i = 0; i < numTex; i++) { texface = CustomData_get_n(fdata, CD_MTFACE, findex, i); texpoly = CustomData_get_n(pdata, CD_MTEXPOLY, polyindex, i); ME_MTEXFACE_CPY(texface, texpoly); - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { mloopuv = CustomData_get_n(ldata, CD_MLOOPUV, lindex[j], i); copy_v2_v2(texface->uv[j], mloopuv->uv); } } - for (i=0; i < numCol; i++) { + for (i = 0; i < numCol; i++) { mcol = CustomData_get_n(fdata, CD_MCOL, findex, i); - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { mloopcol = CustomData_get_n(ldata, CD_MLOOPCOL, lindex[j], i); MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); } @@ -2345,7 +2348,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, if (hasPCol) { mcol = CustomData_get(fdata, findex, CD_PREVIEW_MCOL); - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { mloopcol = CustomData_get(ldata, lindex[j], CD_PREVIEW_MLOOPCOL); MESH_MLOOPCOL_TO_MCOL(mloopcol, &mcol[j]); } @@ -2355,7 +2358,7 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, OrigSpaceFace *of = CustomData_get(fdata, findex, CD_ORIGSPACE); OrigSpaceLoop *lof; - for (j=0; j < mf_len; j++) { + for (j = 0; j < mf_len; j++) { lof = CustomData_get(ldata, lindex[j], CD_ORIGSPACE_MLOOP); copy_v2_v2(of->uv[j], lof->uv); } @@ -2366,13 +2369,13 @@ void mesh_loops_to_mface_corners(CustomData *fdata, CustomData *ldata, * this function recreates a tessellation. * returns number of tessellation faces. */ -int mesh_recalcTessellation(CustomData *fdata, - CustomData *ldata, CustomData *pdata, - MVert *mvert, int totface, int UNUSED(totloop), - int totpoly, - /* when tessellating to recalculate normals after - * we can skip copying here */ - const int do_face_nor_cpy) +int BKE_mesh_recalc_tessellation(CustomData *fdata, + CustomData *ldata, CustomData *pdata, + MVert *mvert, int totface, int UNUSED(totloop), + int totpoly, + /* when tessellating to recalculate normals after + * we can skip copying here */ + const int do_face_nor_cpy) { /* use this to avoid locking pthread for _every_ polygon * and calling the fill function */ @@ -2380,8 +2383,8 @@ int mesh_recalcTessellation(CustomData *fdata, #define USE_TESSFACE_SPEEDUP #define USE_TESSFACE_QUADS // NEEDS FURTHER TESTING -#define TESSFACE_SCANFILL (1<<0) -#define TESSFACE_IS_QUAD (1<<1) +#define TESSFACE_SCANFILL (1 << 0) +#define TESSFACE_IS_QUAD (1 << 1) MPoly *mp, *mpoly; MLoop *ml, *mloop; @@ -2425,7 +2428,7 @@ int mesh_recalcTessellation(CustomData *fdata, BLI_array_grow_one(mface_to_poly_map); \ BLI_array_grow_one(mface); \ mface_to_poly_map[mface_index] = poly_index; \ - mf= &mface[mface_index]; \ + mf = &mface[mface_index]; \ /* set loop indices, transformed to vert indices later */ \ mf->v1 = mp->loopstart + i1; \ mf->v2 = mp->loopstart + i2; \ @@ -2444,7 +2447,7 @@ int mesh_recalcTessellation(CustomData *fdata, BLI_array_grow_one(mface_to_poly_map); \ BLI_array_grow_one(mface); \ mface_to_poly_map[mface_index] = poly_index; \ - mf= &mface[mface_index]; \ + mf = &mface[mface_index]; \ /* set loop indices, transformed to vert indices later */ \ mf->v1 = mp->loopstart + 0; /* EXCEPTION */ \ mf->v2 = mp->loopstart + 1; /* EXCEPTION */ \ @@ -2484,7 +2487,7 @@ int mesh_recalcTessellation(CustomData *fdata, BLI_scanfill_begin(&sf_ctx); firstv = NULL; lastv = NULL; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { v = BLI_scanfill_vert_add(&sf_ctx, mvert[ml->v].co); v->keyindex = mp->loopstart + j; @@ -2508,7 +2511,7 @@ int mesh_recalcTessellation(CustomData *fdata, for (f = sf_ctx.fillfacebase.first; f; f = f->next, mf++) { mface_to_poly_map[mface_index] = poly_index; - mf= &mface[mface_index]; + mf = &mface[mface_index]; /* set loop indices, transformed to vert indices later */ mf->v1 = f->v1->keyindex; @@ -2576,7 +2579,7 @@ int mesh_recalcTessellation(CustomData *fdata, } mf = mface; - for (mface_index=0; mface_index < totface; mface_index++, mf++) { + for (mface_index = 0; mface_index < totface; mface_index++, mf++) { #ifdef USE_TESSFACE_QUADS const int mf_len = mf->edcode & TESSFACE_IS_QUAD ? 4 : 3; @@ -2618,14 +2621,14 @@ int mesh_recalcTessellation(CustomData *fdata, if (mf_len == 4) mf->v4 = mloop[mf->v4].v; #endif - mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, mface_index, mface_to_poly_map[mface_index], + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + lindex, mface_index, mface_to_poly_map[mface_index], #ifdef USE_TESSFACE_QUADS - mf_len, + mf_len, #else - 3, + 3, #endif - numTex, numCol, hasPCol, hasOrigSpace); + numTex, numCol, hasPCol, hasOrigSpace); #ifdef USE_TESSFACE_QUADS @@ -2647,8 +2650,8 @@ int mesh_recalcTessellation(CustomData *fdata, * this function recreates a tessellation. * returns number of tessellation faces. */ -int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, - struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly) +int BKE_mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, + struct CustomData *pdata, int totface, int UNUSED(totloop), int totpoly) { MLoop *mloop; @@ -2670,7 +2673,7 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mp = mpoly; k = 0; - for (i = 0; itotloop, 3, 4)) { BLI_array_grow_one(mface); mf = &mface[k]; @@ -2693,7 +2696,7 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, CustomData_free(fdata, totface); memset(fdata, 0, sizeof(CustomData)); - totface= k; + totface = k; CustomData_add_layer(fdata, CD_MFACE, CD_ASSIGN, mface, totface); @@ -2701,7 +2704,7 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mp = mpoly; k = 0; - for (i = 0; itotloop, 3, 4)) { mf = &mface[k]; @@ -2719,9 +2722,9 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mf->v2 = mloop[mf->v2].v; mf->v3 = mloop[mf->v3].v; - mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, k, i, 3, - numTex, numCol, hasPCol, hasOrigSpace); + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + lindex, k, i, 3, + numTex, numCol, hasPCol, hasOrigSpace); test_index_face(mf, fdata, k, 3); } else { @@ -2739,13 +2742,13 @@ int mesh_mpoly_to_mface(struct CustomData *fdata, struct CustomData *ldata, mf->v3 = mloop[mf->v3].v; mf->v4 = mloop[mf->v4].v; - mesh_loops_to_mface_corners(fdata, ldata, pdata, - lindex, k, i, 4, - numTex, numCol, hasPCol, hasOrigSpace); + BKE_mesh_loops_to_mface_corners(fdata, ldata, pdata, + lindex, k, i, 4, + numTex, numCol, hasPCol, hasOrigSpace); test_index_face(mf, fdata, k, 4); } - mf->edcode= 0; + mf->edcode = 0; k++; } @@ -2829,8 +2832,8 @@ static void mesh_calc_ngon_normal_coords(MPoly *mpoly, MLoop *loopstart, } } -void mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, - const float (*vertex_coords)[3], float no[3]) +void BKE_mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, + const float (*vertex_coords)[3], float no[3]) { if (mpoly->totloop > 4) { mesh_calc_ngon_normal_coords(mpoly, loopstart, vertex_coords, no); @@ -2860,7 +2863,7 @@ void mesh_calc_poly_normal_coords(MPoly *mpoly, MLoop *loopstart, static void mesh_calc_ngon_center(MPoly *mpoly, MLoop *loopstart, MVert *mvert, float cent[3]) { - const float w= 1.0f / (float)mpoly->totloop; + const float w = 1.0f / (float)mpoly->totloop; int i; zero_v3(cent); @@ -2870,8 +2873,8 @@ static void mesh_calc_ngon_center(MPoly *mpoly, MLoop *loopstart, } } -void mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, - MVert *mvarray, float cent[3]) +void BKE_mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, + MVert *mvarray, float cent[3]) { if (mpoly->totloop == 3) { cent_tri_v3(cent, @@ -2894,8 +2897,8 @@ void mesh_calc_poly_center(MPoly *mpoly, MLoop *loopstart, } /* note, passing polynormal is only a speedup so we can skip calculating it */ -float mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, - MVert *mvarray, float polynormal[3]) +float BKE_mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, + MVert *mvarray, float polynormal[3]) { if (mpoly->totloop == 3) { return area_tri_v3(mvarray[loopstart[0].v].co, @@ -2914,7 +2917,7 @@ float mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, int i; MLoop *l_iter = loopstart; float area, polynorm_local[3], (*vertexcos)[3]; - float *no= polynormal ? polynormal : polynorm_local; + float *no = polynormal ? polynormal : polynorm_local; BLI_array_fixedstack_declare(vertexcos, BM_NGON_STACK_SIZE, mpoly->totloop, __func__); /* pack vertex cos into an array for area_poly_v3 */ @@ -2939,7 +2942,7 @@ float mesh_calc_poly_area(MPoly *mpoly, MLoop *loopstart, /* Find the index of the loop in 'poly' which references vertex, * returns -1 if not found */ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, - unsigned vert) + unsigned vert) { int j; for (j = 0; j < poly->totloop; j++, loopstart++) { @@ -2954,11 +2957,11 @@ int poly_find_loop_from_vert(const MPoly *poly, const MLoop *loopstart, * vertex. Returns the index of the loop matching vertex, or -1 if the * vertex is not in 'poly' */ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, - const MLoop *mloop, unsigned vert) + const MLoop *mloop, unsigned vert) { int corner = poly_find_loop_from_vert(poly, - &mloop[poly->loopstart], - vert); + &mloop[poly->loopstart], + vert); if (corner != -1) { const MLoop *ml = &mloop[poly->loopstart + corner]; @@ -2974,10 +2977,10 @@ int poly_get_adj_loops_from_vert(unsigned adj_r[3], const MPoly *poly, /* update the hide flag for edges and faces from the corresponding * flag in verts */ -void mesh_flush_hidden_from_verts(const MVert *mvert, - const MLoop *mloop, - MEdge *medge, int totedge, - MPoly *mpoly, int totpoly) +void BKE_mesh_flush_hidden_from_verts(const MVert *mvert, + const MLoop *mloop, + MEdge *medge, int totedge, + MPoly *mpoly, int totpoly) { int i, j; @@ -3003,38 +3006,38 @@ void mesh_flush_hidden_from_verts(const MVert *mvert, } /* basic vertex data functions */ -int minmax_mesh(Mesh *me, float min[3], float max[3]) +int BKE_mesh_minmax(Mesh *me, float r_min[3], float r_max[3]) { - int i= me->totvert; + int i = me->totvert; MVert *mvert; - for (mvert= me->mvert; i--; mvert++) { - DO_MINMAX(mvert->co, min, max); + for (mvert = me->mvert; i--; mvert++) { + DO_MINMAX(mvert->co, r_min, r_max); } return (me->totvert != 0); } -int mesh_center_median(Mesh *me, float cent[3]) +int BKE_mesh_center_median(Mesh *me, float cent[3]) { - int i= me->totvert; + int i = me->totvert; MVert *mvert; zero_v3(cent); - for (mvert= me->mvert; i--; mvert++) { + for (mvert = me->mvert; i--; mvert++) { add_v3_v3(cent, mvert->co); } /* otherwise we get NAN for 0 verts */ if (me->totvert) { - mul_v3_fl(cent, 1.0f/(float)me->totvert); + mul_v3_fl(cent, 1.0f / (float)me->totvert); } return (me->totvert != 0); } -int mesh_center_bounds(Mesh *me, float cent[3]) +int BKE_mesh_center_bounds(Mesh *me, float cent[3]) { float min[3], max[3]; INIT_MINMAX(min, max); - if (minmax_mesh(me, min, max)) { + if (BKE_mesh_minmax(me, min, max)) { mid_v3_v3v3(cent, min, max); return 1; } @@ -3042,19 +3045,19 @@ int mesh_center_bounds(Mesh *me, float cent[3]) return 0; } -void mesh_translate(Mesh *me, float offset[3], int do_keys) +void BKE_mesh_translate(Mesh *me, float offset[3], int do_keys) { - int i= me->totvert; + int i = me->totvert; MVert *mvert; - for (mvert= me->mvert; i--; mvert++) { + for (mvert = me->mvert; i--; mvert++) { add_v3_v3(mvert->co, offset); } if (do_keys && me->key) { KeyBlock *kb; - for (kb=me->key->block.first; kb; kb=kb->next) { - float *fp= kb->data; - for (i= kb->totelem; i--; fp+=3) { + for (kb = me->key->block.first; kb; kb = kb->next) { + float *fp = kb->data; + for (i = kb->totelem; i--; fp += 3) { add_v3_v3(fp, offset); } } @@ -3069,9 +3072,9 @@ void BKE_mesh_ensure_navmesh(Mesh *me) int numFaces = me->totpoly; int *recastData; CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_CALLOC, NULL, numFaces, "recastData"); - recastData = (int*)CustomData_get_layer(&me->pdata, CD_RECAST); - for (i=0; ipdata, CD_RECAST); + for (i = 0; i < numFaces; i++) { + recastData[i] = i + 1; } CustomData_add_layer_named(&me->pdata, CD_RECAST, CD_REFERENCE, recastData, numFaces, "recastData"); } @@ -3079,11 +3082,11 @@ void BKE_mesh_ensure_navmesh(Mesh *me) void BKE_mesh_tessface_calc(Mesh *mesh) { - mesh->totface = mesh_recalcTessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata, - mesh->mvert, - mesh->totface, mesh->totloop, mesh->totpoly, - /* calc normals right after, don't copy from polys here */ - FALSE); + mesh->totface = BKE_mesh_recalc_tessellation(&mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->mvert, + mesh->totface, mesh->totloop, mesh->totpoly, + /* calc normals right after, don't copy from polys here */ + FALSE); mesh_update_customdata_pointers(mesh, TRUE); } @@ -3099,3 +3102,51 @@ void BKE_mesh_tessface_clear(Mesh *mesh) { mesh_tessface_clear_intern(mesh, TRUE); } + +#if 0 /* slow version of the function below */ +void BKE_mesh_poly_calc_angles(MVert *mvert, MLoop *mloop, + MPoly *mp, float angles[]) +{ + MLoop *ml; + + int j; + for (j = 0, ml = mloop + mp->loopstart; j < mp->totloop; j++, ml++) { + MLoop *ml_prev = ME_POLY_LOOP_PREV(mloop, mp, j); + MLoop *ml_next = ME_POLY_LOOP_NEXT(mloop, mp, j); + + float e1[3], e2[3]; + + sub_v3_v3v3(e1, mvert[ml_next->v].co, mvert[ml->v].co); + sub_v3_v3v3(e2, mvert[ml_prev->v].co, mvert[ml->v].co); + + angles[j] = (float)M_PI - angle_v3v3(e1, e2); + } +} + +#else /* equivalent the function above but avoid multiple subtractions + normalize */ + +void BKE_mesh_poly_calc_angles(MVert *mvert, MLoop *mloop, + MPoly *mp, float angles[]) +{ + MLoop *ml = mloop + mp->loopstart; + float nor_prev[3]; + float nor_next[3]; + + int i_this = mp->totloop - 1; + int i_next = 0; + + sub_v3_v3v3(nor_prev, mvert[ml[i_this - 1].v].co, mvert[ml[i_this].v].co); + normalize_v3(nor_prev); + + while (i_next < mp->totloop) { + sub_v3_v3v3(nor_next, mvert[ml[i_this].v].co, mvert[ml[i_next].v].co); + normalize_v3(nor_next); + angles[i_this] = angle_normalized_v3v3(nor_prev, nor_next); + + /* step */ + copy_v3_v3(nor_prev, nor_next); + i_this = i_next; + i_next++; + } +} +#endif diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 446ad399e11..1645a8c9c9b 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -536,11 +536,11 @@ int BKE_mesh_validate_arrays(Mesh *mesh, if (mesh) { if (do_polyloop_free) { - mesh_strip_loose_polysloops(mesh); + BKE_mesh_strip_loose_polysloops(mesh); } if (do_edge_free) { - mesh_strip_loose_edges(mesh); + BKE_mesh_strip_loose_edges(mesh); } if (do_edge_recalc) { diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 98cbc957201..2159837c9a0 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -68,12 +68,12 @@ ModifierTypeInfo *modifierType_getInfo(ModifierType type) { - static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {NULL}; + static ModifierTypeInfo *types[NUM_MODIFIER_TYPES] = {NULL}; static int types_init = 1; if (types_init) { modifier_type_init(types); /* MOD_utils.c */ - types_init= 0; + types_init = 0; } /* type unsigned, no need to check < 0 */ @@ -96,8 +96,7 @@ ModifierData *modifier_new(int type) BLI_strncpy(md->name, mti->name, sizeof(md->name)); md->type = type; - md->mode = eModifierMode_Realtime - | eModifierMode_Render | eModifierMode_Expanded; + md->mode = eModifierMode_Realtime | eModifierMode_Render | eModifierMode_Expanded; if (mti->flags & eModifierTypeFlag_EnableInEditmode) md->mode |= eModifierMode_Editmode; @@ -137,8 +136,8 @@ int modifier_supportsMapping(ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - return (mti->type==eModifierTypeType_OnlyDeform || - (mti->flags & eModifierTypeFlag_SupportsMapping)); + return (mti->type == eModifierTypeType_OnlyDeform || + (mti->flags & eModifierTypeFlag_SupportsMapping)); } int modifier_isPreview(ModifierData *md) @@ -158,8 +157,8 @@ ModifierData *modifiers_findByType(Object *ob, ModifierType type) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) - if (md->type==type) + for (; md; md = md->next) + if (md->type == type) break; return md; @@ -175,7 +174,7 @@ void modifiers_clearErrors(Object *ob) ModifierData *md = ob->modifiers.first; /* int qRedraw = 0; */ - for (; md; md=md->next) { + for (; md; md = md->next) { if (md->error) { MEM_freeN(md->error); md->error = NULL; @@ -186,11 +185,11 @@ void modifiers_clearErrors(Object *ob) } void modifiers_foreachObjectLink(Object *ob, ObjectWalkFunc walk, - void *userData) + void *userData) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->foreachObjectLink) @@ -202,7 +201,7 @@ void modifiers_foreachIDLink(Object *ob, IDWalkFunc walk, void *userData) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->foreachIDLink) mti->foreachIDLink(md, ob, walk, userData); @@ -218,7 +217,7 @@ void modifiers_foreachTexLink(Object *ob, TexWalkFunc walk, void *userData) { ModifierData *md = ob->modifiers.first; - for (; md; md=md->next) { + for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); if (mti->foreachTexLink) @@ -240,12 +239,12 @@ int modifier_couldBeCage(struct Scene *scene, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; - return ( (md->mode & eModifierMode_Realtime) && - (md->mode & eModifierMode_Editmode) && - (!mti->isDisabled || !mti->isDisabled(md, 0)) && - modifier_supportsMapping(md)); + return ((md->mode & eModifierMode_Realtime) && + (md->mode & eModifierMode_Editmode) && + (!mti->isDisabled || !mti->isDisabled(md, 0)) && + modifier_supportsMapping(md)); } int modifier_sameTopology(ModifierData *md) @@ -269,7 +268,7 @@ void modifier_setError(ModifierData *md, const char *format, ...) va_start(ap, format); vsnprintf(buffer, sizeof(buffer), format, ap); va_end(ap); - buffer[sizeof(buffer) - 1]= '\0'; + buffer[sizeof(buffer) - 1] = '\0'; if (md->error) MEM_freeN(md->error); @@ -287,19 +286,19 @@ void modifier_setError(ModifierData *md, const char *format, ...) */ int modifiers_getCageIndex(struct Scene *scene, Object *ob, int *lastPossibleCageIndex_r, int virtual_) { - ModifierData *md = (virtual_)? modifiers_getVirtualModifierList(ob): ob->modifiers.first; + ModifierData *md = (virtual_) ? modifiers_getVirtualModifierList(ob) : ob->modifiers.first; int i, cageIndex = -1; if (lastPossibleCageIndex_r) { /* ensure the value is initialized */ - *lastPossibleCageIndex_r= -1; + *lastPossibleCageIndex_r = -1; } /* Find the last modifier acting on the cage. */ - for (i=0; md; i++, md=md->next) { + for (i = 0; md; i++, md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if (!(md->mode & eModifierMode_Realtime)) continue; if (!(md->mode & eModifierMode_Editmode)) continue; @@ -344,7 +343,7 @@ int modifier_isEnabled(struct Scene *scene, ModifierData *md, int required_mode) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - md->scene= scene; + md->scene = scene; if ((md->mode & required_mode) != required_mode) return 0; if (mti->isDisabled && mti->isDisabled(md, required_mode == eModifierMode_Render)) return 0; @@ -396,7 +395,7 @@ CDMaskLink *modifiers_calcDataMasks(struct Scene *scene, Object *ob, ModifierDat } /* reverse the list so it's in the correct order */ - BLI_linklist_reverse((LinkNode**)&dataMasks); + BLI_linklist_reverse((LinkNode **)&dataMasks); return dataMasks; } @@ -416,6 +415,7 @@ ModifierData *modifiers_getLastPreview(struct Scene *scene, ModifierData *md, in return tmp_md; } +/* NOTE: these aren't used anymore */ ModifierData *modifiers_getVirtualModifierList(Object *ob) { /* Kinda hacky, but should be fine since we are never @@ -430,19 +430,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) if (init) { md = modifier_new(eModifierType_Armature); - amd = *((ArmatureModifierData*) md); + amd = *((ArmatureModifierData *) md); modifier_free(md); md = modifier_new(eModifierType_Curve); - cmd = *((CurveModifierData*) md); + cmd = *((CurveModifierData *) md); modifier_free(md); md = modifier_new(eModifierType_Lattice); - lmd = *((LatticeModifierData*) md); + lmd = *((LatticeModifierData *) md); modifier_free(md); md = modifier_new(eModifierType_ShapeKey); - smd = *((ShapeKeyModifierData*) md); + smd = *((ShapeKeyModifierData *) md); modifier_free(md); amd.modifier.mode |= eModifierMode_Virtual; @@ -456,19 +456,19 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) md = ob->modifiers.first; if (ob->parent) { - if (ob->parent->type==OB_ARMATURE && ob->partype==PARSKEL) { + if (ob->parent->type == OB_ARMATURE && ob->partype == PARSKEL) { amd.object = ob->parent; amd.modifier.next = md; - amd.deformflag= ((bArmature *)(ob->parent->data))->deformflag; + amd.deformflag = ((bArmature *)(ob->parent->data))->deformflag; md = &amd.modifier; } - else if (ob->parent->type==OB_CURVE && ob->partype==PARSKEL) { + else if (ob->parent->type == OB_CURVE && ob->partype == PARSKEL) { cmd.object = ob->parent; cmd.defaxis = ob->trackflag + 1; cmd.modifier.next = md; md = &cmd.modifier; } - else if (ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) { + else if (ob->parent->type == OB_LATTICE && ob->partype == PARSKEL) { lmd.object = ob->parent; lmd.modifier.next = md; md = &lmd.modifier; @@ -478,9 +478,9 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) /* shape key modifier, not yet for curves */ if (ELEM(ob->type, OB_MESH, OB_LATTICE) && ob_get_key(ob)) { if (ob->type == OB_MESH && (ob->shapeflag & OB_SHAPE_EDIT_MODE)) - smd.modifier.mode |= eModifierMode_Editmode|eModifierMode_OnCage; + smd.modifier.mode |= eModifierMode_Editmode | eModifierMode_OnCage; else - smd.modifier.mode &= ~eModifierMode_Editmode|eModifierMode_OnCage; + smd.modifier.mode &= ~eModifierMode_Editmode | eModifierMode_OnCage; smd.modifier.next = md; md = &smd.modifier; @@ -495,12 +495,12 @@ ModifierData *modifiers_getVirtualModifierList(Object *ob) Object *modifiers_isDeformedByArmature(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); - ArmatureModifierData *amd= NULL; + ArmatureModifierData *amd = NULL; /* return the first selected armature, this lets us use multiple armatures */ - for (; md; md=md->next) { - if (md->type==eModifierType_Armature) { - amd = (ArmatureModifierData*) md; + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + amd = (ArmatureModifierData *) md; if (amd->object && (amd->object->flag & SELECT)) return amd->object; } @@ -519,12 +519,12 @@ Object *modifiers_isDeformedByArmature(Object *ob) Object *modifiers_isDeformedByLattice(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); - LatticeModifierData *lmd= NULL; + LatticeModifierData *lmd = NULL; /* return the first selected lattice, this lets us use multiple lattices */ - for (; md; md=md->next) { - if (md->type==eModifierType_Lattice) { - lmd = (LatticeModifierData*) md; + for (; md; md = md->next) { + if (md->type == eModifierType_Lattice) { + lmd = (LatticeModifierData *) md; if (lmd->object && (lmd->object->flag & SELECT)) return lmd->object; } @@ -542,10 +542,10 @@ int modifiers_usesArmature(Object *ob, bArmature *arm) { ModifierData *md = modifiers_getVirtualModifierList(ob); - for (; md; md=md->next) { - if (md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if (amd->object && amd->object->data==arm) + for (; md; md = md->next) { + if (md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *) md; + if (amd->object && amd->object->data == arm) return 1; } } @@ -555,9 +555,9 @@ int modifiers_usesArmature(Object *ob, bArmature *arm) int modifier_isCorrectableDeformed(ModifierData *md) { - if (md->type==eModifierType_Armature) + if (md->type == eModifierType_Armature) return 1; - if (md->type==eModifierType_ShapeKey) + if (md->type == eModifierType_ShapeKey) return 1; return 0; @@ -567,11 +567,11 @@ int modifiers_isCorrectableDeformed(Object *ob) { ModifierData *md = modifiers_getVirtualModifierList(ob); - for (; md; md=md->next) { - if (ob->mode==OB_MODE_EDIT && (md->mode & eModifierMode_Editmode)==0); + for (; md; md = md->next) { + if (ob->mode == OB_MODE_EDIT && (md->mode & eModifierMode_Editmode) == 0) ; else - if (modifier_isCorrectableDeformed(md)) - return 1; + if (modifier_isCorrectableDeformed(md)) + return 1; } return 0; } @@ -592,22 +592,22 @@ int modifiers_isPreview(Object *ob) int modifiers_indexInObject(Object *ob, ModifierData *md_seek) { - int i= 0; + int i = 0; ModifierData *md; - for (md=ob->modifiers.first; (md && md_seek!=md); md=md->next, i++); - if (!md) return -1; /* modifier isn't in the object */ + for (md = ob->modifiers.first; (md && md_seek != md); md = md->next, i++) ; + if (!md) return -1; /* modifier isn't in the object */ return i; } void modifier_freeTemporaryData(ModifierData *md) { if (md->type == eModifierType_Armature) { - ArmatureModifierData *amd= (ArmatureModifierData*)md; + ArmatureModifierData *amd = (ArmatureModifierData *)md; if (amd->prevCos) { MEM_freeN(amd->prevCos); - amd->prevCos= NULL; + amd->prevCos = NULL; } } } @@ -624,7 +624,7 @@ void test_object_modifiers(Object *ob) for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Multires) { - MultiresModifierData *mmd = (MultiresModifierData*)md; + MultiresModifierData *mmd = (MultiresModifierData *)md; multiresModifier_set_levels_from_disps(mmd, ob); } diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 7a279572738..f07de7f0127 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -71,7 +71,7 @@ #include "BKE_main.h" #include "BKE_utildefines.h" #include "BKE_movieclip.h" -#include "BKE_image.h" /* openanim */ +#include "BKE_image.h" /* openanim */ #include "BKE_tracking.h" #include "IMB_imbuf_types.h" @@ -205,7 +205,7 @@ static ImBuf *movieclip_load_sequence_file(MovieClip *clip, MovieClipUser *user, else get_sequence_fname(clip, framenr, name); - loadflag = IB_rect|IB_multilayer; + loadflag = IB_rect | IB_multilayer; /* read ibuf */ ibuf = IMB_loadiffname(name, loadflag); @@ -250,7 +250,7 @@ static ImBuf *movieclip_load_movie_file(MovieClip *clip, MovieClipUser *user, in dur = IMB_anim_get_duration(clip->anim, tc); fra = framenr - 1; - if (fra<0) + if (fra < 0) fra = 0; if (fra > (dur - 1)) @@ -283,7 +283,7 @@ static void movieclip_calc_length(MovieClip *clip) clip->len = framenr + 1; } else { - for (;;) { + for (;; ) { get_sequence_fname(clip, framenr, name); if (!BLI_exists(name)) { @@ -338,7 +338,7 @@ typedef struct MovieClipImBufCacheKey { static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *render_flags) { - MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)userkey; + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)userkey; *framenr = key->framenr; *proxy = key->proxy; @@ -347,7 +347,7 @@ static void moviecache_keydata(void *userkey, int *framenr, int *proxy, int *ren static unsigned int moviecache_hashhash(const void *keyv) { - MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey*)keyv; + MovieClipImBufCacheKey *key = (MovieClipImBufCacheKey *)keyv; int rval = key->framenr; return rval; @@ -355,8 +355,8 @@ static unsigned int moviecache_hashhash(const void *keyv) static int moviecache_hashcmp(const void *av, const void *bv) { - const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey*)av; - const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey*)bv; + const MovieClipImBufCacheKey *a = (MovieClipImBufCacheKey *)av; + const MovieClipImBufCacheKey *b = (MovieClipImBufCacheKey *)bv; if (a->framenr < b->framenr) return -1; @@ -406,7 +406,7 @@ static void put_imbuf_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, i clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache"); clip->cache->moviecache = IMB_moviecache_create(sizeof(MovieClipImBufCacheKey), moviecache_hashhash, - moviecache_hashcmp, moviecache_keydata); + moviecache_hashcmp, moviecache_keydata); } key.framenr = user->framenr; @@ -430,7 +430,7 @@ static MovieClip *movieclip_alloc(const char *name) { MovieClip *clip; - clip = alloc_libblock(&G.main->movieclip, ID_MC, name); + clip = BKE_libblock_alloc(&G.main->movieclip, ID_MC, name); clip->aspx = clip->aspy = 1.0f; @@ -529,8 +529,8 @@ static void real_ibuf_size(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, in break; case MCLIP_PROXY_RENDER_SIZE_75: - *width = ((float)*width)*4.0f/3.0f; - *height = ((float)*height)*4.0f/3.0f; + *width = ((float)*width) * 4.0f / 3.0f; + *height = ((float)*height) * 4.0f / 3.0f; break; } } @@ -635,7 +635,8 @@ static ImBuf *get_postprocessed_cached_frame(MovieClip *clip, MovieClipUser *use return cache->postprocessed.ibuf; } -static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, int flag, int postprocess_flag) +static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *user, ImBuf *ibuf, + int flag, int postprocess_flag) { MovieClipCache *cache = clip->cache; MovieTrackingCamera *camera = &clip->tracking.camera; @@ -669,8 +670,8 @@ static ImBuf *put_postprocessed_frame_to_cache(MovieClip *clip, MovieClipUser *u if (postprocess_flag) { int disable_red = postprocess_flag & MOVIECLIP_DISABLE_RED, disable_green = postprocess_flag & MOVIECLIP_DISABLE_GREEN, - disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE, - grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE; + disable_blue = postprocess_flag & MOVIECLIP_DISABLE_BLUE, + grayscale = postprocess_flag & MOVIECLIP_PREVIEW_GRAYSCALE; if (!postproc_ibuf) postproc_ibuf = IMB_dupImBuf(ibuf); @@ -801,8 +802,8 @@ static ImBuf *get_stable_cached_frame(MovieClip *clip, MovieClipUser *user, int /* check for stabilization parameters */ if (tscale != cache->stabilized.scale || - tangle != cache->stabilized.angle || - !equals_v2v2(tloc, cache->stabilized.loc)) + tangle != cache->stabilized.angle || + !equals_v2v2(tloc, cache->stabilized.loc)) { return NULL; } @@ -851,7 +852,8 @@ static ImBuf *put_stabilized_frame_to_cache(MovieClip *clip, MovieClipUser *user return stableibuf; } -ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, int postprocess_flag) +ImBuf *BKE_movieclip_get_stable_ibuf(MovieClip *clip, MovieClipUser *user, float loc[2], float *scale, float *angle, + int postprocess_flag) { ImBuf *ibuf, *stableibuf = NULL; int framenr = user->framenr; @@ -1038,7 +1040,7 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip scopes->track_disabled = FALSE; - if (ibuf && ibuf->rect) { + if (ibuf && (ibuf->rect || ibuf->rect_float)) { ImBuf *tmpibuf; MovieTrackingMarker undist_marker = *marker; @@ -1049,17 +1051,17 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip BKE_movieclip_get_size(clip, user, &width, &height); undist_marker.pos[0] *= width; - undist_marker.pos[1] *= height*aspy; + undist_marker.pos[1] *= height * aspy; BKE_tracking_invert_intrinsics(&clip->tracking, undist_marker.pos, undist_marker.pos); undist_marker.pos[0] /= width; - undist_marker.pos[1] /= height*aspy; + undist_marker.pos[1] /= height * aspy; } /* NOTE: margin should be kept in sync with value from ui_draw_but_TRACKPREVIEW */ tmpibuf = BKE_tracking_get_pattern_imbuf(ibuf, track, &undist_marker, 3 /* margin */, - 1 /* anchor */, scopes->track_pos, NULL); + 1 /* anchor */, scopes->track_pos, NULL); if (tmpibuf->rect_float) IMB_rect_from_float(tmpibuf); @@ -1073,11 +1075,11 @@ void BKE_movieclip_update_scopes(MovieClip *clip, MovieClipUser *user, MovieClip IMB_freeImBuf(ibuf); } - if ((track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_LOCKED) == 0) { scopes->marker = marker; scopes->track = track; - scopes->slide_scale[0] = track->pat_max[0]-track->pat_min[0]; - scopes->slide_scale[1] = track->pat_max[1]-track->pat_min[1]; + scopes->slide_scale[0] = track->pat_max[0] - track->pat_min[0]; + scopes->slide_scale[1] = track->pat_max[1] - track->pat_min[1]; } } } diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index f3901cec506..724d80afdd9 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -46,6 +46,7 @@ #include "BLI_pbvh.h" #include "BLI_utildefines.h" +#include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" @@ -75,37 +76,42 @@ typedef enum { } DispOp; static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert); -static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl); +static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem **oldGridData, int totlvl); /** Customdata **/ void multires_customdata_delete(Mesh *me) { if (me->edit_btmesh) { - BMEditMesh *em= me->edit_btmesh; + BMEditMesh *em = me->edit_btmesh; /* CustomData_external_remove is used here only to mark layer * as non-external for further free-ing, so zero element count * looks safer than em->totface */ CustomData_external_remove(&em->bm->ldata, &me->id, - CD_MDISPS, 0); + CD_MDISPS, 0); BM_data_layer_free(em->bm, &em->bm->ldata, CD_MDISPS); + + BM_data_layer_free(em->bm, &em->bm->ldata, CD_GRID_PAINT_MASK); } else { CustomData_external_remove(&me->ldata, &me->id, - CD_MDISPS, me->totloop); + CD_MDISPS, me->totloop); CustomData_free_layer_active(&me->ldata, CD_MDISPS, - me->totloop); + me->totloop); + + CustomData_free_layer_active(&me->ldata, CD_GRID_PAINT_MASK, + me->totloop); } } /** Grid hiding **/ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, - int lo_level, - int hi_level, - - /* assumed to be at hi_level (or - * null) */ - BLI_bitmap prev_hidden) + int lo_level, + int hi_level, + + /* assumed to be at hi_level (or + * null) */ + BLI_bitmap prev_hidden) { BLI_bitmap subd; int hi_gridsize = ccg_gridsize(hi_level); @@ -163,8 +169,8 @@ static BLI_bitmap multires_mdisps_upsample_hidden(BLI_bitmap lo_hidden, } static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden, - int old_level, - int new_level) + int old_level, + int new_level) { BLI_bitmap new_hidden; int new_gridsize = ccg_gridsize(new_level); @@ -174,16 +180,16 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden, BLI_assert(new_level <= old_level); factor = ccg_factor(new_level, old_level); new_hidden = BLI_BITMAP_NEW(new_gridsize * new_gridsize, - "downsample hidden"); + "downsample hidden"); for (y = 0; y < new_gridsize; y++) { for (x = 0; x < new_gridsize; x++) { old_value = BLI_BITMAP_GET(old_hidden, - factor*y*old_gridsize + x*factor); + factor * y * old_gridsize + x * factor); - BLI_BITMAP_MODIFY(new_hidden, y*new_gridsize + x, old_value); + BLI_BITMAP_MODIFY(new_hidden, y * new_gridsize + x, old_value); } } @@ -191,7 +197,7 @@ static BLI_bitmap multires_mdisps_downsample_hidden(BLI_bitmap old_hidden, } static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, - Mesh *me, int level) + Mesh *me, int level) { const MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); BLI_bitmap *grid_hidden = ccgdm->gridHidden; @@ -208,7 +214,7 @@ static void multires_output_hidden_to_ccgdm(CCGDerivedMesh *ccgdm, if (gh) { grid_hidden[g] = - multires_mdisps_downsample_hidden(gh, md->level, level); + multires_mdisps_downsample_hidden(gh, md->level, level); } } } @@ -227,9 +233,9 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level) return; subd = multires_mdisps_upsample_hidden(md->hidden, - md->level, - new_level, - NULL); + md->level, + new_level, + NULL); /* swap in the subdivided data */ MEM_freeN(md->hidden); @@ -239,7 +245,7 @@ static void multires_mdisps_subdivide_hidden(MDisps *md, int new_level) static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level) { MDisps *mdisps = CustomData_add_layer(&me->ldata, CD_MDISPS, - CD_CALLOC, 0, me->totloop); + CD_CALLOC, 0, me->totloop); int gridsize = ccg_gridsize(level); int gridarea = gridsize * gridsize; int i, j, k; @@ -274,12 +280,12 @@ static MDisps *multires_mdisps_initialize_hidden(Mesh *me, int level) DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob) { - ModifierData *md= (ModifierData *)mmd; + ModifierData *md = (ModifierData *)mmd; ModifierTypeInfo *mti = modifierType_getInfo(md->type); DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); DerivedMesh *dm; - dm = mti->applyModifier(md, ob, tdm, 0, 1); + dm = mti->applyModifier(md, ob, tdm, MOD_APPLY_USECACHE); if (dm == tdm) { dm = CDDM_copy(tdm); } @@ -294,7 +300,7 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * for (md = lastmd; md; md = md->prev) { if (md->type == eModifierType_Multires) { if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) - return (MultiresModifierData*)md; + return (MultiresModifierData *)md; } } @@ -307,16 +313,16 @@ MultiresModifierData *find_multires_modifier_before(Scene *scene, ModifierData * MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_first) { ModifierData *md; - MultiresModifierData *mmd= NULL, *firstmmd= NULL; + MultiresModifierData *mmd = NULL, *firstmmd = NULL; /* find first active multires modifier */ for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Multires) { if (!firstmmd) - firstmmd= (MultiresModifierData*)md; + firstmmd = (MultiresModifierData *)md; if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) { - mmd= (MultiresModifierData*)md; + mmd = (MultiresModifierData *)md; break; } } @@ -334,11 +340,11 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, int use_fi static int multires_get_level(Object *ob, MultiresModifierData *mmd, int render) { if (render) - return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl): mmd->renderlvl; + return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl) : mmd->renderlvl; else if (ob->mode == OB_MODE_SCULPT) return mmd->sculptlvl; else - return (mmd->modifier.scene)? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl): mmd->lvl; + return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl) : mmd->lvl; } static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) @@ -354,7 +360,7 @@ static void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lv static void multires_dm_mark_as_modified(DerivedMesh *dm, MultiresModifiedFlags flags) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; ccgdm->multires.modified_flags |= flags; } @@ -368,20 +374,20 @@ void multires_force_update(Object *ob) { if (ob) { if (ob->derivedFinal) { - ob->derivedFinal->needsFree =1; + ob->derivedFinal->needsFree = 1; ob->derivedFinal->release(ob->derivedFinal); ob->derivedFinal = NULL; } if (ob->sculpt && ob->sculpt->pbvh) { BLI_pbvh_free(ob->sculpt->pbvh); - ob->sculpt->pbvh= NULL; + ob->sculpt->pbvh = NULL; } } } void multires_force_external_reload(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); CustomData_external_reload(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); multires_force_update(ob); @@ -394,9 +400,9 @@ void multires_force_render_update(Object *ob) } int multiresModifier_reshapeFromDM(Scene *scene, MultiresModifierData *mmd, - Object *ob, DerivedMesh *srcdm) + Object *ob, DerivedMesh *srcdm) { - DerivedMesh *mrdm = get_multires_dm (scene, mmd, ob); + DerivedMesh *mrdm = get_multires_dm(scene, mmd, ob); if (mrdm && srcdm && mrdm->getNumVerts(mrdm) == srcdm->getNumVerts(srcdm)) { multires_mvert_to_ss(mrdm, srcdm->getVertArray(srcdm)); @@ -422,7 +428,7 @@ int multiresModifier_reshape(Scene *scene, MultiresModifierData *mmd, Object *ds } int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mmd, - Object *ob, ModifierData *md) + Object *ob, ModifierData *md) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); DerivedMesh *dm, *ndm; @@ -434,20 +440,20 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm /* Create DerivedMesh for deformation modifier */ dm = get_multires_dm(scene, mmd, ob); - numVerts= dm->getNumVerts(dm); - deformedVerts= MEM_callocN(sizeof(float)*numVerts*3, "multiresReshape_deformVerts"); + numVerts = dm->getNumVerts(dm); + deformedVerts = MEM_callocN(sizeof(float) * numVerts * 3, "multiresReshape_deformVerts"); dm->getVertCos(dm, deformedVerts); - mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0); - ndm= CDDM_copy(dm); + ndm = CDDM_copy(dm); CDDM_apply_vert_coords(ndm, deformedVerts); MEM_freeN(deformedVerts); dm->release(dm); /* Reshaping */ - result= multiresModifier_reshapeFromDM(scene, mmd, ob, ndm); + result = multiresModifier_reshapeFromDM(scene, mmd, ob, ndm); /* Cleanup */ ndm->release(ndm); @@ -460,25 +466,25 @@ static int get_levels_from_disps(Object *ob) { Mesh *me = ob->data; MDisps *mdisp, *md; - int i, j, totlvl= 0; + int i, j, totlvl = 0; mdisp = CustomData_get_layer(&me->ldata, CD_MDISPS); for (i = 0; i < me->totpoly; ++i) { md = mdisp + me->mpoly[i].loopstart; - for (j=0; jmpoly[i].totloop; j++, md++) { + for (j = 0; j < me->mpoly[i].totloop; j++, md++) { if (md->totdisp == 0) continue; while (1) { - int side = (1 << (totlvl-1)) + 1; - int lvl_totdisp = side*side; + int side = (1 << (totlvl - 1)) + 1; + int lvl_totdisp = side * side; if (md->totdisp == lvl_totdisp) break; else if (md->totdisp < lvl_totdisp) - --totlvl; + totlvl--; else - ++totlvl; + totlvl++; } @@ -510,7 +516,7 @@ void multiresModifier_set_levels_from_disps(MultiresModifierData *mmd, Object *o static void multires_set_tot_mdisps(Mesh *me, int lvl) { - MDisps *mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); int i; if (mdisps) { @@ -554,50 +560,79 @@ static void multires_copy_grid(float (*gridA)[3], float (*gridB)[3], int sizeA, int x, y, j, skip; if (sizeA > sizeB) { - skip = (sizeA-1)/(sizeB-1); + skip = (sizeA - 1) / (sizeB - 1); for (j = 0, y = 0; y < sizeB; y++) for (x = 0; x < sizeB; x++, j++) - copy_v3_v3(gridA[y*skip*sizeA + x*skip], gridB[j]); + copy_v3_v3(gridA[y * skip * sizeA + x * skip], gridB[j]); } else { - skip = (sizeB-1)/(sizeA-1); + skip = (sizeB - 1) / (sizeA - 1); for (j = 0, y = 0; y < sizeA; y++) for (x = 0; x < sizeA; x++, j++) - copy_v3_v3(gridA[j], gridB[y*skip*sizeB + x*skip]); + copy_v3_v3(gridA[j], gridB[y * skip * sizeB + x * skip]); } } -static void multires_copy_dm_grid(DMGridData *gridA, DMGridData *gridB, int sizeA, int sizeB) +static void multires_copy_dm_grid(CCGElem *gridA, CCGElem *gridB, CCGKey *keyA, CCGKey *keyB) { int x, y, j, skip; - if (sizeA > sizeB) { - skip = (sizeA-1)/(sizeB-1); + if (keyA->grid_size > keyB->grid_size) { + skip = (keyA->grid_size - 1) / (keyB->grid_size - 1); - for (j = 0, y = 0; y < sizeB; y++) - for (x = 0; x < sizeB; x++, j++) - copy_v3_v3(gridA[y*skip*sizeA + x*skip].co, gridB[j].co); + for (j = 0, y = 0; y < keyB->grid_size; y++) + for (x = 0; x < keyB->grid_size; x++, j++) + memcpy(CCG_elem_offset_co(keyA, gridA, y * skip * keyA->grid_size + x * skip), + CCG_elem_offset_co(keyB, gridB, j), + sizeof(float) * keyA->num_layers); } else { - skip = (sizeB-1)/(sizeA-1); + skip = (keyB->grid_size - 1) / (keyA->grid_size - 1); - for (j = 0, y = 0; y < sizeA; y++) - for (x = 0; x < sizeA; x++, j++) - copy_v3_v3(gridA[j].co, gridB[y*skip*sizeB + x*skip].co); + for (j = 0, y = 0; y < keyA->grid_size; y++) + for (x = 0; x < keyA->grid_size; x++, j++) + memcpy(CCG_elem_offset_co(keyA, gridA, j), + CCG_elem_offset_co(keyB, gridB, y * skip * keyB->grid_size + x * skip), + sizeof(float) * keyA->num_layers); + } +} + +/* Reallocate gpm->data at a lower resolution and copy values over + from the original high-resolution data */ +static void multires_grid_paint_mask_downsample(GridPaintMask *gpm, int level) +{ + if (level < gpm->level) { + int gridsize = ccg_gridsize(level); + float *data = MEM_callocN(sizeof(float) * gridsize * gridsize, + "multires_grid_paint_mask_downsample"); + int x, y; + + for (y = 0; y < gridsize; y++) { + for (x = 0; x < gridsize; x++) { + data[y * gridsize + x] = + paint_grid_paint_mask(gpm, level, x, y); + } + } + + MEM_freeN(gpm->data); + gpm->data = data; + gpm->level = level; } } static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) { - Mesh *me = (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; int levels = mmd->totlvl - lvl; MDisps *mdisps; + GridPaintMask *gpm; multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); - mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); + gpm = CustomData_get_layer(&me->ldata, CD_GRID_PAINT_MASK); multires_force_update(ob); @@ -609,8 +644,9 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) int i, j; for (i = 0; i < me->totpoly; ++i) { - for (j=0; jmpoly[i].totloop; j++) { - MDisps *mdisp= &mdisps[me->mpoly[i].loopstart+j]; + for (j = 0; j < me->mpoly[i].totloop; j++) { + int g = me->mpoly[i].loopstart + j; + MDisps *mdisp = &mdisps[g]; float (*disps)[3], (*ndisps)[3], (*hdisps)[3]; int totdisp = multires_grid_tot[lvl]; @@ -622,20 +658,22 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) multires_copy_grid(ndisps, hdisps, nsize, hsize); if (mdisp->hidden) { BLI_bitmap gh = - multires_mdisps_downsample_hidden(mdisp->hidden, - mdisp->level, - lvl); + multires_mdisps_downsample_hidden(mdisp->hidden, + mdisp->level, + lvl); MEM_freeN(mdisp->hidden); mdisp->hidden = gh; } - ndisps += nsize*nsize; - hdisps += hsize*hsize; + ndisps += nsize * nsize; + hdisps += hsize * hsize; MEM_freeN(mdisp->disps); mdisp->disps = disps; mdisp->totdisp = totdisp; mdisp->level = lvl; + + multires_grid_paint_mask_downsample(&gpm[g], lvl); } } } @@ -650,14 +688,14 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) /* direction=1 for delete higher, direction=0 for lower (not implemented yet) */ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); int lvl = multires_get_level(ob, mmd, 0); int levels = mmd->totlvl - lvl; MDisps *mdisps; multires_set_tot_mdisps(me, mmd->totlvl); CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); - mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); multires_force_update(ob); @@ -668,9 +706,10 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire multires_set_tot_level(ob, mmd, lvl); } -static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple) +static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, int alloc_paint_mask) { - MultiresModifierData mmd= {{NULL}}; + MultiresModifierData mmd = {{NULL}}; + MultiresFlags flags = MULTIRES_USE_LOCAL_MMD; mmd.lvl = lvl; mmd.sculptlvl = lvl; @@ -678,12 +717,16 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv mmd.totlvl = totlvl; mmd.simple = simple; - return multires_dm_create_from_derived(&mmd, 1, dm, ob, 0); + if (alloc_paint_mask) + flags |= MULTIRES_ALLOC_PAINT_MASK; + + return multires_make_derived_from_derived(dm, &mmd, ob, flags); } -static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv) +static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv, int alloc_paint_mask) { - SubsurfModifierData smd= {{NULL}}; + SubsurfModifierData smd = {{NULL}}; + SubsurfFlags flags = 0; smd.levels = smd.renderLevels = lvl; if (!plain_uv) @@ -693,7 +736,13 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl if (optimal) smd.flags |= eSubsurfModifierFlag_ControlEdges; - return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT)); + if (ob->mode & OB_MODE_EDIT) + flags |= SUBSURF_IN_EDIT_MODE; + + if (alloc_paint_mask) + flags |= SUBSURF_ALLOC_PAINT_MASK; + + return subsurf_make_derived_from_derived(dm, &smd, NULL, flags); } @@ -717,7 +766,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) multires_force_update(ob); - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); totlvl = mmd->totlvl; /* nothing to do */ @@ -729,7 +778,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* generate highest level with displacements */ cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0); + dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0, 0); cddm->release(cddm); /* copy the new locations of the base verts into the mesh */ @@ -742,8 +791,8 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) cddm = CDDM_from_mesh(me, NULL); pmap = cddm->getPolyMap(ob, cddm); - origco = MEM_callocN(sizeof(float)*3*me->totvert, "multires apply base origco"); - for (i = 0; i < me->totvert ;++i) + origco = MEM_callocN(sizeof(float) * 3 * me->totvert, "multires apply base origco"); + for (i = 0; i < me->totvert; ++i) copy_v3_v3(origco[i], me->mvert[i].co); for (i = 0; i < me->totvert; ++i) { @@ -764,7 +813,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) int vndx = me->mloop[p->loopstart + k].v; if (vndx != i) { add_v3_v3(center, origco[vndx]); - ++tot; + tot++; } } } @@ -779,7 +828,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) float no[3]; /* set up poly, loops, and coords in order to call - * mesh_calc_poly_normal_coords() */ + * BKE_mesh_calc_poly_normal_coords() */ fake_poly.totloop = p->totloop; fake_poly.loopstart = 0; fake_loops = MEM_mallocN(sizeof(MLoop) * p->totloop, "fake_loops"); @@ -796,8 +845,8 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) copy_v3_v3(fake_co[k], origco[vndx]); } - mesh_calc_poly_normal_coords(&fake_poly, fake_loops, - (const float(*)[3])fake_co, no); + BKE_mesh_calc_poly_normal_coords(&fake_poly, fake_loops, + (const float(*)[3])fake_co, no); MEM_freeN(fake_loops); MEM_freeN(fake_co); @@ -819,7 +868,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* subdivide the mesh to highest level without displacements */ cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv); + origdm = subsurf_dm_create_local(ob, cddm, totlvl, 0, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); cddm->release(cddm); /* calc disps */ @@ -833,7 +882,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl { Mesh *me = ob->data; MDisps *mdisps; - int lvl= mmd->totlvl; + int lvl = mmd->totlvl; if ((totlvl > multires_max_levels) || (me->totpoly == 0)) return; @@ -847,42 +896,44 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl if (mdisps->disps && !updateblock && totlvl > 1) { /* upsample */ DerivedMesh *lowdm, *cddm, *highdm; - DMGridData **highGridData, **lowGridData, **subGridData; + CCGElem **highGridData, **lowGridData, **subGridData; + CCGKey highGridKey, lowGridKey; CCGSubSurf *ss; - int i, numGrids, highGridSize, lowGridSize; + int i, numGrids, highGridSize; /* create subsurf DM from original mesh at high level */ cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); + highdm = subsurf_dm_create_local(ob, cddm, totlvl, simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE); + ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh at low level */ - lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple); + lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, TRUE); cddm->release(cddm); /* copy subsurf grids and replace them with low displaced grids */ numGrids = highdm->getNumGrids(highdm); highGridSize = highdm->getGridSize(highdm); highGridData = highdm->getGridData(highdm); - lowGridSize = lowdm->getGridSize(lowdm); + highdm->getGridKey(highdm, &highGridKey); lowGridData = lowdm->getGridData(lowdm); + lowdm->getGridKey(lowdm, &lowGridKey); - subGridData = MEM_callocN(sizeof(float*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(float *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; ++i) { /* backup subsurf grids */ - subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData"); - memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize); + subGridData[i] = MEM_callocN(highGridKey.elem_size * highGridSize * highGridSize, "subGridData"); + memcpy(subGridData[i], highGridData[i], highGridKey.elem_size * highGridSize * highGridSize); /* overwrite with current displaced grids */ - multires_copy_dm_grid(highGridData[i], lowGridData[i], highGridSize, lowGridSize); + multires_copy_dm_grid(highGridData[i], lowGridData[i], &highGridKey, &lowGridKey); } /* low lower level dm no longer needed at this point */ lowdm->release(lowdm); /* subsurf higher levels again with displaced data */ - ss= ((CCGDerivedMesh*)highdm)->ss; ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0); ccgSubSurf_updateLevels(ss, lvl, NULL, 0); @@ -908,39 +959,41 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) { - multires_subdivide(mmd, ob, mmd->totlvl+1, updateblock, simple); + multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple); } -void grid_tangent(int gridSize, int index, int x, int y, int axis, DMGridData **gridData, float t[3]) +void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3]) { if (axis == 0) { - if (x == gridSize - 1) { - if (y == gridSize - 1) - sub_v3_v3v3(t, gridData[index][x + gridSize*(y - 1)].co, gridData[index][x - 1 + gridSize*(y - 1)].co); + if (x == key->grid_size - 1) { + if (y == key->grid_size - 1) + sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, y - 1), CCG_grid_elem_co(key, grid, x - 1, y - 1)); else - sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x - 1 + gridSize*y].co); + sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, y), CCG_grid_elem_co(key, grid, x - 1, y)); } else - sub_v3_v3v3(t, gridData[index][x + 1 + gridSize*y].co, gridData[index][x + gridSize*y].co); + sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x + 1, y), CCG_grid_elem_co(key, grid, x, y)); } else if (axis == 1) { - if (y == gridSize - 1) { - if (x == gridSize - 1) - sub_v3_v3v3(t, gridData[index][x - 1 + gridSize*y].co, gridData[index][x - 1 + gridSize*(y - 1)].co); + if (y == key->grid_size - 1) { + if (x == key->grid_size - 1) + sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x - 1, y), CCG_grid_elem_co(key, grid, x - 1, (y - 1))); else - sub_v3_v3v3(t, gridData[index][x + gridSize*y].co, gridData[index][x + gridSize*(y - 1)].co); + sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, y), CCG_grid_elem_co(key, grid, x, (y - 1))); } else - sub_v3_v3v3(t, gridData[index][x + gridSize*(y + 1)].co, gridData[index][x + gridSize*y].co); + sub_v3_v3v3(t, CCG_grid_elem_co(key, grid, x, (y + 1)), CCG_grid_elem_co(key, grid, x, y)); } } -static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, DMGridData **oldGridData, int totlvl) +static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm2, DispOp op, CCGElem **oldGridData, int totlvl) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)dm; - DMGridData **gridData, **subGridData; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCGElem **gridData, **subGridData; + CCGKey key; MPoly *mpoly = me->mpoly; MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); + GridPaintMask *grid_paint_mask = NULL; int *gridOffset; int i, k, /*numGrids, */ gridSize, dGridSize, dSkip; int totloop, totpoly; @@ -968,10 +1021,15 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm gridSize = dm->getGridSize(dm); gridData = dm->getGridData(dm); gridOffset = dm->getGridOffset(dm); - subGridData = (oldGridData)? oldGridData: gridData; + dm->getGridKey(dm, &key); + subGridData = (oldGridData) ? oldGridData : gridData; dGridSize = multires_side_tot[totlvl]; - dSkip = (dGridSize-1)/(gridSize-1); + dSkip = (dGridSize - 1) / (gridSize - 1); + + /* multires paint masks */ + if (key.has_mask) + grid_paint_mask = CustomData_get_layer(&me->ldata, CD_GRID_PAINT_MASK); k = 0; /*current loop/mdisp index within the mloop array*/ @@ -982,9 +1040,10 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm int S, x, y, gIndex = gridOffset[i]; for (S = 0; S < numVerts; ++S, ++gIndex, ++k) { - MDisps *mdisp = &mdisps[mpoly[i].loopstart+S]; - DMGridData *grid = gridData[gIndex]; - DMGridData *subgrid = subGridData[gIndex]; + GridPaintMask *gpm = grid_paint_mask ? &grid_paint_mask[gIndex] : NULL; + MDisps *mdisp = &mdisps[mpoly[i].loopstart + S]; + CCGElem *grid = gridData[gIndex]; + CCGElem *subgrid = subGridData[gIndex]; float (*dispgrid)[3] = NULL; /* when adding new faces in edit mode, need to allocate disps */ @@ -996,19 +1055,28 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm dispgrid = mdisp->disps; + /* if needed, reallocate multires paint mask */ + if (gpm && op == CALC_DISPLACEMENTS) { + if (gpm->level < key.level) { + gpm->level = key.level; + MEM_freeN(gpm->data); + gpm->data = MEM_callocN(sizeof(float) * key.grid_area, "gpm.data"); + } + } + for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *co = grid[x + y*gridSize].co; - float *sco = subgrid[x + y*gridSize].co; - float *no = subgrid[x + y*gridSize].no; - float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; - float mat[3][3], tx[3], ty[3], disp[3], d[3]; + float *co = CCG_grid_elem_co(&key, grid, x, y); + float *sco = CCG_grid_elem_co(&key, subgrid, x, y); + float *no = CCG_grid_elem_no(&key, subgrid, x, y); + float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; + float mat[3][3], tx[3], ty[3], disp[3], d[3], mask; /* construct tangent space matrix */ - grid_tangent(gridSize, gIndex, x, y, 0, subGridData, tx); + grid_tangent(&key, x, y, 0, subGridData[gIndex], tx); normalize_v3(tx); - grid_tangent(gridSize, gIndex, x, y, 1, subGridData, ty); + grid_tangent(&key, x, y, 1, subGridData[gIndex], ty); normalize_v3(ty); //mul_v3_fl(tx, 1.0f/(gridSize-1)); @@ -1018,32 +1086,52 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm column_vectors_to_mat3(mat, tx, ty, no); switch (op) { - case APPLY_DISPLACEMENTS: - /* Convert displacement to object space - * and add to grid points */ - mul_v3_m3v3(disp, mat, data); - add_v3_v3v3(co, sco, disp); - break; - case CALC_DISPLACEMENTS: - /* Calculate displacement between new and old - * grid points and convert to tangent space */ - sub_v3_v3v3(disp, co, sco); - invert_m3(mat); - mul_v3_m3v3(data, mat, disp); - break; - case ADD_DISPLACEMENTS: - /* Convert subdivided displacements to tangent - * space and add to the original displacements */ - invert_m3(mat); - mul_v3_m3v3(d, mat, co); - add_v3_v3(data, d); - break; + case APPLY_DISPLACEMENTS: + /* Convert displacement to object space + * and add to grid points */ + mul_v3_m3v3(disp, mat, data); + add_v3_v3v3(co, sco, disp); + break; + case CALC_DISPLACEMENTS: + /* Calculate displacement between new and old + * grid points and convert to tangent space */ + sub_v3_v3v3(disp, co, sco); + invert_m3(mat); + mul_v3_m3v3(data, mat, disp); + break; + case ADD_DISPLACEMENTS: + /* Convert subdivided displacements to tangent + * space and add to the original displacements */ + invert_m3(mat); + mul_v3_m3v3(d, mat, co); + add_v3_v3(data, d); + break; + } + + if (gpm) { + switch (op) { + case APPLY_DISPLACEMENTS: + /* Copy mask from gpm to DM */ + *CCG_grid_elem_mask(&key, grid, x, y) = + paint_grid_paint_mask(gpm, key.level, x, y); + break; + case CALC_DISPLACEMENTS: + /* Copy mask from DM to gpm */ + mask = *CCG_grid_elem_mask(&key, grid, x, y); + gpm->data[y * gridSize + x] = CLAMPIS(mask, 0, 1); + break; + case ADD_DISPLACEMENTS: + /* Add mask displacement to gpm */ + gpm->data[y * gridSize + x] += + *CCG_grid_elem_mask(&key, grid, x, y); + break; + } } } } } } - + if (op == APPLY_DISPLACEMENTS) { ccgSubSurf_stitchFaces(ccgdm->ss, 0, NULL, 0); ccgSubSurf_updateNormals(ccgdm->ss, NULL, 0); @@ -1052,7 +1140,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm void multires_modifier_update_mdisps(struct DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; Object *ob; Mesh *me; MDisps *mdisps; @@ -1072,7 +1160,8 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) if (lvl < totlvl) { Mesh *me = ob->data; DerivedMesh *lowdm, *cddm, *highdm; - DMGridData **highGridData, **lowGridData, **subGridData, **gridData, *diffGrid; + CCGElem **highGridData, **lowGridData, **subGridData, **gridData, *diffGrid; + CCGKey highGridKey, lowGridKey; CCGSubSurf *ss; int i, j, numGrids, highGridSize, lowGridSize; @@ -1081,33 +1170,41 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) else cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); + highdm = subsurf_dm_create_local(ob, cddm, totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE); + ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh and displacements */ - lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple); + lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, TRUE); cddm->release(cddm); /* gather grid data */ numGrids = highdm->getNumGrids(highdm); highGridSize = highdm->getGridSize(highdm); highGridData = highdm->getGridData(highdm); + highdm->getGridKey(highdm, &highGridKey); lowGridSize = lowdm->getGridSize(lowdm); lowGridData = lowdm->getGridData(lowdm); + lowdm->getGridKey(lowdm, &lowGridKey); gridData = dm->getGridData(dm); - subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*"); - diffGrid = MEM_callocN(sizeof(DMGridData)*lowGridSize*lowGridSize, "diff"); + BLI_assert(highGridKey.elem_size == lowGridKey.elem_size); + + subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*"); + diffGrid = MEM_callocN(lowGridKey.elem_size * lowGridSize * lowGridSize, "diff"); for (i = 0; i < numGrids; ++i) { /* backup subsurf grids */ - subGridData[i] = MEM_callocN(sizeof(DMGridData)*highGridSize*highGridSize, "subGridData"); - memcpy(subGridData[i], highGridData[i], sizeof(DMGridData)*highGridSize*highGridSize); + subGridData[i] = MEM_callocN(highGridKey.elem_size * highGridSize * highGridSize, "subGridData"); + memcpy(subGridData[i], highGridData[i], highGridKey.elem_size * highGridSize * highGridSize); /* write difference of subsurf and displaced low level into high subsurf */ - for (j = 0; j < lowGridSize*lowGridSize; ++j) - sub_v3_v3v3(diffGrid[j].co, gridData[i][j].co, lowGridData[i][j].co); + for (j = 0; j < lowGridSize * lowGridSize; ++j) { + sub_v4_v4v4(CCG_elem_offset_co(&lowGridKey, diffGrid, j), + CCG_elem_offset_co(&lowGridKey, gridData[i], j), + CCG_elem_offset_co(&lowGridKey, lowGridData[i], j)); + } - multires_copy_dm_grid(highGridData[i], diffGrid, highGridSize, lowGridSize); + multires_copy_dm_grid(highGridData[i], diffGrid, &highGridKey, &lowGridKey); } /* lower level dm no longer needed at this point */ @@ -1115,7 +1212,6 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) lowdm->release(lowdm); /* subsurf higher levels again with difference of coordinates */ - ss= ((CCGDerivedMesh*)highdm)->ss; ccgSubSurf_updateFromFaces(ss, lvl, NULL, 0); ccgSubSurf_updateLevels(ss, lvl, NULL, 0); @@ -1135,7 +1231,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) else cddm = CDDM_from_mesh(me, NULL); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv); + subdm = subsurf_dm_create_local(ob, cddm, mmd->totlvl, mmd->simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, TRUE); cddm->release(cddm); multiresModifier_disp_run(dm, me, NULL, CALC_DISPLACEMENTS, subdm->getGridData(subdm), mmd->totlvl); @@ -1147,8 +1243,8 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) void multires_modifier_update_hidden(DerivedMesh *dm) { - CCGDerivedMesh *ccgdm= (CCGDerivedMesh*)dm; - BLI_bitmap *grid_hidden= ccgdm->gridHidden; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + BLI_bitmap *grid_hidden = ccgdm->gridHidden; Mesh *me = ccgdm->multires.ob->data; MDisps *mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); int totlvl = ccgdm->multires.totlvl; @@ -1167,7 +1263,7 @@ void multires_modifier_update_hidden(DerivedMesh *dm) } else if (gh) { gh = multires_mdisps_upsample_hidden(gh, lvl, totlvl, - md->hidden); + md->hidden); if (md->hidden) MEM_freeN(md->hidden); @@ -1180,7 +1276,8 @@ void multires_modifier_update_hidden(DerivedMesh *dm) void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) { DerivedMesh *ccgdm = NULL, *subsurf = NULL; - DMGridData **gridData, **subGridData=NULL; + CCGElem **gridData, **subGridData = NULL; + CCGKey key; MPoly *mpoly = CustomData_get_layer(&dm->polyData, CD_MPOLY); MDisps *mdisps; MultiresModifierData *mmd = get_multires_modifier(NULL, ob, 1); @@ -1197,29 +1294,30 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) } totlvl = mmd->totlvl; - ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple); + ccgdm = multires_dm_create_local(ob, dm, totlvl, totlvl, mmd->simple, FALSE); subsurf = subsurf_dm_create_local(ob, dm, totlvl, - mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv); + mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, mmd->flags & eMultiresModifierFlag_PlainUv, 0); numGrids = subsurf->getNumGrids(subsurf); gridSize = subsurf->getGridSize(subsurf); gridData = subsurf->getGridData(subsurf); + subsurf->getGridKey(subsurf, &key); - subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; i++) { - subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData"); - memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); + subGridData[i] = MEM_callocN(key.elem_size * gridSize * gridSize, "subGridData"); + memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize); } /*numGrids = ccgdm->dm->getNumGrids((DerivedMesh*)ccgdm);*/ /*UNUSED*/ - gridSize = ccgdm->getGridSize((DerivedMesh*)ccgdm); - gridData = ccgdm->getGridData((DerivedMesh*)ccgdm); - gridOffset = ccgdm->getGridOffset((DerivedMesh*)ccgdm); + gridSize = ccgdm->getGridSize((DerivedMesh *)ccgdm); + gridData = ccgdm->getGridData((DerivedMesh *)ccgdm); + gridOffset = ccgdm->getGridOffset((DerivedMesh *)ccgdm); dGridSize = multires_side_tot[totlvl]; - dSkip = (dGridSize-1)/(gridSize-1); + dSkip = (dGridSize - 1) / (gridSize - 1); k = 0; /*current loop/mdisp index within the mloop array*/ @@ -1230,32 +1328,32 @@ void multires_set_space(DerivedMesh *dm, Object *ob, int from, int to) int S, x, y, gIndex = gridOffset[i]; for (S = 0; S < numVerts; ++S, ++gIndex, ++k) { - MDisps *mdisp = &mdisps[mpoly[i].loopstart+S]; - /* DMGridData *grid = gridData[gIndex]; */ /* UNUSED */ - DMGridData *subgrid = subGridData[gIndex]; + MDisps *mdisp = &mdisps[mpoly[i].loopstart + S]; + /* CCGElem *grid = gridData[gIndex]; */ /* UNUSED */ + CCGElem *subgrid = subGridData[gIndex]; float (*dispgrid)[3] = NULL; /* when adding new faces in edit mode, need to allocate disps */ if (!mdisp->disps) { - mdisp->totdisp = gridSize*gridSize; + mdisp->totdisp = gridSize * gridSize; mdisp->level = totlvl; - mdisp->disps = MEM_callocN(sizeof(float)*3*mdisp->totdisp, "disp in multires_set_space"); + mdisp->disps = MEM_callocN(sizeof(float) * 3 * mdisp->totdisp, "disp in multires_set_space"); } dispgrid = mdisp->disps; for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *data = dispgrid[dGridSize*y*dSkip + x*dSkip]; - float *no = subgrid[x + y*gridSize].no; - float *co = subgrid[x + y*gridSize].co; + float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; + float *no = CCG_grid_elem_no(&key, subgrid, x, y); + float *co = CCG_grid_elem_co(&key, subgrid, x, y); float mat[3][3], tx[3], ty[3], dco[3]; /* construct tangent space matrix */ - grid_tangent(gridSize, gIndex, x, y, 0, subGridData, tx); + grid_tangent(&key, x, y, 0, subGridData[gIndex], tx); normalize_v3(tx); - grid_tangent(gridSize, gIndex, x, y, 1, subGridData, ty); + grid_tangent(&key, x, y, 1, subGridData[gIndex], ty); normalize_v3(ty); column_vectors_to_mat3(mat, tx, ty, no); @@ -1308,12 +1406,12 @@ void multires_stitch_grids(Object *ob) { /* utility for smooth brush */ if (ob && ob->derivedFinal) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*)ob->derivedFinal; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)ob->derivedFinal; CCGFace **faces; int totface; if (ccgdm->pbvh) { - BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void***)&faces, &totface); + BLI_pbvh_get_grid_updates(ccgdm->pbvh, 0, (void ***)&faces, &totface); if (totface) { ccgSubSurf_stitchFaces(ccgdm->ss, 0, faces, totface); @@ -1323,30 +1421,33 @@ void multires_stitch_grids(Object *ob) } } -DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, - int local_mmd, DerivedMesh *dm, - Object *ob, int useRenderParams) +DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, + MultiresModifierData *mmd, + Object *ob, + MultiresFlags flags) { - Mesh *me= ob->data; + Mesh *me = ob->data; DerivedMesh *result; CCGDerivedMesh *ccgdm = NULL; - DMGridData **gridData, **subGridData; - int lvl= multires_get_level(ob, mmd, useRenderParams); + CCGElem **gridData, **subGridData; + CCGKey key; + int lvl = multires_get_level(ob, mmd, (flags & MULTIRES_USE_RENDER_PARAMS)); int i, gridSize, numGrids; if (lvl == 0) return dm; result = subsurf_dm_create_local(ob, dm, lvl, - mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, - mmd->flags & eMultiresModifierFlag_PlainUv); + mmd->simple, mmd->flags & eMultiresModifierFlag_ControlEdges, + mmd->flags & eMultiresModifierFlag_PlainUv, + flags & MULTIRES_ALLOC_PAINT_MASK); - if (!local_mmd) { - ccgdm = (CCGDerivedMesh*)result; + if (!(flags & MULTIRES_USE_LOCAL_MMD)) { + ccgdm = (CCGDerivedMesh *)result; ccgdm->multires.ob = ob; ccgdm->multires.mmd = mmd; - ccgdm->multires.local_mmd = local_mmd; + ccgdm->multires.local_mmd = 0; ccgdm->multires.lvl = lvl; ccgdm->multires.totlvl = mmd->totlvl; ccgdm->multires.modified_flags = 0; @@ -1355,12 +1456,13 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, numGrids = result->getNumGrids(result); gridSize = result->getGridSize(result); gridData = result->getGridData(result); + result->getGridKey(result, &key); - subGridData = MEM_callocN(sizeof(DMGridData*)*numGrids, "subGridData*"); + subGridData = MEM_callocN(sizeof(CCGElem *) * numGrids, "subGridData*"); for (i = 0; i < numGrids; i++) { - subGridData[i] = MEM_callocN(sizeof(DMGridData)*gridSize*gridSize, "subGridData"); - memcpy(subGridData[i], gridData[i], sizeof(DMGridData)*gridSize*gridSize); + subGridData[i] = MEM_callocN(key.elem_size * gridSize * gridSize, "subGridData"); + memcpy(subGridData[i], gridData[i], key.elem_size * gridSize * gridSize); } multires_set_tot_mdisps(me, mmd->totlvl); @@ -1381,7 +1483,7 @@ DerivedMesh *multires_dm_create_from_derived(MultiresModifierData *mmd, } /**** Old Multires code **** - ***************************/ +***************************/ /* Adapted from sculptmode.c */ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, float v) @@ -1430,22 +1532,22 @@ void old_mdisps_bilinear(float out[3], float (*disps)[3], const int st, float u, static void old_mdisps_rotate(int S, int UNUSED(newside), int oldside, int x, int y, float *u, float *v) { - float offset = oldside*0.5f - 0.5f; + float offset = oldside * 0.5f - 0.5f; - if (S == 1) { *u= offset + x; *v = offset - y; } - if (S == 2) { *u= offset + y; *v = offset + x; } - if (S == 3) { *u= offset - x; *v = offset + y; } - if (S == 0) { *u= offset - y; *v = offset - x; } + if (S == 1) { *u = offset + x; *v = offset - y; } + if (S == 2) { *u = offset + y; *v = offset + x; } + if (S == 3) { *u = offset - x; *v = offset + y; } + if (S == 0) { *u = offset - y; *v = offset - x; } } static void old_mdisps_convert(MFace *mface, MDisps *mdisp) { - int newlvl = log(sqrt(mdisp->totdisp)-1)/M_LN2; - int oldlvl = newlvl+1; + int newlvl = log(sqrt(mdisp->totdisp) - 1) / M_LN2; + int oldlvl = newlvl + 1; int oldside = multires_side_tot[oldlvl]; int newside = multires_side_tot[newlvl]; - int nvert = (mface->v4)? 4: 3; - int newtotdisp = multires_grid_tot[newlvl]*nvert; + int nvert = (mface->v4) ? 4 : 3; + int newtotdisp = multires_grid_tot[newlvl] * nvert; int x, y, S; float (*disps)[3], (*out)[3], u = 0.0f, v = 0.0f; /* Quite gcc barking. */ @@ -1458,19 +1560,19 @@ static void old_mdisps_convert(MFace *mface, MDisps *mdisp) old_mdisps_rotate(S, newside, oldside, x, y, &u, &v); old_mdisps_bilinear(*out, mdisp->disps, oldside, u, v); - if (S == 1) { (*out)[1]= -(*out)[1]; } + if (S == 1) { (*out)[1] = -(*out)[1]; } else if (S == 2) { SWAP(float, (*out)[0], (*out)[1]); } - else if (S == 3) { (*out)[0]= -(*out)[0]; } - else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0]= -(*out)[0]; (*out)[1]= -(*out)[1]; }; + else if (S == 3) { (*out)[0] = -(*out)[0]; } + else if (S == 0) { SWAP(float, (*out)[0], (*out)[1]); (*out)[0] = -(*out)[0]; (*out)[1] = -(*out)[1]; }; } } } MEM_freeN(mdisp->disps); - mdisp->totdisp= newtotdisp; - mdisp->level= newlvl; - mdisp->disps= disps; + mdisp->totdisp = newtotdisp; + mdisp->level = newlvl; + mdisp->disps = disps; } void multires_load_old_250(Mesh *me) @@ -1479,10 +1581,10 @@ void multires_load_old_250(Mesh *me) MFace *mf; int i, j, k; - mdisps= CustomData_get_layer(&me->fdata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->fdata, CD_MDISPS); if (mdisps) { - for (i=0; itotface; i++) + for (i = 0; i < me->totface; i++) if (mdisps[i].totdisp) old_mdisps_convert(&me->mface[i], &mdisps[i]); @@ -1491,15 +1593,15 @@ void multires_load_old_250(Mesh *me) k = 0; mf = me->mface; - for (i=0; itotface; i++, mf++) { + for (i = 0; i < me->totface; i++, mf++) { int nvert = mf->v4 ? 4 : 3; int totdisp = mdisps[i].totdisp / nvert; - for (j=0; j < mf->v4 ? 4 : 3; j++, k++) { - mdisps2[k].disps = MEM_callocN(sizeof(float)*3*totdisp, "multires disp in conversion"); + for (j = 0; j < mf->v4 ? 4 : 3; j++, k++) { + mdisps2[k].disps = MEM_callocN(sizeof(float) * 3 * totdisp, "multires disp in conversion"); mdisps2[k].totdisp = totdisp; mdisps2[k].level = mdisps[i].level; - memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp*j, totdisp); + memcpy(mdisps2[k].disps, mdisps[i].disps + totdisp * j, totdisp); } } @@ -1519,7 +1621,7 @@ static void multires_free_level(MultiresLevel *lvl) void multires_free(Multires *mr) { if (mr) { - MultiresLevel* lvl= mr->levels.first; + MultiresLevel *lvl = mr->levels.first; /* Free the first-level data */ if (lvl) { @@ -1533,7 +1635,7 @@ void multires_free(Multires *mr) while (lvl) { multires_free_level(lvl); - lvl= lvl->next; + lvl = lvl->next; } MEM_freeN(mr->verts); @@ -1551,12 +1653,12 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult IndexNode *node = NULL; (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert face map"); - (*mem) = MEM_callocN(sizeof(IndexNode) * totface*4, "vert face map mem"); + (*mem) = MEM_callocN(sizeof(IndexNode) * totface * 4, "vert face map mem"); node = *mem; /* Find the users */ for (i = 0; i < totface; ++i) { - for (j = 0; j < (mface[i].v[3]?4:3); ++j, ++node) { + for (j = 0; j < (mface[i].v[3] ? 4 : 3); ++j, ++node) { node->index = i; BLI_addtail(&(*map)[mface[i].v[j]], node); } @@ -1564,13 +1666,13 @@ static void create_old_vert_face_map(ListBase **map, IndexNode **mem, const Mult } static void create_old_vert_edge_map(ListBase **map, IndexNode **mem, const MultiresEdge *medge, - const int totvert, const int totedge) + const int totvert, const int totedge) { int i, j; IndexNode *node = NULL; (*map) = MEM_callocN(sizeof(ListBase) * totvert, "vert edge map"); - (*mem) = MEM_callocN(sizeof(IndexNode) * totedge*2, "vert edge map mem"); + (*mem) = MEM_callocN(sizeof(IndexNode) * totedge * 2, "vert edge map mem"); node = *mem; /* Find the users */ @@ -1587,10 +1689,10 @@ static MultiresFace *find_old_face(ListBase *map, MultiresFace *faces, int v1, i IndexNode *n1; int v[4], i, j; - v[0]= v1; - v[1]= v2; - v[2]= v3; - v[3]= v4; + v[0] = v1; + v[1] = v2; + v[2] = v3; + v[3] = v4; for (n1 = map[v1].first; n1; n1 = n1->next) { int fnd[4] = {0, 0, 0, 0}; @@ -1635,7 +1737,7 @@ static void multires_load_old_edges(ListBase **emap, MultiresLevel *lvl, int *vv } static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLevel *lvl, int *vvmap, int dst, - int v1, int v2, int v3, int v4, int st2, int st3) + int v1, int v2, int v3, int v4, int st2, int st3) { int fmid; int emid13, emid14, emid23, emid24; @@ -1651,16 +1753,16 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst + st2 * st3 + st3, - fmid, v2, emid23, emid24, st2, st3 / 2); + fmid, v2, emid23, emid24, st2, st3 / 2); multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 + st3, - emid14, emid24, fmid, v4, st2, st3 / 2); + emid14, emid24, fmid, v4, st2, st3 / 2); multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst + st2 * st3 - st3, - emid13, emid23, v3, fmid, st2, st3 / 2); + emid13, emid23, v3, fmid, st2, st3 / 2); multires_load_old_faces(fmap + 1, emap + 1, lvl->next, vvmap, dst - st2 * st3 - st3, - v1, fmid, emid13, emid14, st2, st3 / 2); + v1, fmid, emid13, emid14, st2, st3 / 2); if (lvl->next->next) { multires_load_old_edges(emap, lvl->next, vvmap, dst, emid24, fmid, st3); @@ -1673,36 +1775,39 @@ static void multires_load_old_faces(ListBase **fmap, ListBase **emap, MultiresLe static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) { - CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm; + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; - DMGridData *vd; + CCGElem *vd; + CCGKey key; int index; int totvert, totedge, totface; int gridSize = ccgSubSurf_getGridSize(ss); int edgeSize = ccgSubSurf_getEdgeSize(ss); int i = 0; + dm->getGridKey(dm, &key); + totface = ccgSubSurf_getNumFaces(ss); for (index = 0; index < totface; index++) { CCGFace *f = ccgdm->faceMap[index].face; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); - vd= ccgSubSurf_getFaceCenterData(f); - copy_v3_v3(vd->co, mvert[i].co); + vd = ccgSubSurf_getFaceCenterData(f); + copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co); i++; for (S = 0; S < numVerts; S++) { for (x = 1; x < gridSize - 1; x++, i++) { - vd= ccgSubSurf_getFaceGridEdgeData(ss, f, S, x); - copy_v3_v3(vd->co, mvert[i].co); + vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x); + copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co); } } for (S = 0; S < numVerts; S++) { for (y = 1; y < gridSize - 1; y++) { for (x = 1; x < gridSize - 1; x++, i++) { - vd= ccgSubSurf_getFaceGridData(ss, f, S, x, y); - copy_v3_v3(vd->co, mvert[i].co); + vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y); + copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co); } } } @@ -1714,8 +1819,8 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) int x; for (x = 1; x < edgeSize - 1; x++, i++) { - vd= ccgSubSurf_getEdgeData(ss, e, x); - copy_v3_v3(vd->co, mvert[i].co); + vd = ccgSubSurf_getEdgeData(ss, e, x); + copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co); } } @@ -1723,8 +1828,8 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) for (index = 0; index < totvert; index++) { CCGVert *v = ccgdm->vertMap[index].vert; - vd= ccgSubSurf_getVertData(ss, v); - copy_v3_v3(vd->co, mvert[i].co); + vd = ccgSubSurf_getVertData(ss, v); + copy_v3_v3(CCG_elem_co(&key, vd), mvert[i].co); i++; } @@ -1735,7 +1840,7 @@ static void multires_mvert_to_ss(DerivedMesh *dm, MVert *mvert) static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) { MultiresLevel *lvl, *lvl1; - Multires *mr= me->mr; + Multires *mr = me->mr; MVert *vsrc, *vdst; unsigned int src, dst; int st = multires_side_tot[totlvl - 1] - 1; @@ -1755,7 +1860,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) /* Load base verts */ for (i = 0; i < lvl1->totvert; ++i) { vvmap[totvert - lvl1->totvert + i] = src; - ++src; + src++; } /* Original edges */ @@ -1801,7 +1906,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) int sides = lvl1->faces[i].v[3] ? 4 : 3; lvl = lvl1->next->next; - ++dst; + dst++; for (j = 3; j <= mr->level_count; ++j) { int base = multires_side_tot[totlvl - j + 1] - 2; @@ -1819,7 +1924,7 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) for (s = 0; s < sides; ++s) { for (x = 0; x < st2; ++x) { vvmap[dst + crossedgelen * (s + 1) - base - x * skip - 1] = lsrc; - ++lsrc; + lsrc++; } } @@ -1834,10 +1939,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) } /* calculate vert to edge/face maps for each level (except the last) */ - fmap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires fmap"); - emap = MEM_callocN(sizeof(ListBase*) * (mr->level_count-1), "multires emap"); - fmem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires fmem"); - emem = MEM_callocN(sizeof(IndexNode*) * (mr->level_count-1), "multires emem"); + fmap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires fmap"); + emap = MEM_callocN(sizeof(ListBase *) * (mr->level_count - 1), "multires emap"); + fmem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires fmem"); + emem = MEM_callocN(sizeof(IndexNode *) * (mr->level_count - 1), "multires emem"); lvl = lvl1; for (i = 0; i < (unsigned int)mr->level_count - 1; ++i) { create_old_vert_face_map(fmap + i, fmem + i, lvl->faces, lvl->totvert, lvl->totface); @@ -1862,10 +1967,10 @@ static void multires_load_old_dm(DerivedMesh *dm, Mesh *me, int totlvl) int pv = lvl1->faces[j].v[s == 0 ? sides - 1 : s - 1]; multires_load_old_faces(fmap, emap, lvl1->next, vvmap, mid, - vvmap[dst], cv, - find_old_edge(emap[0], lvl1->edges, pv, cv)->mid, - find_old_edge(emap[0], lvl1->edges, cv, nv)->mid, - st2, st4); + vvmap[dst], cv, + find_old_edge(emap[0], lvl1->edges, pv, cv)->mid, + find_old_edge(emap[0], lvl1->edges, cv, nv)->mid, + st2, st4); ldst += (st - 1) * (st - 1); } @@ -1920,10 +2025,10 @@ static void multires_load_old_vcols(Mesh *me) for (i = 0; i < me->totface; ++i) { for (j = 0; j < 4; ++j) { - mcol[i*4 + j].a = colface[i].col[j].a; - mcol[i*4 + j].r = colface[i].col[j].r; - mcol[i*4 + j].g = colface[i].col[j].g; - mcol[i*4 + j].b = colface[i].col[j].b; + mcol[i * 4 + j].a = colface[i].col[j].a; + mcol[i * 4 + j].r = colface[i].col[j].r; + mcol[i * 4 + j].g = colface[i].col[j].g; + mcol[i * 4 + j].b = colface[i].col[j].b; } } } @@ -1982,7 +2087,7 @@ void multires_load_old(Object *ob, Mesh *me) md = ob->modifiers.first; while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) md = md->next; - mmd = (MultiresModifierData*)modifier_new(eModifierType_Multires); + mmd = (MultiresModifierData *)modifier_new(eModifierType_Multires); BLI_insertlinkbefore(&ob->modifiers, md, mmd); for (i = 0; i < me->mr->level_count - 1; ++i) @@ -1990,9 +2095,9 @@ void multires_load_old(Object *ob, Mesh *me) mmd->lvl = mmd->totlvl; orig = CDDM_from_mesh(me, NULL); - dm = multires_dm_create_from_derived(mmd, 0, orig, ob, 0); + dm = multires_make_derived_from_derived(orig, mmd, ob, 0); - multires_load_old_dm(dm, me, mmd->totlvl+1); + multires_load_old_dm(dm, me, mmd->totlvl + 1); multires_dm_mark_as_modified(dm, MULTIRES_COORDS_MODIFIED); dm->release(dm); @@ -2011,13 +2116,13 @@ void multires_load_old(Object *ob, Mesh *me) /* Remove the old multires */ multires_free(me->mr); - me->mr= NULL; + me->mr = NULL; } static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) { - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); - MultiresModifierData *to_mmd= get_multires_modifier(scene, to_ob, 1); + MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); + MultiresModifierData *to_mmd = get_multires_modifier(scene, to_ob, 1); if (!mmd) { /* object could have MDISP even when there is no multires modifier @@ -2030,84 +2135,86 @@ static void multires_sync_levels(Scene *scene, Object *ob, Object *to_ob) if (!mmd || !to_mmd) return; - if (mmd->totlvl>to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); + if (mmd->totlvl > to_mmd->totlvl) multires_del_higher(mmd, ob, to_mmd->totlvl); else multires_subdivide(mmd, ob, to_mmd->totlvl, 0, mmd->simple); } static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) { - DerivedMesh *dm= NULL, *cddm= NULL, *subdm= NULL; - DMGridData **gridData, **subGridData; - Mesh *me= (Mesh*)ob->data; - MPoly *mpoly= me->mpoly; + DerivedMesh *dm = NULL, *cddm = NULL, *subdm = NULL; + CCGElem **gridData, **subGridData; + CCGKey key; + Mesh *me = (Mesh *)ob->data; + MPoly *mpoly = me->mpoly; /* MLoop *mloop = me->mloop; */ /* UNUSED */ MDisps *mdisps; int *gridOffset; int i, /*numGrids, */ gridSize, dGridSize, dSkip, totvert; float (*vertCos)[3] = NULL; - MultiresModifierData *mmd= get_multires_modifier(scene, ob, 1); + MultiresModifierData *mmd = get_multires_modifier(scene, ob, 1); MultiresModifierData high_mmd; CustomData_external_read(&me->ldata, &me->id, CD_MASK_MDISPS, me->totloop); - mdisps= CustomData_get_layer(&me->ldata, CD_MDISPS); + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); if (!mdisps || !mmd || !mmd->totlvl) return; /* we need derived mesh created from highest resolution */ - high_mmd= *mmd; - high_mmd.lvl= high_mmd.totlvl; + high_mmd = *mmd; + high_mmd.lvl = high_mmd.totlvl; /* unscaled multires with applied displacement */ - subdm= get_multires_dm(scene, &high_mmd, ob); + subdm = get_multires_dm(scene, &high_mmd, ob); /* prepare scaled CDDM to create ccgDN */ - cddm= mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); + cddm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); - totvert= cddm->getNumVerts(cddm); - vertCos= MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos"); + totvert = cddm->getNumVerts(cddm); + vertCos = MEM_mallocN(sizeof(*vertCos) * totvert, "multiresScale vertCos"); cddm->getVertCos(cddm, vertCos); - for (i=0; iflags & eMultiresModifierFlag_PlainUv); + dm = subsurf_dm_create_local(ob, cddm, high_mmd.totlvl, high_mmd.simple, 0, mmd->flags & eMultiresModifierFlag_PlainUv, 0); cddm->release(cddm); - /*numGrids= dm->getNumGrids(dm);*/ /*UNUSED*/ - gridSize= dm->getGridSize(dm); - gridData= dm->getGridData(dm); - gridOffset= dm->getGridOffset(dm); - subGridData= subdm->getGridData(subdm); + /*numGrids = dm->getNumGrids(dm);*/ /*UNUSED*/ + gridSize = dm->getGridSize(dm); + gridData = dm->getGridData(dm); + gridOffset = dm->getGridOffset(dm); + dm->getGridKey(dm, &key); + subGridData = subdm->getGridData(subdm); - dGridSize= multires_side_tot[high_mmd.totlvl]; - dSkip= (dGridSize-1)/(gridSize-1); + dGridSize = multires_side_tot[high_mmd.totlvl]; + dSkip = (dGridSize - 1) / (gridSize - 1); #pragma omp parallel for private(i) if (me->totface*gridSize*gridSize*4 >= CCG_OMP_LIMIT) for (i = 0; i < me->totpoly; ++i) { - const int numVerts= mpoly[i].totloop; - MDisps *mdisp= &mdisps[mpoly[i].loopstart]; + const int numVerts = mpoly[i].totloop; + MDisps *mdisp = &mdisps[mpoly[i].loopstart]; int S, x, y, gIndex = gridOffset[i]; for (S = 0; S < numVerts; ++S, ++gIndex, mdisp++) { - DMGridData *grid= gridData[gIndex]; - DMGridData *subgrid= subGridData[gIndex]; - float (*dispgrid)[3]= mdisp->disps; + CCGElem *grid = gridData[gIndex]; + CCGElem *subgrid = subGridData[gIndex]; + float (*dispgrid)[3] = mdisp->disps; for (y = 0; y < gridSize; y++) { for (x = 0; x < gridSize; x++) { - float *co= grid[x + y*gridSize].co; - float *sco= subgrid[x + y*gridSize].co; - float *no= grid[x + y*gridSize].no; - float *data= dispgrid[dGridSize*y*dSkip + x*dSkip]; + float *co = CCG_grid_elem_co(&key, grid, x, y); + float *sco = CCG_grid_elem_co(&key, subgrid, x, y); + float *no = CCG_grid_elem_no(&key, grid, x, y); + float *data = dispgrid[dGridSize * y * dSkip + x * dSkip]; float mat[3][3], tx[3], ty[3], disp[3]; /* construct tangent space matrix */ - grid_tangent(gridSize, gIndex, x, y, 0, gridData, tx); + grid_tangent(&key, x, y, 0, gridData[gIndex], tx); normalize_v3(tx); - grid_tangent(gridSize, gIndex, x, y, 1, gridData, ty); + grid_tangent(&key, x, y, 1, gridData[gIndex], ty); normalize_v3(ty); column_vectors_to_mat3(mat, tx, ty, no); @@ -2130,11 +2237,11 @@ static void multires_apply_smat(Scene *scene, Object *ob, float smat[3][3]) int multires_mdisp_corners(MDisps *s) { - int lvl= 13; + int lvl = 13; while (lvl > 0) { - int side = (1 << (lvl-1)) + 1; - if ((s->totdisp % (side*side)) == 0) return s->totdisp / (side*side); + int side = (1 << (lvl - 1)) + 1; + if ((s->totdisp % (side * side)) == 0) return s->totdisp / (side * side); lvl--; } @@ -2146,7 +2253,7 @@ void multiresModifier_scale_disp(Scene *scene, Object *ob) float smat[3][3]; /* object's scale matrix */ - object_scale_to_mat3(ob, smat); + BKE_object_scale_to_mat3(ob, smat); multires_apply_smat(scene, ob, smat); } @@ -2157,9 +2264,9 @@ void multiresModifier_prepare_join(Scene *scene, Object *ob, Object *to_ob) multires_sync_levels(scene, ob, to_ob); /* construct scale matrix for displacement */ - object_scale_to_mat3(to_ob, tmat); + BKE_object_scale_to_mat3(to_ob, tmat); invert_m3(tmat); - object_scale_to_mat3(ob, smat); + BKE_object_scale_to_mat3(ob, smat); mul_m3_m3m3(mat, smat, tmat); multires_apply_smat(scene, ob, mat); @@ -2204,14 +2311,14 @@ void multires_topology_changed(Mesh *me) /* Find per-corner coordinate with given per-face UV coord */ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y) { - const float offset = face_side*0.5f - 0.5f; + const float offset = face_side * 0.5f - 0.5f; int S = 0; if (corners == 4) { if (u <= offset && v <= offset) S = 0; else if (u > offset && v <= offset) S = 1; else if (u > offset && v > offset) S = 2; - else if (u <= offset && v >= offset) S = 3; + else if (u <= offset && v >= offset) S = 3; if (S == 0) { *y = offset - u; @@ -2226,7 +2333,7 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, *x = v - offset; } else if (S == 3) { - *x= offset - u; + *x = offset - u; *y = v - offset; } } @@ -2235,15 +2342,15 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, float w = (face_side - 1) - u - v; float W1, W2; - if (u >= v && u >= w) {S = 0; W1= w; W2= v;} - else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w;} - else {S = 2; W1 = v; W2 = u;} + if (u >= v && u >= w) {S = 0; W1 = w; W2 = v; } + else if (v >= u && v >= w) {S = 1; W1 = u; W2 = w; } + else {S = 2; W1 = v; W2 = u; } - W1 /= (face_side-1); - W2 /= (face_side-1); + W1 /= (face_side - 1); + W2 /= (face_side - 1); - *x = (1-(2*W1)/(1-W2)) * grid_size; - *y = (1-(2*W2)/(1-W1)) * grid_size; + *x = (1 - (2 * W1) / (1 - W2)) * grid_size; + *y = (1 - (2 * W2) / (1 - W1)) * grid_size; } return S; diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c index b2a85ad0629..a25cd0d3b38 100644 --- a/source/blender/blenkernel/intern/node.c +++ b/source/blender/blenkernel/intern/node.c @@ -339,15 +339,15 @@ bNode *nodeAddNode(bNodeTree *ntree, struct bNodeTemplate *ntemp) node_add_sockets_from_type(ntree, node, ntype); - if (ntype->initfunc!=NULL) - ntype->initfunc(ntree, node, ntemp); - /* initialize the node name with the node label */ BLI_strncpy(node->name, nodeLabel(node), NODE_MAXSTR); nodeUniqueName(ntree, node); BLI_addtail(&ntree->nodes, node); + if (ntype->initfunc!=NULL) + ntype->initfunc(ntree, node, ntemp); + ntree->update |= NTREE_UPDATE_NODES; return node; @@ -643,7 +643,7 @@ bNodeTree *ntreeAddTree(const char *name, int type, int nodetype) BLI_strncpy(ntree->id.name+2, name, sizeof(ntree->id.name)); } else - ntree= alloc_libblock(&G.main->nodetree, ID_NT, name); + ntree= BKE_libblock_alloc(&G.main->nodetree, ID_NT, name); ntree->type= type; ntree->nodetype = nodetype; @@ -675,11 +675,11 @@ bNodeTree *ntreeCopyTree(bNodeTree *ntree) for (newtree=G.main->nodetree.first; newtree; newtree= newtree->id.next) if (newtree==ntree) break; if (newtree) { - newtree= copy_libblock(&ntree->id); + newtree= BKE_libblock_copy(&ntree->id); } else { newtree= MEM_dupallocN(ntree); - copy_libblock_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ + BKE_libblock_copy_data(&newtree->id, &ntree->id, TRUE); /* copy animdata and ID props */ } id_us_plus((ID *)newtree->gpd); @@ -931,7 +931,7 @@ void nodeFreeNode(bNodeTree *ntree, bNode *node) ntree->update |= NTREE_UPDATE_NODES; } -/* do not free ntree itself here, free_libblock calls this function too */ +/* do not free ntree itself here, BKE_libblock_free calls this function too */ void ntreeFreeTree(bNodeTree *ntree) { bNode *node, *next; @@ -1969,6 +1969,7 @@ static void registerShaderNodes(bNodeTreeType *ttype) register_node_type_sh_attribute(ttype); register_node_type_sh_geometry(ttype); register_node_type_sh_light_path(ttype); + register_node_type_sh_light_falloff(ttype); register_node_type_sh_fresnel(ttype); register_node_type_sh_layer_weight(ttype); register_node_type_sh_tex_coord(ttype); @@ -2093,7 +2094,7 @@ void free_nodesystem(void) free_typeinfos(&ntreeGetType(NTREE_TEXTURE)->node_types); } -/* called from unlink_scene, when deleting a scene goes over all scenes +/* called from BKE_scene_unlink, when deleting a scene goes over all scenes * other than the input, checks if they have render layer nodes referencing * the to-be-deleted scene, and resets them to NULL. */ diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index bf2e5b833b6..7bf0eadf088 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -117,50 +117,30 @@ #include "FRS_freestyle.h" /* Local function protos */ -static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); +static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul); -float originmat[3][3]; /* after where_is_object(), can be used in other functions (bad!) */ +float originmat[3][3]; /* after BKE_object_where_is_calc(), can be used in other functions (bad!) */ -void clear_workob(Object *workob) +void BKE_object_workob_clear(Object *workob) { memset(workob, 0, sizeof(Object)); - workob->size[0]= workob->size[1]= workob->size[2]= 1.0f; - workob->dscale[0]= workob->dscale[1]= workob->dscale[2]= 1.0f; - workob->rotmode= ROT_MODE_EUL; + workob->size[0] = workob->size[1] = workob->size[2] = 1.0f; + workob->dscale[0] = workob->dscale[1] = workob->dscale[2] = 1.0f; + workob->rotmode = ROT_MODE_EUL; } -void copy_baseflags(struct Scene *scene) +void BKE_object_update_base_layer(struct Scene *scene, Object *ob) { - Base *base= scene->base.first; - + Base *base = scene->base.first; + while (base) { - base->object->flag= base->flag; - base= base->next; + if (base->object == ob) base->lay = ob->lay; + base = base->next; } } -void copy_objectflags(struct Scene *scene) -{ - Base *base= scene->base.first; - - while (base) { - base->flag= base->object->flag; - base= base->next; - } -} - -void update_base_layer(struct Scene *scene, Object *ob) -{ - Base *base= scene->base.first; - - while (base) { - if (base->object == ob) base->lay= ob->lay; - base= base->next; - } -} - -void object_free_particlesystems(Object *ob) +void BKE_object_free_particlesystems(Object *ob) { while (ob->particlesystem.first) { ParticleSystem *psys = ob->particlesystem.first; @@ -171,23 +151,23 @@ void object_free_particlesystems(Object *ob) } } -void object_free_softbody(Object *ob) +void BKE_object_free_softbody(Object *ob) { if (ob->soft) { sbFree(ob->soft); - ob->soft= NULL; + ob->soft = NULL; } } -void object_free_bulletsoftbody(Object *ob) +void BKE_object_free_bulletsoftbody(Object *ob) { if (ob->bsoft) { bsbFree(ob->bsoft); - ob->bsoft= NULL; + ob->bsoft = NULL; } } -void object_free_modifiers(Object *ob) +void BKE_object_free_modifiers(Object *ob) { while (ob->modifiers.first) { ModifierData *md = ob->modifiers.first; @@ -198,31 +178,31 @@ void object_free_modifiers(Object *ob) } /* particle modifiers were freed, so free the particlesystems as well */ - object_free_particlesystems(ob); + BKE_object_free_particlesystems(ob); /* same for softbody */ - object_free_softbody(ob); + BKE_object_free_softbody(ob); } -int object_support_modifier_type(Object *ob, int modifier_type) +int BKE_object_support_modifier_type_check(Object *ob, int modifier_type) { ModifierTypeInfo *mti; mti = modifierType_getInfo(modifier_type); if (!((mti->flags & eModifierTypeFlag_AcceptsCVs) || - (ob->type==OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) + (ob->type == OB_MESH && (mti->flags & eModifierTypeFlag_AcceptsMesh)))) { - return FALSE; + return FALSE; } return TRUE; } -void object_link_modifiers(struct Object *ob, struct Object *from) +void BKE_object_link_modifiers(struct Object *ob, struct Object *from) { ModifierData *md; - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); if (!ELEM5(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_LATTICE)) { /* only objects listed above can have modifiers and linking them to objects @@ -230,12 +210,12 @@ void object_link_modifiers(struct Object *ob, struct Object *from) return; } - for (md=from->modifiers.first; md; md=md->next) { + for (md = from->modifiers.first; md; md = md->next) { ModifierData *nmd = NULL; if (ELEM4(md->type, eModifierType_Hook, eModifierType_Softbody, eModifierType_ParticleInstance, eModifierType_Collision)) continue; - if (!object_support_modifier_type(ob, md->type)) + if (!BKE_object_support_modifier_type_check(ob, md->type)) continue; nmd = modifier_new(md->type); @@ -243,28 +223,28 @@ void object_link_modifiers(struct Object *ob, struct Object *from) BLI_addtail(&ob->modifiers, nmd); } - copy_object_particlesystems(ob, from); - copy_object_softbody(ob, from); + BKE_object_copy_particlesystems(ob, from); + BKE_object_copy_softbody(ob, from); // TODO: smoke?, cloth? } /* here we will collect all local displist stuff */ /* also (ab)used in depsgraph */ -void object_free_display(Object *ob) +void BKE_object_free_display(Object *ob) { if (ob->derivedDeform) { ob->derivedDeform->needsFree = 1; ob->derivedDeform->release(ob->derivedDeform); - ob->derivedDeform= NULL; + ob->derivedDeform = NULL; } if (ob->derivedFinal) { ob->derivedFinal->needsFree = 1; ob->derivedFinal->release(ob->derivedFinal); - ob->derivedFinal= NULL; + ob->derivedFinal = NULL; } - freedisplist(&ob->disp); + BKE_displist_free(&ob->disp); } void free_sculptsession_deformMats(SculptSession *ss) @@ -282,12 +262,12 @@ void free_sculptsession(Object *ob) { if (ob && ob->sculpt) { SculptSession *ss = ob->sculpt; - DerivedMesh *dm= ob->derivedFinal; + DerivedMesh *dm = ob->derivedFinal; if (ss->pbvh) BLI_pbvh_free(ss->pbvh); if (dm && dm->getPBVH) - dm->getPBVH(NULL, dm); /* signal to clear */ + dm->getPBVH(NULL, dm); /* signal to clear */ if (ss->texcache) MEM_freeN(ss->texcache); @@ -310,44 +290,44 @@ void free_sculptsession(Object *ob) /* do not free object itself */ -void free_object(Object *ob) +void BKE_object_free(Object *ob) { int a; - object_free_display(ob); + BKE_object_free_display(ob); /* disconnect specific data */ if (ob->data) { - ID *id= ob->data; + ID *id = ob->data; id->us--; - if (id->us==0) { - if (ob->type==OB_MESH) unlink_mesh(ob->data); - else if (ob->type==OB_CURVE) BKE_curve_unlink(ob->data); - else if (ob->type==OB_MBALL) BKE_metaball_unlink(ob->data); + if (id->us == 0) { + if (ob->type == OB_MESH) BKE_mesh_unlink(ob->data); + else if (ob->type == OB_CURVE) BKE_curve_unlink(ob->data); + else if (ob->type == OB_MBALL) BKE_mball_unlink(ob->data); } - ob->data= NULL; + ob->data = NULL; } - for (a=0; atotcol; a++) { + for (a = 0; a < ob->totcol; a++) { if (ob->mat[a]) ob->mat[a]->id.us--; } if (ob->mat) MEM_freeN(ob->mat); if (ob->matbits) MEM_freeN(ob->matbits); - ob->mat= NULL; - ob->matbits= NULL; + ob->mat = NULL; + ob->matbits = NULL; if (ob->bb) MEM_freeN(ob->bb); - ob->bb= NULL; + ob->bb = NULL; if (ob->adt) BKE_free_animdata((ID *)ob); if (ob->poselib) ob->poselib->id.us--; if (ob->gpd) ((ID *)ob->gpd)->us--; if (ob->defbase.first) BLI_freelistN(&ob->defbase); if (ob->pose) - free_pose(ob->pose); + BKE_pose_free(ob->pose); if (ob->mpath) animviz_free_motionpath(ob->mpath); free_properties(&ob->prop); - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); free_sensors(&ob->sensors); free_controllers(&ob->controllers); @@ -370,15 +350,15 @@ static void unlink_object__unlinkModifierLinks(void *userData, Object *ob, Objec { Object *unlinkOb = userData; - if (*obpoin==unlinkOb) { + if (*obpoin == unlinkOb) { *obpoin = NULL; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA? + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: should this just be OB_RECALC_DATA? } } -void unlink_object(Object *ob) +void BKE_object_unlink(Object *ob) { - Main *bmain= G.main; + Main *bmain = G.main; Object *obt; Material *mat; World *wrld; @@ -400,55 +380,55 @@ void unlink_object(Object *ob) /* check all objects: parents en bevels and fields, also from libraries */ // FIXME: need to check all animation blocks (drivers) - obt= bmain->object.first; + obt = bmain->object.first; while (obt) { - if (obt->proxy==ob) - obt->proxy= NULL; - if (obt->proxy_from==ob) { - obt->proxy_from= NULL; + if (obt->proxy == ob) + obt->proxy = NULL; + if (obt->proxy_from == ob) { + obt->proxy_from = NULL; obt->recalc |= OB_RECALC_OB; } - if (obt->proxy_group==ob) - obt->proxy_group= NULL; + if (obt->proxy_group == ob) + obt->proxy_group = NULL; - if (obt->parent==ob) { - obt->parent= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (obt->parent == ob) { + obt->parent = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } modifiers_foreachObjectLink(obt, unlink_object__unlinkModifierLinks, ob); if (ELEM(obt->type, OB_CURVE, OB_FONT)) { - cu= obt->data; + cu = obt->data; - if (cu->bevobj==ob) { - cu->bevobj= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (cu->bevobj == ob) { + cu->bevobj = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } - if (cu->taperobj==ob) { - cu->taperobj= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (cu->taperobj == ob) { + cu->taperobj = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } - if (cu->textoncurve==ob) { - cu->textoncurve= NULL; - obt->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + if (cu->textoncurve == ob) { + cu->textoncurve = NULL; + obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; } } - else if (obt->type==OB_ARMATURE && obt->pose) { + else if (obt->type == OB_ARMATURE && obt->pose) { bPoseChannel *pchan; - for (pchan= obt->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con = pchan->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = obt->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { ct->tar = NULL; - ct->subtarget[0]= '\0'; + ct->subtarget[0] = '\0'; obt->recalc |= OB_RECALC_DATA; } } @@ -457,29 +437,29 @@ void unlink_object(Object *ob) cti->flush_constraint_targets(con, &targets, 0); } } - if (pchan->custom==ob) - pchan->custom= NULL; + if (pchan->custom == ob) + pchan->custom = NULL; } } else if (ELEM(OB_MBALL, ob->type, obt->type)) { - if (BKE_metaball_is_basis_for (obt, ob)) - obt->recalc|= OB_RECALC_DATA; + if (BKE_mball_is_basis_for(obt, ob)) + obt->recalc |= OB_RECALC_DATA; } sca_remove_ob_poin(obt, ob); - for (con = obt->constraints.first; con; con=con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = obt->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { ct->tar = NULL; - ct->subtarget[0]= '\0'; + ct->subtarget[0] = '\0'; obt->recalc |= OB_RECALC_DATA; } } @@ -495,73 +475,73 @@ void unlink_object(Object *ob) obt->recalc |= OB_RECALC_DATA; /* cloth */ - for (md=obt->modifiers.first; md; md=md->next) + for (md = obt->modifiers.first; md; md = md->next) if (md->type == eModifierType_Cloth) obt->recalc |= OB_RECALC_DATA; } /* strips */ #if 0 // XXX old animation system - for (strip= obt->nlastrips.first; strip; strip= strip->next) { - if (strip->object==ob) - strip->object= NULL; + for (strip = obt->nlastrips.first; strip; strip = strip->next) { + if (strip->object == ob) + strip->object = NULL; if (strip->modifiers.first) { bActionModifier *amod; - for (amod= strip->modifiers.first; amod; amod= amod->next) - if (amod->ob==ob) - amod->ob= NULL; + for (amod = strip->modifiers.first; amod; amod = amod->next) + if (amod->ob == ob) + amod->ob = NULL; } } #endif // XXX old animation system /* particle systems */ if (obt->particlesystem.first) { - ParticleSystem *tpsys= obt->particlesystem.first; - for (; tpsys; tpsys=tpsys->next) { + ParticleSystem *tpsys = obt->particlesystem.first; + for (; tpsys; tpsys = tpsys->next) { BoidState *state = NULL; BoidRule *rule = NULL; ParticleTarget *pt = tpsys->targets.first; - for (; pt; pt=pt->next) { - if (pt->ob==ob) { + for (; pt; pt = pt->next) { + if (pt->ob == ob) { pt->ob = NULL; obt->recalc |= OB_RECALC_DATA; break; } } - if (tpsys->target_ob==ob) { - tpsys->target_ob= NULL; + if (tpsys->target_ob == ob) { + tpsys->target_ob = NULL; obt->recalc |= OB_RECALC_DATA; } - if (tpsys->part->dup_ob==ob) - tpsys->part->dup_ob= NULL; + if (tpsys->part->dup_ob == ob) + tpsys->part->dup_ob = NULL; - if (tpsys->part->phystype==PART_PHYS_BOIDS) { + if (tpsys->part->phystype == PART_PHYS_BOIDS) { ParticleData *pa; BoidParticle *bpa; int p; - for (p=0, pa=tpsys->particles; ptotpart; p++, pa++) { + for (p = 0, pa = tpsys->particles; p < tpsys->totpart; p++, pa++) { bpa = pa->boid; if (bpa->ground == ob) bpa->ground = NULL; } } if (tpsys->part->boids) { - for (state = tpsys->part->boids->states.first; state; state=state->next) { - for (rule = state->rules.first; rule; rule=rule->next) { - if (rule->type==eBoidRuleType_Avoid) { - BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid*)rule; - if (gabr->ob==ob) - gabr->ob= NULL; + for (state = tpsys->part->boids->states.first; state; state = state->next) { + for (rule = state->rules.first; rule; rule = rule->next) { + if (rule->type == eBoidRuleType_Avoid) { + BoidRuleGoalAvoid *gabr = (BoidRuleGoalAvoid *)rule; + if (gabr->ob == ob) + gabr->ob = NULL; } - else if (rule->type==eBoidRuleType_FollowLeader) { - BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader*)rule; - if (flbr->ob==ob) - flbr->ob= NULL; + else if (rule->type == eBoidRuleType_FollowLeader) { + BoidRuleFollowLeader *flbr = (BoidRuleFollowLeader *)rule; + if (flbr->ob == ob) + flbr->ob = NULL; } } } @@ -571,64 +551,64 @@ void unlink_object(Object *ob) obt->recalc |= OB_RECALC_DATA; } - obt= obt->id.next; + obt = obt->id.next; } /* materials */ - mat= bmain->mat.first; + mat = bmain->mat.first; while (mat) { - for (a=0; amtex[a] && ob==mat->mtex[a]->object) { + for (a = 0; a < MAX_MTEX; a++) { + if (mat->mtex[a] && ob == mat->mtex[a]->object) { /* actually, test for lib here... to do */ - mat->mtex[a]->object= NULL; + mat->mtex[a]->object = NULL; } } - mat= mat->id.next; + mat = mat->id.next; } /* textures */ - for (tex= bmain->tex.first; tex; tex= tex->id.next) { - if (tex->env && (ob==tex->env->object)) tex->env->object= NULL; - if (tex->pd && (ob==tex->pd->object)) tex->pd->object= NULL; - if (tex->vd && (ob==tex->vd->object)) tex->vd->object= NULL; + for (tex = bmain->tex.first; tex; tex = tex->id.next) { + if (tex->env && (ob == tex->env->object)) tex->env->object = NULL; + if (tex->pd && (ob == tex->pd->object)) tex->pd->object = NULL; + if (tex->vd && (ob == tex->vd->object)) tex->vd->object = NULL; } /* worlds */ - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - if (wrld->id.lib==NULL) { - for (a=0; amtex[a] && ob==wrld->mtex[a]->object) - wrld->mtex[a]->object= NULL; + if (wrld->id.lib == NULL) { + for (a = 0; a < MAX_MTEX; a++) { + if (wrld->mtex[a] && ob == wrld->mtex[a]->object) + wrld->mtex[a]->object = NULL; } } - wrld= wrld->id.next; + wrld = wrld->id.next; } /* scenes */ - sce= bmain->scene.first; + sce = bmain->scene.first; while (sce) { - if (sce->id.lib==NULL) { - if (sce->camera==ob) sce->camera= NULL; - if (sce->toolsettings->skgen_template==ob) sce->toolsettings->skgen_template = NULL; - if (sce->toolsettings->particle.object==ob) sce->toolsettings->particle.object= NULL; + if (sce->id.lib == NULL) { + if (sce->camera == ob) sce->camera = NULL; + if (sce->toolsettings->skgen_template == ob) sce->toolsettings->skgen_template = NULL; + if (sce->toolsettings->particle.object == ob) sce->toolsettings->particle.object = NULL; #ifdef DURIAN_CAMERA_SWITCH { TimeMarker *m; - for (m= sce->markers.first; m; m= m->next) { - if (m->camera==ob) - m->camera= NULL; + for (m = sce->markers.first; m; m = m->next) { + if (m->camera == ob) + m->camera = NULL; } } #endif if (sce->ed) { Sequence *seq; - SEQ_BEGIN (sce->ed, seq) + SEQ_BEGIN(sce->ed, seq) { if (seq->scene_camera == ob) { seq->scene_camera = NULL; @@ -646,19 +626,19 @@ void unlink_object(Object *ob) } } - sce= sce->id.next; + sce = sce->id.next; } /* screens */ - sc= bmain->screen.first; + sc = bmain->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; /* found doesn't need to be set here */ if (v3d->ob_centre == ob) { @@ -670,156 +650,156 @@ void unlink_object(Object *ob) v3d->localvd->ob_centre_bone[0] = '\0'; } - found= 0; - if (v3d->camera==ob) { - v3d->camera= NULL; - found= 1; + found = 0; + if (v3d->camera == ob) { + v3d->camera = NULL; + found = 1; } - if (v3d->localvd && v3d->localvd->camera==ob ) { - v3d->localvd->camera= NULL; + if (v3d->localvd && v3d->localvd->camera == ob) { + v3d->localvd->camera = NULL; found += 2; } if (found) { if (sa->spacetype == SPACE_VIEW3D) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - rv3d= (RegionView3D *)ar->regiondata; + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + rv3d = (RegionView3D *)ar->regiondata; if (found == 1 || found == 3) { if (rv3d->persp == RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; + rv3d->persp = RV3D_PERSP; } if (found == 2 || found == 3) { if (rv3d->localvd && rv3d->localvd->persp == RV3D_CAMOB) - rv3d->localvd->persp= RV3D_PERSP; + rv3d->localvd->persp = RV3D_PERSP; } } } } } } - else if (sl->spacetype==SPACE_OUTLINER) { - SpaceOops *so= (SpaceOops *)sl; + else if (sl->spacetype == SPACE_OUTLINER) { + SpaceOops *so = (SpaceOops *)sl; if (so->treestore) { - TreeStoreElem *tselem= so->treestore->data; + TreeStoreElem *tselem = so->treestore->data; int a; - for (a=0; atreestore->usedelem; a++, tselem++) { - if (tselem->id==(ID *)ob) tselem->id= NULL; + for (a = 0; a < so->treestore->usedelem; a++, tselem++) { + if (tselem->id == (ID *)ob) tselem->id = NULL; } } } - else if (sl->spacetype==SPACE_BUTS) { - SpaceButs *sbuts= (SpaceButs *)sl; + else if (sl->spacetype == SPACE_BUTS) { + SpaceButs *sbuts = (SpaceButs *)sl; - if (sbuts->pinid==(ID *)ob) { - sbuts->flag&= ~SB_PIN_CONTEXT; - sbuts->pinid= NULL; + if (sbuts->pinid == (ID *)ob) { + sbuts->flag &= ~SB_PIN_CONTEXT; + sbuts->pinid = NULL; } } } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } /* groups */ - group= bmain->group.first; + group = bmain->group.first; while (group) { rem_from_group(group, ob, NULL, NULL); - group= group->id.next; + group = group->id.next; } /* cameras */ - camera= bmain->camera.first; + camera = bmain->camera.first; while (camera) { - if (camera->dof_ob==ob) { + if (camera->dof_ob == ob) { camera->dof_ob = NULL; } - camera= camera->id.next; + camera = camera->id.next; } } -int exist_object(Object *obtest) +int BKE_object_exists_check(Object *obtest) { Object *ob; - if (obtest==NULL) return 0; + if (obtest == NULL) return 0; - ob= G.main->object.first; + ob = G.main->object.first; while (ob) { - if (ob==obtest) return 1; - ob= ob->id.next; + if (ob == obtest) return 1; + ob = ob->id.next; } return 0; } /* *************************************************** */ -void *add_obdata_from_type(int type) +void *BKE_object_obdata_add_from_type(int type) { switch (type) { - case OB_MESH: return add_mesh("Mesh"); - case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE); - case OB_SURF: return BKE_curve_add("Surf", OB_SURF); - case OB_FONT: return BKE_curve_add("Text", OB_FONT); - case OB_MBALL: return BKE_metaball_add("Meta"); - case OB_CAMERA: return BKE_camera_add("Camera"); - case OB_LAMP: return add_lamp("Lamp"); - case OB_LATTICE: return add_lattice("Lattice"); - case OB_ARMATURE: return add_armature("Armature"); - case OB_SPEAKER: return add_speaker("Speaker"); - case OB_EMPTY: return NULL; - default: - printf("add_obdata_from_type: Internal error, bad type: %d\n", type); - return NULL; + case OB_MESH: return BKE_mesh_add("Mesh"); + case OB_CURVE: return BKE_curve_add("Curve", OB_CURVE); + case OB_SURF: return BKE_curve_add("Surf", OB_SURF); + case OB_FONT: return BKE_curve_add("Text", OB_FONT); + case OB_MBALL: return BKE_mball_add("Meta"); + case OB_CAMERA: return BKE_camera_add("Camera"); + case OB_LAMP: return BKE_lamp_add("Lamp"); + case OB_LATTICE: return BKE_lattice_add("Lattice"); + case OB_ARMATURE: return BKE_armature_add("Armature"); + case OB_SPEAKER: return BKE_speaker_add("Speaker"); + case OB_EMPTY: return NULL; + default: + printf("BKE_object_obdata_add_from_type: Internal error, bad type: %d\n", type); + return NULL; } } static const char *get_obdata_defname(int type) { switch (type) { - case OB_MESH: return "Mesh"; - case OB_CURVE: return "Curve"; - case OB_SURF: return "Surf"; - case OB_FONT: return "Text"; - case OB_MBALL: return "Mball"; - case OB_CAMERA: return "Camera"; - case OB_LAMP: return "Lamp"; - case OB_LATTICE: return "Lattice"; - case OB_ARMATURE: return "Armature"; - case OB_SPEAKER: return "Speaker"; - case OB_EMPTY: return "Empty"; - default: - printf("get_obdata_defname: Internal error, bad type: %d\n", type); - return "Empty"; + case OB_MESH: return "Mesh"; + case OB_CURVE: return "Curve"; + case OB_SURF: return "Surf"; + case OB_FONT: return "Text"; + case OB_MBALL: return "Mball"; + case OB_CAMERA: return "Camera"; + case OB_LAMP: return "Lamp"; + case OB_LATTICE: return "Lattice"; + case OB_ARMATURE: return "Armature"; + case OB_SPEAKER: return "Speaker"; + case OB_EMPTY: return "Empty"; + default: + printf("get_obdata_defname: Internal error, bad type: %d\n", type); + return "Empty"; } } /* more general add: creates minimum required data, but without vertices etc. */ -Object *add_only_object(int type, const char *name) +Object *BKE_object_add_only_object(int type, const char *name) { Object *ob; - if(!name) + if (!name) name = get_obdata_defname(type); - ob= alloc_libblock(&G.main->object, ID_OB, name); + ob = BKE_libblock_alloc(&G.main->object, ID_OB, name); /* default object vars */ - ob->type= type; + ob->type = type; - ob->col[0]= ob->col[1]= ob->col[2]= 1.0; - ob->col[3]= 1.0; + ob->col[0] = ob->col[1] = ob->col[2] = 1.0; + ob->col[3] = 1.0; - ob->size[0]= ob->size[1]= ob->size[2]= 1.0; - ob->dscale[0]= ob->dscale[1]= ob->dscale[2]= 1.0; + ob->size[0] = ob->size[1] = ob->size[2] = 1.0; + ob->dscale[0] = ob->dscale[1] = ob->dscale[2] = 1.0; /* objects should default to having Euler XYZ rotations, * but rotations default to quaternions */ - ob->rotmode= ROT_MODE_EUL; + ob->rotmode = ROT_MODE_EUL; unit_axis_angle(ob->rotAxis, &ob->rotAngle); unit_axis_angle(ob->drotAxis, &ob->drotAngle); @@ -833,35 +813,35 @@ Object *add_only_object(int type, const char *name) unit_m4(ob->constinv); unit_m4(ob->parentinv); unit_m4(ob->obmat); - ob->dt= OB_TEXTURE; - ob->empty_drawtype= OB_PLAINAXES; - ob->empty_drawsize= 1.0; + ob->dt = OB_TEXTURE; + ob->empty_drawtype = OB_PLAINAXES; + ob->empty_drawsize = 1.0; - if (type==OB_CAMERA || type==OB_LAMP || type==OB_SPEAKER) { - ob->trackflag= OB_NEGZ; - ob->upflag= OB_POSY; + if (type == OB_CAMERA || type == OB_LAMP || type == OB_SPEAKER) { + ob->trackflag = OB_NEGZ; + ob->upflag = OB_POSY; } else { - ob->trackflag= OB_POSY; - ob->upflag= OB_POSZ; + ob->trackflag = OB_POSY; + ob->upflag = OB_POSZ; } - ob->dupon= 1; ob->dupoff= 0; - ob->dupsta= 1; ob->dupend= 100; + ob->dupon = 1; ob->dupoff = 0; + ob->dupsta = 1; ob->dupend = 100; ob->dupfacesca = 1.0; /* Game engine defaults*/ - ob->mass= ob->inertia= 1.0f; - ob->formfactor= 0.4f; - ob->damping= 0.04f; - ob->rdamping= 0.1f; + ob->mass = ob->inertia = 1.0f; + ob->formfactor = 0.4f; + ob->damping = 0.04f; + ob->rdamping = 0.1f; ob->anisotropicFriction[0] = 1.0f; ob->anisotropicFriction[1] = 1.0f; ob->anisotropicFriction[2] = 1.0f; - ob->gameflag= OB_PROP|OB_COLLISION; + ob->gameflag = OB_PROP | OB_COLLISION; ob->margin = 0.0; - ob->init_state=1; - ob->state=1; + ob->init_state = 1; + ob->state = 1; /* ob->pad3 == Contact Processing Threshold */ ob->m_contactProcessingThreshold = 1.0f; ob->obstacleRad = 1.0f; @@ -879,23 +859,23 @@ Object *add_only_object(int type, const char *name) /* general add: to scene, with layer from area and default name */ /* creates minimum required data, but without vertices etc. */ -Object *add_object(struct Scene *scene, int type) +Object *BKE_object_add(struct Scene *scene, int type) { Object *ob; Base *base; char name[MAX_ID_NAME]; BLI_strncpy(name, get_obdata_defname(type), sizeof(name)); - ob = add_only_object(type, name); + ob = BKE_object_add_only_object(type, name); - ob->data= add_obdata_from_type(type); + ob->data = BKE_object_obdata_add_from_type(type); - ob->lay= scene->lay; + ob->lay = scene->lay; - base= scene_add_base(scene, ob); - scene_deselect_all(scene); - scene_select_base(scene, base); - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + base = BKE_scene_base_add(scene, ob); + BKE_scene_base_deselect_all(scene); + BKE_scene_base_select(scene, base); + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; return ob; } @@ -904,19 +884,19 @@ SoftBody *copy_softbody(SoftBody *sb) { SoftBody *sbn; - if (sb==NULL) return(NULL); + if (sb == NULL) return(NULL); - sbn= MEM_dupallocN(sb); - sbn->totspring= sbn->totpoint= 0; - sbn->bpoint= NULL; - sbn->bspring= NULL; + sbn = MEM_dupallocN(sb); + sbn->totspring = sbn->totpoint = 0; + sbn->bpoint = NULL; + sbn->bspring = NULL; - sbn->keys= NULL; - sbn->totkey= sbn->totpointkey= 0; + sbn->keys = NULL; + sbn->totkey = sbn->totpointkey = 0; - sbn->scratch= NULL; + sbn->scratch = NULL; - sbn->pointcache= BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); + sbn->pointcache = BKE_ptcache_copy_list(&sbn->ptcaches, &sb->ptcaches); if (sb->effector_weights) sbn->effector_weights = MEM_dupallocN(sb->effector_weights); @@ -941,12 +921,12 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) ParticleData *pa; int p; - psysn= MEM_dupallocN(psys); - psysn->particles= MEM_dupallocN(psys->particles); - psysn->child= MEM_dupallocN(psys->child); + psysn = MEM_dupallocN(psys); + psysn->particles = MEM_dupallocN(psys->particles); + psysn->child = MEM_dupallocN(psys->child); if (psys->part->type == PART_HAIR) { - for (p=0, pa=psysn->particles; ptotpart; p++, pa++) + for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++) pa->hair = MEM_dupallocN(pa->hair); } @@ -960,7 +940,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) if (boid) boid = MEM_dupallocN(boid); - for (p=0, pa=psysn->particles; ptotpart; p++, pa++) { + for (p = 0, pa = psysn->particles; p < psysn->totpart; p++, pa++) { if (boid) pa->boid = boid++; if (key) { @@ -972,29 +952,29 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) if (psys->clmd) { psysn->clmd = (ClothModifierData *)modifier_new(eModifierType_Cloth); - modifier_copyData((ModifierData*)psys->clmd, (ModifierData*)psysn->clmd); + modifier_copyData((ModifierData *)psys->clmd, (ModifierData *)psysn->clmd); psys->hair_in_dm = psys->hair_out_dm = NULL; } BLI_duplicatelist(&psysn->targets, &psys->targets); - psysn->pathcache= NULL; - psysn->childcache= NULL; - psysn->edit= NULL; - psysn->frand= NULL; - psysn->pdd= NULL; - psysn->effectors= NULL; + psysn->pathcache = NULL; + psysn->childcache = NULL; + psysn->edit = NULL; + psysn->frand = NULL; + psysn->pdd = NULL; + psysn->effectors = NULL; psysn->pathcachebufs.first = psysn->pathcachebufs.last = NULL; psysn->childcachebufs.first = psysn->childcachebufs.last = NULL; psysn->renderdata = NULL; - psysn->pointcache= BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); + psysn->pointcache = BKE_ptcache_copy_list(&psysn->ptcaches, &psys->ptcaches); /* XXX - from reading existing code this seems correct but intended usage of * pointcache should /w cloth should be added in 'ParticleSystem' - campbell */ if (psysn->clmd) { - psysn->clmd->point_cache= psysn->pointcache; + psysn->clmd->point_cache = psysn->pointcache; } id_us_plus((ID *)psysn->part); @@ -1002,7 +982,7 @@ static ParticleSystem *copy_particlesystem(ParticleSystem *psys) return psysn; } -void copy_object_particlesystems(Object *obn, Object *ob) +void BKE_object_copy_particlesystems(Object *obn, Object *ob) { ParticleSystem *psys, *npsys; ModifierData *md; @@ -1012,34 +992,34 @@ void copy_object_particlesystems(Object *obn, Object *ob) return; } - obn->particlesystem.first= obn->particlesystem.last= NULL; - for (psys=ob->particlesystem.first; psys; psys=psys->next) { - npsys= copy_particlesystem(psys); + obn->particlesystem.first = obn->particlesystem.last = NULL; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + npsys = copy_particlesystem(psys); BLI_addtail(&obn->particlesystem, npsys); /* need to update particle modifiers too */ - for (md=obn->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_ParticleSystem) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*)md; - if (psmd->psys==psys) - psmd->psys= npsys; + for (md = obn->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_ParticleSystem) { + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *)md; + if (psmd->psys == psys) + psmd->psys = npsys; } - else if (md->type==eModifierType_DynamicPaint) { - DynamicPaintModifierData *pmd= (DynamicPaintModifierData*)md; + else if (md->type == eModifierType_DynamicPaint) { + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; if (pmd->brush) { - if (pmd->brush->psys==psys) { - pmd->brush->psys= npsys; + if (pmd->brush->psys == psys) { + pmd->brush->psys = npsys; } } } - else if (md->type==eModifierType_Smoke) { - SmokeModifierData *smd = (SmokeModifierData*) md; + else if (md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *) md; - if (smd->type==MOD_SMOKE_TYPE_FLOW) { + if (smd->type == MOD_SMOKE_TYPE_FLOW) { if (smd->flow) { if (smd->flow->psys == psys) - smd->flow->psys= npsys; + smd->flow->psys = npsys; } } } @@ -1047,34 +1027,34 @@ void copy_object_particlesystems(Object *obn, Object *ob) } } -void copy_object_softbody(Object *obn, Object *ob) +void BKE_object_copy_softbody(Object *obn, Object *ob) { if (ob->soft) - obn->soft= copy_softbody(ob->soft); + obn->soft = copy_softbody(ob->soft); } static void copy_object_pose(Object *obn, Object *ob) { bPoseChannel *chan; - /* note: need to clear obn->pose pointer first, so that copy_pose works (otherwise there's a crash) */ - obn->pose= NULL; - copy_pose(&obn->pose, ob->pose, 1); /* 1 = copy constraints */ + /* note: need to clear obn->pose pointer first, so that BKE_pose_copy_data works (otherwise there's a crash) */ + obn->pose = NULL; + BKE_pose_copy_data(&obn->pose, ob->pose, 1); /* 1 = copy constraints */ - for (chan = obn->pose->chanbase.first; chan; chan=chan->next) { + for (chan = obn->pose->chanbase.first; chan; chan = chan->next) { bConstraint *con; - chan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); + chan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); - for (con= chan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = chan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) ct->tar = obn; } @@ -1088,11 +1068,11 @@ static void copy_object_pose(Object *obn, Object *ob) static int object_pose_context(Object *ob) { - if ( (ob) && - (ob->type == OB_ARMATURE) && - (ob->pose) && - (ob->mode & OB_MODE_POSE) - ) { + if ( (ob) && + (ob->type == OB_ARMATURE) && + (ob->pose) && + (ob->mode & OB_MODE_POSE)) + { return 1; } else { @@ -1100,15 +1080,15 @@ static int object_pose_context(Object *ob) } } -Object *object_pose_armature_get(Object *ob) +Object *BKE_object_pose_armature_get(Object *ob) { - if (ob==NULL) + if (ob == NULL) return NULL; if (object_pose_context(ob)) return ob; - ob= modifiers_isDeformedByArmature(ob); + ob = modifiers_isDeformedByArmature(ob); if (object_pose_context(ob)) return ob; @@ -1122,31 +1102,31 @@ static void copy_object_transform(Object *ob_tar, Object *ob_src) copy_v3_v3(ob_tar->rot, ob_src->rot); copy_v3_v3(ob_tar->quat, ob_src->quat); copy_v3_v3(ob_tar->rotAxis, ob_src->rotAxis); - ob_tar->rotAngle= ob_src->rotAngle; - ob_tar->rotmode= ob_src->rotmode; + ob_tar->rotAngle = ob_src->rotAngle; + ob_tar->rotmode = ob_src->rotmode; copy_v3_v3(ob_tar->size, ob_src->size); } -Object *copy_object(Object *ob) +Object *BKE_object_copy(Object *ob) { Object *obn; ModifierData *md; int a; - obn= copy_libblock(&ob->id); + obn = BKE_libblock_copy(&ob->id); if (ob->totcol) { - obn->mat= MEM_dupallocN(ob->mat); - obn->matbits= MEM_dupallocN(ob->matbits); - obn->totcol= ob->totcol; + obn->mat = MEM_dupallocN(ob->mat); + obn->matbits = MEM_dupallocN(ob->matbits); + obn->totcol = ob->totcol; } - if (ob->bb) obn->bb= MEM_dupallocN(ob->bb); + if (ob->bb) obn->bb = MEM_dupallocN(ob->bb); obn->flag &= ~OB_FROMGROUP; - obn->modifiers.first = obn->modifiers.last= NULL; + obn->modifiers.first = obn->modifiers.last = NULL; - for (md=ob->modifiers.first; md; md=md->next) { + for (md = ob->modifiers.first; md; md = md->next) { ModifierData *nmd = modifier_new(md->type); BLI_strncpy(nmd->name, md->name, sizeof(nmd->name)); modifier_copyData(md, nmd); @@ -1163,8 +1143,8 @@ Object *copy_object(Object *ob) if (ob->pose) { copy_object_pose(obn, ob); /* backwards compat... non-armatures can get poses in older files? */ - if (ob->type==OB_ARMATURE) - armature_rebuild_pose(obn, obn->data); + if (ob->type == OB_ARMATURE) + BKE_pose_rebuild(obn, obn->data); } defgroup_copy_list(&obn->defbase, &ob->defbase); copy_constraints(&obn->constraints, &ob->constraints, TRUE); @@ -1177,21 +1157,21 @@ Object *copy_object(Object *ob) id_us_plus((ID *)obn->gpd); id_lib_extern((ID *)obn->dup_group); - for (a=0; atotcol; a++) id_us_plus((ID *)obn->mat[a]); + for (a = 0; a < obn->totcol; a++) id_us_plus((ID *)obn->mat[a]); - obn->disp.first= obn->disp.last= NULL; + obn->disp.first = obn->disp.last = NULL; if (ob->pd) { - obn->pd= MEM_dupallocN(ob->pd); + obn->pd = MEM_dupallocN(ob->pd); if (obn->pd->tex) id_us_plus(&(obn->pd->tex->id)); if (obn->pd->rng) obn->pd->rng = MEM_dupallocN(ob->pd->rng); } - obn->soft= copy_softbody(ob->soft); + obn->soft = copy_softbody(ob->soft); obn->bsoft = copy_bulletsoftbody(ob->bsoft); - copy_object_particlesystems(obn, ob); + BKE_object_copy_particlesystems(obn, ob); obn->derivedDeform = NULL; obn->derivedFinal = NULL; @@ -1199,7 +1179,7 @@ Object *copy_object(Object *ob) obn->gpulamp.first = obn->gpulamp.last = NULL; obn->pc_ids.first = obn->pc_ids.last = NULL; - obn->mpath= NULL; + obn->mpath = NULL; return obn; } @@ -1215,35 +1195,35 @@ static void extern_local_object(Object *ob) extern_local_matarar(ob->mat, ob->totcol); - for (psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys = ob->particlesystem.first; psys; psys = psys->next) id_lib_extern((ID *)psys->part); } -void make_local_object(Object *ob) +void BKE_object_make_local(Object *ob) { - Main *bmain= G.main; + Main *bmain = G.main; Scene *sce; Base *base; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (ob->id.lib==NULL) return; + if (ob->id.lib == NULL) return; - ob->proxy= ob->proxy_from= NULL; + ob->proxy = ob->proxy_from = NULL; - if (ob->id.us==1) { + if (ob->id.us == 1) { id_clear_lib_data(bmain, &ob->id); extern_local_object(ob); } else { - for (sce= bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce= sce->id.next) { - if (object_in_scene(ob, sce)) { - if (sce->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (sce = bmain->scene.first; sce && ELEM(0, is_lib, is_local); sce = sce->id.next) { + if (BKE_scene_base_find(sce, ob)) { + if (sce->id.lib) is_lib = TRUE; + else is_local = TRUE; } } @@ -1252,27 +1232,27 @@ void make_local_object(Object *ob) extern_local_object(ob); } else if (is_local && is_lib) { - Object *ob_new= copy_object(ob); + Object *ob_new = BKE_object_copy(ob); - ob_new->id.us= 0; + ob_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, ob->id.lib, &ob_new->id); - sce= bmain->scene.first; + sce = bmain->scene.first; while (sce) { - if (sce->id.lib==NULL) { - base= sce->base.first; + if (sce->id.lib == NULL) { + base = sce->base.first; while (base) { - if (base->object==ob) { - base->object= ob_new; + if (base->object == ob) { + base->object = ob_new; ob_new->id.us++; ob->id.us--; } - base= base->next; + base = base->next; } } - sce= sce->id.next; + sce = sce->id.next; } } } @@ -1281,7 +1261,7 @@ void make_local_object(Object *ob) /* * Returns true if the Object is a from an external blend file (libdata) */ -int object_is_libdata(Object *ob) +int BKE_object_is_libdata(Object *ob) { if (!ob) return 0; if (ob->proxy) return 0; @@ -1290,12 +1270,12 @@ int object_is_libdata(Object *ob) } /* Returns true if the Object data is a from an external blend file (libdata) */ -int object_data_is_libdata(Object *ob) +int BKE_object_obdata_is_libdata(Object *ob) { if (!ob) return 0; - if (ob->proxy && (ob->data==NULL || ((ID *)ob->data)->lib==NULL)) return 0; + if (ob->proxy && (ob->data == NULL || ((ID *)ob->data)->lib == NULL)) return 0; if (ob->id.lib) return 1; - if (ob->data==NULL) return 0; + if (ob->data == NULL) return 0; if (((ID *)ob->data)->lib) return 1; return 0; @@ -1306,45 +1286,45 @@ int object_data_is_libdata(Object *ob) /* when you make proxy, ensure the exposed layers are extern */ static void armature_set_id_extern(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; - unsigned int lay= arm->layer_protected; + unsigned int lay = arm->layer_protected; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (!(pchan->bone->layer & lay)) id_lib_extern((ID *)pchan->custom); } } -void object_copy_proxy_drivers(Object *ob, Object *target) +void BKE_object_copy_proxy_drivers(Object *ob, Object *target) { if ((target->adt) && (target->adt->drivers.first)) { FCurve *fcu; /* add new animdata block */ if (!ob->adt) - ob->adt= BKE_id_add_animdata(&ob->id); + ob->adt = BKE_id_add_animdata(&ob->id); /* make a copy of all the drivers (for now), then correct any links that need fixing */ free_fcurves(&ob->adt->drivers); copy_fcurves(&ob->adt->drivers, &target->adt->drivers); - for (fcu= ob->adt->drivers.first; fcu; fcu= fcu->next) { - ChannelDriver *driver= fcu->driver; + for (fcu = ob->adt->drivers.first; fcu; fcu = fcu->next) { + ChannelDriver *driver = fcu->driver; DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* all drivers */ DRIVER_TARGETS_LOOPER(dvar) { if (dtar->id) { if ((Object *)dtar->id == target) - dtar->id= (ID *)ob; + dtar->id = (ID *)ob; else { /* only on local objects because this causes indirect links a -> b -> c, blend to point directly to a.blend * when a.blend has a proxy thats linked into c.blend */ - if (ob->id.lib==NULL) + if (ob->id.lib == NULL) id_lib_extern((ID *)dtar->id); } } @@ -1359,19 +1339,19 @@ void object_copy_proxy_drivers(Object *ob, Object *target) /* local_object->proxy == pointer to library object, saved in files and read */ /* local_object->proxy_group == pointer to group dupli-object, saved in files and read */ -void object_make_proxy(Object *ob, Object *target, Object *gob) +void BKE_object_make_proxy(Object *ob, Object *target, Object *gob) { /* paranoia checks */ - if (ob->id.lib || target->id.lib==NULL) { + if (ob->id.lib || target->id.lib == NULL) { printf("cannot make proxy\n"); return; } - ob->proxy= target; - ob->proxy_group= gob; + ob->proxy = target; + ob->proxy_group = gob; id_lib_extern(&target->id); - ob->recalc= target->recalc= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc = target->recalc = OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* copy transform * - gob means this proxy comes from a group, just apply the matrix @@ -1380,7 +1360,7 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) * - no gob means this is being made from a linked object, * this is closer to making a copy of the object - in-place. */ if (gob) { - ob->rotmode= target->rotmode; + ob->rotmode = target->rotmode; mult_m4_m4m4(ob->obmat, gob->obmat, target->obmat); if (gob->dup_group) { /* should always be true */ float tvec[3]; @@ -1388,40 +1368,40 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) mul_mat3_m4_v3(ob->obmat, tvec); sub_v3_v3(ob->obmat[3], tvec); } - object_apply_mat4(ob, ob->obmat, FALSE, TRUE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, TRUE); } else { copy_object_transform(ob, target); - ob->parent= target->parent; /* libdata */ + ob->parent = target->parent; /* libdata */ copy_m4_m4(ob->parentinv, target->parentinv); } /* copy animdata stuff - drivers only for now... */ - object_copy_proxy_drivers(ob, target); + BKE_object_copy_proxy_drivers(ob, target); /* skip constraints? */ // FIXME: this is considered by many as a bug /* set object type and link to data */ - ob->type= target->type; - ob->data= target->data; - id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */ + ob->type = target->type; + ob->data = target->data; + id_us_plus((ID *)ob->data); /* ensures lib data becomes LIB_EXTERN */ /* copy material and index information */ - ob->actcol= ob->totcol= 0; + ob->actcol = ob->totcol = 0; if (ob->mat) MEM_freeN(ob->mat); if (ob->matbits) MEM_freeN(ob->matbits); ob->mat = NULL; - ob->matbits= NULL; + ob->matbits = NULL; if ((target->totcol) && (target->mat) && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { int i; - ob->actcol= target->actcol; - ob->totcol= target->totcol; + ob->actcol = target->actcol; + ob->totcol = target->totcol; ob->mat = MEM_dupallocN(target->mat); ob->matbits = MEM_dupallocN(target->matbits); - for (i=0; itotcol; i++) { + for (i = 0; i < target->totcol; i++) { /* don't need to run test_object_materials since we know this object is new and not used elsewhere */ id_us_plus((ID *)ob->mat[i]); } @@ -1429,9 +1409,9 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) /* type conversions */ if (target->type == OB_ARMATURE) { - copy_object_pose(ob, target); /* data copy, object pointers in constraints */ - rest_pose(ob->pose); /* clear all transforms in channels */ - armature_rebuild_pose(ob, ob->data); /* set all internal links */ + copy_object_pose(ob, target); /* data copy, object pointers in constraints */ + BKE_pose_rest(ob->pose); /* clear all transforms in channels */ + BKE_pose_rebuild(ob, ob->data); /* set all internal links */ armature_set_id_extern(ob); } @@ -1444,27 +1424,27 @@ void object_make_proxy(Object *ob, Object *target, Object *gob) if (ob->id.properties) { IDP_FreeProperty(ob->id.properties); MEM_freeN(ob->id.properties); - ob->id.properties= NULL; + ob->id.properties = NULL; } if (target->id.properties) { - ob->id.properties= IDP_CopyProperty(target->id.properties); + ob->id.properties = IDP_CopyProperty(target->id.properties); } /* copy drawtype info */ - ob->dt= target->dt; + ob->dt = target->dt; } /* *************** CALC ****************** */ -void object_scale_to_mat3(Object *ob, float mat[][3]) +void BKE_object_scale_to_mat3(Object *ob, float mat[][3]) { float vec[3]; mul_v3_v3v3(vec, ob->size, ob->dscale); size_to_mat3(mat, vec); } -void object_rot_to_mat3(Object *ob, float mat[][3]) +void BKE_object_rot_to_mat3(Object *ob, float mat[][3]) { float rmat[3][3], dmat[3][3]; @@ -1498,10 +1478,10 @@ void object_rot_to_mat3(Object *ob, float mat[][3]) mul_m3_m3m3(mat, dmat, rmat); } -void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) +void BKE_object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) { switch (ob->rotmode) { - case ROT_MODE_QUAT: + case ROT_MODE_QUAT: { float dquat[4]; mat3_to_quat(ob->quat, mat); @@ -1510,12 +1490,12 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) mul_qt_qtqt(ob->quat, dquat, ob->quat); } break; - case ROT_MODE_AXISANGLE: - mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); - sub_v3_v3(ob->rotAxis, ob->drotAxis); - ob->rotAngle -= ob->drotAngle; - break; - default: /* euler */ + case ROT_MODE_AXISANGLE: + mat3_to_axis_angle(ob->rotAxis, &ob->rotAngle, mat); + sub_v3_v3(ob->rotAxis, ob->drotAxis); + ob->rotAngle -= ob->drotAngle; + break; + default: /* euler */ { float quat[4]; float dquat[4]; @@ -1529,19 +1509,19 @@ void object_mat3_to_rot(Object *ob, float mat[][3], short use_compat) quat_to_mat3(tmat, quat); /* end drot correction */ - if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat); - else mat3_to_eulO(ob->rot, ob->rotmode, tmat); + if (use_compat) mat3_to_compatible_eulO(ob->rot, ob->rot, ob->rotmode, tmat); + else mat3_to_eulO(ob->rot, ob->rotmode, tmat); } } } -void object_tfm_protected_backup(const Object *ob, - ObjectTfmProtectedChannels *obtfm) +void BKE_object_tfm_protected_backup(const Object *ob, + ObjectTfmProtectedChannels *obtfm) { -#define TFMCPY( _v) (obtfm->_v = ob->_v) -#define TFMCPY3D( _v) copy_v3_v3(obtfm->_v, ob->_v) -#define TFMCPY4D( _v) copy_v4_v4(obtfm->_v, ob->_v) +#define TFMCPY(_v) (obtfm->_v = ob->_v) +#define TFMCPY3D(_v) copy_v3_v3(obtfm->_v, ob->_v) +#define TFMCPY4D(_v) copy_v4_v4(obtfm->_v, ob->_v) TFMCPY3D(loc); TFMCPY3D(dloc); @@ -1562,46 +1542,46 @@ void object_tfm_protected_backup(const Object *ob, } -void object_tfm_protected_restore(Object *ob, - const ObjectTfmProtectedChannels *obtfm, - const short protectflag) +void BKE_object_tfm_protected_restore(Object *ob, + const ObjectTfmProtectedChannels *obtfm, + const short protectflag) { unsigned int i; - for (i= 0; i < 3; i++) { - if (protectflag & (OB_LOCK_LOCX<loc[i]= obtfm->loc[i]; - ob->dloc[i]= obtfm->dloc[i]; + for (i = 0; i < 3; i++) { + if (protectflag & (OB_LOCK_LOCX << i)) { + ob->loc[i] = obtfm->loc[i]; + ob->dloc[i] = obtfm->dloc[i]; } - if (protectflag & (OB_LOCK_SCALEX<size[i]= obtfm->size[i]; - ob->dscale[i]= obtfm->dscale[i]; + if (protectflag & (OB_LOCK_SCALEX << i)) { + ob->size[i] = obtfm->size[i]; + ob->dscale[i] = obtfm->dscale[i]; } - if (protectflag & (OB_LOCK_ROTX<rot[i]= obtfm->rot[i]; - ob->drot[i]= obtfm->drot[i]; + if (protectflag & (OB_LOCK_ROTX << i)) { + ob->rot[i] = obtfm->rot[i]; + ob->drot[i] = obtfm->drot[i]; - ob->quat[i + 1]= obtfm->quat[i + 1]; - ob->dquat[i + 1]= obtfm->dquat[i + 1]; + ob->quat[i + 1] = obtfm->quat[i + 1]; + ob->dquat[i + 1] = obtfm->dquat[i + 1]; - ob->rotAxis[i]= obtfm->rotAxis[i]; - ob->drotAxis[i]= obtfm->drotAxis[i]; + ob->rotAxis[i] = obtfm->rotAxis[i]; + ob->drotAxis[i] = obtfm->drotAxis[i]; } } if ((protectflag & OB_LOCK_ROT4D) && (protectflag & OB_LOCK_ROTW)) { - ob->quat[0]= obtfm->quat[0]; - ob->dquat[0]= obtfm->dquat[0]; + ob->quat[0] = obtfm->quat[0]; + ob->dquat[0] = obtfm->dquat[0]; - ob->rotAngle= obtfm->rotAngle; - ob->drotAngle= obtfm->drotAngle; + ob->rotAngle = obtfm->rotAngle; + ob->drotAngle = obtfm->drotAngle; } } -/* see pchan_apply_mat4() for the equivalent 'pchan' function */ -void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent) +/* see BKE_pchan_apply_mat4() for the equivalent 'pchan' function */ +void BKE_object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const short use_parent) { float rot[3][3]; @@ -1610,15 +1590,15 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const mult_m4_m4m4(diff_mat, ob->parent->obmat, ob->parentinv); invert_m4_m4(imat, diff_mat); mult_m4_m4m4(rmat, imat, mat); /* get the parent relative matrix */ - object_apply_mat4(ob, rmat, use_compat, FALSE); + BKE_object_apply_mat4(ob, rmat, use_compat, FALSE); /* same as below, use rmat rather than mat */ mat4_to_loc_rot_size(ob->loc, rot, ob->size, rmat); - object_mat3_to_rot(ob, rot, use_compat); + BKE_object_mat3_to_rot(ob, rot, use_compat); } else { mat4_to_loc_rot_size(ob->loc, rot, ob->size, mat); - object_mat3_to_rot(ob, rot, use_compat); + BKE_object_mat3_to_rot(ob, rot, use_compat); } sub_v3_v3(ob->loc, ob->dloc); @@ -1627,28 +1607,28 @@ void object_apply_mat4(Object *ob, float mat[][4], const short use_compat, const if (ob->dscale[1] != 0.0f) ob->size[1] /= ob->dscale[1]; if (ob->dscale[2] != 0.0f) ob->size[2] /= ob->dscale[2]; - /* object_mat3_to_rot handles delta rotations */ + /* BKE_object_mat3_to_rot handles delta rotations */ } -void object_to_mat3(Object *ob, float mat[][3]) /* no parent */ +void BKE_object_to_mat3(Object *ob, float mat[][3]) /* no parent */ { float smat[3][3]; float rmat[3][3]; /*float q1[4];*/ /* size */ - object_scale_to_mat3(ob, smat); + BKE_object_scale_to_mat3(ob, smat); /* rot */ - object_rot_to_mat3(ob, rmat); + BKE_object_rot_to_mat3(ob, rmat); mul_m3_m3m3(mat, rmat, smat); } -void object_to_mat4(Object *ob, float mat[][4]) +void BKE_object_to_mat4(Object *ob, float mat[][4]) { float tmat[3][3]; - object_to_mat3(ob, tmat); + BKE_object_to_mat3(ob, tmat); copy_m4_m3(mat, tmat); @@ -1656,7 +1636,7 @@ void object_to_mat4(Object *ob, float mat[][4]) } /* extern */ -int enable_cu_speed= 1; +int enable_cu_speed = 1; static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) { @@ -1666,14 +1646,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) unit_m4(mat); - cu= par->data; - if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */ - makeDispListCurveTypes(scene, par, 0); - if (cu->path==NULL) return; + cu = par->data; + if (cu->path == NULL || cu->path->data == NULL) /* only happens on reload file, but violates depsgraph still... fix! */ + BKE_displist_make_curveTypes(scene, par, 0); + if (cu->path == NULL) return; /* catch exceptions: feature for nla stride editing */ if (ob->ipoflag & OB_DISABLE_PATH) { - ctime= 0.0f; + ctime = 0.0f; } /* catch exceptions: curve paths used as a duplicator */ else if (enable_cu_speed) { @@ -1684,14 +1664,14 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) * factor, which then gets clamped to lie within 0.0 - 1.0 range */ if (IS_EQF(cu->pathlen, 0.0f) == 0) - ctime= cu->ctime / cu->pathlen; + ctime = cu->ctime / cu->pathlen; else - ctime= cu->ctime; + ctime = cu->ctime; CLAMP(ctime, 0.0f, 1.0f); } else { - ctime= scene->r.cfra; + ctime = scene->r.cfra; if (IS_EQF(cu->pathlen, 0.0f) == 0) ctime /= cu->pathlen; @@ -1700,7 +1680,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* time calculus is correct, now apply distance offset */ if (cu->flag & CU_OFFS_PATHDIST) { - ctime += timeoffs/cu->path->totdist; + ctime += timeoffs / cu->path->totdist; /* restore */ SWAP(float, sf_orig, ob->sf); @@ -1708,7 +1688,7 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* vec: 4 items! */ - if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat:NULL, &radius, NULL)) { + if (where_on_path(par, ctime, vec, dir, cu->flag & CU_FOLLOW ? quat : NULL, &radius, NULL)) { if (cu->flag & CU_FOLLOW) { #if 0 @@ -1717,11 +1697,11 @@ static void ob_parcurve(Scene *scene, Object *ob, Object *par, float mat[][4]) /* the tilt */ normalize_v3(dir); - q[0]= (float)cos(0.5*vec[3]); - x1= (float)sin(0.5*vec[3]); - q[1]= -x1*dir[0]; - q[2]= -x1*dir[1]; - q[3]= -x1*dir[2]; + q[0] = (float)cos(0.5 * vec[3]); + x1 = (float)sin(0.5 * vec[3]); + q[1] = -x1 * dir[0]; + q[2] = -x1 * dir[1]; + q[3] = -x1 * dir[2]; mul_qt_qtqt(quat, q, quat); #else quat_apply_track(quat, ob->trackflag, ob->upflag); @@ -1747,15 +1727,15 @@ static void ob_parbone(Object *ob, Object *par, float mat[][4]) bPoseChannel *pchan; float vec[3]; - if (par->type!=OB_ARMATURE) { + if (par->type != OB_ARMATURE) { unit_m4(mat); return; } /* Make sure the bone is still valid */ - pchan= get_pose_channel(par->pose, ob->parsubstr); + pchan = BKE_pose_channel_find_name(par->pose, ob->parsubstr); if (!pchan) { - printf ("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name+2, ob->parsubstr); + printf("Object %s with Bone parent: bone %s doesn't exist\n", ob->id.name + 2, ob->parsubstr); unit_m4(mat); return; } @@ -1774,15 +1754,15 @@ static void give_parvert(Object *par, int nr, float vec[3]) BMEditMesh *em; int a, count; - vec[0]=vec[1]=vec[2]= 0.0f; + vec[0] = vec[1] = vec[2] = 0.0f; - if (par->type==OB_MESH) { - Mesh *me= par->data; + if (par->type == OB_MESH) { + Mesh *me = par->data; DerivedMesh *dm; em = me->edit_btmesh; -#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/ +#if 0 /* this was bmesh only, better, evaluate why this was needed - campbell*/ if (em) { BMVert *eve; BMIter iter; @@ -1790,7 +1770,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { int *keyindex = CustomData_bmesh_get(&em->bm->vdata, eve->head.data, CD_SHAPE_KEYINDEX); - if (keyindex && *keyindex==nr) { + if (keyindex && *keyindex == nr) { copy_v3_v3(vec, eve->co); break; } @@ -1798,17 +1778,17 @@ static void give_parvert(Object *par, int nr, float vec[3]) } #endif - dm = (em)? em->derivedFinal: par->derivedFinal; + dm = (em) ? em->derivedFinal : par->derivedFinal; if (dm) { - MVert *mvert= dm->getVertArray(dm); + MVert *mvert = dm->getVertArray(dm); int *index = (int *)dm->getVertDataArray(dm, CD_ORIGINDEX); int i, vindex, numVerts = dm->getNumVerts(dm); /* get the average of all verts with (original index == nr) */ - count= 0; + count = 0; for (i = 0; i < numVerts; i++) { - vindex= (index)? index[i]: i; + vindex = (index) ? index[i] : i; if (vindex == nr) { add_v3_v3(vec, mvert[i].co); @@ -1816,7 +1796,7 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } - if (count==0) { + if (count == 0) { /* keep as 0, 0, 0 */ } else if (count > 0) { @@ -1834,21 +1814,21 @@ static void give_parvert(Object *par, int nr, float vec[3]) Curve *cu; BPoint *bp; BezTriple *bezt; - int found= 0; + int found = 0; ListBase *nurbs; - cu= par->data; - nurbs= BKE_curve_nurbs_get(cu); - nu= nurbs->first; + cu = par->data; + nurbs = BKE_curve_nurbs_get(cu); + nu = nurbs->first; - count= 0; + count = 0; while (nu && !found) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (count==nr) { - found= 1; + if (count == nr) { + found = 1; copy_v3_v3(vec, bezt->vec[1]); break; } @@ -1857,43 +1837,43 @@ static void give_parvert(Object *par, int nr, float vec[3]) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if (count==nr) { - found= 1; - memcpy(vec, bp->vec, sizeof(float)*3); + if (count == nr) { + found = 1; + memcpy(vec, bp->vec, sizeof(float) * 3); break; } count++; bp++; } } - nu= nu->next; + nu = nu->next; } } - else if (par->type==OB_LATTICE) { - Lattice *latt= par->data; + else if (par->type == OB_LATTICE) { + Lattice *latt = par->data; BPoint *bp; - DispList *dl = find_displist(&par->disp, DL_VERTS); - float *co = dl?dl->verts:NULL; + DispList *dl = BKE_displist_find(&par->disp, DL_VERTS); + float *co = dl ? dl->verts : NULL; - if (latt->editlatt) latt= latt->editlatt->latt; + if (latt->editlatt) latt = latt->editlatt->latt; - a= latt->pntsu*latt->pntsv*latt->pntsw; - count= 0; - bp= latt->def; + a = latt->pntsu * latt->pntsv * latt->pntsw; + count = 0; + bp = latt->def; while (a--) { - if (count==nr) { + if (count == nr) { if (co) - memcpy(vec, co, 3*sizeof(float)); + memcpy(vec, co, 3 * sizeof(float)); else - memcpy(vec, bp->vec, 3*sizeof(float)); + memcpy(vec, bp->vec, 3 * sizeof(float)); break; } count++; - if (co) co+= 3; + if (co) co += 3; else bp++; } } @@ -1916,7 +1896,7 @@ static void ob_parvert3(Object *ob, Object *par, float mat[][4]) quat_to_mat3(cmat, q); copy_m4_m3(mat, cmat); - if (ob->type==OB_CURVE) { + if (ob->type == OB_CURVE) { copy_v3_v3(mat[3], v1); } else { @@ -1934,48 +1914,48 @@ static int where_is_object_parslow(Object *ob, float obmat[4][4], float slowmat[ int a; // include framerate - fac1= (1.0f / (1.0f + fabsf(ob->sf)) ); + fac1 = (1.0f / (1.0f + fabsf(ob->sf)) ); if (fac1 >= 1.0f) return 0; - fac2= 1.0f-fac1; + fac2 = 1.0f - fac1; - fp1= obmat[0]; - fp2= slowmat[0]; - for (a=0; a<16; a++, fp1++, fp2++) { - fp1[0]= fac1*fp1[0] + fac2*fp2[0]; + fp1 = obmat[0]; + fp2 = slowmat[0]; + for (a = 0; a < 16; a++, fp1++, fp2++) { + fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; } return 1; } -void where_is_object_time(Scene *scene, Object *ob, float ctime) +void BKE_object_where_is_calc_time(Scene *scene, Object *ob, float ctime) { float slowmat[4][4] = MAT4_UNITY; - float stime=ctime; + float stime = ctime; /* new version: correct parent+vertexparent and track+parent */ /* this one only calculates direct attached parent and track */ /* is faster, but should keep track of timeoffs */ - if (ob==NULL) return; + if (ob == NULL) return; /* execute drivers only, as animation has already been done */ BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, ctime, ADT_RECALC_DRIVERS); if (ob->parent) { - Object *par= ob->parent; + Object *par = ob->parent; /* hurms, code below conflicts with depgraph... (ton) */ /* and even worse, it gives bad effects for NLA stride too (try ctime != par->ctime, with MBlur) */ if (stime != par->ctime) { // only for ipo systems? - Object tmp= *par; + Object tmp = *par; - if (par->proxy_from); // was a copied matrix, no where_is! bad... - else where_is_object_time(scene, par, ctime); + if (par->proxy_from) ; // was a copied matrix, no where_is! bad... + else BKE_object_where_is_calc_time(scene, par, ctime); solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); - *par= tmp; + *par = tmp; } else solve_parenting(scene, ob, par, ob->obmat, slowmat, 0); @@ -1989,36 +1969,36 @@ void where_is_object_time(Scene *scene, Object *ob, float ctime) } } else { - object_to_mat4(ob, ob->obmat); + BKE_object_to_mat4(ob, ob->obmat); } /* solve constraints */ if (ob->constraints.first && !(ob->transflag & OB_NO_CONSTRAINTS)) { bConstraintOb *cob; - cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); - /* constraints need ctime, not stime. Some call where_is_object_time and bsystem_time */ - solve_constraints (&ob->constraints, cob, ctime); + /* constraints need ctime, not stime. Some call BKE_object_where_is_calc_time and bsystem_time */ + solve_constraints(&ob->constraints, cob, ctime); constraints_clear_evalob(cob); } /* set negative scale flag in object */ - if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; - else ob->transflag &= ~OB_NEG_SCALE; + if (is_negative_m4(ob->obmat)) ob->transflag |= OB_NEG_SCALE; + else ob->transflag &= ~OB_NEG_SCALE; } /* get object transformation matrix without recalculating dependencies and * constraints -- assume dependencies are already solved by depsgraph. * no changes to object and it's parent would be done. * used for bundles orientation in 3d space relative to parented blender camera */ -void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4]) +void BKE_object_where_is_calc_mat4(Scene *scene, Object *ob, float obmat[4][4]) { float slowmat[4][4] = MAT4_UNITY; if (ob->parent) { - Object *par= ob->parent; + Object *par = ob->parent; solve_parenting(scene, ob, par, obmat, slowmat, 1); @@ -2026,11 +2006,11 @@ void where_is_object_mat(Scene *scene, Object *ob, float obmat[4][4]) where_is_object_parslow(ob, obmat, slowmat); } else { - object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, obmat); } } -static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul) +static void solve_parenting(Scene *scene, Object *ob, Object *par, float obmat[][4], float slowmat[][4], int simul) { float totmat[4][4]; float tmat[4][4]; @@ -2038,58 +2018,58 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ float vec[3]; int ok; - object_to_mat4(ob, locmat); + BKE_object_to_mat4(ob, locmat); if (ob->partype & PARSLOW) copy_m4_m4(slowmat, obmat); switch (ob->partype & PARTYPE) { - case PAROBJECT: - ok= 0; - if (par->type==OB_CURVE) { - if (((Curve *)par->data)->flag & CU_PATH ) { - ob_parcurve(scene, ob, par, tmat); - ok= 1; + case PAROBJECT: + ok = 0; + if (par->type == OB_CURVE) { + if (((Curve *)par->data)->flag & CU_PATH) { + ob_parcurve(scene, ob, par, tmat); + ok = 1; + } } - } - if (ok) mul_serie_m4(totmat, par->obmat, tmat, - NULL, NULL, NULL, NULL, NULL, NULL); - else copy_m4_m4(totmat, par->obmat); + if (ok) mul_serie_m4(totmat, par->obmat, tmat, + NULL, NULL, NULL, NULL, NULL, NULL); + else copy_m4_m4(totmat, par->obmat); - break; - case PARBONE: - ob_parbone(ob, par, tmat); - mul_serie_m4(totmat, par->obmat, tmat, - NULL, NULL, NULL, NULL, NULL, NULL); - break; + break; + case PARBONE: + ob_parbone(ob, par, tmat); + mul_serie_m4(totmat, par->obmat, tmat, + NULL, NULL, NULL, NULL, NULL, NULL); + break; - case PARVERT1: - unit_m4(totmat); - if (simul) { - copy_v3_v3(totmat[3], par->obmat[3]); - } - else { - give_parvert(par, ob->par1, vec); - mul_v3_m4v3(totmat[3], par->obmat, vec); - } - break; - case PARVERT3: - ob_parvert3(ob, par, tmat); + case PARVERT1: + unit_m4(totmat); + if (simul) { + copy_v3_v3(totmat[3], par->obmat[3]); + } + else { + give_parvert(par, ob->par1, vec); + mul_v3_m4v3(totmat[3], par->obmat, vec); + } + break; + case PARVERT3: + ob_parvert3(ob, par, tmat); - mul_serie_m4(totmat, par->obmat, tmat, - NULL, NULL, NULL, NULL, NULL, NULL); - break; + mul_serie_m4(totmat, par->obmat, tmat, + NULL, NULL, NULL, NULL, NULL, NULL); + break; - case PARSKEL: - copy_m4_m4(totmat, par->obmat); - break; + case PARSKEL: + copy_m4_m4(totmat, par->obmat); + break; } // total mul_serie_m4(tmat, totmat, ob->parentinv, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL); mul_serie_m4(obmat, tmat, locmat, - NULL, NULL, NULL, NULL, NULL, NULL); + NULL, NULL, NULL, NULL, NULL, NULL); if (simul) { @@ -2099,7 +2079,7 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ copy_m3_m4(originmat, tmat); // origin, voor help line - if ((ob->partype & PARTYPE)==PARSKEL ) { + if ((ob->partype & PARTYPE) == PARSKEL) { copy_v3_v3(ob->orig, par->obmat[3]); } else { @@ -2109,13 +2089,13 @@ static void solve_parenting (Scene *scene, Object *ob, Object *par, float obmat[ } -void where_is_object(struct Scene *scene, Object *ob) +void BKE_object_where_is_calc(struct Scene *scene, Object *ob) { - where_is_object_time(scene, ob, (float)scene->r.cfra); + BKE_object_where_is_calc_time(scene, ob, (float)scene->r.cfra); } -void where_is_object_simul(Scene *scene, Object *ob) +void BKE_object_where_is_calc_simul(Scene *scene, Object *ob) /* was written for the old game engine (until 2.04) */ /* It seems that this function is only called * for a lamp that is the child of another object */ @@ -2128,114 +2108,114 @@ void where_is_object_simul(Scene *scene, Object *ob) /* NO TIMEOFFS */ if (ob->parent) { - par= ob->parent; + par = ob->parent; solve_parenting(scene, ob, par, ob->obmat, slowmat, 1); if (ob->partype & PARSLOW) { - fac1= (float)(1.0/(1.0+ fabs(ob->sf))); - fac2= 1.0f-fac1; - fp1= ob->obmat[0]; - fp2= slowmat[0]; - for (a=0; a<16; a++, fp1++, fp2++) { - fp1[0]= fac1*fp1[0] + fac2*fp2[0]; + fac1 = (float)(1.0 / (1.0 + fabs(ob->sf))); + fac2 = 1.0f - fac1; + fp1 = ob->obmat[0]; + fp2 = slowmat[0]; + for (a = 0; a < 16; a++, fp1++, fp2++) { + fp1[0] = fac1 * fp1[0] + fac2 * fp2[0]; } } } else { - object_to_mat4(ob, ob->obmat); + BKE_object_to_mat4(ob, ob->obmat); } /* solve constraints */ if (ob->constraints.first) { bConstraintOb *cob; - cob= constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); + cob = constraints_make_evalob(scene, ob, NULL, CONSTRAINT_OBTYPE_OBJECT); solve_constraints(&ob->constraints, cob, (float)scene->r.cfra); constraints_clear_evalob(cob); } } /* for calculation of the inverse parent transform, only used for editor */ -void what_does_parent(Scene *scene, Object *ob, Object *workob) +void BKE_object_workob_calc_parent(Scene *scene, Object *ob, Object *workob) { - clear_workob(workob); + BKE_object_workob_clear(workob); unit_m4(workob->obmat); unit_m4(workob->parentinv); unit_m4(workob->constinv); - workob->parent= ob->parent; + workob->parent = ob->parent; - workob->trackflag= ob->trackflag; - workob->upflag= ob->upflag; + workob->trackflag = ob->trackflag; + workob->upflag = ob->upflag; - workob->partype= ob->partype; - workob->par1= ob->par1; - workob->par2= ob->par2; - workob->par3= ob->par3; + workob->partype = ob->partype; + workob->par1 = ob->par1; + workob->par2 = ob->par2; + workob->par3 = ob->par3; workob->constraints.first = ob->constraints.first; workob->constraints.last = ob->constraints.last; BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); - where_is_object(scene, workob); + BKE_object_where_is_calc(scene, workob); } -BoundBox *unit_boundbox(void) +BoundBox *BKE_boundbox_alloc_unit(void) { BoundBox *bb; float min[3] = {-1.0f, -1.0f, -1.0f}, max[3] = {-1.0f, -1.0f, -1.0f}; - bb= MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); - boundbox_set_from_min_max(bb, min, max); + bb = MEM_callocN(sizeof(BoundBox), "OB-BoundBox"); + BKE_boundbox_init_from_minmax(bb, min, max); return bb; } -void boundbox_set_from_min_max(BoundBox *bb, float min[3], float max[3]) +void BKE_boundbox_init_from_minmax(BoundBox *bb, float min[3], float max[3]) { - bb->vec[0][0]=bb->vec[1][0]=bb->vec[2][0]=bb->vec[3][0]= min[0]; - bb->vec[4][0]=bb->vec[5][0]=bb->vec[6][0]=bb->vec[7][0]= max[0]; + bb->vec[0][0] = bb->vec[1][0] = bb->vec[2][0] = bb->vec[3][0] = min[0]; + bb->vec[4][0] = bb->vec[5][0] = bb->vec[6][0] = bb->vec[7][0] = max[0]; - bb->vec[0][1]=bb->vec[1][1]=bb->vec[4][1]=bb->vec[5][1]= min[1]; - bb->vec[2][1]=bb->vec[3][1]=bb->vec[6][1]=bb->vec[7][1]= max[1]; + bb->vec[0][1] = bb->vec[1][1] = bb->vec[4][1] = bb->vec[5][1] = min[1]; + bb->vec[2][1] = bb->vec[3][1] = bb->vec[6][1] = bb->vec[7][1] = max[1]; - bb->vec[0][2]=bb->vec[3][2]=bb->vec[4][2]=bb->vec[7][2]= min[2]; - bb->vec[1][2]=bb->vec[2][2]=bb->vec[5][2]=bb->vec[6][2]= max[2]; + bb->vec[0][2] = bb->vec[3][2] = bb->vec[4][2] = bb->vec[7][2] = min[2]; + bb->vec[1][2] = bb->vec[2][2] = bb->vec[5][2] = bb->vec[6][2] = max[2]; } -BoundBox *object_get_boundbox(Object *ob) +BoundBox *BKE_object_boundbox_get(Object *ob) { - BoundBox *bb= NULL; + BoundBox *bb = NULL; - if (ob->type==OB_MESH) { - bb = mesh_get_bb(ob); + if (ob->type == OB_MESH) { + bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - bb= ob->bb ? ob->bb : ((Curve *)ob->data )->bb; + bb = ob->bb ? ob->bb : ((Curve *)ob->data)->bb; } - else if (ob->type==OB_MBALL) { - bb= ob->bb; + else if (ob->type == OB_MBALL) { + bb = ob->bb; } return bb; } /* used to temporally disable/enable boundbox */ -void object_boundbox_flag(Object *ob, int flag, int set) +void BKE_object_boundbox_flag(Object *ob, int flag, int set) { - BoundBox *bb= object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { if (set) bb->flag |= flag; else bb->flag &= ~flag; } } -void object_get_dimensions(Object *ob, float vec[3]) +void BKE_object_dimensions_get(Object *ob, float vec[3]) { BoundBox *bb = NULL; - bb= object_get_boundbox(ob); + bb = BKE_object_boundbox_get(ob); if (bb) { float scale[3]; @@ -2250,11 +2230,11 @@ void object_get_dimensions(Object *ob, float vec[3]) } } -void object_set_dimensions(Object *ob, const float *value) +void BKE_object_dimensions_set(Object *ob, const float *value) { BoundBox *bb = NULL; - bb= object_get_boundbox(ob); + bb = BKE_object_boundbox_get(ob); if (bb) { float scale[3], len[3]; @@ -2270,117 +2250,117 @@ void object_set_dimensions(Object *ob, const float *value) } } -void minmax_object(Object *ob, float min[3], float max[3]) +void BKE_object_minmax(Object *ob, float min_r[3], float max_r[3]) { BoundBox bb; float vec[3]; int a; - short change= FALSE; + short change = FALSE; switch (ob->type) { - case OB_CURVE: - case OB_FONT: - case OB_SURF: + case OB_CURVE: + case OB_FONT: + case OB_SURF: { - Curve *cu= ob->data; + Curve *cu = ob->data; - if (cu->bb==NULL) BKE_curve_tex_space_calc(cu); - bb= *(cu->bb); + if (cu->bb == NULL) BKE_curve_texspace_calc(cu); + bb = *(cu->bb); - for (a=0; a<8; a++) { + for (a = 0; a < 8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); - DO_MINMAX(bb.vec[a], min, max); + DO_MINMAX(bb.vec[a], min_r, max_r); } - change= TRUE; + change = TRUE; } break; - case OB_LATTICE: + case OB_LATTICE: { - Lattice *lt= ob->data; - BPoint *bp= lt->def; + Lattice *lt = ob->data; + BPoint *bp = lt->def; int u, v, w; - for (w=0; wpntsw; w++) { - for (v=0; vpntsv; v++) { - for (u=0; upntsu; u++, bp++) { + for (w = 0; w < lt->pntsw; w++) { + for (v = 0; v < lt->pntsv; v++) { + for (u = 0; u < lt->pntsu; u++, bp++) { mul_v3_m4v3(vec, ob->obmat, bp->vec); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); } } } - change= TRUE; + change = TRUE; } break; - case OB_ARMATURE: - if (ob->pose) { - bPoseChannel *pchan; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); - DO_MINMAX(vec, min, max); - mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); - DO_MINMAX(vec, min, max); + case OB_ARMATURE: + if (ob->pose) { + bPoseChannel *pchan; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + mul_v3_m4v3(vec, ob->obmat, pchan->pose_head); + DO_MINMAX(vec, min_r, max_r); + mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); + DO_MINMAX(vec, min_r, max_r); + } + change = TRUE; } - change= TRUE; - } - break; - case OB_MESH: + break; + case OB_MESH: { - Mesh *me= get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (me) { - bb = *mesh_get_bb(ob); + bb = *BKE_mesh_boundbox_get(ob); - for (a=0; a<8; a++) { + for (a = 0; a < 8; a++) { mul_m4_v3(ob->obmat, bb.vec[a]); - DO_MINMAX(bb.vec[a], min, max); + DO_MINMAX(bb.vec[a], min_r, max_r); } - change= TRUE; + change = TRUE; } } break; } if (change == FALSE) { - DO_MINMAX(ob->obmat[3], min, max); + DO_MINMAX(ob->obmat[3], min_r, max_r); copy_v3_v3(vec, ob->obmat[3]); add_v3_v3(vec, ob->size); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); copy_v3_v3(vec, ob->obmat[3]); sub_v3_v3(vec, ob->size); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, min_r, max_r); } } -int minmax_object_duplis(Scene *scene, Object *ob, float min[3], float max[3]) +int BKE_object_minmax_dupli(Scene *scene, Object *ob, float r_min[3], float r_max[3]) { - int ok= 0; - if ((ob->transflag & OB_DUPLI)==0) { + int ok = 0; + if ((ob->transflag & OB_DUPLI) == 0) { return ok; } else { ListBase *lb; DupliObject *dob; - lb= object_duplilist(scene, ob); - for (dob= lb->first; dob; dob= dob->next) { + lb = object_duplilist(scene, ob); + for (dob = lb->first; dob; dob = dob->next) { if (dob->no_draw == 0) { - BoundBox *bb= object_get_boundbox(dob->ob); + BoundBox *bb = BKE_object_boundbox_get(dob->ob); if (bb) { int i; - for (i=0; i<8; i++) { + for (i = 0; i < 8; i++) { float vec[3]; mul_v3_m4v3(vec, dob->mat, bb->vec[i]); - DO_MINMAX(vec, min, max); + DO_MINMAX(vec, r_min, r_max); } - ok= 1; + ok = 1; } } } - free_object_duplilist(lb); /* does restore */ + free_object_duplilist(lb); /* does restore */ } return ok; @@ -2393,12 +2373,12 @@ void BKE_object_foreach_display_point( float co[3]; if (ob->derivedFinal) { - DerivedMesh *dm= ob->derivedFinal; - MVert *mv= dm->getVertArray(dm); - int totvert= dm->getNumVerts(dm); + DerivedMesh *dm = ob->derivedFinal; + MVert *mv = dm->getVertArray(dm); + int totvert = dm->getNumVerts(dm); int i; - for (i= 0; i < totvert; i++, mv++) { + for (i = 0; i < totvert; i++, mv++) { mul_v3_m4v3(co, obmat, mv->co); func_cb(co, user_data); } @@ -2406,12 +2386,12 @@ void BKE_object_foreach_display_point( else if (ob->disp.first) { DispList *dl; - for (dl=ob->disp.first; dl; dl=dl->next) { - float *v3= dl->verts; - int totvert= dl->nr; + for (dl = ob->disp.first; dl; dl = dl->next) { + float *v3 = dl->verts; + int totvert = dl->nr; int i; - for (i= 0; i < totvert; i++, v3+=3) { + for (i = 0; i < totvert; i++, v3 += 3) { mul_v3_m4v3(co, obmat, v3); func_cb(co, user_data); } @@ -2426,24 +2406,24 @@ void BKE_scene_foreach_display_point( Base *base; Object *ob; - for (base= FIRSTBASE; base; base = base->next) { + for (base = FIRSTBASE; base; base = base->next) { if (BASE_VISIBLE(v3d, base) && (base->flag & flag) == flag) { - ob= base->object; + ob = base->object; - if ((ob->transflag & OB_DUPLI)==0) { + if ((ob->transflag & OB_DUPLI) == 0) { BKE_object_foreach_display_point(ob, ob->obmat, func_cb, user_data); } else { ListBase *lb; DupliObject *dob; - lb= object_duplilist(scene, ob); - for (dob= lb->first; dob; dob= dob->next) { + lb = object_duplilist(scene, ob); + for (dob = lb->first; dob; dob = dob->next) { if (dob->no_draw == 0) { BKE_object_foreach_display_point(dob->ob, dob->mat, func_cb, user_data); } } - free_object_duplilist(lb); /* does restore */ + free_object_duplilist(lb); /* does restore */ } } } @@ -2452,20 +2432,20 @@ void BKE_scene_foreach_display_point( /* copied from DNA_object_types.h */ typedef struct ObTfmBack { float loc[3], dloc[3], orig[3]; - float size[3], dscale[3]; /* scale and delta scale */ - float rot[3], drot[3]; /* euler rotation */ - float quat[4], dquat[4]; /* quaternion rotation */ - float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ - float rotAngle, drotAngle; /* axis angle rotation - angle part */ - float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ + float size[3], dscale[3]; /* scale and delta scale */ + float rot[3], drot[3]; /* euler rotation */ + float quat[4], dquat[4]; /* quaternion rotation */ + float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */ + float rotAngle, drotAngle; /* axis angle rotation - angle part */ + float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */ float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ - float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ + float imat[4][4]; /* inverse matrix of 'obmat' for during render, old game engine, temporally: ipokeys of transform */ } ObTfmBack; -void *object_tfm_backup(Object *ob) +void *BKE_object_tfm_backup(Object *ob) { - ObTfmBack *obtfm= MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack"); + ObTfmBack *obtfm = MEM_mallocN(sizeof(ObTfmBack), "ObTfmBack"); copy_v3_v3(obtfm->loc, ob->loc); copy_v3_v3(obtfm->dloc, ob->dloc); copy_v3_v3(obtfm->orig, ob->orig); @@ -2477,8 +2457,8 @@ void *object_tfm_backup(Object *ob) copy_qt_qt(obtfm->dquat, ob->dquat); copy_v3_v3(obtfm->rotAxis, ob->rotAxis); copy_v3_v3(obtfm->drotAxis, ob->drotAxis); - obtfm->rotAngle= ob->rotAngle; - obtfm->drotAngle= ob->drotAngle; + obtfm->rotAngle = ob->rotAngle; + obtfm->drotAngle = ob->drotAngle; copy_m4_m4(obtfm->obmat, ob->obmat); copy_m4_m4(obtfm->parentinv, ob->parentinv); copy_m4_m4(obtfm->constinv, ob->constinv); @@ -2487,9 +2467,9 @@ void *object_tfm_backup(Object *ob) return (void *)obtfm; } -void object_tfm_restore(Object *ob, void *obtfm_pt) +void BKE_object_tfm_restore(Object *ob, void *obtfm_pt) { - ObTfmBack *obtfm= (ObTfmBack *)obtfm_pt; + ObTfmBack *obtfm = (ObTfmBack *)obtfm_pt; copy_v3_v3(ob->loc, obtfm->loc); copy_v3_v3(ob->dloc, obtfm->dloc); copy_v3_v3(ob->orig, obtfm->orig); @@ -2501,8 +2481,8 @@ void object_tfm_restore(Object *ob, void *obtfm_pt) copy_qt_qt(ob->dquat, obtfm->dquat); copy_v3_v3(ob->rotAxis, obtfm->rotAxis); copy_v3_v3(ob->drotAxis, obtfm->drotAxis); - ob->rotAngle= obtfm->rotAngle; - ob->drotAngle= obtfm->drotAngle; + ob->rotAngle = obtfm->rotAngle; + ob->drotAngle = obtfm->drotAngle; copy_m4_m4(ob->obmat, obtfm->obmat); copy_m4_m4(ob->parentinv, obtfm->parentinv); copy_m4_m4(ob->constinv, obtfm->constinv); @@ -2524,37 +2504,37 @@ int BKE_object_parent_loop_check(const Object *par, const Object *ob) /* the main object update call, for object matrix, constraints, keys and displist (modifiers) */ /* requires flags to be set! */ -void object_handle_update(Scene *scene, Object *ob) +void BKE_object_handle_update(Scene *scene, Object *ob) { if (ob->recalc & OB_RECALC_ALL) { /* speed optimization for animation lookups */ if (ob->pose) - make_pose_channels_hash(ob->pose); + BKE_pose_channels_hash_make(ob->pose); if (ob->recalc & OB_RECALC_DATA) { - if (ob->type==OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { /* this happens for reading old files and to match library armatures - * with poses we do it ahead of where_is_object to ensure animation + * with poses we do it ahead of BKE_object_where_is_calc to ensure animation * is evaluated on the rebuilt pose, otherwise we get incorrect poses * on file load */ - if (ob->pose==NULL || (ob->pose->flag & POSE_RECALC)) - armature_rebuild_pose(ob, ob->data); + if (ob->pose == NULL || (ob->pose->flag & POSE_RECALC)) + BKE_pose_rebuild(ob, ob->data); } } /* XXX new animsys warning: depsgraph tag OB_RECALC_DATA should not skip drivers, - * which is only in where_is_object now */ + * which is only in BKE_object_where_is_calc now */ // XXX: should this case be OB_RECALC_OB instead? if (ob->recalc & OB_RECALC_ALL) { if (G.debug & G_DEBUG) - printf("recalcob %s\n", ob->id.name+2); + printf("recalcob %s\n", ob->id.name + 2); /* handle proxy copy for target */ if (ob->id.lib && ob->proxy_from) { // printf("ob proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); - if (ob->proxy_from->proxy_group) {/* transform proxy into group space */ - Object *obg= ob->proxy_from->proxy_group; + if (ob->proxy_from->proxy_group) { /* transform proxy into group space */ + Object *obg = ob->proxy_from->proxy_group; invert_m4_m4(obg->imat, obg->obmat); mult_m4_m4m4(ob->obmat, obg->imat, ob->proxy_from->obmat); if (obg->dup_group) { /* should always be true */ @@ -2565,18 +2545,18 @@ void object_handle_update(Scene *scene, Object *ob) copy_m4_m4(ob->obmat, ob->proxy_from->obmat); } else - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); } if (ob->recalc & OB_RECALC_DATA) { - ID *data_id= (ID *)ob->data; - AnimData *adt= BKE_animdata_from_id(data_id); - float ctime= (float)scene->r.cfra; // XXX this is bad... + ID *data_id = (ID *)ob->data; + AnimData *adt = BKE_animdata_from_id(data_id); + float ctime = (float)scene->r.cfra; // XXX this is bad... ListBase pidlist; PTCacheID *pid; if (G.debug & G_DEBUG) - printf("recalcdata %s\n", ob->id.name+2); + printf("recalcdata %s\n", ob->id.name + 2); if (adt) { /* evaluate drivers */ @@ -2586,9 +2566,9 @@ void object_handle_update(Scene *scene, Object *ob) /* includes all keys and modifiers */ switch (ob->type) { - case OB_MESH: + case OB_MESH: { -#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' +#if 0 // XXX, comment for 2.56a release, background wont set 'scene->customdata_mask' BMEditMesh *em = (ob == scene->obedit) ? BMEdit_FromObject(ob) : NULL; BLI_assert((scene->customdata_mask & CD_MASK_BAREMESH) == CD_MASK_BAREMESH); if (em) { @@ -2598,9 +2578,9 @@ void object_handle_update(Scene *scene, Object *ob) makeDerivedMesh(scene, ob, NULL, scene->customdata_mask, 0); } -#else /* ensure CD_MASK_BAREMESH for now */ +#else /* ensure CD_MASK_BAREMESH for now */ BMEditMesh *em = (ob == scene->obedit) ? BMEdit_FromObject(ob) : NULL; - uint64_t data_mask= scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; + uint64_t data_mask = scene->customdata_mask | ob->customdata_mask | CD_MASK_BAREMESH; if (em) { makeDerivedMesh(scene, ob, em, data_mask, 0); /* was CD_MASK_BAREMESH */ } @@ -2612,29 +2592,29 @@ void object_handle_update(Scene *scene, Object *ob) } break; - case OB_ARMATURE: - if (ob->id.lib && ob->proxy_from) { - // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); - copy_pose_result(ob->pose, ob->proxy_from->pose); - } - else { - where_is_pose(scene, ob); - } - break; + case OB_ARMATURE: + if (ob->id.lib && ob->proxy_from) { + // printf("pose proxy copy, lib ob %s proxy %s\n", ob->id.name, ob->proxy_from->id.name); + BKE_pose_copy_result(ob->pose, ob->proxy_from->pose); + } + else { + BKE_pose_where_is(scene, ob); + } + break; - case OB_MBALL: - makeDispListMBall(scene, ob); - break; + case OB_MBALL: + BKE_displist_make_mball(scene, ob); + break; - case OB_CURVE: - case OB_SURF: - case OB_FONT: - makeDispListCurveTypes(scene, ob, 0); - break; + case OB_CURVE: + case OB_SURF: + case OB_FONT: + BKE_displist_make_curveTypes(scene, ob, 0); + break; - case OB_LATTICE: - lattice_calc_modifiers(scene, ob); - break; + case OB_LATTICE: + BKE_lattice_modifiers_calc(scene, ob); + break; } @@ -2643,7 +2623,7 @@ void object_handle_update(Scene *scene, Object *ob) DerivedMesh *dm; ob->transflag &= ~OB_DUPLIPARTS; - psys= ob->particlesystem.first; + psys = ob->particlesystem.first; while (psys) { if (psys_check_enabled(ob, psys)) { /* check use of dupli objects here */ @@ -2655,26 +2635,26 @@ void object_handle_update(Scene *scene, Object *ob) } particle_system_update(scene, ob, psys); - psys= psys->next; + psys = psys->next; } else if (psys->flag & PSYS_DELETE) { - tpsys=psys->next; + tpsys = psys->next; BLI_remlink(&ob->particlesystem, psys); psys_free(ob, psys); - psys= tpsys; + psys = tpsys; } else - psys= psys->next; + psys = psys->next; } if (G.rendering && ob->transflag & OB_DUPLIPARTS) { /* this is to make sure we get render level duplis in groups: * the derivedmesh must be created before init_render_mesh, * since object_duplilist does dupliparticles before that */ - dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH|CD_MASK_MTFACE|CD_MASK_MCOL); + dm = mesh_create_derived_render(scene, ob, CD_MASK_BAREMESH | CD_MASK_MTFACE | CD_MASK_MCOL); dm->release(dm); - for (psys=ob->particlesystem.first; psys; psys=psys->next) + for (psys = ob->particlesystem.first; psys; psys = psys->next) psys_get_modifier(ob, psys)->flag &= ~eParticleSystemFlag_psys_updated; } } @@ -2682,18 +2662,18 @@ void object_handle_update(Scene *scene, Object *ob) /* check if quick cache is needed */ BKE_ptcache_ids_from_object(&pidlist, ob, scene, MAX_DUPLI_RECUR); - for (pid=pidlist.first; pid; pid=pid->next) { + for (pid = pidlist.first; pid; pid = pid->next) { if ((pid->cache->flag & PTCACHE_BAKED) || (pid->cache->flag & PTCACHE_QUICK_CACHE) == 0) { continue; } - if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID)==0) { + if (pid->cache->flag & PTCACHE_OUTDATED || (pid->cache->flag & PTCACHE_SIMULATION_VALID) == 0) { scene->physics_settings.quick_cache_step = - scene->physics_settings.quick_cache_step ? - MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) : - pid->cache->step; + scene->physics_settings.quick_cache_step ? + MIN2(scene->physics_settings.quick_cache_step, pid->cache->step) : + pid->cache->step; } } @@ -2701,11 +2681,11 @@ void object_handle_update(Scene *scene, Object *ob) } /* the no-group proxy case, we call update */ - if (ob->proxy && ob->proxy_group==NULL) { + if (ob->proxy && ob->proxy_group == NULL) { /* set pointer in library proxy target, for copying, but restore it */ - ob->proxy->proxy_from= ob; + ob->proxy->proxy_from = ob; // printf("call update, lib ob %s proxy %s\n", ob->proxy->id.name, ob->id.name); - object_handle_update(scene, ob->proxy); + BKE_object_handle_update(scene, ob->proxy); } ob->recalc &= ~OB_RECALC_ALL; @@ -2713,22 +2693,22 @@ void object_handle_update(Scene *scene, Object *ob) /* the case when this is a group proxy, object_update is called in group.c */ if (ob->proxy) { - ob->proxy->proxy_from= ob; + ob->proxy->proxy_from = ob; // printf("set proxy pointer for later group stuff %s\n", ob->id.name); } } -void object_sculpt_modifiers_changed(Object *ob) +void BKE_object_sculpt_modifiers_changed(Object *ob) { - SculptSession *ss= ob->sculpt; + SculptSession *ss = ob->sculpt; if (!ss->cache) { /* we free pbvh on changes, except during sculpt since it can't deal with * changing PVBH node organization, we hope topology does not change in * the meantime .. weak */ if (ss->pbvh) { - BLI_pbvh_free(ss->pbvh); - ss->pbvh= NULL; + BLI_pbvh_free(ss->pbvh); + ss->pbvh = NULL; } free_sculptsession_deformMats(ob->sculpt); @@ -2746,42 +2726,42 @@ void object_sculpt_modifiers_changed(Object *ob) } } -int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, float **rot) +int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc, float **r_size, float **r_rot) { - if (ob->data==NULL) + if (ob->data == NULL) return 0; switch (GS(((ID *)ob->data)->name)) { - case ID_ME: - { - Mesh *me= ob->data; - if (texflag) *texflag = &me->texflag; - if (loc) *loc = me->loc; - if (size) *size = me->size; - if (rot) *rot = me->rot; - break; - } - case ID_CU: - { - Curve *cu= ob->data; - if (texflag) *texflag = &cu->texflag; - if (loc) *loc = cu->loc; - if (size) *size = cu->size; - if (rot) *rot = cu->rot; - break; - } - case ID_MB: - { - MetaBall *mb= ob->data; - if (texflag) *texflag = &mb->texflag; - if (loc) *loc = mb->loc; - if (size) *size = mb->size; - if (rot) *rot = mb->rot; - break; - } - default: - return 0; + case ID_ME: + { + Mesh *me = ob->data; + if (r_texflag) *r_texflag = &me->texflag; + if (r_loc) *r_loc = me->loc; + if (r_size) *r_size = me->size; + if (r_rot) *r_rot = me->rot; + break; + } + case ID_CU: + { + Curve *cu = ob->data; + if (r_texflag) *r_texflag = &cu->texflag; + if (r_loc) *r_loc = cu->loc; + if (r_size) *r_size = cu->size; + if (r_rot) *r_rot = cu->rot; + break; + } + case ID_MB: + { + MetaBall *mb = ob->data; + if (r_texflag) *r_texflag = &mb->texflag; + if (r_loc) *r_loc = mb->loc; + if (r_size) *r_size = mb->size; + if (r_rot) *r_rot = mb->rot; + break; + } + default: + return 0; } return 1; } @@ -2790,7 +2770,7 @@ int give_obdata_texspace(Object *ob, short **texflag, float **loc, float **size, * Test a bounding box for ray intersection * assumes the ray is already local to the boundbox space */ -int ray_hit_boundbox(struct BoundBox *bb, float ray_start[3], float ray_normal[3]) +int BKE_boundbox_ray_hit_check(struct BoundBox *bb, float ray_start[3], float ray_normal[3]) { static int triangle_indexes[12][3] = {{0, 1, 2}, {0, 2, 3}, {3, 2, 6}, {3, 6, 7}, @@ -2821,14 +2801,14 @@ static int pc_cmp(void *a, void *b) else return 0; } -int object_insert_ptcache(Object *ob) +int BKE_object_insert_ptcache(Object *ob) { LinkData *link = NULL; int i = 0; BLI_sortlist(&ob->pc_ids, pc_cmp); - for (link=ob->pc_ids.first, i = 0; link; link=link->next, i++) { + for (link = ob->pc_ids.first, i = 0; link; link = link->next, i++) { int index = GET_INT_FROM_POINTER(link->data); if (i < index) @@ -2845,18 +2825,18 @@ int object_insert_ptcache(Object *ob) #if 0 static int pc_findindex(ListBase *listbase, int index) { - LinkData *link= NULL; - int number= 0; + LinkData *link = NULL; + int number = 0; if (listbase == NULL) return -1; - link= listbase->first; + link = listbase->first; while (link) { if ((int)link->data == index) return number; number++; - link= link->next; + link = link->next; } return -1; @@ -2875,30 +2855,30 @@ void object_delete_ptcache(Object *ob, int index) /************************* Mesh ************************/ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int from_mix) { - Mesh *me= ob->data; - Key *key= me->key; + Mesh *me = ob->data; + Key *key = me->key; KeyBlock *kb; - int newkey= 0; + int newkey = 0; if (key == NULL) { - key= me->key= add_key((ID *)me); - key->type= KEY_RELATIVE; - newkey= 1; + key = me->key = add_key((ID *)me); + key->type = KEY_RELATIVE; + newkey = 1; } - if (newkey || from_mix==FALSE) { + if (newkey || from_mix == FALSE) { /* create from mesh */ kb = add_keyblock_ctime(key, name, FALSE); mesh_to_key(me, kb); } else { /* copy from current values */ - float *data= do_ob_key(scene, ob); + float *data = do_ob_key(scene, ob); /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->data= data; - kb->totelem= me->totvert; + kb->data = data; + kb->totelem = me->totvert; } return kb; @@ -2906,23 +2886,23 @@ static KeyBlock *insert_meshkey(Scene *scene, Object *ob, const char *name, int /************************* Lattice ************************/ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int from_mix) { - Lattice *lt= ob->data; - Key *key= lt->key; + Lattice *lt = ob->data; + Key *key = lt->key; KeyBlock *kb; - int newkey= 0; + int newkey = 0; - if (key==NULL) { - key= lt->key= add_key((ID *)lt); - key->type= KEY_RELATIVE; - newkey= 1; + if (key == NULL) { + key = lt->key = add_key((ID *)lt); + key->type = KEY_RELATIVE; + newkey = 1; } - if (newkey || from_mix==FALSE) { + if (newkey || from_mix == FALSE) { kb = add_keyblock_ctime(key, name, FALSE); if (!newkey) { - KeyBlock *basekb= (KeyBlock *)key->block.first; - kb->data= MEM_dupallocN(basekb->data); - kb->totelem= basekb->totelem; + KeyBlock *basekb = (KeyBlock *)key->block.first; + kb->data = MEM_dupallocN(basekb->data); + kb->totelem = basekb->totelem; } else { latt_to_key(lt, kb); @@ -2930,12 +2910,12 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int } else { /* copy from current values */ - float *data= do_ob_key(scene, ob); + float *data = do_ob_key(scene, ob); /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->totelem= lt->pntsu*lt->pntsv*lt->pntsw; - kb->data= data; + kb->totelem = lt->pntsu * lt->pntsv * lt->pntsw; + kb->data = data; } return kb; @@ -2943,25 +2923,25 @@ static KeyBlock *insert_lattkey(Scene *scene, Object *ob, const char *name, int /************************* Curve ************************/ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int from_mix) { - Curve *cu= ob->data; - Key *key= cu->key; + Curve *cu = ob->data; + Key *key = cu->key; KeyBlock *kb; - ListBase *lb= BKE_curve_nurbs_get(cu); - int newkey= 0; + ListBase *lb = BKE_curve_nurbs_get(cu); + int newkey = 0; - if (key==NULL) { - key= cu->key= add_key((ID *)cu); + if (key == NULL) { + key = cu->key = add_key((ID *)cu); key->type = KEY_RELATIVE; - newkey= 1; + newkey = 1; } - if (newkey || from_mix==FALSE) { + if (newkey || from_mix == FALSE) { /* create from curve */ kb = add_keyblock_ctime(key, name, FALSE); if (!newkey) { - KeyBlock *basekb= (KeyBlock *)key->block.first; - kb->data= MEM_dupallocN(basekb->data); - kb->totelem= basekb->totelem; + KeyBlock *basekb = (KeyBlock *)key->block.first; + kb->data = MEM_dupallocN(basekb->data); + kb->totelem = basekb->totelem; } else { curve_to_key(cu, kb, lb); @@ -2969,18 +2949,18 @@ static KeyBlock *insert_curvekey(Scene *scene, Object *ob, const char *name, int } else { /* copy from current values */ - float *data= do_ob_key(scene, ob); + float *data = do_ob_key(scene, ob); /* create new block with prepared data */ kb = add_keyblock_ctime(key, name, FALSE); - kb->totelem= BKE_nurbList_verts_count(lb); - kb->data= data; + kb->totelem = BKE_nurbList_verts_count(lb); + kb->data = data; } return kb; } -KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix) +KeyBlock *BKE_object_insert_shape_key(Scene *scene, Object *ob, const char *name, int from_mix) { switch (ob->type) { case OB_MESH: @@ -2998,9 +2978,9 @@ KeyBlock *object_insert_shape_key(Scene *scene, Object *ob, const char *name, in /* most important if this is modified it should _always_ return True, in certain * cases false positives are hard to avoid (shape keys for example) */ -int object_is_modified(Scene *scene, Object *ob) +int BKE_object_is_modified(Scene *scene, Object *ob) { - int flag= 0; + int flag = 0; if (ob_get_key(ob)) { flag |= eModifierMode_Render; @@ -3008,9 +2988,9 @@ int object_is_modified(Scene *scene, Object *ob) else { ModifierData *md; /* cloth */ - for (md=modifiers_getVirtualModifierList(ob); + for (md = modifiers_getVirtualModifierList(ob); md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); - md=md->next) + md = md->next) { if ((flag & eModifierMode_Render) == 0 && modifier_isEnabled(scene, md, eModifierMode_Render)) flag |= eModifierMode_Render; @@ -3026,15 +3006,15 @@ int object_is_modified(Scene *scene, Object *ob) /* test if object is affected by deforming modifiers (for motion blur). again * most important is to avoid false positives, this is to skip computations * and we can still if there was actual deformation afterwards */ -int object_is_deform_modified(Scene *scene, Object *ob) +int BKE_object_is_deform_modified(Scene *scene, Object *ob) { ModifierData *md; - int flag= 0; + int flag = 0; /* cloth */ - for (md=modifiers_getVirtualModifierList(ob); - md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); - md=md->next) + for (md = modifiers_getVirtualModifierList(ob); + md && (flag != (eModifierMode_Render | eModifierMode_Realtime)); + md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); @@ -3056,7 +3036,7 @@ static void copy_object__forwardModifierLinks(void *UNUSED(userData), Object *UN if (*idpoin && (*idpoin)->newid) *idpoin = (*idpoin)->newid; } -void object_relink(Object *ob) +void BKE_object_relink(Object *ob) { if (ob->id.lib) return; @@ -3064,7 +3044,7 @@ void object_relink(Object *ob) relink_constraints(&ob->constraints); if (ob->pose) { bPoseChannel *chan; - for (chan = ob->pose->chanbase.first; chan; chan=chan->next) { + for (chan = ob->pose->chanbase.first; chan; chan = chan->next) { relink_constraints(&chan->constraints); } } @@ -3079,26 +3059,26 @@ void object_relink(Object *ob) ID_NEW(ob->proxy_group); } -MovieClip *object_get_movieclip(Scene *scene, Object *ob, int use_default) +MovieClip *BKE_object_movieclip_get(Scene *scene, Object *ob, int use_default) { - MovieClip *clip= use_default ? scene->clip : NULL; - bConstraint *con= ob->constraints.first, *scon= NULL; + MovieClip *clip = use_default ? scene->clip : NULL; + bConstraint *con = ob->constraints.first, *scon = NULL; while (con) { - if (con->type==CONSTRAINT_TYPE_CAMERASOLVER) { - if (scon==NULL || (scon->flag&CONSTRAINT_OFF)) - scon= con; + if (con->type == CONSTRAINT_TYPE_CAMERASOLVER) { + if (scon == NULL || (scon->flag & CONSTRAINT_OFF)) + scon = con; } - con= con->next; + con = con->next; } if (scon) { - bCameraSolverConstraint *solver= scon->data; - if ((solver->flag&CAMERASOLVER_ACTIVECLIP)==0) - clip= solver->clip; + bCameraSolverConstraint *solver = scon->data; + if ((solver->flag & CAMERASOLVER_ACTIVECLIP) == 0) + clip = solver->clip; else - clip= scene->clip; + clip = scene->clip; } return clip; diff --git a/source/blender/blenkernel/intern/ocean.c b/source/blender/blenkernel/intern/ocean.c index 4ddcd6f4b51..6242976d323 100644 --- a/source/blender/blenkernel/intern/ocean.c +++ b/source/blender/blenkernel/intern/ocean.c @@ -1251,18 +1251,18 @@ void BKE_bake_ocean(struct Ocean *o, struct OceanCache *och, void (*update_cb)(v /* write the images */ cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_DISPLACE); - if (0 == BKE_write_ibuf(ibuf_disp, string, &imf)) + if (0 == BKE_imbuf_write(ibuf_disp, string, &imf)) printf("Cannot save Displacement File Output to %s\n", string); if (o->_do_jacobian) { cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_FOAM); - if (0 == BKE_write_ibuf(ibuf_foam, string, &imf)) + if (0 == BKE_imbuf_write(ibuf_foam, string, &imf)) printf("Cannot save Foam File Output to %s\n", string); } if (o->_do_normals) { cache_filename(string, och->bakepath, och->relbase, f, CACHE_TYPE_NORMAL); - if (0 == BKE_write_ibuf(ibuf_normal, string, &imf)) + if (0 == BKE_imbuf_write(ibuf_normal, string, &imf)) printf("Cannot save Normal File Output to %s\n", string); } diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 3b5b4b766fb..a2c89967f44 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -73,17 +73,17 @@ int seekPackedFile(PackedFile *pf, int offset, int whence) if (pf) { oldseek = pf->seek; switch (whence) { - case SEEK_CUR: - seek = oldseek + offset; - break; - case SEEK_END: - seek = pf->size + offset; - break; - case SEEK_SET: - seek = offset; - break; - default: - oldseek = -1; + case SEEK_CUR: + seek = oldseek + offset; + break; + case SEEK_END: + seek = pf->size + offset; + break; + case SEEK_SET: + seek = offset; + break; + default: + oldseek = -1; } if (seek < 0) { seek = 0; @@ -133,15 +133,15 @@ int countPackedFiles(Main *bmain) int count = 0; // let's check if there are packed files... - for (ima=bmain->image.first; ima; ima=ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) count++; - for (vf=bmain->vfont.first; vf; vf=vf->id.next) + for (vf = bmain->vfont.first; vf; vf = vf->id.next) if (vf->packedfile) count++; - for (sound=bmain->sound.first; sound; sound=sound->id.next) + for (sound = bmain->sound.first; sound; sound = sound->id.next) if (sound->packedfile) count++; @@ -176,7 +176,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char /* render result has no filename and can be ignored * any other files with no name can be ignored too */ - if (filename[0]=='\0') + if (filename[0] == '\0') return NULL; //XXX waitcursor(1); @@ -189,7 +189,7 @@ PackedFile *newPackedFile(ReportList *reports, const char *filename, const char // open the file // and create a PackedFile structure - file= BLI_open(name, O_BINARY|O_RDONLY, 0); + file = BLI_open(name, O_BINARY | O_RDONLY, 0); if (file <= 0) { BKE_reportf(reports, RPT_ERROR, "Unable to pack file, source path not found: \"%s\"", name); } @@ -222,23 +222,23 @@ void packAll(Main *bmain, ReportList *reports) VFont *vf; bSound *sound; - for (ima=bmain->image.first; ima; ima=ima->id.next) { - if (ima->packedfile == NULL && ima->id.lib==NULL) { - if (ima->source==IMA_SRC_FILE) { + for (ima = bmain->image.first; ima; ima = ima->id.next) { + if (ima->packedfile == NULL && ima->id.lib == NULL) { + if (ima->source == IMA_SRC_FILE) { ima->packedfile = newPackedFile(reports, ima->name, ID_BLEND_PATH(bmain, &ima->id)); } else if (ELEM(ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { - BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name+2); + BKE_reportf(reports, RPT_WARNING, "Image '%s' skipped, movies and image sequences not supported.", ima->id.name + 2); } } } - for (vf=bmain->vfont.first; vf; vf=vf->id.next) - if (vf->packedfile == NULL && vf->id.lib==NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) + for (vf = bmain->vfont.first; vf; vf = vf->id.next) + if (vf->packedfile == NULL && vf->id.lib == NULL && strcmp(vf->name, FO_BUILTIN_NAME) != 0) vf->packedfile = newPackedFile(reports, vf->name, bmain->name); - for (sound=bmain->sound.first; sound; sound=sound->id.next) - if (sound->packedfile == NULL && sound->id.lib==NULL) + for (sound = bmain->sound.first; sound; sound = sound->id.next) + if (sound->packedfile == NULL && sound->id.lib == NULL) sound->packedfile = newPackedFile(reports, sound->name, bmain->name); } @@ -257,12 +257,12 @@ static char *find_new_name(char *name) if (fop_exists(name)) { for (number = 1; number <= 999; number++) { BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number); - if (! fop_exists(tempname)) { + if (!fop_exists(tempname)) { break; } } } - len= strlen(tempname) + 1; + len = strlen(tempname) + 1; newname = MEM_mallocN(len, "find_new_name"); memcpy(newname, tempname, len * sizeof(char)); return newname; @@ -275,7 +275,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i int ret_value = RET_OK; char name[FILE_MAX]; char tempname[FILE_MAX]; -/* void *data; */ +/* void *data; */ if (guimode) {} //XXX waitcursor(1); @@ -285,7 +285,7 @@ int writePackedFile(ReportList *reports, const char *filename, PackedFile *pf, i if (BLI_exists(name)) { for (number = 1; number <= 999; number++) { BLI_snprintf(tempname, sizeof(tempname), "%s.%03d_", name, number); - if (! BLI_exists(tempname)) { + if (!BLI_exists(tempname)) { if (BLI_copy(name, tempname) == RET_OK) { remove_tmp = TRUE; } @@ -409,7 +409,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na case PF_KEEP: break; case PF_REMOVE: - temp= abs_name; + temp = abs_name; break; case PF_USE_LOCAL: // if file exists use it @@ -417,7 +417,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = local_name; break; } - // else fall through and create it + // else fall through and create it case PF_WRITE_LOCAL: if (writePackedFile(reports, local_name, pf, 1) == RET_OK) { temp = local_name; @@ -429,7 +429,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na temp = abs_name; break; } - // else fall through and create it + // else fall through and create it case PF_WRITE_ORIGINAL: if (writePackedFile(reports, abs_name, pf, 1) == RET_OK) { temp = abs_name; @@ -441,7 +441,7 @@ char *unpackFile(ReportList *reports, const char *abs_name, const char *local_na } if (temp) { - newname= BLI_strdup(temp); + newname = BLI_strdup(temp); } } @@ -533,15 +533,15 @@ void unpackAll(Main *bmain, ReportList *reports, int how) VFont *vf; bSound *sound; - for (ima=bmain->image.first; ima; ima=ima->id.next) + for (ima = bmain->image.first; ima; ima = ima->id.next) if (ima->packedfile) unpackImage(reports, ima, how); - for (vf=bmain->vfont.first; vf; vf=vf->id.next) + for (vf = bmain->vfont.first; vf; vf = vf->id.next) if (vf->packedfile) unpackVFont(reports, vf, how); - for (sound=bmain->sound.first; sound; sound=sound->id.next) + for (sound = bmain->sound.first; sound; sound = sound->id.next) if (sound->packedfile) unpackSound(bmain, reports, sound, how); } diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 08d8479fd93..c7f904755d9 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -60,19 +60,19 @@ Paint *paint_get_active(Scene *sce) if (sce->basact && sce->basact->object) { switch (sce->basact->object->mode) { - case OB_MODE_SCULPT: - return &ts->sculpt->paint; - case OB_MODE_VERTEX_PAINT: - return &ts->vpaint->paint; - case OB_MODE_WEIGHT_PAINT: - return &ts->wpaint->paint; - case OB_MODE_TEXTURE_PAINT: - return &ts->imapaint.paint; - case OB_MODE_EDIT: - if (ts->use_uv_sculpt) - return &ts->uvsculpt->paint; - else + case OB_MODE_SCULPT: + return &ts->sculpt->paint; + case OB_MODE_VERTEX_PAINT: + return &ts->vpaint->paint; + case OB_MODE_WEIGHT_PAINT: + return &ts->wpaint->paint; + case OB_MODE_TEXTURE_PAINT: return &ts->imapaint.paint; + case OB_MODE_EDIT: + if (ts->use_uv_sculpt) + return &ts->uvsculpt->paint; + else + return &ts->imapaint.paint; } } @@ -93,7 +93,7 @@ void paint_brush_set(Paint *p, Brush *br) if (p) { id_us_min((ID *)p->brush); id_us_plus((ID *)br); - p->brush= br; + p->brush = br; } } @@ -104,7 +104,7 @@ int paint_facesel_test(Object *ob) (ob->type == OB_MESH) && (ob->data != NULL) && (((Mesh *)ob->data)->editflag & ME_EDIT_PAINT_MASK) && - (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)) + (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT | OB_MODE_TEXTURE_PAINT)) ); } @@ -126,7 +126,7 @@ void paint_init(Paint *p, const char col[3]) /* If there's no brush, create one */ brush = paint_brush(p); if (brush == NULL) - brush= BKE_brush_add("Brush"); + brush = BKE_brush_add("Brush"); paint_brush_set(p, brush); memcpy(p->paint_cursor_col, col, 3); @@ -146,7 +146,7 @@ void free_paint(Paint *paint) * with paint_brush_set() */ void copy_paint(Paint *src, Paint *tar) { - tar->brush= src->brush; + tar->brush = src->brush; id_us_plus((ID *)tar->brush); } @@ -155,20 +155,29 @@ void copy_paint(Paint *src, Paint *tar) int paint_is_face_hidden(const MFace *f, const MVert *mvert) { return ((mvert[f->v1].flag & ME_HIDE) || - (mvert[f->v2].flag & ME_HIDE) || - (mvert[f->v3].flag & ME_HIDE) || - (f->v4 && (mvert[f->v4].flag & ME_HIDE))); + (mvert[f->v2].flag & ME_HIDE) || + (mvert[f->v3].flag & ME_HIDE) || + (f->v4 && (mvert[f->v4].flag & ME_HIDE))); } /* returns non-zero if any of the corners of the grid * face whose inner corner is at (x,y) are hidden, * zero otherwise */ int paint_is_grid_face_hidden(const unsigned int *grid_hidden, - int gridsize, int x, int y) + int gridsize, int x, int y) { /* skip face if any of its corners are hidden */ return (BLI_BITMAP_GET(grid_hidden, y * gridsize + x) || - BLI_BITMAP_GET(grid_hidden, y * gridsize + x+1) || - BLI_BITMAP_GET(grid_hidden, (y+1) * gridsize + x+1) || - BLI_BITMAP_GET(grid_hidden, (y+1) * gridsize + x)); + BLI_BITMAP_GET(grid_hidden, y * gridsize + x + 1) || + BLI_BITMAP_GET(grid_hidden, (y + 1) * gridsize + x + 1) || + BLI_BITMAP_GET(grid_hidden, (y + 1) * gridsize + x)); +} + +float paint_grid_paint_mask(const GridPaintMask *gpm, unsigned level, + unsigned x, unsigned y) +{ + int factor = ccg_factor(level, gpm->level); + int gridsize = ccg_gridsize(gpm->level); + + return gpm->data[(y * factor) * gridsize + (x * factor)]; } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 1a1ae8e949c..8676a3e75a0 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -84,35 +84,35 @@ #include "RE_render_ext.h" static void get_child_modifier_parameters(ParticleSettings *part, ParticleThreadContext *ctx, - ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex); + ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex); static void do_child_modifiers(ParticleSimulationData *sim, - ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, - float *orco, float mat[4][4], ParticleKey *state, float t); + ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, + float *orco, float mat[4][4], ParticleKey *state, float t); /* few helpers for countall etc. */ int count_particles(ParticleSystem *psys) { - ParticleSettings *part=psys->part; + ParticleSettings *part = psys->part; PARTICLE_P; - int tot=0; + int tot = 0; LOOP_SHOWN_PARTICLES { - if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0); - else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0); + if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) ; + else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) ; else tot++; } return tot; } int count_particles_mod(ParticleSystem *psys, int totgr, int cur) { - ParticleSettings *part=psys->part; + ParticleSettings *part = psys->part; PARTICLE_P; - int tot=0; + int tot = 0; LOOP_SHOWN_PARTICLES { - if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN)==0); - else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED)==0); - else if (p%totgr==cur) tot++; + if (pa->alive == PARS_UNBORN && (part->flag & PART_UNBORN) == 0) ; + else if (pa->alive == PARS_DEAD && (part->flag & PART_DIED) == 0) ; + else if (p % totgr == cur) tot++; } return tot; } @@ -127,17 +127,17 @@ static ParticleCacheKey **psys_alloc_path_cache_buffers(ListBase *bufs, int tot, ParticleCacheKey **cache; int i, totkey, totbufkey; - tot= MAX2(tot, 1); + tot = MAX2(tot, 1); totkey = 0; - cache = MEM_callocN(tot*sizeof(void*), "PathCacheArray"); + cache = MEM_callocN(tot * sizeof(void *), "PathCacheArray"); while (totkey < tot) { - totbufkey= MIN2(tot-totkey, PATH_CACHE_BUF_SIZE); - buf= MEM_callocN(sizeof(LinkData), "PathCacheLinkData"); - buf->data= MEM_callocN(sizeof(ParticleCacheKey)*totbufkey*steps, "ParticleCacheKey"); + totbufkey = MIN2(tot - totkey, PATH_CACHE_BUF_SIZE); + buf = MEM_callocN(sizeof(LinkData), "PathCacheLinkData"); + buf->data = MEM_callocN(sizeof(ParticleCacheKey) * totbufkey * steps, "ParticleCacheKey"); - for (i=0; idata) + i*steps; + for (i = 0; i < totbufkey; i++) + cache[totkey + i] = ((ParticleCacheKey *)buf->data) + i * steps; totkey += totbufkey; BLI_addtail(bufs, buf); @@ -153,7 +153,7 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf if (cache) MEM_freeN(cache); - for (buf= bufs->first; buf; buf=buf->next) + for (buf = bufs->first; buf; buf = buf->next) MEM_freeN(buf->data); BLI_freelistN(bufs); } @@ -165,9 +165,9 @@ static void psys_free_path_cache_buffers(ParticleCacheKey **cache, ListBase *buf ParticleSystem *psys_get_current(Object *ob) { ParticleSystem *psys; - if (ob==NULL) return NULL; + if (ob == NULL) return NULL; - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { if (psys->flag & PSYS_CURRENT) return psys; } @@ -179,9 +179,9 @@ short psys_get_current_num(Object *ob) ParticleSystem *psys; short i; - if (ob==NULL) return 0; + if (ob == NULL) return 0; - for (psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) + for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) if (psys->flag & PSYS_CURRENT) return i; @@ -192,9 +192,9 @@ void psys_set_current_num(Object *ob, int index) ParticleSystem *psys; short i; - if (ob==NULL) return; + if (ob == NULL) return; - for (psys=ob->particlesystem.first, i=0; psys; psys=psys->next, i++) { + for (psys = ob->particlesystem.first, i = 0; psys; psys = psys->next, i++) { if (i == index) psys->flag |= PSYS_CURRENT; else @@ -209,7 +209,7 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys) ParticleSystem *tpsys; for (base = scene->base.first; base; base = base->next) { - for (tpsys = base->object->particlesystem.first; psys; psys=psys->next) { + for (tpsys = base->object->particlesystem.first; psys; psys = psys->next) { if (tpsys == psys) return base->object; } @@ -221,16 +221,16 @@ Object *psys_find_object(Scene *scene, ParticleSystem *psys) Object *psys_get_lattice(ParticleSimulationData *sim) { - Object *lattice=NULL; + Object *lattice = NULL; - if (psys_in_edit_mode(sim->scene, sim->psys)==0) { + if (psys_in_edit_mode(sim->scene, sim->psys) == 0) { - ModifierData *md = (ModifierData*)psys_get_modifier(sim->ob, sim->psys); + ModifierData *md = (ModifierData *)psys_get_modifier(sim->ob, sim->psys); - for (; md; md=md->next) { - if (md->type==eModifierType_Lattice) { + for (; md; md = md->next) { + if (md->type == eModifierType_Lattice) { LatticeModifierData *lmd = (LatticeModifierData *)md; - lattice=lmd->object; + lattice = lmd->object; break; } } @@ -242,21 +242,21 @@ Object *psys_get_lattice(ParticleSimulationData *sim) } void psys_disable_all(Object *ob) { - ParticleSystem *psys=ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) psys->flag |= PSYS_DISABLED; } void psys_enable_all(Object *ob) { - ParticleSystem *psys=ob->particlesystem.first; + ParticleSystem *psys = ob->particlesystem.first; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) psys->flag &= ~PSYS_DISABLED; } int psys_in_edit_mode(Scene *scene, ParticleSystem *psys) { - return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys==psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit) && !psys->renderdata); + return (scene->basact && (scene->basact->object->mode & OB_MODE_PARTICLE_EDIT) && psys == psys_get_current((scene->basact)->object) && (psys->edit || psys->pointcache->edit) && !psys->renderdata); } static void psys_create_frand(ParticleSystem *psys) { @@ -265,7 +265,7 @@ static void psys_create_frand(ParticleSystem *psys) BLI_srandom(psys->seed); - for (i=0; i<1024; i++, rand++) + for (i = 0; i < 1024; i++, rand++) *rand = BLI_frand(); } int psys_check_enabled(Object *ob, ParticleSystem *psys) @@ -275,7 +275,7 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys) if (psys->flag & PSYS_DISABLED || psys->flag & PSYS_DELETE || !psys->part) return 0; - psmd= psys_get_modifier(ob, psys); + psmd = psys_get_modifier(ob, psys); if (psys->renderdata || G.rendering) { if (!(psmd->modifier.mode & eModifierMode_Render)) return 0; @@ -296,7 +296,7 @@ int psys_check_enabled(Object *ob, ParticleSystem *psys) int psys_check_edited(ParticleSystem *psys) { - if (psys->part && psys->part->type==PART_HAIR) + if (psys->part && psys->part->type == PART_HAIR) return (psys->flag & PSYS_EDITED || (psys->edit && psys->edit->edited)); else return (psys->pointcache->edit && psys->pointcache->edit->edited); @@ -339,7 +339,7 @@ void psys_check_group_weights(ParticleSettings *part) } dw = part->dupliweights.first; - for (; dw; dw=dw->next) { + for (; dw; dw = dw->next) { if (dw->flag & PART_DUPLIW_CURRENT) { current = 1; break; @@ -369,7 +369,7 @@ static void fluid_free_settings(SPHFluidSettings *fluid) MEM_freeN(fluid); } -void psys_free_settings(ParticleSettings *part) +void BKE_particlesettings_free(ParticleSettings *part) { MTex *mtex; int a; @@ -385,8 +385,8 @@ void psys_free_settings(ParticleSettings *part) boid_free_settings(part->boids); fluid_free_settings(part->fluid); - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = part->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -411,7 +411,7 @@ void free_hair(Object *UNUSED(ob), ParticleSystem *psys, int dynamics) psys->clmd->point_cache = psys->pointcache = NULL; psys->clmd->ptcaches.first = psys->clmd->ptcaches.last = NULL; - modifier_free((ModifierData*)psys->clmd); + modifier_free((ModifierData *)psys->clmd); psys->clmd = NULL; psys->pointcache = BKE_ptcache_add(&psys->ptcaches); @@ -441,8 +441,8 @@ void free_keyed_keys(ParticleSystem *psys) LOOP_PARTICLES { if (pa->keys) { - pa->keys= NULL; - pa->totkey= 0; + pa->keys = NULL; + pa->totkey = 0; } } } @@ -457,13 +457,13 @@ void psys_free_path_cache(ParticleSystem *psys, PTCacheEdit *edit) { if (edit) { psys_free_path_cache_buffers(edit->pathcache, &edit->pathcachebufs); - edit->pathcache= NULL; - edit->totcached= 0; + edit->pathcache = NULL; + edit->totcached = 0; } if (psys) { psys_free_path_cache_buffers(psys->pathcache, &psys->pathcachebufs); - psys->pathcache= NULL; - psys->totcached= 0; + psys->pathcache = NULL; + psys->totcached = 0; free_child_path_cache(psys); } @@ -472,8 +472,8 @@ void psys_free_children(ParticleSystem *psys) { if (psys->child) { MEM_freeN(psys->child); - psys->child= NULL; - psys->totchild=0; + psys->child = NULL; + psys->totchild = 0; } free_child_path_cache(psys); @@ -483,7 +483,7 @@ void psys_free_particles(ParticleSystem *psys) PARTICLE_P; if (psys->particles) { - if (psys->part->type==PART_HAIR) { + if (psys->part->type == PART_HAIR) { LOOP_PARTICLES { if (pa->hair) MEM_freeN(pa->hair); @@ -497,8 +497,8 @@ void psys_free_particles(ParticleSystem *psys) MEM_freeN(psys->particles->boid); MEM_freeN(psys->particles); - psys->particles= NULL; - psys->totpart= 0; + psys->particles = NULL; + psys->totpart = 0; } } void psys_free_pdd(ParticleSystem *psys) @@ -525,11 +525,11 @@ void psys_free_pdd(ParticleSystem *psys) } } /* free everything */ -void psys_free(Object *ob, ParticleSystem * psys) +void psys_free(Object *ob, ParticleSystem *psys) { if (psys) { int nr = 0; - ParticleSystem * tpsys; + ParticleSystem *tpsys; psys_free_path_cache(psys, NULL); @@ -547,7 +547,7 @@ void psys_free(Object *ob, ParticleSystem * psys) } // check if we are last non-visible particle system - for (tpsys=ob->particlesystem.first; tpsys; tpsys=tpsys->next) { + for (tpsys = ob->particlesystem.first; tpsys; tpsys = tpsys->next) { if (tpsys->part) { if (ELEM(tpsys->part->ren_as, PART_DRAW_OB, PART_DRAW_GR)) { nr++; @@ -561,7 +561,7 @@ void psys_free(Object *ob, ParticleSystem * psys) if (psys->part) { psys->part->id.us--; - psys->part=NULL; + psys->part = NULL; } BKE_ptcache_free_list(&psys->ptcaches); @@ -622,17 +622,17 @@ typedef struct ParticleRenderData { static float psys_render_viewport_falloff(double rate, float dist, float width) { - return pow(rate, dist/width); + return pow(rate, dist / width); } static float psys_render_projected_area(ParticleSystem *psys, const float center[3], float area, double vprate, float *viewport) { - ParticleRenderData *data= psys->renderdata; + ParticleRenderData *data = psys->renderdata; float co[4], view[3], ortho1[3], ortho2[3], w, dx, dy, radius; /* transform to view space */ copy_v3_v3(co, center); - co[3]= 1.0f; + co[3] = 1.0f; mul_m4_v4(data->viewmat, co); /* compute two vectors orthogonal to view vector */ @@ -640,87 +640,87 @@ static float psys_render_projected_area(ParticleSystem *psys, const float center ortho_basis_v3v3_v3(ortho1, ortho2, view); /* compute on screen minification */ - w= co[2]*data->winmat[2][3] + data->winmat[3][3]; - dx= data->winx*ortho2[0]*data->winmat[0][0]; - dy= data->winy*ortho2[1]*data->winmat[1][1]; - w= sqrtf(dx*dx + dy*dy)/w; + w = co[2] * data->winmat[2][3] + data->winmat[3][3]; + dx = data->winx * ortho2[0] * data->winmat[0][0]; + dy = data->winy * ortho2[1] * data->winmat[1][1]; + w = sqrtf(dx * dx + dy * dy) / w; /* w squared because we are working with area */ - area= area*w*w; + area = area * w * w; /* viewport of the screen test */ /* project point on screen */ mul_m4_v4(data->winmat, co); if (co[3] != 0.0f) { - co[0]= 0.5f*data->winx*(1.0f + co[0]/co[3]); - co[1]= 0.5f*data->winy*(1.0f + co[1]/co[3]); + co[0] = 0.5f * data->winx * (1.0f + co[0] / co[3]); + co[1] = 0.5f * data->winy * (1.0f + co[1] / co[3]); } /* screen space radius */ - radius= sqrt(area/(float)M_PI); + radius = sqrt(area / (float)M_PI); /* make smaller using fallof once over screen edge */ - *viewport= 1.0f; + *viewport = 1.0f; - if (co[0]+radius < 0.0f) - *viewport *= psys_render_viewport_falloff(vprate, -(co[0]+radius), data->winx); - else if (co[0]-radius > data->winx) - *viewport *= psys_render_viewport_falloff(vprate, (co[0]-radius) - data->winx, data->winx); + if (co[0] + radius < 0.0f) + *viewport *= psys_render_viewport_falloff(vprate, -(co[0] + radius), data->winx); + else if (co[0] - radius > data->winx) + *viewport *= psys_render_viewport_falloff(vprate, (co[0] - radius) - data->winx, data->winx); - if (co[1]+radius < 0.0f) - *viewport *= psys_render_viewport_falloff(vprate, -(co[1]+radius), data->winy); - else if (co[1]-radius > data->winy) - *viewport *= psys_render_viewport_falloff(vprate, (co[1]-radius) - data->winy, data->winy); + if (co[1] + radius < 0.0f) + *viewport *= psys_render_viewport_falloff(vprate, -(co[1] + radius), data->winy); + else if (co[1] - radius > data->winy) + *viewport *= psys_render_viewport_falloff(vprate, (co[1] - radius) - data->winy, data->winy); return area; } void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float winmat[][4], int winx, int winy, int timeoffset) { - ParticleRenderData*data; - ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); + ParticleRenderData *data; + ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); if (!G.rendering) return; if (psys->renderdata) return; - data= MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData"); + data = MEM_callocN(sizeof(ParticleRenderData), "ParticleRenderData"); - data->child= psys->child; - data->totchild= psys->totchild; - data->pathcache= psys->pathcache; + data->child = psys->child; + data->totchild = psys->totchild; + data->pathcache = psys->pathcache; data->pathcachebufs.first = psys->pathcachebufs.first; data->pathcachebufs.last = psys->pathcachebufs.last; - data->totcached= psys->totcached; - data->childcache= psys->childcache; + data->totcached = psys->totcached; + data->childcache = psys->childcache; data->childcachebufs.first = psys->childcachebufs.first; data->childcachebufs.last = psys->childcachebufs.last; - data->totchildcache= psys->totchildcache; + data->totchildcache = psys->totchildcache; if (psmd->dm) - data->dm= CDDM_copy(psmd->dm); - data->totdmvert= psmd->totdmvert; - data->totdmedge= psmd->totdmedge; - data->totdmface= psmd->totdmface; + data->dm = CDDM_copy(psmd->dm); + data->totdmvert = psmd->totdmvert; + data->totdmedge = psmd->totdmedge; + data->totdmface = psmd->totdmface; - psys->child= NULL; - psys->pathcache= NULL; - psys->childcache= NULL; - psys->totchild= psys->totcached= psys->totchildcache= 0; + psys->child = NULL; + psys->pathcache = NULL; + psys->childcache = NULL; + psys->totchild = psys->totcached = psys->totchildcache = 0; psys->pathcachebufs.first = psys->pathcachebufs.last = NULL; psys->childcachebufs.first = psys->childcachebufs.last = NULL; copy_m4_m4(data->winmat, winmat); mult_m4_m4m4(data->viewmat, viewmat, ob->obmat); mult_m4_m4m4(data->mat, winmat, data->viewmat); - data->winx= winx; - data->winy= winy; + data->winx = winx; + data->winy = winy; - data->timeoffset= timeoffset; + data->timeoffset = timeoffset; - psys->renderdata= data; + psys->renderdata = data; /* Hair can and has to be recalculated if everything isn't displayed. */ if (psys->part->disp != 100 && psys->part->type == PART_HAIR) @@ -729,10 +729,10 @@ void psys_render_set(Object *ob, ParticleSystem *psys, float viewmat[][4], float void psys_render_restore(Object *ob, ParticleSystem *psys) { - ParticleRenderData*data; - ParticleSystemModifierData *psmd= psys_get_modifier(ob, psys); + ParticleRenderData *data; + ParticleSystemModifierData *psmd = psys_get_modifier(ob, psys); - data= psys->renderdata; + data = psys->renderdata; if (!data) return; @@ -740,7 +740,7 @@ void psys_render_restore(Object *ob, ParticleSystem *psys) MEM_freeN(data->elems); if (psmd->dm) { - psmd->dm->needsFree= 1; + psmd->dm->needsFree = 1; psmd->dm->release(psmd->dm); } @@ -748,93 +748,93 @@ void psys_render_restore(Object *ob, ParticleSystem *psys) if (psys->child) { MEM_freeN(psys->child); - psys->child= 0; - psys->totchild= 0; + psys->child = 0; + psys->totchild = 0; } - psys->child= data->child; - psys->totchild= data->totchild; - psys->pathcache= data->pathcache; + psys->child = data->child; + psys->totchild = data->totchild; + psys->pathcache = data->pathcache; psys->pathcachebufs.first = data->pathcachebufs.first; psys->pathcachebufs.last = data->pathcachebufs.last; - psys->totcached= data->totcached; - psys->childcache= data->childcache; + psys->totcached = data->totcached; + psys->childcache = data->childcache; psys->childcachebufs.first = data->childcachebufs.first; psys->childcachebufs.last = data->childcachebufs.last; - psys->totchildcache= data->totchildcache; + psys->totchildcache = data->totchildcache; - psmd->dm= data->dm; - psmd->totdmvert= data->totdmvert; - psmd->totdmedge= data->totdmedge; - psmd->totdmface= data->totdmface; + psmd->dm = data->dm; + psmd->totdmvert = data->totdmvert; + psmd->totdmedge = data->totdmedge; + psmd->totdmface = data->totdmface; psmd->flag &= ~eParticleSystemFlag_psys_updated; if (psmd->dm) psys_calc_dmcache(ob, psmd->dm, psys); MEM_freeN(data); - psys->renderdata= NULL; + psys->renderdata = NULL; } /* BMESH_TODO, for orig face data, we need to use MPoly */ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) { - DerivedMesh *dm= ctx->dm; - Mesh *me= (Mesh*)(ctx->sim.ob->data); + DerivedMesh *dm = ctx->dm; + Mesh *me = (Mesh *)(ctx->sim.ob->data); MFace *mf, *mface; MVert *mvert; ParticleRenderData *data; ParticleRenderElem *elems, *elem; - ParticleSettings *part= ctx->sim.psys->part; + ParticleSettings *part = ctx->sim.psys->part; float *facearea, (*facecenter)[3], size[3], fac, powrate, scaleclamp; float co1[3], co2[3], co3[3], co4[3], lambda, arearatio, t, area, viewport; double vprate; int *origindex, *facetotvert; int a, b, totorigface, totface, newtot, skipped; - if (part->ren_as!=PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND)) + if (part->ren_as != PART_DRAW_PATH || !(part->draw & PART_DRAW_REN_STRAND)) return tot; if (!ctx->sim.psys->renderdata) return tot; - data= ctx->sim.psys->renderdata; + data = ctx->sim.psys->renderdata; if (data->timeoffset) return 0; if (!(part->simplify_flag & PART_SIMPLIFY_ENABLE)) return tot; - mvert= dm->getVertArray(dm); - mface= dm->getTessFaceArray(dm); - origindex= dm->getTessFaceDataArray(dm, CD_ORIGINDEX); - totface= dm->getNumTessFaces(dm); - totorigface= me->totpoly; + mvert = dm->getVertArray(dm); + mface = dm->getTessFaceArray(dm); + origindex = dm->getTessFaceDataArray(dm, CD_ORIGINDEX); + totface = dm->getNumTessFaces(dm); + totorigface = me->totpoly; if (totface == 0 || totorigface == 0) return tot; - facearea= MEM_callocN(sizeof(float)*totorigface, "SimplifyFaceArea"); - facecenter= MEM_callocN(sizeof(float[3])*totorigface, "SimplifyFaceCenter"); - facetotvert= MEM_callocN(sizeof(int)*totorigface, "SimplifyFaceArea"); - elems= MEM_callocN(sizeof(ParticleRenderElem)*totorigface, "SimplifyFaceElem"); + facearea = MEM_callocN(sizeof(float) * totorigface, "SimplifyFaceArea"); + facecenter = MEM_callocN(sizeof(float[3]) * totorigface, "SimplifyFaceCenter"); + facetotvert = MEM_callocN(sizeof(int) * totorigface, "SimplifyFaceArea"); + elems = MEM_callocN(sizeof(ParticleRenderElem) * totorigface, "SimplifyFaceElem"); if (data->elems) MEM_freeN(data->elems); - data->dosimplify= 1; - data->elems= elems; - data->origindex= origindex; + data->dosimplify = 1; + data->elems = elems; + data->origindex = origindex; /* compute number of children per original face */ - for (a=0; aindex[a]]: ctx->index[a]; + for (a = 0; a < tot; a++) { + b = (origindex) ? origindex[ctx->index[a]] : ctx->index[a]; if (b != -1) elems[b].totchild++; } /* compute areas and centers of original faces */ - for (mf=mface, a=0; av1].co); @@ -858,67 +858,67 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) } } - for (a=0; a 0) - mul_v3_fl(facecenter[a], 1.0f/facetotvert[a]); + mul_v3_fl(facecenter[a], 1.0f / facetotvert[a]); /* for conversion from BU area / pixel area to reference screen size */ - mesh_get_texspace(me, 0, 0, size); - fac= ((size[0] + size[1] + size[2])/3.0f)/part->simplify_refsize; - fac= fac*fac; + BKE_mesh_texspace_get(me, 0, 0, size); + fac = ((size[0] + size[1] + size[2]) / 3.0f) / part->simplify_refsize; + fac = fac * fac; - powrate= log(0.5f)/log(part->simplify_rate*0.5f); + powrate = log(0.5f) / log(part->simplify_rate * 0.5f); if (part->simplify_flag & PART_SIMPLIFY_VIEWPORT) - vprate= pow(1.0f - part->simplify_viewport, 5.0); + vprate = pow(1.0f - part->simplify_viewport, 5.0); else - vprate= 1.0; + vprate = 1.0; /* set simplification parameters per original face */ - for (a=0, elem=elems; asim.psys, facecenter[a], facearea[a], vprate, &viewport); - arearatio= fac*area/facearea[a]; + arearatio = fac * area / facearea[a]; if ((arearatio < 1.0f || viewport < 1.0f) && elem->totchild) { /* lambda is percentage of elements to keep */ - lambda= (arearatio < 1.0f)? powf(arearatio, powrate): 1.0f; + lambda = (arearatio < 1.0f) ? powf(arearatio, powrate) : 1.0f; lambda *= viewport; - lambda= MAX2(lambda, 1.0f/elem->totchild); + lambda = MAX2(lambda, 1.0f / elem->totchild); /* compute transition region */ - t= part->simplify_transition; - elem->t= (lambda-t < 0.0f)? lambda: (lambda+t > 1.0f)? 1.0f-lambda: t; - elem->reduce= 1; + t = part->simplify_transition; + elem->t = (lambda - t < 0.0f) ? lambda : (lambda + t > 1.0f) ? 1.0f - lambda : t; + elem->reduce = 1; /* scale at end and beginning of the transition region */ - elem->scalemax= (lambda+t < 1.0f)? 1.0f/lambda: 1.0f/(1.0f - elem->t*elem->t/t); - elem->scalemin= (lambda+t < 1.0f)? 0.0f: elem->scalemax*(1.0f-elem->t/t); + elem->scalemax = (lambda + t < 1.0f) ? 1.0f / lambda : 1.0f / (1.0f - elem->t * elem->t / t); + elem->scalemin = (lambda + t < 1.0f) ? 0.0f : elem->scalemax * (1.0f - elem->t / t); - elem->scalemin= sqrt(elem->scalemin); - elem->scalemax= sqrt(elem->scalemax); + elem->scalemin = sqrt(elem->scalemin); + elem->scalemax = sqrt(elem->scalemax); /* clamp scaling */ - scaleclamp= MIN2(elem->totchild, 10.0f); - elem->scalemin= MIN2(scaleclamp, elem->scalemin); - elem->scalemax= MIN2(scaleclamp, elem->scalemax); + scaleclamp = MIN2(elem->totchild, 10.0f); + elem->scalemin = MIN2(scaleclamp, elem->scalemin); + elem->scalemax = MIN2(scaleclamp, elem->scalemax); /* extend lambda to include transition */ - lambda= lambda + elem->t; + lambda = lambda + elem->t; if (lambda > 1.0f) - lambda= 1.0f; + lambda = 1.0f; } else { - lambda= arearatio; + lambda = arearatio; - elem->scalemax= 1.0f; //sqrt(lambda); - elem->scalemin= 1.0f; //sqrt(lambda); - elem->reduce= 0; + elem->scalemax = 1.0f; //sqrt(lambda); + elem->scalemin = 1.0f; //sqrt(lambda); + elem->reduce = 0; } - elem->lambda= lambda; - elem->scalemin= sqrt(elem->scalemin); - elem->scalemax= sqrt(elem->scalemax); - elem->curchild= 0; + elem->lambda = lambda; + elem->scalemin = sqrt(elem->scalemin); + elem->scalemax = sqrt(elem->scalemax); + elem->curchild = 0; } MEM_freeN(facearea); @@ -926,16 +926,16 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) MEM_freeN(facetotvert); /* move indices and set random number skipping */ - ctx->skip= MEM_callocN(sizeof(int)*tot, "SimplificationSkip"); + ctx->skip = MEM_callocN(sizeof(int) * tot, "SimplificationSkip"); - skipped= 0; - for (a=0, newtot=0; aindex[a]]: ctx->index[a]; + skipped = 0; + for (a = 0, newtot = 0; a < tot; a++) { + b = (origindex) ? origindex[ctx->index[a]] : ctx->index[a]; if (b != -1) { - if (elems[b].curchild++ < ceil(elems[b].lambda*elems[b].totchild)) { - ctx->index[newtot]= ctx->index[a]; - ctx->skip[newtot]= skipped; - skipped= 0; + if (elems[b].curchild++ < ceil(elems[b].lambda * elems[b].totchild)) { + ctx->index[newtot] = ctx->index[a]; + ctx->skip[newtot] = skipped; + skipped = 0; newtot++; } else skipped++; @@ -943,8 +943,8 @@ int psys_render_simplify_distribution(ParticleThreadContext *ctx, int tot) else skipped++; } - for (a=0, elem=elems; acurchild= 0; + for (a = 0, elem = elems; a < totorigface; a++, elem++) + elem->curchild = 0; return newtot; } @@ -959,44 +959,44 @@ int psys_render_simplify_params(ParticleSystem *psys, ChildParticle *cpa, float if (!(psys->renderdata && (psys->part->simplify_flag & PART_SIMPLIFY_ENABLE))) return 0; - data= psys->renderdata; + data = psys->renderdata; if (!data->dosimplify) return 0; - b= (data->origindex)? data->origindex[cpa->num]: cpa->num; + b = (data->origindex) ? data->origindex[cpa->num] : cpa->num; if (b == -1) return 0; - elem= &data->elems[b]; + elem = &data->elems[b]; - lambda= elem->lambda; - t= elem->t; - scalemin= elem->scalemin; - scalemax= elem->scalemax; + lambda = elem->lambda; + t = elem->t; + scalemin = elem->scalemin; + scalemax = elem->scalemax; if (!elem->reduce) { - scale= scalemin; - alpha= 1.0f; + scale = scalemin; + alpha = 1.0f; } else { - x= (elem->curchild+0.5f)/elem->totchild; - if (x < lambda-t) { - scale= scalemax; - alpha= 1.0f; + x = (elem->curchild + 0.5f) / elem->totchild; + if (x < lambda - t) { + scale = scalemax; + alpha = 1.0f; } - else if (x >= lambda+t) { - scale= scalemin; - alpha= 0.0f; + else if (x >= lambda + t) { + scale = scalemin; + alpha = 0.0f; } else { - w= (lambda+t - x)/(2.0f*t); - scale= scalemin + (scalemax - scalemin)*w; - alpha= w; + w = (lambda + t - x) / (2.0f * t); + scale = scalemin + (scalemax - scalemin) * w; + alpha = w; } } - params[0]= scale; - params[1]= alpha; + params[0] = scale; + params[1] = alpha; elem->curchild++; @@ -1010,9 +1010,9 @@ static float interpolate_particle_value(float v1, float v2, float v3, float v4, { float value; - value= w[0]*v1 + w[1]*v2 + w[2]*v3; + value = w[0] * v1 + w[1] * v2 + w[2] * v3; if (four) - value += w[3]*v4; + value += w[3] * v4; CLAMP(value, 0.f, 1.f); @@ -1023,7 +1023,7 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic { float t[4]; - if (type<0) { + if (type < 0) { interp_cubic_v3(result->co, result->vel, keys[1].co, keys[1].vel, keys[2].co, keys[2].vel, dt); } else { @@ -1034,13 +1034,13 @@ void psys_interpolate_particle(short type, ParticleKey keys[4], float dt, Partic if (velocity) { float temp[3]; - if (dt>0.999f) { - key_curve_position_weights(dt-0.001f, t, type); + if (dt > 0.999f) { + key_curve_position_weights(dt - 0.001f, t, type); interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); sub_v3_v3v3(result->vel, result->co, temp); } else { - key_curve_position_weights(dt+0.001f, t, type); + key_curve_position_weights(dt + 0.001f, t, type); interp_v3_v3v3v3v3(temp, keys[0].co, keys[1].co, keys[2].co, keys[3].co, t); sub_v3_v3v3(result->vel, temp, result->co); } @@ -1110,7 +1110,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float PTCacheMem *pm; int ret = 0; - for (pm=cache->mem_cache.first; pm; pm=pm->next) { + for (pm = cache->mem_cache.first; pm; pm = pm->next) { if (BKE_ptcache_mem_index_find(pm, index) >= 0) { *start = pm->frame; ret++; @@ -1118,7 +1118,7 @@ static int get_pointcache_times_for_particle(PointCache *cache, int index, float } } - for (pm=cache->mem_cache.last; pm; pm=pm->prev) { + for (pm = cache->mem_cache.last; pm; pm = pm->prev) { if (BKE_ptcache_mem_index_find(pm, index) >= 0) { *end = pm->frame; ret++; @@ -1134,7 +1134,7 @@ float psys_get_dietime_from_cache(PointCache *cache, int index) PTCacheMem *pm; int dietime = 10000000; /* some max value so that we can default to pa->time+lifetime */ - for (pm=cache->mem_cache.last; pm; pm=pm->prev) { + for (pm = cache->mem_cache.last; pm; pm = pm->prev) { if (BKE_ptcache_mem_index_find(pm, index) >= 0) return (float)pm->frame; } @@ -1163,7 +1163,7 @@ static void init_particle_interpolation(Object *ob, ParticleSystem *psys, Partic pind->dietime = (key + pa->totkey - 1)->time; } else if (pind->cache) { - float start=0.0f, end=0.0f; + float start = 0.0f, end = 0.0f; get_pointcache_keys_for_time(ob, pind->cache, &pind->pm, -1, 0.0f, NULL, NULL); pind->birthtime = pa ? pa->time : pind->cache->startframe; pind->dietime = pa ? pa->dietime : pind->cache->endframe; @@ -1222,7 +1222,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData if (result->time < 0.0f) real_t = -result->time; else - real_t = *(pind->ekey[0]->time) + t * (*(pind->ekey[0][point->totkey-1].time) - *(pind->ekey[0]->time)); + real_t = *(pind->ekey[0]->time) + t * (*(pind->ekey[0][point->totkey - 1].time) - *(pind->ekey[0]->time)); while (*(pind->ekey[1]->time) < real_t) pind->ekey[1]++; @@ -1231,7 +1231,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData } else if (pind->keyed) { /* we have only one key, so let's use that */ - if (pind->kkey[1]==NULL) { + if (pind->kkey[1] == NULL) { copy_particle_key(result, pind->kkey[0], 1); return; } @@ -1239,24 +1239,24 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData if (result->time < 0.0f) real_t = -result->time; else - real_t = pind->kkey[0]->time + t * (pind->kkey[0][pa->totkey-1].time - pind->kkey[0]->time); + real_t = pind->kkey[0]->time + t * (pind->kkey[0][pa->totkey - 1].time - pind->kkey[0]->time); - if (psys->part->phystype==PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) { + if (psys->part->phystype == PART_PHYS_KEYED && psys->flag & PSYS_KEYED_TIMING) { ParticleTarget *pt = psys->targets.first; - pt=pt->next; + pt = pt->next; while (pt && pa->time + pt->time < real_t) - pt= pt->next; + pt = pt->next; if (pt) { - pt=pt->prev; + pt = pt->prev; if (pa->time + pt->time + pt->duration > real_t) real_t = pa->time + pt->time; } else - real_t = pa->time + ((ParticleTarget*)psys->targets.last)->time; + real_t = pa->time + ((ParticleTarget *)psys->targets.last)->time; } CLAMP(real_t, pa->time, pa->dietime); @@ -1276,7 +1276,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData if (result->time < 0.0f) real_t = -result->time; else - real_t = pind->hkey[0]->time + t * (pind->hkey[0][pa->totkey-1].time - pind->hkey[0]->time); + real_t = pind->hkey[0]->time + t * (pind->hkey[0][pa->totkey - 1].time - pind->hkey[0]->time); while (pind->hkey[1]->time < real_t) { pind->hkey[1]++; @@ -1301,7 +1301,7 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData memcpy(keys + 2, pind->kkey[1], sizeof(ParticleKey)); } else if (pind->cache) { - get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys+1, keys+2); + get_pointcache_keys_for_time(NULL, pind->cache, &pind->pm, p, real_t, keys + 1, keys + 2); } else { hair_to_particle(keys + 1, pind->hkey[0]); @@ -1362,37 +1362,37 @@ static void do_particle_interpolation(ParticleSystem *psys, int p, ParticleData /* now we should have in chronologiacl order k1<=k2<=t<=k3<=k4 with keytime between [0, 1]->[k2, k3] (k1 & k4 used for cardinal & bspline interpolation)*/ psys_interpolate_particle((pind->keyed || pind->cache || point_vel) ? -1 /* signal for cubic interpolation */ - : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL), - keys, keytime, result, 1); + : (pind->bspline ? KEY_BSPLINE : KEY_CARDINAL), + keys, keytime, result, 1); /* the velocity needs to be converted back from cubic interpolation */ if (pind->keyed || pind->cache || point_vel) - mul_v3_fl(result->vel, 1.f/invdt); + mul_v3_fl(result->vel, 1.f / invdt); } static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCacheKey *result) { - int i=0; + int i = 0; ParticleCacheKey *cur = first; /* scale the requested time to fit the entire path even if the path is cut early */ - t *= (first+first->steps)->time; + t *= (first + first->steps)->time; - while (isteps && cur->time < t) + while (i < first->steps && cur->time < t) cur++; if (cur->time == t) *result = *cur; else { - float dt = (t-(cur-1)->time)/(cur->time-(cur-1)->time); - interp_v3_v3v3(result->co, (cur-1)->co, cur->co, dt); - interp_v3_v3v3(result->vel, (cur-1)->vel, cur->vel, dt); - interp_qt_qtqt(result->rot, (cur-1)->rot, cur->rot, dt); + float dt = (t - (cur - 1)->time) / (cur->time - (cur - 1)->time); + interp_v3_v3v3(result->co, (cur - 1)->co, cur->co, dt); + interp_v3_v3v3(result->vel, (cur - 1)->vel, cur->vel, dt); + interp_qt_qtqt(result->rot, (cur - 1)->rot, cur->rot, dt); result->time = t; } /* first is actual base rotation, others are incremental from first */ - if (cur==first || cur-1==first) + if (cur == first || cur - 1 == first) copy_qt_qt(result->rot, first->rot); else mul_qt_qtqt(result->rot, first->rot, result->rot); @@ -1405,23 +1405,23 @@ static void interpolate_pathcache(ParticleCacheKey *first, float t, ParticleCach void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*orcodata)[3], float *w, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { - float *v1=0, *v2=0, *v3=0, *v4=0; + float *v1 = 0, *v2 = 0, *v3 = 0, *v4 = 0; float e1[3], e2[3], s1, s2, t1, t2; float *uv1, *uv2, *uv3, *uv4; float n1[3], n2[3], n3[3], n4[3]; float tuv[4][2]; float *o1, *o2, *o3, *o4; - v1= mvert[mface->v1].co; - v2= mvert[mface->v2].co; - v3= mvert[mface->v3].co; + v1 = mvert[mface->v1].co; + v2 = mvert[mface->v2].co; + v3 = mvert[mface->v3].co; normal_short_to_float_v3(n1, mvert[mface->v1].no); normal_short_to_float_v3(n2, mvert[mface->v2].no); normal_short_to_float_v3(n3, mvert[mface->v3].no); if (mface->v4) { - v4= mvert[mface->v4].co; + v4 = mvert[mface->v4].co; normal_short_to_float_v3(n4, mvert[mface->v4].no); interp_v3_v3v3v3v3(vec, v1, v2, v3, v4, w); @@ -1447,58 +1447,58 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or /* calculate tangent vectors */ if (utan && vtan) { if (tface) { - uv1= tface->uv[0]; - uv2= tface->uv[1]; - uv3= tface->uv[2]; - uv4= tface->uv[3]; + uv1 = tface->uv[0]; + uv2 = tface->uv[1]; + uv3 = tface->uv[2]; + uv4 = tface->uv[3]; } else { - uv1= tuv[0]; uv2= tuv[1]; uv3= tuv[2]; uv4= tuv[3]; - map_to_sphere(uv1, uv1+1, v1[0], v1[1], v1[2]); - map_to_sphere(uv2, uv2+1, v2[0], v2[1], v2[2]); - map_to_sphere(uv3, uv3+1, v3[0], v3[1], v3[2]); + uv1 = tuv[0]; uv2 = tuv[1]; uv3 = tuv[2]; uv4 = tuv[3]; + map_to_sphere(uv1, uv1 + 1, v1[0], v1[1], v1[2]); + map_to_sphere(uv2, uv2 + 1, v2[0], v2[1], v2[2]); + map_to_sphere(uv3, uv3 + 1, v3[0], v3[1], v3[2]); if (v4) - map_to_sphere(uv4, uv4+1, v4[0], v4[1], v4[2]); + map_to_sphere(uv4, uv4 + 1, v4[0], v4[1], v4[2]); } if (v4) { - s1= uv3[0] - uv1[0]; - s2= uv4[0] - uv1[0]; + s1 = uv3[0] - uv1[0]; + s2 = uv4[0] - uv1[0]; - t1= uv3[1] - uv1[1]; - t2= uv4[1] - uv1[1]; + t1 = uv3[1] - uv1[1]; + t2 = uv4[1] - uv1[1]; sub_v3_v3v3(e1, v3, v1); sub_v3_v3v3(e2, v4, v1); } else { - s1= uv2[0] - uv1[0]; - s2= uv3[0] - uv1[0]; + s1 = uv2[0] - uv1[0]; + s2 = uv3[0] - uv1[0]; - t1= uv2[1] - uv1[1]; - t2= uv3[1] - uv1[1]; + t1 = uv2[1] - uv1[1]; + t2 = uv3[1] - uv1[1]; sub_v3_v3v3(e1, v2, v1); sub_v3_v3v3(e2, v3, v1); } - vtan[0] = (s1*e2[0] - s2*e1[0]); - vtan[1] = (s1*e2[1] - s2*e1[1]); - vtan[2] = (s1*e2[2] - s2*e1[2]); + vtan[0] = (s1 * e2[0] - s2 * e1[0]); + vtan[1] = (s1 * e2[1] - s2 * e1[1]); + vtan[2] = (s1 * e2[2] - s2 * e1[2]); - utan[0] = (t1*e2[0] - t2*e1[0]); - utan[1] = (t1*e2[1] - t2*e1[1]); - utan[2] = (t1*e2[2] - t2*e1[2]); + utan[0] = (t1 * e2[0] - t2 * e1[0]); + utan[1] = (t1 * e2[1] - t2 * e1[1]); + utan[2] = (t1 * e2[2] - t2 * e1[2]); } if (orco) { if (orcodata) { - o1= orcodata[mface->v1]; - o2= orcodata[mface->v2]; - o3= orcodata[mface->v3]; + o1 = orcodata[mface->v1]; + o2 = orcodata[mface->v2]; + o3 = orcodata[mface->v3]; if (mface->v4) { - o4= orcodata[mface->v4]; + o4 = orcodata[mface->v4]; interp_v3_v3v3v3v3(orco, o1, o2, o3, o4, w); @@ -1521,24 +1521,24 @@ void psys_interpolate_face(MVert *mvert, MFace *mface, MTFace *tface, float (*or } void psys_interpolate_uvs(const MTFace *tface, int quad, const float w[4], float uvco[2]) { - float v10= tface->uv[0][0]; - float v11= tface->uv[0][1]; - float v20= tface->uv[1][0]; - float v21= tface->uv[1][1]; - float v30= tface->uv[2][0]; - float v31= tface->uv[2][1]; + float v10 = tface->uv[0][0]; + float v11 = tface->uv[0][1]; + float v20 = tface->uv[1][0]; + float v21 = tface->uv[1][1]; + float v30 = tface->uv[2][0]; + float v31 = tface->uv[2][1]; float v40, v41; if (quad) { - v40= tface->uv[3][0]; - v41= tface->uv[3][1]; + v40 = tface->uv[3][0]; + v41 = tface->uv[3][1]; - uvco[0]= w[0]*v10 + w[1]*v20 + w[2]*v30 + w[3]*v40; - uvco[1]= w[0]*v11 + w[1]*v21 + w[2]*v31 + w[3]*v41; + uvco[0] = w[0] * v10 + w[1] * v20 + w[2] * v30 + w[3] * v40; + uvco[1] = w[0] * v11 + w[1] * v21 + w[2] * v31 + w[3] * v41; } else { - uvco[0]= w[0]*v10 + w[1]*v20 + w[2]*v30; - uvco[1]= w[0]*v11 + w[1]*v21 + w[2]*v31; + uvco[0] = w[0] * v10 + w[1] * v20 + w[2] * v30; + uvco[1] = w[0] * v11 + w[1] * v21 + w[2] * v31; } } @@ -1546,30 +1546,30 @@ void psys_interpolate_mcol(const MCol *mcol, int quad, const float w[4], MCol *m { char *cp, *cp1, *cp2, *cp3, *cp4; - cp= (char *)mc; - cp1= (char *)&mcol[0]; - cp2= (char *)&mcol[1]; - cp3= (char *)&mcol[2]; + cp = (char *)mc; + cp1 = (char *)&mcol[0]; + cp2 = (char *)&mcol[1]; + cp3 = (char *)&mcol[2]; if (quad) { - cp4= (char *)&mcol[3]; + cp4 = (char *)&mcol[3]; - cp[0]= (int)(w[0]*cp1[0] + w[1]*cp2[0] + w[2]*cp3[0] + w[3]*cp4[0]); - cp[1]= (int)(w[0]*cp1[1] + w[1]*cp2[1] + w[2]*cp3[1] + w[3]*cp4[1]); - cp[2]= (int)(w[0]*cp1[2] + w[1]*cp2[2] + w[2]*cp3[2] + w[3]*cp4[2]); - cp[3]= (int)(w[0]*cp1[3] + w[1]*cp2[3] + w[2]*cp3[3] + w[3]*cp4[3]); + cp[0] = (int)(w[0] * cp1[0] + w[1] * cp2[0] + w[2] * cp3[0] + w[3] * cp4[0]); + cp[1] = (int)(w[0] * cp1[1] + w[1] * cp2[1] + w[2] * cp3[1] + w[3] * cp4[1]); + cp[2] = (int)(w[0] * cp1[2] + w[1] * cp2[2] + w[2] * cp3[2] + w[3] * cp4[2]); + cp[3] = (int)(w[0] * cp1[3] + w[1] * cp2[3] + w[2] * cp3[3] + w[3] * cp4[3]); } else { - cp[0]= (int)(w[0]*cp1[0] + w[1]*cp2[0] + w[2]*cp3[0]); - cp[1]= (int)(w[0]*cp1[1] + w[1]*cp2[1] + w[2]*cp3[1]); - cp[2]= (int)(w[0]*cp1[2] + w[1]*cp2[2] + w[2]*cp3[2]); - cp[3]= (int)(w[0]*cp1[3] + w[1]*cp2[3] + w[2]*cp3[3]); + cp[0] = (int)(w[0] * cp1[0] + w[1] * cp2[0] + w[2] * cp3[0]); + cp[1] = (int)(w[0] * cp1[1] + w[1] * cp2[1] + w[2] * cp3[1]); + cp[2] = (int)(w[0] * cp1[2] + w[1] * cp2[2] + w[2] * cp3[2]); + cp[3] = (int)(w[0] * cp1[3] + w[1] * cp2[3] + w[2] * cp3[3]); } } static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int index, const float fw[4], const float *values) { - if (values==0 || index==-1) + if (values == 0 || index == -1) return 0.0; switch (from) { @@ -1578,7 +1578,7 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int case PART_FROM_FACE: case PART_FROM_VOLUME: { - MFace *mf=dm->getTessFaceData(dm, index, CD_MFACE); + MFace *mf = dm->getTessFaceData(dm, index, CD_MFACE); return interpolate_particle_value(values[mf->v1], values[mf->v2], values[mf->v3], values[mf->v4], fw, mf->v4); } @@ -1589,8 +1589,8 @@ static float psys_interpolate_value_from_verts(DerivedMesh *dm, short from, int /* conversion of pa->fw to origspace layer coordinates */ static void psys_w_to_origspace(const float w[4], float uv[2]) { - uv[0]= w[1] + w[2]; - uv[1]= w[2] + w[3]; + uv[0] = w[1] + w[2]; + uv[1] = w[2] + w[3]; } /* conversion of pa->fw to weights in face from origspace */ @@ -1598,20 +1598,20 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4 { float v[4][3], co[3]; - v[0][0]= osface->uv[0][0]; v[0][1]= osface->uv[0][1]; v[0][2]= 0.0f; - v[1][0]= osface->uv[1][0]; v[1][1]= osface->uv[1][1]; v[1][2]= 0.0f; - v[2][0]= osface->uv[2][0]; v[2][1]= osface->uv[2][1]; v[2][2]= 0.0f; + v[0][0] = osface->uv[0][0]; v[0][1] = osface->uv[0][1]; v[0][2] = 0.0f; + v[1][0] = osface->uv[1][0]; v[1][1] = osface->uv[1][1]; v[1][2] = 0.0f; + v[2][0] = osface->uv[2][0]; v[2][1] = osface->uv[2][1]; v[2][2] = 0.0f; psys_w_to_origspace(w, co); - co[2]= 0.0f; + co[2] = 0.0f; if (quad) { - v[3][0]= osface->uv[3][0]; v[3][1]= osface->uv[3][1]; v[3][2]= 0.0f; + v[3][0] = osface->uv[3][0]; v[3][1] = osface->uv[3][1]; v[3][2] = 0.0f; interp_weights_poly_v3(neww, v, 4, co); } else { interp_weights_poly_v3(neww, v, 3, co); - neww[3]= 0.0f; + neww[3] = 0.0f; } } @@ -1619,7 +1619,7 @@ static void psys_origspace_to_w(OrigSpaceFace *osface, int quad, const float w[4 * and can be optimized but only for many lookups. returns the face index. */ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const float fw[4], struct LinkNode *node) { - Mesh *me= (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; MPoly *mpoly; OrigSpaceFace *osface; int *origindex; @@ -1632,9 +1632,9 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f totface = dm->getNumTessFaces(dm); - if (osface==NULL || origindex==NULL) { + if (osface == NULL || origindex == NULL) { /* Assume we don't need osface data */ - if (index = me->totpoly) - return DMCACHE_NOTFOUND; /* index not in the original mesh */ + return DMCACHE_NOTFOUND; /* index not in the original mesh */ psys_w_to_origspace(fw, uv); if (node) { /* we have a linked list of faces that we use, faster! */ - for (;node; node=node->next) { - findex= GET_INT_FROM_POINTER(node->link); - faceuv= osface[findex].uv; + for (; node; node = node->next) { + findex = GET_INT_FROM_POINTER(node->link); + faceuv = osface[findex].uv; quad = (mpoly[findex].totloop == 4); /* check that this intersects - Its possible this misses :/ - @@ -1665,9 +1665,9 @@ int psys_particle_dm_face_lookup(Object *ob, DerivedMesh *dm, int index, const f } } else { /* if we have no node, try every face */ - for (findex=0; findex= dm->getNumTessFaces(dm)) + if (i == DMCACHE_NOTFOUND || i >= dm->getNumTessFaces(dm)) return 0; *mapindex = i; /* modify the original weights to become * weights for the derived mesh face */ - osface= dm->getTessFaceDataArray(dm, CD_ORIGSPACE); - mface= dm->getTessFaceData(dm, i, CD_MFACE); + osface = dm->getTessFaceDataArray(dm, CD_ORIGSPACE); + mface = dm->getTessFaceData(dm, i, CD_MFACE); if (osface == NULL) - mapfw[0]= mapfw[1]= mapfw[2]= mapfw[3]= 0.0f; + mapfw[0] = mapfw[1] = mapfw[2] = mapfw[3] = 0.0f; else psys_origspace_to_w(&osface[i], mface->v4, fw, mapfw); } @@ -1753,17 +1753,17 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache int mapindex; if (!psys_map_index_on_dm(dm, from, index, index_dmcache, fw, foffset, &mapindex, mapfw)) { - if (vec) { vec[0]=vec[1]=vec[2]=0.0; } - if (nor) { nor[0]=nor[1]=0.0; nor[2]=1.0; } - if (orco) { orco[0]=orco[1]=orco[2]=0.0; } - if (ornor) { ornor[0]=ornor[1]=0.0; ornor[2]=1.0; } - if (utan) { utan[0]=utan[1]=utan[2]=0.0; } - if (vtan) { vtan[0]=vtan[1]=vtan[2]=0.0; } + if (vec) { vec[0] = vec[1] = vec[2] = 0.0; } + if (nor) { nor[0] = nor[1] = 0.0; nor[2] = 1.0; } + if (orco) { orco[0] = orco[1] = orco[2] = 0.0; } + if (ornor) { ornor[0] = ornor[1] = 0.0; ornor[2] = 1.0; } + if (utan) { utan[0] = utan[1] = utan[2] = 0.0; } + if (vtan) { vtan[0] = vtan[1] = vtan[2] = 0.0; } return; } - orcodata= dm->getVertDataArray(dm, CD_ORCO); + orcodata = dm->getVertDataArray(dm, CD_ORCO); if (from == PART_FROM_VERT) { dm->getVertCo(dm, mapindex, vec); @@ -1782,8 +1782,8 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache } if (utan && vtan) { - utan[0]= utan[1]= utan[2]= 0.0f; - vtan[0]= vtan[1]= vtan[2]= 0.0f; + utan[0] = utan[1] = utan[2] = 0.0f; + vtan[0] = vtan[1] = vtan[2] = 0.0f; } } else { /* PART_FROM_FACE / PART_FROM_VOLUME */ @@ -1791,14 +1791,14 @@ void psys_particle_on_dm(DerivedMesh *dm, int from, int index, int index_dmcache MTFace *mtface; MVert *mvert; - mface=dm->getTessFaceData(dm, mapindex, CD_MFACE); - mvert=dm->getVertDataArray(dm, CD_MVERT); - mtface=CustomData_get_layer(&dm->faceData, CD_MTFACE); + mface = dm->getTessFaceData(dm, mapindex, CD_MFACE); + mvert = dm->getVertDataArray(dm, CD_MVERT); + mtface = CustomData_get_layer(&dm->faceData, CD_MTFACE); if (mtface) mtface += mapindex; - if (from==PART_FROM_VOLUME) { + if (from == PART_FROM_VOLUME) { psys_interpolate_face(mvert, mface, mtface, orcodata, mapfw, vec, tmpnor, utan, vtan, orco, ornor); if (nor) copy_v3_v3(nor, tmpnor); @@ -1828,10 +1828,10 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) ModifierData *md; ParticleSystemModifierData *psmd; - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_ParticleSystem) { - psmd= (ParticleSystemModifierData*) md; - if (psmd->psys==psys) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_ParticleSystem) { + psmd = (ParticleSystemModifierData *) md; + if (psmd->psys == psys) { return psmd; } } @@ -1845,7 +1845,7 @@ ParticleSystemModifierData *psys_get_modifier(Object *ob, ParticleSystem *psys) static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float *UNUSED(fuv), float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { /* TODO */ - float zerovec[3]={0.0f, 0.0f, 0.0f}; + float zerovec[3] = {0.0f, 0.0f, 0.0f}; if (vec) { copy_v3_v3(vec, zerovec); } @@ -1871,7 +1871,7 @@ static void psys_particle_on_shape(int UNUSED(distr), int UNUSED(index), float * void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float *fuv, float foffset, float *vec, float *nor, float *utan, float *vtan, float *orco, float *ornor) { if (psmd) { - if (psmd->psys->part->distr==PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) { + if (psmd->psys->part->distr == PART_DISTR_GRID && psmd->psys->part->from != PART_FROM_VERT) { if (vec) copy_v3_v3(vec, fuv); @@ -1892,34 +1892,34 @@ void psys_particle_on_emitter(ParticleSystemModifierData *psmd, int from, int in static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float time, float freq, float shape, float amplitude, float flat, short type, short axis, float obmat[][4], int smooth_start) { - float kink[3]={1.f, 0.f, 0.f}, par_vec[3], q1[4]={1.f, 0.f, 0.f, 0.f}; - float t, dt=1.f, result[3]; + float kink[3] = {1.f, 0.f, 0.f}, par_vec[3], q1[4] = {1.f, 0.f, 0.f, 0.f}; + float t, dt = 1.f, result[3]; if (par == NULL || type == PART_KINK_NO) return; CLAMP(time, 0.f, 1.f); - if (shape!=0.0f && type!=PART_KINK_BRAID) { - if (shape<0.0f) - time= (float)pow(time, 1.f+shape); + if (shape != 0.0f && type != PART_KINK_BRAID) { + if (shape < 0.0f) + time = (float)pow(time, 1.f + shape); else - time= (float)pow(time, 1.f/(1.f-shape)); + time = (float)pow(time, 1.f / (1.f - shape)); } - t = time * freq *(float)M_PI; + t = time * freq * (float)M_PI; if (smooth_start) { dt = fabs(t); /* smooth the beginning of kink */ CLAMP(dt, 0.f, (float)M_PI); - dt = sin(dt/2.f); + dt = sin(dt / 2.f); } if (type != PART_KINK_RADIAL) { float temp[3]; - kink[axis]=1.f; + kink[axis] = 1.f; if (obmat) mul_mat3_m4_v3(obmat, kink); @@ -1937,124 +1937,124 @@ static void do_kink(ParticleKey *state, ParticleKey *par, float *par_rot, float sub_v3_v3v3(par_vec, par->co, state->co); switch (type) { - case PART_KINK_CURL: - { - negate_v3(par_vec); + case PART_KINK_CURL: + { + negate_v3(par_vec); - if (flat > 0.f) { - float proj[3]; - project_v3_v3v3(proj, par_vec, par->vel); - madd_v3_v3fl(par_vec, proj, -flat); + if (flat > 0.f) { + float proj[3]; + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(par_vec, proj, -flat); - project_v3_v3v3(proj, par_vec, kink); - madd_v3_v3fl(par_vec, proj, -flat); - } + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(par_vec, proj, -flat); + } - axis_angle_to_quat(q1, kink, (float)M_PI/2.f); + axis_angle_to_quat(q1, kink, (float)M_PI / 2.f); - mul_qt_v3(q1, par_vec); - - madd_v3_v3fl(par_vec, kink, amplitude); - - /* rotate kink vector around strand tangent */ - if (t!=0.f) { - axis_angle_to_quat(q1, par->vel, t); mul_qt_v3(q1, par_vec); + + madd_v3_v3fl(par_vec, kink, amplitude); + + /* rotate kink vector around strand tangent */ + if (t != 0.f) { + axis_angle_to_quat(q1, par->vel, t); + mul_qt_v3(q1, par_vec); + } + + add_v3_v3v3(result, par->co, par_vec); + break; } + case PART_KINK_RADIAL: + { + if (flat > 0.f) { + float proj[3]; + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } - add_v3_v3v3(result, par->co, par_vec); - break; - } - case PART_KINK_RADIAL: - { - if (flat > 0.f) { - float proj[3]; - /* flatten along strand */ - project_v3_v3v3(proj, par_vec, par->vel); - madd_v3_v3fl(result, proj, flat); + madd_v3_v3fl(result, par_vec, -amplitude * (float)sin(t)); + break; } + case PART_KINK_WAVE: + { + madd_v3_v3fl(result, kink, amplitude * (float)sin(t)); - madd_v3_v3fl(result, par_vec, -amplitude*(float)sin(t)); - break; - } - case PART_KINK_WAVE: - { - madd_v3_v3fl(result, kink, amplitude*(float)sin(t)); + if (flat > 0.f) { + float proj[3]; + /* flatten along wave */ + project_v3_v3v3(proj, par_vec, kink); + madd_v3_v3fl(result, proj, flat); - if (flat > 0.f) { - float proj[3]; - /* flatten along wave */ - project_v3_v3v3(proj, par_vec, kink); - madd_v3_v3fl(result, proj, flat); - - /* flatten along strand */ - project_v3_v3v3(proj, par_vec, par->vel); - madd_v3_v3fl(result, proj, flat); - } - break; - } - case PART_KINK_BRAID: - { - float y_vec[3]={0.f, 1.f, 0.f}; - float z_vec[3]={0.f, 0.f, 1.f}; - float vec_one[3], state_co[3]; - float inp_y, inp_z, length; - - if (par_rot) { - mul_qt_v3(par_rot, y_vec); - mul_qt_v3(par_rot, z_vec); + /* flatten along strand */ + project_v3_v3v3(proj, par_vec, par->vel); + madd_v3_v3fl(result, proj, flat); + } + break; } + case PART_KINK_BRAID: + { + float y_vec[3] = {0.f, 1.f, 0.f}; + float z_vec[3] = {0.f, 0.f, 1.f}; + float vec_one[3], state_co[3]; + float inp_y, inp_z, length; - negate_v3(par_vec); - normalize_v3_v3(vec_one, par_vec); + if (par_rot) { + mul_qt_v3(par_rot, y_vec); + mul_qt_v3(par_rot, z_vec); + } - inp_y=dot_v3v3(y_vec, vec_one); - inp_z=dot_v3v3(z_vec, vec_one); + negate_v3(par_vec); + normalize_v3_v3(vec_one, par_vec); - if (inp_y > 0.5f) { - copy_v3_v3(state_co, y_vec); + inp_y = dot_v3v3(y_vec, vec_one); + inp_z = dot_v3v3(z_vec, vec_one); - mul_v3_fl(y_vec, amplitude*(float)cos(t)); - mul_v3_fl(z_vec, amplitude/2.f*(float)sin(2.f*t)); + if (inp_y > 0.5f) { + copy_v3_v3(state_co, y_vec); + + mul_v3_fl(y_vec, amplitude * (float)cos(t)); + mul_v3_fl(z_vec, amplitude / 2.f * (float)sin(2.f * t)); + } + else if (inp_z > 0.0f) { + mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI / 3.f)); + madd_v3_v3fl(state_co, y_vec, -0.5f); + + mul_v3_fl(y_vec, -amplitude * (float)cos(t + (float)M_PI / 3.f)); + mul_v3_fl(z_vec, amplitude / 2.f * (float)cos(2.f * t + (float)M_PI / 6.f)); + } + else { + mul_v3_v3fl(state_co, z_vec, -(float)sin((float)M_PI / 3.f)); + madd_v3_v3fl(state_co, y_vec, -0.5f); + + mul_v3_fl(y_vec, amplitude * (float)-sin(t + (float)M_PI / 6.f)); + mul_v3_fl(z_vec, amplitude / 2.f * (float)-sin(2.f * t + (float)M_PI / 3.f)); + } + + mul_v3_fl(state_co, amplitude); + add_v3_v3(state_co, par->co); + sub_v3_v3v3(par_vec, state->co, state_co); + + length = normalize_v3(par_vec); + mul_v3_fl(par_vec, MIN2(length, amplitude / 2.f)); + + add_v3_v3v3(state_co, par->co, y_vec); + add_v3_v3(state_co, z_vec); + add_v3_v3(state_co, par_vec); + + shape = 2.f * (float)M_PI * (1.f + shape); + + if (t < shape) { + shape = t / shape; + shape = (float)sqrt((double)shape); + interp_v3_v3v3(result, result, state_co, shape); + } + else { + copy_v3_v3(result, state_co); + } + break; } - else if (inp_z > 0.0f) { - mul_v3_v3fl(state_co, z_vec, (float)sin((float)M_PI/3.f)); - madd_v3_v3fl(state_co, y_vec, -0.5f); - - mul_v3_fl(y_vec, -amplitude * (float)cos(t + (float)M_PI/3.f)); - mul_v3_fl(z_vec, amplitude/2.f * (float)cos(2.f*t + (float)M_PI/6.f)); - } - else { - mul_v3_v3fl(state_co, z_vec, -(float)sin((float)M_PI/3.f)); - madd_v3_v3fl(state_co, y_vec, -0.5f); - - mul_v3_fl(y_vec, amplitude * (float)-sin(t + (float)M_PI/6.f)); - mul_v3_fl(z_vec, amplitude/2.f * (float)-sin(2.f*t + (float)M_PI/3.f)); - } - - mul_v3_fl(state_co, amplitude); - add_v3_v3(state_co, par->co); - sub_v3_v3v3(par_vec, state->co, state_co); - - length = normalize_v3(par_vec); - mul_v3_fl(par_vec, MIN2(length, amplitude/2.f)); - - add_v3_v3v3(state_co, par->co, y_vec); - add_v3_v3(state_co, z_vec); - add_v3_v3(state_co, par_vec); - - shape = 2.f*(float)M_PI * (1.f+shape); - - if (tco, state->co, par->co, clump); } @@ -2108,12 +2108,12 @@ void precalc_guides(ParticleSimulationData *sim, ListBase *effectors) pd_point_from_particle(sim, pa, &state, &point); - for (eff = effectors->first; eff; eff=eff->next) { + for (eff = effectors->first; eff; eff = eff->next) { if (eff->pd->forcefield != PFIELD_GUIDE) continue; if (!eff->guide_data) - eff->guide_data = MEM_callocN(sizeof(GuideEffectorData)*psys->totpart, "GuideEffectorData"); + eff->guide_data = MEM_callocN(sizeof(GuideEffectorData) * psys->totpart, "GuideEffectorData"); data = eff->guide_data + p; @@ -2139,78 +2139,78 @@ int do_guides(ListBase *effectors, ParticleKey *state, int index, float time) float guidetime, radius, weight, angle, totstrength = 0.0f; float vec_to_point[3]; - if (effectors) for (eff = effectors->first; eff; eff=eff->next) { - pd = eff->pd; + if (effectors) for (eff = effectors->first; eff; eff = eff->next) { + pd = eff->pd; - if (pd->forcefield != PFIELD_GUIDE) - continue; + if (pd->forcefield != PFIELD_GUIDE) + continue; - data = eff->guide_data + index; + data = eff->guide_data + index; - if (data->strength <= 0.0f) - continue; + if (data->strength <= 0.0f) + continue; - guidetime = time / (1.0f - pd->free_end); + guidetime = time / (1.0f - pd->free_end); - if (guidetime>1.0f) - continue; + if (guidetime > 1.0f) + continue; - cu = (Curve*)eff->ob->data; + cu = (Curve *)eff->ob->data; - if (pd->flag & PFIELD_GUIDE_PATH_ADD) { - if (where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight)==0) - return 0; - } - else { - if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight)==0) - return 0; - } - - mul_m4_v3(eff->ob->obmat, guidevec); - mul_mat3_m4_v3(eff->ob->obmat, guidedir); - - normalize_v3(guidedir); - - copy_v3_v3(vec_to_point, data->vec_to_point); - - if (guidetime != 0.0f) { - /* curve direction */ - cross_v3_v3v3(temp, eff->guide_dir, guidedir); - angle = dot_v3v3(eff->guide_dir, guidedir)/(len_v3(eff->guide_dir)); - angle = saacos(angle); - axis_angle_to_quat(rot2, temp, angle); - mul_qt_v3(rot2, vec_to_point); - - /* curve tilt */ - axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]); - mul_qt_v3(rot2, vec_to_point); - } - - /* curve taper */ - if (cu->taperobj) - mul_v3_fl(vec_to_point, calc_taper(eff->scene, cu->taperobj, (int)(data->strength*guidetime*100.0f), 100)); - - else { /* curve size*/ - if (cu->flag & CU_PATH_RADIUS) { - mul_v3_fl(vec_to_point, radius); + if (pd->flag & PFIELD_GUIDE_PATH_ADD) { + if (where_on_path(eff->ob, data->strength * guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0) + return 0; } + else { + if (where_on_path(eff->ob, guidetime, guidevec, guidedir, NULL, &radius, &weight) == 0) + return 0; + } + + mul_m4_v3(eff->ob->obmat, guidevec); + mul_mat3_m4_v3(eff->ob->obmat, guidedir); + + normalize_v3(guidedir); + + copy_v3_v3(vec_to_point, data->vec_to_point); + + if (guidetime != 0.0f) { + /* curve direction */ + cross_v3_v3v3(temp, eff->guide_dir, guidedir); + angle = dot_v3v3(eff->guide_dir, guidedir) / (len_v3(eff->guide_dir)); + angle = saacos(angle); + axis_angle_to_quat(rot2, temp, angle); + mul_qt_v3(rot2, vec_to_point); + + /* curve tilt */ + axis_angle_to_quat(rot2, guidedir, guidevec[3] - eff->guide_loc[3]); + mul_qt_v3(rot2, vec_to_point); + } + + /* curve taper */ + if (cu->taperobj) + mul_v3_fl(vec_to_point, BKE_displist_calc_taper(eff->scene, cu->taperobj, (int)(data->strength * guidetime * 100.0f), 100)); + + else { /* curve size*/ + if (cu->flag & CU_PATH_RADIUS) { + mul_v3_fl(vec_to_point, radius); + } + } + par.co[0] = par.co[1] = par.co[2] = 0.0f; + copy_v3_v3(key.co, vec_to_point); + do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); + do_clump(&key, &par, guidetime, pd->clump_fac, pd->clump_pow, 1.0f); + copy_v3_v3(vec_to_point, key.co); + + add_v3_v3(vec_to_point, guidevec); + + //sub_v3_v3v3(pa_loc, pa_loc, pa_zero); + madd_v3_v3fl(effect, vec_to_point, data->strength); + madd_v3_v3fl(veffect, guidedir, data->strength); + totstrength += data->strength; + + if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT) + totstrength *= weight; } - par.co[0] = par.co[1] = par.co[2] = 0.0f; - copy_v3_v3(key.co, vec_to_point); - do_kink(&key, &par, 0, guidetime, pd->kink_freq, pd->kink_shape, pd->kink_amp, 0.f, pd->kink, pd->kink_axis, 0, 0); - do_clump(&key, &par, guidetime, pd->clump_fac, pd->clump_pow, 1.0f); - copy_v3_v3(vec_to_point, key.co); - - add_v3_v3(vec_to_point, guidevec); - - //sub_v3_v3v3(pa_loc, pa_loc, pa_zero); - madd_v3_v3fl(effect, vec_to_point, data->strength); - madd_v3_v3fl(veffect, guidedir, data->strength); - totstrength += data->strength; - - if (pd->flag & PFIELD_GUIDE_PATH_WEIGHT) - totstrength *= weight; - } if (totstrength != 0.0f) { if (totstrength > 1.0f) @@ -2232,13 +2232,13 @@ static void do_rough(float *loc, float mat[4][4], float t, float fac, float size float rco[3]; if (thres != 0.0f) - if ((float)fabs((float)(-1.5f+loc[0]+loc[1]+loc[2]))<1.5f*thres) return; + if ((float)fabs((float)(-1.5f + loc[0] + loc[1] + loc[2])) < 1.5f * thres) return; copy_v3_v3(rco, loc); mul_v3_fl(rco, t); - rough[0]=-1.0f+2.0f*BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2); - rough[1]=-1.0f+2.0f*BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2); - rough[2]=-1.0f+2.0f*BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2); + rough[0] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[0], rco[1], rco[2], 2, 0, 2); + rough[1] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[1], rco[2], rco[0], 2, 0, 2); + rough[2] = -1.0f + 2.0f * BLI_gTurbulence(size, rco[2], rco[0], rco[1], 2, 0, 2); madd_v3_v3fl(state->co, mat[0], fac * rough[0]); madd_v3_v3fl(state->co, mat[1], fac * rough[1]); @@ -2249,10 +2249,10 @@ static void do_rough_end(float *loc, float mat[4][4], float t, float fac, float float rough[2]; float roughfac; - roughfac=fac*(float)pow((double)t, shape); + roughfac = fac * (float)pow((double)t, shape); copy_v2_v2(rough, loc); - rough[0]=-1.0f+2.0f*rough[0]; - rough[1]=-1.0f+2.0f*rough[1]; + rough[0] = -1.0f + 2.0f * rough[0]; + rough[1] = -1.0f + 2.0f * rough[1]; mul_v2_fl(rough, roughfac); madd_v3_v3fl(state->co, mat[0], rough[0]); @@ -2268,23 +2268,23 @@ static void do_path_effectors(ParticleSimulationData *sim, int i, ParticleCacheK if (sim->psys->flag & PSYS_HAIR_DYNAMICS) return; - copy_v3_v3(eff_key.co, (ca-1)->co); - copy_v3_v3(eff_key.vel, (ca-1)->vel); - copy_qt_qt(eff_key.rot, (ca-1)->rot); + copy_v3_v3(eff_key.co, (ca - 1)->co); + copy_v3_v3(eff_key.vel, (ca - 1)->vel); + copy_qt_qt(eff_key.rot, (ca - 1)->rot); - pd_point_from_particle(sim, sim->psys->particles+i, &eff_key, &epoint); + pd_point_from_particle(sim, sim->psys->particles + i, &eff_key, &epoint); pdDoEffectors(sim->psys->effectors, sim->colliders, sim->psys->part->effector_weights, &epoint, force, NULL); - mul_v3_fl(force, effector*powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); + mul_v3_fl(force, effector * powf((float)k / (float)steps, 100.0f * sim->psys->part->eff_hair) / (float)steps); add_v3_v3(force, vec); normalize_v3(force); if (k < steps) - sub_v3_v3v3(vec, (ca+1)->co, ca->co); + sub_v3_v3v3(vec, (ca + 1)->co, ca->co); - madd_v3_v3v3fl(ca->co, (ca-1)->co, force, *length); + madd_v3_v3v3fl(ca->co, (ca - 1)->co, force, *length); if (k < steps) *length = len_v3(vec); @@ -2296,10 +2296,10 @@ static int check_path_length(int k, ParticleCacheKey *keys, ParticleCacheKey *st add_v3_v3v3(state->co, (state - 1)->co, dvec); keys->steps = k; /* something over the maximum step value */ - return k=100000; + return k = 100000; } else { - *cur_length+=length; + *cur_length += length; return k; } } @@ -2308,7 +2308,7 @@ static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, P copy_v3_v3(child->co, cpa->fuv); mul_v3_fl(child->co, radius); - child->co[0]*=flat; + child->co[0] *= flat; copy_v3_v3(child->vel, par->vel); @@ -2323,7 +2323,7 @@ static void offset_child(ChildParticle *cpa, ParticleKey *par, float *par_rot, P } float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) { - float *vg=0; + float *vg = 0; if (vgroup < 0) { /* hair dynamics pinning vgroup */ @@ -2332,15 +2332,15 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) else if (psys->vgroup[vgroup]) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert) { - int totvert=dm->getNumVerts(dm), i; - vg=MEM_callocN(sizeof(float)*totvert, "vg_cache"); - if (psys->vg_neg&(1<vgroup[vgroup] - 1); + int totvert = dm->getNumVerts(dm), i; + vg = MEM_callocN(sizeof(float) * totvert, "vg_cache"); + if (psys->vg_neg & (1 << vgroup)) { + for (i = 0; i < totvert; i++) + vg[i] = 1.0f - defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } else { - for (i=0; ivgroup[vgroup] - 1); + for (i = 0; i < totvert; i++) + vg[i] = defvert_find_weight(&dvert[i], psys->vgroup[vgroup] - 1); } } } @@ -2348,29 +2348,29 @@ float *psys_cache_vgroup(DerivedMesh *dm, ParticleSystem *psys, int vgroup) } void psys_find_parents(ParticleSimulationData *sim) { - ParticleSettings *part=sim->psys->part; + ParticleSettings *part = sim->psys->part; KDTree *tree; ChildParticle *cpa; - int p, totparent, totchild=sim->psys->totchild; + int p, totparent, totchild = sim->psys->totchild; float co[3], orco[3]; - int from=PART_FROM_FACE; - totparent=(int)(totchild*part->parents*0.3f); + int from = PART_FROM_FACE; + totparent = (int)(totchild * part->parents * 0.3f); if (G.rendering && part->child_nbr && part->ren_child_nbr) - totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; - tree=BLI_kdtree_new(totparent); + tree = BLI_kdtree_new(totparent); - for (p=0, cpa=sim->psys->child; ppsys->child; p < totparent; p++, cpa++) { psys_particle_on_emitter(sim->psmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0); BLI_kdtree_insert(tree, p, orco, NULL); } BLI_kdtree_balance(tree); - for (; ppsmd, from, cpa->num, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co, 0, 0, 0, orco, 0); - cpa->parent=BLI_kdtree_find_nearest(tree, orco, NULL, NULL); + cpa->parent = BLI_kdtree_find_nearest(tree, orco, NULL, NULL); } BLI_kdtree_free(tree); @@ -2399,7 +2399,7 @@ static void get_strand_normal(Material *ma, const float surfnor[3], float surfdi if (ma->strand_surfnor > 0.0f) { if (ma->strand_surfnor > surfdist) { - blend= (ma->strand_surfnor - surfdist)/ma->strand_surfnor; + blend = (ma->strand_surfnor - surfdist) / ma->strand_surfnor; interp_v3_v3v3(vnor, vnor, surfnor, blend); normalize_v3(vnor); } @@ -2410,64 +2410,64 @@ static void get_strand_normal(Material *ma, const float surfnor[3], float surfdi static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float cfra, int editupdate) { - ParticleThreadContext *ctx= threads[0].ctx; + ParticleThreadContext *ctx = threads[0].ctx; /* Object *ob= ctx->sim.ob; */ - ParticleSystem *psys= ctx->sim.psys; + ParticleSystem *psys = ctx->sim.psys; ParticleSettings *part = psys->part; /* ParticleEditSettings *pset = &scene->toolsettings->particle; */ - int totparent=0, between=0; + int totparent = 0, between = 0; int steps = (int)pow(2.0, (double)part->draw_step); int totchild = psys->totchild; - int i, seed, totthread= threads[0].tot; + int i, seed, totthread = threads[0].tot; /*---start figuring out what is actually wanted---*/ if (psys_in_edit_mode(scene, psys)) { ParticleEditSettings *pset = &scene->toolsettings->particle; - if (psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) - totchild=0; + if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) + totchild = 0; steps = (int)pow(2.0, (double)pset->draw_step); } - if (totchild && part->childtype==PART_CHILD_FACES) { - totparent=(int)(totchild*part->parents*0.3f); + if (totchild && part->childtype == PART_CHILD_FACES) { + totparent = (int)(totchild * part->parents * 0.3f); if (G.rendering && part->child_nbr && part->ren_child_nbr) - totparent*=(float)part->child_nbr/(float)part->ren_child_nbr; + totparent *= (float)part->child_nbr / (float)part->ren_child_nbr; /* part->parents could still be 0 so we can't test with totparent */ - between=1; + between = 1; } if (psys->renderdata) - steps=(int)pow(2.0, (double)part->ren_step); + steps = (int)pow(2.0, (double)part->ren_step); else { - totchild=(int)((float)totchild*(float)part->disp/100.0f); - totparent=MIN2(totparent, totchild); + totchild = (int)((float)totchild * (float)part->disp / 100.0f); + totparent = MIN2(totparent, totchild); } - if (totchild==0) return 0; + if (totchild == 0) return 0; /* init random number generator */ - seed= 31415926 + ctx->sim.psys->seed; + seed = 31415926 + ctx->sim.psys->seed; if (ctx->editupdate || totchild < 10000) - totthread= 1; + totthread = 1; - for (i=0; ibetween= between; - ctx->steps= steps; - ctx->totchild= totchild; - ctx->totparent= totparent; - ctx->parent_pass= 0; - ctx->cfra= cfra; - ctx->editupdate= editupdate; + ctx->between = between; + ctx->steps = steps; + ctx->totchild = totchild; + ctx->totparent = totparent; + ctx->parent_pass = 0; + ctx->cfra = cfra; + ctx->editupdate = editupdate; psys->lattice = psys_get_lattice(&ctx->sim); @@ -2483,7 +2483,7 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c /* set correct ipo timing */ #if 0 // XXX old animation system - if (part->flag&PART_ABS_TIME && part->ipo) { + if (part->flag & PART_ABS_TIME && part->ipo) { calc_ipo(part->ipo, cfra); execute_ipo((ID *)part, part->ipo); } @@ -2495,15 +2495,15 @@ static int psys_threads_init_path(ParticleThread *threads, Scene *scene, float c /* note: this function must be thread safe, except for branching! */ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle *cpa, ParticleCacheKey *child_keys, int i) { - ParticleThreadContext *ctx= thread->ctx; - Object *ob= ctx->sim.ob; + ParticleThreadContext *ctx = thread->ctx; + Object *ob = ctx->sim.ob; ParticleSystem *psys = ctx->sim.psys; ParticleSettings *part = psys->part; - ParticleCacheKey **cache= psys->childcache; - ParticleCacheKey **pcache= psys_in_edit_mode(ctx->sim.scene, psys) ? psys->edit->pathcache : psys->pathcache; + ParticleCacheKey **cache = psys->childcache; + ParticleCacheKey **pcache = psys_in_edit_mode(ctx->sim.scene, psys) ? psys->edit->pathcache : psys->pathcache; ParticleCacheKey *child, *par = NULL, *key[4]; ParticleTexture ptex; - float *cpa_fuv=0, *par_rot=0, rot[4]; + float *cpa_fuv = 0, *par_rot = 0, rot[4]; float orco[3], ornor[3], hairmat[4][4], t, dvec[3], off1[4][3], off2[4][3]; float length, max_length = 1.0f, cur_length = 0.0f; float eff_length, eff_vec[3], weight[4]; @@ -2516,7 +2516,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (ctx->between) { ParticleData *pa = psys->particles + cpa->pa[0]; int w, needupdate; - float foffset, wsum=0.f; + float foffset, wsum = 0.f; float co[3]; float p_min = part->parting_min; float p_max = part->parting_max; @@ -2524,11 +2524,11 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle float p_fac = part->parents > 0.f ? 0.f : part->parting_fac; if (ctx->editupdate) { - needupdate= 0; - w= 0; - while (w<4 && cpa->pa[w]>=0) { + needupdate = 0; + w = 0; + while (w < 4 && cpa->pa[w] >= 0) { if (psys->edit->points[cpa->pa[w]].flag & PEP_EDIT_RECALC) { - needupdate= 1; + needupdate = 1; break; } w++; @@ -2537,11 +2537,11 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (!needupdate) return; else - memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys) * (ctx->steps + 1)); } /* get parent paths */ - for (w=0; w<4; w++) { + for (w = 0; w < 4; w++) { if (cpa->pa[w] >= 0) { key[w] = pcache[cpa->pa[w]]; weight[w] = cpa->w[w]; @@ -2554,20 +2554,20 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle /* modify weights to create parting */ if (p_fac > 0.f) { - for (w=0; w<4; w++) { + for (w = 0; w < 4; w++) { if (w && weight[w] > 0.f) { float d; if (part->flag & PART_CHILD_LONG_HAIR) { /* For long hair use tip distance/root distance as parting factor instead of root to tip angle. */ float d1 = len_v3v3(key[0]->co, key[w]->co); - float d2 = len_v3v3((key[0]+key[0]->steps-1)->co, (key[w]+key[w]->steps-1)->co); + float d2 = len_v3v3((key[0] + key[0]->steps - 1)->co, (key[w] + key[w]->steps - 1)->co); - d = d1 > 0.f ? d2/d1 - 1.f : 10000.f; + d = d1 > 0.f ? d2 / d1 - 1.f : 10000.f; } else { float v1[3], v2[3]; - sub_v3_v3v3(v1, (key[0]+key[0]->steps-1)->co, key[0]->co); - sub_v3_v3v3(v2, (key[w]+key[w]->steps-1)->co, key[w]->co); + sub_v3_v3v3(v1, (key[0] + key[0]->steps - 1)->co, key[0]->co); + sub_v3_v3v3(v2, (key[w] + key[w]->steps - 1)->co, key[w]->co); normalize_v3(v1); normalize_v3(v2); @@ -2575,7 +2575,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } if (p_max > p_min) - d = (d - p_min)/(p_max - p_min); + d = (d - p_min) / (p_max - p_min); else d = (d - p_min) <= 0.f ? 0.f : 1.f; @@ -2586,7 +2586,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } wsum += weight[w]; } - for (w=0; w<4; w++) + for (w = 0; w < 4; w++) weight[w] /= wsum; interp_v4_v4v4(weight, cpa->w, weight, p_fac); @@ -2603,7 +2603,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle mul_m4_v3(ob->obmat, co); - for (w=0; w<4; w++) + for (w = 0; w < 4; w++) sub_v3_v3v3(off1[w], co, key[w]->co); psys_mat_hair_to_global(ob, ctx->sim.psmd->dm, psys->part->from, pa, hairmat); @@ -2615,7 +2615,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (!(psys->edit->points[cpa->parent].flag & PEP_EDIT_RECALC)) return; - memset(child_keys, 0, sizeof(*child_keys)*(ctx->steps+1)); + memset(child_keys, 0, sizeof(*child_keys) * (ctx->steps + 1)); } /* get the parent path */ @@ -2642,66 +2642,66 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle } /* create the child path */ - for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { + for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) { if (ctx->between) { - int w=0; + int w = 0; zero_v3(child->co); zero_v3(child->vel); unit_qt(child->rot); - for (w=0; w<4; w++) { + for (w = 0; w < 4; w++) { copy_v3_v3(off2[w], off1[w]); if (part->flag & PART_CHILD_LONG_HAIR) { /* Use parent rotation (in addition to emission location) to determine child offset. */ if (k) - mul_qt_v3((key[w]+k)->rot, off2[w]); + mul_qt_v3((key[w] + k)->rot, off2[w]); /* Fade the effect of rotation for even lengths in the end */ - project_v3_v3v3(dvec, off2[w], (key[w]+k)->vel); - madd_v3_v3fl(off2[w], dvec, -(float)k/(float)ctx->steps); + project_v3_v3v3(dvec, off2[w], (key[w] + k)->vel); + madd_v3_v3fl(off2[w], dvec, -(float)k / (float)ctx->steps); } - add_v3_v3(off2[w], (key[w]+k)->co); + add_v3_v3(off2[w], (key[w] + k)->co); } /* child position is the weighted sum of parent positions */ interp_v3_v3v3v3v3(child->co, off2[0], off2[1], off2[2], off2[3], weight); - interp_v3_v3v3v3v3(child->vel, (key[0]+k)->vel, (key[1]+k)->vel, (key[2]+k)->vel, (key[3]+k)->vel, weight); + interp_v3_v3v3v3v3(child->vel, (key[0] + k)->vel, (key[1] + k)->vel, (key[2] + k)->vel, (key[3] + k)->vel, weight); - copy_qt_qt(child->rot, (key[0]+k)->rot); + copy_qt_qt(child->rot, (key[0] + k)->rot); } else { if (k) { - mul_qt_qtqt(rot, (key[0]+k)->rot, key[0]->rot); + mul_qt_qtqt(rot, (key[0] + k)->rot, key[0]->rot); par_rot = rot; } else { par_rot = key[0]->rot; } /* offset the child from the parent position */ - offset_child(cpa, (ParticleKey*)(key[0]+k), par_rot, (ParticleKey*)child, part->childflat, part->childrad); + offset_child(cpa, (ParticleKey *)(key[0] + k), par_rot, (ParticleKey *)child, part->childflat, part->childrad); } - child->time = (float)k/(float)ctx->steps; + child->time = (float)k / (float)ctx->steps; } /* apply effectors */ if (part->flag & PART_CHILD_EFFECT) { - for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { + for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) { if (k) { do_path_effectors(&ctx->sim, cpa->pa[0], child, k, ctx->steps, child_keys->co, ptex.effector, 0.0f, ctx->cfra, &eff_length, eff_vec); } else { - sub_v3_v3v3(eff_vec, (child+1)->co, child->co); + sub_v3_v3v3(eff_vec, (child + 1)->co, child->co); eff_length = len_v3(eff_vec); } } } - for (k=0, child=child_keys; k<=ctx->steps; k++, child++) { - t = (float)k/(float)ctx->steps; + for (k = 0, child = child_keys; k <= ctx->steps; k++, child++) { + t = (float)k / (float)ctx->steps; if (ctx->totparent) /* this is now threadsafe, virtual parents are calculated before rest of children */ @@ -2711,7 +2711,7 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle if (par) { if (k) { - mul_qt_qtqt(rot, (par+k)->rot, par->rot); + mul_qt_qtqt(rot, (par + k)->rot, par->rot); par_rot = rot; } else { @@ -2724,21 +2724,21 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle do_child_modifiers(&ctx->sim, &ptex, (ParticleKey *)par, par_rot, cpa, orco, hairmat, (ParticleKey *)child, t); /* we have to correct velocity because of kink & clump */ - if (k>1) { - sub_v3_v3v3((child-1)->vel, child->co, (child-2)->co); - mul_v3_fl((child-1)->vel, 0.5); + if (k > 1) { + sub_v3_v3v3((child - 1)->vel, child->co, (child - 2)->co); + mul_v3_fl((child - 1)->vel, 0.5); if (ctx->ma && (part->draw_col == PART_DRAW_COL_MAT)) - get_strand_normal(ctx->ma, ornor, cur_length, (child-1)->vel); + get_strand_normal(ctx->ma, ornor, cur_length, (child - 1)->vel); } if (k == ctx->steps) - sub_v3_v3v3(child->vel, child->co, (child-1)->co); + sub_v3_v3v3(child->vel, child->co, (child - 1)->co); /* check if path needs to be cut before actual end of data points */ if (k) { - sub_v3_v3v3(dvec, child->co, (child-1)->co); - length = 1.0f/(float)ctx->steps; + sub_v3_v3v3(dvec, child->co, (child - 1)->co); + length = 1.0f / (float)ctx->steps; k = check_path_length(k, child_keys, child, max_length, &cur_length, length, dvec); } else { @@ -2760,20 +2760,20 @@ static void psys_thread_create_path(ParticleThread *thread, struct ChildParticle static void *exec_child_path_cache(void *data) { - ParticleThread *thread= (ParticleThread*)data; - ParticleThreadContext *ctx= thread->ctx; - ParticleSystem *psys= ctx->sim.psys; - ParticleCacheKey **cache= psys->childcache; + ParticleThread *thread = (ParticleThread *)data; + ParticleThreadContext *ctx = thread->ctx; + ParticleSystem *psys = ctx->sim.psys; + ParticleCacheKey **cache = psys->childcache; ChildParticle *cpa; - int i, totchild= ctx->totchild, first= 0; + int i, totchild = ctx->totchild, first = 0; if (thread->tot > 1) { - first= ctx->parent_pass? 0 : ctx->totparent; - totchild= ctx->parent_pass? ctx->totparent : ctx->totchild; + first = ctx->parent_pass ? 0 : ctx->totparent; + totchild = ctx->parent_pass ? ctx->totparent : ctx->totchild; } - cpa= psys->child + first + thread->num; - for (i=first+thread->num; itot, cpa+=thread->tot) + cpa = psys->child + first + thread->num; + for (i = first + thread->num; i < totchild; i += thread->tot, cpa += thread->tot) psys_thread_create_path(thread, cpa, cache[i], i); return 0; @@ -2789,16 +2789,16 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd if (sim->psys->flag & PSYS_GLOBAL_HAIR) return; - pthreads= psys_threads_create(sim); + pthreads = psys_threads_create(sim); if (!psys_threads_init_path(pthreads, sim->scene, cfra, editupdate)) { psys_threads_free(pthreads); return; } - ctx= pthreads[0].ctx; - totchild= ctx->totchild; - totparent= ctx->totparent; + ctx = pthreads[0].ctx; + totchild = ctx->totchild; + totparent = ctx->totparent; if (editupdate && sim->psys->childcache && totchild == sim->psys->totchildcache) { ; /* just overwrite the existing cache */ @@ -2806,11 +2806,11 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd else { /* clear out old and create new empty path cache */ free_child_path_cache(sim->psys); - sim->psys->childcache= psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps+1); + sim->psys->childcache = psys_alloc_path_cache_buffers(&sim->psys->childcachebufs, totchild, ctx->steps + 1); sim->psys->totchildcache = totchild; } - totthread= pthreads[0].tot; + totthread = pthreads[0].tot; if (totthread > 1) { @@ -2818,20 +2818,20 @@ void psys_cache_child_paths(ParticleSimulationData *sim, float cfra, int editupd if (totparent) { BLI_init_threads(&threads, exec_child_path_cache, totthread); - for (i=0; iparent_pass = 1; BLI_insert_thread(&threads, &pthreads[i]); } BLI_end_threads(&threads); - for (i=0; iparent_pass = 0; } BLI_init_threads(&threads, exec_child_path_cache, totthread); - for (i=0; ico, key1->co); - normalize_v3(prev_tangent); - unit_qt(key1->rot); - break; - default: - sub_v3_v3v3(tangent, key0->co, key1->co); - normalize_v3(tangent); + case 0: + /* start from second key */ + break; + case 1: + /* calculate initial tangent for incremental rotations */ + sub_v3_v3v3(prev_tangent, key0->co, key1->co); + normalize_v3(prev_tangent); + unit_qt(key1->rot); + break; + default: + sub_v3_v3v3(tangent, key0->co, key1->co); + normalize_v3(tangent); - cosangle= dot_v3v3(tangent, prev_tangent); + cosangle = dot_v3v3(tangent, prev_tangent); - /* note we do the comparison on cosangle instead of - * angle, since floating point accuracy makes it give - * different results across platforms */ - if (cosangle > 0.999999f) { - copy_v4_v4(key1->rot, key2->rot); - } - else { - angle= saacos(cosangle); - cross_v3_v3v3(normal, prev_tangent, tangent); - axis_angle_to_quat(q, normal, angle); - mul_qt_qtqt(key1->rot, q, key2->rot); - } + /* note we do the comparison on cosangle instead of + * angle, since floating point accuracy makes it give + * different results across platforms */ + if (cosangle > 0.999999f) { + copy_v4_v4(key1->rot, key2->rot); + } + else { + angle = saacos(cosangle); + cross_v3_v3v3(normal, prev_tangent, tangent); + axis_angle_to_quat(q, normal, angle); + mul_qt_qtqt(key1->rot, q, key2->rot); + } - copy_v3_v3(prev_tangent, tangent); + copy_v3_v3(prev_tangent, tangent); } } @@ -2892,7 +2892,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) ParticleSettings *part = psys->part; ParticleCacheKey *ca, **cache; - DerivedMesh *hair_dm = (psys->part->type==PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; + DerivedMesh *hair_dm = (psys->part->type == PART_HAIR && psys->flag & PSYS_HAIR_DYNAMICS) ? psys->hair_out_dm : NULL; ParticleKey result; @@ -2911,16 +2911,16 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) int steps = (int)pow(2.0, (double)(psys->renderdata ? part->ren_step : part->draw_step)); int totpart = psys->totpart; float length, vec[3]; - float *vg_effector= NULL; - float *vg_length= NULL, pa_length=1.0f; + float *vg_effector = NULL; + float *vg_length = NULL, pa_length = 1.0f; int keyed, baked; /* we don't have anything valid to create paths from so let's quit here */ - if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache)==0) + if ((psys->flag & PSYS_HAIR_DONE || psys->flag & PSYS_KEYED || psys->pointcache) == 0) return; if (psys_in_edit_mode(sim->scene, psys)) - if (psys->renderdata==0 && (psys->edit==NULL || pset->flag & PE_DRAW_PART)==0) + if (psys->renderdata == 0 && (psys->edit == NULL || pset->flag & PE_DRAW_PART) == 0) return; keyed = psys->flag & PSYS_KEYED; @@ -2928,15 +2928,15 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) /* clear out old and create new empty path cache */ psys_free_path_cache(psys, psys->edit); - cache= psys->pathcache= psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps+1); + cache = psys->pathcache = psys_alloc_path_cache_buffers(&psys->pathcachebufs, totpart, steps + 1); psys->lattice = psys_get_lattice(sim); - ma= give_current_material(sim->ob, psys->part->omat); + ma = give_current_material(sim->ob, psys->part->omat); if (ma && (psys->part->draw_col == PART_DRAW_COL_MAT)) copy_v3_v3(col, &ma->r); - if ((psys->flag & PSYS_GLOBAL_HAIR)==0) { - if ((psys->part->flag & PART_CHILD_EFFECT)==0) + if ((psys->flag & PSYS_GLOBAL_HAIR) == 0) { + if ((psys->part->flag & PART_CHILD_EFFECT) == 0) vg_effector = psys_cache_vgroup(psmd->dm, psys, PSYS_VG_EFFECTOR); if (!psys->totchild) @@ -2963,7 +2963,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) pind.bspline = (psys->part->flag & PART_HAIR_BSPLINE); pind.dm = hair_dm; - memset(cache[p], 0, sizeof(*cache[p])*(steps+1)); + memset(cache[p], 0, sizeof(*cache[p]) * (steps + 1)); cache[p]->steps = steps; @@ -2994,7 +2994,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) dietime = birthtime + pa_length * (dietime - birthtime); /*--interpolate actual path from data points--*/ - for (k=0, ca=cache[p]; k<=steps; k++, ca++) { + for (k = 0, ca = cache[p]; k <= steps; k++, ca++) { time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; @@ -3016,45 +3016,45 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if (!(psys->flag & PSYS_GLOBAL_HAIR)) { /* apply effectors */ if ((psys->part->flag & PART_CHILD_EFFECT) == 0) { - float effector= 1.0f; + float effector = 1.0f; if (vg_effector) - effector*= psys_particle_value_from_verts(psmd->dm, psys->part->from, pa, vg_effector); + effector *= psys_particle_value_from_verts(psmd->dm, psys->part->from, pa, vg_effector); - sub_v3_v3v3(vec, (cache[p]+1)->co, cache[p]->co); + sub_v3_v3v3(vec, (cache[p] + 1)->co, cache[p]->co); length = len_v3(vec); - for (k=1, ca=cache[p]+1; k<=steps; k++, ca++) + for (k = 1, ca = cache[p] + 1; k <= steps; k++, ca++) do_path_effectors(sim, p, ca, k, steps, cache[p]->co, effector, dfra, cfra, &length, vec); } /* apply guide curves to path data */ - if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT)==0) { - for (k=0, ca=cache[p]; k<=steps; k++, ca++) + if (sim->psys->effectors && (psys->part->flag & PART_CHILD_EFFECT) == 0) { + for (k = 0, ca = cache[p]; k <= steps; k++, ca++) /* ca is safe to cast, since only co and vel are used */ - do_guides(sim->psys->effectors, (ParticleKey*)ca, p, (float)k/(float)steps); + do_guides(sim->psys->effectors, (ParticleKey *)ca, p, (float)k / (float)steps); } /* lattices have to be calculated separately to avoid mixups between effector calculations */ if (psys->lattice) { - for (k=0, ca=cache[p]; k<=steps; k++, ca++) + for (k = 0, ca = cache[p]; k <= steps; k++, ca++) calc_latt_deform(psys->lattice, ca->co, 1.0f); } } /* finally do rotation & velocity */ - for (k=1, ca=cache[p]+1; k<=steps; k++, ca++) { + for (k = 1, ca = cache[p] + 1; k <= steps; k++, ca++) { cache_key_incremental_rotation(ca, ca - 1, ca - 2, prev_tangent, k); if (k == steps) copy_qt_qt(ca->rot, (ca - 1)->rot); /* set velocity */ - sub_v3_v3v3(ca->vel, ca->co, (ca-1)->co); + sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co); - if (k==1) - copy_v3_v3((ca-1)->vel, ca->vel); + if (k == 1) + copy_v3_v3((ca - 1)->vel, ca->vel); - ca->time = (float)k/(float)steps; + ca->time = (float)k / (float)steps; } /* First rotation is based on emitting face orientation. * This is way better than having flipping rotations resulting @@ -3070,7 +3070,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) if (psys->lattice) { end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; } if (vg_effector) @@ -3081,7 +3081,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) } void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cfra) { - ParticleCacheKey *ca, **cache= edit->pathcache; + ParticleCacheKey *ca, **cache = edit->pathcache; ParticleEditSettings *pset = &scene->toolsettings->particle; PTCacheEditPoint *point = NULL; @@ -3099,7 +3099,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf float hairmat[4][4], rotmat[3][3], prev_tangent[3] = {0.0f, 0.0f, 0.0f}; int k, i; int steps = (int)pow(2.0, (double)pset->draw_step); - int totpart = edit->totpoint, recalc_set=0; + int totpart = edit->totpoint, recalc_set = 0; float sel_col[3]; float nosel_col[3]; @@ -3108,10 +3108,10 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf if (!cache || edit->totpoint != edit->totcached) { /* clear out old and create new empty path cache */ psys_free_path_cache(edit->psys, edit); - cache= edit->pathcache= psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps+1); + cache = edit->pathcache = psys_alloc_path_cache_buffers(&edit->pathcachebufs, totpart, steps + 1); /* set flag for update (child particles check this too) */ - for (i=0, point=edit->points; ipoints; i < totpart; i++, point++) point->flag |= PEP_EDIT_RECALC; recalc_set = 1; } @@ -3119,7 +3119,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* frs_sec = (psys || edit->pid.flag & PTCACHE_VEL_PER_SEC) ? 25.0f : 1.0f; */ /* UNUSED */ if (pset->brushtype == PE_BRUSH_WEIGHT) { - ;/* use weight painting colors now... */ + ; /* use weight painting colors now... */ } else { sel_col[0] = (float)edit->sel_col[0] / 255.0f; @@ -3131,7 +3131,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*---first main loop: create all actual particles' paths---*/ - for (i=0, point=edit->points; ipoints; i < totpart; i++, pa += pa ? 1 : 0, point++) { if (edit->totcached && !(point->flag & PEP_EDIT_RECALC)) continue; @@ -3148,14 +3148,14 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* should init_particle_interpolation set this ? */ - if (pset->brushtype==PE_BRUSH_WEIGHT) { + if (pset->brushtype == PE_BRUSH_WEIGHT) { pind.hkey[0] = NULL; /* pa != NULL since the weight brush is only available for hair */ pind.hkey[1] = pa->hair; } - memset(cache[i], 0, sizeof(*cache[i])*(steps+1)); + memset(cache[i], 0, sizeof(*cache[i]) * (steps + 1)); cache[i]->steps = steps; @@ -3178,14 +3178,14 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /*--interpolate actual path from data points--*/ - for (k=0, ca=cache[i]; k<=steps; k++, ca++) { + for (k = 0, ca = cache[i]; k <= steps; k++, ca++) { time = (float)k / (float)steps; t = birthtime + time * (dietime - birthtime); result.time = -t; do_particle_interpolation(psys, i, pa, t, &pind, &result); copy_v3_v3(ca->co, result.co); - /* non-hair points are already in global space */ + /* non-hair points are already in global space */ if (psys && !(psys->flag & PSYS_GLOBAL_HAIR)) { mul_m4_v3(hairmat, ca->co); @@ -3198,7 +3198,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* set velocity */ sub_v3_v3v3(ca->vel, ca->co, (ca - 1)->co); - if (k==1) + if (k == 1) copy_v3_v3((ca - 1)->vel, ca->vel); } } @@ -3208,15 +3208,15 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf } /* selection coloring in edit mode */ - if (pset->brushtype==PE_BRUSH_WEIGHT) { + if (pset->brushtype == PE_BRUSH_WEIGHT) { float t2; - if (k==0) { + if (k == 0) { weight_to_rgb(ca->col, pind.hkey[1]->weight); } else { float w1[3], w2[3]; - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); weight_to_rgb(w1, pind.hkey[0]->weight); weight_to_rgb(w2, pind.hkey[1]->weight); @@ -3226,7 +3226,7 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf /* at the moment this is only used for weight painting. * will need to move out of this check if its used elsewhere. */ - t2 = birthtime + ((float)k/(float)steps) * (dietime - birthtime); + t2 = birthtime + ((float)k / (float)steps) * (dietime - birthtime); while (pind.hkey[1]->time < t2) pind.hkey[1]++; pind.hkey[0] = pind.hkey[1] - 1; @@ -3237,13 +3237,13 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf copy_v3_v3(ca->col, sel_col); } else { - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); interp_v3_v3v3(ca->col, sel_col, nosel_col, keytime); } } else { if ((ekey + (pind.ekey[1] - point->keys))->flag & PEK_SELECT) { - keytime = (t - (*pind.ekey[0]->time))/((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); + keytime = (t - (*pind.ekey[0]->time)) / ((*pind.ekey[1]->time) - (*pind.ekey[0]->time)); interp_v3_v3v3(ca->col, nosel_col, sel_col, keytime); } else { @@ -3269,18 +3269,18 @@ void psys_cache_edit_paths(Scene *scene, Object *ob, PTCacheEdit *edit, float cf edit->totcached = totpart; if (psys) { - ParticleSimulationData sim= {0}; - sim.scene= scene; - sim.ob= ob; - sim.psys= psys; - sim.psmd= psys_get_modifier(ob, psys); + ParticleSimulationData sim = {0}; + sim.scene = scene; + sim.ob = ob; + sim.psys = psys; + sim.psmd = psys_get_modifier(ob, psys); psys_cache_child_paths(&sim, cfra, 1); } /* clear recalc flag if set here */ if (recalc_set) { - for (i=0, point=edit->points; ipoints; i < totpart; i++, point++) point->flag &= ~PEP_EDIT_RECALC; } } @@ -3293,9 +3293,9 @@ void copy_particle_key(ParticleKey *to, ParticleKey *from, int time) memcpy(to, from, sizeof(ParticleKey)); } else { - float to_time=to->time; + float to_time = to->time; memcpy(to, from, sizeof(ParticleKey)); - to->time=to_time; + to->time = to_time; } } void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, float *time) @@ -3303,7 +3303,7 @@ void psys_get_from_key(ParticleKey *key, float *loc, float *vel, float *rot, flo if (loc) copy_v3_v3(loc, key->co); if (vel) copy_v3_v3(vel, key->vel); if (rot) copy_qt_qt(rot, key->rot); - if (time) *time=key->time; + if (time) *time = key->time; } /*-------changing particle keys from space to another-------*/ #if 0 @@ -3326,33 +3326,33 @@ static void triatomat(float *v1, float *v2, float *v3, float (*uv)[2], float mat { float det, w1, w2, d1[2], d2[2]; - memset(mat, 0, sizeof(float)*4*4); - mat[3][3]= 1.0f; + memset(mat, 0, sizeof(float) * 4 * 4); + mat[3][3] = 1.0f; /* first axis is the normal */ normal_tri_v3(mat[2], v1, v2, v3); /* second axis along (1, 0) in uv space */ if (uv) { - d1[0]= uv[1][0] - uv[0][0]; - d1[1]= uv[1][1] - uv[0][1]; - d2[0]= uv[2][0] - uv[0][0]; - d2[1]= uv[2][1] - uv[0][1]; + d1[0] = uv[1][0] - uv[0][0]; + d1[1] = uv[1][1] - uv[0][1]; + d2[0] = uv[2][0] - uv[0][0]; + d2[1] = uv[2][1] - uv[0][1]; - det = d2[0]*d1[1] - d2[1]*d1[0]; + det = d2[0] * d1[1] - d2[1] * d1[0]; if (det != 0.0f) { - det= 1.0f/det; - w1= -d2[1]*det; - w2= d1[1]*det; + det = 1.0f / det; + w1 = -d2[1] * det; + w2 = d1[1] * det; - mat[1][0]= w1*(v2[0] - v1[0]) + w2*(v3[0] - v1[0]); - mat[1][1]= w1*(v2[1] - v1[1]) + w2*(v3[1] - v1[1]); - mat[1][2]= w1*(v2[2] - v1[2]) + w2*(v3[2] - v1[2]); + mat[1][0] = w1 * (v2[0] - v1[0]) + w2 * (v3[0] - v1[0]); + mat[1][1] = w1 * (v2[1] - v1[1]) + w2 * (v3[1] - v1[1]); + mat[1][2] = w1 * (v2[2] - v1[2]) + w2 * (v3[2] - v1[2]); normalize_v3(mat[1]); } else - mat[1][0]= mat[1][1]= mat[1][2]= 0.0f; + mat[1][0] = mat[1][1] = mat[1][2] = 0.0f; } else { sub_v3_v3v3(mat[1], v2, v1); @@ -3370,14 +3370,14 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m OrigSpaceFace *osface; float (*orcodata)[3]; - int i = pa->num_dmcache==DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache; + int i = pa->num_dmcache == DMCACHE_NOTFOUND ? pa->num : pa->num_dmcache; - if (i==-1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; } + if (i == -1 || i >= dm->getNumTessFaces(dm)) { unit_m4(mat); return; } - mface=dm->getTessFaceData(dm, i, CD_MFACE); - osface=dm->getTessFaceData(dm, i, CD_ORIGSPACE); + mface = dm->getTessFaceData(dm, i, CD_MFACE); + osface = dm->getTessFaceData(dm, i, CD_ORIGSPACE); - if (orco && (orcodata=dm->getVertDataArray(dm, CD_ORCO))) { + if (orco && (orcodata = dm->getVertDataArray(dm, CD_ORCO))) { copy_v3_v3(v[0], orcodata[mface->v1]); copy_v3_v3(v[1], orcodata[mface->v2]); copy_v3_v3(v[2], orcodata[mface->v3]); @@ -3385,7 +3385,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m /* ugly hack to use non-transformed orcos, since only those * give symmetric results for mirroring in particle mode */ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX)) - transform_mesh_orco_verts(ob->data, v, 3, 1); + BKE_mesh_orco_verts_transform(ob->data, v, 3, 1); } else { dm->getVertCo(dm, mface->v1, v[0]); @@ -3393,7 +3393,7 @@ static void psys_face_mat(Object *ob, DerivedMesh *dm, ParticleData *pa, float m dm->getVertCo(dm, mface->v3, v[2]); } - triatomat(v[0], v[1], v[2], (osface)? osface->uv: NULL, mat); + triatomat(v[0], v[1], v[2], (osface) ? osface->uv : NULL, mat); } void psys_mat_hair_to_object(Object *UNUSED(ob), DerivedMesh *dm, short from, ParticleData *pa, float hairmat[][4]) @@ -3414,7 +3414,7 @@ void psys_mat_hair_to_orco(Object *ob, DerivedMesh *dm, short from, ParticleData /* see psys_face_mat for why this function is called */ if (DM_get_vert_data_layer(dm, CD_ORIGINDEX)) - transform_mesh_orco_verts(ob->data, &orco, 1, 1); + BKE_mesh_orco_verts_transform(ob->data, &orco, 1, 1); copy_v3_v3(hairmat[3], orco); } @@ -3449,7 +3449,7 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n return NULL; psys = ob->particlesystem.first; - for (; psys; psys=psys->next) + for (; psys; psys = psys->next) psys->flag &= ~PSYS_CURRENT; psys = MEM_callocN(sizeof(ParticleSystem), "particle_system"); @@ -3458,24 +3458,24 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->part = psys_new_settings("ParticleSettings", NULL); - if (BLI_countlist(&ob->particlesystem)>1) + if (BLI_countlist(&ob->particlesystem) > 1) BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); else strcpy(psys->name, "ParticleSystem"); - md= modifier_new(eModifierType_ParticleSystem); + md = modifier_new(eModifierType_ParticleSystem); - if (name) BLI_strncpy(md->name, name, sizeof(md->name)); - else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + if (name) BLI_strncpy(md->name, name, sizeof(md->name)); + else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); modifier_unique_name(&ob->modifiers, md); - psmd= (ParticleSystemModifierData*) md; - psmd->psys=psys; + psmd = (ParticleSystemModifierData *) md; + psmd->psys = psys; BLI_addtail(&ob->modifiers, md); - psys->totpart=0; - psys->flag = PSYS_ENABLED|PSYS_CURRENT; - psys->cfra = BKE_frame_to_ctime(scene, CFRA + 1); + psys->totpart = 0; + psys->flag = PSYS_ENABLED | PSYS_CURRENT; + psys->cfra = BKE_scene_frame_get_from_ctime(scene, CFRA + 1); DAG_scene_sort(G.main, scene); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -3507,7 +3507,7 @@ void object_remove_particle_system(Scene *scene, Object *ob) } /* clear modifier */ - psmd= psys_get_modifier(ob, psys); + psmd = psys_get_modifier(ob, psys); BLI_remlink(&ob->modifiers, psmd); modifier_free((ModifierData *)psmd); @@ -3525,64 +3525,64 @@ void object_remove_particle_system(Scene *scene, Object *ob) } static void default_particle_settings(ParticleSettings *part) { - part->type= PART_EMITTER; - part->distr= PART_DISTR_JIT; + part->type = PART_EMITTER; + part->distr = PART_DISTR_JIT; part->draw_as = PART_DRAW_REND; part->ren_as = PART_DRAW_HALO; - part->bb_uv_split=1; - part->bb_align=PART_BB_VIEW; - part->bb_split_offset=PART_BB_OFF_LINEAR; - part->flag=PART_EDISTR|PART_TRAND|PART_HIDE_ADVANCED_HAIR; + part->bb_uv_split = 1; + part->bb_align = PART_BB_VIEW; + part->bb_split_offset = PART_BB_OFF_LINEAR; + part->flag = PART_EDISTR | PART_TRAND | PART_HIDE_ADVANCED_HAIR; - part->sta= 1.0; - part->end= 200.0; - part->lifetime= 50.0; - part->jitfac= 1.0; - part->totpart= 1000; - part->grid_res= 10; - part->timetweak= 1.0; + part->sta = 1.0; + part->end = 200.0; + part->lifetime = 50.0; + part->jitfac = 1.0; + part->totpart = 1000; + part->grid_res = 10; + part->timetweak = 1.0; part->courant_target = 0.2; - part->integrator= PART_INT_MIDPOINT; - part->phystype= PART_PHYS_NEWTON; - part->hair_step= 5; - part->keys_step= 5; - part->draw_step= 2; - part->ren_step= 3; - part->adapt_angle= 5; - part->adapt_pix= 3; - part->kink_axis= 2; - part->kink_amp_clump= 1.f; - part->reactevent= PART_EVENT_DEATH; - part->disp=100; - part->from= PART_FROM_FACE; + part->integrator = PART_INT_MIDPOINT; + part->phystype = PART_PHYS_NEWTON; + part->hair_step = 5; + part->keys_step = 5; + part->draw_step = 2; + part->ren_step = 3; + part->adapt_angle = 5; + part->adapt_pix = 3; + part->kink_axis = 2; + part->kink_amp_clump = 1.f; + part->reactevent = PART_EVENT_DEATH; + part->disp = 100; + part->from = PART_FROM_FACE; - part->normfac= 1.0f; + part->normfac = 1.0f; - part->mass=1.0; - part->size=0.05; - part->childsize=1.0; + part->mass = 1.0; + part->size = 0.05; + part->childsize = 1.0; part->rotmode = PART_ROT_VEL; part->avemode = PART_AVE_VELOCITY; - part->child_nbr=10; - part->ren_child_nbr=100; - part->childrad=0.2f; - part->childflat=0.0f; - part->clumppow=0.0f; - part->kink_amp=0.2f; - part->kink_freq=2.0; + part->child_nbr = 10; + part->ren_child_nbr = 100; + part->childrad = 0.2f; + part->childflat = 0.0f; + part->clumppow = 0.0f; + part->kink_amp = 0.2f; + part->kink_freq = 2.0; - part->rough1_size=1.0; - part->rough2_size=1.0; - part->rough_end_shape=1.0; + part->rough1_size = 1.0; + part->rough2_size = 1.0; + part->rough_end_shape = 1.0; - part->clength=1.0f; - part->clength_thres=0.0f; + part->clength = 1.0f; + part->clength_thres = 0.0f; - part->draw= PART_DRAW_EMITTER; - part->draw_line[0]=0.5; + part->draw = PART_DRAW_EMITTER; + part->draw_line[0] = 0.5; part->path_start = 0.0f; part->path_end = 1.0f; @@ -3593,10 +3593,10 @@ static void default_particle_settings(ParticleSettings *part) part->color_vec_max = 1.f; part->draw_col = PART_DRAW_COL_MAT; - part->simplify_refsize= 1920; - part->simplify_rate= 1.0f; - part->simplify_transition= 0.1f; - part->simplify_viewport= 0.8; + part->simplify_refsize = 1920; + part->simplify_rate = 1.0f; + part->simplify_transition = 0.1f; + part->simplify_viewport = 0.8; if (!part->effector_weights) part->effector_weights = BKE_add_effector_weights(NULL); @@ -3607,32 +3607,32 @@ ParticleSettings *psys_new_settings(const char *name, Main *main) { ParticleSettings *part; - if (main==NULL) + if (main == NULL) main = G.main; - part= alloc_libblock(&main->particle, ID_PA, name); + part = BKE_libblock_alloc(&main->particle, ID_PA, name); default_particle_settings(part); return part; } -ParticleSettings *psys_copy_settings(ParticleSettings *part) +ParticleSettings *BKE_particlesettings_copy(ParticleSettings *part) { ParticleSettings *partn; int a; - partn= copy_libblock(&part->id); - partn->pd= MEM_dupallocN(part->pd); - partn->pd2= MEM_dupallocN(part->pd2); - partn->effector_weights= MEM_dupallocN(part->effector_weights); - partn->fluid= MEM_dupallocN(part->fluid); + partn = BKE_libblock_copy(&part->id); + partn->pd = MEM_dupallocN(part->pd); + partn->pd2 = MEM_dupallocN(part->pd2); + partn->effector_weights = MEM_dupallocN(part->effector_weights); + partn->fluid = MEM_dupallocN(part->fluid); partn->boids = boid_copy_settings(part->boids); - for (a=0; amtex[a]) { - partn->mtex[a]= MEM_mallocN(sizeof(MTex), "psys_copy_tex"); + partn->mtex[a] = MEM_mallocN(sizeof(MTex), "psys_copy_tex"); memcpy(partn->mtex[a], part->mtex[a], sizeof(MTex)); id_us_plus((ID *)partn->mtex[a]->tex); } @@ -3648,57 +3648,57 @@ static void expand_local_particlesettings(ParticleSettings *part) int i; id_lib_extern((ID *)part->dup_group); - for (i=0; imtex[i]) id_lib_extern((ID *)part->mtex[i]->tex); } } -void make_local_particlesettings(ParticleSettings *part) +void BKE_particlesettings_make_local(ParticleSettings *part) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (part->id.lib==0) return; - if (part->id.us==1) { + if (part->id.lib == 0) return; + if (part->id.us == 1) { id_clear_lib_data(bmain, &part->id); expand_local_particlesettings(part); return; } /* test objects */ - for (ob= bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob= ob->id.next) { - ParticleSystem *psys=ob->particlesystem.first; - for (; psys; psys=psys->next) { - if (psys->part==part) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (ob = bmain->object.first; ob && ELEM(FALSE, is_lib, is_local); ob = ob->id.next) { + ParticleSystem *psys = ob->particlesystem.first; + for (; psys; psys = psys->next) { + if (psys->part == part) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } } } - if (is_local && is_lib==FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &part->id); expand_local_particlesettings(part); } else if (is_local && is_lib) { - ParticleSettings *part_new= psys_copy_settings(part); - part_new->id.us= 0; + ParticleSettings *part_new = BKE_particlesettings_copy(part); + part_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, part->id.lib, &part_new->id); /* do objects */ - for (ob= bmain->object.first; ob; ob= ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { ParticleSystem *psys; - for (psys= ob->particlesystem.first; psys; psys=psys->next) { - if (psys->part==part && ob->id.lib==0) { - psys->part= part_new; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part == part && ob->id.lib == 0) { + psys->part = part_new; part_new->id.us++; part->id.us--; } @@ -3717,42 +3717,42 @@ static int get_particle_uv(DerivedMesh *dm, ParticleData *pa, int face_index, co MTFace *tf; int i; - tf= CustomData_get_layer_named(&dm->faceData, CD_MTFACE, name); + tf = CustomData_get_layer_named(&dm->faceData, CD_MTFACE, name); if (tf == NULL) - tf= CustomData_get_layer(&dm->faceData, CD_MTFACE); + tf = CustomData_get_layer(&dm->faceData, CD_MTFACE); if (tf == NULL) return 0; if (pa) { - i= (pa->num_dmcache==DMCACHE_NOTFOUND)? pa->num: pa->num_dmcache; + i = (pa->num_dmcache == DMCACHE_NOTFOUND) ? pa->num : pa->num_dmcache; if (i >= dm->getNumTessFaces(dm)) i = -1; } else - i= face_index; + i = face_index; - if (i==-1) { - texco[0]= 0.0f; - texco[1]= 0.0f; - texco[2]= 0.0f; + if (i == -1) { + texco[0] = 0.0f; + texco[1] = 0.0f; + texco[2] = 0.0f; } else { - mf= dm->getTessFaceData(dm, i, CD_MFACE); + mf = dm->getTessFaceData(dm, i, CD_MFACE); psys_interpolate_uvs(&tf[i], mf->v4, fuv, texco); - texco[0]= texco[0]*2.0f - 1.0f; - texco[1]= texco[1]*2.0f - 1.0f; - texco[2]= 0.0f; + texco[0] = texco[0] * 2.0f - 1.0f; + texco[1] = texco[1] * 2.0f - 1.0f; + texco[2] = 0.0f; } return 1; } -#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend);} -#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if (event & type) { if (pvalue < 0.f) pvalue = 1.f+pvalue; CLAMP(pvalue, 0.0f, 1.0f); } +#define SET_PARTICLE_TEXTURE(type, pvalue, texfac) if ((event & mtex->mapto) & type) {pvalue = texture_value_blend(def, pvalue, value, texfac, blend); } +#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue) if (event & type) { if (pvalue < 0.f) pvalue = 1.f + pvalue; CLAMP(pvalue, 0.0f, 1.0f); } #define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue) if (event & type) { CLAMP(pvalue, -1.0f, 1.0f); } static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, const float fw[4], float *orco, ParticleTexture *ptex, int event, float cfra) @@ -3762,50 +3762,50 @@ static void get_cpa_texture(DerivedMesh *dm, ParticleSystem *psys, ParticleSetti float value, rgba[4], texvec[3]; ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = - ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = - ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + ptex->gravity = ptex->field = ptex->time = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; - ptex->length= 1.0f - part->randlength * PSYS_FRAND(child_index + 26); - ptex->length*= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; + ptex->length = 1.0f - part->randlength *PSYS_FRAND(child_index + 26); + ptex->length *= part->clength_thres < PSYS_FRAND(child_index + 27) ? part->clength : 1.0f; - for (m=0; mmapto) { - float def=mtex->def_var; - short blend=mtex->blendtype; + float def = mtex->def_var; + short blend = mtex->blendtype; short texco = mtex->texco; if (ELEM(texco, TEXCO_UV, TEXCO_ORCO) && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; switch (texco) { - case TEXCO_GLOB: - copy_v3_v3(texvec, par->state.co); - break; - case TEXCO_OBJECT: - copy_v3_v3(texvec, par->state.co); - if (mtex->object) - mul_m4_v3(mtex->object->imat, texvec); - break; - case TEXCO_UV: - if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec)) + case TEXCO_GLOB: + copy_v3_v3(texvec, par->state.co); break; + case TEXCO_OBJECT: + copy_v3_v3(texvec, par->state.co); + if (mtex->object) + mul_m4_v3(mtex->object->imat, texvec); + break; + case TEXCO_UV: + if (fw && get_particle_uv(dm, NULL, face_index, fw, mtex->uvname, texvec)) + break; /* no break, failed to get uv's, so let's try orco's */ - case TEXCO_ORCO: - copy_v3_v3(texvec, orco); - break; - case TEXCO_PARTICLE: - /* texture coordinates in range [-1, 1] */ - texvec[0] = 2.f * (cfra - par->time)/(par->dietime-par->time) - 1.f; - texvec[1] = 0.f; - texvec[2] = 0.f; - break; + case TEXCO_ORCO: + copy_v3_v3(texvec, orco); + break; + case TEXCO_PARTICLE: + /* texture coordinates in range [-1, 1] */ + texvec[0] = 2.f * (cfra - par->time) / (par->dietime - par->time) - 1.f; + texvec[1] = 0.f; + texvec[2] = 0.f; + break; } - externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); + externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0); if ((event & mtex->mapto) & PAMAP_ROUGH) - ptex->rough1= ptex->rough2= ptex->roughe= texture_value_blend(def, ptex->rough1, value, mtex->roughfac, blend); + ptex->rough1 = ptex->rough2 = ptex->roughe = texture_value_blend(def, ptex->rough1, value, mtex->roughfac, blend); SET_PARTICLE_TEXTURE(PAMAP_LENGTH, ptex->length, mtex->lengthfac); SET_PARTICLE_TEXTURE(PAMAP_CLUMP, ptex->clump, mtex->clumpfac); @@ -3827,62 +3827,62 @@ void psys_get_texture(ParticleSimulationData *sim, ParticleData *pa, ParticleTex MTex *mtex; int m; float value, rgba[4], co[3], texvec[3]; - int setvars=0; + int setvars = 0; /* initialize ptex */ ptex->ivel = ptex->life = ptex->exist = ptex->size = ptex->damp = - ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink = - ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.f; + ptex->gravity = ptex->field = ptex->length = ptex->clump = ptex->kink = + ptex->effector = ptex->rough1 = ptex->rough2 = ptex->roughe = 1.0f; - ptex->time = (float)(pa - sim->psys->particles)/(float)sim->psys->totpart; + ptex->time = (float)(pa - sim->psys->particles) / (float)sim->psys->totpart; - for (m=0; mmapto) { - float def=mtex->def_var; - short blend=mtex->blendtype; + float def = mtex->def_var; + short blend = mtex->blendtype; short texco = mtex->texco; if (texco == TEXCO_UV && (ELEM(part->from, PART_FROM_FACE, PART_FROM_VOLUME) == 0 || part->distr == PART_DISTR_GRID)) texco = TEXCO_GLOB; switch (texco) { - case TEXCO_GLOB: - copy_v3_v3(texvec, pa->state.co); - break; - case TEXCO_OBJECT: - copy_v3_v3(texvec, pa->state.co); - if (mtex->object) - mul_m4_v3(mtex->object->imat, texvec); - break; - case TEXCO_UV: - if (get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec)) + case TEXCO_GLOB: + copy_v3_v3(texvec, pa->state.co); break; + case TEXCO_OBJECT: + copy_v3_v3(texvec, pa->state.co); + if (mtex->object) + mul_m4_v3(mtex->object->imat, texvec); + break; + case TEXCO_UV: + if (get_particle_uv(sim->psmd->dm, pa, 0, pa->fuv, mtex->uvname, texvec)) + break; /* no break, failed to get uv's, so let's try orco's */ - case TEXCO_ORCO: - psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0); - break; - case TEXCO_PARTICLE: - /* texture coordinates in range [-1, 1] */ - texvec[0] = 2.f * (cfra - pa->time)/(pa->dietime-pa->time) - 1.f; - texvec[1] = 0.f; - texvec[2] = 0.f; - break; + case TEXCO_ORCO: + psys_particle_on_emitter(sim->psmd, sim->psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, 0, 0, 0, texvec, 0); + break; + case TEXCO_PARTICLE: + /* texture coordinates in range [-1, 1] */ + texvec[0] = 2.f * (cfra - pa->time) / (pa->dietime - pa->time) - 1.f; + texvec[1] = 0.f; + texvec[2] = 0.f; + break; } - externtex(mtex, texvec, &value, rgba, rgba+1, rgba+2, rgba+3, 0); + externtex(mtex, texvec, &value, rgba, rgba + 1, rgba + 2, rgba + 3, 0); if ((event & mtex->mapto) & PAMAP_TIME) { /* the first time has to set the base value for time regardless of blend mode */ - if ((setvars&MAP_PA_TIME)==0) { - int flip= (mtex->timefac < 0.0f); - float timefac= fabsf(mtex->timefac); + if ((setvars & MAP_PA_TIME) == 0) { + int flip = (mtex->timefac < 0.0f); + float timefac = fabsf(mtex->timefac); ptex->time *= 1.0f - timefac; - ptex->time += timefac * ((flip)? 1.0f - value : value); + ptex->time += timefac * ((flip) ? 1.0f - value : value); setvars |= MAP_PA_TIME; } else - ptex->time= texture_value_blend(def, ptex->time, value, mtex->timefac, blend); + ptex->time = texture_value_blend(def, ptex->time, value, mtex->timefac, blend); } SET_PARTICLE_TEXTURE(PAMAP_LIFE, ptex->life, mtex->lifefac) SET_PARTICLE_TEXTURE(PAMAP_DENS, ptex->exist, mtex->padensfac) @@ -3917,11 +3917,11 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, ParticleSettings *part = psys->part; float time, life; - if (part->childtype==PART_CHILD_FACES) { - int w=0; - time=0.0; - while (w<4 && cpa->pa[w]>=0) { - time+=cpa->w[w]*(psys->particles+cpa->pa[w])->time; + if (part->childtype == PART_CHILD_FACES) { + int w = 0; + time = 0.0; + while (w < 4 && cpa->pa[w] >= 0) { + time += cpa->w[w] * (psys->particles + cpa->pa[w])->time; w++; } @@ -3937,24 +3937,24 @@ float psys_get_child_time(ParticleSystem *psys, ChildParticle *cpa, float cfra, if (birthtime) *birthtime = time; if (dietime) - *dietime = time+life; + *dietime = time + life; - return (cfra-time)/life; + return (cfra - time) / life; } float psys_get_child_size(ParticleSystem *psys, ChildParticle *cpa, float UNUSED(cfra), float *UNUSED(pa_time)) { ParticleSettings *part = psys->part; float size; // time XXX - if (part->childtype==PART_CHILD_FACES) - size=part->size; + if (part->childtype == PART_CHILD_FACES) + size = part->size; else - size=psys->particles[cpa->parent].size; + size = psys->particles[cpa->parent].size; - size*=part->childsize; + size *= part->childsize; if (part->childrandsize != 0.0f) - size *= 1.0f - part->childrandsize * PSYS_FRAND(cpa - psys->child + 26); + size *= 1.0f - part->childrandsize *PSYS_FRAND(cpa - psys->child + 26); return size; } @@ -3963,26 +3963,26 @@ static void get_child_modifier_parameters(ParticleSettings *part, ParticleThread ParticleSystem *psys = ctx->sim.psys; int i = cpa - psys->child; - get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS|PAMAP_CHILD, psys->cfra); + get_cpa_texture(ctx->dm, psys, part, psys->particles + cpa->pa[0], i, cpa_num, cpa_fuv, orco, ptex, PAMAP_DENS | PAMAP_CHILD, psys->cfra); if (ptex->exist < PSYS_FRAND(i + 24)) return; if (ctx->vg_length) - ptex->length*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_length); + ptex->length *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_length); if (ctx->vg_clump) - ptex->clump*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump); + ptex->clump *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_clump); if (ctx->vg_kink) - ptex->kink*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink); + ptex->kink *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_kink); if (ctx->vg_rough1) - ptex->rough1*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1); + ptex->rough1 *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough1); if (ctx->vg_rough2) - ptex->rough2*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2); + ptex->rough2 *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_rough2); if (ctx->vg_roughe) - ptex->roughe*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe); + ptex->roughe *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_roughe); if (ctx->vg_effector) - ptex->effector*=psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector); + ptex->effector *= psys_interpolate_value_from_verts(ctx->dm, cpa_from, cpa_num, cpa_fuv, ctx->vg_effector); } static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *ptex, ParticleKey *par, float *par_rot, ChildParticle *cpa, float *orco, float mat[4][4], ParticleKey *state, float t) { @@ -4004,17 +4004,17 @@ static void do_child_modifiers(ParticleSimulationData *sim, ParticleTexture *pte if (part->flag & PART_CHILD_EFFECT) /* state is safe to cast, since only co and vel are used */ - guided = do_guides(sim->psys->effectors, (ParticleKey*)state, cpa->parent, t); + guided = do_guides(sim->psys->effectors, (ParticleKey *)state, cpa->parent, t); - if (guided==0) { + if (guided == 0) { float clump = do_clump(state, par, t, part->clumpfac, part->clumppow, ptex ? ptex->clump : 1.f); if (kink_freq != 0.f) { float kink_amp = part->kink_amp * (1.f - part->kink_amp_clump * clump); do_kink(state, par, par_rot, t, kink_freq, part->kink_shape, - kink_amp, part->kink_flat, part->kink, part->kink_axis, - sim->ob->obmat, sim->psys->part->childtype == PART_CHILD_FACES); + kink_amp, part->kink_flat, part->kink, part->kink_axis, + sim->ob->obmat, sim->psys->part->childtype == PART_CHILD_FACES); } } @@ -4037,7 +4037,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * ParticleData *pa; ChildParticle *cpa; ParticleTexture ptex; - ParticleKey *par=0, keys[4], tstate; + ParticleKey *par = 0, keys[4], tstate; ParticleThreadContext ctx; /* fake thread context for child modifiers */ ParticleInterpolationData pind; @@ -4054,12 +4054,12 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * float *cpa_fuv; int cpa_num; short cpa_from; /* initialize keys to zero */ - memset(keys, 0, 4*sizeof(ParticleKey)); + memset(keys, 0, 4 * sizeof(ParticleKey)); - t=state->time; + t = state->time; CLAMP(t, 0.0f, 1.0f); - if (ppathcache) { ParticleCacheKey result; @@ -4087,17 +4087,17 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * mul_mat3_m4_v3(sim->ob->obmat, state->vel); } else if (!keyed && !cached && !(psys->flag & PSYS_GLOBAL_HAIR)) { - if ((pa->flag & PARS_REKEY)==0) { + if ((pa->flag & PARS_REKEY) == 0) { psys_mat_hair_to_global(sim->ob, sim->psmd->dm, part->from, pa, hairmat); mul_m4_v3(hairmat, state->co); mul_mat3_m4_v3(hairmat, state->vel); - if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE)==0) { + if (sim->psys->effectors && (part->flag & PART_CHILD_GUIDE) == 0) { do_guides(sim->psys->effectors, state, p, state->time); /* TODO: proper velocity handling */ } - if (psys->lattice && edit==0) + if (psys->lattice && edit == 0) calc_latt_deform(psys->lattice, state->co, 1.0f); } } @@ -4109,36 +4109,36 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* interpolate childcache directly if it exists */ if (psys->childcache) { ParticleCacheKey result; - interpolate_pathcache(psys->childcache[p-totpart], t, &result); + interpolate_pathcache(psys->childcache[p - totpart], t, &result); copy_v3_v3(state->co, result.co); copy_v3_v3(state->vel, result.vel); copy_qt_qt(state->rot, result.rot); } else { - cpa=psys->child+p-totpart; + cpa = psys->child + p - totpart; if (state->time < 0.0f) t = psys_get_child_time(psys, cpa, -state->time, NULL, NULL); - if (totchild && part->childtype==PART_CHILD_FACES) { + if (totchild && part->childtype == PART_CHILD_FACES) { /* part->parents could still be 0 so we can't test with totparent */ - between=1; + between = 1; } if (between) { int w = 0; float foffset; /* get parent states */ - while (w<4 && cpa->pa[w]>=0) { + while (w < 4 && cpa->pa[w] >= 0) { keys[w].time = state->time; - psys_get_particle_on_path(sim, cpa->pa[w], keys+w, 1); + psys_get_particle_on_path(sim, cpa->pa[w], keys + w, 1); w++; } /* get the original coordinates (orco) for texture usage */ - cpa_num=cpa->num; + cpa_num = cpa->num; - foffset= cpa->foffset; + foffset = cpa->foffset; cpa_fuv = cpa->fuv; cpa_from = PART_FROM_FACE; @@ -4156,7 +4156,7 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * else unit_m4(hairmat); - pa=0; + pa = 0; } else { /* get the parent state */ @@ -4164,11 +4164,11 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * psys_get_particle_on_path(sim, cpa->parent, keys, 1); /* get the original coordinates (orco) for texture usage */ - pa=psys->particles+cpa->parent; + pa = psys->particles + cpa->parent; - cpa_from=part->from; - cpa_num=pa->num; - cpa_fuv=pa->fuv; + cpa_from = part->from; + cpa_num = pa->num; + cpa_fuv = pa->fuv; @@ -4184,8 +4184,8 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * /* correct child ipo timing */ #if 0 // XXX old animation system - if ((part->flag&PART_ABS_TIME)==0 && part->ipo) { - calc_ipo(part->ipo, 100.0f*t); + if ((part->flag & PART_ABS_TIME) == 0 && part->ipo) { + calc_ipo(part->ipo, 100.0f * t); execute_ipo((ID *)part, part->ipo); } #endif // XXX old animation system @@ -4199,13 +4199,13 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * get_child_modifier_parameters(part, &ctx, cpa, cpa_from, cpa_num, cpa_fuv, orco, &ptex); if (between) { - int w=0; + int w = 0; state->co[0] = state->co[1] = state->co[2] = 0.0f; state->vel[0] = state->vel[1] = state->vel[2] = 0.0f; /* child position is the weighted sum of parent positions */ - while (w<4 && cpa->pa[w]>=0) { + while (w < 4 && cpa->pa[w] >= 0) { state->co[0] += cpa->w[w] * keys[w].co[0]; state->co[1] += cpa->w[w] * keys[w].co[1]; state->co[2] += cpa->w[w] * keys[w].co[2]; @@ -4236,14 +4236,14 @@ void psys_get_particle_on_path(ParticleSimulationData *sim, int p, ParticleKey * ParticleKey tstate; float length = len_v3(state->vel); - if (t>=0.001f) { - tstate.time=t-0.001f; + if (t >= 0.001f) { + tstate.time = t - 0.001f; psys_get_particle_on_path(sim, p, &tstate, 0); sub_v3_v3v3(state->vel, state->co, tstate.co); normalize_v3(state->vel); } else { - tstate.time=t+0.001f; + tstate.time = t + 0.001f; psys_get_particle_on_path(sim, p, &tstate, 0); sub_v3_v3v3(state->vel, tstate.co, state->co); normalize_v3(state->vel); @@ -4266,9 +4266,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta float timestep = psys_get_timestep(sim); /* negative time means "use current time" */ - cfra = state->time > 0 ? state->time : BKE_curframe(sim->scene); + cfra = state->time > 0 ? state->time : BKE_scene_frame_get(sim->scene); - if (p>=totpart) { + if (p >= totpart) { if (!psys->totchild) return 0; @@ -4288,7 +4288,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } } - state->time= (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); + state->time = (cfra - (part->sta + (part->end - part->sta) * PSYS_FRAND(p + 23))) / (part->lifetime * PSYS_FRAND(p + 24)); psys_get_particle_on_path(sim, p, state, 1); return 1; @@ -4315,7 +4315,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta } if (sim->psys->flag & PSYS_KEYED) { - state->time= -cfra; + state->time = -cfra; psys_get_particle_on_path(sim, p, state, 1); return 1; } @@ -4325,7 +4325,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta ParticleKey *key1; float t = (cfra - pa->time) / pa->lifetime; - key1=&pa->state; + key1 = &pa->state; offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); CLAMP(t, 0.0f, 1.0f); @@ -4337,9 +4337,9 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta calc_latt_deform(sim->psys->lattice, state->co, 1.0f); } else { - if (pa->state.time==cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) + if (pa->state.time == cfra || ELEM(part->phystype, PART_PHYS_NO, PART_PHYS_KEYED)) copy_particle_key(state, &pa->state, 1); - else if (pa->prev_state.time==cfra) + else if (pa->prev_state.time == cfra) copy_particle_key(state, &pa->prev_state, 1); else { float dfra, frs_sec = sim->scene->r.frs_sec; @@ -4351,14 +4351,14 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta copy_particle_key(state, &pa->state, 1); - madd_v3_v3v3fl(state->co, state->co, state->vel, dfra/frs_sec); + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); } else { ParticleKey keys[4]; float keytime; - copy_particle_key(keys+1, &pa->prev_state, 1); - copy_particle_key(keys+2, &pa->state, 1); + copy_particle_key(keys + 1, &pa->prev_state, 1); + copy_particle_key(keys + 2, &pa->state, 1); dfra = keys[2].time - keys[1].time; @@ -4384,7 +4384,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta copy_particle_key(state, &pa->state, 1); - madd_v3_v3v3fl(state->co, state->co, state->vel, dfra/frs_sec); + madd_v3_v3v3fl(state->co, state->co, state->vel, dfra / frs_sec); } else { /* extrapolating over big ranges is not accurate so let's just give something close to reasonable back */ @@ -4411,9 +4411,9 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic if (cpa) { if (part->childtype == PART_CHILD_FACES) { - mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); + mtface = CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); if (mtface) { - mface= psmd->dm->getTessFaceData(psmd->dm, cpa->num, CD_MFACE); + mface = psmd->dm->getTessFaceData(psmd->dm, cpa->num, CD_MFACE); mtface += cpa->num; psys_interpolate_uvs(mtface, mface->v4, cpa->fuv, uv); } @@ -4427,20 +4427,20 @@ void psys_get_dupli_texture(ParticleSystem *psys, ParticleSettings *part, Partic } if (part->from == PART_FROM_FACE) { - mtface= CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); - num= pa->num_dmcache; + mtface = CustomData_get_layer(&psmd->dm->faceData, CD_MTFACE); + num = pa->num_dmcache; if (num == DMCACHE_NOTFOUND) - num= pa->num; + num = pa->num; if (num >= psmd->dm->getNumTessFaces(psmd->dm)) { /* happens when simplify is enabled * gives invalid coords but would crash otherwise */ - num= DMCACHE_NOTFOUND; + num = DMCACHE_NOTFOUND; } if (mtface && num != DMCACHE_NOTFOUND) { - mface= psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE); + mface = psmd->dm->getTessFaceData(psmd->dm, num, CD_MFACE); mtface += num; psys_interpolate_uvs(mtface, mface->v4, pa->fuv, uv); } @@ -4457,8 +4457,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float loc[3], nor[3], vec[3], side[3], len; float xvec[3] = {-1.0, 0.0, 0.0}, nmat[3][3]; - sub_v3_v3v3(vec, (cache+cache->steps)->co, cache->co); - len= normalize_v3(vec); + sub_v3_v3v3(vec, (cache + cache->steps)->co, cache->co); + len = normalize_v3(vec); if (pa == NULL && psys->part->childflat != PART_CHILD_FACES) pa = psys->particles + cpa->pa[0]; @@ -4475,8 +4475,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa normalize_v3(nor); /* make sure that we get a proper side vector */ - if (fabs(dot_v3v3(nor, vec))>0.999999) { - if (fabs(dot_v3v3(nor, xvec))>0.999999) { + if (fabs(dot_v3v3(nor, vec)) > 0.999999) { + if (fabs(dot_v3v3(nor, xvec)) > 0.999999) { nor[0] = 0.0f; nor[1] = 1.0f; nor[2] = 0.0f; @@ -4495,8 +4495,8 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa float q_phase[4]; float phasefac = psys->part->phasefac; if (psys->part->randphasefac != 0.0f) - phasefac += psys->part->randphasefac * PSYS_FRAND((pa-psys->particles) + 20); - axis_angle_to_quat(q_phase, vec, phasefac*(float)M_PI); + phasefac += psys->part->randphasefac * PSYS_FRAND((pa - psys->particles) + 20); + axis_angle_to_quat(q_phase, vec, phasefac * (float)M_PI); mul_qt_v3(q_phase, side); } @@ -4512,7 +4512,7 @@ void psys_get_dupli_path_transform(ParticleSimulationData *sim, ParticleData *pa quat_to_mat4(mat, pa->state.rot); } - *scale= len; + *scale = len; } void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3], float zvec[3], float center[3]) @@ -4525,7 +4525,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] /* can happen with bad pointcache or physics calculation * since this becomes geometry, nan's and inf's crash raytrace code. * better not allow this. */ - if ( !finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || + if (!finite(bb->vec[0]) || !finite(bb->vec[1]) || !finite(bb->vec[2]) || !finite(bb->vel[0]) || !finite(bb->vel[1]) || !finite(bb->vel[2]) ) { zero_v3(bb->vec); @@ -4540,7 +4540,7 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] } if (bb->align < PART_BB_VIEW) - onevec[bb->align]=1.0f; + onevec[bb->align] = 1.0f; if (bb->lock && (bb->align == PART_BB_VIEW)) { normalize_v3_v3(xvec, bb->ob->obmat[0]); @@ -4601,11 +4601,11 @@ void psys_make_billboard(ParticleBillboardData *bb, float xvec[3], float yvec[3] void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) { - ParticleSimulationData sim= {0}; - sim.scene= scene; - sim.ob= ob; - sim.psys= psys; - sim.psmd= psys_get_modifier(ob, psys); + ParticleSimulationData sim = {0}; + sim.scene = scene; + sim.ob = ob; + sim.psys = psys; + sim.psmd = psys_get_modifier(ob, psys); psys->lattice = psys_get_lattice(&sim); @@ -4615,12 +4615,12 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) int p, h; float hairmat[4][4], imat[4][4]; - for (p=0; ptotpart; p++, pa++) { + for (p = 0; p < psys->totpart; p++, pa++) { psys_mat_hair_to_global(sim.ob, sim.psmd->dm, psys->part->from, pa, hairmat); invert_m4_m4(imat, hairmat); hkey = pa->hair; - for (h=0; htotkey; h++, hkey++) { + for (h = 0; h < pa->totkey; h++, hkey++) { mul_m4_v3(hairmat, hkey->co); calc_latt_deform(psys->lattice, hkey->co, 1.0f); mul_m4_v3(imat, hkey->co); @@ -4628,7 +4628,7 @@ void psys_apply_hair_lattice(Scene *scene, Object *ob, ParticleSystem *psys) } end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; /* protect the applied shape */ psys->flag |= PSYS_EDITED; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index a4d61cea3fb..cd1561734cc 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -512,9 +512,9 @@ static void distribute_grid(DerivedMesh *dm, ParticleSystem *psys) vec[0]/=delta[0]; vec[1]/=delta[1]; vec[2]/=delta[2]; - (pa +((int)(vec[0]*(size[0]-1))*res - +(int)(vec[1]*(size[1]-1)))*res - +(int)(vec[2]*(size[2]-1)))->flag &= ~PARS_UNEXIST; + (pa + ((int)(vec[0] * (size[0] - 1)) * res + + (int)(vec[1] * (size[1] - 1))) * res + + (int)(vec[2] * (size[2] - 1)))->flag &= ~PARS_UNEXIST; } } else if (ELEM(from, PART_FROM_FACE, PART_FROM_VOLUME)) { @@ -772,7 +772,7 @@ static void distribute_threads_exec(ParticleThread *thread, ParticleData *pa, Ch int w, maxw; psys_particle_on_dm(ctx->dm, from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co1, 0, 0, 0, orco1, 0); - transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1); maxw = BLI_kdtree_find_n_nearest(ctx->tree, 3, orco1, NULL, ptn); for (w=0; wnum, DMCACHE_ISCHILD, cpa->fuv, cpa->foffset, co1, nor1, NULL, NULL, orco1, NULL); - transform_mesh_orco_verts((Mesh*)ob->data, &orco1, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco1, 1, 1); maxw = BLI_kdtree_find_n_nearest(ctx->tree, 4, orco1, NULL, ptn); maxd=ptn[maxw-1].dist; @@ -1086,7 +1086,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0, pa=psys->particles; pfrom, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, nor, 0, 0, orco, ornor); - transform_mesh_orco_verts((Mesh*)ob->data, &orco, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &orco, 1, 1); BLI_kdtree_insert(tree, p, orco, ornor); } @@ -1107,7 +1107,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D } /* we need orco for consistent distributions */ - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); + DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob)); if (from == PART_FROM_VERT) { MVert *mv= dm->getVertDataArray(dm, CD_MVERT); @@ -1119,7 +1119,7 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D for (p=0; pdata, &co, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co, 1, 1); } else copy_v3_v3(co, mv[p].co); @@ -1166,12 +1166,12 @@ static int distribute_threads_init_data(ParticleThread *threads, Scene *scene, D copy_v3_v3(co1, orcodata[mf->v1]); copy_v3_v3(co2, orcodata[mf->v2]); copy_v3_v3(co3, orcodata[mf->v3]); - transform_mesh_orco_verts((Mesh*)ob->data, &co1, 1, 1); - transform_mesh_orco_verts((Mesh*)ob->data, &co2, 1, 1); - transform_mesh_orco_verts((Mesh*)ob->data, &co3, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co1, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co2, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co3, 1, 1); if (mf->v4) { copy_v3_v3(co4, orcodata[mf->v4]); - transform_mesh_orco_verts((Mesh*)ob->data, &co4, 1, 1); + BKE_mesh_orco_verts_transform((Mesh*)ob->data, &co4, 1, 1); } } else { @@ -1854,7 +1854,7 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, ob = ob->parent; } ob = sim->ob; - where_is_object_time(sim->scene, ob, pa->time); + BKE_object_where_is_calc_time(sim->scene, ob, pa->time); psys->flag |= PSYS_OB_ANIM_RESTORE; } @@ -4465,7 +4465,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) if (!psys_check_enabled(ob, psys)) return; - cfra= BKE_curframe(scene); + cfra= BKE_scene_frame_get(scene); sim.scene= scene; sim.ob= ob; @@ -4612,7 +4612,7 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) ob = ob->parent; } ob = sim.ob; - where_is_object_time(scene, ob, cfra); + BKE_object_where_is_calc_time(scene, ob, cfra); psys->flag &= ~PSYS_OB_ANIM_RESTORE; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 1e80f1e6d1e..69808db52b6 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1122,7 +1122,7 @@ static int ptcache_filename(PTCacheID *pid, char *filename, int cfra, short do_p if (do_ext) { if (pid->cache->index < 0) - pid->cache->index = pid->stack_index = object_insert_ptcache(pid->ob); + pid->cache->index = pid->stack_index = BKE_object_insert_ptcache(pid->ob); if (pid->cache->flag & PTCACHE_EXTERNAL) { if (pid->cache->index >= 0) @@ -2320,8 +2320,8 @@ void BKE_ptcache_id_time(PTCacheID *pid, Scene *scene, float cfra, int *startfra cache= pid->cache; if (timescale) { - time= BKE_curframe(scene); - nexttime = BKE_frame_to_ctime(scene, CFRA + 1.0f); + time= BKE_scene_frame_get(scene); + nexttime = BKE_scene_frame_get_from_ctime(scene, CFRA + 1.0f); *timescale= MAX2(nexttime - time, 0.0f); } @@ -2743,7 +2743,7 @@ static void *ptcache_bake_thread(void *ptr) efra = data->endframe; for (; (*data->cfra_ptr <= data->endframe) && !data->break_operation; *data->cfra_ptr+=data->step) { - scene_update_for_newframe(data->main, data->scene, data->scene->lay); + BKE_scene_update_for_newframe(data->main, data->scene, data->scene->lay); if (G.background) { printf("bake: frame %d :: %d\n", (int)*data->cfra_ptr, data->endframe); } @@ -2974,7 +2974,7 @@ void BKE_ptcache_bake(PTCacheBaker* baker) CFRA = cfrao; if (bake) /* already on cfra unless baking */ - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); if (thread_data.break_operation) WM_cursor_wait(0); diff --git a/source/blender/blenkernel/intern/property.c b/source/blender/blenkernel/intern/property.c index e7247be7f51..b82521504dd 100644 --- a/source/blender/blenkernel/intern/property.c +++ b/source/blender/blenkernel/intern/property.c @@ -57,7 +57,7 @@ void free_properties(ListBase *lb) { bProperty *prop; - while ( (prop= lb->first) ) { + while ( (prop = lb->first) ) { BLI_remlink(lb, prop); free_property(prop); } @@ -67,11 +67,11 @@ bProperty *copy_property(bProperty *prop) { bProperty *propn; - propn= MEM_dupallocN(prop); + propn = MEM_dupallocN(prop); if (prop->poin && prop->poin != &prop->data) { - propn->poin= MEM_dupallocN(prop->poin); + propn->poin = MEM_dupallocN(prop->poin); } - else propn->poin= &propn->data; + else propn->poin = &propn->data; return propn; } @@ -80,11 +80,11 @@ void copy_properties(ListBase *lbn, ListBase *lbo) { bProperty *prop, *propn; free_properties(lbn); /* in case we are copying to an object with props */ - prop= lbo->first; + prop = lbo->first; while (prop) { - propn= copy_property(prop); + propn = copy_property(prop); BLI_addtail(lbn, propn); - prop= prop->next; + prop = prop->next; } @@ -95,20 +95,20 @@ void init_property(bProperty *prop) /* also use when property changes type */ if (prop->poin && prop->poin != &prop->data) MEM_freeN(prop->poin); - prop->poin= NULL; + prop->poin = NULL; - prop->data= 0; + prop->data = 0; switch (prop->type) { - case GPROP_BOOL: - case GPROP_INT: - case GPROP_FLOAT: - case GPROP_TIME: - prop->poin= &prop->data; - break; - case GPROP_STRING: - prop->poin= MEM_callocN(MAX_PROPSTRING, "property string"); - break; + case GPROP_BOOL: + case GPROP_INT: + case GPROP_FLOAT: + case GPROP_TIME: + prop->poin = &prop->data; + break; + case GPROP_STRING: + prop->poin = MEM_callocN(MAX_PROPSTRING, "property string"); + break; } } @@ -117,8 +117,8 @@ bProperty *new_property(int type) { bProperty *prop; - prop= MEM_callocN(sizeof(bProperty), "property"); - prop->type= type; + prop = MEM_callocN(sizeof(bProperty), "property"); + prop->type = type; init_property(prop); @@ -131,8 +131,8 @@ bProperty *new_property(int type) static bProperty *get_property__internal(bProperty *first, bProperty *self, const char *name) { bProperty *p; - for (p= first; p; p= p->next) { - if (p!=self && (strcmp(p->name, name)==0)) + for (p = first; p; p = p->next) { + if (p != self && (strcmp(p->name, name) == 0)) return p; } return NULL; @@ -142,10 +142,10 @@ void unique_property(bProperty *first, bProperty *prop, int force) bProperty *p; /* set the first if its not set */ - if (first==NULL) { - first= prop; + if (first == NULL) { + first = prop; while (first->prev) { - first= first->prev; + first = first->prev; } } @@ -162,14 +162,14 @@ void unique_property(bProperty *first, bProperty *prop, int force) char new_name[sizeof(prop->name)]; char base_name[sizeof(prop->name)]; char num[sizeof(prop->name)]; - int i= 0; + int i = 0; /* strip numbers */ BLI_strncpy(base_name, prop->name, sizeof(base_name)); - for (i= strlen(base_name)-1; (i>=0 && isdigit(base_name[i])); i--) { - base_name[i]= '\0'; + for (i = strlen(base_name) - 1; (i >= 0 && isdigit(base_name[i])); i--) { + base_name[i] = '\0'; } - i= 0; + i = 0; do { /* ensure we have enough chars for the new number in the name */ BLI_snprintf(num, sizeof(num), "%d", i++); @@ -190,7 +190,7 @@ bProperty *get_ob_property(Object *ob, const char *name) void set_ob_property(Object *ob, bProperty *propc) { bProperty *prop; - prop= get_ob_property(ob, propc->name); + prop = get_ob_property(ob, propc->name); if (prop) { free_property(prop); BLI_remlink(&ob->prop, prop); @@ -207,32 +207,32 @@ int compare_property(bProperty *prop, const char *str) float fvalue, ftest; switch (prop->type) { - case GPROP_BOOL: - if (BLI_strcasecmp(str, "true")==0) { - if (prop->data==1) return 0; - else return 1; - } - else if (BLI_strcasecmp(str, "false")==0) { - if (prop->data==0) return 0; - else return 1; - } + case GPROP_BOOL: + if (BLI_strcasecmp(str, "true") == 0) { + if (prop->data == 1) return 0; + else return 1; + } + else if (BLI_strcasecmp(str, "false") == 0) { + if (prop->data == 0) return 0; + else return 1; + } /* no break, do GPROP_int too! */ - case GPROP_INT: - return prop->data - atoi(str); + case GPROP_INT: + return prop->data - atoi(str); - case GPROP_FLOAT: - case GPROP_TIME: - // WARNING: untested for GPROP_TIME - // function isn't used currently - fvalue= *((float *)&prop->data); - ftest= (float)atof(str); - if ( fvalue > ftest) return 1; - else if ( fvalue < ftest) return -1; - return 0; + case GPROP_FLOAT: + case GPROP_TIME: + // WARNING: untested for GPROP_TIME + // function isn't used currently + fvalue = *((float *)&prop->data); + ftest = (float)atof(str); + if (fvalue > ftest) return 1; + else if (fvalue < ftest) return -1; + return 0; - case GPROP_STRING: - return strcmp(prop->poin, str); + case GPROP_STRING: + return strcmp(prop->poin, str); } return 0; @@ -243,21 +243,21 @@ void set_property(bProperty *prop, const char *str) // extern int Gdfra; /* sector.c */ switch (prop->type) { - case GPROP_BOOL: - if (BLI_strcasecmp(str, "true")==0) prop->data= 1; - else if (BLI_strcasecmp(str, "false")==0) prop->data= 0; - else prop->data= (atoi(str)!=0); - break; - case GPROP_INT: - prop->data= atoi(str); - break; - case GPROP_FLOAT: - case GPROP_TIME: - *((float *)&prop->data)= (float)atof(str); - break; - case GPROP_STRING: - strcpy(prop->poin, str); /* TODO - check size? */ - break; + case GPROP_BOOL: + if (BLI_strcasecmp(str, "true") == 0) prop->data = 1; + else if (BLI_strcasecmp(str, "false") == 0) prop->data = 0; + else prop->data = (atoi(str) != 0); + break; + case GPROP_INT: + prop->data = atoi(str); + break; + case GPROP_FLOAT: + case GPROP_TIME: + *((float *)&prop->data) = (float)atof(str); + break; + case GPROP_STRING: + strcpy(prop->poin, str); /* TODO - check size? */ + break; } } @@ -267,17 +267,17 @@ void add_property(bProperty *prop, const char *str) // extern int Gdfra; /* sector.c */ switch (prop->type) { - case GPROP_BOOL: - case GPROP_INT: - prop->data+= atoi(str); - break; - case GPROP_FLOAT: - case GPROP_TIME: - *((float *)&prop->data)+= (float)atof(str); - break; - case GPROP_STRING: - /* strcpy(prop->poin, str); */ - break; + case GPROP_BOOL: + case GPROP_INT: + prop->data += atoi(str); + break; + case GPROP_FLOAT: + case GPROP_TIME: + *((float *)&prop->data) += (float)atof(str); + break; + case GPROP_STRING: + /* strcpy(prop->poin, str); */ + break; } } @@ -289,17 +289,17 @@ void set_property_valstr(bProperty *prop, char *str) if (str == NULL) return; switch (prop->type) { - case GPROP_BOOL: - case GPROP_INT: - sprintf(str, "%d", prop->data); - break; - case GPROP_FLOAT: - case GPROP_TIME: - sprintf(str, "%f", *((float *)&prop->data)); - break; - case GPROP_STRING: - BLI_strncpy(str, prop->poin, MAX_PROPSTRING); - break; + case GPROP_BOOL: + case GPROP_INT: + sprintf(str, "%d", prop->data); + break; + case GPROP_FLOAT: + case GPROP_TIME: + sprintf(str, "%f", *((float *)&prop->data)); + break; + case GPROP_STRING: + BLI_strncpy(str, prop->poin, MAX_PROPSTRING); + break; } } diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 2d3c18ff03b..36963e55606 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -112,7 +112,7 @@ void free_qtcodecdata(QuicktimeCodecData *qcd) } } -Scene *copy_scene(Scene *sce, int type) +Scene *BKE_scene_copy(Scene *sce, int type) { Scene *scen; ToolSettings *ts; @@ -120,20 +120,20 @@ Scene *copy_scene(Scene *sce, int type) if (type == SCE_COPY_EMPTY) { ListBase lb; - scen= add_scene(sce->id.name+2); + scen = BKE_scene_add(sce->id.name + 2); - lb= scen->r.layers; - scen->r= sce->r; - scen->r.layers= lb; - scen->unit= sce->unit; - scen->physics_settings= sce->physics_settings; - scen->gm= sce->gm; - scen->audio= sce->audio; + lb = scen->r.layers; + scen->r = sce->r; + scen->r.layers = lb; + scen->unit = sce->unit; + scen->physics_settings = sce->physics_settings; + scen->gm = sce->gm; + scen->audio = sce->audio; MEM_freeN(scen->toolsettings); } else { - scen= copy_libblock(&sce->id); + scen = BKE_libblock_copy(&sce->id); BLI_duplicatelist(&(scen->base), &(sce->base)); clear_id_newpoins(); @@ -142,11 +142,11 @@ Scene *copy_scene(Scene *sce, int type) id_us_plus((ID *)scen->set); id_us_plus((ID *)scen->gm.dome.warptext); - scen->ed= NULL; - scen->theDag= NULL; - scen->obedit= NULL; - scen->stats= NULL; - scen->fps_info= NULL; + scen->ed = NULL; + scen->theDag = NULL; + scen->obedit = NULL; + scen->stats = NULL; + scen->fps_info = NULL; BLI_duplicatelist(&(scen->markers), &(sce->markers)); BLI_duplicatelist(&(scen->transform_spaces), &(sce->transform_spaces)); @@ -154,48 +154,48 @@ Scene *copy_scene(Scene *sce, int type) BKE_keyingsets_copy(&(scen->keyingsets), &(sce->keyingsets)); if (sce->nodetree) { - scen->nodetree= ntreeCopyTree(sce->nodetree); /* copies actions */ + scen->nodetree = ntreeCopyTree(sce->nodetree); /* copies actions */ ntreeSwitchID(scen->nodetree, &sce->id, &scen->id); } - obase= sce->base.first; - base= scen->base.first; + obase = sce->base.first; + base = scen->base.first; while (base) { id_us_plus(&base->object->id); - if (obase==sce->basact) scen->basact= base; + if (obase == sce->basact) scen->basact = base; - obase= obase->next; - base= base->next; + obase = obase->next; + base = base->next; } } /* tool settings */ - scen->toolsettings= MEM_dupallocN(sce->toolsettings); + scen->toolsettings = MEM_dupallocN(sce->toolsettings); - ts= scen->toolsettings; + ts = scen->toolsettings; if (ts) { if (ts->vpaint) { - ts->vpaint= MEM_dupallocN(ts->vpaint); - ts->vpaint->paintcursor= NULL; - ts->vpaint->vpaint_prev= NULL; - ts->vpaint->wpaint_prev= NULL; + ts->vpaint = MEM_dupallocN(ts->vpaint); + ts->vpaint->paintcursor = NULL; + ts->vpaint->vpaint_prev = NULL; + ts->vpaint->wpaint_prev = NULL; copy_paint(&ts->vpaint->paint, &ts->vpaint->paint); } if (ts->wpaint) { - ts->wpaint= MEM_dupallocN(ts->wpaint); - ts->wpaint->paintcursor= NULL; - ts->wpaint->vpaint_prev= NULL; - ts->wpaint->wpaint_prev= NULL; + ts->wpaint = MEM_dupallocN(ts->wpaint); + ts->wpaint->paintcursor = NULL; + ts->wpaint->vpaint_prev = NULL; + ts->wpaint->wpaint_prev = NULL; copy_paint(&ts->wpaint->paint, &ts->wpaint->paint); } if (ts->sculpt) { - ts->sculpt= MEM_dupallocN(ts->sculpt); + ts->sculpt = MEM_dupallocN(ts->sculpt); copy_paint(&ts->sculpt->paint, &ts->sculpt->paint); } copy_paint(&ts->imapaint.paint, &ts->imapaint.paint); - ts->imapaint.paintcursor= NULL; - ts->particle.paintcursor= NULL; + ts->imapaint.paintcursor = NULL; + ts->particle.paintcursor = NULL; } /* make a private copy of the avicodecdata */ @@ -212,7 +212,7 @@ Scene *copy_scene(Scene *sce, int type) } if (sce->r.ffcodecdata.properties) { /* intentionally check scen not sce. */ - scen->r.ffcodecdata.properties= IDP_CopyProperty(sce->r.ffcodecdata.properties); + scen->r.ffcodecdata.properties = IDP_CopyProperty(sce->r.ffcodecdata.properties); } /* NOTE: part of SCE_COPY_LINK_DATA and SCE_COPY_FULL operations @@ -231,13 +231,13 @@ Scene *copy_scene(Scene *sce, int type) BKE_copy_animdata_id_action((ID *)scen); if (scen->world) { id_us_plus((ID *)scen->world); - scen->world= copy_world(scen->world); + scen->world = BKE_world_copy(scen->world); BKE_copy_animdata_id_action((ID *)scen->world); } if (sce->ed) { - scen->ed= MEM_callocN(sizeof(Editing), "addseq"); - scen->ed->seqbasep= &scen->ed->seqbase; + scen->ed = MEM_callocN(sizeof(Editing), "addseq"); + scen->ed->seqbasep = &scen->ed->seqbase; seqbase_dupli_recursive(sce, scen, &scen->ed->seqbase, &sce->ed->seqbase, SEQ_DUPE_ALL); } } @@ -246,15 +246,15 @@ Scene *copy_scene(Scene *sce, int type) } /* do not free scene itself */ -void free_scene(Scene *sce) +void BKE_scene_free(Scene *sce) { Base *base; SceneRenderLayer *srl; - base= sce->base.first; + base = sce->base.first; while (base) { base->object->id.us--; - base= base->next; + base = base->next; } /* do not free objects! */ @@ -265,11 +265,11 @@ void free_scene(Scene *sce) // its probably safe not to do this, some save and reload will free this. sce->gpd->id.us--; #endif - sce->gpd= NULL; + sce->gpd = NULL; } BLI_freelistN(&sce->base); - seq_free_editing(sce); + BKE_sequencer_editing_free(sce); BKE_free_animdata((ID *)sce); BKE_keyingsets_free(&sce->keyingsets); @@ -339,76 +339,76 @@ void free_scene(Scene *sce) sound_destroy_scene(sce); } -Scene *add_scene(const char *name) +Scene *BKE_scene_add(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Scene *sce; ParticleEditSettings *pset; int a; - sce= alloc_libblock(&bmain->scene, ID_SCE, name); - sce->lay= sce->layact= 1; + sce = BKE_libblock_alloc(&bmain->scene, ID_SCE, name); + sce->lay = sce->layact = 1; - sce->r.mode= R_GAMMA|R_OSA|R_SHADOW|R_SSS|R_ENVMAP|R_RAYTRACE; - sce->r.cfra= 1; - sce->r.sfra= 1; - sce->r.efra= 250; - sce->r.frame_step= 1; - sce->r.xsch= 1920; - sce->r.ysch= 1080; - sce->r.xasp= 1; - sce->r.yasp= 1; - sce->r.xparts= 8; - sce->r.yparts= 8; - sce->r.mblur_samples= 1; - sce->r.filtertype= R_FILTER_MITCH; - sce->r.size= 50; + sce->r.mode = R_GAMMA | R_OSA | R_SHADOW | R_SSS | R_ENVMAP | R_RAYTRACE; + sce->r.cfra = 1; + sce->r.sfra = 1; + sce->r.efra = 250; + sce->r.frame_step = 1; + sce->r.xsch = 1920; + sce->r.ysch = 1080; + sce->r.xasp = 1; + sce->r.yasp = 1; + sce->r.xparts = 8; + sce->r.yparts = 8; + sce->r.mblur_samples = 1; + sce->r.filtertype = R_FILTER_MITCH; + sce->r.size = 50; - sce->r.im_format.planes= R_IMF_PLANES_RGB; - sce->r.im_format.imtype= R_IMF_IMTYPE_PNG; - sce->r.im_format.quality= 90; + sce->r.im_format.planes = R_IMF_PLANES_RGB; + sce->r.im_format.imtype = R_IMF_IMTYPE_PNG; + sce->r.im_format.quality = 90; - sce->r.displaymode= R_OUTPUT_AREA; - sce->r.framapto= 100; - sce->r.images= 100; - sce->r.framelen= 1.0; - sce->r.blurfac= 0.5; - sce->r.frs_sec= 24; - sce->r.frs_sec_base= 1; - sce->r.edgeint= 10; + sce->r.displaymode = R_OUTPUT_AREA; + sce->r.framapto = 100; + sce->r.images = 100; + sce->r.framelen = 1.0; + sce->r.blurfac = 0.5; + sce->r.frs_sec = 24; + sce->r.frs_sec_base = 1; + sce->r.edgeint = 10; sce->r.ocres = 128; sce->r.color_mgt_flag |= R_COLOR_MANAGEMENT; - sce->r.gauss= 1.0; + sce->r.gauss = 1.0; /* deprecated but keep for upwards compat */ - sce->r.postgamma= 1.0; - sce->r.posthue= 0.0; - sce->r.postsat= 1.0; - - sce->r.bake_mode= 1; /* prevent to include render stuff here */ - sce->r.bake_filter= 2; - sce->r.bake_osa= 5; - sce->r.bake_flag= R_BAKE_CLEAR; - sce->r.bake_normal_space= R_BAKE_SPACE_TANGENT; - sce->r.scemode= R_DOCOMP|R_DOSEQ|R_EXTENSION; - sce->r.stamp= R_STAMP_TIME|R_STAMP_FRAME|R_STAMP_DATE|R_STAMP_CAMERA|R_STAMP_SCENE|R_STAMP_FILENAME|R_STAMP_RENDERTIME; - sce->r.stamp_font_id= 12; - sce->r.fg_stamp[0]= sce->r.fg_stamp[1]= sce->r.fg_stamp[2]= 0.8f; - sce->r.fg_stamp[3]= 1.0f; - sce->r.bg_stamp[0]= sce->r.bg_stamp[1]= sce->r.bg_stamp[2]= 0.0f; - sce->r.bg_stamp[3]= 0.25f; + sce->r.postgamma = 1.0; + sce->r.posthue = 0.0; + sce->r.postsat = 1.0; + + sce->r.bake_mode = 1; /* prevent to include render stuff here */ + sce->r.bake_filter = 2; + sce->r.bake_osa = 5; + sce->r.bake_flag = R_BAKE_CLEAR; + sce->r.bake_normal_space = R_BAKE_SPACE_TANGENT; + sce->r.scemode = R_DOCOMP | R_DOSEQ | R_EXTENSION; + sce->r.stamp = R_STAMP_TIME | R_STAMP_FRAME | R_STAMP_DATE | R_STAMP_CAMERA | R_STAMP_SCENE | R_STAMP_FILENAME | R_STAMP_RENDERTIME; + sce->r.stamp_font_id = 12; + sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; + sce->r.fg_stamp[3] = 1.0f; + sce->r.bg_stamp[0] = sce->r.bg_stamp[1] = sce->r.bg_stamp[2] = 0.0f; + sce->r.bg_stamp[3] = 0.25f; sce->r.raytrace_options = R_RAYTRACE_USE_INSTANCES; - sce->r.seq_prev_type= OB_SOLID; - sce->r.seq_rend_type= OB_SOLID; - sce->r.seq_flag= R_SEQ_GL_PREV; + sce->r.seq_prev_type = OB_SOLID; + sce->r.seq_rend_type = OB_SOLID; + sce->r.seq_flag = R_SEQ_GL_PREV; - sce->r.threads= 1; + sce->r.threads = 1; - sce->r.simplify_subsurf= 6; - sce->r.simplify_particles= 1.0f; - sce->r.simplify_shadowsamples= 16; - sce->r.simplify_aosss= 1.0f; + sce->r.simplify_subsurf = 6; + sce->r.simplify_particles = 1.0f; + sce->r.simplify_shadowsamples = 16; + sce->r.simplify_aosss = 1.0f; sce->r.border.xmin = 0.0f; sce->r.border.ymin = 0.0f; @@ -416,7 +416,7 @@ Scene *add_scene(const char *name) sce->r.border.ymax = 1.0f; sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); - sce->toolsettings->cornertype=1; + sce->toolsettings->cornertype = 1; sce->toolsettings->degr = 90; sce->toolsettings->step = 9; sce->toolsettings->turn = 1; @@ -430,25 +430,25 @@ Scene *add_scene(const char *name) sce->toolsettings->uvcalc_mapdir = 1; sce->toolsettings->uvcalc_mapalign = 1; sce->toolsettings->unwrapper = 1; - sce->toolsettings->select_thresh= 0.01f; + sce->toolsettings->select_thresh = 0.01f; sce->toolsettings->jointrilimit = 0.8f; - sce->toolsettings->selectmode= SCE_SELECT_VERTEX; - sce->toolsettings->uv_selectmode= UV_SELECT_VERTEX; - sce->toolsettings->normalsize= 0.1; - sce->toolsettings->autokey_mode= U.autokey_mode; + sce->toolsettings->selectmode = SCE_SELECT_VERTEX; + sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX; + sce->toolsettings->normalsize = 0.1; + sce->toolsettings->autokey_mode = U.autokey_mode; sce->toolsettings->skgen_resolution = 100; - sce->toolsettings->skgen_threshold_internal = 0.01f; - sce->toolsettings->skgen_threshold_external = 0.01f; - sce->toolsettings->skgen_angle_limit = 45.0f; - sce->toolsettings->skgen_length_ratio = 1.3f; - sce->toolsettings->skgen_length_limit = 1.5f; - sce->toolsettings->skgen_correlation_limit = 0.98f; - sce->toolsettings->skgen_symmetry_limit = 0.1f; + sce->toolsettings->skgen_threshold_internal = 0.01f; + sce->toolsettings->skgen_threshold_external = 0.01f; + sce->toolsettings->skgen_angle_limit = 45.0f; + sce->toolsettings->skgen_length_ratio = 1.3f; + sce->toolsettings->skgen_length_limit = 1.5f; + sce->toolsettings->skgen_correlation_limit = 0.98f; + sce->toolsettings->skgen_symmetry_limit = 0.1f; sce->toolsettings->skgen_postpro = SKGEN_SMOOTH; sce->toolsettings->skgen_postpro_passes = 1; - sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL|SKGEN_FILTER_EXTERNAL|SKGEN_FILTER_SMART|SKGEN_HARMONIC|SKGEN_SUB_CORRELATION|SKGEN_STICK_TO_EMBEDDING; + sce->toolsettings->skgen_options = SKGEN_FILTER_INTERNAL | SKGEN_FILTER_EXTERNAL | SKGEN_FILTER_SMART | SKGEN_HARMONIC | SKGEN_SUB_CORRELATION | SKGEN_STICK_TO_EMBEDDING; sce->toolsettings->skgen_subdivisions[0] = SKGEN_SUB_CORRELATION; sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; @@ -462,22 +462,22 @@ Scene *add_scene(const char *name) sce->unit.scale_length = 1.0f; - pset= &sce->toolsettings->particle; - pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER|PE_AUTO_VELOCITY; - pset->emitterdist= 0.25f; - pset->totrekey= 5; - pset->totaddkey= 5; - pset->brushtype= PE_BRUSH_NONE; - pset->draw_step= 2; - pset->fade_frames= 2; - pset->selectmode= SCE_SELECT_PATH; - for (a=0; abrush[a].strength= 0.5; - pset->brush[a].size= 50; - pset->brush[a].step= 10; - pset->brush[a].count= 10; + pset = &sce->toolsettings->particle; + pset->flag = PE_KEEP_LENGTHS | PE_LOCK_FIRST | PE_DEFLECT_EMITTER | PE_AUTO_VELOCITY; + pset->emitterdist = 0.25f; + pset->totrekey = 5; + pset->totaddkey = 5; + pset->brushtype = PE_BRUSH_NONE; + pset->draw_step = 2; + pset->fade_frames = 2; + pset->selectmode = SCE_SELECT_PATH; + for (a = 0; a < PE_TOT_BRUSH; a++) { + pset->brush[a].strength = 0.5; + pset->brush[a].size = 50; + pset->brush[a].step = 10; + pset->brush[a].count = 10; } - pset->brush[PE_BRUSH_CUT].strength= 100; + pset->brush[PE_BRUSH_CUT].strength = 100; sce->r.ffcodecdata.audio_mixrate = 44100; sce->r.ffcodecdata.audio_volume = 1.0f; @@ -494,10 +494,10 @@ Scene *add_scene(const char *name) BLI_strncpy(sce->r.pic, U.renderdir, sizeof(sce->r.pic)); BLI_init_rctf(&sce->r.safety, 0.1f, 0.9f, 0.1f, 0.9f); - sce->r.osa= 8; + sce->r.osa = 8; /* note; in header_info.c the scene copy happens..., if you add more to renderdata it has to be checked there */ - scene_add_render_layer(sce, NULL); + BKE_scene_add_render_layer(sce, NULL); /* game data */ sce->gm.stereoflag = STEREO_NOSTEREO; @@ -510,13 +510,13 @@ Scene *add_scene(const char *name) sce->gm.dome.resbuf = 1.0f; sce->gm.dome.tilt = 0; - sce->gm.xplay= 640; - sce->gm.yplay= 480; - sce->gm.freqplay= 60; - sce->gm.depth= 32; + sce->gm.xplay = 640; + sce->gm.yplay = 480; + sce->gm.freqplay = 60; + sce->gm.depth = 32; - sce->gm.gravity= 9.8f; - sce->gm.physicsEngine= WOPHY_BULLET; + sce->gm.gravity = 9.8f; + sce->gm.physicsEngine = WOPHY_BULLET; sce->gm.mode = 32; //XXX ugly harcoding, still not sure we should drop mode. 32 == 1 << 5 == use_occlusion_culling sce->gm.occlusionRes = 128; sce->gm.ticrate = 60; @@ -527,12 +527,12 @@ Scene *add_scene(const char *name) sce->gm.flag = GAME_DISPLAY_LISTS; sce->gm.matmode = GAME_MAT_MULTITEX; - sce->gm.obstacleSimulation= OBSTSIMULATION_NONE; + sce->gm.obstacleSimulation = OBSTSIMULATION_NONE; sce->gm.levelHeight = 2.f; sce->gm.recastData.cellsize = 0.3f; sce->gm.recastData.cellheight = 0.2f; - sce->gm.recastData.agentmaxslope = M_PI/2; + sce->gm.recastData.agentmaxslope = M_PI / 2; sce->gm.recastData.agentmaxclimb = 0.9f; sce->gm.recastData.agentheight = 2.0f; sce->gm.recastData.agentradius = 0.6f; @@ -551,19 +551,19 @@ Scene *add_scene(const char *name) return sce; } -Base *object_in_scene(Object *ob, Scene *sce) +Base *BKE_scene_base_find(Scene *scene, Object *ob) { Base *base; - base= sce->base.first; + base = scene->base.first; while (base) { if (base->object == ob) return base; - base= base->next; + base = base->next; } return NULL; } -void set_scene_bg(Main *bmain, Scene *scene) +void BKE_scene_set_background(Main *bmain, Scene *scene) { Scene *sce; Base *base; @@ -573,22 +573,22 @@ void set_scene_bg(Main *bmain, Scene *scene) int flag; /* check for cyclic sets, for reading old files but also for definite security (py?) */ - scene_check_setscene(bmain, scene); + BKE_scene_validate_setscene(bmain, scene); /* can happen when switching modes in other scenes */ if (scene->obedit && !(scene->obedit->mode & OB_MODE_EDIT)) - scene->obedit= NULL; + scene->obedit = NULL; /* deselect objects (for dataselect) */ - for (ob= bmain->object.first; ob; ob= ob->id.next) - ob->flag &= ~(SELECT|OB_FROMGROUP); + for (ob = bmain->object.first; ob; ob = ob->id.next) + ob->flag &= ~(SELECT | OB_FROMGROUP); /* group flags again */ - for (group= bmain->group.first; group; group= group->id.next) { - go= group->gobject.first; + for (group = bmain->group.first; group; group = group->id.next) { + go = group->gobject.first; while (go) { if (go->ob) go->ob->flag |= OB_FROMGROUP; - go= go->next; + go = go->next; } } @@ -596,35 +596,35 @@ void set_scene_bg(Main *bmain, Scene *scene) DAG_scene_sort(bmain, scene); /* ensure dags are built for sets */ - for (sce= scene->set; sce; sce= sce->set) - if (sce->theDag==NULL) + for (sce = scene->set; sce; sce = sce->set) + if (sce->theDag == NULL) DAG_scene_sort(bmain, sce); /* copy layers and flags from bases to objects */ - for (base= scene->base.first; base; base= base->next) { - ob= base->object; - ob->lay= base->lay; + for (base = scene->base.first; base; base = base->next) { + ob = base->object; + ob->lay = base->lay; /* group patch... */ base->flag &= ~(OB_FROMGROUP); - flag= ob->flag & (OB_FROMGROUP); + flag = ob->flag & (OB_FROMGROUP); base->flag |= flag; /* not too nice... for recovering objects with lost data */ //if (ob->pose==NULL) base->flag &= ~OB_POSEMODE; - ob->flag= base->flag; + ob->flag = base->flag; - ob->ctime= -1234567.0; /* force ipo to be calculated later */ + ob->ctime = -1234567.0; /* force ipo to be calculated later */ } /* no full animation update, this to enable render code to work (render code calls own animation updates) */ } /* called from creator.c */ -Scene *set_scene_name(Main *bmain, const char *name) +Scene *BKE_scene_set_name(Main *bmain, const char *name) { - Scene *sce= (Scene *)find_id("SC", name); + Scene *sce = (Scene *)BKE_libblock_find_name(ID_SCE, name); if (sce) { - set_scene_bg(bmain, sce); + BKE_scene_set_background(bmain, sce); printf("Scene switch: '%s' in file: '%s'\n", name, G.main->name); return sce; } @@ -633,15 +633,15 @@ Scene *set_scene_name(Main *bmain, const char *name) return NULL; } -void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) +void BKE_scene_unlink(Main *bmain, Scene *sce, Scene *newsce) { Scene *sce1; bScreen *sc; /* check all sets */ - for (sce1= bmain->scene.first; sce1; sce1= sce1->id.next) + for (sce1 = bmain->scene.first; sce1; sce1 = sce1->id.next) if (sce1->set == sce) - sce1->set= NULL; + sce1->set = NULL; /* check all sequences */ clear_scene_in_allseqs(bmain, sce); @@ -650,27 +650,27 @@ void unlink_scene(Main *bmain, Scene *sce, Scene *newsce) clear_scene_in_nodes(bmain, sce); /* al screens */ - for (sc= bmain->screen.first; sc; sc= sc->id.next) + for (sc = bmain->screen.first; sc; sc = sc->id.next) if (sc->scene == sce) - sc->scene= newsce; + sc->scene = newsce; - free_libblock(&bmain->scene, sce); + BKE_libblock_free(&bmain->scene, sce); } /* used by metaballs * doesnt return the original duplicated object, only dupli's */ -int next_object(Scene **scene, int val, Base **base, Object **ob) +int BKE_scene_base_iter_next(Scene **scene, int val, Base **base, Object **ob) { - static ListBase *duplilist= NULL; + static ListBase *duplilist = NULL; static DupliObject *dupob; - static int fase= F_START, in_next_object= 0; - int run_again=1; + static int fase = F_START, in_next_object = 0; + int run_again = 1; /* init */ - if (val==0) { - fase= F_START; - dupob= NULL; + if (val == 0) { + fase = F_START; + dupob = NULL; /* XXX particle systems with metas+dupligroups call this recursively */ /* see bug #18725 */ @@ -681,44 +681,44 @@ int next_object(Scene **scene, int val, Base **base, Object **ob) } } else { - in_next_object= 1; + in_next_object = 1; /* run_again is set when a duplilist has been ended */ while (run_again) { - run_again= 0; + run_again = 0; /* the first base */ - if (fase==F_START) { - *base= (*scene)->base.first; + if (fase == F_START) { + *base = (*scene)->base.first; if (*base) { - *ob= (*base)->object; - fase= F_SCENE; + *ob = (*base)->object; + fase = F_SCENE; } else { /* exception: empty scene */ while ((*scene)->set) { - (*scene)= (*scene)->set; + (*scene) = (*scene)->set; if ((*scene)->base.first) { - *base= (*scene)->base.first; - *ob= (*base)->object; - fase= F_SCENE; + *base = (*scene)->base.first; + *ob = (*base)->object; + fase = F_SCENE; break; } } } } else { - if (*base && fase!=F_DUPLI) { - *base= (*base)->next; - if (*base) *ob= (*base)->object; + if (*base && fase != F_DUPLI) { + *base = (*base)->next; + if (*base) *ob = (*base)->object; else { - if (fase==F_SCENE) { + if (fase == F_SCENE) { /* (*scene) is finished, now do the set */ while ((*scene)->set) { - (*scene)= (*scene)->set; + (*scene) = (*scene)->set; if ((*scene)->base.first) { - *base= (*scene)->base.first; - *ob= (*base)->object; + *base = (*scene)->base.first; + *ob = (*base)->object; break; } } @@ -727,17 +727,17 @@ int next_object(Scene **scene, int val, Base **base, Object **ob) } } - if (*base == NULL) fase= F_START; + if (*base == NULL) fase = F_START; else { - if (fase!=F_DUPLI) { + if (fase != F_DUPLI) { if ( (*base)->object->transflag & OB_DUPLI) { /* groups cannot be duplicated for mballs yet, * this enters eternal loop because of * makeDispListMBall getting called inside of group_duplilist */ if ((*base)->object->dup_group == NULL) { - duplilist= object_duplilist((*scene), (*base)->object); + duplilist = object_duplilist((*scene), (*base)->object); - dupob= duplilist->first; + dupob = duplilist->first; if (!dupob) free_object_duplilist(duplilist); @@ -750,22 +750,22 @@ int next_object(Scene **scene, int val, Base **base, Object **ob) copy_m4_m4(dupob->ob->obmat, dupob->mat); (*base)->flag |= OB_FROMDUPLI; - *ob= dupob->ob; - fase= F_DUPLI; + *ob = dupob->ob; + fase = F_DUPLI; - dupob= dupob->next; + dupob = dupob->next; } - else if (fase==F_DUPLI) { - fase= F_SCENE; + else if (fase == F_DUPLI) { + fase = F_SCENE; (*base)->flag &= ~OB_FROMDUPLI; - for (dupob= duplilist->first; dupob; dupob= dupob->next) { + for (dupob = duplilist->first; dupob; dupob = dupob->next) { copy_m4_m4(dupob->ob->obmat, dupob->omat); } free_object_duplilist(duplilist); - duplilist= NULL; - run_again= 1; + duplilist = NULL; + run_again = 1; } } } @@ -773,39 +773,39 @@ int next_object(Scene **scene, int val, Base **base, Object **ob) #if 0 if (ob && *ob) { - printf("Scene: '%s', '%s'\n", (*scene)->id.name+2, (*ob)->id.name+2); + printf("Scene: '%s', '%s'\n", (*scene)->id.name + 2, (*ob)->id.name + 2); } #endif /* reset recursion test */ - in_next_object= 0; + in_next_object = 0; return fase; } -Object *scene_find_camera(Scene *sc) +Object *BKE_scene_camera_find(Scene *sc) { Base *base; - for (base= sc->base.first; base; base= base->next) - if (base->object->type==OB_CAMERA) + for (base = sc->base.first; base; base = base->next) + if (base->object->type == OB_CAMERA) return base->object; return NULL; } #ifdef DURIAN_CAMERA_SWITCH -Object *scene_camera_switch_find(Scene *scene) +Object *BKE_scene_camera_switch_find(Scene *scene) { TimeMarker *m; int cfra = scene->r.cfra; int frame = -(MAXFRAME + 1); - Object *camera= NULL; + Object *camera = NULL; - for (m= scene->markers.first; m; m= m->next) { - if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER)==0 && (m->frame <= cfra) && (m->frame > frame)) { - camera= m->camera; - frame= m->frame; + for (m = scene->markers.first; m; m = m->next) { + if (m->camera && (m->camera->restrictflag & OB_RESTRICT_RENDER) == 0 && (m->frame <= cfra) && (m->frame > frame)) { + camera = m->camera; + frame = m->frame; if (frame == cfra) break; @@ -816,12 +816,12 @@ Object *scene_camera_switch_find(Scene *scene) } #endif -int scene_camera_switch_update(Scene *scene) +int BKE_scene_camera_switch_update(Scene *scene) { #ifdef DURIAN_CAMERA_SWITCH - Object *camera= scene_camera_switch_find(scene); + Object *camera = BKE_scene_camera_switch_find(scene); if (camera) { - scene->camera= camera; + scene->camera = camera; return 1; } #else @@ -830,20 +830,20 @@ int scene_camera_switch_update(Scene *scene) return 0; } -char *scene_find_marker_name(Scene *scene, int frame) +char *BKE_scene_find_marker_name(Scene *scene, int frame) { - ListBase *markers= &scene->markers; + ListBase *markers = &scene->markers; TimeMarker *m1, *m2; /* search through markers for match */ - for (m1=markers->first, m2=markers->last; m1 && m2; m1=m1->next, m2=m2->prev) { - if (m1->frame==frame) + for (m1 = markers->first, m2 = markers->last; m1 && m2; m1 = m1->next, m2 = m2->prev) { + if (m1->frame == frame) return m1->name; if (m1 == m2) break; - if (m2->frame==frame) + if (m2->frame == frame) return m2->name; } @@ -852,16 +852,16 @@ char *scene_find_marker_name(Scene *scene, int frame) /* return the current marker for this frame, * we can have more then 1 marker per frame, this just returns the first :/ */ -char *scene_find_last_marker_name(Scene *scene, int frame) +char *BKE_scene_find_last_marker_name(Scene *scene, int frame) { TimeMarker *marker, *best_marker = NULL; - int best_frame = -MAXFRAME*2; - for (marker= scene->markers.first; marker; marker= marker->next) { - if (marker->frame==frame) { + int best_frame = -MAXFRAME * 2; + for (marker = scene->markers.first; marker; marker = marker->next) { + if (marker->frame == frame) { return marker->name; } - if ( marker->frame > best_frame && marker->frame < frame) { + if (marker->frame > best_frame && marker->frame < frame) { best_marker = marker; best_frame = marker->frame; } @@ -871,53 +871,53 @@ char *scene_find_last_marker_name(Scene *scene, int frame) } -Base *scene_add_base(Scene *sce, Object *ob) +Base *BKE_scene_base_add(Scene *sce, Object *ob) { - Base *b= MEM_callocN(sizeof(*b), "scene_add_base"); + Base *b = MEM_callocN(sizeof(*b), "BKE_scene_base_add"); BLI_addhead(&sce->base, b); - b->object= ob; - b->flag= ob->flag; - b->lay= ob->lay; + b->object = ob; + b->flag = ob->flag; + b->lay = ob->lay; return b; } -void scene_deselect_all(Scene *sce) +void BKE_scene_base_deselect_all(Scene *sce) { Base *b; - for (b= sce->base.first; b; b= b->next) { - b->flag&= ~SELECT; - b->object->flag= b->flag; + for (b = sce->base.first; b; b = b->next) { + b->flag &= ~SELECT; + b->object->flag = b->flag; } } -void scene_select_base(Scene *sce, Base *selbase) +void BKE_scene_base_select(Scene *sce, Base *selbase) { selbase->flag |= SELECT; - selbase->object->flag= selbase->flag; + selbase->object->flag = selbase->flag; - sce->basact= selbase; + sce->basact = selbase; } /* checks for cycle, returns 1 if it's all OK */ -int scene_check_setscene(Main *bmain, Scene *sce) +int BKE_scene_validate_setscene(Main *bmain, Scene *sce) { Scene *scene; int a, totscene; - if (sce->set==NULL) return 1; + if (sce->set == NULL) return 1; - totscene= 0; - for (scene= bmain->scene.first; scene; scene= scene->id.next) + totscene = 0; + for (scene = bmain->scene.first; scene; scene = scene->id.next) totscene++; - for (a=0, scene=sce; scene->set; scene=scene->set, a++) { + for (a = 0, scene = sce; scene->set; scene = scene->set, a++) { /* more iterations than scenes means we have a cycle */ if (a > totscene) { /* the tested scene gets zero'ed, that's typically current scene */ - sce->set= NULL; + sce->set = NULL; return 0; } } @@ -928,13 +928,13 @@ int scene_check_setscene(Main *bmain, Scene *sce) /* This function is needed to cope with fractional frames - including two Blender rendering features * mblur (motion blur that renders 'subframes' and blurs them together), and fields rendering. */ -float BKE_curframe(Scene *scene) +float BKE_scene_frame_get(Scene *scene) { - return BKE_frame_to_ctime(scene, scene->r.cfra); + return BKE_scene_frame_get_from_ctime(scene, scene->r.cfra); } /* This function is used to obtain arbitrary fractional frames */ -float BKE_frame_to_ctime(Scene *scene, const float frame) +float BKE_scene_frame_get_from_ctime(Scene *scene, const float frame) { float ctime = frame; ctime += scene->r.subframe; @@ -944,14 +944,14 @@ float BKE_frame_to_ctime(Scene *scene, const float frame) } /* drivers support/hacks - * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render + * - this method is called from scene_update_tagged_recursive(), so gets included in viewport + render * - these are always run since the depsgraph can't handle non-object data * - these happen after objects are all done so that we can read in their final transform values, * though this means that objects can't refer to scene info for guidance... */ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) { - float ctime = BKE_curframe(scene); + float ctime = BKE_scene_frame_get(scene); /* scene itself */ if (scene->adt && scene->adt->drivers.first) { @@ -962,7 +962,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) // TODO: what about world textures? but then those have nodes too... if (scene->world) { ID *wid = (ID *)scene->world; - AnimData *adt= BKE_animdata_from_id(wid); + AnimData *adt = BKE_animdata_from_id(wid); if (adt && adt->drivers.first) BKE_animsys_evaluate_animdata(scene, wid, adt, ctime, ADT_RECALC_DRIVERS); @@ -971,7 +971,7 @@ static void scene_update_drivers(Main *UNUSED(bmain), Scene *scene) /* nodes */ if (scene->nodetree) { ID *nid = (ID *)scene->nodetree; - AnimData *adt= BKE_animdata_from_id(nid); + AnimData *adt = BKE_animdata_from_id(nid); if (adt && adt->drivers.first) BKE_animsys_evaluate_animdata(scene, nid, adt, ctime, ADT_RECALC_DRIVERS); @@ -983,7 +983,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen Base *base; - scene->customdata_mask= scene_parent->customdata_mask; + scene->customdata_mask = scene_parent->customdata_mask; /* sets first, we allow per definition current scene to have * dependencies on sets, but not the other way around. */ @@ -991,16 +991,16 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen scene_update_tagged_recursive(bmain, scene->set, scene_parent); /* scene objects */ - for (base= scene->base.first; base; base= base->next) { - Object *ob= base->object; + for (base = scene->base.first; base; base = base->next) { + Object *ob = base->object; - object_handle_update(scene_parent, ob); + BKE_object_handle_update(scene_parent, ob); if (ob->dup_group && (ob->transflag & OB_DUPLIGROUP)) group_handle_recalc_and_update(scene_parent, ob, ob->dup_group); /* always update layer, so that animating layers works */ - base->lay= ob->lay; + base->lay = ob->lay; } /* scene drivers... */ @@ -1011,7 +1011,7 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen } /* this is called in main loop, doing tagged updates before redraw */ -void scene_update_tagged(Main *bmain, Scene *scene) +void BKE_scene_update_tagged(Main *bmain, Scene *scene) { /* keep this first */ BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); @@ -1019,7 +1019,7 @@ void scene_update_tagged(Main *bmain, Scene *scene) /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); - scene->physics_settings.quick_cache_step= 0; + scene->physics_settings.quick_cache_step = 0; /* update all objects: drivers, matrices, displists, etc. flags set * by depgraph or manual, no layer check here, gets correct flushed @@ -1030,8 +1030,8 @@ void scene_update_tagged(Main *bmain, Scene *scene) /* extra call here to recalc scene animation (for sequencer) */ { - AnimData *adt= BKE_animdata_from_id(&scene->id); - float ctime = BKE_curframe(scene); + AnimData *adt = BKE_animdata_from_id(&scene->id); + float ctime = BKE_scene_frame_get(scene); if (adt && (adt->recalc & ADT_RECALC_ANIM)) BKE_animsys_evaluate_animdata(scene, &scene->id, adt, ctime, 0); @@ -1050,9 +1050,9 @@ void scene_update_tagged(Main *bmain, Scene *scene) } /* applies changes right away, does all sets too */ -void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) +void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) { - float ctime = BKE_curframe(sce); + float ctime = BKE_scene_frame_get(sce); Scene *sce_iter; /* keep this first */ @@ -1064,14 +1064,14 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* clear animation overrides */ // XXX TODO... - for (sce_iter= sce; sce_iter; sce_iter= sce_iter->set) { - if (sce_iter->theDag==NULL) + for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) { + if (sce_iter->theDag == NULL) DAG_scene_sort(bmain, sce_iter); } /* flush recalc flags to dependencies, if we were only changing a frame * this would not be necessary, but if a user or a script has modified - * some datablock before scene_update_tagged was called, we need the flush */ + * some datablock before BKE_scene_update_tagged was called, we need the flush */ DAG_ids_flush_tagged(bmain); /* Following 2 functions are recursive @@ -1087,7 +1087,7 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) BKE_animsys_evaluate_all_animation(bmain, sce, ctime); /*...done with recusrive funcs */ - /* object_handle_update() on all objects, groups and sets */ + /* BKE_object_handle_update() on all objects, groups and sets */ scene_update_tagged_recursive(bmain, sce, sce); /* notify editors and python about recalc */ @@ -1101,30 +1101,30 @@ void scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) } /* return default layer, also used to patch old files */ -SceneRenderLayer *scene_add_render_layer(Scene *sce, const char *name) +SceneRenderLayer *BKE_scene_add_render_layer(Scene *sce, const char *name) { SceneRenderLayer *srl; if (!name) - name= "RenderLayer"; + name = "RenderLayer"; - srl= MEM_callocN(sizeof(SceneRenderLayer), "new render layer"); + srl = MEM_callocN(sizeof(SceneRenderLayer), "new render layer"); BLI_strncpy(srl->name, name, sizeof(srl->name)); BLI_uniquename(&sce->r.layers, srl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(srl->name)); BLI_addtail(&sce->r.layers, srl); /* note, this is also in render, pipeline.c, to make layer when scenedata doesnt have it */ - srl->lay= (1<<20) -1; - srl->layflag= 0x7FFF; /* solid ztra halo edge strand */ - srl->passflag= SCE_PASS_COMBINED|SCE_PASS_Z; + srl->lay = (1 << 20) - 1; + srl->layflag = 0x7FFF; /* solid ztra halo edge strand */ + srl->passflag = SCE_PASS_COMBINED | SCE_PASS_Z; FRS_add_freestyle_config( srl ); return srl; } -int scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl) +int BKE_scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl) { - const int act= BLI_findindex(&scene->r.layers, srl); + const int act = BLI_findindex(&scene->r.layers, srl); Scene *sce; if (act == -1) { @@ -1140,16 +1140,16 @@ int scene_remove_render_layer(Main *bmain, Scene *scene, SceneRenderLayer *srl) BLI_remlink(&scene->r.layers, srl); MEM_freeN(srl); - scene->r.actlay= 0; + scene->r.actlay = 0; for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) { bNode *node; for (node = sce->nodetree->nodes.first; node; node = node->next) { - if (node->type==CMP_NODE_R_LAYERS && (Scene*)node->id==scene) { - if (node->custom1==act) - node->custom1= 0; - else if (node->custom1>act) + if (node->type == CMP_NODE_R_LAYERS && (Scene *)node->id == scene) { + if (node->custom1 == act) + node->custom1 = 0; + else if (node->custom1 > act) node->custom1--; } } @@ -1172,7 +1172,7 @@ int get_render_subsurf_level(RenderData *r, int lvl) int get_render_child_particle_number(RenderData *r, int num) { if (r->mode & R_SIMPLIFY) - return (int)(r->simplify_particles*num); + return (int)(r->simplify_particles * num); else return num; } @@ -1188,7 +1188,7 @@ int get_render_shadow_samples(RenderData *r, int samples) float get_render_aosss_error(RenderData *r, float error) { if (r->mode & R_SIMPLIFY) - return ((1.0f-r->simplify_aosss)*10.0f + 1.0f)*error; + return ((1.0f - r->simplify_aosss) * 10.0f + 1.0f) * error; else return error; } @@ -1200,14 +1200,14 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) /* common case, step to the next */ return base->next; } - else if (base==NULL && (*sce_iter)->base.first) { + else if (base == NULL && (*sce_iter)->base.first) { /* first time looping, return the scenes first base */ return (Base *)(*sce_iter)->base.first; } else { /* reached the end, get the next base in the set */ - while ((*sce_iter= (*sce_iter)->set)) { - base= (Base *)(*sce_iter)->base.first; + while ((*sce_iter = (*sce_iter)->set)) { + base = (Base *)(*sce_iter)->base.first; if (base) { return base; } @@ -1217,9 +1217,28 @@ Base *_setlooper_base_step(Scene **sce_iter, Base *base) return NULL; } -int scene_use_new_shading_nodes(Scene *scene) +int BKE_scene_use_new_shading_nodes(Scene *scene) { - RenderEngineType *type= RE_engines_find(scene->r.engine); + RenderEngineType *type = RE_engines_find(scene->r.engine); return (type && type->flag & RE_USE_SHADING_NODES); } +void BKE_scene_base_flag_to_objects(struct Scene *scene) +{ + Base *base = scene->base.first; + + while (base) { + base->object->flag = base->flag; + base = base->next; + } +} + +void BKE_scene_base_flag_from_objects(struct Scene *scene) +{ + Base *base = scene->base.first; + + while (base) { + base->flag = base->object->flag; + base = base->next; + } +} diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index f69495483ea..1f129b1c547 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -51,7 +51,7 @@ /* ************ Spacetype/regiontype handling ************** */ /* keep global; this has to be accessible outside of windowmanager */ -static ListBase spacetypes= {NULL, NULL}; +static ListBase spacetypes = {NULL, NULL}; /* not SpaceType itself */ static void spacetype_free(SpaceType *st) @@ -60,14 +60,14 @@ static void spacetype_free(SpaceType *st) PanelType *pt; HeaderType *ht; - for (art= st->regiontypes.first; art; art= art->next) { + for (art = st->regiontypes.first; art; art = art->next) { BLI_freelistN(&art->drawcalls); - for (pt= art->paneltypes.first; pt; pt= pt->next) + for (pt = art->paneltypes.first; pt; pt = pt->next) if (pt->ext.free) pt->ext.free(pt->ext.data); - for (ht= art->headertypes.first; ht; ht= ht->next) + for (ht = art->headertypes.first; ht; ht = ht->next) if (ht->ext.free) ht->ext.free(ht->ext.data); @@ -84,7 +84,7 @@ void BKE_spacetypes_free(void) { SpaceType *st; - for (st= spacetypes.first; st; st= st->next) { + for (st = spacetypes.first; st; st = st->next) { spacetype_free(st); } @@ -95,8 +95,8 @@ SpaceType *BKE_spacetype_from_id(int spaceid) { SpaceType *st; - for (st= spacetypes.first; st; st= st->next) { - if (st->spaceid==spaceid) + for (st = spacetypes.first; st; st = st->next) { + if (st->spaceid == spaceid) return st; } return NULL; @@ -106,8 +106,8 @@ ARegionType *BKE_regiontype_from_id(SpaceType *st, int regionid) { ARegionType *art; - for (art= st->regiontypes.first; art; art= art->next) - if (art->regionid==regionid) + for (art = st->regiontypes.first; art; art = art->next) + if (art->regionid == regionid) return art; printf("Error, region type missing in - name:\"%s\", id:%d\n", st->name, st->spaceid); @@ -125,7 +125,7 @@ void BKE_spacetype_register(SpaceType *st) SpaceType *stype; /* sanity check */ - stype= BKE_spacetype_from_id(st->spaceid); + stype = BKE_spacetype_from_id(st->spaceid); if (stype) { printf("error: redefinition of spacetype %s\n", stype->name); spacetype_free(stype); @@ -142,11 +142,11 @@ void BKE_spacedata_freelist(ListBase *lb) SpaceLink *sl; ARegion *ar; - for (sl= lb->first; sl; sl= sl->next) { - SpaceType *st= BKE_spacetype_from_id(sl->spacetype); + for (sl = lb->first; sl; sl = sl->next) { + SpaceType *st = BKE_spacetype_from_id(sl->spacetype); /* free regions for pushed spaces */ - for (ar=sl->regionbase.first; ar; ar=ar->next) + for (ar = sl->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sl->regionbase); @@ -160,41 +160,41 @@ void BKE_spacedata_freelist(ListBase *lb) ARegion *BKE_area_region_copy(SpaceType *st, ARegion *ar) { - ARegion *newar= MEM_dupallocN(ar); + ARegion *newar = MEM_dupallocN(ar); Panel *pa, *newpa, *patab; - newar->prev= newar->next= NULL; - newar->handlers.first= newar->handlers.last= NULL; - newar->uiblocks.first= newar->uiblocks.last= NULL; - newar->swinid= 0; + newar->prev = newar->next = NULL; + newar->handlers.first = newar->handlers.last = NULL; + newar->uiblocks.first = newar->uiblocks.last = NULL; + newar->swinid = 0; /* use optional regiondata callback */ if (ar->regiondata) { - ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype); + ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); if (art && art->duplicate) - newar->regiondata= art->duplicate(ar->regiondata); + newar->regiondata = art->duplicate(ar->regiondata); else - newar->regiondata= MEM_dupallocN(ar->regiondata); + newar->regiondata = MEM_dupallocN(ar->regiondata); } if (ar->v2d.tab_offset) - newar->v2d.tab_offset= MEM_dupallocN(ar->v2d.tab_offset); + newar->v2d.tab_offset = MEM_dupallocN(ar->v2d.tab_offset); - newar->panels.first= newar->panels.last= NULL; + newar->panels.first = newar->panels.last = NULL; BLI_duplicatelist(&newar->panels, &ar->panels); /* copy panel pointers */ - for (newpa= newar->panels.first; newpa; newpa= newpa->next) { - patab= newar->panels.first; - pa= ar->panels.first; + for (newpa = newar->panels.first; newpa; newpa = newpa->next) { + patab = newar->panels.first; + pa = ar->panels.first; while (patab) { if (newpa->paneltab == pa) { newpa->paneltab = patab; break; } - patab= patab->next; - pa= pa->next; + patab = patab->next; + pa = pa->next; } } @@ -208,10 +208,10 @@ static void region_copylist(SpaceType *st, ListBase *lb1, ListBase *lb2) ARegion *ar; /* to be sure */ - lb1->first= lb1->last= NULL; + lb1->first = lb1->last = NULL; - for (ar= lb2->first; ar; ar= ar->next) { - ARegion *arnew= BKE_area_region_copy(st, ar); + for (ar = lb2->first; ar; ar = ar->next) { + ARegion *arnew = BKE_area_region_copy(st, ar); BLI_addtail(lb1, arnew); } } @@ -222,13 +222,13 @@ void BKE_spacedata_copylist(ListBase *lb1, ListBase *lb2) { SpaceLink *sl; - lb1->first= lb1->last= NULL; /* to be sure */ + lb1->first = lb1->last = NULL; /* to be sure */ - for (sl= lb2->first; sl; sl= sl->next) { - SpaceType *st= BKE_spacetype_from_id(sl->spacetype); + for (sl = lb2->first; sl; sl = sl->next) { + SpaceType *st = BKE_spacetype_from_id(sl->spacetype); if (st && st->duplicate) { - SpaceLink *slnew= st->duplicate(sl); + SpaceLink *slnew = st->duplicate(sl); BLI_addtail(lb1, slnew); @@ -244,14 +244,14 @@ void BKE_spacedata_draw_locks(int set) { SpaceType *st; - for (st= spacetypes.first; st; st= st->next) { + for (st = spacetypes.first; st; st = st->next) { ARegionType *art; - for (art= st->regiontypes.first; art; art= art->next) { + for (art = st->regiontypes.first; art; art = art->next) { if (set) - art->do_lock= art->lock; + art->do_lock = art->lock; else - art->do_lock= 0; + art->do_lock = 0; } } } @@ -261,7 +261,7 @@ void BKE_spacedata_draw_locks(int set) void BKE_area_region_free(SpaceType *st, ARegion *ar) { if (st) { - ARegionType *art= BKE_regiontype_from_id(st, ar->regiontype); + ARegionType *art = BKE_regiontype_from_id(st, ar->regiontype); if (art && art->free) art->free(ar); @@ -274,7 +274,7 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) if (ar->v2d.tab_offset) { MEM_freeN(ar->v2d.tab_offset); - ar->v2d.tab_offset= NULL; + ar->v2d.tab_offset = NULL; } BLI_freelistN(&ar->panels); @@ -283,10 +283,10 @@ void BKE_area_region_free(SpaceType *st, ARegion *ar) /* not area itself */ void BKE_screen_area_free(ScrArea *sa) { - SpaceType *st= BKE_spacetype_from_id(sa->spacetype); + SpaceType *st = BKE_spacetype_from_id(sa->spacetype); ARegion *ar; - for (ar=sa->regionbase.first; ar; ar=ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sa->regionbase); @@ -297,18 +297,18 @@ void BKE_screen_area_free(ScrArea *sa) } /* don't free screen itself */ -void free_screen(bScreen *sc) +void BKE_screen_free(bScreen *sc) { ScrArea *sa, *san; ARegion *ar; - for (ar=sc->regionbase.first; ar; ar=ar->next) + for (ar = sc->regionbase.first; ar; ar = ar->next) BKE_area_region_free(NULL, ar); BLI_freelistN(&sc->regionbase); - for (sa= sc->areabase.first; sa; sa= san) { - san= sa->next; + for (sa = sc->areabase.first; sa; sa = san) { + san = sa->next; BKE_screen_area_free(sa); } @@ -321,12 +321,12 @@ void free_screen(bScreen *sc) unsigned int BKE_screen_visible_layers(bScreen *screen, Scene *scene) { ScrArea *sa; - unsigned int layer= 0; + unsigned int layer = 0; if (screen) { /* get all used view3d layers */ - for (sa= screen->areabase.first; sa; sa= sa->next) - if (sa->spacetype==SPACE_VIEW3D) + for (sa = screen->areabase.first; sa; sa = sa->next) + if (sa->spacetype == SPACE_VIEW3D) layer |= ((View3D *)sa->spacedata.first)->lay; } @@ -344,7 +344,7 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) if (sa) { ARegion *ar; - for (ar=sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == type) return ar; } @@ -357,16 +357,16 @@ ARegion *BKE_area_find_region_type(ScrArea *sa, int type) * -1 for any type */ struct ScrArea *BKE_screen_find_big_area(struct bScreen *sc, const int spacetype, const short min) { - ScrArea *sa, *big= NULL; - int size, maxsize= 0; + ScrArea *sa, *big = NULL; + int size, maxsize = 0; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { if ((spacetype == -1) || sa->spacetype == spacetype) { if (min <= sa->winx && min <= sa->winy) { - size= sa->winx*sa->winy; + size = sa->winx * sa->winy; if (size > maxsize) { - maxsize= size; - big= sa; + maxsize = size; + big = sa; } } } @@ -379,26 +379,26 @@ void BKE_screen_view3d_sync(struct View3D *v3d, struct Scene *scene) { int bit; - if (v3d->scenelock && v3d->localvd==NULL) { - v3d->lay= scene->lay; - v3d->camera= scene->camera; + if (v3d->scenelock && v3d->localvd == NULL) { + v3d->lay = scene->lay; + v3d->camera = scene->camera; - if (v3d->camera==NULL) { + if (v3d->camera == NULL) { ARegion *ar; - for (ar=v3d->regionbase.first; ar; ar= ar->next) { + for (ar = v3d->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; - if (rv3d->persp==RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; + RegionView3D *rv3d = ar->regiondata; + if (rv3d->persp == RV3D_CAMOB) + rv3d->persp = RV3D_PERSP; } } } if ((v3d->lay & v3d->layact) == 0) { - for (bit= 0; bit<32; bit++) { - if (v3d->lay & (1<layact= 1<lay & (1 << bit)) { + v3d->layact = 1 << bit; break; } } @@ -410,11 +410,11 @@ void BKE_screen_view3d_scene_sync(bScreen *sc) { /* are there cameras in the views that are not in the scene? */ ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; BKE_screen_view3d_sync(v3d, sc->scene); } } @@ -428,14 +428,14 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene) SpaceLink *sl; /* from scene copy to the other views */ - for (sc=screen_lb->first; sc; sc=sc->id.next) { - if (sc->scene!=scene) + for (sc = screen_lb->first; sc; sc = sc->id.next) { + if (sc->scene != scene) continue; - for (sa=sc->areabase.first; sa; sa=sa->next) - for (sl=sa->spacedata.first; sl; sl=sl->next) - if (sl->spacetype==SPACE_VIEW3D) - BKE_screen_view3d_sync((View3D*)sl, scene); + for (sa = sc->areabase.first; sa; sa = sa->next) + for (sl = sa->spacedata.first; sl; sl = sl->next) + if (sl->spacetype == SPACE_VIEW3D) + BKE_screen_view3d_sync((View3D *)sl, scene); } } @@ -449,7 +449,7 @@ void BKE_screen_view3d_main_sync(ListBase *screen_lb, Scene *scene) */ float BKE_screen_view3d_zoom_to_fac(float camzoom) { - return powf(((float)M_SQRT2 + camzoom/50.0f), 2.0f) / 4.0f; + return powf(((float)M_SQRT2 + camzoom / 50.0f), 2.0f) / 4.0f; } float BKE_screen_view3d_zoom_from_fac(float zoomfac) diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c index 5983beac4ef..9358b786472 100644 --- a/source/blender/blenkernel/intern/seqeffects.c +++ b/source/blender/blenkernel/intern/seqeffects.c @@ -58,27 +58,27 @@ #include "RNA_access.h" /* **** XXX **** */ -static void error(const char *UNUSED(error), ...) {} +static void error(const char *UNUSED(error), ...) { +} -#define INT 96 -#define FLO 128 +#define INT 96 +#define FLO 128 /* **** XXX **** */ /* Glow effect */ enum { - GlowR=0, - GlowG=1, - GlowB=2, - GlowA=3 + GlowR = 0, + GlowG = 1, + GlowB = 2, + GlowA = 3 }; -static struct ImBuf * prepare_effect_imbufs( - SeqRenderData context, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out; +static struct ImBuf *prepare_effect_imbufs( + SeqRenderData context, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out; int x = context.rectx; int y = context.recty; @@ -87,8 +87,9 @@ static struct ImBuf * prepare_effect_imbufs( out = IMB_allocImBuf((short)x, (short)y, 32, IB_rect); } else if ((ibuf1 && ibuf1->rect_float) || - (ibuf2 && ibuf2->rect_float) || - (ibuf3 && ibuf3->rect_float)) { + (ibuf2 && ibuf2->rect_float) || + (ibuf3 && ibuf3->rect_float)) + { /* if any inputs are rectfloat, output is float too */ out = IMB_allocImBuf((short)x, (short)y, 32, IB_rectfloat); @@ -127,15 +128,15 @@ static struct ImBuf * prepare_effect_imbufs( static void open_plugin_seq(PluginSeq *pis, const char *seqname) { int (*version)(void); - void* (*alloc_private)(void); + void * (*alloc_private)(void); char *cp; /* to be sure: (is tested for) */ - pis->doit= NULL; - pis->pname= NULL; - pis->varstr= NULL; - pis->cfra= NULL; - pis->version= 0; + pis->doit = NULL; + pis->pname = NULL; + pis->varstr = NULL; + pis->cfra = NULL; + pis->version = 0; pis->instance_private_data = NULL; /* clear the error list */ @@ -145,55 +146,54 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname) /* pis->handle= 0; */ /* open the needed object */ - pis->handle= BLI_dynlib_open(pis->name); + pis->handle = BLI_dynlib_open(pis->name); if (test_dlerr(pis->name, pis->name)) return; if (pis->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); + version = (int (*)(void))BLI_dynlib_find_symbol(pis->handle, "plugin_seq_getversion"); if (test_dlerr(pis->name, "plugin_seq_getversion")) return; if (version != NULL) { - pis->version= version(); + pis->version = version(); if (pis->version >= 2 && pis->version <= 6) { int (*info_func)(PluginInfo *); - PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); + PluginInfo *info = (PluginInfo *) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo"); + info_func = (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pis->handle, "plugin_getinfo"); if (info_func == NULL) error("No info func"); else { info_func(info); - pis->pname= info->name; - pis->vars= info->nvars; - pis->cfra= info->cfra; + pis->pname = info->name; + pis->vars = info->nvars; + pis->cfra = info->cfra; - pis->varstr= info->varstr; + pis->varstr = info->varstr; - pis->doit= (void(*)(void))info->seq_doit; + pis->doit = (void (*)(void))info->seq_doit; if (info->init) info->init(); } MEM_freeN(info); - cp= BLI_dynlib_find_symbol(pis->handle, "seqname"); + cp = BLI_dynlib_find_symbol(pis->handle, "seqname"); if (cp) BLI_strncpy(cp, seqname, SEQ_NAME_MAXSTR); } else { - printf ("Plugin returned unrecognized version number\n"); + printf("Plugin returned unrecognized version number\n"); return; } } - alloc_private = (void* (*)(void))BLI_dynlib_find_symbol( - pis->handle, "plugin_seq_alloc_private_data"); + alloc_private = (void * (*)(void))BLI_dynlib_find_symbol( + pis->handle, "plugin_seq_alloc_private_data"); if (alloc_private) { pis->instance_private_data = alloc_private(); } - pis->current_private_data = (void**) - BLI_dynlib_find_symbol( - pis->handle, "plugin_private_data"); + pis->current_private_data = (void **) + BLI_dynlib_find_symbol(pis->handle, "plugin_private_data"); } } @@ -203,25 +203,25 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname) VarStruct *varstr; int a; - pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq"); + pis = MEM_callocN(sizeof(PluginSeq), "PluginSeq"); BLI_strncpy(pis->name, str, FILE_MAX); open_plugin_seq(pis, seqname); - if (pis->doit==NULL) { - if (pis->handle==NULL) error("no plugin: %s", str); + if (pis->doit == NULL) { + if (pis->handle == NULL) error("no plugin: %s", str); else error("in plugin: %s", str); MEM_freeN(pis); return NULL; } /* default values */ - varstr= pis->varstr; - for (a=0; avars; a++, varstr++) { - if ( (varstr->type & FLO)==FLO) - pis->data[a]= varstr->def; - else if ( (varstr->type & INT)==INT) - *((int *)(pis->data+a))= (int) varstr->def; + varstr = pis->varstr; + for (a = 0; a < pis->vars; a++, varstr++) { + if ( (varstr->type & FLO) == FLO) + pis->data[a] = varstr->def; + else if ( (varstr->type & INT) == INT) + *((int *)(pis->data + a)) = (int) varstr->def; } return pis; @@ -229,7 +229,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname) static void free_plugin_seq(PluginSeq *pis) { - if (pis==NULL) return; + if (pis == NULL) return; /* no BLI_dynlib_close: same plugin can be opened multiple times with 1 handle */ @@ -237,7 +237,7 @@ static void free_plugin_seq(PluginSeq *pis) void (*free_private)(void *); free_private = (void (*)(void *))BLI_dynlib_find_symbol( - pis->handle, "plugin_seq_free_private_data"); + pis->handle, "plugin_seq_free_private_data"); if (free_private) { free_private(pis->instance_private_data); } @@ -246,9 +246,9 @@ static void free_plugin_seq(PluginSeq *pis) MEM_freeN(pis); } -static void init_plugin(Sequence * seq, const char * fname) +static void init_plugin(Sequence *seq, const char *fname) { - seq->plugin= (PluginSeq *)add_plugin_seq(fname, seq->name+2); + seq->plugin = (PluginSeq *)add_plugin_seq(fname, seq->name + 2); } /* @@ -259,34 +259,34 @@ static int num_inputs_plugin(void) return 1; } -static void load_plugin(Sequence * seq) +static void load_plugin(Sequence *seq) { if (seq) { - open_plugin_seq(seq->plugin, seq->name+2); + open_plugin_seq(seq->plugin, seq->name + 2); } } -static void copy_plugin(Sequence * dst, Sequence * src) +static void copy_plugin(Sequence *dst, Sequence *src) { if (src->plugin) { - dst->plugin= MEM_dupallocN(src->plugin); - open_plugin_seq(dst->plugin, dst->name+2); + dst->plugin = MEM_dupallocN(src->plugin); + open_plugin_seq(dst->plugin, dst->name + 2); } } -static ImBuf * IMB_cast_away_list(ImBuf * i) +static ImBuf *IMB_cast_away_list(ImBuf *i) { if (!i) { return NULL; } - return (ImBuf*) (((void**) i) + 2); + return (ImBuf *) (((void **) i) + 2); } -static struct ImBuf * do_plugin_effect( - SeqRenderData context, Sequence *seq, float cfra, - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_plugin_effect( + SeqRenderData context, Sequence *seq, float cfra, + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { char *cp; int float_rendering; @@ -294,31 +294,30 @@ static struct ImBuf * do_plugin_effect( * old plugins) do very bad stuff * with imbuf-internals */ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; if (seq->plugin && seq->plugin->doit) { if (seq->plugin->cfra) - *(seq->plugin->cfra)= cfra; + *(seq->plugin->cfra) = cfra; cp = BLI_dynlib_find_symbol( - seq->plugin->handle, "seqname"); + seq->plugin->handle, "seqname"); /* XXX: it's crappy to limit copying buffer by it's lemgth, * but assuming plugin stuff is using correct buffer size * it should be fine */ - if (cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2); + if (cp) strncpy(cp, seq->name + 2, sizeof(seq->name) - 2); if (seq->plugin->current_private_data) { - *seq->plugin->current_private_data - = seq->plugin->instance_private_data; + *seq->plugin->current_private_data = seq->plugin->instance_private_data; } float_rendering = (out->rect_float != NULL); - if (seq->plugin->version<=3 && float_rendering) { + if (seq->plugin->version <= 3 && float_rendering) { use_temp_bufs = 1; if (ibuf1) { @@ -344,27 +343,27 @@ static struct ImBuf * do_plugin_effect( out->flags &= ~IB_rectfloat; } - if (seq->plugin->version<=2) { + if (seq->plugin->version <= 2) { if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1); if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2); if (ibuf3) IMB_convert_rgba_to_abgr(ibuf3); } - if (seq->plugin->version<=4) { + if (seq->plugin->version <= 4) { ((SeqDoit)seq->plugin->doit)( - seq->plugin->data, facf0, facf1, x, y, - IMB_cast_away_list(ibuf1), - IMB_cast_away_list(ibuf2), - IMB_cast_away_list(out), - IMB_cast_away_list(ibuf3)); + seq->plugin->data, facf0, facf1, x, y, + IMB_cast_away_list(ibuf1), + IMB_cast_away_list(ibuf2), + IMB_cast_away_list(out), + IMB_cast_away_list(ibuf3)); } else { ((SeqDoit)seq->plugin->doit)( - seq->plugin->data, facf0, facf1, x, y, - ibuf1, ibuf2, out, ibuf3); + seq->plugin->data, facf0, facf1, x, y, + ibuf1, ibuf2, out, ibuf3); } - if (seq->plugin->version<=2) { + if (seq->plugin->version <= 2) { if (!use_temp_bufs) { if (ibuf1) IMB_convert_rgba_to_abgr(ibuf1); if (ibuf2) IMB_convert_rgba_to_abgr(ibuf2); @@ -372,7 +371,7 @@ static struct ImBuf * do_plugin_effect( } IMB_convert_rgba_to_abgr(out); } - if (seq->plugin->version<=3 && float_rendering) { + if (seq->plugin->version <= 3 && float_rendering) { IMB_float_from_rect_simple(out); } @@ -386,12 +385,12 @@ static struct ImBuf * do_plugin_effect( } static int do_plugin_early_out(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return 0; } -static void free_plugin(struct Sequence * seq) +static void free_plugin(struct Sequence *seq) { free_plugin_seq(seq->plugin); seq->plugin = NULL; @@ -401,129 +400,129 @@ static void free_plugin(struct Sequence * seq) * ALPHA OVER * ********************************************************************** */ -static void init_alpha_over_or_under(Sequence * seq) +static void init_alpha_over_or_under(Sequence *seq) { - Sequence * seq1 = seq->seq1; - Sequence * seq2 = seq->seq2; + Sequence *seq1 = seq->seq1; + Sequence *seq2 = seq->seq2; - seq->seq2= seq1; - seq->seq1= seq2; + seq->seq2 = seq1; + seq->seq1 = seq2; } static void do_alphaover_effect_byte(float facf0, float facf1, int x, int y, - char * rect1, char *rect2, char *out) + char *rect1, char *rect2, char *out) { int fac2, mfac, fac, fac4; int xo, tempc; char *rt1, *rt2, *rt; - xo= x; - rt1= (char *)rect1; - rt2= (char *)rect2; - rt= (char *)out; + xo = x; + rt1 = (char *)rect1; + rt2 = (char *)rect2; + rt = (char *)out; - fac2= (int)(256.0f*facf0); - fac4= (int)(256.0f*facf1); + fac2 = (int)(256.0f * facf0); + fac4 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 over rt2 (alpha from rt1) */ - fac= fac2; - mfac= 256 - ( (fac2*rt1[3])>>8 ); + fac = fac2; + mfac = 256 - ( (fac2 * rt1[3]) >> 8); - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); - else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + else if (mfac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); else { - tempc= ( fac*rt1[0] + mfac*rt2[0])>>8; - if (tempc>255) rt[0]= 255; else rt[0]= tempc; - tempc= ( fac*rt1[1] + mfac*rt2[1])>>8; - if (tempc>255) rt[1]= 255; else rt[1]= tempc; - tempc= ( fac*rt1[2] + mfac*rt2[2])>>8; - if (tempc>255) rt[2]= 255; else rt[2]= tempc; - tempc= ( fac*rt1[3] + mfac*rt2[3])>>8; - if (tempc>255) rt[3]= 255; else rt[3]= tempc; + tempc = (fac * rt1[0] + mfac * rt2[0]) >> 8; + if (tempc > 255) rt[0] = 255; else rt[0] = tempc; + tempc = (fac * rt1[1] + mfac * rt2[1]) >> 8; + if (tempc > 255) rt[1] = 255; else rt[1] = tempc; + tempc = (fac * rt1[2] + mfac * rt2[2]) >> 8; + if (tempc > 255) rt[2] = 255; else rt[2] = tempc; + tempc = (fac * rt1[3] + mfac * rt2[3]) >> 8; + if (tempc > 255) rt[3] = 255; else rt[3] = tempc; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - fac= fac4; - mfac= 256 - ( (fac4*rt1[3])>>8 ); + fac = fac4; + mfac = 256 - ( (fac4 * rt1[3]) >> 8); - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); - else if (mfac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + else if (mfac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt1); else { - tempc= ( fac*rt1[0] + mfac*rt2[0])>>8; - if (tempc>255) rt[0]= 255; else rt[0]= tempc; - tempc= ( fac*rt1[1] + mfac*rt2[1])>>8; - if (tempc>255) rt[1]= 255; else rt[1]= tempc; - tempc= ( fac*rt1[2] + mfac*rt2[2])>>8; - if (tempc>255) rt[2]= 255; else rt[2]= tempc; - tempc= ( fac*rt1[3] + mfac*rt2[3])>>8; - if (tempc>255) rt[3]= 255; else rt[3]= tempc; + tempc = (fac * rt1[0] + mfac * rt2[0]) >> 8; + if (tempc > 255) rt[0] = 255; else rt[0] = tempc; + tempc = (fac * rt1[1] + mfac * rt2[1]) >> 8; + if (tempc > 255) rt[1] = 255; else rt[1] = tempc; + tempc = (fac * rt1[2] + mfac * rt2[2]) >> 8; + if (tempc > 255) rt[2] = 255; else rt[2] = tempc; + tempc = (fac * rt1[3] + mfac * rt2[3]) >> 8; + if (tempc > 255) rt[3] = 255; else rt[3] = tempc; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, - float * rect1, float *rect2, float *out) + float *rect1, float *rect2, float *out) { float fac2, mfac, fac, fac4; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac4= facf1; + fac2 = facf0; + fac4 = facf1; while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 over rt2 (alpha from rt1) */ - fac= fac2; - mfac= 1.0f - (fac2 * rt1[3]); + fac = fac2; + mfac = 1.0f - (fac2 * rt1[3]); if (fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } - else if (mfac <=0) { + else if (mfac <= 0) { memcpy(rt, rt1, 4 * sizeof(float)); } else { - rt[0] = fac*rt1[0] + mfac*rt2[0]; - rt[1] = fac*rt1[1] + mfac*rt2[1]; - rt[2] = fac*rt1[2] + mfac*rt2[2]; - rt[3] = fac*rt1[3] + mfac*rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - fac= fac4; - mfac= 1.0f - (fac4*rt1[3]); + fac = fac4; + mfac = 1.0f - (fac4 * rt1[3]); if (fac <= 0.0f) { memcpy(rt, rt2, 4 * sizeof(float)); @@ -532,35 +531,35 @@ static void do_alphaover_effect_float(float facf0, float facf1, int x, int y, memcpy(rt, rt1, 4 * sizeof(float)); } else { - rt[0] = fac*rt1[0] + mfac*rt2[0]; - rt[1] = fac*rt1[1] + mfac*rt2[1]; - rt[2] = fac*rt1[2] + mfac*rt2[2]; - rt[3] = fac*rt1[3] + mfac*rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } -static struct ImBuf * do_alphaover_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_alphaover_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaover_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_alphaover_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -571,24 +570,24 @@ static struct ImBuf * do_alphaover_effect( * ********************************************************************** */ static void do_alphaunder_effect_byte( - float facf0, float facf1, int x, int y, char *rect1, - char *rect2, char *out) + float facf0, float facf1, int x, int y, char *rect1, + char *rect2, char *out) { int fac2, mfac, fac, fac4; int xo; char *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= (int)(256.0f*facf0); - fac4= (int)(256.0f*facf1); + fac2 = (int)(256.0f * facf0); + fac4 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 under rt2 (alpha from rt2) */ @@ -596,68 +595,68 @@ static void do_alphaunder_effect_byte( /* this complex optimalisation is because the * 'skybuf' can be crossed in */ - if (rt2[3]==0 && fac2==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); - else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (rt2[3] == 0 && fac2 == 256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + else if (rt2[3] == 255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - mfac= rt2[3]; - fac= (fac2*(256-mfac))>>8; + mfac = rt2[3]; + fac = (fac2 * (256 - mfac)) >> 8; - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8; - rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8; - rt[2]= ( fac*rt1[2] + mfac*rt2[2])>>8; - rt[3]= ( fac*rt1[3] + mfac*rt2[3])>>8; + rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8; + rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8; + rt[2] = (fac * rt1[2] + mfac * rt2[2]) >> 8; + rt[3] = (fac * rt1[3] + mfac * rt2[3]) >> 8; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - if (rt2[3]==0 && fac4==256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); - else if (rt2[3]==255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (rt2[3] == 0 && fac4 == 256) *( (unsigned int *)rt) = *( (unsigned int *)rt1); + else if (rt2[3] == 255) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - mfac= rt2[3]; - fac= (fac4*(256-mfac))>>8; + mfac = rt2[3]; + fac = (fac4 * (256 - mfac)) >> 8; - if (fac==0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); + if (fac == 0) *( (unsigned int *)rt) = *( (unsigned int *)rt2); else { - rt[0]= ( fac*rt1[0] + mfac*rt2[0])>>8; - rt[1]= ( fac*rt1[1] + mfac*rt2[1])>>8; - rt[2]= ( fac*rt1[2] + mfac*rt2[2])>>8; - rt[3]= ( fac*rt1[3] + mfac*rt2[3])>>8; + rt[0] = (fac * rt1[0] + mfac * rt2[0]) >> 8; + rt[1] = (fac * rt1[1] + mfac * rt2[1]) >> 8; + rt[2] = (fac * rt1[2] + mfac * rt2[2]) >> 8; + rt[3] = (fac * rt1[3] + mfac * rt2[3]) >> 8; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { float fac2, mfac, fac, fac4; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac4= facf1; + fac2 = facf0; + fac4 = facf1; while (y--) { - x= xo; + x = xo; while (x--) { /* rt = rt1 under rt2 (alpha from rt2) */ @@ -665,7 +664,7 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, /* this complex optimalisation is because the * 'skybuf' can be crossed in */ - if ( rt2[3]<=0 && fac2 >= 1.0f) { + if (rt2[3] <= 0 && fac2 >= 1.0f) { memcpy(rt, rt1, 4 * sizeof(float)); } else if (rt2[3] >= 1.0f) { @@ -679,67 +678,67 @@ static void do_alphaunder_effect_float(float facf0, float facf1, int x, int y, memcpy(rt, rt2, 4 * sizeof(float)); } else { - rt[0]= fac*rt1[0] + mfac*rt2[0]; - rt[1]= fac*rt1[1] + mfac*rt2[1]; - rt[2]= fac*rt1[2] + mfac*rt2[2]; - rt[3]= fac*rt1[3] + mfac*rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - if (rt2[3]<=0 && fac4 >= 1.0f) { + if (rt2[3] <= 0 && fac4 >= 1.0f) { memcpy(rt, rt1, 4 * sizeof(float)); } - else if (rt2[3]>=1.0f) { + else if (rt2[3] >= 1.0f) { memcpy(rt, rt2, 4 * sizeof(float)); } else { - mfac= rt2[3]; - fac= fac4*(1.0f-mfac); + mfac = rt2[3]; + fac = fac4 * (1.0f - mfac); if (fac == 0) { memcpy(rt, rt2, 4 * sizeof(float)); } else { - rt[0]= fac * rt1[0] + mfac * rt2[0]; - rt[1]= fac * rt1[1] + mfac * rt2[1]; - rt[2]= fac * rt1[2] + mfac * rt2[2]; - rt[3]= fac * rt1[3] + mfac * rt2[3]; + rt[0] = fac * rt1[0] + mfac * rt2[0]; + rt[1] = fac * rt1[1] + mfac * rt2[1]; + rt[2] = fac * rt1[2] + mfac * rt2[2]; + rt[3] = fac * rt1[3] + mfac * rt2[3]; } } - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } -static struct ImBuf* do_alphaunder_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_alphaunder_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs( - context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_alphaunder_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_alphaunder_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -750,95 +749,95 @@ static struct ImBuf* do_alphaunder_effect( * ********************************************************************** */ static void do_cross_effect_byte(float facf0, float facf1, int x, int y, - char *rect1, char *rect2, - char *out) + char *rect1, char *rect2, + char *out) { int fac1, fac2, fac3, fac4; int xo; char *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= (int)(256.0f*facf0); - fac1= 256-fac2; - fac4= (int)(256.0f*facf1); - fac3= 256-fac4; + fac2 = (int)(256.0f * facf0); + fac1 = 256 - fac2; + fac4 = (int)(256.0f * facf1); + fac3 = 256 - fac4; while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= (fac1*rt1[0] + fac2*rt2[0])>>8; - rt[1]= (fac1*rt1[1] + fac2*rt2[1])>>8; - rt[2]= (fac1*rt1[2] + fac2*rt2[2])>>8; - rt[3]= (fac1*rt1[3] + fac2*rt2[3])>>8; + rt[0] = (fac1 * rt1[0] + fac2 * rt2[0]) >> 8; + rt[1] = (fac1 * rt1[1] + fac2 * rt2[1]) >> 8; + rt[2] = (fac1 * rt1[2] + fac2 * rt2[2]) >> 8; + rt[3] = (fac1 * rt1[3] + fac2 * rt2[3]) >> 8; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= (fac3*rt1[0] + fac4*rt2[0])>>8; - rt[1]= (fac3*rt1[1] + fac4*rt2[1])>>8; - rt[2]= (fac3*rt1[2] + fac4*rt2[2])>>8; - rt[3]= (fac3*rt1[3] + fac4*rt2[3])>>8; + rt[0] = (fac3 * rt1[0] + fac4 * rt2[0]) >> 8; + rt[1] = (fac3 * rt1[1] + fac4 * rt2[1]) >> 8; + rt[2] = (fac3 * rt1[2] + fac4 * rt2[2]) >> 8; + rt[3] = (fac3 * rt1[3] + fac4 * rt2[3]) >> 8; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_cross_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, float *out) + float *rect1, float *rect2, float *out) { float fac1, fac2, fac3, fac4; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac1= 1.0f - fac2; - fac4= facf1; - fac3= 1.0f - fac4; + fac2 = facf0; + fac1 = 1.0f - fac2; + fac4 = facf1; + fac3 = 1.0f - fac4; while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= fac1*rt1[0] + fac2*rt2[0]; - rt[1]= fac1*rt1[1] + fac2*rt2[1]; - rt[2]= fac1*rt1[2] + fac2*rt2[2]; - rt[3]= fac1*rt1[3] + fac2*rt2[3]; + rt[0] = fac1 * rt1[0] + fac2 * rt2[0]; + rt[1] = fac1 * rt1[1] + fac2 * rt2[1]; + rt[2] = fac1 * rt1[2] + fac2 * rt2[2]; + rt[3] = fac1 * rt1[3] + fac2 * rt2[3]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= fac3*rt1[0] + fac4*rt2[0]; - rt[1]= fac3*rt1[1] + fac4*rt2[1]; - rt[2]= fac3*rt1[2] + fac4*rt2[2]; - rt[3]= fac3*rt1[3] + fac4*rt2[3]; + rt[0] = fac3 * rt1[0] + fac4 * rt2[0]; + rt[1] = fac3 * rt1[1] + fac4 * rt2[1]; + rt[2] = fac3 * rt1[2] + fac4 * rt2[2]; + rt[3] = fac3 * rt1[3] + fac4 * rt2[3]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } @@ -846,26 +845,26 @@ static void do_cross_effect_float(float facf0, float facf1, int x, int y, /* careful: also used by speed effect! */ -static struct ImBuf* do_cross_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_cross_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs( - context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs( + context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_cross_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_cross_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -906,9 +905,9 @@ static void makeGammaTables(float gamma) for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { color_domain_table[i] = i * color_step; gamma_range_table[i] = pow(color_domain_table[i], - valid_gamma); + valid_gamma); inv_gamma_range_table[i] = pow(color_domain_table[i], - valid_inv_gamma); + valid_inv_gamma); } /* The end of the table should match 1.0 carefully. In order to avoid */ @@ -921,11 +920,11 @@ static void makeGammaTables(float gamma) /* To speed up calculations, we make these calc factor tables. They are */ /* multiplication factors used in scaling the interpolation. */ - for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++ ) { - gamfactor_table[i] = inv_color_step - * (gamma_range_table[i + 1] - gamma_range_table[i]); - inv_gamfactor_table[i] = inv_color_step - * (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); + for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++) { + gamfactor_table[i] = inv_color_step * + (gamma_range_table[i + 1] - gamma_range_table[i]); + inv_gamfactor_table[i] = inv_color_step * + (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); } } /* end of void makeGammaTables(float gamma) */ @@ -942,9 +941,9 @@ static float gammaCorrect(float c) /* may help solve that, by exchanging LUT size for the interpolation. */ /* Negative colors are explicitly handled. */ if (i < 0) res = -pow(abs(c), valid_gamma); - else if (i >= RE_GAMMA_TABLE_SIZE ) res = pow(c, valid_gamma); + else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(c, valid_gamma); else res = gamma_range_table[i] + - ( (c - color_domain_table[i]) * gamfactor_table[i]); + ( (c - color_domain_table[i]) * gamfactor_table[i]); return res; } /* end of float gammaCorrect(float col) */ @@ -956,12 +955,12 @@ static float invGammaCorrect(float col) int i; float res = 0.0; - i = floor(col*inv_color_step); + i = floor(col * inv_color_step); /* Negative colors are explicitly handled. */ if (i < 0) res = -pow(abs(col), valid_inv_gamma); else if (i >= RE_GAMMA_TABLE_SIZE) res = pow(col, valid_inv_gamma); else res = inv_gamma_range_table[i] + - ( (col - color_domain_table[i]) * inv_gamfactor_table[i]); + ( (col - color_domain_table[i]) * inv_gamfactor_table[i]); return res; } /* end of float invGammaCorrect(float col) */ @@ -969,26 +968,26 @@ static float invGammaCorrect(float col) static void gamtabs(float gamma) { - float val, igamma= 1.0f/gamma; + float val, igamma = 1.0f / gamma; int a; /* gamtab: in short, out short */ - for (a=0; a<65536; a++) { - val= a; - val/= 65535.0f; + for (a = 0; a < 65536; a++) { + val = a; + val /= 65535.0f; - if (gamma==2.0f) val= sqrt(val); - else if (gamma!=1.0f) val= pow(val, igamma); + if (gamma == 2.0f) val = sqrt(val); + else if (gamma != 1.0f) val = pow(val, igamma); - gamtab[a]= (65535.99f*val); + gamtab[a] = (65535.99f * val); } /* inverse gamtab1 : in byte, out short */ - for (a=1; a<=256; a++) { - if (gamma==2.0f) igamtab1[a-1]= a*a-1; - else if (gamma==1.0f) igamtab1[a-1]= 256*a-1; + for (a = 1; a <= 256; a++) { + if (gamma == 2.0f) igamtab1[a - 1] = a * a - 1; + else if (gamma == 1.0f) igamtab1[a - 1] = 256 * a - 1; else { - val= a/256.0f; - igamtab1[a - 1]= (65535.0 * pow(val, gamma)) - 1; + val = a / 256.0f; + igamtab1[a - 1] = (65535.0 * pow(val, gamma)) - 1; } } @@ -1003,139 +1002,137 @@ static void build_gammatabs(void) } } -static void init_gammacross(Sequence * UNUSED(seq)) +static void init_gammacross(Sequence *UNUSED(seq)) { } -static void load_gammacross(Sequence * UNUSED(seq)) +static void load_gammacross(Sequence *UNUSED(seq)) { } -static void free_gammacross(Sequence * UNUSED(seq)) +static void free_gammacross(Sequence *UNUSED(seq)) { } static void do_gammacross_effect_byte(float facf0, float UNUSED(facf1), - int x, int y, - unsigned char *rect1, - unsigned char *rect2, - unsigned char *out) + int x, int y, + unsigned char *rect1, + unsigned char *rect2, + unsigned char *out) { int fac1, fac2, col; int xo; unsigned char *rt1, *rt2, *rt; - xo= x; - rt1= (unsigned char *)rect1; - rt2= (unsigned char *)rect2; - rt= (unsigned char *)out; + xo = x; + rt1 = (unsigned char *)rect1; + rt2 = (unsigned char *)rect2; + rt = (unsigned char *)out; - fac2= (int)(256.0f*facf0); - fac1= 256-fac2; + fac2 = (int)(256.0f * facf0); + fac1 = 256 - fac2; while (y--) { - x= xo; + x = xo; while (x--) { - col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8; - if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col=(fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8; - if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8; - if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8; - if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[0]] + fac2 * igamtab1[rt2[0]]) >> 8; + if (col > 65535) rt[0] = 255; else rt[0] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[1]] + fac2 * igamtab1[rt2[1]]) >> 8; + if (col > 65535) rt[1] = 255; else rt[1] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[2]] + fac2 * igamtab1[rt2[2]]) >> 8; + if (col > 65535) rt[2] = 255; else rt[2] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[3]] + fac2 * igamtab1[rt2[3]]) >> 8; + if (col > 65535) rt[3] = 255; else rt[3] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - col= (fac1*igamtab1[rt1[0]] + fac2*igamtab1[rt2[0]])>>8; - if (col>65535) rt[0]= 255; else rt[0]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[1]] + fac2*igamtab1[rt2[1]])>>8; - if (col>65535) rt[1]= 255; else rt[1]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[2]] + fac2*igamtab1[rt2[2]])>>8; - if (col>65535) rt[2]= 255; else rt[2]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; - col= (fac1*igamtab1[rt1[3]] + fac2*igamtab1[rt2[3]])>>8; - if (col>65535) rt[3]= 255; else rt[3]= ( (char *)(gamtab+col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[0]] + fac2 * igamtab1[rt2[0]]) >> 8; + if (col > 65535) rt[0] = 255; else rt[0] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[1]] + fac2 * igamtab1[rt2[1]]) >> 8; + if (col > 65535) rt[1] = 255; else rt[1] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[2]] + fac2 * igamtab1[rt2[2]]) >> 8; + if (col > 65535) rt[2] = 255; else rt[2] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; + col = (fac1 * igamtab1[rt1[3]] + fac2 * igamtab1[rt2[3]]) >> 8; + if (col > 65535) rt[3] = 255; else rt[3] = ( (char *)(gamtab + col))[MOST_SIG_BYTE]; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_gammacross_effect_float(float facf0, float UNUSED(facf1), - int x, int y, - float *rect1, float *rect2, - float *out) + int x, int y, + float *rect1, float *rect2, + float *out) { float fac1, fac2; int xo; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac2= facf0; - fac1= 1.0f - fac2; + fac2 = facf0; + fac1 = 1.0f - fac2; while (y--) { - x= xo * 4; + x = xo * 4; while (x--) { - *rt= gammaCorrect( - fac1 * invGammaCorrect(*rt1) - + fac2 * invGammaCorrect(*rt2)); + *rt = gammaCorrect( + fac1 * invGammaCorrect(*rt1) + fac2 * invGammaCorrect(*rt2)); rt1++; rt2++; rt++; } - if (y==0) break; + if (y == 0) break; y--; - x= xo * 4; + x = xo * 4; while (x--) { - *rt= gammaCorrect( - fac1*invGammaCorrect(*rt1) - + fac2*invGammaCorrect(*rt2)); + *rt = gammaCorrect( + fac1 * invGammaCorrect(*rt1) + fac2 * invGammaCorrect(*rt2)); rt1++; rt2++; rt++; } } } -static struct ImBuf * do_gammacross_effect( - SeqRenderData context, - Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_gammacross_effect( + SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); build_gammatabs(); if (out->rect_float) { do_gammacross_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_gammacross_effect_byte( - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; } @@ -1146,86 +1143,86 @@ static struct ImBuf * do_gammacross_effect( * ********************************************************************** */ static void do_add_effect_byte(float facf0, float facf1, int x, int y, - unsigned char *rect1, unsigned char *rect2, - unsigned char *out) + unsigned char *rect1, unsigned char *rect2, + unsigned char *out) { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; - xo= x; - rt1= (char *)rect1; - rt2= (char *)rect2; - rt= (char *)out; + xo = x; + rt1 = (char *)rect1; + rt2 = (char *)rect2; + rt = (char *)out; - fac1= (int)(256.0f*facf0); - fac3= (int)(256.0f*facf1); + fac1 = (int)(256.0f * facf0); + fac3 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { - col= rt1[0]+ ((fac1*rt2[0])>>8); - if (col>255) rt[0]= 255; else rt[0]= col; - col= rt1[1]+ ((fac1*rt2[1])>>8); - if (col>255) rt[1]= 255; else rt[1]= col; - col= rt1[2]+ ((fac1*rt2[2])>>8); - if (col>255) rt[2]= 255; else rt[2]= col; - col= rt1[3]+ ((fac1*rt2[3])>>8); - if (col>255) rt[3]= 255; else rt[3]= col; + col = rt1[0] + ((fac1 * rt2[0]) >> 8); + if (col > 255) rt[0] = 255; else rt[0] = col; + col = rt1[1] + ((fac1 * rt2[1]) >> 8); + if (col > 255) rt[1] = 255; else rt[1] = col; + col = rt1[2] + ((fac1 * rt2[2]) >> 8); + if (col > 255) rt[2] = 255; else rt[2] = col; + col = rt1[3] + ((fac1 * rt2[3]) >> 8); + if (col > 255) rt[3] = 255; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - col= rt1[0]+ ((fac3*rt2[0])>>8); - if (col>255) rt[0]= 255; else rt[0]= col; - col= rt1[1]+ ((fac3*rt2[1])>>8); - if (col>255) rt[1]= 255; else rt[1]= col; - col= rt1[2]+ ((fac3*rt2[2])>>8); - if (col>255) rt[2]= 255; else rt[2]= col; - col= rt1[3]+ ((fac3*rt2[3])>>8); - if (col>255) rt[3]= 255; else rt[3]= col; + col = rt1[0] + ((fac3 * rt2[0]) >> 8); + if (col > 255) rt[0] = 255; else rt[0] = col; + col = rt1[1] + ((fac3 * rt2[1]) >> 8); + if (col > 255) rt[1] = 255; else rt[1] = col; + col = rt1[2] + ((fac3 * rt2[2]) >> 8); + if (col > 255) rt[2] = 255; else rt[2] = col; + col = rt1[3] + ((fac3 * rt2[3]) >> 8); + if (col > 255) rt[3] = 255; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_add_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac1= facf0; - fac3= facf1; + fac1 = facf0; + fac3 = facf1; while (y--) { - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 + fac1 * (*rt2); rt1++; rt2++; rt++; } - if (y==0) break; + if (y == 0) break; y--; - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 + fac3 * (*rt2); @@ -1234,25 +1231,24 @@ static void do_add_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_add_effect(SeqRenderData context, - Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_add_effect(SeqRenderData context, + Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_add_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_add_effect_byte( - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; } @@ -1263,86 +1259,86 @@ static struct ImBuf * do_add_effect(SeqRenderData context, * ********************************************************************** */ static void do_sub_effect_byte(float facf0, float facf1, - int x, int y, - char *rect1, char *rect2, char *out) + int x, int y, + char *rect1, char *rect2, char *out) { int col, xo, fac1, fac3; char *rt1, *rt2, *rt; - xo= x; - rt1= (char *)rect1; - rt2= (char *)rect2; - rt= (char *)out; + xo = x; + rt1 = (char *)rect1; + rt2 = (char *)rect2; + rt = (char *)out; - fac1= (int)(256.0f*facf0); - fac3= (int)(256.0f*facf1); + fac1 = (int)(256.0f * facf0); + fac3 = (int)(256.0f * facf1); while (y--) { - x= xo; + x = xo; while (x--) { - col= rt1[0]- ((fac1*rt2[0])>>8); - if (col<0) rt[0]= 0; else rt[0]= col; - col= rt1[1]- ((fac1*rt2[1])>>8); - if (col<0) rt[1]= 0; else rt[1]= col; - col= rt1[2]- ((fac1*rt2[2])>>8); - if (col<0) rt[2]= 0; else rt[2]= col; - col= rt1[3]- ((fac1*rt2[3])>>8); - if (col<0) rt[3]= 0; else rt[3]= col; + col = rt1[0] - ((fac1 * rt2[0]) >> 8); + if (col < 0) rt[0] = 0; else rt[0] = col; + col = rt1[1] - ((fac1 * rt2[1]) >> 8); + if (col < 0) rt[1] = 0; else rt[1] = col; + col = rt1[2] - ((fac1 * rt2[2]) >> 8); + if (col < 0) rt[2] = 0; else rt[2] = col; + col = rt1[3] - ((fac1 * rt2[3]) >> 8); + if (col < 0) rt[3] = 0; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - col= rt1[0]- ((fac3*rt2[0])>>8); - if (col<0) rt[0]= 0; else rt[0]= col; - col= rt1[1]- ((fac3*rt2[1])>>8); - if (col<0) rt[1]= 0; else rt[1]= col; - col= rt1[2]- ((fac3*rt2[2])>>8); - if (col<0) rt[2]= 0; else rt[2]= col; - col= rt1[3]- ((fac3*rt2[3])>>8); - if (col<0) rt[3]= 0; else rt[3]= col; + col = rt1[0] - ((fac3 * rt2[0]) >> 8); + if (col < 0) rt[0] = 0; else rt[0] = col; + col = rt1[1] - ((fac3 * rt2[1]) >> 8); + if (col < 0) rt[1] = 0; else rt[1] = col; + col = rt1[2] - ((fac3 * rt2[2]) >> 8); + if (col < 0) rt[2] = 0; else rt[2] = col; + col = rt1[3] - ((fac3 * rt2[3]) >> 8); + if (col < 0) rt[3] = 0; else rt[3] = col; - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_sub_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac1= facf0; - fac3= facf1; + fac1 = facf0; + fac3 = facf1; while (y--) { - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 - fac1 * (*rt2); rt1++; rt2++; rt++; } - if (y==0) break; + if (y == 0) break; y--; - x= xo * 4; + x = xo * 4; while (x--) { *rt = *rt1 - fac3 * (*rt2); @@ -1351,25 +1347,24 @@ static void do_sub_effect_float(float facf0, float facf1, int x, int y, } } -static struct ImBuf * do_sub_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_sub_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_sub_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_sub_effect_byte( - facf0, facf1, context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } @@ -1379,88 +1374,88 @@ static struct ImBuf * do_sub_effect( * ********************************************************************** */ /* Must be > 0 or add precopy, etc to the function */ -#define XOFF 8 -#define YOFF 8 +#define XOFF 8 +#define YOFF 8 static void do_drop_effect_byte(float facf0, float facf1, int x, int y, - char *rect2i, char *rect1i, - char *outi) + char *rect2i, char *rect1i, + char *outi) { int height, width, temp, fac, fac1, fac2; char *rt1, *rt2, *out; - int field= 1; + int field = 1; - width= x; - height= y; + width = x; + height = y; - fac1= (int)(70.0f*facf0); - fac2= (int)(70.0f*facf1); + fac1 = (int)(70.0f * facf0); + fac2 = (int)(70.0f * facf1); - rt2= (char*) (rect2i + YOFF*width); - rt1= (char*) rect1i; - out= (char*) outi; - for (y=0; y>8); + for (x = XOFF; x < width; x++) { + temp = ((fac * rt2[3]) >> 8); - *(out++)= MAX2(0, *rt1 - temp); rt1++; - *(out++)= MAX2(0, *rt1 - temp); rt1++; - *(out++)= MAX2(0, *rt1 - temp); rt1++; - *(out++)= MAX2(0, *rt1 - temp); rt1++; - rt2+=4; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + *(out++) = MAX2(0, *rt1 - temp); rt1++; + rt2 += 4; } - rt2+=XOFF*4; + rt2 += XOFF * 4; } - memcpy(out, rt1, sizeof(int)*YOFF*width); + memcpy(out, rt1, sizeof(int) * YOFF * width); } static void do_drop_effect_float(float facf0, float facf1, int x, int y, - float *rect2i, float *rect1i, - float *outi) + float *rect2i, float *rect1i, + float *outi) { int height, width; float temp, fac, fac1, fac2; float *rt1, *rt2, *out; - int field= 1; + int field = 1; - width= x; - height= y; + width = x; + height = y; - fac1= 70.0f*facf0; - fac2= 70.0f*facf1; + fac1 = 70.0f * facf0; + fac2 = 70.0f * facf1; - rt2= (rect2i + YOFF*width); - rt1= rect1i; - out= outi; - for (y=0; y fac*a*(b-1)+axaux= c*px + py*s ;//+centx @@ -1489,48 +1484,48 @@ static void do_mul_effect_byte(float facf0, float facf1, int x, int y, while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + ((fac1*rt1[0]*(rt2[0]-256))>>16); - rt[1]= rt1[1] + ((fac1*rt1[1]*(rt2[1]-256))>>16); - rt[2]= rt1[2] + ((fac1*rt1[2]*(rt2[2]-256))>>16); - rt[3]= rt1[3] + ((fac1*rt1[3]*(rt2[3]-256))>>16); + rt[0] = rt1[0] + ((fac1 * rt1[0] * (rt2[0] - 256)) >> 16); + rt[1] = rt1[1] + ((fac1 * rt1[1] * (rt2[1] - 256)) >> 16); + rt[2] = rt1[2] + ((fac1 * rt1[2] * (rt2[2] - 256)) >> 16); + rt[3] = rt1[3] + ((fac1 * rt1[3] * (rt2[3] - 256)) >> 16); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + ((fac3*rt1[0]*(rt2[0]-256))>>16); - rt[1]= rt1[1] + ((fac3*rt1[1]*(rt2[1]-256))>>16); - rt[2]= rt1[2] + ((fac3*rt1[2]*(rt2[2]-256))>>16); - rt[3]= rt1[3] + ((fac3*rt1[3]*(rt2[3]-256))>>16); + rt[0] = rt1[0] + ((fac3 * rt1[0] * (rt2[0] - 256)) >> 16); + rt[1] = rt1[1] + ((fac3 * rt1[1] * (rt2[1] - 256)) >> 16); + rt[2] = rt1[2] + ((fac3 * rt1[2] * (rt2[2] - 256)) >> 16); + rt[3] = rt1[3] + ((fac3 * rt1[3] * (rt2[3] - 256)) >> 16); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } static void do_mul_effect_float(float facf0, float facf1, int x, int y, - float *rect1, float *rect2, - float *out) + float *rect1, float *rect2, + float *out) { int xo; float fac1, fac3; float *rt1, *rt2, *rt; - xo= x; - rt1= rect1; - rt2= rect2; - rt= out; + xo = x; + rt1 = rect1; + rt2 = rect2; + rt = out; - fac1= facf0; - fac3= facf1; + fac1 = facf0; + fac3 = facf1; /* formula: * fac*(a*b) + (1-fac)*a => fac*a*(b-1)+a @@ -1538,52 +1533,52 @@ static void do_mul_effect_float(float facf0, float facf1, int x, int y, while (y--) { - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + fac1*rt1[0]*(rt2[0]-1.0f); - rt[1]= rt1[1] + fac1*rt1[1]*(rt2[1]-1.0f); - rt[2]= rt1[2] + fac1*rt1[2]*(rt2[2]-1.0f); - rt[3]= rt1[3] + fac1*rt1[3]*(rt2[3]-1.0f); + rt[0] = rt1[0] + fac1 * rt1[0] * (rt2[0] - 1.0f); + rt[1] = rt1[1] + fac1 * rt1[1] * (rt2[1] - 1.0f); + rt[2] = rt1[2] + fac1 * rt1[2] * (rt2[2] - 1.0f); + rt[3] = rt1[3] + fac1 * rt1[3] * (rt2[3] - 1.0f); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } - if (y==0) break; + if (y == 0) break; y--; - x= xo; + x = xo; while (x--) { - rt[0]= rt1[0] + fac3*rt1[0]*(rt2[0]-1.0f); - rt[1]= rt1[1] + fac3*rt1[1]*(rt2[1]-1.0f); - rt[2]= rt1[2] + fac3*rt1[2]*(rt2[2]-1.0f); - rt[3]= rt1[3] + fac3*rt1[3]*(rt2[3]-1.0f); + rt[0] = rt1[0] + fac3 * rt1[0] * (rt2[0] - 1.0f); + rt[1] = rt1[1] + fac3 * rt1[1] * (rt2[1] - 1.0f); + rt[2] = rt1[2] + fac3 * rt1[2] * (rt2[2] - 1.0f); + rt[3] = rt1[3] + fac3 * rt1[3] * (rt2[3] - 1.0f); - rt1+= 4; rt2+= 4; rt+= 4; + rt1 += 4; rt2 += 4; rt += 4; } } } -static struct ImBuf * do_mul_effect( - SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_mul_effect( + SeqRenderData context, Sequence *UNUSED(seq), float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); if (out->rect_float) { do_mul_effect_float( - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_mul_effect_byte( - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; @@ -1607,8 +1602,8 @@ static void precalc_wipe_zone(WipeZone *wipezone, WipeVars *wipe, int xo, int yo wipezone->angle = tanf(DEG2RADF(fabsf(wipe->angle))); wipezone->xo = xo; wipezone->yo = yo; - wipezone->width = (int)(wipe->edgeWidth*((xo+yo)/2.0f)); - wipezone->pythangle = 1.0f/sqrtf(wipezone->angle*wipezone->angle + 1.0f); + wipezone->width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0f)); + wipezone->pythangle = 1.0f / sqrtf(wipezone->angle * wipezone->angle + 1.0f); } // This function calculates the blur band for the wipe effects @@ -1623,18 +1618,18 @@ static float in_band(float width, float dist, int side, int dir) return (float)side; if (side == 1) - alpha = (dist+0.5f*width) / (width); + alpha = (dist + 0.5f * width) / (width); else - alpha = (0.5f*width-dist) / (width); + alpha = (0.5f * width - dist) / (width); if (dir == 0) - alpha = 1-alpha; + alpha = 1 - alpha; return alpha; } static float check_zone(WipeZone *wipezone, int x, int y, - Sequence *seq, float facf0) + Sequence *seq, float facf0) { float posx, posy, hyp, hyp2, angle, hwidth, b1, b2, b3, pointdist; /* some future stuff */ @@ -1642,9 +1637,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, float temp1, temp2, temp3, temp4; //some placeholder variables int xo = wipezone->xo; int yo = wipezone->yo; - float halfx = xo*0.5f; - float halfy = yo*0.5f; - float widthf, output=0; + float halfx = xo * 0.5f; + float halfy = yo * 0.5f; + float widthf, output = 0; WipeVars *wipe = (WipeVars *)seq->effectdata; int width; @@ -1670,9 +1665,9 @@ static float check_zone(WipeZone *wipezone, int x, int y, hyp = fabs(y - posy); } else { - b1 = posy - (-angle)*posx; - b2 = y - (-angle)*x; - hyp = fabsf(angle*x+y+(-posy-angle*posx))*wipezone->pythangle; + b1 = posy - (-angle) * posx; + b2 = y - (-angle) * x; + hyp = fabsf(angle * x + y + (-posy - angle * posx)) * wipezone->pythangle; } if (angle < 0) { @@ -1693,49 +1688,49 @@ static float check_zone(WipeZone *wipezone, int x, int y, else output = in_band(width, hyp, 1, 1); } - break; + break; case DO_DOUBLE_WIPE: if (!wipe->forward) - facf0 = 1.0f-facf0; // Go the other direction + facf0 = 1.0f - facf0; // Go the other direction width = wipezone->width; // calculate the blur width - hwidth = width*0.5f; + hwidth = width * 0.5f; if (angle == 0) { - b1 = posy*0.5f; - b3 = yo-posy*0.5f; + b1 = posy * 0.5f; + b3 = yo - posy * 0.5f; b2 = y; - hyp = abs(y - posy*0.5f); - hyp2 = abs(y - (yo-posy*0.5f)); + hyp = abs(y - posy * 0.5f); + hyp2 = abs(y - (yo - posy * 0.5f)); } else { - b1 = posy*0.5f - (-angle)*posx*0.5f; - b3 = (yo-posy*0.5f) - (-angle)*(xo-posx*0.5f); - b2 = y - (-angle)*x; + b1 = posy * 0.5f - (-angle) * posx * 0.5f; + b3 = (yo - posy * 0.5f) - (-angle) * (xo - posx * 0.5f); + b2 = y - (-angle) * x; - hyp = fabsf(angle*x+y+(-posy*0.5f-angle*posx*0.5f))*wipezone->pythangle; - hyp2 = fabsf(angle*x+y+(-(yo-posy*0.5f)-angle*(xo-posx*0.5f)))*wipezone->pythangle; + hyp = fabsf(angle * x + y + (-posy * 0.5f - angle * posx * 0.5f)) * wipezone->pythangle; + hyp2 = fabsf(angle * x + y + (-(yo - posy * 0.5f) - angle * (xo - posx * 0.5f))) * wipezone->pythangle; } - hwidth = minf(hwidth, fabsf(b3-b1)/2.0f); + hwidth = minf(hwidth, fabsf(b3 - b1) / 2.0f); - if (b2 < b1 && b2 < b3 ) { + if (b2 < b1 && b2 < b3) { output = in_band(hwidth, hyp, 0, 1); } - else if (b2 > b1 && b2 > b3 ) { + else if (b2 > b1 && b2 > b3) { output = in_band(hwidth, hyp2, 0, 1); } else { - if ( hyp < hwidth && hyp2 > hwidth ) + if (hyp < hwidth && hyp2 > hwidth) output = in_band(hwidth, hyp, 1, 1); - else if ( hyp > hwidth && hyp2 < hwidth ) - output = in_band(hwidth, hyp2, 1, 1); + else if (hyp > hwidth && hyp2 < hwidth) + output = in_band(hwidth, hyp2, 1, 1); else - output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1); + output = in_band(hwidth, hyp2, 1, 1) * in_band(hwidth, hyp, 1, 1); } - if (!wipe->forward)output = 1-output; - break; + if (!wipe->forward) output = 1 - output; + break; case DO_CLOCK_WIPE: /* * temp1: angle of effect center in rads @@ -1744,125 +1739,125 @@ static float check_zone(WipeZone *wipezone, int x, int y, * temp4: angle of high side of blur */ output = 1.0f - facf0; - widthf = wipe->edgeWidth*2.0f*(float)M_PI; + widthf = wipe->edgeWidth * 2.0f * (float)M_PI; temp1 = 2.0f * (float)M_PI * facf0; if (wipe->forward) { - temp1 = 2.0f*(float)M_PI - temp1; + temp1 = 2.0f * (float)M_PI - temp1; } x = x - halfx; y = y - halfy; - temp2 = asin(abs(y)/sqrt(x*x + y*y)); + temp2 = asin(abs(y) / sqrt(x * x + y * y)); if (x <= 0 && y >= 0) temp2 = (float)M_PI - temp2; - else if (x<=0 && y <= 0) temp2 += (float)M_PI; - else if (x >= 0 && y <= 0) temp2 = 2.0f*(float)M_PI - temp2; + else if (x <= 0 && y <= 0) temp2 += (float)M_PI; + else if (x >= 0 && y <= 0) temp2 = 2.0f * (float)M_PI - temp2; if (wipe->forward) { - temp3 = temp1-(widthf*0.5f)*facf0; - temp4 = temp1+(widthf*0.5f)*(1-facf0); + temp3 = temp1 - (widthf * 0.5f) * facf0; + temp4 = temp1 + (widthf * 0.5f) * (1 - facf0); } else { - temp3 = temp1-(widthf*0.5f)*(1-facf0); - temp4 = temp1+(widthf*0.5f)*facf0; + temp3 = temp1 - (widthf * 0.5f) * (1 - facf0); + temp4 = temp1 + (widthf * 0.5f) * facf0; } if (temp3 < 0) temp3 = 0; - if (temp4 > 2.0f*(float)M_PI) temp4 = 2.0f*(float)M_PI; + if (temp4 > 2.0f * (float)M_PI) temp4 = 2.0f * (float)M_PI; if (temp2 < temp3) output = 0; else if (temp2 > temp4) output = 1; - else output = (temp2-temp3)/(temp4-temp3); + else output = (temp2 - temp3) / (temp4 - temp3); if (x == 0 && y == 0) output = 1; if (output != output) output = 1; if (wipe->forward) output = 1 - output; - break; - /* BOX WIPE IS NOT WORKING YET */ - /* case DO_CROSS_WIPE: */ - /* BOX WIPE IS NOT WORKING YET */ + break; + /* BOX WIPE IS NOT WORKING YET */ + /* case DO_CROSS_WIPE: */ + /* BOX WIPE IS NOT WORKING YET */ #if 0 case DO_BOX_WIPE: - if (invert)facf0 = 1-facf0; + if (invert) facf0 = 1 - facf0; - width = (int)(wipe->edgeWidth*((xo+yo)/2.0)); - hwidth = (float)width/2.0; - if (angle == 0)angle = 0.000001; - b1 = posy/2 - (-angle)*posx/2; - b3 = (yo-posy/2) - (-angle)*(xo-posx/2); - b2 = y - (-angle)*x; + width = (int)(wipe->edgeWidth * ((xo + yo) / 2.0)); + hwidth = (float)width / 2.0; + if (angle == 0) angle = 0.000001; + b1 = posy / 2 - (-angle) * posx / 2; + b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2); + b2 = y - (-angle) * x; - hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle; - hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle; + hyp = abs(angle * x + y + (-posy / 2 - angle * posx / 2)) * wipezone->pythangle; + hyp2 = abs(angle * x + y + (-(yo - posy / 2) - angle * (xo - posx / 2))) * wipezone->pythangle; - temp1 = xo*(1-facf0/2)-xo*facf0/2; - temp2 = yo*(1-facf0/2)-yo*facf0/2; - pointdist = sqrt(temp1*temp1 + temp2*temp2); + temp1 = xo * (1 - facf0 / 2) - xo * facf0 / 2; + temp2 = yo * (1 - facf0 / 2) - yo * facf0 / 2; + pointdist = sqrt(temp1 * temp1 + temp2 * temp2); - if (b2 < b1 && b2 < b3 ) { + if (b2 < b1 && b2 < b3) { if (hwidth < pointdist) output = in_band(wipezone, hwidth, hyp, facf0, 0, 1); - } - else if (b2 > b1 && b2 > b3 ) { + } + else if (b2 > b1 && b2 > b3) { if (hwidth < pointdist) output = in_band(wipezone, hwidth, hyp2, facf0, 0, 1); - } - else { - if ( hyp < hwidth && hyp2 > hwidth ) + } + else { + if (hyp < hwidth && hyp2 > hwidth) output = in_band(wipezone, hwidth, hyp, facf0, 1, 1); - else if ( hyp > hwidth && hyp2 < hwidth ) - output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1); + else if (hyp > hwidth && hyp2 < hwidth) + output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1); else - output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); + output = in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); } - if (invert)facf0 = 1-facf0; - angle = -1/angle; - b1 = posy/2 - (-angle)*posx/2; - b3 = (yo-posy/2) - (-angle)*(xo-posx/2); - b2 = y - (-angle)*x; + if (invert) facf0 = 1 - facf0; + angle = -1 / angle; + b1 = posy / 2 - (-angle) * posx / 2; + b3 = (yo - posy / 2) - (-angle) * (xo - posx / 2); + b2 = y - (-angle) * x; - hyp = abs(angle*x+y+(-posy/2-angle*posx/2))*wipezone->pythangle; - hyp2 = abs(angle*x+y+(-(yo-posy/2)-angle*(xo-posx/2)))*wipezone->pythangle; + hyp = abs(angle * x + y + (-posy / 2 - angle * posx / 2)) * wipezone->pythangle; + hyp2 = abs(angle * x + y + (-(yo - posy / 2) - angle * (xo - posx / 2))) * wipezone->pythangle; - if (b2 < b1 && b2 < b3 ) { + if (b2 < b1 && b2 < b3) { if (hwidth < pointdist) output *= in_band(wipezone, hwidth, hyp, facf0, 0, 1); - } - else if (b2 > b1 && b2 > b3 ) { + } + else if (b2 > b1 && b2 > b3) { if (hwidth < pointdist) output *= in_band(wipezone, hwidth, hyp2, facf0, 0, 1); - } - else { - if ( hyp < hwidth && hyp2 > hwidth ) + } + else { + if (hyp < hwidth && hyp2 > hwidth) output *= in_band(wipezone, hwidth, hyp, facf0, 1, 1); - else if ( hyp > hwidth && hyp2 < hwidth ) + else if (hyp > hwidth && hyp2 < hwidth) output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1); else output *= in_band(wipezone, hwidth, hyp2, facf0, 1, 1) * in_band(wipezone, hwidth, hyp, facf0, 1, 1); } - break; + break; #endif case DO_IRIS_WIPE: if (xo > yo) yo = xo; else xo = yo; - if (!wipe->forward) facf0 = 1-facf0; + if (!wipe->forward) facf0 = 1 - facf0; width = wipezone->width; - hwidth = width*0.5f; + hwidth = width * 0.5f; - temp1 = (halfx-(halfx)*facf0); - pointdist = sqrt(temp1*temp1 + temp1*temp1); + temp1 = (halfx - (halfx) * facf0); + pointdist = sqrt(temp1 * temp1 + temp1 * temp1); - temp2 = sqrt((halfx-x)*(halfx-x) + (halfy-y)*(halfy-y)); - if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2-pointdist), 0, 1); - else output = in_band(hwidth, fabs(temp2-pointdist), 1, 1); + temp2 = sqrt((halfx - x) * (halfx - x) + (halfy - y) * (halfy - y)); + if (temp2 > pointdist) output = in_band(hwidth, fabs(temp2 - pointdist), 0, 1); + else output = in_band(hwidth, fabs(temp2 - pointdist), 1, 1); - if (!wipe->forward) output = 1-output; + if (!wipe->forward) output = 1 - output; - break; + break; } if (output < 0) output = 0; else if (output > 1) output = 1; @@ -1871,7 +1866,7 @@ static float check_zone(WipeZone *wipezone, int x, int y, static void init_wipe_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct WipeVars), "wipevars"); } @@ -1882,7 +1877,7 @@ static int num_inputs_wipe(void) static void free_wipe_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -1892,9 +1887,9 @@ static void copy_wipe_effect(Sequence *dst, Sequence *src) } static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), - int x, int y, - unsigned char *rect1, - unsigned char *rect2, unsigned char *out) + int x, int y, + unsigned char *rect1, + unsigned char *rect2, unsigned char *out) { WipeZone wipezone; WipeVars *wipe = (WipeVars *)seq->effectdata; @@ -1909,15 +1904,15 @@ static void do_wipe_effect_byte(Sequence *seq, float facf0, float UNUSED(facf1), xo = x; yo = y; - for (y=0;yeffectdata; @@ -1970,15 +1965,15 @@ static void do_wipe_effect_float(Sequence *seq, float facf0, float UNUSED(facf1) xo = x; yo = y; - for (y=0;yrect_float) { do_wipe_effect_float(seq, - facf0, facf1, context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_wipe_effect_byte(seq, - facf0, facf1, context.rectx, context.recty, - (unsigned char*) ibuf1->rect, (unsigned char*) ibuf2->rect, - (unsigned char*) out->rect); + facf0, facf1, context.rectx, context.recty, + (unsigned char *) ibuf1->rect, (unsigned char *) ibuf2->rect, + (unsigned char *) out->rect); } return out; @@ -2043,7 +2037,7 @@ static void init_transform_effect(Sequence *seq) { TransformVars *transform; - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct TransformVars), "transformvars"); transform = (TransformVars *)seq->effectdata; @@ -2051,14 +2045,14 @@ static void init_transform_effect(Sequence *seq) transform->ScalexIni = 1.0f; transform->ScaleyIni = 1.0f; - transform->xIni=0.0f; - transform->yIni=0.0f; + transform->xIni = 0.0f; + transform->yIni = 0.0f; - transform->rotIni=0.0f; + transform->rotIni = 0.0f; - transform->interpolation=1; - transform->percent=1; - transform->uniform_scale=0; + transform->interpolation = 1; + transform->percent = 1; + transform->uniform_scale = 0; } static int num_inputs_transform(void) @@ -2068,7 +2062,7 @@ static int num_inputs_transform(void) static void free_transform_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -2078,8 +2072,8 @@ static void copy_transform_effect(Sequence *dst, Sequence *src) } static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out, - float scale_x, float scale_y, float translate_x, float translate_y, - float rotate, int interpolation) + float scale_x, float scale_y, float translate_x, float translate_y, + float rotate, int interpolation) { int xo, yo, xi, yi; float xt, yt, xr, yr; @@ -2089,19 +2083,19 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out yo = y; // Rotate - s= sin(rotate); - c= cos(rotate); + s = sin(rotate); + c = cos(rotate); for (yi = 0; yi < yo; yi++) { for (xi = 0; xi < xo; xi++) { //translate point - xt = xi-translate_x; - yt = yi-translate_y; + xt = xi - translate_x; + yt = yi - translate_y; //rotate point with center ref - xr = c*xt + s*yt; - yr = -s*xt + c*yt; + xr = c * xt + s * yt; + yr = -s * xt + c * yt; //scale point with center ref xt = xr / scale_x; @@ -2113,22 +2107,22 @@ static void transform_image(int x, int y, struct ImBuf *ibuf1, struct ImBuf *out //interpolate switch (interpolation) { - case 0: - neareast_interpolation(ibuf1, out, xt, yt, xi, yi); - break; - case 1: - bilinear_interpolation(ibuf1, out, xt, yt, xi, yi); - break; - case 2: - bicubic_interpolation(ibuf1, out, xt, yt, xi, yi); - break; + case 0: + neareast_interpolation(ibuf1, out, xt, yt, xi, yi); + break; + case 1: + bilinear_interpolation(ibuf1, out, xt, yt, xi, yi); + break; + case 2: + bicubic_interpolation(ibuf1, out, xt, yt, xi, yi); + break; } } } } static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x, int y, - struct ImBuf *ibuf1, struct ImBuf *out) + struct ImBuf *ibuf1, struct ImBuf *out) { TransformVars *transform = (TransformVars *)seq->effectdata; float scale_x, scale_y, translate_x, translate_y, rotate_radians; @@ -2144,14 +2138,14 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x // Translate if (!transform->percent) { - float rd_s = (scene->r.size/100.0f); + float rd_s = (scene->r.size / 100.0f); - translate_x = transform->xIni*rd_s+(x/2.0f); - translate_y = transform->yIni*rd_s+(y/2.0f); + translate_x = transform->xIni * rd_s + (x / 2.0f); + translate_y = transform->yIni * rd_s + (y / 2.0f); } else { - translate_x = x*(transform->xIni/100.0f)+(x/2.0f); - translate_y = y*(transform->yIni/100.0f)+(y/2.0f); + translate_x = x * (transform->xIni / 100.0f) + (x / 2.0f); + translate_y = y * (transform->yIni / 100.0f) + (y / 2.0f); } // Rotate @@ -2161,13 +2155,12 @@ static void do_transform(Scene *scene, Sequence *seq, float UNUSED(facf0), int x } -static struct ImBuf * do_transform_effect( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float UNUSED(facf1), - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_transform_effect( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float UNUSED(facf1), + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); do_transform(context.scene, seq, facf0, context.rectx, context.recty, ibuf1, out); @@ -2180,7 +2173,7 @@ static struct ImBuf * do_transform_effect( * GLOW * ********************************************************************** */ -static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, +static void RVBlurBitmap2_byte(unsigned char *map, int width, int height, float blur, int quality) /* MUUUCCH better than the previous blur. */ @@ -2192,26 +2185,26 @@ static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, /* a small bitmap. Avoid avoid avoid. */ /*=============================== */ { - unsigned char* temp=NULL, *swap; - float *filter=NULL; - int x, y, i, fx, fy; - int index, ix, halfWidth; - float fval, k, curColor[3], curColor2[3], weight=0; + unsigned char *temp = NULL, *swap; + float *filter = NULL; + int x, y, i, fx, fy; + int index, ix, halfWidth; + float fval, k, curColor[3], curColor2[3], weight = 0; /* If we're not really blurring, bail out */ - if (blur<=0) + if (blur <= 0) return; /* Allocate memory for the tempmap and the blur filter matrix */ - temp= MEM_mallocN((width*height*4), "blurbitmaptemp"); + temp = MEM_mallocN((width * height * 4), "blurbitmaptemp"); if (!temp) return; /* Allocate memory for the filter elements */ - halfWidth = ((quality+1)*blur); - filter = (float *)MEM_mallocN(sizeof(float)*halfWidth*2, "blurbitmapfilter"); + halfWidth = ((quality + 1) * blur); + filter = (float *)MEM_mallocN(sizeof(float) * halfWidth * 2, "blurbitmapfilter"); if (!filter) { - MEM_freeN (temp); + MEM_freeN(temp); return; } @@ -2221,137 +2214,137 @@ static void RVBlurBitmap2_byte(unsigned char* map, int width, int height, /* posted to comp.graphics.algorithms by */ /* Blancmange (bmange@airdmhor.gen.nz) */ - k = -1.0f/(2.0f*(float)M_PI*blur*blur); - for (ix = 0;ix< halfWidth;ix++) { - weight = (float)exp(k*(ix*ix)); + k = -1.0f / (2.0f * (float)M_PI * blur * blur); + for (ix = 0; ix < halfWidth; ix++) { + weight = (float)exp(k * (ix * ix)); filter[halfWidth - ix] = weight; filter[halfWidth + ix] = weight; } filter[0] = weight; /* Normalize the array */ - fval=0; - for (ix = 0;ix< halfWidth*2;ix++) - fval+=filter[ix]; + fval = 0; + for (ix = 0; ix < halfWidth * 2; ix++) + fval += filter[ix]; - for (ix = 0;ix< halfWidth*2;ix++) - filter[ix]/=fval; + for (ix = 0; ix < halfWidth * 2; ix++) + filter[ix] /= fval; /* Blur the rows */ - for (y=0;y=0)&&(i= 0) && (i < width)) { + curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx]; + curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx]; + curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx]; - curColor2[0]+=map[(width-1-i+y*width)*4+GlowR] * - filter[fx]; - curColor2[1]+=map[(width-1-i+y*width)*4+GlowG] * - filter[fx]; - curColor2[2]+=map[(width-1-i+y*width)*4+GlowB] * - filter[fx]; + curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] * + filter[fx]; + curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] * + filter[fx]; + curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] * + filter[fx]; } fx++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; - temp[((width-1-x+y*width)*4)+GlowR]=curColor2[0]; - temp[((width-1-x+y*width)*4)+GlowG]=curColor2[1]; - temp[((width-1-x+y*width)*4)+GlowB]=curColor2[2]; + temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0]; + temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1]; + temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (x=halfWidth;x=0)&&(i= 0) && (i < height)) { /* Bottom */ - curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; - curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; - curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy]; + curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy]; + curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy]; + curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy]; /* Top */ - curColor2[0]+=map[(x+(height-1-i)*width) * - 4+GlowR]*filter[fy]; - curColor2[1]+=map[(x+(height-1-i)*width) * - 4+GlowG]*filter[fy]; - curColor2[2]+=map[(x+(height-1-i)*width) * - 4+GlowB]*filter[fy]; + curColor2[0] += map[(x + (height - 1 - i) * width) * + 4 + GlowR] * filter[fy]; + curColor2[1] += map[(x + (height - 1 - i) * width) * + 4 + GlowG] * filter[fy]; + curColor2[2] += map[(x + (height - 1 - i) * width) * + 4 + GlowB] * filter[fy]; } fy++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; - temp[((x+(height-1-y)*width)*4)+GlowR]=curColor2[0]; - temp[((x+(height-1-y)*width)*4)+GlowG]=curColor2[1]; - temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; + temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0]; + temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1]; + temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (y=halfWidth;y=0)&&(i= 0) && (i < width)) { + curColor[0] += map[(i + y * width) * 4 + GlowR] * filter[fx]; + curColor[1] += map[(i + y * width) * 4 + GlowG] * filter[fx]; + curColor[2] += map[(i + y * width) * 4 + GlowB] * filter[fx]; - curColor2[0]+=map[(width-1-i+y*width)*4+GlowR] * - filter[fx]; - curColor2[1]+=map[(width-1-i+y*width)*4+GlowG] * - filter[fx]; - curColor2[2]+=map[(width-1-i+y*width)*4+GlowB] * - filter[fx]; + curColor2[0] += map[(width - 1 - i + y * width) * 4 + GlowR] * + filter[fx]; + curColor2[1] += map[(width - 1 - i + y * width) * 4 + GlowG] * + filter[fx]; + curColor2[2] += map[(width - 1 - i + y * width) * 4 + GlowB] * + filter[fx]; } fx++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; - temp[((width-1-x+y*width)*4)+GlowR]=curColor2[0]; - temp[((width-1-x+y*width)*4)+GlowG]=curColor2[1]; - temp[((width-1-x+y*width)*4)+GlowB]=curColor2[2]; + temp[((width - 1 - x + y * width) * 4) + GlowR] = curColor2[0]; + temp[((width - 1 - x + y * width) * 4) + GlowG] = curColor2[1]; + temp[((width - 1 - x + y * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (x=halfWidth;x=0)&&(i= 0) && (i < height)) { /* Bottom */ - curColor[0]+=map[(x+i*width)*4+GlowR]*filter[fy]; - curColor[1]+=map[(x+i*width)*4+GlowG]*filter[fy]; - curColor[2]+=map[(x+i*width)*4+GlowB]*filter[fy]; + curColor[0] += map[(x + i * width) * 4 + GlowR] * filter[fy]; + curColor[1] += map[(x + i * width) * 4 + GlowG] * filter[fy]; + curColor[2] += map[(x + i * width) * 4 + GlowB] * filter[fy]; /* Top */ - curColor2[0]+=map[(x+(height-1-i)*width) * - 4+GlowR]*filter[fy]; - curColor2[1]+=map[(x+(height-1-i)*width) * - 4+GlowG]*filter[fy]; - curColor2[2]+=map[(x+(height-1-i)*width) * - 4+GlowB]*filter[fy]; + curColor2[0] += map[(x + (height - 1 - i) * width) * + 4 + GlowR] * filter[fy]; + curColor2[1] += map[(x + (height - 1 - i) * width) * + 4 + GlowG] * filter[fy]; + curColor2[2] += map[(x + (height - 1 - i) * width) * + 4 + GlowB] * filter[fy]; } fy++; } - temp[index+GlowR]=curColor[0]; - temp[index+GlowG]=curColor[1]; - temp[index+GlowB]=curColor[2]; - temp[((x+(height-1-y)*width)*4)+GlowR]=curColor2[0]; - temp[((x+(height-1-y)*width)*4)+GlowG]=curColor2[1]; - temp[((x+(height-1-y)*width)*4)+GlowB]=curColor2[2]; + temp[index + GlowR] = curColor[0]; + temp[index + GlowG] = curColor[1]; + temp[index + GlowB] = curColor[2]; + temp[((x + (height - 1 - y) * width) * 4) + GlowR] = curColor2[0]; + temp[((x + (height - 1 - y) * width) * 4) + GlowG] = curColor2[1]; + temp[((x + (height - 1 - y) * width) * 4) + GlowB] = curColor2[2]; } /* Do the main body */ - for (y=halfWidth;y0) { - out[index+GlowR]=MIN2(255*clamp, (in[index+GlowR]*boost*intensity)/255); - out[index+GlowG]=MIN2(255*clamp, (in[index+GlowG]*boost*intensity)/255); - out[index+GlowB]=MIN2(255*clamp, (in[index+GlowB]*boost*intensity)/255); - out[index+GlowA]=MIN2(255*clamp, (in[index+GlowA]*boost*intensity)/255); + intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold); + if (intensity > 0) { + out[index + GlowR] = MIN2(255 * clamp, (in[index + GlowR] * boost * intensity) / 255); + out[index + GlowG] = MIN2(255 * clamp, (in[index + GlowG] * boost * intensity) / 255); + out[index + GlowB] = MIN2(255 * clamp, (in[index + GlowB] * boost * intensity) / 255); + out[index + GlowA] = MIN2(255 * clamp, (in[index + GlowA] * boost * intensity) / 255); } else { - out[index+GlowR]=0; - out[index+GlowG]=0; - out[index+GlowB]=0; - out[index+GlowA]=0; + out[index + GlowR] = 0; + out[index + GlowG] = 0; + out[index + GlowB] = 0; + out[index + GlowA] = 0; } } } } -static void RVIsolateHighlights_float (float* in, float* out, - int width, int height, float threshold, - float boost, float clamp) +static void RVIsolateHighlights_float(float *in, float *out, + int width, int height, float threshold, + float boost, float clamp) { int x, y, index; - float intensity; + float intensity; - for (y=0;y< height;y++) { - for (x=0;x< width;x++) { - index= (x+y*width)*4; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + index = (x + y * width) * 4; /* Isolate the intensity */ - intensity=(in[index+GlowR]+in[index+GlowG]+in[index+GlowB]-threshold); - if (intensity>0) { - out[index+GlowR]=MIN2(clamp, (in[index+GlowR]*boost*intensity)); - out[index+GlowG]=MIN2(clamp, (in[index+GlowG]*boost*intensity)); - out[index+GlowB]=MIN2(clamp, (in[index+GlowB]*boost*intensity)); - out[index+GlowA]=MIN2(clamp, (in[index+GlowA]*boost*intensity)); + intensity = (in[index + GlowR] + in[index + GlowG] + in[index + GlowB] - threshold); + if (intensity > 0) { + out[index + GlowR] = MIN2(clamp, (in[index + GlowR] * boost * intensity)); + out[index + GlowG] = MIN2(clamp, (in[index + GlowG] * boost * intensity)); + out[index + GlowB] = MIN2(clamp, (in[index + GlowB] * boost * intensity)); + out[index + GlowA] = MIN2(clamp, (in[index + GlowA] * boost * intensity)); } else { - out[index+GlowR]=0; - out[index+GlowG]=0; - out[index+GlowB]=0; - out[index+GlowA]=0; + out[index + GlowR] = 0; + out[index + GlowG] = 0; + out[index + GlowB] = 0; + out[index + GlowA] = 0; } } } @@ -2621,7 +2614,7 @@ static void init_glow_effect(Sequence *seq) { GlowVars *glow; - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct GlowVars), "glowvars"); glow = (GlowVars *)seq->effectdata; @@ -2640,7 +2633,7 @@ static int num_inputs_glow(void) static void free_glow_effect(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -2651,56 +2644,56 @@ static void copy_glow_effect(Sequence *dst, Sequence *src) //void do_glow_effect(Cast *cast, float facf0, float facf1, int xo, int yo, ImBuf *ibuf1, ImBuf *ibuf2, ImBuf *outbuf, ImBuf *use) static void do_glow_effect_byte(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), - int x, int y, char *rect1, - char *UNUSED(rect2), char *out) + int x, int y, char *rect1, + char *UNUSED(rect2), char *out) { - unsigned char *outbuf=(unsigned char *)out; - unsigned char *inbuf=(unsigned char *)rect1; + unsigned char *outbuf = (unsigned char *)out; + unsigned char *inbuf = (unsigned char *)rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini*765, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_byte (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); + RVIsolateHighlights_byte(inbuf, outbuf, x, y, glow->fMini * 765, glow->fBoost * facf0, glow->fClamp); + RVBlurBitmap2_byte(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); if (!glow->bNoComp) - RVAddBitmaps_byte (inbuf, outbuf, outbuf, x, y); + RVAddBitmaps_byte(inbuf, outbuf, outbuf, x, y); } static void do_glow_effect_float(Sequence *seq, int render_size, float facf0, float UNUSED(facf1), - int x, int y, - float *rect1, float *UNUSED(rect2), float *out) + int x, int y, + float *rect1, float *UNUSED(rect2), float *out) { float *outbuf = out; float *inbuf = rect1; GlowVars *glow = (GlowVars *)seq->effectdata; - RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini*3.0f, glow->fBoost * facf0, glow->fClamp); - RVBlurBitmap2_float (outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); + RVIsolateHighlights_float(inbuf, outbuf, x, y, glow->fMini * 3.0f, glow->fBoost * facf0, glow->fClamp); + RVBlurBitmap2_float(outbuf, x, y, glow->dDist * (render_size / 100.0f), glow->dQuality); if (!glow->bNoComp) - RVAddBitmaps_float (inbuf, outbuf, outbuf, x, y); + RVAddBitmaps_float(inbuf, outbuf, outbuf, x, y); } -static struct ImBuf * do_glow_effect( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) +static struct ImBuf *do_glow_effect( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3) { - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); - int render_size = 100*context.rectx/context.scene->r.xsch; + int render_size = 100 * context.rectx / context.scene->r.xsch; if (out->rect_float) { do_glow_effect_float(seq, render_size, - facf0, facf1, - context.rectx, context.recty, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, + context.rectx, context.recty, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_glow_effect_byte(seq, render_size, - facf0, facf1, - context.rectx, context.recty, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, + context.rectx, context.recty, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; @@ -2714,7 +2707,7 @@ static void init_solid_color(Sequence *seq) { SolidColorVars *cv; - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct SolidColorVars), "solidcolor"); cv = (SolidColorVars *)seq->effectdata; @@ -2728,7 +2721,7 @@ static int num_inputs_color(void) static void free_solid_color(Sequence *seq) { - if (seq->effectdata)MEM_freeN(seq->effectdata); + if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; } @@ -2738,18 +2731,17 @@ static void copy_solid_color(Sequence *dst, Sequence *src) } static int early_out_color(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return -1; } -static struct ImBuf * do_solid_color( - SeqRenderData context, Sequence *seq, float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf *ibuf1, struct ImBuf *ibuf2, - struct ImBuf *ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_solid_color( + SeqRenderData context, Sequence *seq, float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); SolidColorVars *cv = (SolidColorVars *)seq->effectdata; @@ -2772,20 +2764,20 @@ static struct ImBuf * do_solid_color( rect = (unsigned char *)out->rect; - for (y=0; yy; y++) { - for (x=0; xx; x++, rect+=4) { - rect[0]= col0[0]; - rect[1]= col0[1]; - rect[2]= col0[2]; - rect[3]= 255; + for (y = 0; y < out->y; y++) { + for (x = 0; x < out->x; x++, rect += 4) { + rect[0] = col0[0]; + rect[1] = col0[1]; + rect[2] = col0[2]; + rect[3] = 255; } y++; - if (yy) { - for (x=0; xx; x++, rect+=4) { - rect[0]= col1[0]; - rect[1]= col1[1]; - rect[2]= col1[2]; - rect[3]= 255; + if (y < out->y) { + for (x = 0; x < out->x; x++, rect += 4) { + rect[0] = col1[0]; + rect[1] = col1[1]; + rect[2] = col1[2]; + rect[3] = 255; } } } @@ -2805,20 +2797,20 @@ static struct ImBuf * do_solid_color( rect_float = out->rect_float; - for (y=0; yy; y++) { - for (x=0; xx; x++, rect_float+=4) { - rect_float[0]= col0[0]; - rect_float[1]= col0[1]; - rect_float[2]= col0[2]; - rect_float[3]= 1.0; + for (y = 0; y < out->y; y++) { + for (x = 0; x < out->x; x++, rect_float += 4) { + rect_float[0] = col0[0]; + rect_float[1] = col0[1]; + rect_float[2] = col0[2]; + rect_float[3] = 1.0; } y++; - if (yy) { - for (x=0; xx; x++, rect_float+=4) { - rect_float[0]= col1[0]; - rect_float[1]= col1[1]; - rect_float[2]= col1[2]; - rect_float[3]= 1.0; + if (y < out->y) { + for (x = 0; x < out->x; x++, rect_float += 4) { + rect_float[0] = col1[0]; + rect_float[1] = col1[1]; + rect_float[2] = col1[2]; + rect_float[3] = 1.0; } } } @@ -2841,16 +2833,15 @@ static int early_out_multicam(struct Sequence *UNUSED(seq), float UNUSED(facf0), return -1; } -static struct ImBuf * do_multicam( - SeqRenderData context, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), - struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), - struct ImBuf *UNUSED(ibuf3)) -{ - struct ImBuf * i; - struct ImBuf * out; - Editing * ed; - ListBase * seqbasep; +static struct ImBuf *do_multicam( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)){ + struct ImBuf *i; + struct ImBuf *out; + Editing *ed; + ListBase *seqbasep; if (seq->multicam_source == 0 || seq->multicam_source >= seq->machine) { return NULL; @@ -2896,12 +2887,11 @@ static int early_out_adjustment(struct Sequence *UNUSED(seq), float UNUSED(facf0 return -1; } -static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, - float cfra) -{ - Editing * ed; - ListBase * seqbasep; - struct ImBuf * i= NULL; +static struct ImBuf *do_adjustment_impl(SeqRenderData context, Sequence *seq, + float cfra){ + Editing *ed; + ListBase *seqbasep; + struct ImBuf *i = NULL; ed = context.scene->ed; @@ -2909,7 +2899,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, if (seq->machine > 0) { i = give_ibuf_seqbase(context, cfra, - seq->machine - 1, seqbasep); + seq->machine - 1, seqbasep); } /* found nothing? so let's work the way up the metastrip stack, so @@ -2918,7 +2908,7 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, */ if (!i) { - Sequence * meta; + Sequence *meta; meta = seq_metastrip(&ed->seqbase, NULL, seq); @@ -2930,15 +2920,14 @@ static struct ImBuf * do_adjustment_impl(SeqRenderData context, Sequence * seq, return i; } -static struct ImBuf * do_adjustment( - SeqRenderData context, Sequence *seq, float cfra, - float UNUSED(facf0), float UNUSED(facf1), - struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), - struct ImBuf *UNUSED(ibuf3)) -{ - struct ImBuf * i = NULL; - struct ImBuf * out; - Editing * ed; +static struct ImBuf *do_adjustment( + SeqRenderData context, Sequence *seq, float cfra, + float UNUSED(facf0), float UNUSED(facf1), + struct ImBuf *UNUSED(ibuf1), struct ImBuf *UNUSED(ibuf2), + struct ImBuf *UNUSED(ibuf3)){ + struct ImBuf *i = NULL; + struct ImBuf *out; + Editing *ed; ed = context.scene->ed; @@ -2964,11 +2953,11 @@ static struct ImBuf * do_adjustment( * ********************************************************************** */ static void init_speed_effect(Sequence *seq) { - SpeedControlVars * v; + SpeedControlVars *v; if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = MEM_callocN(sizeof(struct SpeedControlVars), - "speedcontrolvars"); + "speedcontrolvars"); v = (SpeedControlVars *)seq->effectdata; v->globalSpeed = 1.0; @@ -2977,9 +2966,9 @@ static void init_speed_effect(Sequence *seq) v->length = 0; } -static void load_speed_effect(Sequence * seq) +static void load_speed_effect(Sequence *seq) { - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; v->frameMap = NULL; v->length = 0; @@ -2992,7 +2981,7 @@ static int num_inputs_speed(void) static void free_speed_effect(Sequence *seq) { - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; if (v->frameMap) MEM_freeN(v->frameMap); if (seq->effectdata) MEM_freeN(seq->effectdata); seq->effectdata = NULL; @@ -3000,7 +2989,7 @@ static void free_speed_effect(Sequence *seq) static void copy_speed_effect(Sequence *dst, Sequence *src) { - SpeedControlVars * v; + SpeedControlVars *v; dst->effectdata = MEM_dupallocN(src->effectdata); v = (SpeedControlVars *)dst->effectdata; v->frameMap = NULL; @@ -3008,15 +2997,15 @@ static void copy_speed_effect(Sequence *dst, Sequence *src) } static int early_out_speed(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return 1; } -static void store_icu_yrange_speed(struct Sequence * seq, - short UNUSED(adrcode), float * ymin, float * ymax) +static void store_icu_yrange_speed(struct Sequence *seq, + short UNUSED(adrcode), float *ymin, float *ymax) { - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; /* if not already done, load / initialize data */ get_sequence_effect(seq); @@ -3036,32 +3025,31 @@ static void store_icu_yrange_speed(struct Sequence * seq, } } } -void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) +void sequence_effect_speed_rebuild_map(Scene *scene, Sequence *seq, int force) { int cfra; float fallback_fac = 1.0f; - SpeedControlVars * v = (SpeedControlVars *)seq->effectdata; - FCurve *fcu= NULL; + SpeedControlVars *v = (SpeedControlVars *)seq->effectdata; + FCurve *fcu = NULL; int flags = v->flags; /* if not already done, load / initialize data */ get_sequence_effect(seq); - if ( (force == FALSE) && - (seq->len == v->length) && - (v->frameMap != NULL) - ) { + if ((force == FALSE) && + (seq->len == v->length) && + (v->frameMap != NULL)) + { return; } - if ( (seq->seq1 == NULL) || - (seq->len < 1) - ) { /* make coverity happy and check for (CID 598) input strip ... */ + if ((seq->seq1 == NULL) || (seq->len < 1)) { + /* make coverity happy and check for (CID 598) input strip ... */ return; } /* XXX - new in 2.5x. should we use the animation system this way? * The fcurve is needed because many frames need evaluating at once - campbell */ - fcu= id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL); + fcu = id_data_find_fcurve(&scene->id, seq, &RNA_Sequence, "speed_factor", 0, NULL); if (!v->frameMap || v->length != seq->len) { @@ -3070,7 +3058,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) v->length = seq->len; v->frameMap = MEM_callocN(sizeof(float) * v->length, - "speedcontrol frameMap"); + "speedcontrol frameMap"); } fallback_fac = 1.0; @@ -3080,7 +3068,7 @@ void sequence_effect_speed_rebuild_map(Scene *scene, Sequence * seq, int force) (seq->seq1->len != 0)) { fallback_fac = (float) seq->seq1->len / - (float) (seq->seq1->enddisp - seq->seq1->start); + (float) (seq->seq1->enddisp - seq->seq1->start); flags = SEQ_SPEED_INTEGRATE; fcu = NULL; } @@ -3179,13 +3167,13 @@ static int num_inputs_default(void) } static int early_out_noop(struct Sequence *UNUSED(seq), - float UNUSED(facf0), float UNUSED(facf1)) + float UNUSED(facf0), float UNUSED(facf1)) { return 0; } static int early_out_fade(struct Sequence *UNUSED(seq), - float facf0, float facf1) + float facf0, float facf1) { if (facf0 == 0.0f && facf1 == 0.0f) { return 1; @@ -3197,7 +3185,7 @@ static int early_out_fade(struct Sequence *UNUSED(seq), } static int early_out_mul_input2(struct Sequence *UNUSED(seq), - float facf0, float facf1) + float facf0, float facf1) { if (facf0 == 0.0f && facf1 == 0.0f) { return 1; @@ -3205,20 +3193,20 @@ static int early_out_mul_input2(struct Sequence *UNUSED(seq), return 0; } -static void store_icu_yrange_noop(struct Sequence * UNUSED(seq), - short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax)) +static void store_icu_yrange_noop(struct Sequence *UNUSED(seq), + short UNUSED(adrcode), float *UNUSED(ymin), float *UNUSED(ymax)) { /* defaults are fine */ } static void get_default_fac_noop(struct Sequence *UNUSED(seq), float UNUSED(cfra), - float * facf0, float * facf1) + float *facf0, float *facf1) { *facf0 = *facf1 = 1.0; } static void get_default_fac_fade(struct Sequence *seq, float cfra, - float * facf0, float * facf1) + float *facf0, float *facf1) { *facf0 = (float)(cfra - seq->startdisp); *facf1 = (float)(*facf0 + 0.5f); @@ -3226,45 +3214,43 @@ static void get_default_fac_fade(struct Sequence *seq, float cfra, *facf1 /= seq->len; } -static struct ImBuf * do_overdrop_effect(SeqRenderData context, - Sequence *UNUSED(seq), - float UNUSED(cfra), - float facf0, float facf1, - struct ImBuf * ibuf1, - struct ImBuf * ibuf2, - struct ImBuf * ibuf3) -{ - struct ImBuf * out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); +static struct ImBuf *do_overdrop_effect(SeqRenderData context, + Sequence *UNUSED(seq), + float UNUSED(cfra), + float facf0, float facf1, + struct ImBuf *ibuf1, + struct ImBuf *ibuf2, + struct ImBuf *ibuf3){ + struct ImBuf *out = prepare_effect_imbufs(context, ibuf1, ibuf2, ibuf3); int x = context.rectx; int y = context.recty; if (out->rect_float) { do_drop_effect_float( - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); do_alphaover_effect_float( - facf0, facf1, x, y, - ibuf1->rect_float, ibuf2->rect_float, - out->rect_float); + facf0, facf1, x, y, + ibuf1->rect_float, ibuf2->rect_float, + out->rect_float); } else { do_drop_effect_byte( - facf0, facf1, x, y, - (char*) ibuf1->rect, - (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, x, y, + (char *) ibuf1->rect, + (char *) ibuf2->rect, + (char *) out->rect); do_alphaover_effect_byte( - facf0, facf1, x, y, - (char*) ibuf1->rect, (char*) ibuf2->rect, - (char*) out->rect); + facf0, facf1, x, y, + (char *) ibuf1->rect, (char *) ibuf2->rect, + (char *) out->rect); } return out; } -static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) -{ +static struct SeqEffectHandle get_sequence_effect_impl(int seq_type){ struct SeqEffectHandle rval; int sequence_type = seq_type; @@ -3280,112 +3266,112 @@ static struct SeqEffectHandle get_sequence_effect_impl(int seq_type) rval.copy = NULL; switch (sequence_type) { - case SEQ_CROSS: - rval.execute = do_cross_effect; - rval.early_out = early_out_fade; - rval.get_default_fac = get_default_fac_fade; - break; - case SEQ_GAMCROSS: - rval.init = init_gammacross; - rval.load = load_gammacross; - rval.free = free_gammacross; - rval.early_out = early_out_fade; - rval.get_default_fac = get_default_fac_fade; - rval.execute = do_gammacross_effect; - break; - case SEQ_ADD: - rval.execute = do_add_effect; - rval.early_out = early_out_mul_input2; - break; - case SEQ_SUB: - rval.execute = do_sub_effect; - rval.early_out = early_out_mul_input2; - break; - case SEQ_MUL: - rval.execute = do_mul_effect; - rval.early_out = early_out_mul_input2; - break; - case SEQ_ALPHAOVER: - rval.init = init_alpha_over_or_under; - rval.execute = do_alphaover_effect; - break; - case SEQ_OVERDROP: - rval.execute = do_overdrop_effect; - break; - case SEQ_ALPHAUNDER: - rval.init = init_alpha_over_or_under; - rval.execute = do_alphaunder_effect; - break; - case SEQ_WIPE: - rval.init = init_wipe_effect; - rval.num_inputs = num_inputs_wipe; - rval.free = free_wipe_effect; - rval.copy = copy_wipe_effect; - rval.early_out = early_out_fade; - rval.get_default_fac = get_default_fac_fade; - rval.execute = do_wipe_effect; - break; - case SEQ_GLOW: - rval.init = init_glow_effect; - rval.num_inputs = num_inputs_glow; - rval.free = free_glow_effect; - rval.copy = copy_glow_effect; - rval.execute = do_glow_effect; - break; - case SEQ_TRANSFORM: - rval.init = init_transform_effect; - rval.num_inputs = num_inputs_transform; - rval.free = free_transform_effect; - rval.copy = copy_transform_effect; - rval.execute = do_transform_effect; - break; - case SEQ_SPEED: - rval.init = init_speed_effect; - rval.num_inputs = num_inputs_speed; - rval.load = load_speed_effect; - rval.free = free_speed_effect; - rval.copy = copy_speed_effect; - rval.execute = do_cross_effect; - rval.early_out = early_out_speed; - rval.store_icu_yrange = store_icu_yrange_speed; - break; - case SEQ_COLOR: - rval.init = init_solid_color; - rval.num_inputs = num_inputs_color; - rval.early_out = early_out_color; - rval.free = free_solid_color; - rval.copy = copy_solid_color; - rval.execute = do_solid_color; - break; - case SEQ_PLUGIN: - rval.init_plugin = init_plugin; - rval.num_inputs = num_inputs_plugin; - rval.load = load_plugin; - rval.free = free_plugin; - rval.copy = copy_plugin; - rval.execute = do_plugin_effect; - rval.early_out = do_plugin_early_out; - rval.get_default_fac = get_default_fac_fade; - break; - case SEQ_MULTICAM: - rval.num_inputs = num_inputs_multicam; - rval.early_out = early_out_multicam; - rval.execute = do_multicam; - break; - case SEQ_ADJUSTMENT: - rval.num_inputs = num_inputs_adjustment; - rval.early_out = early_out_adjustment; - rval.execute = do_adjustment; - break; + case SEQ_CROSS: + rval.execute = do_cross_effect; + rval.early_out = early_out_fade; + rval.get_default_fac = get_default_fac_fade; + break; + case SEQ_GAMCROSS: + rval.init = init_gammacross; + rval.load = load_gammacross; + rval.free = free_gammacross; + rval.early_out = early_out_fade; + rval.get_default_fac = get_default_fac_fade; + rval.execute = do_gammacross_effect; + break; + case SEQ_ADD: + rval.execute = do_add_effect; + rval.early_out = early_out_mul_input2; + break; + case SEQ_SUB: + rval.execute = do_sub_effect; + rval.early_out = early_out_mul_input2; + break; + case SEQ_MUL: + rval.execute = do_mul_effect; + rval.early_out = early_out_mul_input2; + break; + case SEQ_ALPHAOVER: + rval.init = init_alpha_over_or_under; + rval.execute = do_alphaover_effect; + break; + case SEQ_OVERDROP: + rval.execute = do_overdrop_effect; + break; + case SEQ_ALPHAUNDER: + rval.init = init_alpha_over_or_under; + rval.execute = do_alphaunder_effect; + break; + case SEQ_WIPE: + rval.init = init_wipe_effect; + rval.num_inputs = num_inputs_wipe; + rval.free = free_wipe_effect; + rval.copy = copy_wipe_effect; + rval.early_out = early_out_fade; + rval.get_default_fac = get_default_fac_fade; + rval.execute = do_wipe_effect; + break; + case SEQ_GLOW: + rval.init = init_glow_effect; + rval.num_inputs = num_inputs_glow; + rval.free = free_glow_effect; + rval.copy = copy_glow_effect; + rval.execute = do_glow_effect; + break; + case SEQ_TRANSFORM: + rval.init = init_transform_effect; + rval.num_inputs = num_inputs_transform; + rval.free = free_transform_effect; + rval.copy = copy_transform_effect; + rval.execute = do_transform_effect; + break; + case SEQ_SPEED: + rval.init = init_speed_effect; + rval.num_inputs = num_inputs_speed; + rval.load = load_speed_effect; + rval.free = free_speed_effect; + rval.copy = copy_speed_effect; + rval.execute = do_cross_effect; + rval.early_out = early_out_speed; + rval.store_icu_yrange = store_icu_yrange_speed; + break; + case SEQ_COLOR: + rval.init = init_solid_color; + rval.num_inputs = num_inputs_color; + rval.early_out = early_out_color; + rval.free = free_solid_color; + rval.copy = copy_solid_color; + rval.execute = do_solid_color; + break; + case SEQ_PLUGIN: + rval.init_plugin = init_plugin; + rval.num_inputs = num_inputs_plugin; + rval.load = load_plugin; + rval.free = free_plugin; + rval.copy = copy_plugin; + rval.execute = do_plugin_effect; + rval.early_out = do_plugin_early_out; + rval.get_default_fac = get_default_fac_fade; + break; + case SEQ_MULTICAM: + rval.num_inputs = num_inputs_multicam; + rval.early_out = early_out_multicam; + rval.execute = do_multicam; + break; + case SEQ_ADJUSTMENT: + rval.num_inputs = num_inputs_adjustment; + rval.early_out = early_out_adjustment; + rval.execute = do_adjustment; + break; } return rval; } -struct SeqEffectHandle get_sequence_effect(Sequence * seq) +struct SeqEffectHandle get_sequence_effect(Sequence *seq) { - struct SeqEffectHandle rval= {NULL}; + struct SeqEffectHandle rval = {NULL}; if (seq->type & SEQ_EFFECT) { rval = get_sequence_effect_impl(seq->type); @@ -3398,9 +3384,9 @@ struct SeqEffectHandle get_sequence_effect(Sequence * seq) return rval; } -struct SeqEffectHandle get_sequence_blend(Sequence * seq) +struct SeqEffectHandle get_sequence_blend(Sequence *seq) { - struct SeqEffectHandle rval= {NULL}; + struct SeqEffectHandle rval = {NULL}; if (seq->blend_mode != 0) { rval = get_sequence_effect_impl(seq->blend_mode); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index 395214b1609..41858eeecb4 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -216,13 +216,10 @@ void seq_free_sequence_recurse(Scene *scene, Sequence *seq) } -Editing *seq_give_editing(Scene *scene, int alloc) +Editing *BKE_sequencer_editing_get(Scene *scene, int alloc) { - if (scene->ed == NULL && alloc) { - Editing *ed; - - ed = scene->ed = MEM_callocN(sizeof(Editing), "addseq"); - ed->seqbasep = &ed->seqbase; + if (alloc) { + BKE_sequencer_editing_ensure(scene); } return scene->ed; } @@ -250,7 +247,19 @@ void seq_free_clipboard(void) seqbase_clipboard.first = seqbase_clipboard.last = NULL; } -void seq_free_editing(Scene *scene) +Editing *BKE_sequencer_editing_ensure(Scene *scene) +{ + if (scene->ed == NULL) { + Editing *ed; + + ed = scene->ed = MEM_callocN(sizeof(Editing), "addseq"); + ed->seqbasep = &ed->seqbase; + } + + return scene->ed; +} + +void BKE_sequencer_editing_free(Scene *scene) { Editing *ed = scene->ed; MetaStack *ms; @@ -271,6 +280,8 @@ void seq_free_editing(Scene *scene) } MEM_freeN(ed); + + scene->ed = NULL; } /* ********************************************************************** @@ -754,11 +765,11 @@ void reload_sequence_new_file(Scene *scene, Sequence *seq, int lock_range) calc_sequence(scene, seq); } -void sort_seq(Scene *scene) +void BKE_sequencer_sort(Scene *scene) { /* all strips together per kind, and in order of y location ("machine") */ ListBase seqbase, effbase; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *seqt; @@ -1075,7 +1086,7 @@ static int evaluate_seq_frame_gen(Sequence **seq_arr, ListBase *seqbase, int cfr int evaluate_seq_frame(Scene *scene, int cfra) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq_arr[MAXSEQ + 1]; if (ed == NULL) return 0; @@ -2099,7 +2110,7 @@ static ImBuf *seq_render_scene_strip( if (seq->scene_camera) camera = seq->scene_camera; else { - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); camera = scene->camera; } @@ -2127,7 +2138,7 @@ static ImBuf *seq_render_scene_strip( context.scene->r.seq_prev_type = 3 /* ==OB_SOLID */; /* opengl offscreen render */ - scene_update_for_newframe(context.bmain, scene, scene->lay); + BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); ibuf = sequencer_view3d_cb(scene, camera, context.rectx, context.recty, IB_rect, context.scene->r.seq_prev_type, TRUE, err_out); if (ibuf == NULL) { @@ -2182,7 +2193,7 @@ static ImBuf *seq_render_scene_strip( scene->r.cfra = oldcfra; if (frame != oldcfra) - scene_update_for_newframe(context.bmain, scene, scene->lay); + BKE_scene_update_for_newframe(context.bmain, scene, scene->lay); #ifdef DURIAN_CAMERA_SWITCH /* stooping to new low's in hackyness :( */ @@ -2530,7 +2541,7 @@ static ImBuf *seq_render_strip_stack( ImBuf *give_ibuf_seq(SeqRenderData context, float cfra, int chanshown) { - Editing *ed = seq_give_editing(context.scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(context.scene, FALSE); int count; ListBase *seqbasep; @@ -3007,7 +3018,7 @@ static int update_changed_seq_recurs(Scene *scene, Sequence *seq, Sequence *chan void update_changed_seq_and_deps(Scene *scene, Sequence *changed_seq, int len_change, int ibuf_change) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; if (ed == NULL) return; @@ -3254,7 +3265,7 @@ void seq_sound_init(Scene *scene, Sequence *seq) Sequence *seq_foreground_frame_get(Scene *scene, int frame) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *best_seq = NULL; int best_machine = -1; @@ -3660,26 +3671,26 @@ Sequence *get_seq_by_name(ListBase *seqbase, const char *name, int recursive) } -Sequence *seq_active_get(Scene *scene) +Sequence *BKE_sequencer_active_get(Scene *scene) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return NULL; return ed->act_seq; } -void seq_active_set(Scene *scene, Sequence *seq) +void BKE_sequencer_active_set(Scene *scene, Sequence *seq) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; ed->act_seq = seq; } -int seq_active_pair_get(Scene *scene, Sequence **seq_act, Sequence **seq_other) +int BKE_sequencer_active_get_pair(Scene *scene, Sequence **seq_act, Sequence **seq_other) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - *seq_act = seq_active_get(scene); + *seq_act = BKE_sequencer_active_get(scene); if (*seq_act == NULL) { return 0; @@ -3718,7 +3729,7 @@ void seq_load_apply(Scene *scene, Sequence *seq, SeqLoadInfo *seq_load) if (seq_load->flag & SEQ_LOAD_REPLACE_SEL) { seq_load->flag |= SELECT; - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); } if (seq_load->flag & SEQ_LOAD_SOUND_CACHE) { @@ -3785,7 +3796,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); /* only for sound */ - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); bSound *sound; Sequence *seq; /* generic strip vars */ @@ -3934,8 +3945,7 @@ static Sequence *seq_dupli(struct Scene *scene, struct Scene *scene_to, Sequence } if (seq->strip->color_balance) { - seqn->strip->color_balance - = MEM_dupallocN(seq->strip->color_balance); + seqn->strip->color_balance = MEM_dupallocN(seq->strip->color_balance); } if (seq->type == SEQ_META) { @@ -4016,7 +4026,7 @@ void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase, { Sequence *seq; Sequence *seqn = NULL; - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); for (seq = seqbase->first; seq; seq = seq->next) { seq->tmp = NULL; @@ -4034,7 +4044,7 @@ void seqbase_dupli_recursive(Scene *scene, Scene *scene_to, ListBase *nseqbase, if (dupe_flag & SEQ_DUPE_CONTEXT) { if (seq == last_seq) { - seq_active_set(scene, seqn); + BKE_sequencer_active_set(scene, seqn); } } } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index d6fea87397d..6c1c18c7cf8 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -57,7 +57,7 @@ #include "BKE_tessmesh.h" /* Util macros */ -#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n")) +#define OUT_OF_MEMORY() ((void)printf("Shrinkwrap: Out of memory\n")) /* Benchmark macros */ #if !defined(_WIN32) && 0 @@ -79,17 +79,17 @@ #else -#define BENCH(a) (a) +#define BENCH(a) (a) #endif -typedef void ( *Shrinkwrap_ForeachVertexCallback) (DerivedMesh *target, float *co, float *normal); +typedef void (*Shrinkwrap_ForeachVertexCallback)(DerivedMesh *target, float *co, float *normal); /* get derived mesh */ //TODO is anyfunction that does this? returning the derivedFinal without we caring if its in edit mode or not? DerivedMesh *object_get_derived_final(Object *ob) { - Mesh *me= ob->data; + Mesh *me = ob->data; BMEditMesh *em = me->edit_btmesh; if (em) { @@ -111,12 +111,12 @@ void space_transform_from_matrixs(SpaceTransform *data, float local[4][4], float void space_transform_apply(const SpaceTransform *data, float *co) { - mul_v3_m4v3(co, ((SpaceTransform*)data)->local2target, co); + mul_v3_m4v3(co, ((SpaceTransform *)data)->local2target, co); } void space_transform_invert(const SpaceTransform *data, float *co) { - mul_v3_m4v3(co, ((SpaceTransform*)data)->target2local, co); + mul_v3_m4v3(co, ((SpaceTransform *)data)->target2local, co); } static void space_transform_apply_normal(const SpaceTransform *data, float *no) @@ -127,7 +127,7 @@ static void space_transform_apply_normal(const SpaceTransform *data, float *no) static void space_transform_invert_normal(const SpaceTransform *data, float *no) { - mul_mat3_m4_v3(((SpaceTransform*)data)->target2local, no); + mul_mat3_m4_v3(((SpaceTransform *)data)->target2local, no); normalize_v3(no); // TODO: could we just determine de scale value from the matrix? } @@ -142,7 +142,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) int i; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; - BVHTreeNearest nearest = NULL_BVHTreeNearest; + BVHTreeNearest nearest = NULL_BVHTreeNearest; BENCH(bvhtree_from_mesh_verts(&treeData, calc->target, 0.0, 2, 6)); @@ -157,7 +157,7 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(treeData,calc) schedule(static) #endif - for (i = 0; inumVerts; ++i) { + for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -190,13 +190,13 @@ static void shrinkwrap_calc_nearest_vertex(ShrinkwrapCalcData *calc) if (nearest.index != -1) { //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position float dist = sasqrt(nearest.dist); - if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist)/dist; + if (dist > FLT_EPSILON) weight *= (dist - calc->keepDist) / dist; //Convert the coordinates back to mesh coordinates copy_v3_v3(tmp_co, nearest.co); space_transform_invert(&calc->local2target, tmp_co); - interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation } } @@ -230,7 +230,7 @@ int normal_projection_project_vertex(char options, const float *vert, const floa space_transform_apply_normal(transf, tmp_no); no = tmp_no; - hit_tmp.dist *= mat4_to_scale(((SpaceTransform*)transf)->local2target); + hit_tmp.dist *= mat4_to_scale(((SpaceTransform *)transf)->local2target); } else { co = vert; @@ -247,12 +247,12 @@ int normal_projection_project_vertex(char options, const float *vert, const floa space_transform_invert_normal(transf, hit_tmp.no); } - if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE|MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) { + if (options & (MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE | MOD_SHRINKWRAP_CULL_TARGET_BACKFACE)) { /* apply backface */ - const float dot= dot_v3v3(dir, hit_tmp.no); - if ( ((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || - ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f) - ) { + const float dot = dot_v3v3(dir, hit_tmp.no); + if (((options & MOD_SHRINKWRAP_CULL_TARGET_FRONTFACE) && dot <= 0.0f) || + ((options & MOD_SHRINKWRAP_CULL_TARGET_BACKFACE) && dot >= 0.0f)) + { return FALSE; /* Ignore hit */ } } @@ -275,16 +275,16 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) int i; //Options about projection direction - const char use_normal = calc->smd->shrinkOpts; - float proj_axis[3] = {0.0f, 0.0f, 0.0f}; + const char use_normal = calc->smd->shrinkOpts; + float proj_axis[3] = {0.0f, 0.0f, 0.0f}; //Raycast and tree stuff BVHTreeRayHit hit; - BVHTreeFromMesh treeData= NULL_BVHTreeFromMesh; + BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; //auxiliary target - DerivedMesh *auxMesh = NULL; - BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; + DerivedMesh *auxMesh = NULL; + BVHTreeFromMesh auxData = NULL_BVHTreeFromMesh; SpaceTransform local2aux; //If the user doesn't allows to project in any direction of projection axis @@ -326,7 +326,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for private(i,hit) schedule(static) #endif - for (i = 0; inumVerts; ++i) { + for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3], tmp_no[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -399,10 +399,10 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) int i; BVHTreeFromMesh treeData = NULL_BVHTreeFromMesh; - BVHTreeNearest nearest = NULL_BVHTreeNearest; + BVHTreeNearest nearest = NULL_BVHTreeNearest; //Create a bvh-tree of the given target - BENCH(bvhtree_from_mesh_faces( &treeData, calc->target, 0.0, 2, 6)); + BENCH(bvhtree_from_mesh_faces(&treeData, calc->target, 0.0, 2, 6)); if (treeData.tree == NULL) { OUT_OF_MEMORY(); return; @@ -417,7 +417,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) #ifndef __APPLE__ #pragma omp parallel for default(none) private(i) firstprivate(nearest) shared(calc,treeData) schedule(static) #endif - for (i = 0; inumVerts; ++i) { + for (i = 0; i < calc->numVerts; ++i) { float *co = calc->vertexCos[i]; float tmp_co[3]; float weight = defvert_array_find_weight_safe(calc->dvert, i, calc->vgroup); @@ -452,16 +452,16 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) } else { //Adjusting the vertex weight, so that after interpolating it keeps a certain distance from the nearest position - float dist = sasqrt( nearest.dist ); + float dist = sasqrt(nearest.dist); if (dist > FLT_EPSILON) - interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist)/dist); //linear interpolation + interp_v3_v3v3(tmp_co, tmp_co, nearest.co, (dist - calc->keepDist) / dist); //linear interpolation else copy_v3_v3(tmp_co, nearest.co); } //Convert the coordinates back to mesh coordinates space_transform_invert(&calc->local2target, tmp_co); - interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation + interp_v3_v3v3(co, co, tmp_co, weight); //linear interpolation } } @@ -472,7 +472,7 @@ static void shrinkwrap_calc_nearest_surface_point(ShrinkwrapCalcData *calc) void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { - DerivedMesh *ss_mesh = NULL; + DerivedMesh *ss_mesh = NULL; ShrinkwrapCalcData calc = NULL_ShrinkwrapCalcData; //remove loop dependencies on derived meshs (TODO should this be done elsewhere?) @@ -492,7 +492,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM calc.dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); } else if (calc.ob->type == OB_LATTICE) { - calc.dvert = lattice_get_deform_verts(calc.ob); + calc.dvert = BKE_lattice_deform_verts_get(calc.ob); } @@ -519,11 +519,11 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM //Using vertexs positions/normals as if a subsurface was applied if (smd->subsurfLevels) { - SubsurfModifierData ssmd= {{NULL}}; - ssmd.subdivType = ME_CC_SUBSURF; //catmull clark - ssmd.levels = smd->subsurfLevels; //levels + SubsurfModifierData ssmd = {{NULL}}; + ssmd.subdivType = ME_CC_SUBSURF; //catmull clark + ssmd.levels = smd->subsurfLevels; //levels - ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT)); + ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0); if (ss_mesh) { calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT); @@ -545,15 +545,15 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM switch (smd->shrinkType) { case MOD_SHRINKWRAP_NEAREST_SURFACE: BENCH(shrinkwrap_calc_nearest_surface_point(&calc)); - break; + break; case MOD_SHRINKWRAP_PROJECT: BENCH(shrinkwrap_calc_normal_projection(&calc)); - break; + break; case MOD_SHRINKWRAP_NEAREST_VERTEX: BENCH(shrinkwrap_calc_nearest_vertex(&calc)); - break; + break; } } diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c index f98b6366e97..4b814a5b22b 100644 --- a/source/blender/blenkernel/intern/smoke.c +++ b/source/blender/blenkernel/intern/smoke.c @@ -279,29 +279,6 @@ static int smokeModifier_init (SmokeModifierData *smd, Object *ob, Scene *scene, smd->time = scene->r.cfra; - if (smd->flow->psys && smd->flow->psys->part && !(smd->flow->flags & MOD_SMOKE_FLOW_INIT)) - { - // update particle lifetime to be one frame - smd->flow->psys->part->lifetime = 1; // scene->r.efra + 1; - - // use "unborn" flag as standard setting - smd->flow->psys->part->flag |= PART_UNBORN; - - smd->flow->flags |= MOD_SMOKE_FLOW_INIT; - } - -/* - if(!smd->flow->bvh) - { - // smd->flow->bvh = MEM_callocN(sizeof(BVHTreeFromMesh), "smoke_bvhfromfaces"); - // bvhtree_from_mesh_faces(smd->flow->bvh, dm, 0.0, 2, 6); - - // copy obmat - // copy_m4_m4(smd->flow->mat, ob->obmat); - // copy_m4_m4(smd->flow->mat_old, ob->obmat); - } -*/ - return 1; } else if((smd->type & MOD_SMOKE_TYPE_COLL)) diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index 690b6c83870..ee70d4228de 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -3514,11 +3514,11 @@ static void lattice_to_softbody(Scene *scene, Object *ob) totvert= lt->pntsu*lt->pntsv*lt->pntsw; if (ob->softflag & OB_SB_EDGES) { - totspring = ((lt->pntsu -1) * lt->pntsv - + (lt->pntsv -1) * lt->pntsu) * lt->pntsw - +lt->pntsu*lt->pntsv*(lt->pntsw -1); + totspring = ((lt->pntsu - 1) * lt->pntsv + + (lt->pntsv - 1) * lt->pntsu) * lt->pntsw + + lt->pntsu*lt->pntsv * (lt->pntsw - 1); if (ob->softflag & OB_SB_QUADS) { - totspring += 4*(lt->pntsu -1) * (lt->pntsv -1) * (lt->pntsw-1); + totspring += 4 * (lt->pntsu - 1) * (lt->pntsv -1) * (lt->pntsw - 1); } } diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index 28ce95ea8d1..52007f1f43e 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -63,16 +63,16 @@ // evil quiet NaN definition static const int NAN_INT = 0x7FC00000; -#define NAN_FLT *((float*)(&NAN_INT)) +#define NAN_FLT *((float *)(&NAN_INT)) #ifdef WITH_AUDASPACE // evil global ;-) static int sound_cfra; #endif -struct bSound* sound_new_file(struct Main *bmain, const char *filename) +bSound *sound_new_file(struct Main *bmain, const char *filename) { - bSound* sound = NULL; + bSound *sound = NULL; char str[FILE_MAX]; char *path; @@ -86,24 +86,24 @@ struct bSound* sound_new_file(struct Main *bmain, const char *filename) BLI_path_abs(str, path); len = strlen(filename); - while (len > 0 && filename[len-1] != '/' && filename[len-1] != '\\') + while (len > 0 && filename[len - 1] != '/' && filename[len - 1] != '\\') len--; - sound = alloc_libblock(&bmain->sound, ID_SO, filename+len); + sound = BKE_libblock_alloc(&bmain->sound, ID_SO, filename + len); BLI_strncpy(sound->name, filename, FILE_MAX); // XXX unused currently sound->type = SOUND_TYPE_FILE; sound_load(bmain, sound); if (!sound->playback_handle) { - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); sound = NULL; } return sound; } -void sound_free(struct bSound* sound) +void BKE_sound_free(bSound *sound) { if (sound->packedfile) { freePackedFile(sound->packedfile); @@ -131,10 +131,10 @@ void sound_free(struct bSound* sound) static int force_device = -1; #ifdef WITH_JACK -static void sound_sync_callback(void* data, int mode, float time) +static void sound_sync_callback(void *data, int mode, float time) { - struct Main* bmain = (struct Main*)data; - struct Scene* scene; + struct Main *bmain = (struct Main *)data; + struct Scene *scene; scene = bmain->scene.first; while (scene) { @@ -223,15 +223,15 @@ void sound_exit(void) // XXX unused currently #if 0 -struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) +bSound *sound_new_buffer(struct Main *bmain, bSound *source) { - bSound* sound = NULL; + bSound *sound = NULL; - char name[MAX_ID_NAME+5]; + char name[MAX_ID_NAME + 5]; strcpy(name, "buf_"); strcpy(name + 4, source->id.name); - sound = alloc_libblock(&bmain->sound, ID_SO, name); + sound = BKE_libblock_alloc(&bmain->sound, ID_SO, name); sound->child_sound = source; sound->type = SOUND_TYPE_BUFFER; @@ -240,22 +240,22 @@ struct bSound* sound_new_buffer(struct Main *bmain, struct bSound *source) if (!sound->playback_handle) { - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); sound = NULL; } return sound; } -struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, float start, float end) +bSound *sound_new_limiter(struct Main *bmain, bSound *source, float start, float end) { - bSound* sound = NULL; + bSound *sound = NULL; - char name[MAX_ID_NAME+5]; + char name[MAX_ID_NAME + 5]; strcpy(name, "lim_"); strcpy(name + 4, source->id.name); - sound = alloc_libblock(&bmain->sound, ID_SO, name); + sound = BKE_libblock_alloc(&bmain->sound, ID_SO, name); sound->child_sound = source; sound->start = start; @@ -266,7 +266,7 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa if (!sound->playback_handle) { - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); sound = NULL; } @@ -274,16 +274,16 @@ struct bSound* sound_new_limiter(struct Main *bmain, struct bSound *source, floa } #endif -void sound_delete(struct Main *bmain, struct bSound* sound) +void sound_delete(struct Main *bmain, bSound *sound) { if (sound) { - sound_free(sound); + BKE_sound_free(sound); - free_libblock(&bmain->sound, sound); + BKE_libblock_free(&bmain->sound, sound); } } -void sound_cache(struct bSound* sound) +void sound_cache(bSound *sound) { sound->flags |= SOUND_FLAGS_CACHING; if (sound->cache) @@ -296,13 +296,13 @@ void sound_cache(struct bSound* sound) sound->playback_handle = sound->handle; } -void sound_cache_notifying(struct Main* main, struct bSound* sound) +void sound_cache_notifying(struct Main *main, bSound *sound) { sound_cache(sound); sound_update_sequencer(main, sound); } -void sound_delete_cache(struct bSound* sound) +void sound_delete_cache(bSound *sound) { sound->flags &= ~SOUND_FLAGS_CACHING; if (sound->cache) { @@ -312,7 +312,7 @@ void sound_delete_cache(struct bSound* sound) } } -void sound_load(struct Main *bmain, struct bSound* sound) +void sound_load(struct Main *bmain, bSound *sound) { if (sound) { if (sound->cache) { @@ -332,13 +332,13 @@ void sound_load(struct Main *bmain, struct bSound* sound) #if 0 switch (sound->type) { - case SOUND_TYPE_FILE: + case SOUND_TYPE_FILE: #endif { char fullpath[FILE_MAX]; /* load sound */ - PackedFile* pf = sound->packedfile; + PackedFile *pf = sound->packedfile; /* don't modify soundact->sound->name, only change a copy */ BLI_strncpy(fullpath, sound->name, sizeof(fullpath)); @@ -346,27 +346,27 @@ void sound_load(struct Main *bmain, struct bSound* sound) /* but we need a packed file then */ if (pf) - sound->handle = AUD_loadBuffer((unsigned char*) pf->data, pf->size); + sound->handle = AUD_loadBuffer((unsigned char *) pf->data, pf->size); /* or else load it from disk */ else sound->handle = AUD_load(fullpath); } // XXX unused currently #if 0 - break; - } - case SOUND_TYPE_BUFFER: - if (sound->child_sound && sound->child_sound->handle) - sound->handle = AUD_bufferSound(sound->child_sound->handle); - break; - case SOUND_TYPE_LIMITER: - if (sound->child_sound && sound->child_sound->handle) - sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end); - break; - } + break; + } + case SOUND_TYPE_BUFFER: + if (sound->child_sound && sound->child_sound->handle) + sound->handle = AUD_bufferSound(sound->child_sound->handle); + break; + case SOUND_TYPE_LIMITER: + if (sound->child_sound && sound->child_sound->handle) + sound->handle = AUD_limitSound(sound->child_sound, sound->start, sound->end); + break; +} #endif if (sound->flags & SOUND_FLAGS_MONO) { - void* handle = AUD_monoSound(sound->handle); + void *handle = AUD_monoSound(sound->handle); AUD_unload(sound->handle); sound->handle = handle; } @@ -384,16 +384,20 @@ void sound_load(struct Main *bmain, struct bSound* sound) } } -AUD_Device* sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume) +AUD_Device *sound_mixdown(struct Scene *scene, AUD_DeviceSpecs specs, int start, float volume) { return AUD_openMixdownDevice(specs, scene->sound_scene, volume, start / FPS); } void sound_create_scene(struct Scene *scene) { + /* should be done in version patch, but this gets called before */ + if (scene->r.frs_sec_base == 0) + scene->r.frs_sec_base = 1; + scene->sound_scene = AUD_createSequencer(FPS, scene->audio.flag & AUDIO_MUTE); AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound, - scene->audio.doppler_factor, scene->audio.distance_model); + scene->audio.doppler_factor, scene->audio.distance_model); scene->sound_scene_handle = NULL; scene->sound_scrub_handle = NULL; scene->speaker_handles = NULL; @@ -426,26 +430,26 @@ void sound_update_fps(struct Scene *scene) void sound_update_scene_listener(struct Scene *scene) { AUD_updateSequencerData(scene->sound_scene, scene->audio.speed_of_sound, - scene->audio.doppler_factor, scene->audio.distance_model); + scene->audio.doppler_factor, scene->audio.distance_model); } -void* sound_scene_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) +void *sound_scene_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip) { if (scene != sequence->scene) return AUD_addSequence(scene->sound_scene, sequence->scene->sound_scene, startframe / FPS, endframe / FPS, frameskip / FPS); return NULL; } -void* sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence) +void *sound_scene_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence) { return sound_scene_add_scene_sound(scene, sequence, sequence->startdisp, sequence->enddisp, sequence->startofs + sequence->anim_startofs); } -void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int startframe, int endframe, int frameskip) +void *sound_add_scene_sound(struct Scene *scene, struct Sequence *sequence, int startframe, int endframe, int frameskip) { - void* handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS); + void *handle = AUD_addSequence(scene->sound_scene, sequence->sound->playback_handle, startframe / FPS, endframe / FPS, frameskip / FPS); AUD_muteSequence(handle, (sequence->flag & SEQ_MUTE) != 0); AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, CFRA, &sequence->volume, 0); AUD_setSequenceAnimData(handle, AUD_AP_PITCH, CFRA, &sequence->pitch, 0); @@ -453,29 +457,29 @@ void* sound_add_scene_sound(struct Scene *scene, struct Sequence* sequence, int return handle; } -void* sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence) +void *sound_add_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence) { return sound_add_scene_sound(scene, sequence, sequence->startdisp, sequence->enddisp, sequence->startofs + sequence->anim_startofs); } -void sound_remove_scene_sound(struct Scene *scene, void* handle) +void sound_remove_scene_sound(struct Scene *scene, void *handle) { AUD_removeSequence(scene->sound_scene, handle); } -void sound_mute_scene_sound(void* handle, char mute) +void sound_mute_scene_sound(void *handle, char mute) { AUD_muteSequence(handle, mute); } -void sound_move_scene_sound(struct Scene *scene, void* handle, int startframe, int endframe, int frameskip) +void sound_move_scene_sound(struct Scene *scene, void *handle, int startframe, int endframe, int frameskip) { AUD_moveSequence(handle, startframe / FPS, endframe / FPS, frameskip / FPS); } -void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* sequence) +void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence *sequence) { if (sequence->scene_sound) { sound_move_scene_sound(scene, sequence->scene_sound, @@ -484,7 +488,7 @@ void sound_move_scene_sound_defaults(struct Scene *scene, struct Sequence* seque } } -void sound_update_scene_sound(void* handle, struct bSound* sound) +void sound_update_scene_sound(void *handle, bSound *sound) { AUD_updateSequenceSound(handle, sound->playback_handle); } @@ -499,24 +503,24 @@ void sound_set_scene_volume(struct Scene *scene, float volume) AUD_setSequencerAnimData(scene->sound_scene, AUD_AP_VOLUME, CFRA, &volume, (scene->audio.flag & AUDIO_VOLUME_ANIMATED) != 0); } -void sound_set_scene_sound_volume(void* handle, float volume, char animated) +void sound_set_scene_sound_volume(void *handle, float volume, char animated) { AUD_setSequenceAnimData(handle, AUD_AP_VOLUME, sound_cfra, &volume, animated); } -void sound_set_scene_sound_pitch(void* handle, float pitch, char animated) +void sound_set_scene_sound_pitch(void *handle, float pitch, char animated) { AUD_setSequenceAnimData(handle, AUD_AP_PITCH, sound_cfra, &pitch, animated); } -void sound_set_scene_sound_pan(void* handle, float pan, char animated) +void sound_set_scene_sound_pan(void *handle, float pan, char animated) { AUD_setSequenceAnimData(handle, AUD_AP_PANNING, sound_cfra, &pan, animated); } -void sound_update_sequencer(struct Main* main, struct bSound* sound) +void sound_update_sequencer(struct Main *main, bSound *sound) { - struct Scene* scene; + struct Scene *scene; for (scene = main->scene.first; scene; scene = scene->id.next) { seq_update_sound(scene, sound); @@ -592,7 +596,7 @@ void sound_seek_scene(struct Main *bmain, struct Scene *scene) } animation_playing = 0; - for (screen=bmain->screen.first; screen; screen=screen->id.next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { if (screen->animtimer) { animation_playing = 1; } @@ -645,24 +649,24 @@ int sound_scene_playing(struct Scene *scene) return -1; } -void sound_free_waveform(struct bSound* sound) +void sound_free_waveform(bSound *sound) { if (sound->waveform) { - MEM_freeN(((SoundWaveform*)sound->waveform)->data); + MEM_freeN(((SoundWaveform *)sound->waveform)->data); MEM_freeN(sound->waveform); } sound->waveform = NULL; } -void sound_read_waveform(struct bSound* sound) +void sound_read_waveform(bSound *sound) { AUD_SoundInfo info; info = AUD_getInfo(sound->playback_handle); if (info.length > 0) { - SoundWaveform* waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); + SoundWaveform *waveform = MEM_mallocN(sizeof(SoundWaveform), "SoundWaveform"); int length = info.length * SOUND_WAVE_SAMPLES_PER_SECOND; waveform->data = MEM_mallocN(length * sizeof(float) * 3, "SoundWaveform.samples"); @@ -673,17 +677,17 @@ void sound_read_waveform(struct bSound* sound) } } -void sound_update_scene(struct Scene* scene) +void sound_update_scene(struct Scene *scene) { - Object* ob; - Base* base; - NlaTrack* track; - NlaStrip* strip; - Speaker* speaker; - Scene* sce_it; + Object *ob; + Base *base; + NlaTrack *track; + NlaStrip *strip; + Speaker *speaker; + Scene *sce_it; - void* new_set = AUD_createSet(); - void* handle; + void *new_set = AUD_createSet(); + void *handle; float quat[4]; for (SETLOOPER(scene, sce_it, base)) { @@ -693,7 +697,7 @@ void sound_update_scene(struct Scene* scene) for (track = ob->adt->nla_tracks.first; track; track = track->next) { for (strip = track->strips.first; strip; strip = strip->next) { if (strip->type == NLASTRIP_TYPE_SOUND) { - speaker = (Speaker*)ob->data; + speaker = (Speaker *)ob->data; if (AUD_removeSet(scene->speaker_handles, strip->speaker_handle)) { if (speaker->sound) @@ -713,10 +717,10 @@ void sound_update_scene(struct Scene* scene) if (strip->speaker_handle) { AUD_addSet(new_set, strip->speaker_handle); AUD_updateSequenceData(strip->speaker_handle, speaker->volume_max, - speaker->volume_min, speaker->distance_max, - speaker->distance_reference, speaker->attenuation, - speaker->cone_angle_outer, speaker->cone_angle_inner, - speaker->cone_volume_outer); + speaker->volume_min, speaker->distance_max, + speaker->distance_reference, speaker->attenuation, + speaker->cone_angle_outer, speaker->cone_angle_inner, + speaker->cone_volume_outer); mat4_to_quat(quat, ob->obmat); AUD_setSequenceAnimData(strip->speaker_handle, AUD_AP_LOCATION, CFRA, ob->obmat[3], 1); @@ -747,9 +751,17 @@ void sound_update_scene(struct Scene* scene) scene->speaker_handles = new_set; } -void* sound_get_factory(void* sound) +void *sound_get_factory(void *sound) { - return ((struct bSound*) sound)->playback_handle; + return ((bSound *) sound)->playback_handle; +} + +/* stupid wrapper because AUD_C-API.h includes Python.h which makesrna doesn't like */ +float sound_get_length(bSound *sound) +{ + AUD_SoundInfo info = AUD_getInfo(sound->playback_handle); + + return info.length; } #else // WITH_AUDASPACE @@ -793,5 +805,5 @@ void sound_set_scene_sound_volume(void* handle, float volume, char animated) { ( void sound_set_scene_sound_pan(void* handle, float pan, char animated) { (void)handle; (void)pan; (void)animated; } void sound_set_scene_volume(struct Scene *scene, float volume) { (void)scene; (void)volume; } void sound_set_scene_sound_pitch(void* handle, float pitch, char animated) { (void)handle; (void)pitch; (void)animated; } - +float sound_get_length(struct bSound* sound) { (void)sound; return 0; } #endif // WITH_AUDASPACE diff --git a/source/blender/blenkernel/intern/speaker.c b/source/blender/blenkernel/intern/speaker.c index 5466630f621..09440591826 100644 --- a/source/blender/blenkernel/intern/speaker.c +++ b/source/blender/blenkernel/intern/speaker.c @@ -43,11 +43,11 @@ #include "BKE_main.h" #include "BKE_speaker.h" -void *add_speaker(const char *name) +void *BKE_speaker_add(const char *name) { Speaker *spk; - spk= alloc_libblock(&G.main->speaker, ID_SPK, name); + spk = BKE_libblock_alloc(&G.main->speaker, ID_SPK, name); spk->attenuation = 1.0f; spk->cone_angle_inner = 360.0f; @@ -65,69 +65,69 @@ void *add_speaker(const char *name) return spk; } -Speaker *copy_speaker(Speaker *spk) +Speaker *BKE_speaker_copy(Speaker *spk) { Speaker *spkn; - spkn= copy_libblock(&spk->id); + spkn = BKE_libblock_copy(&spk->id); if (spkn->sound) spkn->sound->id.us++; return spkn; } -void make_local_speaker(Speaker *spk) +void BKE_speaker_make_local(Speaker *spk) { - Main *bmain= G.main; + Main *bmain = G.main; Object *ob; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (spk->id.lib==NULL) return; - if (spk->id.us==1) { + if (spk->id.lib == NULL) return; + if (spk->id.us == 1) { id_clear_lib_data(bmain, &spk->id); return; } - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==spk) { - if (ob->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (ob->data == spk) { + if (ob->id.lib) is_lib = TRUE; + else is_local = TRUE; } - ob= ob->id.next; + ob = ob->id.next; } if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &spk->id); } else if (is_local && is_lib) { - Speaker *spk_new= copy_speaker(spk); - spk_new->id.us= 0; + Speaker *spk_new = BKE_speaker_copy(spk); + spk_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, spk->id.lib, &spk_new->id); - ob= bmain->object.first; + ob = bmain->object.first; while (ob) { - if (ob->data==spk) { + if (ob->data == spk) { - if (ob->id.lib==NULL) { - ob->data= spk_new; + if (ob->id.lib == NULL) { + ob->data = spk_new; spk_new->id.us++; spk->id.us--; } } - ob= ob->id.next; + ob = ob->id.next; } } } -void free_speaker(Speaker *spk) +void BKE_speaker_free(Speaker *spk) { if (spk->sound) spk->sound->id.us--; diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index c69458f236a..2c05029e82e 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -52,6 +52,7 @@ #include "BLI_memarena.h" #include "BLI_pbvh.h" +#include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_global.h" #include "BKE_mesh.h" @@ -110,15 +111,19 @@ static void arena_release(CCGAllocatorHDL a) typedef enum { CCG_USE_AGING = 1, CCG_USE_ARENA = 2, - CCG_CALC_NORMALS = 4 + CCG_CALC_NORMALS = 4, + /* add an extra four bytes for a mask layer */ + CCG_ALLOC_MASK = 8 } CCGFlags; -static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags flags) +static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, + int numLayers, CCGFlags flags) { CCGMeshIFC ifc; CCGSubSurf *ccgSS; int useAging = !!(flags & CCG_USE_AGING); int useArena = flags & CCG_USE_ARENA; + int normalOffset = 0; /* subdivLevels==0 is not allowed */ subdivLevels = MAX2(subdivLevels, 1); @@ -144,7 +149,13 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl else { ifc.vertUserSize = ifc.edgeUserSize = ifc.faceUserSize = 8; } - ifc.vertDataSize = sizeof(float) * (flags & CCG_CALC_NORMALS ? 6 : 3); + ifc.numLayers = numLayers; + ifc.vertDataSize = sizeof(float) * numLayers; + normalOffset += sizeof(float) * numLayers; + if (flags & CCG_CALC_NORMALS) + ifc.vertDataSize += sizeof(float) * 3; + if (flags & CCG_ALLOC_MASK) + ifc.vertDataSize += sizeof(float); if (useArena) { CCGAllocatorIFC allocatorIFC; @@ -165,8 +176,14 @@ static CCGSubSurf *_getSubSurf(CCGSubSurf *prevSS, int subdivLevels, CCGFlags fl ccgSubSurf_setUseAgeCounts(ccgSS, 1, 8, 8, 8); } + if (flags & CCG_ALLOC_MASK) { + normalOffset += sizeof(float); + /* mask is allocated after regular layers */ + ccgSubSurf_setAllocMask(ccgSS, 1, sizeof(float) * numLayers); + } + if (flags & CCG_CALC_NORMALS) - ccgSubSurf_setCalcVertexNormals(ccgSS, 1, offsetof(DMGridData, no)); + ccgSubSurf_setCalcVertexNormals(ccgSS, 1, normalOffset); else ccgSubSurf_setCalcVertexNormals(ccgSS, 0, 0); @@ -244,7 +261,7 @@ static void get_face_uv_map_vert(UvVertMap *vmap, struct MPoly *mpoly, struct ML int j, nverts = mpoly[fi].totloop; for (j = 0; j < nverts; j++) { - for (nv = v = get_uv_map_vert(vmap, ml[j].v); v; v = v->next) { + for (nv = v = BKE_mesh_uv_vert_map_get_vert(vmap, ml[j].v); v; v = v->next) { if (v->separate) nv = v; if (v->f == fi) @@ -273,7 +290,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, float uv[3] = {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ limit[0] = limit[1] = STD_UV_CONNECT_LIMIT; - vmap = make_uv_vert_map(mpoly, mloop, mloopuv, totface, totvert, 0, limit); + vmap = BKE_mesh_uv_vert_map_make(mpoly, mloop, mloopuv, totface, totvert, 0, limit); if (!vmap) return 0; @@ -281,16 +298,16 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, /* create vertices */ for (i = 0; i < totvert; i++) { - if (!get_uv_map_vert(vmap, i)) + if (!BKE_mesh_uv_vert_map_get_vert(vmap, i)) continue; - for (v = get_uv_map_vert(vmap, i)->next; v; v = v->next) + for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i)->next; v; v = v->next) if (v->separate) break; seam = (v != NULL) || ((mvert + i)->flag & ME_VERT_MERGED); - for (v = get_uv_map_vert(vmap, i); v; v = v->next) { + for (v = BKE_mesh_uv_vert_map_get_vert(vmap, i); v; v = v->next) { if (v->separate) { CCGVert *ssv; int loopid = mpoly[v->f].loopstart + v->tfindex; @@ -358,7 +375,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, BLI_array_free(fverts); - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); ccgSubSurf_processSync(ss); return 1; @@ -382,7 +399,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, return; /* create a CCGSubSurf from uv's */ - uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), CCG_USE_ARENA); + uvss = _getSubSurf(NULL, ccgSubSurf_getSubdivisionLevels(ss), 2, CCG_USE_ARENA); if (!ss_sync_from_uv(uvss, ss, dm, dmloopuv)) { ccgSubSurf_free(uvss); @@ -414,7 +431,7 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, int numVerts = ccgSubSurf_getFaceNumVerts(f); for (S = 0; S < numVerts; S++) { - float (*faceGridData)[3] = ccgSubSurf_getFaceGridDataArray(uvss, f, S); + float (*faceGridData)[2] = ccgSubSurf_getFaceGridDataArray(uvss, f, S); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { @@ -633,6 +650,16 @@ static int ccgDM_getFaceMapIndex(CCGSubSurf *ss, CCGFace *f) return ((int *) ccgSubSurf_getFaceUserData(ss, f))[1]; } +static void minmax_v3_v3v3(const float vec[3], float min[3], float max[3]) +{ + if (min[0] > vec[0]) min[0] = vec[0]; + if (min[1] > vec[1]) min[1] = vec[1]; + if (min[2] > vec[2]) min[2] = vec[2]; + if (max[0] < vec[0]) max[0] = vec[0]; + if (max[1] < vec[1]) max[1] = vec[1]; + if (max[2] < vec[2]) max[2] = vec[2]; +} + static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; @@ -640,9 +667,12 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) CCGVertIterator *vi = ccgSubSurf_getVertIterator(ss); CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); + CCGKey key; int i, edgeSize = ccgSubSurf_getEdgeSize(ss); int gridSize = ccgSubSurf_getGridSize(ss); + CCG_key_top_level(&key, ss); + if (!ccgSubSurf_getNumVerts(ss)) min_r[0] = min_r[1] = min_r[2] = max_r[0] = max_r[1] = max_r[2] = 0.0; @@ -650,15 +680,15 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) CCGVert *v = ccgVertIterator_getCurrent(vi); float *co = ccgSubSurf_getVertData(ss, v); - DO_MINMAX(co, min_r, max_r); + minmax_v3_v3v3(co, min_r, max_r); } for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { CCGEdge *e = ccgEdgeIterator_getCurrent(ei); - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); for (i = 0; i < edgeSize; i++) - DO_MINMAX(edgeData[i].co, min_r, max_r); + minmax_v3_v3v3(CCG_elem_offset_co(&key, edgeData, i), min_r, max_r); } for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { @@ -666,11 +696,11 @@ static void ccgDM_getMinMax(DerivedMesh *dm, float min_r[3], float max_r[3]) int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); for (y = 0; y < gridSize; y++) for (x = 0; x < gridSize; x++) - DO_MINMAX(faceGridData[y * gridSize + x].co, min_r, max_r); + minmax_v3_v3v3(CCG_grid_elem_co(&key, faceGridData, x, y), min_r, max_r); } } @@ -712,9 +742,11 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; - DMGridData *vd; + CCGElem *vd; + CCGKey key; int i; + CCG_key_top_level(&key, ss); memset(mv, 0, sizeof(*mv)); if ((vertNum < ccgdm->edgeMap[0].startVert) && (ccgSubSurf_getNumFaces(ss) > 0)) { @@ -730,8 +762,9 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) int gridInternalEnd; i = 0; - while (i < lastface && vertNum >= ccgdm->faceMap[i + 1].startVert) - ++i; + while (i < lastface && vertNum >= ccgdm->faceMap[i + 1].startVert) { + i++; + } f = ccgdm->faceMap[i].face; numVerts = ccgSubSurf_getFaceNumVerts(f); @@ -745,16 +778,16 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) offset = vertNum - ccgdm->faceMap[i].startVert; if (offset < 1) { vd = ccgSubSurf_getFaceCenterData(f); - copy_v3_v3(mv->co, vd->co); - normal_float_to_short_v3(mv->no, vd->no); + copy_v3_v3(mv->co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mv->no, CCG_elem_no(&key, vd)); } else if (offset < gridSideEnd) { offset -= 1; grid = offset / gridSideVerts; x = offset % gridSideVerts + 1; vd = ccgSubSurf_getFaceGridEdgeData(ss, f, grid, x); - copy_v3_v3(mv->co, vd->co); - normal_float_to_short_v3(mv->no, vd->no); + copy_v3_v3(mv->co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mv->no, CCG_elem_no(&key, vd)); } else if (offset < gridInternalEnd) { offset -= gridSideEnd; @@ -763,8 +796,8 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) y = offset / gridSideVerts + 1; x = offset % gridSideVerts + 1; vd = ccgSubSurf_getFaceGridData(ss, f, grid, x, y); - copy_v3_v3(mv->co, vd->co); - normal_float_to_short_v3(mv->no, vd->no); + copy_v3_v3(mv->co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mv->no, CCG_elem_no(&key, vd)); } } else if ((vertNum < ccgdm->vertMap[0].startVert) && (ccgSubSurf_getNumEdges(ss) > 0)) { @@ -774,15 +807,16 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) int x; i = 0; - while (i < lastedge && vertNum >= ccgdm->edgeMap[i + 1].startVert) - ++i; + while (i < lastedge && vertNum >= ccgdm->edgeMap[i + 1].startVert) { + i++; + } e = ccgdm->edgeMap[i].edge; x = vertNum - ccgdm->edgeMap[i].startVert + 1; vd = ccgSubSurf_getEdgeData(ss, e, x); - copy_v3_v3(mv->co, vd->co); - normal_float_to_short_v3(mv->no, vd->no); + copy_v3_v3(mv->co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mv->no, CCG_elem_no(&key, vd)); } else { /* this vert comes from vert data */ @@ -791,8 +825,8 @@ static void ccgDM_getFinalVert(DerivedMesh *dm, int vertNum, MVert *mv) v = ccgdm->vertMap[i].vert; vd = ccgSubSurf_getVertData(ss, v); - copy_v3_v3(mv->co, vd->co); - normal_float_to_short_v3(mv->no, vd->no); + copy_v3_v3(mv->co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mv->no, CCG_elem_no(&key, vd)); } } @@ -869,8 +903,9 @@ static void ccgDM_getFinalEdge(DerivedMesh *dm, int edgeNum, MEdge *med) #endif i = 0; - while (i < lastface && edgeNum >= ccgdm->faceMap[i + 1].startEdge) - ++i; + while (i < lastface && edgeNum >= ccgdm->faceMap[i + 1].startEdge) { + i++; + } f = ccgdm->faceMap[i].face; /* numVerts = ccgSubSurf_getFaceNumVerts(f); */ /*UNUSED*/ @@ -1012,32 +1047,74 @@ void subsurf_copy_grid_hidden(DerivedMesh *dm, const MPoly *mpoly, } } +/* Translate GridPaintMask into vertex paint masks. Assumes vertices + are in the order output by ccgDM_copyFinalVertArray. */ +void subsurf_copy_grid_paint_mask(DerivedMesh *dm, const MPoly *mpoly, + float *paint_mask, + const GridPaintMask *grid_paint_mask) +{ + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCGSubSurf *ss = ccgdm->ss; + int level = ccgSubSurf_getSubdivisionLevels(ss); + int gridSize = ccgSubSurf_getGridSize(ss); + int edgeSize = ccgSubSurf_getEdgeSize(ss); + int totface = ccgSubSurf_getNumFaces(ss); + int i, j, x, y, factor, gpm_gridsize; + + for (i = 0; i < totface; i++) { + CCGFace *f = ccgdm->faceMap[i].face; + const MPoly *p = &mpoly[i]; + + for (j = 0; j < p->totloop; j++) { + const GridPaintMask *gpm = &grid_paint_mask[p->loopstart + j]; + if (!gpm->data) + continue; + + factor = ccg_factor(level, gpm->level); + gpm_gridsize = ccg_gridsize(gpm->level); + + for (y = 0; y < gridSize; y++) { + for (x = 0; x < gridSize; x++) { + int vndx, offset; + + vndx = getFaceIndex(ss, f, j, x, y, edgeSize, gridSize); + offset = y * factor * gpm_gridsize + x * factor; + paint_mask[vndx] = gpm->data[offset]; + } + } + } + } +} + static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; - DMGridData *vd; + CCGElem *vd; + CCGKey key; int index; int totvert, totedge, totface; int gridSize = ccgSubSurf_getGridSize(ss); int edgeSize = ccgSubSurf_getEdgeSize(ss); int i = 0; + CCG_key_top_level(&key, ss); + totface = ccgSubSurf_getNumFaces(ss); for (index = 0; index < totface; index++) { CCGFace *f = ccgdm->faceMap[index].face; int x, y, S, numVerts = ccgSubSurf_getFaceNumVerts(f); vd = ccgSubSurf_getFaceCenterData(f); - copy_v3_v3(mvert[i].co, vd->co); - normal_float_to_short_v3(mvert[i].no, vd->no); + copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd)); i++; for (S = 0; S < numVerts; S++) { for (x = 1; x < gridSize - 1; x++, i++) { vd = ccgSubSurf_getFaceGridEdgeData(ss, f, S, x); - copy_v3_v3(mvert[i].co, vd->co); - normal_float_to_short_v3(mvert[i].no, vd->no); + copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd)); } } @@ -1045,8 +1122,8 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for (y = 1; y < gridSize - 1; y++) { for (x = 1; x < gridSize - 1; x++, i++) { vd = ccgSubSurf_getFaceGridData(ss, f, S, x, y); - copy_v3_v3(mvert[i].co, vd->co); - normal_float_to_short_v3(mvert[i].no, vd->no); + copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd)); } } } @@ -1059,13 +1136,13 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) for (x = 1; x < edgeSize - 1; x++, i++) { vd = ccgSubSurf_getEdgeData(ss, e, x); - copy_v3_v3(mvert[i].co, vd->co); + copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd)); /* This gives errors with -debug-fpe * the normals don't seem to be unit length. * this is most likely caused by edges with no * faces which are now zerod out, see comment in: * ccgSubSurf__calcVertNormals(), - campbell */ - normal_float_to_short_v3(mvert[i].no, vd->no); + normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd)); } } @@ -1074,8 +1151,8 @@ static void ccgDM_copyFinalVertArray(DerivedMesh *dm, MVert *mvert) CCGVert *v = ccgdm->vertMap[index].vert; vd = ccgSubSurf_getVertData(ss, v); - copy_v3_v3(mvert[i].co, vd->co); - normal_float_to_short_v3(mvert[i].no, vd->no); + copy_v3_v3(mvert[i].co, CCG_elem_co(&key, vd)); + normal_float_to_short_v3(mvert[i].no, CCG_elem_no(&key, vd)); i++; } } @@ -1144,8 +1221,7 @@ static void ccgDM_copyFinalEdgeArray(DerivedMesh *dm, MEdge *medge) if (edgeFlags) { if (edgeIdx != -1) { - flags |= (edgeFlags[index] & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE)) - | ME_EDGEDRAW | ME_EDGERENDER; + flags |= ((edgeFlags[index] & (ME_SEAM | ME_SHARP | ME_FREESTYLE_EDGE)) | ME_EDGEDRAW | ME_EDGERENDER); } } else { @@ -1398,14 +1474,16 @@ static void ccgDM_foreachMappedVert( { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGVertIterator *vi = ccgSubSurf_getVertIterator(ccgdm->ss); + CCGKey key; + CCG_key_top_level(&key, ccgdm->ss); for (; !ccgVertIterator_isStopped(vi); ccgVertIterator_next(vi)) { CCGVert *v = ccgVertIterator_getCurrent(vi); - DMGridData *vd = ccgSubSurf_getVertData(ccgdm->ss, v); + CCGElem *vd = ccgSubSurf_getVertData(ccgdm->ss, v); int index = ccgDM_getVertMapIndex(ccgdm->ss, v); if (index != -1) - func(userData, index, vd->co, vd->no, NULL); + func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd), NULL); } ccgVertIterator_free(vi); @@ -1419,16 +1497,19 @@ static void ccgDM_foreachMappedEdge( CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); + CCGKey key; int i, edgeSize = ccgSubSurf_getEdgeSize(ss); + CCG_key_top_level(&key, ss); + for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { CCGEdge *e = ccgEdgeIterator_getCurrent(ei); - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); int index = ccgDM_getEdgeMapIndex(ss, e); if (index != -1) { for (i = 0; i < edgeSize - 1; i++) - func(userData, index, edgeData[i].co, edgeData[i + 1].co); + func(userData, index, CCG_elem_offset_co(&key, edgeData, i), CCG_elem_offset_co(&key, edgeData, i + 1)); } } @@ -1500,18 +1581,20 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); int totedge = ccgSubSurf_getNumEdges(ss); int gridSize = ccgSubSurf_getGridSize(ss); int useAging; + CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); for (j = 0; j < totedge; j++) { CCGEdge *e = ccgdm->edgeMap[j].edge; - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); if (!drawLooseEdges && !ccgSubSurf_getEdgeNumFaces(e)) continue; @@ -1526,8 +1609,8 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge glBegin(GL_LINE_STRIP); for (i = 0; i < edgeSize - 1; i++) { - glVertex3fv(edgeData[i].co); - glVertex3fv(edgeData[i + 1].co); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i)); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i + 1)); } glEnd(); } @@ -1544,22 +1627,22 @@ static void ccgDM_drawEdges(DerivedMesh *dm, int drawLooseEdges, int drawAllEdge int S, x, y, numVerts = ccgSubSurf_getFaceNumVerts(f); for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); glBegin(GL_LINE_STRIP); for (x = 0; x < gridSize; x++) - glVertex3fv(faceGridData[x].co); + glVertex3fv(CCG_elem_offset_co(&key, faceGridData, x)); glEnd(); for (y = 1; y < gridSize - 1; y++) { glBegin(GL_LINE_STRIP); for (x = 0; x < gridSize; x++) - glVertex3fv(faceGridData[y * gridSize + x].co); + glVertex3fv(CCG_grid_elem_co(&key, faceGridData, x, y)); glEnd(); } for (x = 1; x < gridSize - 1; x++) { glBegin(GL_LINE_STRIP); for (y = 0; y < gridSize; y++) - glVertex3fv(faceGridData[y * gridSize + x].co); + glVertex3fv(CCG_grid_elem_co(&key, faceGridData, x, y)); glEnd(); } } @@ -1571,18 +1654,21 @@ static void ccgDM_drawLooseEdges(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; int totedge = ccgSubSurf_getNumEdges(ss); int i, j, edgeSize = ccgSubSurf_getEdgeSize(ss); + CCG_key_top_level(&key, ss); + for (j = 0; j < totedge; j++) { CCGEdge *e = ccgdm->edgeMap[j].edge; - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); if (!ccgSubSurf_getEdgeNumFaces(e)) { glBegin(GL_LINE_STRIP); for (i = 0; i < edgeSize - 1; i++) { - glVertex3fv(edgeData[i].co); - glVertex3fv(edgeData[i + 1].co); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i)); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i + 1)); } glEnd(); } @@ -1608,12 +1694,14 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; int gridSize = ccgSubSurf_getGridSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; int step = (fast) ? gridSize - 1 : 1; int i, totface = ccgSubSurf_getNumFaces(ss); int drawcurrent = 0, matnr = -1, shademodel = -1; + CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); if (ccgdm->pbvh && ccgdm->multires.mmd && !fast) { @@ -1653,19 +1741,19 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) continue; for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); if (shademodel == GL_SMOOTH) { for (y = 0; y < gridSize - 1; y += step) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridSize; x += step) { - DMGridData *a = &faceGridData[(y + 0) * gridSize + x]; - DMGridData *b = &faceGridData[(y + step) * gridSize + x]; + CCGElem *a = CCG_grid_elem(&key, faceGridData, x, y + 0); + CCGElem *b = CCG_grid_elem(&key, faceGridData, x, y + step); - glNormal3fv(a->no); - glVertex3fv(a->co); - glNormal3fv(b->no); - glVertex3fv(b->co); + glNormal3fv(CCG_elem_no(&key, a)); + glVertex3fv(CCG_elem_co(&key, a)); + glNormal3fv(CCG_elem_no(&key, b)); + glVertex3fv(CCG_elem_co(&key, b)); } glEnd(); } @@ -1674,10 +1762,10 @@ static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes) glBegin(GL_QUADS); for (y = 0; y < gridSize - 1; y += step) { for (x = 0; x < gridSize - 1; x += step) { - float *a = faceGridData[(y + 0) * gridSize + x].co; - float *b = faceGridData[(y + 0) * gridSize + x + step].co; - float *c = faceGridData[(y + step) * gridSize + x + step].co; - float *d = faceGridData[(y + step) * gridSize + x].co; + float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0); + float *b = CCG_grid_elem_co(&key, faceGridData, x + step, y + 0); + float *c = CCG_grid_elem_co(&key, faceGridData, x + step, y + step); + float *d = CCG_grid_elem_co(&key, faceGridData, x, y + step); ccgDM_glNormalFast(a, b, c, d); @@ -1701,6 +1789,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; GPUVertexAttribs gattribs; DMVertexAttribs attribs = {{{NULL}}}; /* MTFace *tf = dm->getTessFaceDataArray(dm, CD_MTFACE); */ /* UNUSED */ @@ -1710,6 +1799,7 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, DMFlagMat *faceFlags = ccgdm->faceFlags; int a, b, i, doDraw, numVerts, matnr, new_matnr, totface; + CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); doDraw = 0; @@ -1769,38 +1859,38 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT); for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); - DMGridData *vda, *vdb; + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *vda, *vdb; if (drawSmooth) { for (y = 0; y < gridFaces; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridFaces; x++) { - vda = &faceGridData[(y + 0) * gridSize + x]; - vdb = &faceGridData[(y + 1) * gridSize + x]; + vda = CCG_grid_elem(&key, faceGridData, x, y + 0); + vdb = CCG_grid_elem(&key, faceGridData, x, y + 1); PASSATTRIB(0, 0, 0); - glNormal3fv(vda->no); - glVertex3fv(vda->co); + glNormal3fv(CCG_elem_no(&key, vda)); + glVertex3fv(CCG_elem_co(&key, vda)); PASSATTRIB(0, 1, 1); - glNormal3fv(vdb->no); - glVertex3fv(vdb->co); + glNormal3fv(CCG_elem_no(&key, vdb)); + glVertex3fv(CCG_elem_co(&key, vdb)); if (x != gridFaces - 1) a++; } - vda = &faceGridData[(y + 0) * gridSize + x]; - vdb = &faceGridData[(y + 1) * gridSize + x]; + vda = CCG_grid_elem(&key, faceGridData, x, y + 0); + vdb = CCG_grid_elem(&key, faceGridData, x, y + 1); PASSATTRIB(0, 0, 3); - glNormal3fv(vda->no); - glVertex3fv(vda->co); + glNormal3fv(CCG_elem_no(&key, vda)); + glVertex3fv(CCG_elem_co(&key, vda)); PASSATTRIB(0, 1, 2); - glNormal3fv(vdb->no); - glVertex3fv(vdb->co); + glNormal3fv(CCG_elem_no(&key, vdb)); + glVertex3fv(CCG_elem_co(&key, vdb)); glEnd(); @@ -1811,10 +1901,10 @@ static void ccgDM_drawMappedFacesGLSL(DerivedMesh *dm, glBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { - float *aco = faceGridData[(y + 0) * gridSize + x].co; - float *bco = faceGridData[(y + 0) * gridSize + x + 1].co; - float *cco = faceGridData[(y + 1) * gridSize + x + 1].co; - float *dco = faceGridData[(y + 1) * gridSize + x].co; + float *aco = CCG_grid_elem_co(&key, faceGridData, x, y); + float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y); + float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1); + float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1); ccgDM_glNormalFast(aco, bco, cco, dco); @@ -1848,6 +1938,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; GPUVertexAttribs gattribs; DMVertexAttribs attribs = {{{NULL}}}; int gridSize = ccgSubSurf_getGridSize(ss); @@ -1856,6 +1947,7 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * DMFlagMat *faceFlags = ccgdm->faceFlags; int a, b, i, numVerts, matnr, new_matnr, totface; + CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); matnr = -1; @@ -1921,38 +2013,38 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * /* draw face*/ glShadeModel(drawSmooth ? GL_SMOOTH : GL_FLAT); for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); - DMGridData *vda, *vdb; + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *vda, *vdb; if (drawSmooth) { for (y = 0; y < gridFaces; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridFaces; x++) { - vda = &faceGridData[(y + 0) * gridSize + x]; - vdb = &faceGridData[(y + 1) * gridSize + x]; + vda = CCG_grid_elem(&key, faceGridData, x, y); + vdb = CCG_grid_elem(&key, faceGridData, x, y + 1); PASSATTRIB(0, 0, 0); - glNormal3fv(vda->no); - glVertex3fv(vda->co); + glNormal3fv(CCG_elem_no(&key, vda)); + glVertex3fv(CCG_elem_co(&key, vda)); PASSATTRIB(0, 1, 1); - glNormal3fv(vdb->no); - glVertex3fv(vdb->co); + glNormal3fv(CCG_elem_no(&key, vdb)); + glVertex3fv(CCG_elem_co(&key, vdb)); if (x != gridFaces - 1) a++; } - vda = &faceGridData[(y + 0) * gridSize + x]; - vdb = &faceGridData[(y + 1) * gridSize + x]; + vda = CCG_grid_elem(&key, faceGridData, x, y + 0); + vdb = CCG_grid_elem(&key, faceGridData, x, y + 1); PASSATTRIB(0, 0, 3); - glNormal3fv(vda->no); - glVertex3fv(vda->co); + glNormal3fv(CCG_elem_no(&key, vda)); + glVertex3fv(CCG_elem_co(&key, vda)); PASSATTRIB(0, 1, 2); - glNormal3fv(vdb->no); - glVertex3fv(vdb->co); + glNormal3fv(CCG_elem_no(&key, vdb)); + glVertex3fv(CCG_elem_co(&key, vdb)); glEnd(); @@ -1963,10 +2055,10 @@ static void ccgDM_drawMappedFacesMat(DerivedMesh *dm, void (*setMaterial)(void * glBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { - float *aco = faceGridData[(y + 0) * gridSize + x].co; - float *bco = faceGridData[(y + 0) * gridSize + x + 1].co; - float *cco = faceGridData[(y + 1) * gridSize + x + 1].co; - float *dco = faceGridData[(y + 1) * gridSize + x].co; + float *aco = CCG_grid_elem_co(&key, faceGridData, x, y + 0); + float *bco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0); + float *cco = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1); + float *dco = CCG_grid_elem_co(&key, faceGridData, x, y + 1); ccgDM_glNormalFast(aco, bco, cco, dco); @@ -1998,6 +2090,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; MCol *mcol = dm->getTessFaceDataArray(dm, CD_PREVIEW_MCOL); MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); DMFlagMat *faceFlags = ccgdm->faceFlags; @@ -2007,6 +2100,7 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, (void) compareDrawOptions; + CCG_key_top_level(&key, ss); ccgdm_pbvh_update(ccgdm); if (!mcol) @@ -2055,26 +2149,26 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, } for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); - DMGridData *a, *b; + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *a, *b; if (drawSmooth) { glShadeModel(GL_SMOOTH); for (y = 0; y < gridFaces; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridFaces; x++) { - a = &faceGridData[(y + 0) * gridSize + x]; - b = &faceGridData[(y + 1) * gridSize + x]; + a = CCG_grid_elem(&key, faceGridData, x, y + 0); + b = CCG_grid_elem(&key, faceGridData, x, y + 1); if (tf) glTexCoord2fv(tf->uv[0]); if (cp) glColor3ub(cp[3], cp[2], cp[1]); - glNormal3fv(a->no); - glVertex3fv(a->co); + glNormal3fv(CCG_elem_no(&key, a)); + glVertex3fv(CCG_elem_co(&key, a)); if (tf) glTexCoord2fv(tf->uv[1]); if (cp) glColor3ub(cp[7], cp[6], cp[5]); - glNormal3fv(b->no); - glVertex3fv(b->co); + glNormal3fv(CCG_elem_no(&key, b)); + glVertex3fv(CCG_elem_co(&key, b)); if (x != gridFaces - 1) { if (tf) tf++; @@ -2082,18 +2176,18 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, } } - a = &faceGridData[(y + 0) * gridSize + x]; - b = &faceGridData[(y + 1) * gridSize + x]; + a = CCG_grid_elem(&key, faceGridData, x, y + 0); + b = CCG_grid_elem(&key, faceGridData, x, y + 1); if (tf) glTexCoord2fv(tf->uv[3]); if (cp) glColor3ub(cp[15], cp[14], cp[13]); - glNormal3fv(a->no); - glVertex3fv(a->co); + glNormal3fv(CCG_elem_no(&key, a)); + glVertex3fv(CCG_elem_co(&key, a)); if (tf) glTexCoord2fv(tf->uv[2]); if (cp) glColor3ub(cp[11], cp[10], cp[9]); - glNormal3fv(b->no); - glVertex3fv(b->co); + glNormal3fv(CCG_elem_no(&key, b)); + glVertex3fv(CCG_elem_co(&key, b)); if (tf) tf++; if (cp) cp += 16; @@ -2102,14 +2196,14 @@ static void ccgDM_drawFacesTex_common(DerivedMesh *dm, } } else { - glShadeModel((cp)? GL_SMOOTH: GL_FLAT); + glShadeModel((cp) ? GL_SMOOTH : GL_FLAT); glBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { - float *a_co = faceGridData[(y + 0) * gridSize + x].co; - float *b_co = faceGridData[(y + 0) * gridSize + x + 1].co; - float *c_co = faceGridData[(y + 1) * gridSize + x + 1].co; - float *d_co = faceGridData[(y + 1) * gridSize + x].co; + float *a_co = CCG_grid_elem_co(&key, faceGridData, x, y + 0); + float *b_co = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0); + float *c_co = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1); + float *d_co = CCG_grid_elem_co(&key, faceGridData, x, y + 1); ccgDM_glNormalFast(a_co, b_co, c_co, d_co); @@ -2197,12 +2291,15 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; MCol *mcol = NULL; int i, gridSize = ccgSubSurf_getGridSize(ss); DMFlagMat *faceFlags = ccgdm->faceFlags; int useColors = flag & DM_DRAW_USE_COLORS; int gridFaces = gridSize - 1, totface; + CCG_key_top_level(&key, ss); + /* currently unused -- each original face is handled separately */ (void)compareDrawOptions; @@ -2250,36 +2347,36 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, glShadeModel(GL_SMOOTH); for (S = 0; S < numVerts; S++) { - DMGridData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); + CCGElem *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S); if (drawSmooth) { for (y = 0; y < gridFaces; y++) { - DMGridData *a, *b; + CCGElem *a, *b; glBegin(GL_QUAD_STRIP); for (x = 0; x < gridFaces; x++) { - a = &faceGridData[(y + 0) * gridSize + x]; - b = &faceGridData[(y + 1) * gridSize + x]; + a = CCG_grid_elem(&key, faceGridData, x, y + 0); + b = CCG_grid_elem(&key, faceGridData, x, y + 1); if (cp) glColor3ub(cp[3], cp[2], cp[1]); - glNormal3fv(a->no); - glVertex3fv(a->co); + glNormal3fv(CCG_elem_no(&key, a)); + glVertex3fv(CCG_elem_co(&key, a)); if (cp) glColor3ub(cp[7], cp[6], cp[5]); - glNormal3fv(b->no); - glVertex3fv(b->co); + glNormal3fv(CCG_elem_no(&key, b)); + glVertex3fv(CCG_elem_co(&key, b)); if (x != gridFaces - 1) { if (cp) cp += 16; } } - a = &faceGridData[(y + 0) * gridSize + x]; - b = &faceGridData[(y + 1) * gridSize + x]; + a = CCG_grid_elem(&key, faceGridData, x, y + 0); + b = CCG_grid_elem(&key, faceGridData, x, y + 1); if (cp) glColor3ub(cp[15], cp[14], cp[13]); - glNormal3fv(a->no); - glVertex3fv(a->co); + glNormal3fv(CCG_elem_no(&key, a)); + glVertex3fv(CCG_elem_co(&key, a)); if (cp) glColor3ub(cp[11], cp[10], cp[9]); - glNormal3fv(b->no); - glVertex3fv(b->co); + glNormal3fv(CCG_elem_no(&key, b)); + glVertex3fv(CCG_elem_co(&key, b)); if (cp) cp += 16; @@ -2290,10 +2387,10 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, glBegin(GL_QUADS); for (y = 0; y < gridFaces; y++) { for (x = 0; x < gridFaces; x++) { - float *a = faceGridData[(y + 0) * gridSize + x].co; - float *b = faceGridData[(y + 0) * gridSize + x + 1].co; - float *c = faceGridData[(y + 1) * gridSize + x + 1].co; - float *d = faceGridData[(y + 1) * gridSize + x].co; + float *a = CCG_grid_elem_co(&key, faceGridData, x, y + 0); + float *b = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 0); + float *c = CCG_grid_elem_co(&key, faceGridData, x + 1, y + 1); + float *d = CCG_grid_elem_co(&key, faceGridData, x, y + 1); ccgDM_glNormalFast(a, b, c, d); @@ -2326,13 +2423,15 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm, CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); + CCGKey key; int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss); + CCG_key_top_level(&key, ss); ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { CCGEdge *e = ccgEdgeIterator_getCurrent(ei); - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); int index = ccgDM_getEdgeMapIndex(ss, e); glBegin(GL_LINE_STRIP); @@ -2343,8 +2442,8 @@ static void ccgDM_drawMappedEdges(DerivedMesh *dm, } for (i = 0; i < edgeSize - 1; i++) { - glVertex3fv(edgeData[i].co); - glVertex3fv(edgeData[i + 1].co); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i)); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i + 1)); } } glEnd(); @@ -2360,14 +2459,16 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm, { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; CCGEdgeIterator *ei = ccgSubSurf_getEdgeIterator(ss); int i, useAging, edgeSize = ccgSubSurf_getEdgeSize(ss); + CCG_key_top_level(&key, ss); ccgSubSurf_getUseAgeCounts(ss, &useAging, NULL, NULL, NULL); for (; !ccgEdgeIterator_isStopped(ei); ccgEdgeIterator_next(ei)) { CCGEdge *e = ccgEdgeIterator_getCurrent(ei); - DMGridData *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); + CCGElem *edgeData = ccgSubSurf_getEdgeDataArray(ss, e); int index = ccgDM_getEdgeMapIndex(ss, e); glBegin(GL_LINE_STRIP); @@ -2380,7 +2481,7 @@ static void ccgDM_drawMappedEdgesInterp(DerivedMesh *dm, glColor3ub(0, ageCol > 0 ? ageCol : 0, 0); } - glVertex3fv(edgeData[i].co); + glVertex3fv(CCG_elem_offset_co(&key, edgeData, i)); } } glEnd(); @@ -2396,17 +2497,20 @@ static void ccgDM_foreachMappedFaceCenter( { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *) dm; CCGSubSurf *ss = ccgdm->ss; + CCGKey key; CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss); + CCG_key_top_level(&key, ss); + for (; !ccgFaceIterator_isStopped(fi); ccgFaceIterator_next(fi)) { CCGFace *f = ccgFaceIterator_getCurrent(fi); int index = ccgDM_getFaceMapIndex(ss, f); if (index != -1) { /* Face center data normal isn't updated atm. */ - DMGridData *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0); + CCGElem *vd = ccgSubSurf_getFaceGridData(ss, f, 0, 0, 0); - func(userData, index, vd->co, vd->no); + func(userData, index, CCG_elem_co(&key, vd), CCG_elem_no(&key, vd)); } } @@ -2719,7 +2823,7 @@ static void ccgdm_create_grids(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; CCGSubSurf *ss = ccgdm->ss; - DMGridData **gridData; + CCGElem **gridData; DMGridAdjacency *gridAdjacency, *adj; DMFlagMat *gridFlagMats; CCGFace **gridFaces; @@ -2745,7 +2849,7 @@ static void ccgdm_create_grids(DerivedMesh *dm) } /* compute grid data */ - gridData = MEM_mallocN(sizeof(DMGridData *) * numGrids, "ccgdm.gridData"); + gridData = MEM_mallocN(sizeof(CCGElem *) * numGrids, "ccgdm.gridData"); gridAdjacency = MEM_mallocN(sizeof(DMGridAdjacency) * numGrids, "ccgdm.gridAdjacency"); gridFaces = MEM_mallocN(sizeof(CCGFace *) * numGrids, "ccgdm.gridFaces"); gridFlagMats = MEM_mallocN(sizeof(DMFlagMat) * numGrids, "ccgdm.gridFlagMats"); @@ -2784,7 +2888,7 @@ static void ccgdm_create_grids(DerivedMesh *dm) ccgdm->gridFlagMats = gridFlagMats; } -static DMGridData **ccgDM_getGridData(DerivedMesh *dm) +static CCGElem **ccgDM_getGridData(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; @@ -2808,6 +2912,12 @@ static int *ccgDM_getGridOffset(DerivedMesh *dm) return ccgdm->gridOffset; } +static void ccgDM_getGridKey(DerivedMesh *dm, CCGKey *key) +{ + CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; + CCG_key_top_level(key, ccgdm->ss); +} + static DMFlagMat *ccgDM_getGridFlagMats(DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; @@ -2854,7 +2964,10 @@ static int ccgDM_use_grid_pbvh(CCGDerivedMesh *ccgdm) static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; - int gridSize, numGrids, grid_pbvh; + CCGKey key; + int numGrids, grid_pbvh; + + CCG_key_top_level(&key, ccgdm->ss); if (!ob) { ccgdm->pbvh = NULL; @@ -2888,19 +3001,18 @@ static struct PBVH *ccgDM_getPBVH(Object *ob, DerivedMesh *dm) if (grid_pbvh) { ccgdm_create_grids(dm); - gridSize = ccgDM_getGridSize(dm); numGrids = ccgDM_getNumGrids(dm); ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new(); BLI_pbvh_build_grids(ccgdm->pbvh, ccgdm->gridData, ccgdm->gridAdjacency, - numGrids, gridSize, (void **)ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden); + numGrids, &key, (void **) ccgdm->gridFaces, ccgdm->gridFlagMats, ccgdm->gridHidden); } else if (ob->type == OB_MESH) { Mesh *me = ob->data; ob->sculpt->pbvh = ccgdm->pbvh = BLI_pbvh_new(); BLI_assert(!(me->mface == NULL && me->mpoly != NULL)); /* BMESH ONLY complain if mpoly is valid but not mface */ BLI_pbvh_build_mesh(ccgdm->pbvh, me->mface, me->mvert, - me->totface, me->totvert); + me->totface, me->totvert, &me->vdata); } return ccgdm->pbvh; @@ -3014,6 +3126,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, ccgdm->dm.getGridData = ccgDM_getGridData; ccgdm->dm.getGridAdjacency = ccgDM_getGridAdjacency; ccgdm->dm.getGridOffset = ccgDM_getGridOffset; + ccgdm->dm.getGridKey = ccgDM_getGridKey; ccgdm->dm.getGridFlagMats = ccgDM_getGridFlagMats; ccgdm->dm.getGridHidden = ccgDM_getGridHidden; ccgdm->dm.getPolyMap = ccgDM_getPolyMap; @@ -3169,10 +3282,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, numVerts, vertNum); if (vertOrigIndex) { *vertOrigIndex = ORIGINDEX_NONE; - ++vertOrigIndex; + vertOrigIndex++; } - ++vertNum; + vertNum++; /*interpolate per-vert data*/ for (s = 0; s < numVerts; s++) { @@ -3183,10 +3296,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, if (vertOrigIndex) { *vertOrigIndex = ORIGINDEX_NONE; - ++vertOrigIndex; + vertOrigIndex++; } - ++vertNum; + vertNum++; } } @@ -3200,10 +3313,10 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, if (vertOrigIndex) { *vertOrigIndex = ORIGINDEX_NONE; - ++vertOrigIndex; + vertOrigIndex++; } - ++vertNum; + vertNum++; } } } @@ -3299,9 +3412,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, DM_interp_vert_data(dm, &ccgdm->dm, vertIdx, w, 2, vertNum); if (vertOrigIndex) { *vertOrigIndex = ORIGINDEX_NONE; - ++vertOrigIndex; + vertOrigIndex++; } - ++vertNum; + vertNum++; } for (i = 0; i < numFinalEdges; ++i) { @@ -3339,9 +3452,9 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, if (vertOrigIndex) { *vertOrigIndex = mapIndex; - ++vertOrigIndex; + vertOrigIndex++; } - ++vertNum; + vertNum++; } ccgdm->dm.numVertData = vertNum; @@ -3365,8 +3478,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, struct DerivedMesh *subsurf_make_derived_from_derived( struct DerivedMesh *dm, struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int forEditMode, int inEditMode) + float (*vertCos)[3], + SubsurfFlags flags) { int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF; CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0; @@ -3374,17 +3487,17 @@ struct DerivedMesh *subsurf_make_derived_from_derived( int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges); CCGDerivedMesh *result; - if (forEditMode) { + if (flags & SUBSURF_FOR_EDIT_MODE) { int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels; - smd->emCache = _getSubSurf(smd->emCache, levels, useAging | CCG_CALC_NORMALS); + smd->emCache = _getSubSurf(smd->emCache, levels, 3, useAging | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(smd->emCache, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->emCache, drawInteriorEdges, useSubsurfUv, dm); } - else if (useRenderParams) { + else if (flags & SUBSURF_USE_RENDER_PARAMS) { /* Do not use cache in render mode. */ CCGSubSurf *ss; int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels) : smd->renderLevels; @@ -3392,7 +3505,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( if (levels == 0) return dm; - ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS); + ss = _getSubSurf(NULL, levels, 3, CCG_USE_ARENA | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -3417,13 +3530,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived( * Addendum: we can't really ensure that this is never called in edit * mode, so now we have a parameter to verify it. - brecht */ - if (!inEditMode && smd->emCache) { + if (!(flags & SUBSURF_IN_EDIT_MODE) && smd->emCache) { ccgSubSurf_free(smd->emCache); smd->emCache = NULL; } - if (useIncremental && isFinalCalc) { - smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging | CCG_CALC_NORMALS); + if (useIncremental && (flags & SUBSURF_IS_FINAL_CALC)) { + smd->mCache = ss = _getSubSurf(smd->mCache, levels, 3, useAging | CCG_CALC_NORMALS); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); @@ -3432,20 +3545,28 @@ struct DerivedMesh *subsurf_make_derived_from_derived( useSubsurfUv, dm); } else { - if (smd->mCache && isFinalCalc) { + CCGFlags ccg_flags = CCG_USE_ARENA | CCG_CALC_NORMALS; + + if (smd->mCache && (flags & SUBSURF_IS_FINAL_CALC)) { ccgSubSurf_free(smd->mCache); smd->mCache = NULL; } - ss = _getSubSurf(NULL, levels, CCG_USE_ARENA | CCG_CALC_NORMALS); + if (flags & SUBSURF_ALLOC_PAINT_MASK) + ccg_flags |= CCG_ALLOC_MASK; + + ss = _getSubSurf(NULL, levels, 3, ccg_flags); ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); - if (isFinalCalc) + if (flags & SUBSURF_IS_FINAL_CALC) smd->mCache = ss; else result->freeSS = 1; + + if (flags & SUBSURF_ALLOC_PAINT_MASK) + ccgSubSurf_setNumLayers(ss, 4); } } @@ -3459,7 +3580,7 @@ void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) * calculated vert positions is incorrect for the verts * on the boundary of the mesh. */ - CCGSubSurf *ss = _getSubSurf(NULL, 1, CCG_USE_ARENA); + CCGSubSurf *ss = _getSubSurf(NULL, 1, 3, CCG_USE_ARENA); float edge_sum[3], face_sum[3]; CCGVertIterator *vi; DerivedMesh *dm = CDDM_from_mesh(me, NULL); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index d67c5fb3698..7634528927a 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -135,8 +135,8 @@ static void txt_pop_last(Text *text); static void txt_undo_add_op(Text *text, int op); static void txt_undo_add_block(Text *text, int op, const char *buf); static void txt_delete_line(Text *text, TextLine *line); -static void txt_delete_sel (Text *text); -static void txt_make_dirty (Text *text); +static void txt_delete_sel(Text *text); +static void txt_make_dirty(Text *text); /***/ @@ -155,19 +155,19 @@ int txt_get_undostate(void) static void init_undo_text(Text *text) { - text->undo_pos= -1; - text->undo_len= TXT_INIT_UNDO; - text->undo_buf= MEM_mallocN(text->undo_len, "undo buf"); + text->undo_pos = -1; + text->undo_len = TXT_INIT_UNDO; + text->undo_buf = MEM_mallocN(text->undo_len, "undo buf"); } -void free_text(Text *text) +void BKE_text_free(Text *text) { TextLine *tmp; - for (tmp= text->lines.first; tmp; tmp= tmp->next) { + for (tmp = text->lines.first; tmp; tmp = tmp->next) { MEM_freeN(tmp->line); if (tmp->format) - MEM_freeN(tmp->format); + MEM_freeN(tmp->format); } BLI_freelistN(&text->lines); @@ -180,43 +180,43 @@ void free_text(Text *text) #endif } -Text *add_empty_text(const char *name) +Text *BKE_text_add(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Text *ta; TextLine *tmp; - ta= alloc_libblock(&bmain->text, ID_TXT, name); - ta->id.us= 1; + ta = BKE_libblock_alloc(&bmain->text, ID_TXT, name); + ta->id.us = 1; - ta->name= NULL; + ta->name = NULL; init_undo_text(ta); - ta->nlines=1; - ta->flags= TXT_ISDIRTY | TXT_ISMEM; - if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0) + ta->nlines = 1; + ta->flags = TXT_ISDIRTY | TXT_ISMEM; + if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) ta->flags |= TXT_TABSTOSPACES; - ta->lines.first= ta->lines.last= NULL; - ta->markers.first= ta->markers.last= NULL; + ta->lines.first = ta->lines.last = NULL; + ta->markers.first = ta->markers.last = NULL; - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= (char*) MEM_mallocN(1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(1, "textline_string"); + tmp->format = NULL; - tmp->line[0]=0; - tmp->len= 0; + tmp->line[0] = 0; + tmp->len = 0; - tmp->next= NULL; - tmp->prev= NULL; + tmp->next = NULL; + tmp->prev = NULL; BLI_addhead(&ta->lines, tmp); - ta->curl= ta->lines.first; - ta->curc= 0; - ta->sell= ta->lines.first; - ta->selc= 0; + ta->curl = ta->lines.first; + ta->curc = 0; + ta->sell = ta->lines.first; + ta->selc = 0; return ta; } @@ -225,35 +225,35 @@ Text *add_empty_text(const char *name) /* to a valid utf-8 sequences */ int txt_extended_ascii_as_utf8(char **str) { - int bad_char, added= 0, i= 0; + int bad_char, added = 0, i = 0; int length = strlen(*str); while ((*str)[i]) { - if ((bad_char= BLI_utf8_invalid_byte(*str+i, length-i)) == -1) + if ((bad_char = BLI_utf8_invalid_byte(*str + i, length - i)) == -1) break; added++; - i+= bad_char + 1; + i += bad_char + 1; } if (added != 0) { - char *newstr = MEM_mallocN(length+added+1, "text_line"); + char *newstr = MEM_mallocN(length + added + 1, "text_line"); int mi = 0; - i= 0; + i = 0; while ((*str)[i]) { - if ((bad_char= BLI_utf8_invalid_byte((*str)+i, length-i)) == -1) { - memcpy(newstr+mi, (*str)+i, length - i + 1); + if ((bad_char = BLI_utf8_invalid_byte((*str) + i, length - i)) == -1) { + memcpy(newstr + mi, (*str) + i, length - i + 1); break; } - memcpy(newstr+mi, (*str)+i, bad_char); + memcpy(newstr + mi, (*str) + i, bad_char); - BLI_str_utf8_from_unicode((*str)[i+bad_char], newstr+mi+bad_char); - i+= bad_char+1; - mi+= bad_char+2; + BLI_str_utf8_from_unicode((*str)[i + bad_char], newstr + mi + bad_char); + i += bad_char + 1; + mi += bad_char + 2; } - newstr[length+added] = '\0'; + newstr[length + added] = '\0'; MEM_freeN(*str); *str = newstr; } @@ -264,21 +264,21 @@ int txt_extended_ascii_as_utf8(char **str) // this function removes any control characters from // a textline and fixes invalid utf-8 sequences -static void cleanup_textline(TextLine * tl) +static void cleanup_textline(TextLine *tl) { int i; - for (i = 0; i < tl->len; i++ ) { + for (i = 0; i < tl->len; i++) { if (tl->line[i] < ' ' && tl->line[i] != '\t') { memmove(tl->line + i, tl->line + i + 1, tl->len - i); tl->len--; i--; } } - tl->len+= txt_extended_ascii_as_utf8(&tl->line); + tl->len += txt_extended_ascii_as_utf8(&tl->line); } -int reopen_text(Text *text) +int BKE_text_reload(Text *text) { FILE *fp; int i, llen, len; @@ -292,32 +292,32 @@ int reopen_text(Text *text) BLI_strncpy(str, text->name, FILE_MAX); BLI_path_abs(str, G.main->name); - fp= BLI_fopen(str, "r"); - if (fp==NULL) return 0; + fp = BLI_fopen(str, "r"); + if (fp == NULL) return 0; /* free memory: */ - for (tmp= text->lines.first; tmp; tmp= tmp->next) { + for (tmp = text->lines.first; tmp; tmp = tmp->next) { MEM_freeN(tmp->line); if (tmp->format) MEM_freeN(tmp->format); } BLI_freelistN(&text->lines); - text->lines.first= text->lines.last= NULL; - text->curl= text->sell= NULL; + text->lines.first = text->lines.last = NULL; + text->curl = text->sell = NULL; /* clear undo buffer */ MEM_freeN(text->undo_buf); init_undo_text(text); fseek(fp, 0L, SEEK_END); - len= ftell(fp); + len = ftell(fp); fseek(fp, 0L, SEEK_SET); - text->undo_pos= -1; + text->undo_pos = -1; - buffer= MEM_mallocN(len, "text_buffer"); + buffer = MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because // of CR stripping len = fread(buffer, 1, len, fp); @@ -325,40 +325,40 @@ int reopen_text(Text *text) fclose(fp); stat(str, &st); - text->mtime= st.st_mtime; + text->mtime = st.st_mtime; - text->nlines=0; - llen=0; - for (i=0; iline= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; - - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + text->nlines = 0; + llen = 0; + for (i = 0; i < len; i++) { + if (buffer[i] == '\n') { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; + + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); BLI_addtail(&text->lines, tmp); text->nlines++; - llen=0; + llen = 0; continue; } llen++; } - if (llen!=0 || text->nlines==0) { - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; + if (llen != 0 || text->nlines == 0) { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); @@ -366,16 +366,16 @@ int reopen_text(Text *text) text->nlines++; } - text->curl= text->sell= text->lines.first; - text->curc= text->selc= 0; + text->curl = text->sell = text->lines.first; + text->curc = text->selc = 0; MEM_freeN(buffer); return 1; } -Text *add_text(const char *file, const char *relpath) +Text *BKE_text_load(const char *file, const char *relpath) { - Main *bmain= G.main; + Main *bmain = G.main; FILE *fp; int i, llen, len; unsigned char *buffer; @@ -388,29 +388,29 @@ Text *add_text(const char *file, const char *relpath) if (relpath) /* can be NULL (bg mode) */ BLI_path_abs(str, relpath); - fp= BLI_fopen(str, "r"); - if (fp==NULL) return NULL; + fp = BLI_fopen(str, "r"); + if (fp == NULL) return NULL; - ta= alloc_libblock(&bmain->text, ID_TXT, BLI_path_basename(str)); - ta->id.us= 1; + ta = BKE_libblock_alloc(&bmain->text, ID_TXT, BLI_path_basename(str)); + ta->id.us = 1; - ta->lines.first= ta->lines.last= NULL; - ta->markers.first= ta->markers.last= NULL; - ta->curl= ta->sell= NULL; + ta->lines.first = ta->lines.last = NULL; + ta->markers.first = ta->markers.last = NULL; + ta->curl = ta->sell = NULL; - if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE)==0) - ta->flags= TXT_TABSTOSPACES; + if ((U.flag & USER_TXT_TABSTOSPACES_DISABLE) == 0) + ta->flags = TXT_TABSTOSPACES; fseek(fp, 0L, SEEK_END); - len= ftell(fp); + len = ftell(fp); fseek(fp, 0L, SEEK_SET); - ta->name= MEM_mallocN(strlen(file)+1, "text_name"); + ta->name = MEM_mallocN(strlen(file) + 1, "text_name"); strcpy(ta->name, file); init_undo_text(ta); - buffer= MEM_mallocN(len, "text_buffer"); + buffer = MEM_mallocN(len, "text_buffer"); // under windows fread can return less then len bytes because // of CR stripping len = fread(buffer, 1, len, fp); @@ -418,26 +418,26 @@ Text *add_text(const char *file, const char *relpath) fclose(fp); stat(str, &st); - ta->mtime= st.st_mtime; + ta->mtime = st.st_mtime; - ta->nlines=0; - llen=0; - for (i=0; iline= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; - - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + ta->nlines = 0; + llen = 0; + for (i = 0; i < len; i++) { + if (buffer[i] == '\n') { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; + + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); BLI_addtail(&ta->lines, tmp); ta->nlines++; - llen=0; + llen = 0; continue; } llen++; @@ -449,15 +449,15 @@ Text *add_text(const char *file, const char *relpath) * - file is empty. in this case new line is needed to start editing from. * - last characted in buffer is \n. in this case new line is needed to * deal with newline at end of file. (see [#28087]) (sergey) */ - if (llen!=0 || ta->nlines==0 || buffer[len-1]=='\n') { - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= (char*) MEM_mallocN(llen+1, "textline_string"); - tmp->format= NULL; + if (llen != 0 || ta->nlines == 0 || buffer[len - 1] == '\n') { + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = (char *) MEM_mallocN(llen + 1, "textline_string"); + tmp->format = NULL; - if (llen) memcpy(tmp->line, &buffer[i-llen], llen); + if (llen) memcpy(tmp->line, &buffer[i - llen], llen); - tmp->line[llen]=0; - tmp->len= llen; + tmp->line[llen] = 0; + tmp->len = llen; cleanup_textline(tmp); @@ -465,63 +465,63 @@ Text *add_text(const char *file, const char *relpath) ta->nlines++; } - ta->curl= ta->sell= ta->lines.first; - ta->curc= ta->selc= 0; + ta->curl = ta->sell = ta->lines.first; + ta->curc = ta->selc = 0; MEM_freeN(buffer); return ta; } -Text *copy_text(Text *ta) +Text *BKE_text_copy(Text *ta) { Text *tan; TextLine *line, *tmp; - tan= copy_libblock(&ta->id); + tan = BKE_libblock_copy(&ta->id); /* file name can be NULL */ if (ta->name) { - tan->name= MEM_mallocN(strlen(ta->name)+1, "text_name"); + tan->name = MEM_mallocN(strlen(ta->name) + 1, "text_name"); strcpy(tan->name, ta->name); } else { - tan->name= NULL; + tan->name = NULL; } tan->flags = ta->flags | TXT_ISDIRTY; - tan->lines.first= tan->lines.last= NULL; - tan->markers.first= tan->markers.last= NULL; - tan->curl= tan->sell= NULL; + tan->lines.first = tan->lines.last = NULL; + tan->markers.first = tan->markers.last = NULL; + tan->curl = tan->sell = NULL; - tan->nlines= ta->nlines; + tan->nlines = ta->nlines; - line= ta->lines.first; + line = ta->lines.first; /* Walk down, reconstructing */ while (line) { - tmp= (TextLine*) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= MEM_mallocN(line->len+1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = MEM_mallocN(line->len + 1, "textline_string"); + tmp->format = NULL; strcpy(tmp->line, line->line); - tmp->len= line->len; + tmp->len = line->len; BLI_addtail(&tan->lines, tmp); - line= line->next; + line = line->next; } - tan->curl= tan->sell= tan->lines.first; - tan->curc= tan->selc= 0; + tan->curl = tan->sell = tan->lines.first; + tan->curc = tan->selc = 0; init_undo_text(tan); return tan; } -void unlink_text(Main *bmain, Text *text) +void BKE_text_unlink(Main *bmain, Text *text) { bScreen *scr; ScrArea *area; @@ -531,27 +531,27 @@ void unlink_text(Main *bmain, Text *text) bConstraint *con; short update; - for (ob=bmain->object.first; ob; ob=ob->id.next) { + for (ob = bmain->object.first; ob; ob = ob->id.next) { /* game controllers */ - for (cont=ob->controllers.first; cont; cont=cont->next) { - if (cont->type==CONT_PYTHON) { + for (cont = ob->controllers.first; cont; cont = cont->next) { + if (cont->type == CONT_PYTHON) { bPythonCont *pc; - pc= cont->data; - if (pc->text==text) pc->text= NULL; + pc = cont->data; + if (pc->text == text) pc->text = NULL; } } /* pyconstraints */ update = 0; - if (ob->type==OB_ARMATURE && ob->pose) { + if (ob->type == OB_ARMATURE && ob->pose) { bPoseChannel *pchan; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con = pchan->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_PYTHON) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_PYTHON) { bPythonConstraint *data = con->data; - if (data->text==text) data->text = NULL; + if (data->text == text) data->text = NULL; update = 1; } @@ -559,10 +559,10 @@ void unlink_text(Main *bmain, Text *text) } } - for (con = ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_PYTHON) { + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_PYTHON) { bPythonConstraint *data = con->data; - if (data->text==text) data->text = NULL; + if (data->text == text) data->text = NULL; update = 1; } } @@ -575,25 +575,25 @@ void unlink_text(Main *bmain, Text *text) // XXX nodeDynamicUnlinkText(&text->id); /* text space */ - for (scr= bmain->screen.first; scr; scr= scr->id.next) { - for (area= scr->areabase.first; area; area= area->next) { - for (sl= area->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText*) sl; - - if (st->text==text) { - st->text= NULL; - st->top= 0; + for (scr = bmain->screen.first; scr; scr = scr->id.next) { + for (area = scr->areabase.first; area; area = area->next) { + for (sl = area->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_TEXT) { + SpaceText *st = (SpaceText *) sl; + + if (st->text == text) { + st->text = NULL; + st->top = 0; } } } } } - text->id.us= 0; + text->id.us = 0; } -void clear_text(Text *text) /* called directly from rna */ +void BKE_text_clear(Text *text) /* called directly from rna */ { int oldstate; @@ -606,7 +606,7 @@ void clear_text(Text *text) /* called directly from rna */ txt_make_dirty(text); } -void write_text(Text *text, const char *str) /* called directly from rna */ +void BKE_text_write(Text *text, const char *str) /* called directly from rna */ { int oldstate; @@ -627,25 +627,25 @@ static void make_new_line(TextLine *line, char *newline) if (line->line) MEM_freeN(line->line); if (line->format) MEM_freeN(line->format); - line->line= newline; - line->len= strlen(newline); - line->format= NULL; + line->line = newline; + line->len = strlen(newline); + line->format = NULL; } static TextLine *txt_new_line(const char *str) { TextLine *tmp; - if (!str) str= ""; + if (!str) str = ""; - tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= MEM_mallocN(strlen(str)+1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = MEM_mallocN(strlen(str) + 1, "textline_string"); + tmp->format = NULL; strcpy(tmp->line, str); - tmp->len= strlen(str); - tmp->next= tmp->prev= NULL; + tmp->len = strlen(str); + tmp->next = tmp->prev = NULL; return tmp; } @@ -654,14 +654,14 @@ static TextLine *txt_new_linen(const char *str, int n) { TextLine *tmp; - tmp= (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); - tmp->line= MEM_mallocN(n+1, "textline_string"); - tmp->format= NULL; + tmp = (TextLine *) MEM_mallocN(sizeof(TextLine), "textline"); + tmp->line = MEM_mallocN(n + 1, "textline_string"); + tmp->format = NULL; - BLI_strncpy(tmp->line, (str)? str: "", n+1); + BLI_strncpy(tmp->line, (str) ? str : "", n + 1); - tmp->len= strlen(tmp->line); - tmp->next= tmp->prev= NULL; + tmp->len = strlen(tmp->line); + tmp->next = tmp->prev = NULL; return tmp; } @@ -673,61 +673,61 @@ void txt_clean_text(Text *text) if (!text) return; if (!text->lines.first) { - if (text->lines.last) text->lines.first= text->lines.last; - else text->lines.first= text->lines.last= txt_new_line(NULL); + if (text->lines.last) text->lines.first = text->lines.last; + else text->lines.first = text->lines.last = txt_new_line(NULL); } - if (!text->lines.last) text->lines.last= text->lines.first; + if (!text->lines.last) text->lines.last = text->lines.first; - top= (TextLine **) &text->lines.first; - bot= (TextLine **) &text->lines.last; + top = (TextLine **) &text->lines.first; + bot = (TextLine **) &text->lines.last; - while ((*top)->prev) *top= (*top)->prev; - while ((*bot)->next) *bot= (*bot)->next; + while ((*top)->prev) *top = (*top)->prev; + while ((*bot)->next) *bot = (*bot)->next; if (!text->curl) { - if (text->sell) text->curl= text->sell; - else text->curl= text->lines.first; - text->curc= 0; + if (text->sell) text->curl = text->sell; + else text->curl = text->lines.first; + text->curc = 0; } if (!text->sell) { - text->sell= text->curl; - text->selc= 0; + text->sell = text->curl; + text->selc = 0; } } int txt_get_span(TextLine *from, TextLine *to) { - int ret=0; - TextLine *tmp= from; + int ret = 0; + TextLine *tmp = from; if (!to || !from) return 0; - if (from==to) return 0; + if (from == to) return 0; /* Look forwards */ while (tmp) { if (tmp == to) return ret; ret++; - tmp= tmp->next; + tmp = tmp->next; } /* Look backwards */ if (!tmp) { - tmp= from; - ret=0; + tmp = from; + ret = 0; while (tmp) { if (tmp == to) break; ret--; - tmp= tmp->prev; + tmp = tmp->prev; } - if (!tmp) ret=0; + if (!tmp) ret = 0; } return ret; } -static void txt_make_dirty (Text *text) +static void txt_make_dirty(Text *text) { text->flags |= TXT_ISDIRTY; #ifdef WITH_PYTHON @@ -739,30 +739,30 @@ static void txt_make_dirty (Text *text) /* Cursor utility functions */ /****************************/ -static void txt_curs_cur (Text *text, TextLine ***linep, int **charp) +static void txt_curs_cur(Text *text, TextLine ***linep, int **charp) { - *linep= &text->curl; *charp= &text->curc; + *linep = &text->curl; *charp = &text->curc; } -static void txt_curs_sel (Text *text, TextLine ***linep, int **charp) +static void txt_curs_sel(Text *text, TextLine ***linep, int **charp) { - *linep= &text->sell; *charp= &text->selc; + *linep = &text->sell; *charp = &text->selc; } -static void txt_curs_first (Text *text, TextLine **linep, int *charp) +static void txt_curs_first(Text *text, TextLine **linep, int *charp) { - if (text->curl==text->sell) { - *linep= text->curl; - if (text->curcselc) *charp= text->curc; - else *charp= text->selc; + if (text->curl == text->sell) { + *linep = text->curl; + if (text->curc < text->selc) *charp = text->curc; + else *charp = text->selc; } - else if (txt_get_span(text->lines.first, text->curl)lines.first, text->sell)) { - *linep= text->curl; - *charp= text->curc; + else if (txt_get_span(text->lines.first, text->curl) < txt_get_span(text->lines.first, text->sell)) { + *linep = text->curl; + *charp = text->curc; } else { - *linep= text->sell; - *charp= text->selc; + *linep = text->sell; + *charp = text->selc; } } @@ -772,7 +772,7 @@ static void txt_curs_first (Text *text, TextLine **linep, int *charp) int txt_utf8_offset_to_index(const char *str, int offset) { - int index= 0, pos= 0; + int index = 0, pos = 0; while (pos != offset) { pos += BLI_str_utf8_size(str + pos); index++; @@ -782,7 +782,7 @@ int txt_utf8_offset_to_index(const char *str, int offset) int txt_utf8_index_to_offset(const char *str, int index) { - int offset= 0, pos= 0; + int offset = 0, pos = 0; while (pos != index) { offset += BLI_str_utf8_size(str + offset); pos++; @@ -796,7 +796,7 @@ static int txt_utf8_len(const char *src) { int len; - for (len=0; *src; len++) { + for (len = 0; *src; len++) { src += BLI_str_utf8_size(src); } @@ -817,12 +817,12 @@ void txt_move_up(Text *text, short sel) if ((*linep)->prev) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); - *linep= (*linep)->prev; - if (index > txt_utf8_len((*linep)->line)) *charp= (*linep)->len; - else *charp= txt_utf8_index_to_offset((*linep)->line, index); + *linep = (*linep)->prev; + if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; + else *charp = txt_utf8_index_to_offset((*linep)->line, index); if (!undoing) - txt_undo_add_op(text, sel?UNDO_SUP:UNDO_CUP); + txt_undo_add_op(text, sel ? UNDO_SUP : UNDO_CUP); } else { txt_move_bol(text, sel); @@ -845,12 +845,12 @@ void txt_move_down(Text *text, short sel) if ((*linep)->next) { int index = txt_utf8_offset_to_index((*linep)->line, *charp); - *linep= (*linep)->next; - if (index > txt_utf8_len((*linep)->line)) *charp= (*linep)->len; - else *charp= txt_utf8_index_to_offset((*linep)->line, index); + *linep = (*linep)->next; + if (index > txt_utf8_len((*linep)->line)) *charp = (*linep)->len; + else *charp = txt_utf8_index_to_offset((*linep)->line, index); if (!undoing) - txt_undo_add_op(text, sel?UNDO_SDOWN:UNDO_CDOWN); + txt_undo_add_op(text, sel ? UNDO_SDOWN : UNDO_CDOWN); } else { txt_move_eol(text, sel); @@ -862,49 +862,49 @@ void txt_move_down(Text *text, short sel) void txt_move_left(Text *text, short sel) { TextLine **linep; - int *charp, oundoing= undoing; - int tabsize= 0, i= 0; + int *charp, oundoing = undoing; + int tabsize = 0, i = 0; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - undoing= 1; + undoing = 1; - if (*charp== 0) { + if (*charp == 0) { if ((*linep)->prev) { txt_move_up(text, sel); - *charp= (*linep)->len; + *charp = (*linep)->len; } } else { // do nice left only if there are only spaces // TXT_TABSIZE hardcoded in DNA_text_types.h if (text->flags & TXT_TABSTOSPACES) { - tabsize= (*charp < TXT_TABSIZE) ? *charp : TXT_TABSIZE; + tabsize = (*charp < TXT_TABSIZE) ? *charp : TXT_TABSIZE; - for (i=0; i<(*charp); i++) + for (i = 0; i < (*charp); i++) if ((*linep)->line[i] != ' ') { - tabsize= 0; + tabsize = 0; break; } // if in the middle of the space-tab if (tabsize && (*charp) % TXT_TABSIZE != 0) - tabsize= ((*charp) % TXT_TABSIZE); + tabsize = ((*charp) % TXT_TABSIZE); } if (tabsize) - (*charp)-= tabsize; + (*charp) -= tabsize; else { - const char *prev= BLI_str_prev_char_utf8((*linep)->line + *charp); - *charp= prev - (*linep)->line; + const char *prev = BLI_str_prev_char_utf8((*linep)->line + *charp); + *charp = prev - (*linep)->line; } } - undoing= oundoing; - if (!undoing) txt_undo_add_op(text, sel?UNDO_SLEFT:UNDO_CLEFT); + undoing = oundoing; + if (!undoing) txt_undo_add_op(text, sel ? UNDO_SLEFT : UNDO_CLEFT); if (!sel) txt_pop_sel(text); } @@ -912,104 +912,90 @@ void txt_move_left(Text *text, short sel) void txt_move_right(Text *text, short sel) { TextLine **linep; - int *charp, oundoing= undoing, do_tab= 0, i; + int *charp, oundoing = undoing, do_tab = 0, i; if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - undoing= 1; + undoing = 1; - if (*charp== (*linep)->len) { + if (*charp == (*linep)->len) { if ((*linep)->next) { txt_move_down(text, sel); - *charp= 0; + *charp = 0; } } else { // do nice right only if there are only spaces // spaces hardcoded in DNA_text_types.h - if (text->flags & TXT_TABSTOSPACES && (*linep)->line[*charp]== ' ') { - do_tab= 1; - for (i=0; i<*charp; i++) - if ((*linep)->line[i]!= ' ') { - do_tab= 0; + if (text->flags & TXT_TABSTOSPACES && (*linep)->line[*charp] == ' ') { + do_tab = 1; + for (i = 0; i < *charp; i++) + if ((*linep)->line[i] != ' ') { + do_tab = 0; break; } } if (do_tab) { - int tabsize= (*charp) % TXT_TABSIZE + 1; - for (i=*charp+1; (*linep)->line[i]==' ' && tabsizeline[i] == ' ' && tabsize < TXT_TABSIZE; i++) tabsize++; - (*charp)= i; + (*charp) = i; } - else (*charp)+= BLI_str_utf8_size((*linep)->line + *charp); + else (*charp) += BLI_str_utf8_size((*linep)->line + *charp); } - undoing= oundoing; - if (!undoing) txt_undo_add_op(text, sel?UNDO_SRIGHT:UNDO_CRIGHT); + undoing = oundoing; + if (!undoing) txt_undo_add_op(text, sel ? UNDO_SRIGHT : UNDO_CRIGHT); if (!sel) txt_pop_sel(text); } void txt_jump_left(Text *text, short sel) { - TextLine **linep, *oldl; - int *charp, oldc, oldflags; - unsigned char oldu; - + TextLine **linep; + int *charp, oldc; + if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_first(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - - oldflags = text->flags; - text->flags &= ~TXT_TABSTOSPACES; - - oldl= *linep; - oldc= *charp; - oldu= undoing; - undoing= 1; /* Don't push individual moves to undo stack */ + oldc = *charp; BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, - charp, STRCUR_DIR_PREV, + charp, STRCUR_DIR_PREV, STRCUR_JUMP_DELIM); - - text->flags = oldflags; - - undoing= oldu; - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + + if (!sel) txt_pop_sel(text); + if (!undoing) { + int span = txt_get_span(text->lines.first, *linep); + txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp); + } } void txt_jump_right(Text *text, short sel) { - TextLine **linep, *oldl; - int *charp, oldc, oldflags; - unsigned char oldu; - + TextLine **linep; + int *charp, oldc; + if (!text) return; if (sel) txt_curs_sel(text, &linep, &charp); else { txt_pop_last(text); txt_curs_cur(text, &linep, &charp); } if (!*linep) return; - - oldflags = text->flags; - text->flags &= ~TXT_TABSTOSPACES; - - oldl= *linep; - oldc= *charp; - oldu= undoing; - undoing= 1; /* Don't push individual moves to undo stack */ - + oldc = *charp; + BLI_str_cursor_step_utf8((*linep)->line, (*linep)->len, - charp, STRCUR_DIR_NEXT, + charp, STRCUR_DIR_NEXT, STRCUR_JUMP_DELIM); - - text->flags = oldflags; - - undoing= oldu; - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + + if (!sel) txt_pop_sel(text); + if (!undoing) { + int span = txt_get_span(text->lines.first, *linep); + txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, span, oldc, span, (unsigned short)*charp); + } } void txt_move_bol(Text *text, short sel) @@ -1021,12 +1007,12 @@ void txt_move_bol(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *charp= 0; + *charp = 0; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_eol(Text *text, short sel) @@ -1038,12 +1024,12 @@ void txt_move_eol(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *charp= (*linep)->len; + *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_bof(Text *text, short sel) @@ -1055,13 +1041,13 @@ void txt_move_bof(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *linep= text->lines.first; - *charp= 0; + *linep = text->lines.first; + *charp = 0; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_eof(Text *text, short sel) @@ -1073,13 +1059,13 @@ void txt_move_eof(Text *text, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - old= *charp; + old = *charp; - *linep= text->lines.last; - *charp= (*linep)->len; + *linep = text->lines.last; + *charp = (*linep)->len; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, *linep), old, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } void txt_move_toline(Text *text, unsigned int line, short sel) @@ -1098,71 +1084,71 @@ void txt_move_to(Text *text, unsigned int line, unsigned int ch, short sel) if (sel) txt_curs_sel(text, &linep, &charp); else txt_curs_cur(text, &linep, &charp); if (!*linep) return; - oldc= *charp; - oldl= *linep; + oldc = *charp; + oldl = *linep; - *linep= text->lines.first; - for (i=0; inext) *linep= (*linep)->next; + *linep = text->lines.first; + for (i = 0; i < line; i++) { + if ((*linep)->next) *linep = (*linep)->next; else break; } - if (ch>(unsigned int)((*linep)->len)) - ch= (unsigned int)((*linep)->len); - *charp= ch; + if (ch > (unsigned int)((*linep)->len)) + ch = (unsigned int)((*linep)->len); + *charp = ch; if (!sel) txt_pop_sel(text); - if (!undoing) txt_undo_add_toop(text, sel?UNDO_STO:UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); + if (!undoing) txt_undo_add_toop(text, sel ? UNDO_STO : UNDO_CTO, txt_get_span(text->lines.first, oldl), oldc, txt_get_span(text->lines.first, *linep), (unsigned short)*charp); } /****************************/ /* Text selection functions */ /****************************/ -static void txt_curs_swap (Text *text) +static void txt_curs_swap(Text *text) { TextLine *tmpl; int tmpc; - tmpl= text->curl; - text->curl= text->sell; - text->sell= tmpl; - - tmpc= text->curc; - text->curc= text->selc; - text->selc= tmpc; + tmpl = text->curl; + text->curl = text->sell; + text->sell = tmpl; + + tmpc = text->curc; + text->curc = text->selc; + text->selc = tmpc; if (!undoing) txt_undo_add_op(text, UNDO_SWAP); } -static void txt_pop_first (Text *text) +static void txt_pop_first(Text *text) { - if (txt_get_span(text->curl, text->sell)<0 || - (text->curl==text->sell && text->curc>text->selc)) { + if (txt_get_span(text->curl, text->sell) < 0 || + (text->curl == text->sell && text->curc > text->selc)) { txt_curs_swap(text); } if (!undoing) txt_undo_add_toop(text, UNDO_STO, - txt_get_span(text->lines.first, text->sell), - text->selc, - txt_get_span(text->lines.first, text->curl), - text->curc); + txt_get_span(text->lines.first, text->sell), + text->selc, + txt_get_span(text->lines.first, text->curl), + text->curc); txt_pop_sel(text); } -static void txt_pop_last (Text *text) +static void txt_pop_last(Text *text) { - if (txt_get_span(text->curl, text->sell)>0 || - (text->curl==text->sell && text->curcselc)) { + if (txt_get_span(text->curl, text->sell) > 0 || + (text->curl == text->sell && text->curc < text->selc)) { txt_curs_swap(text); } if (!undoing) txt_undo_add_toop(text, UNDO_STO, - txt_get_span(text->lines.first, text->sell), - text->selc, - txt_get_span(text->lines.first, text->curl), - text->curc); + txt_get_span(text->lines.first, text->sell), + text->selc, + txt_get_span(text->lines.first, text->curl), + text->curc); txt_pop_sel(text); } @@ -1172,8 +1158,8 @@ static void txt_pop_last (Text *text) void txt_pop_sel(Text *text) { - text->sell= text->curl; - text->selc= text->curc; + text->sell = text->curl; + text->selc = text->curc; } void txt_order_cursors(Text *text) @@ -1182,7 +1168,7 @@ void txt_order_cursors(Text *text) if (!text->curl) return; if (!text->sell) return; - /* Flip so text->curl is before text->sell */ + /* Flip so text->curl is before text->sell */ if ((txt_get_span(text->curl, text->sell) < 0) || (text->curl == text->sell && text->curc > text->selc)) { @@ -1192,10 +1178,10 @@ void txt_order_cursors(Text *text) int txt_has_sel(Text *text) { - return ((text->curl!=text->sell) || (text->curc!=text->selc)); + return ((text->curl != text->sell) || (text->curc != text->selc)); } -static void txt_delete_sel (Text *text) +static void txt_delete_sel(Text *text) { TextLine *tmpl; TextMarker *mrk; @@ -1211,62 +1197,62 @@ static void txt_delete_sel (Text *text) txt_order_cursors(text); if (!undoing) { - buf= txt_sel_to_buf(text); + buf = txt_sel_to_buf(text); txt_undo_add_block(text, UNDO_DBLOCK, buf); MEM_freeN(buf); } - buf= MEM_mallocN(text->curc+(text->sell->len - text->selc)+1, "textline_string"); + buf = MEM_mallocN(text->curc + (text->sell->len - text->selc) + 1, "textline_string"); if (text->curl != text->sell) { txt_clear_marker_region(text, text->curl, text->curc, text->curl->len, 0, 0); - move= txt_get_span(text->curl, text->sell); + move = txt_get_span(text->curl, text->sell); } else { - mrk= txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc, text->selc, 0, 0); if (mrk && (mrk->start > text->curc || mrk->end < text->selc)) txt_clear_marker_region(text, text->curl, text->curc, text->selc, 0, 0); - move= 0; + move = 0; } - mrk= txt_find_marker_region(text, text->sell, text->selc-1, text->sell->len, 0, 0); + mrk = txt_find_marker_region(text, text->sell, text->selc - 1, text->sell->len, 0, 0); if (mrk) { - lineno= mrk->lineno; + lineno = mrk->lineno; do { mrk->lineno -= move; if (mrk->start > text->curc) mrk->start -= text->selc - text->curc; mrk->end -= text->selc - text->curc; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } strncpy(buf, text->curl->line, text->curc); - strcpy(buf+text->curc, text->sell->line + text->selc); - buf[text->curc+(text->sell->len - text->selc)]=0; + strcpy(buf + text->curc, text->sell->line + text->selc); + buf[text->curc + (text->sell->len - text->selc)] = 0; make_new_line(text->curl, buf); - tmpl= text->sell; + tmpl = text->sell; while (tmpl != text->curl) { - tmpl= tmpl->prev; + tmpl = tmpl->prev; if (!tmpl) break; txt_delete_line(text, tmpl->next); } - text->sell= text->curl; - text->selc= text->curc; + text->sell = text->curl; + text->selc = text->curc; } void txt_sel_all(Text *text) { if (!text) return; - text->curl= text->lines.first; - text->curc= 0; + text->curl = text->lines.first; + text->curc = 0; - text->sell= text->lines.last; - text->selc= text->sell->len; + text->sell = text->lines.last; + text->selc = text->sell->len; } void txt_sel_line(Text *text) @@ -1274,16 +1260,16 @@ void txt_sel_line(Text *text) if (!text) return; if (!text->curl) return; - text->curc= 0; - text->sell= text->curl; - text->selc= text->sell->len; + text->curc = 0; + text->sell = text->curl; + text->selc = text->sell->len; } /***************************/ /* Cut and paste functions */ /***************************/ -char *txt_to_buf (Text *text) +char *txt_to_buf(Text *text) { int length; TextLine *tmp, *linef, *linel; @@ -1295,53 +1281,53 @@ char *txt_to_buf (Text *text) if (!text->sell) return NULL; if (!text->lines.first) return NULL; - linef= text->lines.first; - charf= 0; + linef = text->lines.first; + charf = 0; - linel= text->lines.last; - charl= linel->len; + linel = text->lines.last; + charl = linel->len; if (linef == text->lines.last) { - length= charl-charf; + length = charl - charf; - buf= MEM_mallocN(length+2, "text buffer"); + buf = MEM_mallocN(length + 2, "text buffer"); - BLI_strncpy(buf, linef->line + charf, length+1); - buf[length]=0; + BLI_strncpy(buf, linef->line + charf, length + 1); + buf[length] = 0; } else { - length= linef->len - charf; - length+= charl; - length+= 2; /* For the 2 '\n' */ + length = linef->len - charf; + length += charl; + length += 2; /* For the 2 '\n' */ - tmp= linef->next; - while (tmp && tmp!= linel) { - length+= tmp->len+1; - tmp= tmp->next; + tmp = linef->next; + while (tmp && tmp != linel) { + length += tmp->len + 1; + tmp = tmp->next; } - buf= MEM_mallocN(length+1, "cut buffer"); + buf = MEM_mallocN(length + 1, "cut buffer"); - strncpy(buf, linef->line + charf, linef->len-charf); - length= linef->len - charf; + strncpy(buf, linef->line + charf, linef->len - charf); + length = linef->len - charf; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= linef->next; - while (tmp && tmp!=linel) { - strncpy(buf+length, tmp->line, tmp->len); - length+= tmp->len; + tmp = linef->next; + while (tmp && tmp != linel) { + strncpy(buf + length, tmp->line, tmp->len); + length += tmp->len; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= tmp->next; + tmp = tmp->next; } - strncpy(buf+length, linel->line, charl); - length+= charl; + strncpy(buf + length, linel->line, charl); + length += charl; /* python compiler wants an empty end line */ - buf[length++]='\n'; - buf[length]=0; + buf[length++] = '\n'; + buf[length] = 0; } return buf; @@ -1350,34 +1336,34 @@ char *txt_to_buf (Text *text) int txt_find_string(Text *text, const char *findstr, int wrap, int match_case) { TextLine *tl, *startl; - char *s= NULL; + char *s = NULL; if (!text || !text->curl || !text->sell) return 0; txt_order_cursors(text); - tl= startl= text->sell; + tl = startl = text->sell; - if (match_case) s= strstr(&tl->line[text->selc], findstr); - else s= BLI_strcasestr(&tl->line[text->selc], findstr); + if (match_case) s = strstr(&tl->line[text->selc], findstr); + else s = BLI_strcasestr(&tl->line[text->selc], findstr); while (!s) { - tl= tl->next; + tl = tl->next; if (!tl) { if (wrap) - tl= text->lines.first; + tl = text->lines.first; else break; } - if (match_case) s= strstr(tl->line, findstr); - else s= BLI_strcasestr(tl->line, findstr); - if (tl==startl) + if (match_case) s = strstr(tl->line, findstr); + else s = BLI_strcasestr(tl->line, findstr); + if (tl == startl) break; } if (s) { - int newl= txt_get_span(text->lines.first, tl); - int newc= (int)(s-tl->line); + int newl = txt_get_span(text->lines.first, tl); + int newc = (int)(s - tl->line); txt_move_to(text, newl, newc, 0); txt_move_to(text, newl, newc + strlen(findstr), 1); return 1; @@ -1386,10 +1372,10 @@ int txt_find_string(Text *text, const char *findstr, int wrap, int match_case) return 0; } -char *txt_sel_to_buf (Text *text) +char *txt_sel_to_buf(Text *text) { char *buf; - int length=0; + int length = 0; TextLine *tmp, *linef, *linel; int charf, charl; @@ -1397,71 +1383,71 @@ char *txt_sel_to_buf (Text *text) if (!text->curl) return NULL; if (!text->sell) return NULL; - if (text->curl==text->sell) { - linef= linel= text->curl; + if (text->curl == text->sell) { + linef = linel = text->curl; if (text->curc < text->selc) { - charf= text->curc; - charl= text->selc; + charf = text->curc; + charl = text->selc; } else { - charf= text->selc; - charl= text->curc; + charf = text->selc; + charl = text->curc; } } - else if (txt_get_span(text->curl, text->sell)<0) { - linef= text->sell; - linel= text->curl; + else if (txt_get_span(text->curl, text->sell) < 0) { + linef = text->sell; + linel = text->curl; - charf= text->selc; - charl= text->curc; + charf = text->selc; + charl = text->curc; } else { - linef= text->curl; - linel= text->sell; + linef = text->curl; + linel = text->sell; - charf= text->curc; - charl= text->selc; + charf = text->curc; + charl = text->selc; } if (linef == linel) { - length= charl-charf; + length = charl - charf; - buf= MEM_mallocN(length+1, "sel buffer"); + buf = MEM_mallocN(length + 1, "sel buffer"); - BLI_strncpy(buf, linef->line + charf, length+1); + BLI_strncpy(buf, linef->line + charf, length + 1); } else { - length+= linef->len - charf; - length+= charl; + length += linef->len - charf; + length += charl; length++; /* For the '\n' */ - tmp= linef->next; - while (tmp && tmp!= linel) { - length+= tmp->len+1; - tmp= tmp->next; + tmp = linef->next; + while (tmp && tmp != linel) { + length += tmp->len + 1; + tmp = tmp->next; } - buf= MEM_mallocN(length+1, "sel buffer"); + buf = MEM_mallocN(length + 1, "sel buffer"); - strncpy(buf, linef->line+ charf, linef->len-charf); - length= linef->len-charf; + strncpy(buf, linef->line + charf, linef->len - charf); + length = linef->len - charf; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= linef->next; - while (tmp && tmp!=linel) { - strncpy(buf+length, tmp->line, tmp->len); - length+= tmp->len; + tmp = linef->next; + while (tmp && tmp != linel) { + strncpy(buf + length, tmp->line, tmp->len); + length += tmp->len; - buf[length++]='\n'; + buf[length++] = '\n'; - tmp= tmp->next; + tmp = tmp->next; } - strncpy(buf+length, linel->line, charl); - length+= charl; + strncpy(buf + length, linel->line, charl); + length += charl; - buf[length]=0; + buf[length] = 0; } return buf; @@ -1471,16 +1457,16 @@ static void txt_shift_markers(Text *text, int lineno, int count) { TextMarker *marker; - for (marker=text->markers.first; marker; marker= marker->next) - if (marker->lineno>=lineno) { - marker->lineno+= count; + for (marker = text->markers.first; marker; marker = marker->next) + if (marker->lineno >= lineno) { + marker->lineno += count; } } void txt_insert_buf(Text *text, const char *in_buffer) { - int l=0, u, len, lineno= -1, count= 0; - size_t i=0, j; + int l = 0, u, len, lineno = -1, count = 0; + size_t i = 0, j; TextLine *add; char *buffer; @@ -1489,35 +1475,35 @@ void txt_insert_buf(Text *text, const char *in_buffer) txt_delete_sel(text); - len= strlen(in_buffer); - buffer= BLI_strdupn(in_buffer, len); - len+= txt_extended_ascii_as_utf8(&buffer); + len = strlen(in_buffer); + buffer = BLI_strdupn(in_buffer, len); + len += txt_extended_ascii_as_utf8(&buffer); if (!undoing) txt_undo_add_block(text, UNDO_IBLOCK, buffer); - u= undoing; - undoing= 1; + u = undoing; + undoing = 1; /* Read the first line (or as close as possible */ - while (buffer[i] && buffer[i]!='\n') + while (buffer[i] && buffer[i] != '\n') txt_add_raw_char(text, BLI_str_utf8_as_unicode_step(buffer, &i)); - if (buffer[i]=='\n') txt_split_curline(text); + if (buffer[i] == '\n') txt_split_curline(text); else { undoing = u; MEM_freeN(buffer); return; } i++; /* Read as many full lines as we can */ - lineno= txt_get_span(text->lines.first, text->curl); + lineno = txt_get_span(text->lines.first, text->curl); - while (ilines, text->curl, add); i++; count++; @@ -1525,10 +1511,10 @@ void txt_insert_buf(Text *text, const char *in_buffer) else { if (count) { txt_shift_markers(text, lineno, count); - count= 0; + count = 0; } - for (j= i-l; jundo_pos+x >= text->undo_len) { - if (text->undo_len*2 > TXT_MAX_UNDO) { + while (text->undo_pos + x >= text->undo_len) { + if (text->undo_len * 2 > TXT_MAX_UNDO) { /* XXX error("Undo limit reached, buffer cleared\n"); */ MEM_freeN(text->undo_buf); init_undo_text(text); return 0; } else { - void *tmp= text->undo_buf; - text->undo_buf= MEM_callocN(text->undo_len*2, "undo buf"); + void *tmp = text->undo_buf; + text->undo_buf = MEM_callocN(text->undo_len * 2, "undo buf"); memcpy(text->undo_buf, tmp, text->undo_len); - text->undo_len*=2; + text->undo_len *= 2; MEM_freeN(tmp); } } @@ -1570,218 +1556,218 @@ static int max_undo_test(Text *text, int x) static void dump_buffer(Text *text) { - int i= 0; + int i = 0; - while (i++undo_pos) printf("%d: %d %c\n", i, text->undo_buf[i], text->undo_buf[i]); + while (i++ < text->undo_pos) printf("%d: %d %c\n", i, text->undo_buf[i], text->undo_buf[i]); } void txt_print_undo(Text *text) { - int i= 0; + int i = 0; int op; const char *ops; int linep, charp; dump_buffer(text); - printf ("---< Undo Buffer >---\n"); + printf("---< Undo Buffer >---\n"); - printf ("UndoPosition is %d\n", text->undo_pos); + printf("UndoPosition is %d\n", text->undo_pos); - while (i<=text->undo_pos) { - op= text->undo_buf[i]; + while (i <= text->undo_pos) { + op = text->undo_buf[i]; - if (op==UNDO_CLEFT) { - ops= "Cursor left"; + if (op == UNDO_CLEFT) { + ops = "Cursor left"; } - else if (op==UNDO_CRIGHT) { - ops= "Cursor right"; + else if (op == UNDO_CRIGHT) { + ops = "Cursor right"; } - else if (op==UNDO_CUP) { - ops= "Cursor up"; + else if (op == UNDO_CUP) { + ops = "Cursor up"; } - else if (op==UNDO_CDOWN) { - ops= "Cursor down"; + else if (op == UNDO_CDOWN) { + ops = "Cursor down"; } - else if (op==UNDO_SLEFT) { - ops= "Selection left"; + else if (op == UNDO_SLEFT) { + ops = "Selection left"; } - else if (op==UNDO_SRIGHT) { - ops= "Selection right"; + else if (op == UNDO_SRIGHT) { + ops = "Selection right"; } - else if (op==UNDO_SUP) { - ops= "Selection up"; + else if (op == UNDO_SUP) { + ops = "Selection up"; } - else if (op==UNDO_SDOWN) { - ops= "Selection down"; + else if (op == UNDO_SDOWN) { + ops = "Selection down"; } - else if (op==UNDO_STO) { - ops= "Selection "; + else if (op == UNDO_STO) { + ops = "Selection "; } - else if (op==UNDO_CTO) { - ops= "Cursor "; + else if (op == UNDO_CTO) { + ops = "Cursor "; } - else if (op==UNDO_INSERT_1) { - ops= "Insert ascii "; + else if (op == UNDO_INSERT_1) { + ops = "Insert ascii "; } - else if (op==UNDO_INSERT_2) { - ops= "Insert 2 bytes "; + else if (op == UNDO_INSERT_2) { + ops = "Insert 2 bytes "; } - else if (op==UNDO_INSERT_3) { - ops= "Insert 3 bytes "; + else if (op == UNDO_INSERT_3) { + ops = "Insert 3 bytes "; } - else if (op==UNDO_INSERT_4) { - ops= "Insert unicode "; + else if (op == UNDO_INSERT_4) { + ops = "Insert unicode "; } - else if (op==UNDO_BS_1) { - ops= "Backspace for ascii "; + else if (op == UNDO_BS_1) { + ops = "Backspace for ascii "; } - else if (op==UNDO_BS_2) { - ops= "Backspace for 2 bytes "; + else if (op == UNDO_BS_2) { + ops = "Backspace for 2 bytes "; } - else if (op==UNDO_BS_3) { - ops= "Backspace for 3 bytes "; + else if (op == UNDO_BS_3) { + ops = "Backspace for 3 bytes "; } - else if (op==UNDO_BS_4) { - ops= "Backspace for unicode "; + else if (op == UNDO_BS_4) { + ops = "Backspace for unicode "; } - else if (op==UNDO_DEL_1) { - ops= "Delete ascii "; + else if (op == UNDO_DEL_1) { + ops = "Delete ascii "; } - else if (op==UNDO_DEL_2) { - ops= "Delete 2 bytes "; + else if (op == UNDO_DEL_2) { + ops = "Delete 2 bytes "; } - else if (op==UNDO_DEL_3) { - ops= "Delete 3 bytes "; + else if (op == UNDO_DEL_3) { + ops = "Delete 3 bytes "; } - else if (op==UNDO_DEL_4) { - ops= "Delete unicode "; + else if (op == UNDO_DEL_4) { + ops = "Delete unicode "; } - else if (op==UNDO_SWAP) { - ops= "Cursor swap"; + else if (op == UNDO_SWAP) { + ops = "Cursor swap"; } - else if (op==UNDO_DBLOCK) { - ops= "Delete text block"; + else if (op == UNDO_DBLOCK) { + ops = "Delete text block"; } - else if (op==UNDO_IBLOCK) { - ops= "Insert text block"; + else if (op == UNDO_IBLOCK) { + ops = "Insert text block"; } - else if (op==UNDO_INDENT) { - ops= "Indent "; + else if (op == UNDO_INDENT) { + ops = "Indent "; } - else if (op==UNDO_UNINDENT) { - ops= "Unindent "; + else if (op == UNDO_UNINDENT) { + ops = "Unindent "; } - else if (op==UNDO_COMMENT) { - ops= "Comment "; + else if (op == UNDO_COMMENT) { + ops = "Comment "; } - else if (op==UNDO_UNCOMMENT) { - ops= "Uncomment "; + else if (op == UNDO_UNCOMMENT) { + ops = "Uncomment "; } else { - ops= "Unknown"; + ops = "Unknown"; } - printf ("Op (%o) at %d = %s", op, i, ops); + printf("Op (%o) at %d = %s", op, i, ops); if (op >= UNDO_INSERT_1 && op <= UNDO_DEL_4) { i++; - printf (" - Char is "); + printf(" - Char is "); switch (op) { case UNDO_INSERT_1: case UNDO_BS_1: case UNDO_DEL_1: - printf ("%c", text->undo_buf[i]); + printf("%c", text->undo_buf[i]); i++; break; case UNDO_INSERT_2: case UNDO_BS_2: case UNDO_DEL_2: - printf ("%c%c", text->undo_buf[i], text->undo_buf[i+1]); - i+=2; + printf("%c%c", text->undo_buf[i], text->undo_buf[i + 1]); + i += 2; break; case UNDO_INSERT_3: case UNDO_BS_3: case UNDO_DEL_3: - printf ("%c%c%c", text->undo_buf[i], text->undo_buf[i+1], text->undo_buf[i+2]); - i+=3; + printf("%c%c%c", text->undo_buf[i], text->undo_buf[i + 1], text->undo_buf[i + 2]); + i += 3; break; case UNDO_INSERT_4: case UNDO_BS_4: case UNDO_DEL_4: { unsigned int uc; - char c[BLI_UTF8_MAX+1]; + char c[BLI_UTF8_MAX + 1]; size_t c_len; - uc= text->undo_buf[i]; i++; - uc= uc+(text->undo_buf[i]<<8); i++; - uc= uc+(text->undo_buf[i]<<16); i++; - uc= uc+(text->undo_buf[i]<<24); i++; - c_len= BLI_str_utf8_from_unicode(uc, c); - c[c_len]= '\0'; + uc = text->undo_buf[i]; i++; + uc = uc + (text->undo_buf[i] << 8); i++; + uc = uc + (text->undo_buf[i] << 16); i++; + uc = uc + (text->undo_buf[i] << 24); i++; + c_len = BLI_str_utf8_from_unicode(uc, c); + c[c_len] = '\0'; puts(c); } } } - else if (op==UNDO_STO || op==UNDO_CTO) { + else if (op == UNDO_STO || op == UNDO_CTO) { i++; - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("to <%d, %d> ", linep, charp); + printf("to <%d, %d> ", linep, charp); - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("from <%d, %d>", linep, charp); + printf("from <%d, %d>", linep, charp); } - else if (op==UNDO_DBLOCK || op==UNDO_IBLOCK) { + else if (op == UNDO_DBLOCK || op == UNDO_IBLOCK) { i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf (" (length %d) <", linep); + printf(" (length %d) <", linep); - while (linep>0) { + while (linep > 0) { putchar(text->undo_buf[i]); linep--; i++; } - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; - printf ("> (%d)", linep); + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; + printf("> (%d)", linep); } - else if (op==UNDO_INDENT || op==UNDO_UNINDENT) { + else if (op == UNDO_INDENT || op == UNDO_UNINDENT) { i++; - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("to <%d, %d> ", linep, charp); + printf("to <%d, %d> ", linep, charp); - charp= text->undo_buf[i]; i++; - charp= charp+(text->undo_buf[i]<<8); i++; + charp = text->undo_buf[i]; i++; + charp = charp + (text->undo_buf[i] << 8); i++; - linep= text->undo_buf[i]; i++; - linep= linep+(text->undo_buf[i]<<8); i++; - linep= linep+(text->undo_buf[i]<<16); i++; - linep= linep+(text->undo_buf[i]<<24); i++; + linep = text->undo_buf[i]; i++; + linep = linep + (text->undo_buf[i] << 8); i++; + linep = linep + (text->undo_buf[i] << 16); i++; + linep = linep + (text->undo_buf[i] << 24); i++; - printf ("from <%d, %d>", linep, charp); + printf("from <%d, %d>", linep, charp); } - printf (" %d\n", i); + printf(" %d\n", i); i++; } } @@ -1792,50 +1778,50 @@ static void txt_undo_add_op(Text *text, int op) return; text->undo_pos++; - text->undo_buf[text->undo_pos]= op; - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos] = op; + text->undo_buf[text->undo_pos + 1] = 0; } static void txt_undo_store_uint16(char *undo_buf, int *undo_pos, unsigned short value) { - undo_buf[*undo_pos]= (value)&0xff; + undo_buf[*undo_pos] = (value) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>8)&0xff; + undo_buf[*undo_pos] = (value >> 8) & 0xff; (*undo_pos)++; } static void txt_undo_store_uint32(char *undo_buf, int *undo_pos, unsigned int value) { - undo_buf[*undo_pos]= (value)&0xff; + undo_buf[*undo_pos] = (value) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>8)&0xff; + undo_buf[*undo_pos] = (value >> 8) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>16)&0xff; + undo_buf[*undo_pos] = (value >> 16) & 0xff; (*undo_pos)++; - undo_buf[*undo_pos]= (value>>24)&0xff; + undo_buf[*undo_pos] = (value >> 24) & 0xff; (*undo_pos)++; } static void txt_undo_add_block(Text *text, int op, const char *buf) { - unsigned int length= strlen(buf); + unsigned int length = strlen(buf); - if (!max_undo_test(text, length+11)) + if (!max_undo_test(text, length + 11)) return; text->undo_pos++; - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; text->undo_pos++; txt_undo_store_uint32(text->undo_buf, &text->undo_pos, length); - strncpy(text->undo_buf+text->undo_pos, buf, length); - text->undo_pos+=length; + strncpy(text->undo_buf + text->undo_pos, buf, length); + text->undo_pos += length; txt_undo_store_uint32(text->undo_buf, &text->undo_pos, length); - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos + 1] = 0; } void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fromc, unsigned int tol, unsigned short toc) @@ -1843,10 +1829,10 @@ void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fr if (!max_undo_test(text, 15)) return; - if (froml==tol && fromc==toc) return; + if (froml == tol && fromc == toc) return; text->undo_pos++; - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; text->undo_pos++; @@ -1855,9 +1841,9 @@ void txt_undo_add_toop(Text *text, int op, unsigned int froml, unsigned short fr txt_undo_store_uint16(text->undo_buf, &text->undo_pos, toc); txt_undo_store_uint32(text->undo_buf, &text->undo_pos, tol); - text->undo_buf[text->undo_pos]= op; + text->undo_buf[text->undo_pos] = op; - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos + 1] = 0; } static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) @@ -1871,48 +1857,48 @@ static void txt_undo_add_charop(Text *text, int op_start, unsigned int c) text->undo_pos++; if (utf8_size < 4) { - text->undo_buf[text->undo_pos]= op_start + utf8_size - 1; + text->undo_buf[text->undo_pos] = op_start + utf8_size - 1; text->undo_pos++; for (i = 0; i < utf8_size; i++) { - text->undo_buf[text->undo_pos]= utf8[i]; + text->undo_buf[text->undo_pos] = utf8[i]; text->undo_pos++; } - text->undo_buf[text->undo_pos]= op_start + utf8_size - 1; + text->undo_buf[text->undo_pos] = op_start + utf8_size - 1; } else { - text->undo_buf[text->undo_pos]= op_start + 3; + text->undo_buf[text->undo_pos] = op_start + 3; text->undo_pos++; txt_undo_store_uint32(text->undo_buf, &text->undo_pos, c); - text->undo_buf[text->undo_pos]= op_start + 3; + text->undo_buf[text->undo_pos] = op_start + 3; } - text->undo_buf[text->undo_pos+1]= 0; + text->undo_buf[text->undo_pos + 1] = 0; } static unsigned short txt_undo_read_uint16(const char *undo_buf, int *undo_pos) { unsigned short val; - val= undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; + val = undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; return val; } static unsigned int txt_undo_read_uint32(const char *undo_buf, int *undo_pos) { unsigned int val; - val= undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; - val= (val<<8)+undo_buf[*undo_pos]; (*undo_pos)--; + val = undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; + val = (val << 8) + undo_buf[*undo_pos]; (*undo_pos)--; return val; } static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, short bytes) { unsigned int unicode; - char utf8[BLI_UTF8_MAX+1]; + char utf8[BLI_UTF8_MAX + 1]; switch (bytes) { case 1: /* ascii */ @@ -1922,21 +1908,21 @@ static unsigned int txt_undo_read_unicode(const char *undo_buf, int *undo_pos, s utf8[2] = '\0'; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)--; utf8[0] = undo_buf[*undo_pos]; (*undo_pos)--; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 3: /* 3-byte symbol */ utf8[3] = '\0'; utf8[2] = undo_buf[*undo_pos]; (*undo_pos)--; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)--; utf8[0] = undo_buf[*undo_pos]; (*undo_pos)--; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 4: /* 32-bit unicode symbol */ - unicode= txt_undo_read_uint32(undo_buf, undo_pos); + unicode = txt_undo_read_uint32(undo_buf, undo_pos); default: /* should never happen */ BLI_assert(0); - unicode= 0; + unicode = 0; } return unicode; @@ -1946,24 +1932,24 @@ static unsigned short txt_redo_read_uint16(const char *undo_buf, int *undo_pos) { unsigned short val; val = undo_buf[*undo_pos]; (*undo_pos)++; - val = val+(undo_buf[*undo_pos]<<8); (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 8); (*undo_pos)++; return val; } static unsigned int txt_redo_read_uint32(const char *undo_buf, int *undo_pos) { unsigned int val; - val= undo_buf[*undo_pos]; (*undo_pos)++; - val= val+(undo_buf[*undo_pos]<<8); (*undo_pos)++; - val= val+(undo_buf[*undo_pos]<<16); (*undo_pos)++; - val= val+(undo_buf[*undo_pos]<<24); (*undo_pos)++; + val = undo_buf[*undo_pos]; (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 8); (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 16); (*undo_pos)++; + val = val + (undo_buf[*undo_pos] << 24); (*undo_pos)++; return val; } static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, short bytes) { unsigned int unicode; - char utf8[BLI_UTF8_MAX+1]; + char utf8[BLI_UTF8_MAX + 1]; switch (bytes) { case 1: /* ascii */ @@ -1973,21 +1959,21 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s utf8[0] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[2] = '\0'; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 3: /* 3-byte symbol */ utf8[0] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[1] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[2] = undo_buf[*undo_pos]; (*undo_pos)++; utf8[3] = '\0'; - unicode= BLI_str_utf8_as_unicode(utf8); + unicode = BLI_str_utf8_as_unicode(utf8); break; case 4: /* 32-bit unicode symbol */ - unicode= txt_undo_read_uint32(undo_buf, undo_pos); + unicode = txt_undo_read_uint32(undo_buf, undo_pos); default: /* should never happen */ BLI_assert(0); - unicode= 0; + unicode = 0; } return unicode; @@ -1995,20 +1981,20 @@ static unsigned int txt_redo_read_unicode(const char *undo_buf, int *undo_pos, s void txt_do_undo(Text *text) { - int op= text->undo_buf[text->undo_pos]; + int op = text->undo_buf[text->undo_pos]; unsigned int linep, i; unsigned short charp; TextLine *holdl; int holdc, holdln; char *buf; - if (text->undo_pos<0) { + if (text->undo_pos < 0) { return; } text->undo_pos--; - undoing= 1; + undoing = 1; switch (op) { case UNDO_CLEFT: @@ -2053,17 +2039,17 @@ void txt_do_undo(Text *text) text->undo_pos--; text->undo_pos--; - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - charp= txt_undo_read_uint16(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); - if (op==UNDO_CTO) { + if (op == UNDO_CTO) { txt_move_toline(text, linep, 0); - text->curc= charp; + text->curc = charp; txt_pop_sel(text); } else { txt_move_toline(text, linep, 1); - text->selc= charp; + text->selc = charp; } text->undo_pos--; @@ -2071,7 +2057,7 @@ void txt_do_undo(Text *text) case UNDO_INSERT_1: case UNDO_INSERT_2: case UNDO_INSERT_3: case UNDO_INSERT_4: txt_backspace_char(text); - text->undo_pos-= op - UNDO_INSERT_1 + 1; + text->undo_pos -= op - UNDO_INSERT_1 + 1; text->undo_pos--; break; @@ -2093,29 +2079,29 @@ void txt_do_undo(Text *text) break; case UNDO_DBLOCK: - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); - buf= MEM_mallocN(linep+1, "dblock buffer"); - for (i=0; i < linep; i++) { - buf[(linep-1)-i]= text->undo_buf[text->undo_pos]; + buf = MEM_mallocN(linep + 1, "dblock buffer"); + for (i = 0; i < linep; i++) { + buf[(linep - 1) - i] = text->undo_buf[text->undo_pos]; text->undo_pos--; } - buf[i]= 0; + buf[i] = 0; txt_curs_first(text, &holdl, &holdc); - holdln= txt_get_span(text->lines.first, holdl); + holdln = txt_get_span(text->lines.first, holdl); txt_insert_buf(text, buf); MEM_freeN(buf); - text->curl= text->lines.first; - while (holdln>0) { + text->curl = text->lines.first; + while (holdln > 0) { if (text->curl->next) - text->curl= text->curl->next; + text->curl = text->curl->next; holdln--; } - text->curc= holdc; + text->curc = holdc; text->undo_pos--; text->undo_pos--; @@ -2127,20 +2113,20 @@ void txt_do_undo(Text *text) break; case UNDO_IBLOCK: - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); txt_delete_sel(text); /* txt_backspace_char removes utf8-characters, not bytes */ - buf= MEM_mallocN(linep+1, "iblock buffer"); - for (i=0; i < linep; i++) { - buf[(linep-1)-i]= text->undo_buf[text->undo_pos]; + buf = MEM_mallocN(linep + 1, "iblock buffer"); + for (i = 0; i < linep; i++) { + buf[(linep - 1) - i] = text->undo_buf[text->undo_pos]; text->undo_pos--; } - buf[i]= 0; - linep= txt_utf8_len(buf); + buf[i] = 0; + linep = txt_utf8_len(buf); MEM_freeN(buf); - while (linep>0) { + while (linep > 0) { txt_backspace_char(text); linep--; } @@ -2157,7 +2143,7 @@ void txt_do_undo(Text *text) case UNDO_UNINDENT: case UNDO_COMMENT: case UNDO_UNCOMMENT: - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); //linep is now the end line of the selection charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); @@ -2166,11 +2152,11 @@ void txt_do_undo(Text *text) //set the selection for this now text->selc = charp; text->sell = text->lines.first; - for (i= 0; i < linep; i++) { + for (i = 0; i < linep; i++) { text->sell = text->sell->next; } - linep= txt_undo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_undo_read_uint32(text->undo_buf, &text->undo_pos); //first line to be selected charp = txt_undo_read_uint16(text->undo_buf, &text->undo_pos); @@ -2182,10 +2168,10 @@ void txt_do_undo(Text *text) } - if (op==UNDO_INDENT) { + if (op == UNDO_INDENT) { txt_unindent(text); } - else if (op== UNDO_UNINDENT) { + else if (op == UNDO_UNINDENT) { txt_indent(text); } else if (op == UNDO_COMMENT) { @@ -2208,13 +2194,13 @@ void txt_do_undo(Text *text) break; default: //XXX error("Undo buffer error - resetting"); - text->undo_pos= -1; + text->undo_pos = -1; break; } /* next undo step may need evaluating */ - if (text->undo_pos>=0) { + if (text->undo_pos >= 0) { switch (text->undo_buf[text->undo_pos]) { case UNDO_STO: txt_do_undo(text); @@ -2226,7 +2212,7 @@ void txt_do_undo(Text *text) } } - undoing= 0; + undoing = 0; } void txt_do_redo(Text *text) @@ -2237,14 +2223,14 @@ void txt_do_redo(Text *text) char *buf; text->undo_pos++; - op= text->undo_buf[text->undo_pos]; + op = text->undo_buf[text->undo_pos]; if (!op) { text->undo_pos--; return; } - undoing= 1; + undoing = 1; switch (op) { case UNDO_CLEFT: @@ -2288,13 +2274,13 @@ void txt_do_redo(Text *text) case UNDO_BS_1: case UNDO_BS_2: case UNDO_BS_3: case UNDO_BS_4: text->undo_pos++; txt_backspace_char(text); - text->undo_pos+= op - UNDO_BS_1 + 1; + text->undo_pos += op - UNDO_BS_1 + 1; break; case UNDO_DEL_1: case UNDO_DEL_2: case UNDO_DEL_3: case UNDO_DEL_4: text->undo_pos++; txt_delete_char(text); - text->undo_pos+= op - UNDO_DEL_1 + 1; + text->undo_pos += op - UNDO_DEL_1 + 1; break; case UNDO_SWAP: @@ -2314,27 +2300,27 @@ void txt_do_redo(Text *text) text->undo_pos++; - charp= txt_redo_read_uint16(text->undo_buf, &text->undo_pos); - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - if (op==UNDO_CTO) { + if (op == UNDO_CTO) { txt_move_toline(text, linep, 0); - text->curc= charp; + text->curc = charp; txt_pop_sel(text); } else { txt_move_toline(text, linep, 1); - text->selc= charp; + text->selc = charp; } break; case UNDO_DBLOCK: text->undo_pos++; - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); txt_delete_sel(text); - text->undo_pos+=linep; + text->undo_pos += linep; text->undo_pos++; text->undo_pos++; @@ -2345,12 +2331,12 @@ void txt_do_redo(Text *text) case UNDO_IBLOCK: text->undo_pos++; - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); - buf= MEM_mallocN(linep+1, "iblock buffer"); - memcpy (buf, &text->undo_buf[text->undo_pos], linep); - text->undo_pos+= linep; - buf[linep]= 0; + buf = MEM_mallocN(linep + 1, "iblock buffer"); + memcpy(buf, &text->undo_buf[text->undo_pos], linep); + text->undo_pos += linep; + buf[linep] = 0; txt_insert_buf(text, buf); MEM_freeN(buf); @@ -2369,19 +2355,19 @@ void txt_do_redo(Text *text) charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); //charp is the first char selected or 0 - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); //linep is now the first line of the selection //set the selcetion for this now text->curc = charp; text->curl = text->lines.first; - for (i= 0; i < linep; i++) { + for (i = 0; i < linep; i++) { text->curl = text->curl->next; } charp = txt_redo_read_uint16(text->undo_buf, &text->undo_pos); //last postion to be selected - linep= txt_redo_read_uint32(text->undo_buf, &text->undo_pos); + linep = txt_redo_read_uint32(text->undo_buf, &text->undo_pos); //Last line to be selected text->selc = charp; @@ -2390,10 +2376,10 @@ void txt_do_redo(Text *text) text->sell = text->sell->next; } - if (op==UNDO_INDENT) { + if (op == UNDO_INDENT) { txt_indent(text); } - else if (op== UNDO_UNINDENT) { + else if (op == UNDO_UNINDENT) { txt_unindent(text); } else if (op == UNDO_COMMENT) { @@ -2414,12 +2400,12 @@ void txt_do_redo(Text *text) break; default: //XXX error("Undo buffer error - resetting"); - text->undo_pos= -1; + text->undo_pos = -1; break; } - undoing= 0; + undoing = 0; } /**************************/ @@ -2431,7 +2417,7 @@ void txt_split_curline(Text *text) TextLine *ins; TextMarker *mrk; char *left, *right; - int lineno= -1; + int lineno = -1; if (!text) return; if (!text->curl) return; @@ -2440,10 +2426,10 @@ void txt_split_curline(Text *text) /* Move markers */ - lineno= txt_get_span(text->lines.first, text->curl); - mrk= text->markers.first; + lineno = txt_get_span(text->lines.first, text->curl); + mrk = text->markers.first; while (mrk) { - if (mrk->lineno==lineno && mrk->start>text->curc) { + if (mrk->lineno == lineno && mrk->start > text->curc) { mrk->lineno++; mrk->start -= text->curc; mrk->end -= text->curc; @@ -2451,35 +2437,35 @@ void txt_split_curline(Text *text) else if (mrk->lineno > lineno) { mrk->lineno++; } - mrk= mrk->next; + mrk = mrk->next; } /* Make the two half strings */ - left= MEM_mallocN(text->curc+1, "textline_string"); + left = MEM_mallocN(text->curc + 1, "textline_string"); if (text->curc) memcpy(left, text->curl->line, text->curc); - left[text->curc]=0; + left[text->curc] = 0; - right= MEM_mallocN(text->curl->len - text->curc+1, "textline_string"); - memcpy(right, text->curl->line+text->curc, text->curl->len-text->curc+1); + right = MEM_mallocN(text->curl->len - text->curc + 1, "textline_string"); + memcpy(right, text->curl->line + text->curc, text->curl->len - text->curc + 1); MEM_freeN(text->curl->line); if (text->curl->format) MEM_freeN(text->curl->format); /* Make the new TextLine */ - ins= MEM_mallocN(sizeof(TextLine), "textline"); - ins->line= left; - ins->format= NULL; - ins->len= text->curc; - - text->curl->line= right; - text->curl->format= NULL; - text->curl->len= text->curl->len - text->curc; + ins = MEM_mallocN(sizeof(TextLine), "textline"); + ins->line = left; + ins->format = NULL; + ins->len = text->curc; + + text->curl->line = right; + text->curl->format = NULL; + text->curl->len = text->curl->len - text->curc; BLI_insertlinkbefore(&text->lines, text->curl, ins); - text->curc=0; + text->curc = 0; txt_make_dirty(text); txt_clean_text(text); @@ -2488,26 +2474,26 @@ void txt_split_curline(Text *text) if (!undoing) txt_undo_add_charop(text, UNDO_INSERT_1, '\n'); } -static void txt_delete_line (Text *text, TextLine *line) +static void txt_delete_line(Text *text, TextLine *line) { - TextMarker *mrk=NULL, *nxt; - int lineno= -1; + TextMarker *mrk = NULL, *nxt; + int lineno = -1; if (!text) return; if (!text->curl) return; - lineno= txt_get_span(text->lines.first, line); - mrk= text->markers.first; + lineno = txt_get_span(text->lines.first, line); + mrk = text->markers.first; while (mrk) { - nxt= mrk->next; - if (mrk->lineno==lineno) + nxt = mrk->next; + if (mrk->lineno == lineno) BLI_freelinkN(&text->markers, mrk); else if (mrk->lineno > lineno) mrk->lineno--; - mrk= nxt; + mrk = nxt; } - BLI_remlink (&text->lines, line); + BLI_remlink(&text->lines, line); if (line->line) MEM_freeN(line->line); if (line->format) MEM_freeN(line->format); @@ -2518,29 +2504,29 @@ static void txt_delete_line (Text *text, TextLine *line) txt_clean_text(text); } -static void txt_combine_lines (Text *text, TextLine *linea, TextLine *lineb) +static void txt_combine_lines(Text *text, TextLine *linea, TextLine *lineb) { char *tmp; - TextMarker *mrk= NULL; - int lineno=-1; + TextMarker *mrk = NULL; + int lineno = -1; if (!text) return; if (!linea || !lineb) return; - mrk= txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); + mrk = txt_find_marker_region(text, lineb, 0, lineb->len, 0, 0); if (mrk) { - lineno= mrk->lineno; + lineno = mrk->lineno; do { mrk->lineno--; mrk->start += linea->len; mrk->end += linea->len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } - if (lineno==-1) lineno= txt_get_span(text->lines.first, lineb); + if (lineno == -1) lineno = txt_get_span(text->lines.first, lineb); - tmp= MEM_mallocN(linea->len+lineb->len+1, "textline_string"); + tmp = MEM_mallocN(linea->len + lineb->len + 1, "textline_string"); strcpy(tmp, linea->line); strcat(tmp, lineb->line); @@ -2572,7 +2558,7 @@ void txt_duplicate_line(Text *text) void txt_delete_char(Text *text) { - unsigned int c='\n'; + unsigned int c = '\n'; if (!text) return; if (!text->curl) return; @@ -2582,7 +2568,7 @@ void txt_delete_char(Text *text) txt_make_dirty(text); return; } - else if (text->curc== text->curl->len) { /* Appending two lines */ + else if (text->curc == text->curl->len) { /* Appending two lines */ if (text->curl->next) { txt_combine_lines(text, text->curl, text->curl->next); txt_pop_sel(text); @@ -2593,12 +2579,12 @@ void txt_delete_char(Text *text) else { /* Just deleting a char */ size_t c_len = 0; TextMarker *mrk; - c= BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len); + c = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &c_len); - mrk= txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); if (mrk) { - int lineno= mrk->lineno; - if (mrk->end==text->curc) { + int lineno = mrk->lineno; + if (mrk->end == text->curc) { if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) { txt_clear_markers(text, mrk->group, TMARK_TEMP); } @@ -2608,15 +2594,15 @@ void txt_delete_char(Text *text) return; } do { - if (mrk->start>text->curc) mrk->start-= c_len; - mrk->end-= c_len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + if (mrk->start > text->curc) mrk->start -= c_len; + mrk->end -= c_len; + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } - memmove(text->curl->line+text->curc, text->curl->line+text->curc+c_len, text->curl->len-text->curc-c_len+1); + memmove(text->curl->line + text->curc, text->curl->line + text->curc + c_len, text->curl->len - text->curc - c_len + 1); - text->curl->len-= c_len; + text->curl->len -= c_len; txt_pop_sel(text); } @@ -2635,7 +2621,7 @@ void txt_delete_word(Text *text) void txt_backspace_char(Text *text) { - unsigned int c='\n'; + unsigned int c = '\n'; if (!text) return; if (!text->curl) return; @@ -2645,11 +2631,11 @@ void txt_backspace_char(Text *text) txt_make_dirty(text); return; } - else if (text->curc==0) { /* Appending two lines */ + else if (text->curc == 0) { /* Appending two lines */ if (!text->curl->prev) return; - text->curl= text->curl->prev; - text->curc= text->curl->len; + text->curl = text->curl->prev; + text->curc = text->curl->len; txt_combine_lines(text, text->curl, text->curl->next); txt_pop_sel(text); @@ -2658,12 +2644,12 @@ void txt_backspace_char(Text *text) size_t c_len = 0; TextMarker *mrk; char *prev = BLI_str_prev_char_utf8(text->curl->line + text->curc); - c= BLI_str_utf8_as_unicode_and_size(prev, &c_len); + c = BLI_str_utf8_as_unicode_and_size(prev, &c_len); - mrk= txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc - c_len, text->curl->len, 0, 0); if (mrk) { - int lineno= mrk->lineno; - if (mrk->start==text->curc) { + int lineno = mrk->lineno; + if (mrk->start == text->curc) { if ((mrk->flags & TMARK_TEMP) && !(mrk->flags & TMARK_EDITALL)) { txt_clear_markers(text, mrk->group, TMARK_TEMP); } @@ -2673,10 +2659,10 @@ void txt_backspace_char(Text *text) return; } do { - if (mrk->start>text->curc - c_len) mrk->start-= c_len; - mrk->end-= c_len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + if (mrk->start > text->curc - c_len) mrk->start -= c_len; + mrk->end -= c_len; + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } /* source and destination overlap, don't use memcpy() */ @@ -2684,8 +2670,8 @@ void txt_backspace_char(Text *text) text->curl->line + text->curc, text->curl->len - text->curc + 1); - text->curl->len-= c_len; - text->curc-= c_len; + text->curl->len -= c_len; + text->curc -= c_len; txt_pop_sel(text); } @@ -2707,7 +2693,7 @@ void txt_backspace_word(Text *text) * Remember to change this string according to max tab size */ static char tab_to_spaces[] = " "; -static void txt_convert_tab_to_spaces (Text *text) +static void txt_convert_tab_to_spaces(Text *text) { /* sb aims to pad adjust the tab-width needed so that the right number of spaces * is added so that the indention of the line is the right width (i.e. aligned @@ -2717,7 +2703,7 @@ static void txt_convert_tab_to_spaces (Text *text) txt_insert_buf(text, sb); } -static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) +static int txt_add_char_intern(Text *text, unsigned int add, int replace_tabs) { int lineno; char *tmp, ch[BLI_UTF8_MAX]; @@ -2727,7 +2713,7 @@ static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) if (!text) return 0; if (!text->curl) return 0; - if (add=='\n') { + if (add == '\n') { txt_split_curline(text); return 1; } @@ -2741,25 +2727,25 @@ static int txt_add_char_intern (Text *text, unsigned int add, int replace_tabs) txt_delete_sel(text); add_len = BLI_str_utf8_from_unicode(add, ch); - mrk= txt_find_marker_region(text, text->curl, text->curc-1, text->curl->len, 0, 0); + mrk = txt_find_marker_region(text, text->curl, text->curc - 1, text->curl->len, 0, 0); if (mrk) { - lineno= mrk->lineno; + lineno = mrk->lineno; do { - if (mrk->start>text->curc) mrk->start+= add_len; - mrk->end+= add_len; - mrk= mrk->next; - } while (mrk && mrk->lineno==lineno); + if (mrk->start > text->curc) mrk->start += add_len; + mrk->end += add_len; + mrk = mrk->next; + } while (mrk && mrk->lineno == lineno); } - tmp= MEM_mallocN(text->curl->len+add_len+1, "textline_string"); + tmp = MEM_mallocN(text->curl->len + add_len + 1, "textline_string"); memcpy(tmp, text->curl->line, text->curc); - memcpy(tmp+text->curc, ch, add_len); - memcpy(tmp+text->curc+add_len, text->curl->line+text->curc, text->curl->len-text->curc+1); + memcpy(tmp + text->curc, ch, add_len); + memcpy(tmp + text->curc + add_len, text->curl->line + text->curc, text->curl->len - text->curc + 1); make_new_line(text->curl, tmp); - text->curc+= add_len; + text->curc += add_len; txt_pop_sel(text); @@ -2796,30 +2782,30 @@ int txt_replace_char(Text *text, unsigned int add) if (!text->curl) return 0; /* If text is selected or we're at the end of the line just use txt_add_char */ - if (text->curc==text->curl->len || txt_has_sel(text) || add=='\n') { - int i= txt_add_char(text, add); - TextMarker *mrk= txt_find_marker(text, text->curl, text->curc, 0, 0); + if (text->curc == text->curl->len || txt_has_sel(text) || add == '\n') { + int i = txt_add_char(text, add); + TextMarker *mrk = txt_find_marker(text, text->curl, text->curc, 0, 0); if (mrk) BLI_freelinkN(&text->markers, mrk); return i; } - del= BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &del_size); - add_size= BLI_str_utf8_from_unicode(add, ch); + del = BLI_str_utf8_as_unicode_and_size(text->curl->line + text->curc, &del_size); + add_size = BLI_str_utf8_from_unicode(add, ch); if (add_size > del_size) { - char *tmp= MEM_mallocN(text->curl->len+add_size-del_size+1, "textline_string"); + char *tmp = MEM_mallocN(text->curl->len + add_size - del_size + 1, "textline_string"); memcpy(tmp, text->curl->line, text->curc); - memcpy(tmp+text->curc+add_size, text->curl->line+text->curc+del_size, text->curl->len-text->curc-del_size+1); + memcpy(tmp + text->curc + add_size, text->curl->line + text->curc + del_size, text->curl->len - text->curc - del_size + 1); MEM_freeN(text->curl->line); text->curl->line = tmp; } else if (add_size < del_size) { - char *tmp= text->curl->line; - memmove(tmp+text->curc+add_size, tmp+text->curc+del_size, text->curl->len-text->curc-del_size+1); + char *tmp = text->curl->line; + memmove(tmp + text->curc + add_size, tmp + text->curc + del_size, text->curl->len - text->curc - del_size + 1); } memcpy(text->curl->line + text->curc, ch, add_size); - text->curc+= add_size; + text->curc += add_size; txt_pop_sel(text); txt_make_dirty(text); @@ -2860,19 +2846,19 @@ void txt_indent(Text *text) num = 0; while (TRUE) { - tmp= MEM_mallocN(text->curl->len+indentlen+1, "textline_string"); + tmp = MEM_mallocN(text->curl->len + indentlen + 1, "textline_string"); text->curc = 0; - if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */ - memcpy(tmp+text->curc, add, indentlen); + if (text->curc) memcpy(tmp, text->curl->line, text->curc); /* XXX never true, check prev line */ + memcpy(tmp + text->curc, add, indentlen); - len= text->curl->len - text->curc; - if (len>0) memcpy(tmp+text->curc+indentlen, text->curl->line+text->curc, len); - tmp[text->curl->len+indentlen]= 0; + len = text->curl->len - text->curc; + if (len > 0) memcpy(tmp + text->curc + indentlen, text->curl->line + text->curc, len); + tmp[text->curl->len + indentlen] = 0; make_new_line(text->curl, tmp); - text->curc+= indentlen; + text->curc += indentlen; txt_make_dirty(text); txt_clean_text(text); @@ -2887,7 +2873,7 @@ void txt_indent(Text *text) } } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -2920,11 +2906,11 @@ void txt_unindent(Text *text) int i = 0; if (BLI_strncasecmp(text->curl->line, remove, indent) == 0) { - while (i< text->curl->len) { - text->curl->line[i]= text->curl->line[i+indent]; + while (i < text->curl->len) { + text->curl->line[i] = text->curl->line[i + indent]; i++; } - text->curl->len-= indent; + text->curl->len -= indent; } txt_make_dirty(text); @@ -2941,7 +2927,7 @@ void txt_unindent(Text *text) } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -2959,19 +2945,19 @@ void txt_comment(Text *text) if (!text) return; if (!text->curl) return; - if (!text->sell) return;// Need to change this need to check if only one line is selected to more then one + if (!text->sell) return; // Need to change this need to check if only one line is selected to more then one num = 0; while (TRUE) { - tmp= MEM_mallocN(text->curl->len+2, "textline_string"); + tmp = MEM_mallocN(text->curl->len + 2, "textline_string"); text->curc = 0; if (text->curc) memcpy(tmp, text->curl->line, text->curc); - tmp[text->curc]= add; + tmp[text->curc] = add; - len= text->curl->len - text->curc; - if (len>0) memcpy(tmp+text->curc+1, text->curl->line+text->curc, len); - tmp[text->curl->len+1]=0; + len = text->curl->len - text->curc; + if (len > 0) memcpy(tmp + text->curc + 1, text->curl->line + text->curc, len); + tmp[text->curl->len + 1] = 0; make_new_line(text->curl, tmp); @@ -2990,7 +2976,7 @@ void txt_comment(Text *text) } } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -3013,8 +2999,8 @@ void txt_uncomment(Text *text) int i = 0; if (text->curl->line[i] == remove) { - while (i< text->curl->len) { - text->curl->line[i]= text->curl->line[i+1]; + while (i < text->curl->len) { + text->curl->line[i] = text->curl->line[i + 1]; i++; } text->curl->len--; @@ -3035,7 +3021,7 @@ void txt_uncomment(Text *text) } text->curc = 0; - while ( num > 0 ) { + while (num > 0) { text->curl = text->curl->prev; num--; } @@ -3054,7 +3040,7 @@ void txt_move_lines_up(struct Text *text) txt_order_cursors(text); - prev_line= text->curl->prev; + prev_line = text->curl->prev; if (!prev_line) return; @@ -3106,8 +3092,8 @@ int setcurr_tab_spaces(Text *text, int space) int test = 0; const char *word = ":"; const char *comm = "#"; - const char indent= (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; - static const char *back_words[]= {"return", "break", "continue", "pass", "yield", NULL}; + const char indent = (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t'; + static const char *back_words[] = {"return", "break", "continue", "pass", "yield", NULL}; if (!text) return 0; if (!text->curl) return 0; @@ -3122,20 +3108,20 @@ int setcurr_tab_spaces(Text *text, int space) } if (strstr(text->curl->line, word)) { /* if we find a ':' on this line, then add a tab but not if it is: - * 1) in a comment - * 2) within an identifier + * 1) in a comment + * 2) within an identifier * 3) after the cursor (text->curc), i.e. when creating space before a function def [#25414] */ int a, is_indent = 0; - for (a=0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { - char ch= text->curl->line[a]; - if (ch=='#') { + for (a = 0; (a < text->curc) && (text->curl->line[a] != '\0'); a++) { + char ch = text->curl->line[a]; + if (ch == '#') { break; } - else if (ch==':') { + else if (ch == ':') { is_indent = 1; } - else if (ch!=' ' && ch!='\t') { + else if (ch != ' ' && ch != '\t') { is_indent = 0; } } @@ -3144,7 +3130,7 @@ int setcurr_tab_spaces(Text *text, int space) } } - for (test=0; back_words[test]; test++) { + for (test = 0; back_words[test]; test++) { /* if there are these key words then remove a tab because we are done with the block */ if (strstr(text->curl->line, back_words[test]) && i > 0) { if (strcspn(text->curl->line, back_words[test]) < strcspn(text->curl->line, comm)) { @@ -3164,21 +3150,21 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsign { TextMarker *tmp, *marker; - marker= MEM_mallocN(sizeof(TextMarker), "text_marker"); + marker = MEM_mallocN(sizeof(TextMarker), "text_marker"); - marker->lineno= txt_get_span(text->lines.first, line); - marker->start= MIN2(start, end); - marker->end= MAX2(start, end); - marker->group= group; - marker->flags= flags; + marker->lineno = txt_get_span(text->lines.first, line); + marker->start = MIN2(start, end); + marker->end = MAX2(start, end); + marker->group = group; + marker->flags = flags; - marker->color[0]= color[0]; - marker->color[1]= color[1]; - marker->color[2]= color[2]; - marker->color[3]= color[3]; + marker->color[0] = color[0]; + marker->color[1] = color[1]; + marker->color[2] = color[2]; + marker->color[3] = color[3]; - for (tmp=text->markers.last; tmp; tmp=tmp->prev) - if (tmp->lineno < marker->lineno || (tmp->lineno==marker->lineno && tmp->start < marker->start)) + for (tmp = text->markers.last; tmp; tmp = tmp->prev) + if (tmp->lineno < marker->lineno || (tmp->lineno == marker->lineno && tmp->start < marker->start)) break; if (tmp) BLI_insertlinkafter(&text->markers, tmp, marker); @@ -3191,18 +3177,18 @@ void txt_add_marker(Text *text, TextLine *line, int start, int end, const unsign TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) { TextMarker *marker, *next; - int lineno= txt_get_span(text->lines.first, line); + int lineno = txt_get_span(text->lines.first, line); - for (marker=text->markers.first; marker; marker=next) { - next= marker->next; + for (marker = text->markers.first; marker; marker = next) { + next = marker->next; - if (group && marker->group != group) continue; + if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; - else if (marker->lineno < lineno) continue; + else if (marker->lineno < lineno) continue; else if (marker->lineno > lineno) break; - if ((marker->start==marker->end && start<=marker->start && marker->start<=end) || - (marker->startend>start)) + if ((marker->start == marker->end && start <= marker->start && marker->start <= end) || + (marker->start < end && marker->end > start)) { return marker; } @@ -3216,21 +3202,21 @@ TextMarker *txt_find_marker_region(Text *text, TextLine *line, int start, int en short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, int group, int flags) { TextMarker *marker, *next; - int lineno= txt_get_span(text->lines.first, line); - short cleared= 0; + int lineno = txt_get_span(text->lines.first, line); + short cleared = 0; - for (marker=text->markers.first; marker; marker=next) { - next= marker->next; + for (marker = text->markers.first; marker; marker = next) { + next = marker->next; if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; else if (marker->lineno < lineno) continue; else if (marker->lineno > lineno) break; - if ((marker->start==marker->end && start<=marker->start && marker->start<=end) || - (marker->startend>start)) { + if ((marker->start == marker->end && start <= marker->start && marker->start <= end) || + (marker->start < end && marker->end > start)) { BLI_freelinkN(&text->markers, marker); - cleared= 1; + cleared = 1; } } return cleared; @@ -3242,15 +3228,15 @@ short txt_clear_marker_region(Text *text, TextLine *line, int start, int end, in short txt_clear_markers(Text *text, int group, int flags) { TextMarker *marker, *next; - short cleared= 0; + short cleared = 0; - for (marker=text->markers.first; marker; marker=next) { - next= marker->next; + for (marker = text->markers.first; marker; marker = next) { + next = marker->next; - if ((!group || marker->group==group) && - (marker->flags & flags) == flags) { + if ((!group || marker->group == group) && + (marker->flags & flags) == flags) { BLI_freelinkN(&text->markers, marker); - cleared= 1; + cleared = 1; } } return cleared; @@ -3261,9 +3247,9 @@ short txt_clear_markers(Text *text, int group, int flags) TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int flags) { TextMarker *marker; - int lineno= txt_get_span(text->lines.first, line); + int lineno = txt_get_span(text->lines.first, line); - for (marker=text->markers.first; marker; marker=marker->next) { + for (marker = text->markers.first; marker; marker = marker->next) { if (group && marker->group != group) continue; else if ((marker->flags & flags) != flags) continue; else if (marker->lineno < lineno) continue; @@ -3279,10 +3265,10 @@ TextMarker *txt_find_marker(Text *text, TextLine *line, int curs, int group, int * marker will be returned */ TextMarker *txt_prev_marker(Text *text, TextMarker *marker) { - TextMarker *tmp= marker; + TextMarker *tmp = marker; while (tmp) { - if (tmp->prev) tmp= tmp->prev; - else tmp= text->markers.last; + if (tmp->prev) tmp = tmp->prev; + else tmp = text->markers.last; if (tmp->group == marker->group) return tmp; } @@ -3293,10 +3279,10 @@ TextMarker *txt_prev_marker(Text *text, TextMarker *marker) * marker will be returned */ TextMarker *txt_next_marker(Text *text, TextMarker *marker) { - TextMarker *tmp= marker; + TextMarker *tmp = marker; while (tmp) { - if (tmp->next) tmp= tmp->next; - else tmp= text->markers.first; + if (tmp->next) tmp = tmp->next; + else tmp = text->markers.first; if (tmp->group == marker->group) return tmp; } @@ -3314,11 +3300,11 @@ int text_check_bracket(const char ch) char opens[] = "([{"; char close[] = ")]}"; - for (a=0; a<(sizeof(opens)-1); a++) { - if (ch==opens[a]) - return a+1; - else if (ch==close[a]) - return -(a+1); + for (a = 0; a < (sizeof(opens) - 1); a++) { + if (ch == opens[a]) + return a + 1; + else if (ch == close[a]) + return -(a + 1); } return 0; } @@ -3329,8 +3315,8 @@ int text_check_delim(const char ch) int a; char delims[] = "():\"\' ~!%^&*-+=[]{};/<>|.#\t,@"; - for (a=0; a<(sizeof(delims)-1); a++) { - if (ch==delims[a]) + for (a = 0; a < (sizeof(delims) - 1); a++) { + if (ch == delims[a]) return 1; } return 0; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 9200b1dca18..2c868ca2601 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -80,7 +80,7 @@ int test_dlerr(const char *name, const char *symbol) { char *err; - err= BLI_dynlib_get_error_as_string(NULL); + err = BLI_dynlib_get_error_as_string(NULL); if (err) { printf("var1: %s, var2: %s, var3: %s\n", name, symbol, err); return 1; @@ -96,14 +96,14 @@ void open_plugin_tex(PluginTex *pit) int (*version)(void); /* init all the happy variables */ - pit->doit= NULL; - pit->pname= NULL; - pit->stnames= NULL; - pit->varstr= NULL; - pit->result= NULL; - pit->cfra= NULL; - pit->version= 0; - pit->instance_init= NULL; + pit->doit = NULL; + pit->pname = NULL; + pit->stnames = NULL; + pit->varstr = NULL; + pit->result = NULL; + pit->cfra = NULL; + pit->version = 0; + pit->instance_init = NULL; /* clear the error list */ BLI_dynlib_get_error_as_string(NULL); @@ -113,42 +113,42 @@ void open_plugin_tex(PluginTex *pit) /* pit->handle= 0; */ /* open the needed object */ - pit->handle= BLI_dynlib_open(pit->name); + pit->handle = BLI_dynlib_open(pit->name); if (test_dlerr(pit->name, pit->name)) return; if (pit->handle != NULL) { /* find the address of the version function */ - version= (int (*)(void)) BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); + version = (int (*)(void))BLI_dynlib_find_symbol(pit->handle, "plugin_tex_getversion"); if (test_dlerr(pit->name, "plugin_tex_getversion")) return; if (version != NULL) { - pit->version= version(); - if ( pit->version >= 2 && pit->version <=6) { + pit->version = version(); + if (pit->version >= 2 && pit->version <= 6) { int (*info_func)(PluginInfo *); - PluginInfo *info= (PluginInfo*) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); + PluginInfo *info = (PluginInfo *) MEM_mallocN(sizeof(PluginInfo), "plugin_info"); - info_func= (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); + info_func = (int (*)(PluginInfo *))BLI_dynlib_find_symbol(pit->handle, "plugin_getinfo"); if (!test_dlerr(pit->name, "plugin_getinfo")) { info->instance_init = NULL; info_func(info); - pit->doit= (int(*)(void)) info->tex_doit; - pit->callback= (void(*)(unsigned short)) info->callback; - pit->stypes= info->stypes; - pit->vars= info->nvars; - pit->pname= info->name; - pit->stnames= info->snames; - pit->varstr= info->varstr; - pit->result= info->result; - pit->cfra= info->cfra; + pit->doit = (int (*)(void))info->tex_doit; + pit->callback = (void (*)(unsigned short))info->callback; + pit->stypes = info->stypes; + pit->vars = info->nvars; + pit->pname = info->name; + pit->stnames = info->snames; + pit->varstr = info->varstr; + pit->result = info->result; + pit->cfra = info->cfra; pit->instance_init = info->instance_init; if (info->init) info->init(); } MEM_freeN(info); } else { - printf ("Plugin returned unrecognized version number\n"); + printf("Plugin returned unrecognized version number\n"); return; } } @@ -158,8 +158,8 @@ void open_plugin_tex(PluginTex *pit) /* ------------------------------------------------------------------------- */ /* very badlevel define to bypass linking with BIF_interface.h */ -#define INT 96 -#define FLO 128 +#define INT 96 +#define FLO 128 PluginTex *add_plugin_tex(char *str) { @@ -167,24 +167,24 @@ PluginTex *add_plugin_tex(char *str) VarStruct *varstr; int a; - pit= MEM_callocN(sizeof(PluginTex), "plugintex"); + pit = MEM_callocN(sizeof(PluginTex), "plugintex"); BLI_strncpy(pit->name, str, sizeof(pit->name)); open_plugin_tex(pit); - if (pit->doit==NULL) { - if (pit->handle==NULL) {;} //XXX error("no plugin: %s", str); - else {;} //XXX error("in plugin: %s", str); + if (pit->doit == NULL) { + if (pit->handle == NULL) {; } //XXX error("no plugin: %s", str); + else {; } //XXX error("in plugin: %s", str); MEM_freeN(pit); return NULL; } - varstr= pit->varstr; - for (a=0; avars; a++, varstr++) { - if ( (varstr->type & FLO)==FLO) - pit->data[a]= varstr->def; - else if ( (varstr->type & INT)==INT) - *((int *)(pit->data+a))= (int) varstr->def; + varstr = pit->varstr; + for (a = 0; a < pit->vars; a++, varstr++) { + if ( (varstr->type & FLO) == FLO) + pit->data[a] = varstr->def; + else if ( (varstr->type & INT) == INT) + *((int *)(pit->data + a)) = (int) varstr->def; } if (pit->instance_init) @@ -197,7 +197,7 @@ PluginTex *add_plugin_tex(char *str) void free_plugin_tex(PluginTex *pit) { - if (pit==NULL) return; + if (pit == NULL) return; /* no BLI_dynlib_close: same plugin can be opened multiple times, 1 handle */ MEM_freeN(pit); @@ -207,7 +207,7 @@ void free_plugin_tex(PluginTex *pit) TexMapping *add_tex_mapping(void) { - TexMapping *texmap= MEM_callocN(sizeof(TexMapping), "TexMapping"); + TexMapping *texmap = MEM_callocN(sizeof(TexMapping), "TexMapping"); default_tex_mapping(texmap); @@ -218,14 +218,14 @@ void default_tex_mapping(TexMapping *texmap) { memset(texmap, 0, sizeof(TexMapping)); - texmap->size[0]= texmap->size[1]= texmap->size[2]= 1.0f; - texmap->max[0]= texmap->max[1]= texmap->max[2]= 1.0f; + texmap->size[0] = texmap->size[1] = texmap->size[2] = 1.0f; + texmap->max[0] = texmap->max[1] = texmap->max[2] = 1.0f; unit_m4(texmap->mat); - texmap->projx= PROJ_X; - texmap->projy= PROJ_Y; - texmap->projz= PROJ_Z; - texmap->mapping= MTEX_FLAT; + texmap->projx = PROJ_X; + texmap->projy = PROJ_Y; + texmap->projz = PROJ_Z; + texmap->mapping = MTEX_FLAT; } void init_tex_mapping(TexMapping *texmap) @@ -233,7 +233,7 @@ void init_tex_mapping(TexMapping *texmap) float smat[3][3], rmat[3][3], mat[3][3], proj[3][3]; if (texmap->projx == PROJ_X && texmap->projy == PROJ_Y && texmap->projz == PROJ_Z && - is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { + is_zero_v3(texmap->loc) && is_zero_v3(texmap->rot) && is_one_v3(texmap->size)) { unit_m4(texmap->mat); texmap->flag |= TEXMAP_UNIT_MATRIX; @@ -243,11 +243,11 @@ void init_tex_mapping(TexMapping *texmap) zero_m3(proj); if (texmap->projx != PROJ_N) - proj[texmap->projx-1][0]= 1.0f; + proj[texmap->projx - 1][0] = 1.0f; if (texmap->projy != PROJ_N) - proj[texmap->projy-1][1]= 1.0f; + proj[texmap->projy - 1][1] = 1.0f; if (texmap->projz != PROJ_N) - proj[texmap->projz-1][2]= 1.0f; + proj[texmap->projz - 1][2] = 1.0f; /* scale */ size_to_mat3(smat, texmap->size); @@ -270,7 +270,7 @@ void init_tex_mapping(TexMapping *texmap) ColorMapping *add_color_mapping(void) { - ColorMapping *colormap= MEM_callocN(sizeof(ColorMapping), "ColorMapping"); + ColorMapping *colormap = MEM_callocN(sizeof(ColorMapping), "ColorMapping"); default_color_mapping(colormap); @@ -283,15 +283,15 @@ void default_color_mapping(ColorMapping *colormap) init_colorband(&colormap->coba, 1); - colormap->bright= 1.0; - colormap->contrast= 1.0; - colormap->saturation= 1.0; + colormap->bright = 1.0; + colormap->contrast = 1.0; + colormap->saturation = 1.0; - colormap->blend_color[0]= 0.8f; - colormap->blend_color[1]= 0.8f; - colormap->blend_color[2]= 0.8f; - colormap->blend_type= MA_RAMP_BLEND; - colormap->blend_factor= 0.0f; + colormap->blend_color[0] = 0.8f; + colormap->blend_color[1] = 0.8f; + colormap->blend_color[2] = 0.8f; + colormap->blend_type = MA_RAMP_BLEND; + colormap->blend_factor = 0.0f; } /* ****************** COLORBAND ******************* */ @@ -300,41 +300,41 @@ void init_colorband(ColorBand *coba, int rangetype) { int a; - coba->data[0].pos= 0.0; - coba->data[1].pos= 1.0; + coba->data[0].pos = 0.0; + coba->data[1].pos = 1.0; - if (rangetype==0) { - coba->data[0].r= 0.0; - coba->data[0].g= 0.0; - coba->data[0].b= 0.0; - coba->data[0].a= 0.0; - - coba->data[1].r= 1.0; - coba->data[1].g= 1.0; - coba->data[1].b= 1.0; - coba->data[1].a= 1.0; + if (rangetype == 0) { + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 0.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; } else { - coba->data[0].r= 0.0; - coba->data[0].g= 0.0; - coba->data[0].b= 0.0; - coba->data[0].a= 1.0; - - coba->data[1].r= 1.0; - coba->data[1].g= 1.0; - coba->data[1].b= 1.0; - coba->data[1].a= 1.0; + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 1.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; + } + + for (a = 2; a < MAXCOLORBAND; a++) { + coba->data[a].r = 0.5; + coba->data[a].g = 0.5; + coba->data[a].b = 0.5; + coba->data[a].a = 1.0; + coba->data[a].pos = 0.5; } - for (a=2; adata[a].r= 0.5; - coba->data[a].g= 0.5; - coba->data[a].b= 0.5; - coba->data[a].a= 1.0; - coba->data[a].pos= 0.5; - } - - coba->tot= 2; + coba->tot = 2; } @@ -342,7 +342,7 @@ ColorBand *add_colorband(int rangetype) { ColorBand *coba; - coba= MEM_callocN(sizeof(ColorBand), "colorband"); + coba = MEM_callocN(sizeof(ColorBand), "colorband"); init_colorband(coba, rangetype); return coba; @@ -356,85 +356,85 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) float fac, mfac, t[4]; int a; - if (coba==NULL || coba->tot==0) return 0; + if (coba == NULL || coba->tot == 0) return 0; - cbd1= coba->data; - if (coba->tot==1) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + cbd1 = coba->data; + if (coba->tot == 1) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { - if (in <= cbd1->pos && coba->ipotype<2) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + if (in <= cbd1->pos && coba->ipotype < 2) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { CBData left, right; /* we're looking for first pos > in */ - for (a=0; atot; a++, cbd1++) if (cbd1->pos > in) break; + for (a = 0; a < coba->tot; a++, cbd1++) if (cbd1->pos > in) break; - if (a==coba->tot) { - cbd2= cbd1-1; - right= *cbd2; - right.pos= 1.0f; - cbd1= &right; + if (a == coba->tot) { + cbd2 = cbd1 - 1; + right = *cbd2; + right.pos = 1.0f; + cbd1 = &right; } - else if (a==0) { - left= *cbd1; - left.pos= 0.0f; - cbd2= &left; + else if (a == 0) { + left = *cbd1; + left.pos = 0.0f; + cbd2 = &left; } - else cbd2= cbd1-1; + else cbd2 = cbd1 - 1; - if (in >= cbd1->pos && coba->ipotype<2) { - out[0]= cbd1->r; - out[1]= cbd1->g; - out[2]= cbd1->b; - out[3]= cbd1->a; + if (in >= cbd1->pos && coba->ipotype < 2) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; } else { - if (cbd2->pos!=cbd1->pos) - fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos); + if (cbd2->pos != cbd1->pos) + fac = (in - cbd1->pos) / (cbd2->pos - cbd1->pos); else { /* was setting to 0.0 in 2.56 & previous, but this * is incorrect for the last element, see [#26732] */ - fac= (a != coba->tot) ? 0.0f : 1.0f; + fac = (a != coba->tot) ? 0.0f : 1.0f; } - if (coba->ipotype==4) { + if (coba->ipotype == 4) { /* constant */ - out[0]= cbd2->r; - out[1]= cbd2->g; - out[2]= cbd2->b; - out[3]= cbd2->a; + out[0] = cbd2->r; + out[1] = cbd2->g; + out[2] = cbd2->b; + out[3] = cbd2->a; return 1; } - if (coba->ipotype>=2) { + if (coba->ipotype >= 2) { /* ipo from right to left: 3 2 1 0 */ - if (a>=coba->tot-1) cbd0= cbd1; - else cbd0= cbd1+1; - if (a<2) cbd3= cbd2; - else cbd3= cbd2-1; + if (a >= coba->tot - 1) cbd0 = cbd1; + else cbd0 = cbd1 + 1; + if (a < 2) cbd3 = cbd2; + else cbd3 = cbd2 - 1; CLAMP(fac, 0.0f, 1.0f); - if (coba->ipotype==3) + if (coba->ipotype == 3) key_curve_position_weights(fac, t, KEY_CARDINAL); else key_curve_position_weights(fac, t, KEY_BSPLINE); - out[0]= t[3]*cbd3->r +t[2]*cbd2->r +t[1]*cbd1->r +t[0]*cbd0->r; - out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g; - out[2]= t[3]*cbd3->b +t[2]*cbd2->b +t[1]*cbd1->b +t[0]*cbd0->b; - out[3]= t[3]*cbd3->a +t[2]*cbd2->a +t[1]*cbd1->a +t[0]*cbd0->a; + out[0] = t[3] * cbd3->r + t[2] * cbd2->r + t[1] * cbd1->r + t[0] * cbd0->r; + out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g; + out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b; + out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a; CLAMP(out[0], 0.0f, 1.0f); CLAMP(out[1], 0.0f, 1.0f); CLAMP(out[2], 0.0f, 1.0f); @@ -442,40 +442,40 @@ int do_colorband(const ColorBand *coba, float in, float out[4]) } else { - if (coba->ipotype==1) { /* EASE */ - mfac= fac*fac; - fac= 3.0f*mfac-2.0f*mfac*fac; + if (coba->ipotype == 1) { /* EASE */ + mfac = fac * fac; + fac = 3.0f * mfac - 2.0f * mfac * fac; } - mfac= 1.0f-fac; + mfac = 1.0f - fac; - out[0]= mfac*cbd1->r + fac*cbd2->r; - out[1]= mfac*cbd1->g + fac*cbd2->g; - out[2]= mfac*cbd1->b + fac*cbd2->b; - out[3]= mfac*cbd1->a + fac*cbd2->a; + out[0] = mfac * cbd1->r + fac * cbd2->r; + out[1] = mfac * cbd1->g + fac * cbd2->g; + out[2] = mfac * cbd1->b + fac * cbd2->b; + out[3] = mfac * cbd1->a + fac * cbd2->a; } } } } - return 1; /* OK */ + return 1; /* OK */ } void colorband_table_RGBA(ColorBand *coba, float **array, int *size) { int a; - *size = CM_TABLE+1; - *array = MEM_callocN(sizeof(float)*(*size)*4, "ColorBand"); + *size = CM_TABLE + 1; + *array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand"); - for (a=0; a<*size; a++) - do_colorband(coba, (float)a/(float)CM_TABLE, &(*array)[a*4]); + for (a = 0; a < *size; a++) + do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]); } int vergcband(const void *a1, const void *a2) { - const CBData *x1=a1, *x2=a2; + const CBData *x1 = a1, *x2 = a2; - if ( x1->pos > x2->pos ) return 1; - else if ( x1->pos < x2->pos) return -1; + if (x1->pos > x2->pos) return 1; + else if (x1->pos < x2->pos) return -1; return 0; } @@ -483,17 +483,17 @@ void colorband_update_sort(ColorBand *coba) { int a; - if (coba->tot<2) + if (coba->tot < 2) return; - for (a=0; atot; a++) - coba->data[a].cur= a; + for (a = 0; a < coba->tot; a++) + coba->data[a].cur = a; qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - for (a=0; atot; a++) { - if (coba->data[a].cur==coba->cur) { - coba->cur= a; + for (a = 0; a < coba->tot; a++) { + if (coba->data[a].cur == coba->cur) { + coba->cur = a; break; } } @@ -501,7 +501,7 @@ void colorband_update_sort(ColorBand *coba) CBData *colorband_element_add(struct ColorBand *coba, float position) { - if (coba->tot==MAXCOLORBAND) { + if (coba->tot == MAXCOLORBAND) { return NULL; } else if (coba->tot > 0) { @@ -520,7 +520,7 @@ CBData *colorband_element_add(struct ColorBand *coba, float position) } coba->tot++; - coba->cur = coba->tot-1; + coba->cur = coba->tot - 1; colorband_update_sort(coba); @@ -547,7 +547,7 @@ int colorband_element_remove(struct ColorBand *coba, int index) /* ******************* TEX ************************ */ -void free_texture(Tex *tex) +void BKE_texture_free(Tex *tex) { free_plugin_tex(tex->plugin); @@ -559,7 +559,7 @@ void free_texture(Tex *tex) BKE_free_animdata((struct ID *)tex); BKE_previewimg_free(&tex->preview); - BKE_icon_delete((struct ID*)tex); + BKE_icon_delete((struct ID *)tex); tex->id.icon_id = 0; if (tex->nodetree) { @@ -576,31 +576,31 @@ void default_tex(Tex *tex) VarStruct *varstr; int a; - tex->type= TEX_CLOUDS; - tex->stype= 0; - tex->flag= TEX_CHECKER_ODD; - tex->imaflag= TEX_INTERPOL|TEX_MIPMAP|TEX_USEALPHA; - tex->extend= TEX_REPEAT; - tex->cropxmin= tex->cropymin= 0.0; - tex->cropxmax= tex->cropymax= 1.0; + tex->type = TEX_CLOUDS; + tex->stype = 0; + tex->flag = TEX_CHECKER_ODD; + tex->imaflag = TEX_INTERPOL | TEX_MIPMAP | TEX_USEALPHA; + tex->extend = TEX_REPEAT; + tex->cropxmin = tex->cropymin = 0.0; + tex->cropxmax = tex->cropymax = 1.0; tex->texfilter = TXF_EWA; tex->afmax = 8; - tex->xrepeat= tex->yrepeat= 1; - tex->fie_ima= 2; - tex->sfra= 1; - tex->frames= 0; - tex->offset= 0; - tex->noisesize= 0.25; - tex->noisedepth= 2; - tex->turbul= 5.0; - tex->nabla= 0.025; // also in do_versions - tex->bright= 1.0; - tex->contrast= 1.0; - tex->saturation= 1.0; - tex->filtersize= 1.0; - tex->rfac= 1.0; - tex->gfac= 1.0; - tex->bfac= 1.0; + tex->xrepeat = tex->yrepeat = 1; + tex->fie_ima = 2; + tex->sfra = 1; + tex->frames = 0; + tex->offset = 0; + tex->noisesize = 0.25; + tex->noisedepth = 2; + tex->turbul = 5.0; + tex->nabla = 0.025; // also in do_versions + tex->bright = 1.0; + tex->contrast = 1.0; + tex->saturation = 1.0; + tex->filtersize = 1.0; + tex->rfac = 1.0; + tex->gfac = 1.0; + tex->bfac = 1.0; /* newnoise: init. */ tex->noisebasis = 0; tex->noisebasis2 = 0; @@ -621,11 +621,11 @@ void default_tex(Tex *tex) tex->vn_coltype = 0; if (tex->env) { - tex->env->stype=ENV_ANIM; - tex->env->clipsta=0.1; - tex->env->clipend=100; - tex->env->cuberes=600; - tex->env->depth=0; + tex->env->stype = ENV_ANIM; + tex->env->clipsta = 0.1; + tex->env->clipend = 100; + tex->env->cuberes = 600; + tex->env->depth = 0; } if (tex->pd) { @@ -635,8 +635,8 @@ void default_tex(Tex *tex) if (tex->vd) { tex->vd->resol[0] = tex->vd->resol[1] = tex->vd->resol[2] = 0; - tex->vd->interp_type=TEX_VD_LINEAR; - tex->vd->file_format=TEX_VD_SMOKE; + tex->vd->interp_type = TEX_VD_LINEAR; + tex->vd->file_format = TEX_VD_SMOKE; } if (tex->ot) { @@ -645,18 +645,18 @@ void default_tex(Tex *tex) } pit = tex->plugin; if (pit) { - varstr= pit->varstr; + varstr = pit->varstr; if (varstr) { - for (a=0; avars; a++, varstr++) { + for (a = 0; a < pit->vars; a++, varstr++) { pit->data[a] = varstr->def; } } } - tex->iuser.fie_ima= 2; - tex->iuser.ok= 1; - tex->iuser.frames= 100; - tex->iuser.sfra= 1; + tex->iuser.fie_ima = 2; + tex->iuser.ok = 1; + tex->iuser.frames = 100; + tex->iuser.sfra = 1; tex->preview = NULL; } @@ -690,10 +690,10 @@ void tex_set_type(Tex *tex, int type) Tex *add_texture(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; Tex *tex; - tex= alloc_libblock(&bmain->tex, ID_TE, name); + tex = BKE_libblock_alloc(&bmain->tex, ID_TE, name); default_tex(tex); @@ -704,65 +704,65 @@ Tex *add_texture(const char *name) void default_mtex(MTex *mtex) { - mtex->texco= TEXCO_ORCO; - mtex->mapto= MAP_COL; - mtex->object= NULL; - mtex->projx= PROJ_X; - mtex->projy= PROJ_Y; - mtex->projz= PROJ_Z; - mtex->mapping= MTEX_FLAT; - mtex->ofs[0]= 0.0; - mtex->ofs[1]= 0.0; - mtex->ofs[2]= 0.0; - mtex->size[0]= 1.0; - mtex->size[1]= 1.0; - mtex->size[2]= 1.0; - mtex->tex= NULL; - mtex->texflag= MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; - mtex->colormodel= 0; - mtex->r= 1.0; - mtex->g= 0.0; - mtex->b= 1.0; - mtex->k= 1.0; - mtex->def_var= 1.0; - mtex->blendtype= MTEX_BLEND; - mtex->colfac= 1.0; - mtex->norfac= 1.0; - mtex->varfac= 1.0; - mtex->dispfac=0.2; - mtex->colspecfac= 1.0f; - mtex->mirrfac= 1.0f; - mtex->alphafac= 1.0f; - mtex->difffac= 1.0f; - mtex->specfac= 1.0f; - mtex->emitfac= 1.0f; - mtex->hardfac= 1.0f; - mtex->raymirrfac= 1.0f; - mtex->translfac= 1.0f; - mtex->ambfac= 1.0f; - mtex->colemitfac= 1.0f; - mtex->colreflfac= 1.0f; - mtex->coltransfac= 1.0f; - mtex->densfac= 1.0f; - mtex->scatterfac= 1.0f; - mtex->reflfac= 1.0f; - mtex->shadowfac= 1.0f; - mtex->zenupfac= 1.0f; - mtex->zendownfac= 1.0f; - mtex->blendfac= 1.0f; - mtex->timefac= 1.0f; - mtex->lengthfac= 1.0f; - mtex->clumpfac= 1.0f; - mtex->kinkfac= 1.0f; - mtex->roughfac= 1.0f; - mtex->padensfac= 1.0f; - mtex->lifefac= 1.0f; - mtex->sizefac= 1.0f; - mtex->ivelfac= 1.0f; - mtex->dampfac= 1.0f; - mtex->gravityfac= 1.0f; - mtex->fieldfac= 1.0f; - mtex->normapspace= MTEX_NSPACE_TANGENT; + mtex->texco = TEXCO_ORCO; + mtex->mapto = MAP_COL; + mtex->object = NULL; + mtex->projx = PROJ_X; + mtex->projy = PROJ_Y; + mtex->projz = PROJ_Z; + mtex->mapping = MTEX_FLAT; + mtex->ofs[0] = 0.0; + mtex->ofs[1] = 0.0; + mtex->ofs[2] = 0.0; + mtex->size[0] = 1.0; + mtex->size[1] = 1.0; + mtex->size[2] = 1.0; + mtex->tex = NULL; + mtex->texflag = MTEX_3TAP_BUMP | MTEX_BUMP_OBJECTSPACE; + mtex->colormodel = 0; + mtex->r = 1.0; + mtex->g = 0.0; + mtex->b = 1.0; + mtex->k = 1.0; + mtex->def_var = 1.0; + mtex->blendtype = MTEX_BLEND; + mtex->colfac = 1.0; + mtex->norfac = 1.0; + mtex->varfac = 1.0; + mtex->dispfac = 0.2; + mtex->colspecfac = 1.0f; + mtex->mirrfac = 1.0f; + mtex->alphafac = 1.0f; + mtex->difffac = 1.0f; + mtex->specfac = 1.0f; + mtex->emitfac = 1.0f; + mtex->hardfac = 1.0f; + mtex->raymirrfac = 1.0f; + mtex->translfac = 1.0f; + mtex->ambfac = 1.0f; + mtex->colemitfac = 1.0f; + mtex->colreflfac = 1.0f; + mtex->coltransfac = 1.0f; + mtex->densfac = 1.0f; + mtex->scatterfac = 1.0f; + mtex->reflfac = 1.0f; + mtex->shadowfac = 1.0f; + mtex->zenupfac = 1.0f; + mtex->zendownfac = 1.0f; + mtex->blendfac = 1.0f; + mtex->timefac = 1.0f; + mtex->lengthfac = 1.0f; + mtex->clumpfac = 1.0f; + mtex->kinkfac = 1.0f; + mtex->roughfac = 1.0f; + mtex->padensfac = 1.0f; + mtex->lifefac = 1.0f; + mtex->sizefac = 1.0f; + mtex->ivelfac = 1.0f; + mtex->dampfac = 1.0f; + mtex->gravityfac = 1.0f; + mtex->fieldfac = 1.0f; + mtex->normapspace = MTEX_NSPACE_TANGENT; } @@ -772,7 +772,7 @@ MTex *add_mtex(void) { MTex *mtex; - mtex= MEM_callocN(sizeof(MTex), "add_mtex"); + mtex = MEM_callocN(sizeof(MTex), "add_mtex"); default_mtex(mtex); @@ -787,16 +787,16 @@ MTex *add_mtex_id(ID *id, int slot) give_active_mtex(id, &mtex_ar, &act); - if (mtex_ar==NULL) { + if (mtex_ar == NULL) { return NULL; } - if (slot==-1) { + if (slot == -1) { /* find first free */ int i; - for (i= 0; i < MAX_MTEX; i++) { + for (i = 0; i < MAX_MTEX; i++) { if (!mtex_ar[i]) { - slot= i; + slot = i; break; } } @@ -814,41 +814,41 @@ MTex *add_mtex_id(ID *id, int slot) if (mtex_ar[slot]) { id_us_min((ID *)mtex_ar[slot]->tex); MEM_freeN(mtex_ar[slot]); - mtex_ar[slot]= NULL; + mtex_ar[slot] = NULL; } - mtex_ar[slot]= add_mtex(); + mtex_ar[slot] = add_mtex(); return mtex_ar[slot]; } /* ------------------------------------------------------------------------- */ -Tex *copy_texture(Tex *tex) +Tex *BKE_texture_copy(Tex *tex) { Tex *texn; - texn= copy_libblock(&tex->id); - if (texn->type==TEX_IMAGE) id_us_plus((ID *)texn->ima); - else texn->ima= NULL; + texn = BKE_libblock_copy(&tex->id); + if (texn->type == TEX_IMAGE) id_us_plus((ID *)texn->ima); + else texn->ima = NULL; if (texn->plugin) { - texn->plugin= MEM_dupallocN(texn->plugin); + texn->plugin = MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); - if (texn->env) texn->env= BKE_copy_envmap(texn->env); - if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); - if (texn->vd) texn->vd= MEM_dupallocN(texn->vd); - if (texn->ot) texn->ot= BKE_copy_oceantex(texn->ot); + if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); + if (texn->env) texn->env = BKE_copy_envmap(texn->env); + if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd); + if (texn->vd) texn->vd = MEM_dupallocN(texn->vd); + if (texn->ot) texn->ot = BKE_copy_oceantex(texn->ot); if (tex->preview) texn->preview = BKE_previewimg_copy(tex->preview); if (tex->nodetree) { if (tex->nodetree->execdata) { ntreeTexEndExecTree(tex->nodetree->execdata, 1); } - texn->nodetree= ntreeCopyTree(tex->nodetree); + texn->nodetree = ntreeCopyTree(tex->nodetree); } return texn; @@ -859,35 +859,35 @@ Tex *localize_texture(Tex *tex) { Tex *texn; - texn= copy_libblock(&tex->id); + texn = BKE_libblock_copy(&tex->id); BLI_remlink(&G.main->tex, texn); - /* image texture: free_texture also doesn't decrease */ + /* image texture: BKE_texture_free also doesn't decrease */ if (texn->plugin) { - texn->plugin= MEM_dupallocN(texn->plugin); + texn->plugin = MEM_dupallocN(texn->plugin); open_plugin_tex(texn->plugin); } - if (texn->coba) texn->coba= MEM_dupallocN(texn->coba); + if (texn->coba) texn->coba = MEM_dupallocN(texn->coba); if (texn->env) { - texn->env= BKE_copy_envmap(texn->env); + texn->env = BKE_copy_envmap(texn->env); id_us_min(&texn->env->ima->id); } - if (texn->pd) texn->pd= BKE_copy_pointdensity(texn->pd); + if (texn->pd) texn->pd = BKE_copy_pointdensity(texn->pd); if (texn->vd) { - texn->vd= MEM_dupallocN(texn->vd); + texn->vd = MEM_dupallocN(texn->vd); if (texn->vd->dataset) - texn->vd->dataset= MEM_dupallocN(texn->vd->dataset); + texn->vd->dataset = MEM_dupallocN(texn->vd->dataset); } if (texn->ot) { - texn->ot= BKE_copy_oceantex(tex->ot); + texn->ot = BKE_copy_oceantex(tex->ot); } texn->preview = NULL; if (tex->nodetree) { - texn->nodetree= ntreeLocalize(tex->nodetree); + texn->nodetree = ntreeLocalize(tex->nodetree); } return texn; @@ -901,76 +901,76 @@ static void extern_local_texture(Tex *tex) id_lib_extern((ID *)tex->ima); } -void make_local_texture(Tex *tex) +void BKE_texture_make_local(Tex *tex) { - Main *bmain= G.main; + Main *bmain = G.main; Material *ma; World *wrld; Lamp *la; Brush *br; ParticleSettings *pa; - int a, is_local= FALSE, is_lib= FALSE; + int a, is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (tex->id.lib==NULL) return; + if (tex->id.lib == NULL) return; - if (tex->id.us==1) { + if (tex->id.us == 1) { id_clear_lib_data(bmain, &tex->id); extern_local_texture(tex); return; } - ma= bmain->mat.first; + ma = bmain->mat.first; while (ma) { - for (a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if (ma->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex == tex) { + if (ma->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - ma= ma->id.next; + ma = ma->id.next; } - la= bmain->lamp.first; + la = bmain->lamp.first; while (la) { - for (a=0; amtex[a] && la->mtex[a]->tex==tex) { - if (la->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (la->mtex[a] && la->mtex[a]->tex == tex) { + if (la->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - la= la->id.next; + la = la->id.next; } - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - for (a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if (wrld->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (wrld->mtex[a] && wrld->mtex[a]->tex == tex) { + if (wrld->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - wrld= wrld->id.next; + wrld = wrld->id.next; } - br= bmain->brush.first; + br = bmain->brush.first; while (br) { - if (br->mtex.tex==tex) { - if (br->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (br->mtex.tex == tex) { + if (br->id.lib) is_lib = TRUE; + else is_local = TRUE; } - br= br->id.next; + br = br->id.next; } - pa= bmain->particle.first; + pa = bmain->particle.first; while (pa) { - for (a=0; amtex[a] && pa->mtex[a]->tex==tex) { - if (pa->id.lib) is_lib= TRUE; - else is_local= TRUE; + for (a = 0; a < MAX_MTEX; a++) { + if (pa->mtex[a] && pa->mtex[a]->tex == tex) { + if (pa->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - pa= pa->id.next; + pa = pa->id.next; } if (is_local && is_lib == FALSE) { @@ -978,75 +978,75 @@ void make_local_texture(Tex *tex) extern_local_texture(tex); } else if (is_local && is_lib) { - Tex *tex_new= copy_texture(tex); + Tex *tex_new = BKE_texture_copy(tex); - tex_new->id.us= 0; + tex_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, tex->id.lib, &tex_new->id); - ma= bmain->mat.first; + ma = bmain->mat.first; while (ma) { - for (a=0; amtex[a] && ma->mtex[a]->tex==tex) { - if (ma->id.lib==NULL) { - ma->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (ma->mtex[a] && ma->mtex[a]->tex == tex) { + if (ma->id.lib == NULL) { + ma->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - ma= ma->id.next; + ma = ma->id.next; } - la= bmain->lamp.first; + la = bmain->lamp.first; while (la) { - for (a=0; amtex[a] && la->mtex[a]->tex==tex) { - if (la->id.lib==NULL) { - la->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (la->mtex[a] && la->mtex[a]->tex == tex) { + if (la->id.lib == NULL) { + la->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - la= la->id.next; + la = la->id.next; } - wrld= bmain->world.first; + wrld = bmain->world.first; while (wrld) { - for (a=0; amtex[a] && wrld->mtex[a]->tex==tex) { - if (wrld->id.lib==NULL) { - wrld->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (wrld->mtex[a] && wrld->mtex[a]->tex == tex) { + if (wrld->id.lib == NULL) { + wrld->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - wrld= wrld->id.next; + wrld = wrld->id.next; } - br= bmain->brush.first; + br = bmain->brush.first; while (br) { - if (br->mtex.tex==tex) { - if (br->id.lib==NULL) { - br->mtex.tex= tex_new; + if (br->mtex.tex == tex) { + if (br->id.lib == NULL) { + br->mtex.tex = tex_new; tex_new->id.us++; tex->id.us--; } } - br= br->id.next; + br = br->id.next; } - pa= bmain->particle.first; + pa = bmain->particle.first; while (pa) { - for (a=0; amtex[a] && pa->mtex[a]->tex==tex) { - if (pa->id.lib==NULL) { - pa->mtex[a]->tex= tex_new; + for (a = 0; a < MAX_MTEX; a++) { + if (pa->mtex[a] && pa->mtex[a]->tex == tex) { + if (pa->id.lib == NULL) { + pa->mtex[a]->tex = tex_new; tex_new->id.us++; tex->id.us--; } } } - pa= pa->id.next; + pa = pa->id.next; } } } @@ -1055,10 +1055,10 @@ void make_local_texture(Tex *tex) #if 0 /* UNUSED */ void autotexname(Tex *tex) { - Main *bmain= G.main; - char texstr[20][15]= {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", - "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", - "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; + Main *bmain = G.main; + char texstr[20][15] = {"None", "Clouds", "Wood", "Marble", "Magic", "Blend", + "Stucci", "Noise", "Image", "Plugin", "EnvMap", "Musgrave", + "Voronoi", "DistNoise", "Point Density", "Voxel Data", "Ocean", "", "", ""}; Image *ima; char di[FILE_MAXDIR], fi[FILE_MAXFILE]; @@ -1067,8 +1067,8 @@ void autotexname(Tex *tex) new_id(&bmain->tex, (ID *)tex, "Noddy"); } else - if (tex->type==TEX_IMAGE) { - ima= tex->ima; + if (tex->type == TEX_IMAGE) { + ima = tex->ima; if (ima) { BLI_strncpy(di, ima->name, sizeof(di)); BLI_splitdirstring(di, fi); @@ -1078,7 +1078,7 @@ void autotexname(Tex *tex) } else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } - else if (tex->type==TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); + else if (tex->type == TEX_PLUGIN && tex->plugin) new_id(&bmain->tex, (ID *)tex, tex->plugin->pname); else new_id(&bmain->tex, (ID *)tex, texstr[tex->type]); } } @@ -1089,21 +1089,21 @@ void autotexname(Tex *tex) Tex *give_current_object_texture(Object *ob) { Material *ma, *node_ma; - Tex *tex= NULL; + Tex *tex = NULL; - if (ob==NULL) return NULL; - if (ob->totcol==0 && !(ob->type==OB_LAMP)) return NULL; + if (ob == NULL) return NULL; + if (ob->totcol == 0 && !(ob->type == OB_LAMP)) return NULL; - if (ob->type==OB_LAMP) { - tex= give_current_lamp_texture(ob->data); + if (ob->type == OB_LAMP) { + tex = give_current_lamp_texture(ob->data); } else { - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); - if ((node_ma=give_node_material(ma))) - ma= node_ma; + if ((node_ma = give_node_material(ma))) + ma = node_ma; - tex= give_current_material_texture(ma); + tex = give_current_material_texture(ma); } return tex; @@ -1111,12 +1111,12 @@ Tex *give_current_object_texture(Object *ob) Tex *give_current_lamp_texture(Lamp *la) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (la) { - mtex= la->mtex[(int)(la->texact)]; - if (mtex) tex= mtex->tex; + mtex = la->mtex[(int)(la->texact)]; + if (mtex) tex = mtex->tex; } return tex; @@ -1124,23 +1124,23 @@ Tex *give_current_lamp_texture(Lamp *la) void set_current_lamp_texture(Lamp *la, Tex *newtex) { - int act= la->texact; + int act = la->texact; if (la->mtex[act] && la->mtex[act]->tex) id_us_min(&la->mtex[act]->tex->id); if (newtex) { if (!la->mtex[act]) { - la->mtex[act]= add_mtex(); - la->mtex[act]->texco= TEXCO_GLOB; + la->mtex[act] = add_mtex(); + la->mtex[act]->texco = TEXCO_GLOB; } - la->mtex[act]->tex= newtex; + la->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (la->mtex[act]) { MEM_freeN(la->mtex[act]); - la->mtex[act]= NULL; + la->mtex[act] = NULL; } } @@ -1154,25 +1154,25 @@ bNode *give_current_material_texture_node(Material *ma) Tex *give_current_material_texture(Material *ma) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; bNode *node; if (ma && ma->use_nodes && ma->nodetree) { /* first check texture, then material, this works together * with a hack that clears the active ID flag for textures on * making a material node active */ - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) { - tex= (Tex *)node->id; - ma= NULL; + tex = (Tex *)node->id; + ma = NULL; } } if (ma) { - mtex= ma->mtex[(int)(ma->texact)]; - if (mtex) tex= mtex->tex; + mtex = ma->mtex[(int)(ma->texact)]; + if (mtex) tex = mtex->tex; } return tex; @@ -1181,26 +1181,26 @@ Tex *give_current_material_texture(Material *ma) int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) { switch (GS(id->name)) { - case ID_MA: - *mtex_ar= ((Material *)id)->mtex; - if (act) *act= (((Material *)id)->texact); - break; - case ID_WO: - *mtex_ar= ((World *)id)->mtex; - if (act) *act= (((World *)id)->texact); - break; - case ID_LA: - *mtex_ar= ((Lamp *)id)->mtex; - if (act) *act= (((Lamp *)id)->texact); - break; - case ID_PA: - *mtex_ar= ((ParticleSettings *)id)->mtex; - if (act) *act= (((ParticleSettings *)id)->texact); - break; - default: - *mtex_ar = NULL; - if (act) *act= 0; - return FALSE; + case ID_MA: + *mtex_ar = ((Material *)id)->mtex; + if (act) *act = (((Material *)id)->texact); + break; + case ID_WO: + *mtex_ar = ((World *)id)->mtex; + if (act) *act = (((World *)id)->texact); + break; + case ID_LA: + *mtex_ar = ((Lamp *)id)->mtex; + if (act) *act = (((Lamp *)id)->texact); + break; + case ID_PA: + *mtex_ar = ((ParticleSettings *)id)->mtex; + if (act) *act = (((ParticleSettings *)id)->texact); + break; + default: + *mtex_ar = NULL; + if (act) *act = 0; + return FALSE; } return TRUE; @@ -1208,57 +1208,57 @@ int give_active_mtex(ID *id, MTex ***mtex_ar, short *act) void set_active_mtex(ID *id, short act) { - if (act<0) act= 0; - else if (act>=MAX_MTEX) act= MAX_MTEX-1; + if (act < 0) act = 0; + else if (act >= MAX_MTEX) act = MAX_MTEX - 1; switch (GS(id->name)) { - case ID_MA: - ((Material *)id)->texact= act; - break; - case ID_WO: - ((World *)id)->texact= act; - break; - case ID_LA: - ((Lamp *)id)->texact= act; - break; - case ID_PA: - ((ParticleSettings *)id)->texact= act; - break; + case ID_MA: + ((Material *)id)->texact = act; + break; + case ID_WO: + ((World *)id)->texact = act; + break; + case ID_LA: + ((Lamp *)id)->texact = act; + break; + case ID_PA: + ((ParticleSettings *)id)->texact = act; + break; } } void set_current_material_texture(Material *ma, Tex *newtex) { - Tex *tex= NULL; + Tex *tex = NULL; bNode *node; if (ma && ma->use_nodes && ma->nodetree) { - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) { - tex= (Tex *)node->id; + tex = (Tex *)node->id; id_us_min(&tex->id); - node->id= &newtex->id; + node->id = &newtex->id; id_us_plus(&newtex->id); - ma= NULL; + ma = NULL; } } if (ma) { - int act= (int)ma->texact; + int act = (int)ma->texact; - tex= (ma->mtex[act])? ma->mtex[act]->tex: NULL; + tex = (ma->mtex[act]) ? ma->mtex[act]->tex : NULL; id_us_min(&tex->id); if (newtex) { if (!ma->mtex[act]) - ma->mtex[act]= add_mtex(); + ma->mtex[act] = add_mtex(); - ma->mtex[act]->tex= newtex; + ma->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (ma->mtex[act]) { MEM_freeN(ma->mtex[act]); - ma->mtex[act]= NULL; + ma->mtex[act] = NULL; } } } @@ -1268,7 +1268,7 @@ int has_current_material_texture(Material *ma) bNode *node; if (ma && ma->use_nodes && ma->nodetree) { - node= nodeGetActiveID(ma->nodetree, ID_TE); + node = nodeGetActiveID(ma->nodetree, ID_TE); if (node) return 1; @@ -1279,36 +1279,36 @@ int has_current_material_texture(Material *ma) Tex *give_current_world_texture(World *world) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (!world) return NULL; - mtex= world->mtex[(int)(world->texact)]; - if (mtex) tex= mtex->tex; + mtex = world->mtex[(int)(world->texact)]; + if (mtex) tex = mtex->tex; return tex; } void set_current_world_texture(World *wo, Tex *newtex) { - int act= wo->texact; + int act = wo->texact; if (wo->mtex[act] && wo->mtex[act]->tex) id_us_min(&wo->mtex[act]->tex->id); if (newtex) { if (!wo->mtex[act]) { - wo->mtex[act]= add_mtex(); - wo->mtex[act]->texco= TEXCO_VIEW; + wo->mtex[act] = add_mtex(); + wo->mtex[act]->texco = TEXCO_VIEW; } - wo->mtex[act]->tex= newtex; + wo->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (wo->mtex[act]) { MEM_freeN(wo->mtex[act]); - wo->mtex[act]= NULL; + wo->mtex[act] = NULL; } } @@ -1323,44 +1323,44 @@ void set_current_brush_texture(Brush *br, Tex *newtex) id_us_min(&br->mtex.tex->id); if (newtex) { - br->mtex.tex= newtex; + br->mtex.tex = newtex; id_us_plus(&newtex->id); } } Tex *give_current_particle_texture(ParticleSettings *part) { - MTex *mtex= NULL; - Tex *tex= NULL; + MTex *mtex = NULL; + Tex *tex = NULL; if (!part) return NULL; - mtex= part->mtex[(int)(part->texact)]; - if (mtex) tex= mtex->tex; + mtex = part->mtex[(int)(part->texact)]; + if (mtex) tex = mtex->tex; return tex; } void set_current_particle_texture(ParticleSettings *part, Tex *newtex) { - int act= part->texact; + int act = part->texact; if (part->mtex[act] && part->mtex[act]->tex) id_us_min(&part->mtex[act]->tex->id); if (newtex) { if (!part->mtex[act]) { - part->mtex[act]= add_mtex(); - part->mtex[act]->texco= TEXCO_ORCO; - part->mtex[act]->blendtype= MTEX_MUL; + part->mtex[act] = add_mtex(); + part->mtex[act]->texco = TEXCO_ORCO; + part->mtex[act]->blendtype = MTEX_MUL; } - part->mtex[act]->tex= newtex; + part->mtex[act]->tex = newtex; id_us_plus(&newtex->id); } else if (part->mtex[act]) { MEM_freeN(part->mtex[act]); - part->mtex[act]= NULL; + part->mtex[act] = NULL; } } @@ -1370,12 +1370,12 @@ EnvMap *BKE_add_envmap(void) { EnvMap *env; - env= MEM_callocN(sizeof(EnvMap), "envmap"); - env->type= ENV_CUBE; - env->stype= ENV_ANIM; - env->clipsta= 0.1; - env->clipend= 100.0; - env->cuberes= 600; + env = MEM_callocN(sizeof(EnvMap), "envmap"); + env->type = ENV_CUBE; + env->stype = ENV_ANIM; + env->clipsta = 0.1; + env->clipend = 100.0; + env->cuberes = 600; env->viewscale = 0.5; return env; @@ -1388,9 +1388,9 @@ EnvMap *BKE_copy_envmap(EnvMap *env) EnvMap *envn; int a; - envn= MEM_dupallocN(env); - envn->ok= 0; - for (a=0; a<6; a++) envn->cube[a]= NULL; + envn = MEM_dupallocN(env); + envn->ok = 0; + for (a = 0; a < 6; a++) envn->cube[a] = NULL; if (envn->ima) id_us_plus((ID *)envn->ima); return envn; @@ -1402,12 +1402,12 @@ void BKE_free_envmapdata(EnvMap *env) { unsigned int part; - for (part=0; part<6; part++) { + for (part = 0; part < 6; part++) { if (env->cube[part]) IMB_freeImBuf(env->cube[part]); - env->cube[part]= NULL; + env->cube[part] = NULL; } - env->ok= 0; + env->ok = 0; } /* ------------------------------------------------------------------------- */ @@ -1426,7 +1426,7 @@ PointDensity *BKE_add_pointdensity(void) { PointDensity *pd; - pd= MEM_callocN(sizeof(PointDensity), "pointdensity"); + pd = MEM_callocN(sizeof(PointDensity), "pointdensity"); pd->flag = 0; pd->radius = 0.3f; pd->falloff_type = TEX_PD_FALLOFF_STD; @@ -1443,7 +1443,7 @@ PointDensity *BKE_add_pointdensity(void) pd->totpoints = 0; pd->object = NULL; pd->psys = 0; - pd->psys_cache_space= TEX_PD_WORLDSPACE; + pd->psys_cache_space = TEX_PD_WORLDSPACE; pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); pd->falloff_curve->preset = CURVE_PRESET_LINE; @@ -1458,10 +1458,10 @@ PointDensity *BKE_copy_pointdensity(PointDensity *pd) { PointDensity *pdn; - pdn= MEM_dupallocN(pd); + pdn = MEM_dupallocN(pd); pdn->point_tree = NULL; pdn->point_data = NULL; - if (pdn->coba) pdn->coba= MEM_dupallocN(pdn->coba); + if (pdn->coba) pdn->coba = MEM_dupallocN(pdn->coba); pdn->falloff_curve = curvemapping_copy(pdn->falloff_curve); /* can be NULL */ return pdn; } @@ -1492,7 +1492,7 @@ void BKE_free_pointdensity(PointDensity *pd) /* ------------------------------------------------------------------------- */ -void BKE_free_voxeldatadata(struct VoxelData *vd) +void BKE_free_voxeldatadata(VoxelData *vd) { if (vd->dataset) { MEM_freeN(vd->dataset); @@ -1501,21 +1501,21 @@ void BKE_free_voxeldatadata(struct VoxelData *vd) } -void BKE_free_voxeldata(struct VoxelData *vd) +void BKE_free_voxeldata(VoxelData *vd) { BKE_free_voxeldatadata(vd); MEM_freeN(vd); } -struct VoxelData *BKE_add_voxeldata(void) +VoxelData *BKE_add_voxeldata(void) { VoxelData *vd; - vd= MEM_callocN(sizeof(struct VoxelData), "voxeldata"); + vd = MEM_callocN(sizeof(VoxelData), "voxeldata"); vd->dataset = NULL; vd->resol[0] = vd->resol[1] = vd->resol[2] = 1; - vd->interp_type= TEX_VD_LINEAR; - vd->file_format= TEX_VD_SMOKE; + vd->interp_type = TEX_VD_LINEAR; + vd->file_format = TEX_VD_SMOKE; vd->int_multiplier = 1.0; vd->extend = TEX_CLIP; vd->object = NULL; @@ -1523,13 +1523,13 @@ struct VoxelData *BKE_add_voxeldata(void) vd->ok = 0; return vd; - } +} -struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) +VoxelData *BKE_copy_voxeldata(VoxelData *vd) { VoxelData *vdn; - vdn= MEM_dupallocN(vd); + vdn = MEM_dupallocN(vd); vdn->dataset = NULL; return vdn; @@ -1537,20 +1537,20 @@ struct VoxelData *BKE_copy_voxeldata(struct VoxelData *vd) /* ------------------------------------------------------------------------- */ -struct OceanTex *BKE_add_oceantex(void) +OceanTex *BKE_add_oceantex(void) { OceanTex *ot; - ot= MEM_callocN(sizeof(struct OceanTex), "ocean texture"); + ot = MEM_callocN(sizeof(struct OceanTex), "ocean texture"); ot->output = TEX_OCN_DISPLACEMENT; ot->object = NULL; return ot; } -struct OceanTex *BKE_copy_oceantex(struct OceanTex *ot) +OceanTex *BKE_copy_oceantex(struct OceanTex *ot) { - OceanTex *otn= MEM_dupallocN(ot); + OceanTex *otn = MEM_dupallocN(ot); return otn; } @@ -1568,8 +1568,9 @@ int BKE_texture_dependsOnTime(const struct Tex *texture) // assume all plugins depend on time return 1; } - else if ( texture->ima && - ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) { + else if (texture->ima && + ELEM(texture->ima->source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) + { return 1; } else if (texture->adt) { diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c index f4335862629..4e2b4be474b 100644 --- a/source/blender/blenkernel/intern/tracking.c +++ b/source/blender/blenkernel/intern/tracking.c @@ -166,11 +166,11 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) /* search shouldn't be moved inside pattern */ if (track->search_min[a] > pat_min[a]) { track->search_min[a] = pat_min[a]; - track->search_max[a] = track->search_min[a]+dim[a]; + track->search_max[a] = track->search_min[a] + dim[a]; } if (track->search_max[a] < pat_max[a]) { track->search_max[a] = pat_max[a]; - track->search_min[a] = track->search_max[a]-dim[a]; + track->search_min[a] = track->search_max[a] - dim[a]; } } } @@ -196,8 +196,8 @@ void BKE_tracking_clamp_track(MovieTrackingTrack *track, int event) sub_v2_v2v2(dim, track->pat_max, track->pat_min); for (a = 0; a < 2; a++) { - track->pat_min[a] = -dim[a]/2.0f; - track->pat_max[a] = dim[a]/2.0f; + track->pat_min[a] = -dim[a] / 2.0f; + track->pat_max[a] = dim[a] / 2.0f; } } } @@ -302,8 +302,9 @@ MovieTrackingMarker *BKE_tracking_insert_marker(MovieTrackingTrack *track, Movie else track->markers = MEM_callocN(sizeof(MovieTrackingMarker), "MovieTracking markers"); - memmove(track->markers+a+2, track->markers+a+1, (track->markersnr-a-2)*sizeof(MovieTrackingMarker)); - track->markers[a+1] = *marker; + memmove(track->markers + a + 2, track->markers + a + 1, + (track->markersnr - a - 2) * sizeof(MovieTrackingMarker)); + track->markers[a + 1] = *marker; track->last_marker = a + 1; @@ -315,12 +316,13 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) { int a = 0; - while (amarkersnr) { + while (a < track->markersnr) { if (track->markers[a].framenr == framenr) { if (track->markersnr > 1) { - memmove(track->markers+a, track->markers+a+1, (track->markersnr-a-1)*sizeof(MovieTrackingMarker)); + memmove(track->markers + a, track->markers + a + 1, + (track->markersnr - a - 1) * sizeof(MovieTrackingMarker)); track->markersnr--; - track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr); + track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker) * track->markersnr); } else { MEM_freeN(track->markers); @@ -337,7 +339,7 @@ void BKE_tracking_delete_marker(MovieTrackingTrack *track, int framenr) MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int framenr) { - int a = track->markersnr-1; + int a = track->markersnr - 1; if (!track->markersnr) return NULL; @@ -360,7 +362,7 @@ MovieTrackingMarker *BKE_tracking_get_marker(MovieTrackingTrack *track, int fram } /* if there's no marker for exact position, use nearest marker from left side */ - return &track->markers[a-1]; + return &track->markers[a - 1]; } else { while (a >= 0 && track->markers[a].framenr >= framenr) { @@ -461,16 +463,16 @@ void BKE_tracking_clear_path(MovieTrackingTrack *track, int ref_frame, int actio } if (track->markersnr) - put_disabled_marker(track, &track->markers[track->markersnr-1], 0, 1); + put_disabled_marker(track, &track->markers[track->markersnr - 1], 0, 1); } else if (action == TRACK_CLEAR_UPTO) { - a = track->markersnr-1; + a = track->markersnr - 1; while (a >= 0) { if (track->markers[a].framenr <= ref_frame) { - memmove(track->markers, track->markers+a, (track->markersnr-a)*sizeof(MovieTrackingMarker)); + memmove(track->markers, track->markers + a, (track->markersnr - a) * sizeof(MovieTrackingMarker)); - track->markersnr = track->markersnr-a; + track->markersnr = track->markersnr - a; track->markers = MEM_reallocN(track->markers, sizeof(MovieTrackingMarker)*track->markersnr); break; @@ -521,8 +523,8 @@ void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack markers[i] = dst_track->markers[b++]; } else { - if ((src_track->markers[a].flag & MARKER_DISABLED)==0) { - if ((dst_track->markers[b].flag & MARKER_DISABLED)==0) { + if ((src_track->markers[a].flag & MARKER_DISABLED) == 0) { + if ((dst_track->markers[b].flag & MARKER_DISABLED) == 0) { /* both tracks are enabled on this frame, so find the whole segment * on which tracks are intersecting and blend tracks using linear * interpolation to prevent jumps */ @@ -532,8 +534,8 @@ void BKE_tracking_join_tracks(MovieTrackingTrack *dst_track, MovieTrackingTrack int j, inverse = 0; inverse = (b == 0) || - (dst_track->markers[b-1].flag & MARKER_DISABLED) || - (dst_track->markers[b-1].framenr != frame - 1); + (dst_track->markers[b - 1].flag & MARKER_DISABLED) || + (dst_track->markers[b - 1].framenr != frame - 1); /* find length of intersection */ while (a < src_track->markersnr && b < dst_track->markersnr) { @@ -969,7 +971,7 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u /* count */ track = tracksbase->first; while (track) { - if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN))==0) { + if (TRACK_SELECTED(track) && (track->flag & (TRACK_LOCKED | TRACK_HIDDEN)) == 0) { MovieTrackingMarker *marker = BKE_tracking_get_marker(track, user->framenr); if ((marker->flag & MARKER_DISABLED) == 0) @@ -1000,13 +1002,13 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u #ifdef WITH_LIBMV { - float patx = (int)((track->pat_max[0]-track->pat_min[0])*width), - paty = (int)((track->pat_max[1]-track->pat_min[1])*height); + float patx = (int)((track->pat_max[0] - track->pat_min[0]) * width), + paty = (int)((track->pat_max[1] - track->pat_min[1]) * height); - float search_size_x = (track->search_max[0]-track->search_min[0])*width; - float search_size_y = (track->search_max[1]-track->search_min[1])*height; - float pattern_size_x = (track->pat_max[0]-track->pat_min[0])*width; - float pattern_size_y = (track->pat_max[1]-track->pat_min[1])*height; + float search_size_x = (track->search_max[0] - track->search_min[0]) * width; + float search_size_y = (track->search_max[1] - track->search_min[1]) * height; + float pattern_size_x = (track->pat_max[0] - track->pat_min[0]) * width; + float pattern_size_y = (track->pat_max[1] - track->pat_min[1]) * height; int wndx = (int)patx / 2, wndy = (int)paty / 2; int half_wnd = MAX2(wndx, wndy); @@ -1021,17 +1023,20 @@ MovieTrackingContext *BKE_tracking_context_new(MovieClip *clip, MovieClipUser *u * than the search size */ int level = MIN2(track->pyramid_levels, max_pyramid_levels); + struct libmv_RegionTracker *region_tracker; + if (track->tracker == TRACKER_KLT) { - track_context.region_tracker = - libmv_pyramidRegionTrackerNew(100, level, half_wnd, track->minimum_correlation); + region_tracker = libmv_pyramidRegionTrackerNew(100, level, half_wnd, + track->minimum_correlation); } else if (track->tracker == TRACKER_HYBRID) { - track_context.region_tracker = - libmv_hybridRegionTrackerNew(100, half_wnd, track->minimum_correlation); + region_tracker = libmv_hybridRegionTrackerNew(100, half_wnd, track->minimum_correlation); } else if (track->tracker == TRACKER_SAD) { - track_context.region_tracker = libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); + region_tracker = libmv_bruteRegionTrackerNew(MAX2(wndx, wndy), track->minimum_correlation); } + + track_context.region_tracker = region_tracker; } #endif @@ -1094,7 +1099,8 @@ void BKE_tracking_context_free(MovieTrackingContext *context) /* zap channels from the imbuf that are disabled by the user. this can lead to * better tracks sometimes. however, instead of simply zeroing the channels * out, do a partial grayscale conversion so the display is better. */ -void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, int grayscale) +void BKE_tracking_disable_imbuf_channels(ImBuf *ibuf, int disable_red, int disable_green, int disable_blue, + int grayscale) { int x, y; float scale; @@ -1181,13 +1187,19 @@ static ImBuf *get_area_imbuf(ImBuf *ibuf, MovieTrackingTrack *track, MovieTracki h = (max[1] - min[1]) * ibuf->y; /* dimensions should be odd */ - w = w|1; - h = h|1; + w = w | 1; + h = h | 1; - x1 = x-(int)(w * (-min[0] / (max[0] - min[0]))); - y1 = y-(int)(h * (-min[1] / (max[1] - min[1]))); + x1 = x - (int)(w * (-min[0] / (max[0] - min[0]))); + y1 = y - (int)(h * (-min[1] / (max[1] - min[1]))); + + if (ibuf->rect_float) + tmpibuf = IMB_allocImBuf(w + margin * 2, h + margin * 2, 32, IB_rectfloat); + else + tmpibuf = IMB_allocImBuf(w + margin * 2, h + margin * 2, 32, IB_rect); + + tmpibuf->profile = ibuf->profile; - tmpibuf = IMB_allocImBuf(w+margin*2, h+margin*2, 32, IB_rect); IMB_rectcpy(tmpibuf, ibuf, 0, 0, x1 - margin, y1 - margin, w + margin * 2, h + margin * 2); if (pos != NULL) { @@ -1310,17 +1322,17 @@ static ImBuf *get_keyframed_ibuf(MovieTrackingContext *context, MovieTrackingTra MovieTrackingMarker *marker, MovieTrackingMarker **marker_keyed) { int framenr = marker->framenr; - int a = marker-track->markers; + int a = marker - track->markers; *marker_keyed = marker; while (a >= 0 && a < track->markersnr) { - int next = (context->backwards) ? a+1 : a-1; + int next = (context->backwards) ? a + 1 : a - 1; int is_keyframed = FALSE; MovieTrackingMarker *cur_marker = &track->markers[a]; MovieTrackingMarker *next_marker = NULL; - if (next>=0 && nextmarkersnr) + if (next >= 0 && next < track->markersnr) next_marker = &track->markers[next]; /* if next mrker is disabled, stop searching keyframe and use current frame as keyframe */ @@ -1442,8 +1454,8 @@ int BKE_tracking_next(MovieTrackingContext *context) margin[1] = MAX2(margin[1], (float)track->margin / ibuf_new->y); /* do not track markers which are too close to boundary */ - if (marker->pos[0]pos[0]>1.0f-margin[0] || - marker->pos[1]pos[1]>1.0f-margin[1]) + if (marker->pos[0] < margin[0] || marker->pos[0] > 1.0f - margin[0] || + marker->pos[1] < margin[1] || marker->pos[1] > 1.0f - margin[1]) { onbound = TRUE; } @@ -1669,7 +1681,8 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M reconstruction->camnr = 0; reconstruction->cameras = NULL; - reconstructed = MEM_callocN((efra-sfra+1)*sizeof(MovieReconstructedCamera), "temp reconstructed camera"); + reconstructed = MEM_callocN((efra - sfra + 1) * sizeof(MovieReconstructedCamera), + "temp reconstructed camera"); for (a = sfra; a <= efra; a++) { double matd[4][4]; @@ -1704,8 +1717,9 @@ static int retrieve_libmv_reconstruct_tracks(MovieReconstructContext *context, M } if (reconstruction->camnr) { - reconstruction->cameras = MEM_callocN(reconstruction->camnr * sizeof(MovieReconstructedCamera), "reconstructed camera"); - memcpy(reconstruction->cameras, reconstructed, reconstruction->camnr * sizeof(MovieReconstructedCamera)); + int size = reconstruction->camnr * sizeof(MovieReconstructedCamera); + reconstruction->cameras = MEM_callocN(size, "reconstructed camera"); + memcpy(reconstruction->cameras, reconstructed, size); } if (origin_set) { @@ -1783,7 +1797,8 @@ int BKE_tracking_can_reconstruct(MovieTracking *tracking, MovieTrackingObject *o return TRUE; } else if (count_tracks_on_both_keyframes(tracking, tracksbase) < 8) { - BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", error_size); + BLI_strncpy(error_msg, "At least 8 common tracks on both of keyframes are needed for reconstruction", + error_size); return FALSE; } @@ -1818,7 +1833,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * track = tracksbase->first; while (track) { - int first = 0, last = track->markersnr-1; + int first = 0, last = track->markersnr - 1; MovieTrackingMarker *first_marker = &track->markers[0]; MovieTrackingMarker *last_marker = &track->markers[track->markersnr - 1]; @@ -1834,7 +1849,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking * last_marker--; } - if (firstmarkersnr - 1) + if (first < track->markersnr - 1) sfra = MIN2(sfra, first_marker->framenr); if (last >= 0) @@ -2010,21 +2025,21 @@ static int reconstruction_camera_index(MovieTrackingReconstruction *reconstructi if (!reconstruction->camnr) return -1; - if (framenrcameras[reconstruction->camnr - 1].framenr) { + if (framenr > cameras[reconstruction->camnr - 1].framenr) { if (nearest) return reconstruction->camnr - 1; else return -1; } - if (reconstruction->last_cameracamnr) + if (reconstruction->last_camera < reconstruction->camnr) a = reconstruction->last_camera; if (cameras[a].framenr >= framenr) @@ -2106,9 +2121,9 @@ void BKE_tracking_get_interpolated_camera(MovieTracking *tracking, MovieTracking } if (cameras[a].framenr != framenr && a > 0 && a < reconstruction->camnr - 1) { - float t = ((float)framenr-cameras[a].framenr) / (cameras[a + 1].framenr-cameras[a].framenr); + float t = ((float)framenr - cameras[a].framenr) / (cameras[a + 1].framenr - cameras[a].framenr); - blend_m4_m4m4(mat, cameras[a].mat, cameras[a+1].mat, t); + blend_m4_m4m4(mat, cameras[a].mat, cameras[a + 1].mat, t); } else { copy_m4_m4(mat, cameras[a].mat); @@ -2123,11 +2138,11 @@ void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4]) if (scene->camera) ob = scene->camera; else - ob = scene_find_camera(scene); + ob = BKE_scene_camera_find(scene); } if (ob) - where_is_object_mat(scene, ob, mat); + BKE_object_where_is_calc_mat4(scene, ob, mat); else unit_m4(mat); } @@ -2135,8 +2150,8 @@ void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4]) void BKE_tracking_camera_shift(MovieTracking *tracking, int winx, int winy, float *shiftx, float *shifty) { /* indeed in both of cases it should be winx -- it's just how camera shift works for blender's camera */ - *shiftx = (0.5f * winx-tracking->camera.principal[0]) / winx; - *shifty = (0.5f * winy-tracking->camera.principal[1]) / winx; + *shiftx = (0.5f * winx - tracking->camera.principal[0]) / winx; + *shifty = (0.5f * winy - tracking->camera.principal[1]) / winx; } void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camera *camera, int width, int height) @@ -2145,9 +2160,9 @@ void BKE_tracking_camera_to_blender(MovieTracking *tracking, Scene *scene, Camer camera->sensor_x = tracking->camera.sensor_width; camera->sensor_fit = CAMERA_SENSOR_FIT_AUTO; - camera->lens = focal*camera->sensor_x/width; + camera->lens = focal * camera->sensor_x / width; - scene->r.xsch = width*tracking->camera.pixel_aspect; + scene->r.xsch = width * tracking->camera.pixel_aspect; scene->r.ysch = height; scene->r.xasp = 1.0f; @@ -2160,7 +2175,7 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject int framenr, int winx, int winy, float mat[4][4]) { MovieReconstructedCamera *camera; - float lens = tracking->camera.focal*tracking->camera.sensor_width/(float)winx; + float lens = tracking->camera.focal * tracking->camera.sensor_width / (float)winx; float viewfac, pixsize, left, right, bottom, top, clipsta, clipend; float winmat[4][4]; float ycor = 1.0f / tracking->camera.pixel_aspect; @@ -2172,11 +2187,11 @@ void BKE_tracking_projection_matrix(MovieTracking *tracking, MovieTrackingObject clipend = 1000.0f; if (winx >= winy) - viewfac = (lens*winx)/tracking->camera.sensor_width; + viewfac = (lens * winx) / tracking->camera.sensor_width; else - viewfac = (ycor*lens*winy)/tracking->camera.sensor_width; + viewfac = (ycor * lens * winy) / tracking->camera.sensor_width; - pixsize = clipsta/viewfac; + pixsize = clipsta / viewfac; left = -0.5f * (float)winx + shiftx * winside; bottom = -0.5f * (ycor) * (float)winy + shifty * winside; @@ -2278,7 +2293,7 @@ void BKE_tracking_apply_intrinsics(MovieTracking *tracking, float co[2], float n #ifdef WITH_LIBMV double x, y; - float aspy = 1.0f/tracking->camera.pixel_aspect; + float aspy = 1.0f / tracking->camera.pixel_aspect; /* normalize coords */ x = (co[0] - camera->principal[0]) / camera->focal; @@ -2326,7 +2341,7 @@ static int point_in_stroke(bGPDstroke *stroke, float x, float y) prev = stroke->totpoints - 1; - for (i = 0; itotpoints; i++) { + for (i = 0; i < stroke->totpoints; i++) { if ((points[i].y < y && points[prev].y >= y) || (points[prev].y < y && points[i].y >= y)) { float fac = (y - points[i].y) / (points[prev].y - points[i].y); @@ -2507,7 +2522,7 @@ static void calculate_stabdata(MovieTracking *tracking, int framenr, float width b[0] *= width; b[1] *= height; - *angle = -atan2(a[0]*b[1]-a[1]*b[0], a[0]*b[0]+a[1]*b[1]); + *angle = -atan2(a[0] * b[1] - a[1] * b[0], a[0] * b[0] + a[1] * b[1]); *angle *= stab->rotinf; /* convert to rotation around image center */ @@ -2563,10 +2578,10 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width, for (i = 0; i < 4; i++) { int j; - float a[3] = {0.0f, 0.0f, 0.0f}, b[3]= {0.0f, 0.0f, 0.0f}; + float a[3] = {0.0f, 0.0f, 0.0f}, b[3] = {0.0f, 0.0f, 0.0f}; copy_v3_v3(a, points[i]); - copy_v3_v3(b, points[(i+1)%4]); + copy_v3_v3(b, points[(i + 1) % 4]); mul_m4_v3(mat, a); mul_m4_v3(mat, b); @@ -2622,7 +2637,7 @@ static float stabilization_auto_scale_factor(MovieTracking *tracking, int width, stab->scale = scale; - if (stab->maxscale>0.0f) + if (stab->maxscale > 0.0f) stab->scale = MIN2(stab->scale, stab->maxscale); } else { @@ -2663,7 +2678,8 @@ static ImBuf* stabilize_alloc_ibuf(ImBuf *cacheibuf, ImBuf *srcibuf, int fill) return cacheibuf; } -void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int width, int height, float loc[2], float *scale, float *angle) +void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int width, int height, + float loc[2], float *scale, float *angle) { float firstmedian[2], median[2]; MovieTrackingStabilization *stab = &tracking->stabilization; @@ -2701,7 +2717,8 @@ void BKE_tracking_stabilization_data(MovieTracking *tracking, int framenr, int w } } -ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, float loc[2], float *scale, float *angle) +ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, + float loc[2], float *scale, float *angle) { float tloc[2], tscale, tangle; MovieTrackingStabilization *stab = &tracking->stabilization; @@ -2798,10 +2815,11 @@ ImBuf *BKE_tracking_stabilize(MovieTracking *tracking, int framenr, ImBuf *ibuf, return tmpibuf; } -void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, float loc[2], float scale, float angle, float mat[4][4]) +void BKE_tracking_stabdata_to_mat4(int width, int height, float aspect, + float loc[2], float scale, float angle, float mat[4][4]) { float lmat[4][4], rmat[4][4], smat[4][4], cmat[4][4], icmat[4][4], amat[4][4], iamat[4][4]; - float svec[3]= {scale, scale, scale}; + float svec[3] = {scale, scale, scale}; unit_m4(rmat); unit_m4(lmat); @@ -3013,7 +3031,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob MovieTrackingTrack *track; int index = BLI_findindex(&tracking->objects, object); - if (index<0) + if (index < 0) return; if (object->flag & TRACKING_OBJECT_CAMERA) { @@ -3034,7 +3052,7 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob tracking->tot_object--; - if (index>0) + if (index > 0) tracking->objectnr = index - 1; else tracking->objectnr = 0; @@ -3042,7 +3060,8 @@ void BKE_tracking_remove_object(MovieTracking *tracking, MovieTrackingObject *ob void BKE_tracking_object_unique_name(MovieTracking *tracking, MovieTrackingObject *object) { - BLI_uniquename(&tracking->objects, object, "Object", '.', offsetof(MovieTrackingObject, name), sizeof(object->name)); + BLI_uniquename(&tracking->objects, object, "Object", '.', + offsetof(MovieTrackingObject, name), sizeof(object->name)); } MovieTrackingObject *BKE_tracking_named_object(MovieTracking *tracking, const char *name) diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c index 07a83da3d8c..303098ea0bd 100644 --- a/source/blender/blenkernel/intern/world.c +++ b/source/blender/blenkernel/intern/world.c @@ -51,13 +51,13 @@ #include "BKE_node.h" #include "BKE_world.h" -void free_world(World *wrld) +void BKE_world_free(World *wrld) { MTex *mtex; int a; - for (a=0; amtex[a]; + for (a = 0; a < MAX_MTEX; a++) { + mtex = wrld->mtex[a]; if (mtex && mtex->tex) mtex->tex->id.us--; if (mtex) MEM_freeN(mtex); } @@ -71,40 +71,40 @@ void free_world(World *wrld) MEM_freeN(wrld->nodetree); } - BKE_icon_delete((struct ID*)wrld); + BKE_icon_delete((struct ID *)wrld); wrld->id.icon_id = 0; } World *add_world(const char *name) { - Main *bmain= G.main; + Main *bmain = G.main; World *wrld; - wrld= alloc_libblock(&bmain->world, ID_WO, name); + wrld = BKE_libblock_alloc(&bmain->world, ID_WO, name); - wrld->horr= 0.05f; - wrld->horg= 0.05f; - wrld->horb= 0.05f; - wrld->zenr= 0.01f; - wrld->zeng= 0.01f; - wrld->zenb= 0.01f; - wrld->skytype= 0; - wrld->stardist= 15.0f; - wrld->starsize= 2.0f; - - wrld->exp= 0.0f; - wrld->exposure=wrld->range= 1.0f; + wrld->horr = 0.05f; + wrld->horg = 0.05f; + wrld->horb = 0.05f; + wrld->zenr = 0.01f; + wrld->zeng = 0.01f; + wrld->zenb = 0.01f; + wrld->skytype = 0; + wrld->stardist = 15.0f; + wrld->starsize = 2.0f; - wrld->aodist= 10.0f; - wrld->aosamp= 5; - wrld->aoenergy= 1.0f; - wrld->ao_env_energy= 1.0f; - wrld->ao_indirect_energy= 1.0f; - wrld->ao_indirect_bounces= 1; - wrld->aobias= 0.05f; + wrld->exp = 0.0f; + wrld->exposure = wrld->range = 1.0f; + + wrld->aodist = 10.0f; + wrld->aosamp = 5; + wrld->aoenergy = 1.0f; + wrld->ao_env_energy = 1.0f; + wrld->ao_indirect_energy = 1.0f; + wrld->ao_indirect_bounces = 1; + wrld->aobias = 0.05f; wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; - wrld->ao_approx_error= 0.25f; + wrld->ao_approx_error = 0.25f; wrld->preview = NULL; wrld->miststa = 5.0f; @@ -113,23 +113,23 @@ World *add_world(const char *name) return wrld; } -World *copy_world(World *wrld) +World *BKE_world_copy(World *wrld) { World *wrldn; int a; - wrldn= copy_libblock(&wrld->id); + wrldn = BKE_libblock_copy(&wrld->id); - for (a=0; amtex[a]) { - wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "copy_world"); + wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), "BKE_world_copy"); memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex)); id_us_plus((ID *)wrldn->mtex[a]->tex); } } if (wrld->nodetree) - wrldn->nodetree= ntreeCopyTree(wrld->nodetree); + wrldn->nodetree = ntreeCopyTree(wrld->nodetree); if (wrld->preview) wrldn->preview = BKE_previewimg_copy(wrld->preview); @@ -142,12 +142,12 @@ World *localize_world(World *wrld) World *wrldn; int a; - wrldn= copy_libblock(&wrld->id); + wrldn = BKE_libblock_copy(&wrld->id); BLI_remlink(&G.main->world, wrldn); - for (a=0; amtex[a]) { - wrldn->mtex[a]= MEM_mallocN(sizeof(MTex), "localize_world"); + wrldn->mtex[a] = MEM_mallocN(sizeof(MTex), "localize_world"); memcpy(wrldn->mtex[a], wrld->mtex[a], sizeof(MTex)); /* free world decrements */ id_us_plus((ID *)wrldn->mtex[a]->tex); @@ -155,51 +155,51 @@ World *localize_world(World *wrld) } if (wrld->nodetree) - wrldn->nodetree= ntreeLocalize(wrld->nodetree); + wrldn->nodetree = ntreeLocalize(wrld->nodetree); - wrldn->preview= NULL; + wrldn->preview = NULL; return wrldn; } -void make_local_world(World *wrld) +void BKE_world_make_local(World *wrld) { - Main *bmain= G.main; + Main *bmain = G.main; Scene *sce; - int is_local= FALSE, is_lib= FALSE; + int is_local = FALSE, is_lib = FALSE; /* - only lib users: do nothing * - only local users: set flag * - mixed: make copy */ - if (wrld->id.lib==NULL) return; - if (wrld->id.us==1) { + if (wrld->id.lib == NULL) return; + if (wrld->id.us == 1) { id_clear_lib_data(bmain, &wrld->id); return; } - for (sce= bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce= sce->id.next) { + for (sce = bmain->scene.first; sce && ELEM(FALSE, is_lib, is_local); sce = sce->id.next) { if (sce->world == wrld) { - if (sce->id.lib) is_lib= TRUE; - else is_local= TRUE; + if (sce->id.lib) is_lib = TRUE; + else is_local = TRUE; } } - if (is_local && is_lib==FALSE) { + if (is_local && is_lib == FALSE) { id_clear_lib_data(bmain, &wrld->id); } else if (is_local && is_lib) { - World *wrld_new= copy_world(wrld); - wrld_new->id.us= 0; + World *wrld_new = BKE_world_copy(wrld); + wrld_new->id.us = 0; /* Remap paths of new ID using old library as base. */ BKE_id_lib_local_paths(bmain, wrld->id.lib, &wrld_new->id); - for (sce= bmain->scene.first; sce; sce= sce->id.next) { + for (sce = bmain->scene.first; sce; sce = sce->id.next) { if (sce->world == wrld) { - if (sce->id.lib==NULL) { - sce->world= wrld_new; + if (sce->id.lib == NULL) { + sce->world = wrld_new; wrld_new->id.us++; wrld->id.us--; } diff --git a/source/blender/blenkernel/intern/writeavi.c b/source/blender/blenkernel/intern/writeavi.c index ba8a46256c5..841a0f84fed 100644 --- a/source/blender/blenkernel/intern/writeavi.c +++ b/source/blender/blenkernel/intern/writeavi.c @@ -68,7 +68,7 @@ static void filepath_avi(char *string, RenderData *rd); #include "BKE_writeframeserver.h" -bMovieHandle *BKE_get_movie_handle(const char imtype) +bMovieHandle *BKE_movie_handle_get(const char imtype) { static bMovieHandle mh; @@ -97,18 +97,18 @@ bMovieHandle *BKE_get_movie_handle(const char imtype) #endif #ifdef WITH_FFMPEG if (ELEM4(imtype, R_IMF_IMTYPE_FFMPEG, R_IMF_IMTYPE_H264, R_IMF_IMTYPE_XVID, R_IMF_IMTYPE_THEORA)) { - mh.start_movie = start_ffmpeg; - mh.append_movie = append_ffmpeg; - mh.end_movie = end_ffmpeg; - mh.get_movie_path = filepath_ffmpeg; + mh.start_movie = BKE_ffmpeg_start; + mh.append_movie = BKE_ffmpeg_append; + mh.end_movie = BKE_ffmpeg_end; + mh.get_movie_path = BKE_ffmpeg_filepath_get; } #endif #ifdef WITH_FRAMESERVER if (imtype == R_IMF_IMTYPE_FRAMESERVER) { - mh.start_movie = start_frameserver; - mh.append_movie = append_frameserver; - mh.end_movie = end_frameserver; - mh.get_next_frame = frameserver_loop; + mh.start_movie = BKE_frameserver_start; + mh.append_movie = BKE_frameserver_append; + mh.end_movie = BKE_frameserver_end; + mh.get_next_frame = BKE_frameserver_loop; } #endif @@ -228,9 +228,9 @@ static void end_avi(void) } /* similar to BKE_makepicstring() */ -void BKE_makeanimstring(char *string, RenderData *rd) +void BKE_movie_filepath_get(char *string, RenderData *rd) { - bMovieHandle *mh= BKE_get_movie_handle(rd->im_format.imtype); + bMovieHandle *mh= BKE_movie_handle_get(rd->im_format.imtype); if (mh->get_movie_path) mh->get_movie_path(string, rd); else diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 7330269c1f4..a29de3b0157 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -317,8 +317,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) if (ENDIAN_ORDER == L_ENDIAN) { int y; for (y = 0; y < height; y++) { - uint8_t* target = rgb_frame->data[0] - + width * 4 * (height - y - 1); + uint8_t* target = rgb_frame->data[0] + width * 4 * (height - y - 1); uint8_t* src = rendered_frame + width * 4 * y; uint8_t* end = src + width * 4; while (src != end) { @@ -335,8 +334,7 @@ static AVFrame* generate_video_frame(uint8_t* pixels, ReportList *reports) else { int y; for (y = 0; y < height; y++) { - uint8_t* target = rgb_frame->data[0] - + width * 4 * (height - y - 1); + uint8_t* target = rgb_frame->data[0] + width * 4 * (height - y - 1); uint8_t* src = rendered_frame + width * 4 * y; uint8_t* end = src + width * 4; while (src != end) { @@ -488,8 +486,7 @@ static AVStream* alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->rc_max_rate = rd->ffcodecdata.rc_max_rate*1000; c->rc_min_rate = rd->ffcodecdata.rc_min_rate*1000; c->rc_buffer_size = rd->ffcodecdata.rc_buffer_size * 1024; - c->rc_initial_buffer_occupancy - = rd->ffcodecdata.rc_buffer_size*3/4; + c->rc_initial_buffer_occupancy = rd->ffcodecdata.rc_buffer_size * 3 / 4; c->rc_buffer_aggressivity = 1.0; c->me_method = ME_EPZS; @@ -678,7 +675,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report do_init_ffmpeg(); /* Determine the correct filename */ - filepath_ffmpeg(name, rd); + BKE_ffmpeg_filepath_get(name, rd); fprintf(stderr, "Starting output to %s(ffmpeg)...\n" " Using type=%d, codec=%d, audio_codec=%d,\n" " video_bitrate=%d, audio_bitrate=%d,\n" @@ -884,7 +881,7 @@ void flush_ffmpeg(void) * ********************************************************************** */ /* Get the output filename-- similar to the other output formats */ -void filepath_ffmpeg(char* string, RenderData* rd) +void BKE_ffmpeg_filepath_get(char* string, RenderData* rd) { char autosplit[20]; @@ -925,7 +922,7 @@ void filepath_ffmpeg(char* string, RenderData* rd) } } -int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports) +int BKE_ffmpeg_start(struct Scene *scene, RenderData *rd, int rectx, int recty, ReportList *reports) { int success; @@ -949,7 +946,7 @@ int start_ffmpeg(struct Scene *scene, RenderData *rd, int rectx, int recty, Repo return success; } -void end_ffmpeg(void); +void BKE_ffmpeg_end(void); #ifdef WITH_AUDASPACE static void write_audio_frames(double to_pts) @@ -965,7 +962,7 @@ static void write_audio_frames(double to_pts) } #endif -int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports) +int BKE_ffmpeg_append(RenderData *rd, int start_frame, int frame, int *pixels, int rectx, int recty, ReportList *reports) { AVFrame* avframe; int success = 1; @@ -983,7 +980,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r if (ffmpeg_autosplit) { if (avio_tell(outfile->pb) > FFMPEG_AUTOSPLIT_SIZE) { - end_ffmpeg(); + BKE_ffmpeg_end(); ffmpeg_autosplit_count++; success &= start_ffmpeg_impl(rd, rectx, recty, reports); } @@ -996,7 +993,7 @@ int append_ffmpeg(RenderData *rd, int start_frame, int frame, int *pixels, int r return success; } -void end_ffmpeg(void) +void BKE_ffmpeg_end(void) { unsigned int i; @@ -1074,7 +1071,7 @@ void end_ffmpeg(void) /* properties */ -void ffmpeg_property_del(RenderData *rd, void *type, void *prop_) +void BKE_ffmpeg_property_del(RenderData *rd, void *type, void *prop_) { struct IDProperty *prop = (struct IDProperty *) prop_; IDProperty * group; @@ -1091,7 +1088,7 @@ void ffmpeg_property_del(RenderData *rd, void *type, void *prop_) } } -IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index) +IDProperty *BKE_ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, int parent_index) { AVCodecContext c; const AVOption * o; @@ -1110,8 +1107,7 @@ IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index, parent = c.av_class->option + parent_index; if (!rd->ffcodecdata.properties) { - rd->ffcodecdata.properties - = IDP_New(IDP_GROUP, &val, "ffmpeg"); + rd->ffcodecdata.properties = IDP_New(IDP_GROUP, &val, "ffmpeg"); } group = IDP_GetPropertyFromGroup(rd->ffcodecdata.properties, type); @@ -1184,7 +1180,7 @@ static const AVOption *my_av_find_opt(void *v, const char *name, return NULL; } -int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * str) +int BKE_ffmpeg_property_add_string(RenderData *rd, const char * type, const char * str) { AVCodecContext c; const AVOption * o = 0; @@ -1220,12 +1216,12 @@ int ffmpeg_property_add_string(RenderData *rd, const char * type, const char * s } if (param && o->type != FF_OPT_TYPE_CONST && o->unit) { p = my_av_find_opt(&c, param, o->unit, 0, 0); - prop = ffmpeg_property_add(rd, + prop = BKE_ffmpeg_property_add(rd, (char*) type, p - c.av_class->option, o - c.av_class->option); } else { - prop = ffmpeg_property_add(rd, + prop = BKE_ffmpeg_property_add(rd, (char*) type, o - c.av_class->option, 0); } @@ -1268,37 +1264,37 @@ static void ffmpeg_set_expert_options(RenderData *rd) * Use CABAC coder. Using "coder:1", which should be equivalent, * crashes Blender for some reason. Either way - this is no big deal. */ - ffmpeg_property_add_string(rd, "video", "coder:vlc"); + BKE_ffmpeg_property_add_string(rd, "video", "coder:vlc"); /* * The other options were taken from the libx264-default.preset * included in the ffmpeg distribution. */ // ffmpeg_property_add_string(rd, "video", "flags:loop"); // this breaks compatibility for QT - ffmpeg_property_add_string(rd, "video", "cmp:chroma"); - ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); - ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); - ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); - ffmpeg_property_add_string(rd, "video", "me:hex"); - ffmpeg_property_add_string(rd, "video", "subq:6"); - ffmpeg_property_add_string(rd, "video", "me_range:16"); - ffmpeg_property_add_string(rd, "video", "qdiff:4"); - ffmpeg_property_add_string(rd, "video", "keyint_min:25"); - ffmpeg_property_add_string(rd, "video", "sc_threshold:40"); - ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71"); - ffmpeg_property_add_string(rd, "video", "b_strategy:1"); - ffmpeg_property_add_string(rd, "video", "bf:3"); - ffmpeg_property_add_string(rd, "video", "refs:2"); - ffmpeg_property_add_string(rd, "video", "qcomp:0.6"); - ffmpeg_property_add_string(rd, "video", "directpred:3"); - ffmpeg_property_add_string(rd, "video", "trellis:0"); - ffmpeg_property_add_string(rd, "video", "flags2:wpred"); - ffmpeg_property_add_string(rd, "video", "flags2:dct8x8"); - ffmpeg_property_add_string(rd, "video", "flags2:fastpskip"); - ffmpeg_property_add_string(rd, "video", "wpredp:2"); + BKE_ffmpeg_property_add_string(rd, "video", "cmp:chroma"); + BKE_ffmpeg_property_add_string(rd, "video", "partitions:parti4x4"); + BKE_ffmpeg_property_add_string(rd, "video", "partitions:partp8x8"); + BKE_ffmpeg_property_add_string(rd, "video", "partitions:partb8x8"); + BKE_ffmpeg_property_add_string(rd, "video", "me:hex"); + BKE_ffmpeg_property_add_string(rd, "video", "subq:6"); + BKE_ffmpeg_property_add_string(rd, "video", "me_range:16"); + BKE_ffmpeg_property_add_string(rd, "video", "qdiff:4"); + BKE_ffmpeg_property_add_string(rd, "video", "keyint_min:25"); + BKE_ffmpeg_property_add_string(rd, "video", "sc_threshold:40"); + BKE_ffmpeg_property_add_string(rd, "video", "i_qfactor:0.71"); + BKE_ffmpeg_property_add_string(rd, "video", "b_strategy:1"); + BKE_ffmpeg_property_add_string(rd, "video", "bf:3"); + BKE_ffmpeg_property_add_string(rd, "video", "refs:2"); + BKE_ffmpeg_property_add_string(rd, "video", "qcomp:0.6"); + BKE_ffmpeg_property_add_string(rd, "video", "directpred:3"); + BKE_ffmpeg_property_add_string(rd, "video", "trellis:0"); + BKE_ffmpeg_property_add_string(rd, "video", "flags2:wpred"); + BKE_ffmpeg_property_add_string(rd, "video", "flags2:dct8x8"); + BKE_ffmpeg_property_add_string(rd, "video", "flags2:fastpskip"); + BKE_ffmpeg_property_add_string(rd, "video", "wpredp:2"); if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) - ffmpeg_property_add_string(rd, "video", "cqp:0"); + BKE_ffmpeg_property_add_string(rd, "video", "cqp:0"); } #if 0 /* disabled for after release */ else if (codec_id == CODEC_ID_DNXHD) { @@ -1308,7 +1304,7 @@ static void ffmpeg_set_expert_options(RenderData *rd) #endif } -void ffmpeg_set_preset(RenderData *rd, int preset) +void BKE_ffmpeg_preset_set(RenderData *rd, int preset) { int isntsc = (rd->frs_sec != 25); @@ -1402,7 +1398,7 @@ void ffmpeg_set_preset(RenderData *rd, int preset) ffmpeg_set_expert_options(rd); } -void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) +void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf) { int audio= 0; @@ -1414,7 +1410,7 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) rd->ffcodecdata.codec = CODEC_ID_MPEG2VIDEO; - ffmpeg_set_preset(rd, FFMPEG_PRESET_DVD); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_DVD); } if (rd->ffcodecdata.type == FFMPEG_OGG) { rd->ffcodecdata.type = FFMPEG_MPEG2; @@ -1424,19 +1420,19 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) } else if (imf->imtype == R_IMF_IMTYPE_H264) { if (rd->ffcodecdata.codec != CODEC_ID_H264) { - ffmpeg_set_preset(rd, FFMPEG_PRESET_H264); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264); audio= 1; } } else if (imf->imtype == R_IMF_IMTYPE_XVID) { if (rd->ffcodecdata.codec != CODEC_ID_MPEG4) { - ffmpeg_set_preset(rd, FFMPEG_PRESET_XVID); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_XVID); audio= 1; } } else if (imf->imtype == R_IMF_IMTYPE_THEORA) { if (rd->ffcodecdata.codec != CODEC_ID_THEORA) { - ffmpeg_set_preset(rd, FFMPEG_PRESET_THEORA); + BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_THEORA); audio= 1; } } @@ -1447,12 +1443,12 @@ void ffmpeg_verify_image_type(RenderData *rd, ImageFormatData *imf) } } -void ffmpeg_verify_codec_settings(RenderData *rd) +void BKE_ffmpeg_codec_settings_verify(RenderData *rd) { ffmpeg_set_expert_options(rd); } -int ffmpeg_alpha_channel_supported(RenderData *rd) +int BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd) { int codec = rd->ffcodecdata.codec; diff --git a/source/blender/blenkernel/intern/writeframeserver.c b/source/blender/blenkernel/intern/writeframeserver.c index 0ff095607e3..b5965838a30 100644 --- a/source/blender/blenkernel/intern/writeframeserver.c +++ b/source/blender/blenkernel/intern/writeframeserver.c @@ -110,7 +110,7 @@ static int closesocket(int fd) } #endif -int start_frameserver(struct Scene *scene, RenderData *UNUSED(rd), int rectx, int recty, ReportList *reports) +int BKE_frameserver_start(struct Scene *scene, RenderData *UNUSED(rd), int rectx, int recty, ReportList *reports) { struct sockaddr_in addr; int arg = 1; @@ -258,7 +258,7 @@ static int handle_request(RenderData *rd, char * req) return -1; } -int frameserver_loop(RenderData *rd, ReportList *UNUSED(reports)) +int BKE_frameserver_loop(RenderData *rd, ReportList *UNUSED(reports)) { fd_set readfds; struct timeval tv; @@ -371,7 +371,7 @@ static void serve_ppm(int *pixels, int rectx, int recty) connsock = -1; } -int append_frameserver(RenderData *UNUSED(rd), int UNUSED(start_frame), int frame, int *pixels, +int BKE_frameserver_append(RenderData *UNUSED(rd), int UNUSED(start_frame), int frame, int *pixels, int rectx, int recty, ReportList *UNUSED(reports)) { fprintf(stderr, "Serving frame: %d\n", frame); @@ -386,7 +386,7 @@ int append_frameserver(RenderData *UNUSED(rd), int UNUSED(start_frame), int fram return 0; } -void end_frameserver(void) +void BKE_frameserver_end(void) { if (connsock != -1) { closesocket(connsock); diff --git a/source/blender/blenlib/BLI_pbvh.h b/source/blender/blenlib/BLI_pbvh.h index e6578390ea6..8806721c044 100644 --- a/source/blender/blenlib/BLI_pbvh.h +++ b/source/blender/blenlib/BLI_pbvh.h @@ -28,9 +28,11 @@ #include "BLI_bitmap.h" +struct CCGElem; +struct CCGKey; +struct CustomData; struct DMFlagMat; struct DMGridAdjacency; -struct DMGridData; struct ListBase; struct MFace; struct MVert; @@ -50,17 +52,17 @@ typedef struct { typedef int (*BLI_pbvh_SearchCallback)(PBVHNode *node, void *data); typedef void (*BLI_pbvh_HitCallback)(PBVHNode *node, void *data); -typedef void (*BLI_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float* tmin); +typedef void (*BLI_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float *tmin); /* Building */ PBVH *BLI_pbvh_new(void); void BLI_pbvh_build_mesh(PBVH *bvh, struct MFace *faces, struct MVert *verts, - int totface, int totvert); -void BLI_pbvh_build_grids(PBVH *bvh, struct DMGridData **grids, - struct DMGridAdjacency *gridadj, int totgrid, - int gridsize, void **gridfaces, struct DMFlagMat *flagmats, - unsigned int **grid_hidden); + int totface, int totvert, struct CustomData *vdata); +void BLI_pbvh_build_grids(PBVH *bvh, struct CCGElem **grid_elems, + struct DMGridAdjacency *gridadj, int totgrid, + struct CCGKey *key, void **gridfaces, struct DMFlagMat *flagmats, + unsigned int **grid_hidden); void BLI_pbvh_free(PBVH *bvh); /* Hierarchical Search in the BVH, two methods: @@ -68,28 +70,28 @@ void BLI_pbvh_free(PBVH *bvh); * - gather nodes in an array (easy to multithread) */ void BLI_pbvh_search_callback(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - BLI_pbvh_HitCallback hcb, void *hit_data); + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitCallback hcb, void *hit_data); void BLI_pbvh_search_gather(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - PBVHNode ***array, int *tot); + BLI_pbvh_SearchCallback scb, void *search_data, + PBVHNode ***array, int *tot); /* Raycast * the hit callback is called for all leaf nodes intersecting the ray; * it's up to the callback to find the primitive within the leaves that is * hit first */ -void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, +void BLI_pbvh_raycast(PBVH * bvh, BLI_pbvh_HitOccludedCallback cb, void *data, float ray_start[3], float ray_normal[3], int original); -int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], - float ray_start[3], float ray_normal[3], float *dist); +int BLI_pbvh_node_raycast(PBVH * bvh, PBVHNode * node, float (*origco)[3], + float ray_start[3], float ray_normal[3], float *dist); /* Drawing */ void BLI_pbvh_node_draw(PBVHNode *node, void *data); void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], - int (*setMaterial)(int, void *attribs)); + int (*setMaterial)(int, void *attribs)); /* PBVH Access */ typedef enum { @@ -102,6 +104,9 @@ PBVHType BLI_pbvh_type(const PBVH *bvh); /* multires hidden data, only valid for type == PBVH_GRIDS */ unsigned int **BLI_pbvh_grid_hidden(const PBVH *bvh); +/* multires level, only valid for type == PBVH_GRIDS */ +void BLI_pbvh_get_grid_key(const PBVH *pbvh, struct CCGKey *key); + /* Node Access */ typedef enum { @@ -122,17 +127,17 @@ void BLI_pbvh_node_mark_rebuild_draw(PBVHNode *node); void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden); void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, - int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, - struct DMGridData ***griddata, struct DMGridAdjacency **gridadj); + int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, + struct CCGElem ***grid_elems, struct DMGridAdjacency **gridadj); void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, - int *uniquevert, int *totvert); + int *uniquevert, int *totvert); void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, - int **vert_indices, struct MVert **verts); + int **vert_indices, struct MVert **verts); -void BLI_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3]); -void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3]); +void BLI_pbvh_node_get_BB(PBVHNode * node, float bb_min[3], float bb_max[3]); +void BLI_pbvh_node_get_original_BB(PBVHNode * node, float bb_min[3], float bb_max[3]); -float BLI_pbvh_node_get_tmin(PBVHNode* node); +float BLI_pbvh_node_get_tmin(PBVHNode *node); /* test if AABB is at least partially inside the planes' volume */ int BLI_pbvh_node_planes_contain_AABB(PBVHNode *node, void *data); @@ -142,10 +147,10 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data); /* Update Normals/Bounding Box/Draw Buffers/Redraw and clear flags */ void BLI_pbvh_update(PBVH *bvh, int flags, float (*face_nors)[3]); -void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]); +void BLI_pbvh_redraw_BB(PBVH * bvh, float bb_min[3], float bb_max[3]); void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *totface); -void BLI_pbvh_grids_update(PBVH *bvh, struct DMGridData **grids, - struct DMGridAdjacency *gridadj, void **gridfaces); +void BLI_pbvh_grids_update(PBVH *bvh, struct CCGElem **grid_elems, + struct DMGridAdjacency *gridadj, void **gridfaces); /* vertex deformer */ float (*BLI_pbvh_get_vertCos(struct PBVH *pbvh))[3]; @@ -161,8 +166,8 @@ int BLI_pbvh_isDeformed(struct PBVH *pbvh); /* note: PBVH_ITER_ALL does not skip hidden vertices, * PBVH_ITER_UNIQUE does */ -#define PBVH_ITER_ALL 0 -#define PBVH_ITER_UNIQUE 1 +#define PBVH_ITER_ALL 0 +#define PBVH_ITER_UNIQUE 1 typedef struct PBVHVertexIter { /* iteration */ @@ -174,8 +179,9 @@ typedef struct PBVHVertexIter { int i; /* grid */ - struct DMGridData **grids; - struct DMGridData *grid; + struct CCGElem **grids; + struct CCGElem *grid; + struct CCGKey *key; BLI_bitmap *grid_hidden, gh; int *grid_indices; int totgrid; @@ -185,6 +191,7 @@ typedef struct PBVHVertexIter { struct MVert *mverts; int totvert; int *vert_indices; + float *vmask; /* result: these are all computed in the macro, but we assume * that compiler optimization's will skip the ones we don't use */ @@ -192,6 +199,7 @@ typedef struct PBVHVertexIter { float *co; short *no; float *fno; + float *mask; } PBVHVertexIter; #ifdef _MSC_VER @@ -199,41 +207,44 @@ typedef struct PBVHVertexIter { #endif void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, - PBVHVertexIter *vi, int mode); + PBVHVertexIter *vi, int mode); #define BLI_pbvh_vertex_iter_begin(bvh, node, vi, mode) \ pbvh_vertex_iter_init(bvh, node, &vi, mode); \ \ - for(vi.i=0, vi.g=0; vi.gco; \ - vi.fno= vi.grid->no; \ - vi.grid++; \ - if(vi.gh) { \ - if(BLI_BITMAP_GET(vi.gh, vi.gy * vi.gridsize + vi.gx)) \ + for (vi.gy = 0; vi.gy < vi.height; vi.gy++) { \ + for (vi.gx = 0; vi.gx < vi.width; vi.gx++, vi.i++) { \ + if (vi.grid) { \ + vi.co = CCG_elem_co(vi.key, vi.grid); \ + vi.fno = CCG_elem_no(vi.key, vi.grid); \ + vi.mask = CCG_elem_mask(vi.key, vi.grid); \ + vi.grid = CCG_elem_next(vi.key, vi.grid); \ + if (vi.gh) { \ + if (BLI_BITMAP_GET(vi.gh, vi.gy * vi.gridsize + vi.gx)) \ continue; \ } \ } \ else { \ - vi.mvert= &vi.mverts[vi.vert_indices[vi.gx]]; \ - if(mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \ + vi.mvert = &vi.mverts[vi.vert_indices[vi.gx]]; \ + if (mode == PBVH_ITER_UNIQUE && vi.mvert->flag & ME_HIDE) \ continue; \ - vi.co= vi.mvert->co; \ - vi.no= vi.mvert->no; \ + vi.co = vi.mvert->co; \ + vi.no = vi.mvert->no; \ + if (vi.vmask) \ + vi.mask = &vi.vmask[vi.vert_indices[vi.gx]]; \ } \ #define BLI_pbvh_vertex_iter_end \ @@ -241,10 +252,10 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, } \ } -void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* proxy_count); -void BLI_pbvh_node_free_proxies(PBVHNode* node); -PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node); -void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** nodes, int* totnode); +void BLI_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count); +void BLI_pbvh_node_free_proxies(PBVHNode *node); +PBVHProxyNode *BLI_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node); +void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***nodes, int *totnode); //void BLI_pbvh_node_BB_reset(PBVHNode* node); //void BLI_pbvh_node_BB_expand(PBVHNode* node, float co[3]); diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c index 4dba726cb61..65461b7258a 100644 --- a/source/blender/blenlib/intern/BLI_ghash.c +++ b/source/blender/blenlib/intern/BLI_ghash.c @@ -145,7 +145,7 @@ int BLI_ghash_remove(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFre else gh->buckets[hash] = n; - --gh->nentries; + gh->nentries--; return 1; } p = e; diff --git a/source/blender/blenlib/intern/freetypefont.c b/source/blender/blenlib/intern/freetypefont.c index c9f7b7c7e64..d85765d8f56 100644 --- a/source/blender/blenlib/intern/freetypefont.c +++ b/source/blender/blenlib/intern/freetypefont.c @@ -297,7 +297,7 @@ static int objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode) struct TmpFont *tf; // Find the correct FreeType font - tf= vfont_find_tmpfont(vfont); + tf= BKE_vfont_find_tmpfont(vfont); // What, no font found. Something strange here if (!tf) return FALSE; diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 9f775028c1a..a18c297fdae 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -485,7 +485,9 @@ void BLI_path_rel(char *file, const char *relfile) while (*p == *q) #endif { - ++p; ++q; + p++; + q++; + /* don't search beyond the end of the string * in the rare case they match */ if ((*p=='\0') || (*q=='\0')) { @@ -513,7 +515,7 @@ void BLI_path_rel(char *file, const char *relfile) while (p && p < lslash) { if (*p == '/') strcat(res, "../"); - ++p; + p++; } strcat(res, q+1); /* don't copy the slash at the beginning */ diff --git a/source/blender/blenlib/intern/pbvh.c b/source/blender/blenlib/intern/pbvh.c index 8ab55f9ac85..d80f90ec41a 100644 --- a/source/blender/blenlib/intern/pbvh.c +++ b/source/blender/blenlib/intern/pbvh.c @@ -34,9 +34,10 @@ #include "BLI_ghash.h" #include "BLI_pbvh.h" +#include "BKE_ccg.h" #include "BKE_DerivedMesh.h" -#include "BKE_mesh.h" /* for mesh_calc_normals */ -#include "BKE_global.h" /* for mesh_calc_normals */ +#include "BKE_mesh.h" /* for BKE_mesh_calc_normals */ +#include "BKE_global.h" /* for BKE_mesh_calc_normals */ #include "BKE_paint.h" #include "BKE_subsurf.h" @@ -117,7 +118,7 @@ struct PBVHNode { float tmin; int proxy_count; - PBVHProxyNode* proxies; + PBVHProxyNode *proxies; }; struct PBVH { @@ -135,14 +136,15 @@ struct PBVH { /* Mesh data */ MVert *verts; MFace *faces; + CustomData *vdata; /* Grid Data */ - DMGridData **grids; + CCGKey gridkey; + CCGElem **grids; DMGridAdjacency *gridadj; void **gridfaces; const DMFlagMat *grid_flag_mats; int totgrid; - int gridsize; BLI_bitmap *grid_hidden; /* Only used during BVH build and update, @@ -157,7 +159,7 @@ struct PBVH { int deformed; }; -#define STACK_FIXED_DEPTH 100 +#define STACK_FIXED_DEPTH 100 typedef struct PBVHStack { PBVHNode *node; @@ -242,19 +244,20 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node) if (node->flag & PBVH_Leaf) { PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(bvh, node, vd, PBVH_ITER_ALL) { + BLI_pbvh_vertex_iter_begin(bvh, node, vd, PBVH_ITER_ALL) + { BB_expand(&vb, vd.co); } BLI_pbvh_vertex_iter_end; } else { BB_expand_with_bb(&vb, - &bvh->nodes[node->children_offset].vb); + &bvh->nodes[node->children_offset].vb); BB_expand_with_bb(&vb, - &bvh->nodes[node->children_offset + 1].vb); + &bvh->nodes[node->children_offset + 1].vb); } - node->vb= vb; + node->vb = vb; } //void BLI_pbvh_node_BB_reset(PBVHNode* node) @@ -270,24 +273,24 @@ static void update_node_vb(PBVH *bvh, PBVHNode *node) static int face_materials_match(const MFace *f1, const MFace *f2) { return ((f1->flag & ME_SMOOTH) == (f2->flag & ME_SMOOTH) && - (f1->mat_nr == f2->mat_nr)); + (f1->mat_nr == f2->mat_nr)); } static int grid_materials_match(const DMFlagMat *f1, const DMFlagMat *f2) { return ((f1->flag & ME_SMOOTH) == (f2->flag & ME_SMOOTH) && - (f1->mat_nr == f2->mat_nr)); + (f1->mat_nr == f2->mat_nr)); } /* Adapted from BLI_kdopbvh.c */ /* Returns the index of the first element on the right of the partition */ static int partition_indices(int *prim_indices, int lo, int hi, int axis, - float mid, BBC *prim_bbc) + float mid, BBC *prim_bbc) { - int i=lo, j=hi; - for (;;) { - for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++); - for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--); + int i = lo, j = hi; + for (;; ) { + for (; prim_bbc[prim_indices[i]].bcentroid[axis] < mid; i++) ; + for (; mid < prim_bbc[prim_indices[j]].bcentroid[axis]; j--) ; if (!(i < j)) return i; @@ -304,21 +307,21 @@ static int partition_indices_material(PBVH *bvh, int lo, int hi) const DMFlagMat *flagmats = bvh->grid_flag_mats; const int *indices = bvh->prim_indices; const void *first; - int i=lo, j=hi; + int i = lo, j = hi; if (bvh->faces) first = &faces[bvh->prim_indices[lo]]; else first = &flagmats[bvh->prim_indices[lo]]; - for (;;) { + for (;; ) { if (bvh->faces) { - for (; face_materials_match(first, &faces[indices[i]]); i++); - for (; !face_materials_match(first, &faces[indices[j]]); j--); + for (; face_materials_match(first, &faces[indices[i]]); i++) ; + for (; !face_materials_match(first, &faces[indices[j]]); j--) ; } else { - for (; grid_materials_match(first, &flagmats[indices[i]]); i++); - for (; !grid_materials_match(first, &flagmats[indices[j]]); j--); + for (; grid_materials_match(first, &flagmats[indices[i]]); i++) ; + for (; !grid_materials_match(first, &flagmats[indices[j]]); j--) ; } if (!(i < j)) @@ -337,7 +340,7 @@ static void grow_nodes(PBVH *bvh, int totnode) if (bvh->node_mem_count < totnode) bvh->node_mem_count = totnode; bvh->nodes = MEM_callocN(sizeof(PBVHNode) * bvh->node_mem_count, - "bvh nodes"); + "bvh nodes"); memcpy(bvh->nodes, prev, bvh->totnode * sizeof(PBVHNode)); MEM_freeN(prev); } @@ -348,8 +351,8 @@ static void grow_nodes(PBVH *bvh, int totnode) /* Add a vertex to the map, with a positive value for unique vertices and * a negative value for additional vertices */ static int map_insert_vert(PBVH *bvh, GHash *map, - unsigned int *face_verts, - unsigned int *uniq_verts, int vertex) + unsigned int *face_verts, + unsigned int *uniq_verts, int vertex) { void *value, *key = SET_INT_IN_POINTER(vertex); @@ -381,30 +384,30 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) map = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "build_mesh_leaf_node gh"); node->uniq_verts = node->face_verts = 0; - totface= node->totprim; + totface = node->totprim; - node->face_vert_indices = MEM_callocN(sizeof(int) * 4*totface, - "bvh node face vert indices"); + node->face_vert_indices = MEM_callocN(sizeof(int) * 4 * totface, + "bvh node face vert indices"); for (i = 0; i < totface; ++i) { MFace *f = bvh->faces + node->prim_indices[i]; int sides = f->v4 ? 4 : 3; for (j = 0; j < sides; ++j) { - node->face_vert_indices[i][j]= - map_insert_vert(bvh, map, &node->face_verts, - &node->uniq_verts, (&f->v1)[j]); + node->face_vert_indices[i][j] = + map_insert_vert(bvh, map, &node->face_verts, + &node->uniq_verts, (&f->v1)[j]); } } node->vert_indices = MEM_callocN(sizeof(int) * - (node->uniq_verts + node->face_verts), - "bvh node vert indices"); + (node->uniq_verts + node->face_verts), + "bvh node vert indices"); /* Build the vertex list, unique verts first */ for (iter = BLI_ghashIterator_new(map), i = 0; - !BLI_ghashIterator_isDone(iter); - BLI_ghashIterator_step(iter), ++i) { + !BLI_ghashIterator_isDone(iter); + BLI_ghashIterator_step(iter), ++i) { void *value = BLI_ghashIterator_getValue(iter); int ndx = GET_INT_FROM_POINTER(value); @@ -412,7 +415,7 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) ndx = -ndx + node->uniq_verts - 1; node->vert_indices[ndx] = - GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(iter)); + GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(iter)); } BLI_ghashIterator_free(iter); @@ -423,18 +426,18 @@ static void build_mesh_leaf_node(PBVH *bvh, PBVHNode *node) for (j = 0; j < sides; ++j) { if (node->face_vert_indices[i][j] < 0) - node->face_vert_indices[i][j]= - -node->face_vert_indices[i][j] + - node->uniq_verts - 1; + node->face_vert_indices[i][j] = + -node->face_vert_indices[i][j] + + node->uniq_verts - 1; } } if (!G.background) { node->draw_buffers = - GPU_build_mesh_buffers(node->face_vert_indices, - bvh->faces, bvh->verts, - node->prim_indices, - node->totprim); + GPU_build_mesh_buffers(node->face_vert_indices, + bvh->faces, bvh->verts, + node->prim_indices, + node->totprim); } node->flag |= PBVH_UpdateDrawBuffers; @@ -446,26 +449,26 @@ static void build_grids_leaf_node(PBVH *bvh, PBVHNode *node) { if (!G.background) { node->draw_buffers = - GPU_build_grid_buffers(node->prim_indices, - node->totprim, bvh->grid_hidden, bvh->gridsize); + GPU_build_grid_buffers(node->prim_indices, + node->totprim, bvh->grid_hidden, bvh->gridkey.grid_size); } node->flag |= PBVH_UpdateDrawBuffers; } static void update_vb(PBVH *bvh, PBVHNode *node, BBC *prim_bbc, - int offset, int count) + int offset, int count) { int i; BB_reset(&node->vb); for (i = offset + count - 1; i >= offset; --i) { - BB_expand_with_bb(&node->vb, (BB*)(&prim_bbc[bvh->prim_indices[i]])); + BB_expand_with_bb(&node->vb, (BB *)(&prim_bbc[bvh->prim_indices[i]])); } node->orig_vb = node->vb; } static void build_leaf(PBVH *bvh, int node_index, BBC *prim_bbc, - int offset, int count) + int offset, int count) { bvh->nodes[node_index].flag |= PBVH_Leaf; @@ -525,7 +528,7 @@ int leaf_needs_material_split(PBVH *bvh, int offset, int count) */ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, - int offset, int count) + int offset, int count) { int i, axis, end, below_leaf_limit; BB cb_backing; @@ -558,10 +561,10 @@ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, /* Partition primitives along that axis */ end = partition_indices(bvh->prim_indices, - offset, offset + count - 1, - axis, - (cb->bmax[axis] + cb->bmin[axis]) * 0.5f, - prim_bbc); + offset, offset + count - 1, + axis, + (cb->bmax[axis] + cb->bmin[axis]) * 0.5f, + prim_bbc); } else { /* Partition primitives by material */ @@ -570,9 +573,9 @@ static void build_sub(PBVH *bvh, int node_index, BB *cb, BBC *prim_bbc, /* Build children */ build_sub(bvh, bvh->nodes[node_index].children_offset, NULL, - prim_bbc, offset, end - offset); + prim_bbc, offset, end - offset); build_sub(bvh, bvh->nodes[node_index].children_offset + 1, NULL, - prim_bbc, end, offset + count - end); + prim_bbc, end, offset + count - end); } static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim) @@ -584,15 +587,15 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim) if (bvh->nodes) MEM_freeN(bvh->nodes); if (bvh->prim_indices) MEM_freeN(bvh->prim_indices); bvh->prim_indices = MEM_callocN(sizeof(int) * totprim, - "bvh prim indices"); + "bvh prim indices"); for (i = 0; i < totprim; ++i) bvh->prim_indices[i] = i; bvh->totnode = 0; if (bvh->node_mem_count < 100) { bvh->node_mem_count = 100; bvh->nodes = MEM_callocN(sizeof(PBVHNode) * - bvh->node_mem_count, - "bvh initial nodes"); + bvh->node_mem_count, + "bvh initial nodes"); } } @@ -601,7 +604,7 @@ static void pbvh_build(PBVH *bvh, BB *cb, BBC *prim_bbc, int totprim) } /* Do a full rebuild with on Mesh data structure */ -void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int totvert) +void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int totvert, struct CustomData *vdata) { BBC *prim_bbc = NULL; BB cb; @@ -613,6 +616,7 @@ void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int bvh->vert_bitmap = BLI_BITMAP_NEW(totvert, "bvh->vert_bitmap"); bvh->totvert = totvert; bvh->leaf_limit = LEAF_LIMIT; + bvh->vdata = vdata; BB_reset(&cb); @@ -624,10 +628,10 @@ void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int const int sides = f->v4 ? 4 : 3; BBC *bbc = prim_bbc + i; - BB_reset((BB*)bbc); + BB_reset((BB *)bbc); for (j = 0; j < sides; ++j) - BB_expand((BB*)bbc, verts[(&f->v1)[j]].co); + BB_expand((BB *)bbc, verts[(&f->v1)[j]].co); BBC_update_centroid(bbc); @@ -642,22 +646,23 @@ void BLI_pbvh_build_mesh(PBVH *bvh, MFace *faces, MVert *verts, int totface, int } /* Do a full rebuild with on Grids data structure */ -void BLI_pbvh_build_grids(PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridadj, - int totgrid, int gridsize, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap *grid_hidden) +void BLI_pbvh_build_grids(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, + int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap *grid_hidden) { BBC *prim_bbc = NULL; BB cb; + int gridsize = key->grid_size; int i, j; bvh->type = PBVH_GRIDS; - bvh->grids= grids; - bvh->gridadj= gridadj; - bvh->gridfaces= gridfaces; - bvh->grid_flag_mats= flagmats; - bvh->totgrid= totgrid; - bvh->gridsize= gridsize; - bvh->grid_hidden= grid_hidden; - bvh->leaf_limit = MAX2(LEAF_LIMIT/((gridsize-1)*(gridsize-1)), 1); + bvh->grids = grids; + bvh->gridadj = gridadj; + bvh->gridfaces = gridfaces; + bvh->grid_flag_mats = flagmats; + bvh->totgrid = totgrid; + bvh->gridkey = *key; + bvh->grid_hidden = grid_hidden; + bvh->leaf_limit = MAX2(LEAF_LIMIT / ((gridsize - 1) * (gridsize - 1)), 1); BB_reset(&cb); @@ -665,13 +670,13 @@ void BLI_pbvh_build_grids(PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridad prim_bbc = MEM_mallocN(sizeof(BBC) * totgrid, "prim_bbc"); for (i = 0; i < totgrid; ++i) { - DMGridData *grid= grids[i]; + CCGElem *grid = grids[i]; BBC *bbc = prim_bbc + i; - BB_reset((BB*)bbc); + BB_reset((BB *)bbc); - for (j = 0; j < gridsize*gridsize; ++j) - BB_expand((BB*)bbc, grid[j].co); + for (j = 0; j < gridsize * gridsize; ++j) + BB_expand((BB *)bbc, CCG_elem_offset_co(key, grid, j)); BBC_update_centroid(bbc); @@ -697,7 +702,7 @@ void BLI_pbvh_free(PBVH *bvh) int i; for (i = 0; i < bvh->totnode; ++i) { - node= &bvh->nodes[i]; + node = &bvh->nodes[i]; if (node->flag & PBVH_Leaf) { if (node->draw_buffers) @@ -730,16 +735,16 @@ void BLI_pbvh_free(PBVH *bvh) static void pbvh_iter_begin(PBVHIter *iter, PBVH *bvh, BLI_pbvh_SearchCallback scb, void *search_data) { - iter->bvh= bvh; - iter->scb= scb; - iter->search_data= search_data; + iter->bvh = bvh; + iter->scb = scb; + iter->search_data = search_data; - iter->stack= iter->stackfixed; - iter->stackspace= STACK_FIXED_DEPTH; + iter->stack = iter->stackfixed; + iter->stackspace = STACK_FIXED_DEPTH; - iter->stack[0].node= bvh->nodes; - iter->stack[0].revisiting= 0; - iter->stacksize= 1; + iter->stack[0].node = bvh->nodes; + iter->stack[0].revisiting = 0; + iter->stacksize = 1; } static void pbvh_iter_end(PBVHIter *iter) @@ -754,16 +759,16 @@ static void pbvh_stack_push(PBVHIter *iter, PBVHNode *node, int revisiting) PBVHStack *newstack; iter->stackspace *= 2; - newstack= MEM_callocN(sizeof(PBVHStack)*iter->stackspace, "PBVHStack"); - memcpy(newstack, iter->stack, sizeof(PBVHStack)*iter->stacksize); + newstack = MEM_callocN(sizeof(PBVHStack) * iter->stackspace, "PBVHStack"); + memcpy(newstack, iter->stack, sizeof(PBVHStack) * iter->stacksize); if (iter->stackspace > STACK_FIXED_DEPTH) MEM_freeN(iter->stack); - iter->stack= newstack; + iter->stack = newstack; } - iter->stack[iter->stacksize].node= node; - iter->stack[iter->stacksize].revisiting= revisiting; + iter->stack[iter->stacksize].node = node; + iter->stack[iter->stacksize].revisiting = revisiting; iter->stacksize++; } @@ -778,21 +783,21 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) while (iter->stacksize) { /* pop node */ iter->stacksize--; - node= iter->stack[iter->stacksize].node; + node = iter->stack[iter->stacksize].node; /* on a mesh with no faces this can happen * can remove this check if we know meshes have at least 1 face */ - if (node==NULL) + if (node == NULL) return NULL; - revisiting= iter->stack[iter->stacksize].revisiting; + revisiting = iter->stack[iter->stacksize].revisiting; /* revisiting node already checked */ if (revisiting) return node; if (iter->scb && !iter->scb(node, iter->search_data)) - continue; /* don't traverse, outside of search zone */ + continue; /* don't traverse, outside of search zone */ if (node->flag & PBVH_Leaf) { /* immediately hit leaf node */ @@ -803,8 +808,8 @@ static PBVHNode *pbvh_iter_next(PBVHIter *iter) pbvh_stack_push(iter, node, 1); /* push two child nodes on the stack */ - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset + 1, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset, 0); } } @@ -818,21 +823,21 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter) while (iter->stacksize) { /* pop node */ iter->stacksize--; - node= iter->stack[iter->stacksize].node; + node = iter->stack[iter->stacksize].node; /* on a mesh with no faces this can happen * can remove this check if we know meshes have at least 1 face */ - if (node==NULL) return NULL; + if (node == NULL) return NULL; - if (iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ + if (iter->scb && !iter->scb(node, iter->search_data)) continue; /* don't traverse, outside of search zone */ if (node->flag & PBVH_Leaf) { /* immediately hit leaf node */ return node; } else { - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset+1, 0); - pbvh_stack_push(iter, iter->bvh->nodes+node->children_offset, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset + 1, 0); + pbvh_stack_push(iter, iter->bvh->nodes + node->children_offset, 0); } } @@ -840,31 +845,31 @@ static PBVHNode *pbvh_iter_next_occluded(PBVHIter *iter) } void BLI_pbvh_search_gather(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - PBVHNode ***r_array, int *r_tot) + BLI_pbvh_SearchCallback scb, void *search_data, + PBVHNode ***r_array, int *r_tot) { PBVHIter iter; - PBVHNode **array= NULL, **newarray, *node; - int tot= 0, space= 0; + PBVHNode **array = NULL, **newarray, *node; + int tot = 0, space = 0; pbvh_iter_begin(&iter, bvh, scb, search_data); - while ((node=pbvh_iter_next(&iter))) { + while ((node = pbvh_iter_next(&iter))) { if (node->flag & PBVH_Leaf) { if (tot == space) { /* resize array if needed */ - space= (tot == 0)? 32: space*2; - newarray= MEM_callocN(sizeof(PBVHNode)*space, "PBVHNodeSearch"); + space = (tot == 0) ? 32 : space * 2; + newarray = MEM_callocN(sizeof(PBVHNode) * space, "PBVHNodeSearch"); if (array) { - memcpy(newarray, array, sizeof(PBVHNode)*tot); + memcpy(newarray, array, sizeof(PBVHNode) * tot); MEM_freeN(array); } - array= newarray; + array = newarray; } - array[tot]= node; + array[tot] = node; tot++; } } @@ -873,23 +878,23 @@ void BLI_pbvh_search_gather(PBVH *bvh, if (tot == 0 && array) { MEM_freeN(array); - array= NULL; + array = NULL; } - *r_array= array; - *r_tot= tot; + *r_array = array; + *r_tot = tot; } void BLI_pbvh_search_callback(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - BLI_pbvh_HitCallback hcb, void *hit_data) + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitCallback hcb, void *hit_data) { PBVHIter iter; PBVHNode *node; pbvh_iter_begin(&iter, bvh, scb, search_data); - while ((node=pbvh_iter_next(&iter))) + while ((node = pbvh_iter_next(&iter))) if (node->flag & PBVH_Leaf) hcb(node, hit_data); @@ -897,13 +902,13 @@ void BLI_pbvh_search_callback(PBVH *bvh, } typedef struct node_tree { - PBVHNode* data; + PBVHNode *data; - struct node_tree* left; - struct node_tree* right; + struct node_tree *left; + struct node_tree *right; } node_tree; -static void node_tree_insert(node_tree* tree, node_tree* new_node) +static void node_tree_insert(node_tree *tree, node_tree *new_node) { if (new_node->data->tmin < tree->data->tmin) { if (tree->left) { @@ -923,7 +928,7 @@ static void node_tree_insert(node_tree* tree, node_tree* new_node) } } -static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, void* hit_data, float* tmin) +static void traverse_tree(node_tree *tree, BLI_pbvh_HitOccludedCallback hcb, void *hit_data, float *tmin) { if (tree->left) traverse_tree(tree->left, hcb, hit_data, tmin); @@ -932,7 +937,7 @@ static void traverse_tree(node_tree* tree, BLI_pbvh_HitOccludedCallback hcb, voi if (tree->right) traverse_tree(tree->right, hcb, hit_data, tmin); } -static void free_tree(node_tree* tree) +static void free_tree(node_tree *tree) { if (tree->left) { free_tree(tree->left); @@ -947,14 +952,14 @@ static void free_tree(node_tree* tree) free(tree); } -float BLI_pbvh_node_get_tmin(PBVHNode* node) +float BLI_pbvh_node_get_tmin(PBVHNode *node) { return node->tmin; } static void BLI_pbvh_search_callback_occluded(PBVH *bvh, - BLI_pbvh_SearchCallback scb, void *search_data, - BLI_pbvh_HitOccludedCallback hcb, void *hit_data) + BLI_pbvh_SearchCallback scb, void *search_data, + BLI_pbvh_HitOccludedCallback hcb, void *hit_data) { PBVHIter iter; PBVHNode *node; @@ -962,9 +967,9 @@ static void BLI_pbvh_search_callback_occluded(PBVH *bvh, pbvh_iter_begin(&iter, bvh, scb, search_data); - while ((node=pbvh_iter_next_occluded(&iter))) { + while ((node = pbvh_iter_next_occluded(&iter))) { if (node->flag & PBVH_Leaf) { - node_tree* new_node = malloc(sizeof(node_tree)); + node_tree *new_node = malloc(sizeof(node_tree)); new_node->data = node; @@ -991,7 +996,7 @@ static void BLI_pbvh_search_callback_occluded(PBVH *bvh, static int update_search_cb(PBVHNode *node, void *data_v) { - int flag= GET_INT_FROM_POINTER(data_v); + int flag = GET_INT_FROM_POINTER(data_v); if (node->flag & PBVH_Leaf) return (node->flag & flag); @@ -1000,7 +1005,7 @@ static int update_search_cb(PBVHNode *node, void *data_v) } static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, - int totnode, float (*face_nors)[3]) + int totnode, float (*face_nors)[3]) { float (*vnor)[3]; int n; @@ -1010,7 +1015,7 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, /* could be per node to save some memory, but also means * we have to store for each vertex which node it is in */ - vnor= MEM_callocN(sizeof(float)*3*bvh->totvert, "bvh temp vnors"); + vnor = MEM_callocN(sizeof(float) * 3 * bvh->totvert, "bvh temp vnors"); /* subtle assumptions: * - We know that for all edited vertices, the nodes with faces @@ -1024,29 +1029,29 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, #pragma omp parallel for private(n) schedule(static) for (n = 0; n < totnode; n++) { - PBVHNode *node= nodes[n]; + PBVHNode *node = nodes[n]; if ((node->flag & PBVH_UpdateNormals)) { int i, j, totface, *faces; - faces= node->prim_indices; - totface= node->totprim; + faces = node->prim_indices; + totface = node->totprim; for (i = 0; i < totface; ++i) { - MFace *f= bvh->faces + faces[i]; + MFace *f = bvh->faces + faces[i]; float fn[3]; unsigned int *fv = &f->v1; - int sides= (f->v4)? 4: 3; + int sides = (f->v4) ? 4 : 3; if (f->v4) normal_quad_v3(fn, bvh->verts[f->v1].co, bvh->verts[f->v2].co, - bvh->verts[f->v3].co, bvh->verts[f->v4].co); + bvh->verts[f->v3].co, bvh->verts[f->v4].co); else normal_tri_v3(fn, bvh->verts[f->v1].co, bvh->verts[f->v2].co, - bvh->verts[f->v3].co); + bvh->verts[f->v3].co); for (j = 0; j < sides; ++j) { - int v= fv[j]; + int v = fv[j]; if (bvh->verts[v].flag & ME_VERT_PBVH_UPDATE) { /* this seems like it could be very slow but profile @@ -1068,17 +1073,17 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, #pragma omp parallel for private(n) schedule(static) for (n = 0; n < totnode; n++) { - PBVHNode *node= nodes[n]; + PBVHNode *node = nodes[n]; if (node->flag & PBVH_UpdateNormals) { int i, *verts, totvert; - verts= node->vert_indices; - totvert= node->uniq_verts; + verts = node->vert_indices; + totvert = node->uniq_verts; for (i = 0; i < totvert; ++i) { const int v = verts[i]; - MVert *mvert= &bvh->verts[v]; + MVert *mvert = &bvh->verts[v]; if (mvert->flag & ME_VERT_PBVH_UPDATE) { float no[3]; @@ -1086,9 +1091,9 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, copy_v3_v3(no, vnor[v]); normalize_v3(no); - mvert->no[0] = (short)(no[0]*32767.0f); - mvert->no[1] = (short)(no[1]*32767.0f); - mvert->no[2] = (short)(no[2]*32767.0f); + mvert->no[0] = (short)(no[0] * 32767.0f); + mvert->no[1] = (short)(no[1] * 32767.0f); + mvert->no[2] = (short)(no[2] * 32767.0f); mvert->flag &= ~ME_VERT_PBVH_UPDATE; } @@ -1102,21 +1107,21 @@ static void pbvh_update_normals(PBVH *bvh, PBVHNode **nodes, } static void pbvh_update_BB_redraw(PBVH *bvh, PBVHNode **nodes, - int totnode, int flag) + int totnode, int flag) { int n; /* update BB, redraw flag */ #pragma omp parallel for private(n) schedule(static) for (n = 0; n < totnode; n++) { - PBVHNode *node= nodes[n]; + PBVHNode *node = nodes[n]; if ((flag & PBVH_UpdateBB) && (node->flag & PBVH_UpdateBB)) /* don't clear flag yet, leave it for flushing later */ update_node_vb(bvh, node); if ((flag & PBVH_UpdateOriginalBB) && (node->flag & PBVH_UpdateOriginalBB)) - node->orig_vb= node->vb; + node->orig_vb = node->vb; if ((flag & PBVH_UpdateRedraw) && (node->flag & PBVH_UpdateRedraw)) node->flag &= ~PBVH_UpdateRedraw; @@ -1130,21 +1135,21 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) /* can't be done in parallel with OpenGL */ for (n = 0; n < totnode; n++) { - node= nodes[n]; + node = nodes[n]; if (node->flag & PBVH_RebuildDrawBuffers) { GPU_free_buffers(node->draw_buffers); if (bvh->grids) { node->draw_buffers = - GPU_build_grid_buffers(node->prim_indices, - node->totprim, bvh->grid_hidden, bvh->gridsize); + GPU_build_grid_buffers(node->prim_indices, + node->totprim, bvh->grid_hidden, bvh->gridkey.grid_size); } else { node->draw_buffers = - GPU_build_mesh_buffers(node->face_vert_indices, - bvh->faces, bvh->verts, - node->prim_indices, - node->totprim); + GPU_build_mesh_buffers(node->face_vert_indices, + bvh->faces, bvh->verts, + node->prim_indices, + node->totprim); } node->flag &= ~PBVH_RebuildDrawBuffers; @@ -1152,21 +1157,23 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) if (node->flag & PBVH_UpdateDrawBuffers) { switch (bvh->type) { - case PBVH_GRIDS: - GPU_update_grid_buffers(node->draw_buffers, - bvh->grids, - bvh->grid_flag_mats, - node->prim_indices, - node->totprim, - bvh->gridsize); - break; - case PBVH_FACES: - GPU_update_mesh_buffers(node->draw_buffers, - bvh->verts, - node->vert_indices, - node->uniq_verts + - node->face_verts); - break; + case PBVH_GRIDS: + GPU_update_grid_buffers(node->draw_buffers, + bvh->grids, + bvh->grid_flag_mats, + node->prim_indices, + node->totprim, + &bvh->gridkey); + break; + case PBVH_FACES: + GPU_update_mesh_buffers(node->draw_buffers, + bvh->verts, + node->vert_indices, + node->uniq_verts + + node->face_verts, + CustomData_get_layer(bvh->vdata, + CD_PAINT_MASK)); + break; } node->flag &= ~PBVH_UpdateDrawBuffers; @@ -1176,7 +1183,7 @@ static void pbvh_update_draw_buffers(PBVH *bvh, PBVHNode **nodes, int totnode) static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag) { - int update= 0; + int update = 0; /* difficult to multithread well, we just do single threaded recursive */ if (node->flag & PBVH_Leaf) { @@ -1199,7 +1206,7 @@ static int pbvh_flush_bb(PBVH *bvh, PBVHNode *node, int flag) if (update & PBVH_UpdateBB) update_node_vb(bvh, node); if (update & PBVH_UpdateOriginalBB) - node->orig_vb= node->vb; + node->orig_vb = node->vb; } return update; @@ -1214,15 +1221,15 @@ void BLI_pbvh_update(PBVH *bvh, int flag, float (*face_nors)[3]) return; BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(flag), - &nodes, &totnode); + &nodes, &totnode); if (flag & PBVH_UpdateNormals) pbvh_update_normals(bvh, nodes, totnode, face_nors); - if (flag & (PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw)) + if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateRedraw)) pbvh_update_BB_redraw(bvh, nodes, totnode, flag); - if (flag & (PBVH_UpdateBB|PBVH_UpdateOriginalBB)) + if (flag & (PBVH_UpdateBB | PBVH_UpdateOriginalBB)) pbvh_flush_bb(bvh, bvh->nodes, flag); if (nodes) MEM_freeN(nodes); @@ -1238,7 +1245,7 @@ void BLI_pbvh_redraw_BB(PBVH *bvh, float bb_min[3], float bb_max[3]) pbvh_iter_begin(&iter, bvh, NULL, NULL); - while ((node=pbvh_iter_next(&iter))) + while ((node = pbvh_iter_next(&iter))) if (node->flag & PBVH_UpdateRedraw) BB_expand_with_bb(&bb, &node->vb); @@ -1262,10 +1269,10 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot pbvh_iter_begin(&iter, bvh, NULL, NULL); - while ((node=pbvh_iter_next(&iter))) { + while ((node = pbvh_iter_next(&iter))) { if (node->flag & PBVH_UpdateNormals) { for (i = 0; i < node->totprim; ++i) { - face= bvh->gridfaces[node->prim_indices[i]]; + face = bvh->gridfaces[node->prim_indices[i]]; if (!BLI_ghash_lookup(map, face)) BLI_ghash_insert(map, face, face); } @@ -1277,29 +1284,29 @@ void BLI_pbvh_get_grid_updates(PBVH *bvh, int clear, void ***gridfaces, int *tot pbvh_iter_end(&iter); - tot= BLI_ghash_size(map); + tot = BLI_ghash_size(map); if (tot == 0) { - *totface= 0; - *gridfaces= NULL; + *totface = 0; + *gridfaces = NULL; BLI_ghash_free(map, NULL, NULL); return; } - faces= MEM_callocN(sizeof(void*)*tot, "PBVH Grid Faces"); + faces = MEM_callocN(sizeof(void *) * tot, "PBVH Grid Faces"); for (hiter = BLI_ghashIterator_new(map), i = 0; - !BLI_ghashIterator_isDone(hiter); - BLI_ghashIterator_step(hiter), ++i) + !BLI_ghashIterator_isDone(hiter); + BLI_ghashIterator_step(hiter), ++i) { - faces[i]= BLI_ghashIterator_getKey(hiter); + faces[i] = BLI_ghashIterator_getKey(hiter); } BLI_ghashIterator_free(hiter); BLI_ghash_free(map, NULL, NULL); - *totface= tot; - *gridfaces= faces; + *totface = tot; + *gridfaces = faces; } /***************************** PBVH Access ***********************************/ @@ -1315,16 +1322,22 @@ BLI_bitmap *BLI_pbvh_grid_hidden(const PBVH *bvh) return bvh->grid_hidden; } +void BLI_pbvh_get_grid_key(const PBVH *bvh, CCGKey *key) +{ + BLI_assert(bvh->type == PBVH_GRIDS); + *key = bvh->gridkey; +} + /***************************** Node Access ***********************************/ void BLI_pbvh_node_mark_update(PBVHNode *node) { - node->flag |= PBVH_UpdateNormals|PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw; + node->flag |= PBVH_UpdateNormals | PBVH_UpdateBB | PBVH_UpdateOriginalBB | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; } void BLI_pbvh_node_mark_rebuild_draw(PBVHNode *node) { - node->flag |= PBVH_RebuildDrawBuffers|PBVH_UpdateDrawBuffers|PBVH_UpdateRedraw; + node->flag |= PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers | PBVH_UpdateRedraw; } void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden) @@ -1339,8 +1352,8 @@ void BLI_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden) void BLI_pbvh_node_get_verts(PBVH *bvh, PBVHNode *node, int **vert_indices, MVert **verts) { - if (vert_indices) *vert_indices= node->vert_indices; - if (verts) *verts= bvh->verts; + if (vert_indices) *vert_indices = node->vert_indices; + if (verts) *verts = bvh->verts; } void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *totvert) @@ -1348,37 +1361,37 @@ void BLI_pbvh_node_num_verts(PBVH *bvh, PBVHNode *node, int *uniquevert, int *to int tot; switch (bvh->type) { - case PBVH_GRIDS: - tot= node->totprim*bvh->gridsize*bvh->gridsize; - if (totvert) *totvert= tot; - if (uniquevert) *uniquevert= tot; - break; - case PBVH_FACES: - if (totvert) *totvert= node->uniq_verts + node->face_verts; - if (uniquevert) *uniquevert= node->uniq_verts; - break; + case PBVH_GRIDS: + tot = node->totprim * bvh->gridkey.grid_area; + if (totvert) *totvert = tot; + if (uniquevert) *uniquevert = tot; + break; + case PBVH_FACES: + if (totvert) *totvert = node->uniq_verts + node->face_verts; + if (uniquevert) *uniquevert = node->uniq_verts; + break; } } -void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, DMGridData ***griddata, DMGridAdjacency **gridadj) +void BLI_pbvh_node_get_grids(PBVH *bvh, PBVHNode *node, int **grid_indices, int *totgrid, int *maxgrid, int *gridsize, CCGElem ***griddata, DMGridAdjacency **gridadj) { switch (bvh->type) { - case PBVH_GRIDS: - if (grid_indices) *grid_indices= node->prim_indices; - if (totgrid) *totgrid= node->totprim; - if (maxgrid) *maxgrid= bvh->totgrid; - if (gridsize) *gridsize= bvh->gridsize; - if (griddata) *griddata= bvh->grids; - if (gridadj) *gridadj= bvh->gridadj; - break; - case PBVH_FACES: - if (grid_indices) *grid_indices= NULL; - if (totgrid) *totgrid= 0; - if (maxgrid) *maxgrid= 0; - if (gridsize) *gridsize= 0; - if (griddata) *griddata= NULL; - if (gridadj) *gridadj= NULL; - break; + case PBVH_GRIDS: + if (grid_indices) *grid_indices = node->prim_indices; + if (totgrid) *totgrid = node->totprim; + if (maxgrid) *maxgrid = bvh->totgrid; + if (gridsize) *gridsize = bvh->gridkey.grid_size; + if (griddata) *griddata = bvh->grids; + if (gridadj) *gridadj = bvh->gridadj; + break; + case PBVH_FACES: + if (grid_indices) *grid_indices = NULL; + if (totgrid) *totgrid = 0; + if (maxgrid) *maxgrid = 0; + if (gridsize) *gridsize = 0; + if (griddata) *griddata = NULL; + if (gridadj) *gridadj = NULL; + break; } } @@ -1394,7 +1407,7 @@ void BLI_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max copy_v3_v3(bb_max, node->orig_vb.bmax); } -void BLI_pbvh_node_get_proxies(PBVHNode* node, PBVHProxyNode** proxies, int* proxy_count) +void BLI_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count) { if (node->proxy_count > 0) { if (proxies) *proxies = node->proxies; @@ -1429,10 +1442,10 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) BLI_pbvh_node_get_BB(node, bbox[0], bbox[1]); tmin = (bbox[ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; - tmax = (bbox[1-ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; + tmax = (bbox[1 - ray->sign[0]][0] - ray->start[0]) * ray->inv_dir[0]; tymin = (bbox[ray->sign[1]][1] - ray->start[1]) * ray->inv_dir[1]; - tymax = (bbox[1-ray->sign[1]][1] - ray->start[1]) * ray->inv_dir[1]; + tymax = (bbox[1 - ray->sign[1]][1] - ray->start[1]) * ray->inv_dir[1]; if ((tmin > tymax) || (tymin > tmax)) return 0; @@ -1444,7 +1457,7 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) tmax = tymax; tzmin = (bbox[ray->sign[2]][2] - ray->start[2]) * ray->inv_dir[2]; - tzmax = (bbox[1-ray->sign[2]][2] - ray->start[2]) * ray->inv_dir[2]; + tzmax = (bbox[1 - ray->sign[2]][2] - ray->start[2]) * ray->inv_dir[2]; if ((tmin > tzmax) || (tzmin > tmax)) return 0; @@ -1462,7 +1475,7 @@ static int ray_aabb_intersect(PBVHNode *node, void *data_v) } void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, - float ray_start[3], float ray_normal[3], int original) + float ray_start[3], float ray_normal[3], int original) { RaycastData rcd; @@ -1479,13 +1492,13 @@ void BLI_pbvh_raycast(PBVH *bvh, BLI_pbvh_HitOccludedCallback cb, void *data, } static int ray_face_intersection(float ray_start[3], float ray_normal[3], - float *t0, float *t1, float *t2, float *t3, - float *fdist) + float *t0, float *t1, float *t2, float *t3, + float *fdist) { float dist; if ((isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t1, t2, &dist, NULL, 0.1f) && dist < *fdist) || - (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) + (t3 && isect_ray_tri_epsilon_v3(ray_start, ray_normal, t0, t2, t3, &dist, NULL, 0.1f) && dist < *fdist)) { *fdist = dist; return 1; @@ -1496,91 +1509,91 @@ static int ray_face_intersection(float ray_start[3], float ray_normal[3], } int BLI_pbvh_node_raycast(PBVH *bvh, PBVHNode *node, float (*origco)[3], - float ray_start[3], float ray_normal[3], float *dist) + float ray_start[3], float ray_normal[3], float *dist) { MVert *vert; BLI_bitmap gh; int *faces, totface, gridsize, totgrid; - int i, x, y, hit= 0; + int i, x, y, hit = 0; if (node->flag & PBVH_FullyHidden) return 0; switch (bvh->type) { - case PBVH_FACES: - vert = bvh->verts; - faces= node->prim_indices; - totface= node->totprim; + case PBVH_FACES: + vert = bvh->verts; + faces = node->prim_indices; + totface = node->totprim; - for (i = 0; i < totface; ++i) { - const MFace *f = bvh->faces + faces[i]; - int *face_verts = node->face_vert_indices[i]; + for (i = 0; i < totface; ++i) { + const MFace *f = bvh->faces + faces[i]; + int *face_verts = node->face_vert_indices[i]; - if (paint_is_face_hidden(f, vert)) - continue; + if (paint_is_face_hidden(f, vert)) + continue; - if (origco) { - /* intersect with backuped original coordinates */ - hit |= ray_face_intersection(ray_start, ray_normal, - origco[face_verts[0]], - origco[face_verts[1]], - origco[face_verts[2]], - f->v4? origco[face_verts[3]]: NULL, - dist); - } - else { - /* intersect with current coordinates */ - hit |= ray_face_intersection(ray_start, ray_normal, - vert[f->v1].co, - vert[f->v2].co, - vert[f->v3].co, - f->v4 ? vert[f->v4].co : NULL, - dist); - } - } - break; - case PBVH_GRIDS: - totgrid= node->totprim; - gridsize= bvh->gridsize; - - for (i = 0; i < totgrid; ++i) { - DMGridData *grid= bvh->grids[node->prim_indices[i]]; - if (!grid) - continue; - - gh= bvh->grid_hidden[node->prim_indices[i]]; - - for (y = 0; y < gridsize-1; ++y) { - for (x = 0; x < gridsize-1; ++x) { - /* check if grid face is hidden */ - if (gh) { - if (paint_is_grid_face_hidden(gh, gridsize, x, y)) - continue; - } - - if (origco) { - hit |= ray_face_intersection(ray_start, ray_normal, - origco[y*gridsize + x], - origco[y*gridsize + x+1], - origco[(y+1)*gridsize + x+1], - origco[(y+1)*gridsize + x], - dist); - } - else { - hit |= ray_face_intersection(ray_start, ray_normal, - grid[y*gridsize + x].co, - grid[y*gridsize + x+1].co, - grid[(y+1)*gridsize + x+1].co, - grid[(y+1)*gridsize + x].co, - dist); - } + if (origco) { + /* intersect with backuped original coordinates */ + hit |= ray_face_intersection(ray_start, ray_normal, + origco[face_verts[0]], + origco[face_verts[1]], + origco[face_verts[2]], + f->v4 ? origco[face_verts[3]] : NULL, + dist); + } + else { + /* intersect with current coordinates */ + hit |= ray_face_intersection(ray_start, ray_normal, + vert[f->v1].co, + vert[f->v2].co, + vert[f->v3].co, + f->v4 ? vert[f->v4].co : NULL, + dist); } } + break; + case PBVH_GRIDS: + totgrid = node->totprim; + gridsize = bvh->gridkey.grid_size; - if (origco) - origco += gridsize*gridsize; - } - break; + for (i = 0; i < totgrid; ++i) { + CCGElem *grid = bvh->grids[node->prim_indices[i]]; + if (!grid) + continue; + + gh = bvh->grid_hidden[node->prim_indices[i]]; + + for (y = 0; y < gridsize - 1; ++y) { + for (x = 0; x < gridsize - 1; ++x) { + /* check if grid face is hidden */ + if (gh) { + if (paint_is_grid_face_hidden(gh, gridsize, x, y)) + continue; + } + + if (origco) { + hit |= ray_face_intersection(ray_start, ray_normal, + origco[y * gridsize + x], + origco[y * gridsize + x + 1], + origco[(y + 1) * gridsize + x + 1], + origco[(y + 1) * gridsize + x], + dist); + } + else { + hit |= ray_face_intersection(ray_start, ray_normal, + CCG_grid_elem_co(&bvh->gridkey, grid, x, y), + CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y), + CCG_grid_elem_co(&bvh->gridkey, grid, x + 1, y + 1), + CCG_grid_elem_co(&bvh->gridkey, grid, x, y + 1), + dist); + } + } + } + + if (origco) + origco += gridsize * gridsize; + } + break; } return hit; @@ -1623,8 +1636,8 @@ typedef enum { * (ok, not a real frustum), false otherwise. */ static PlaneAABBIsect test_planes_aabb(const float bb_min[3], - const float bb_max[3], - const float (*planes)[4]) + const float bb_max[3], + const float (*planes)[4]) { float vmin[3], vmax[3]; PlaneAABBIsect ret = ISECT_INSIDE; @@ -1668,13 +1681,13 @@ int BLI_pbvh_node_planes_exclude_AABB(PBVHNode *node, void *data) } void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], - DMSetMaterial setMaterial) + DMSetMaterial setMaterial) { PBVHNode **nodes; int totnode; - BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals|PBVH_UpdateDrawBuffers), - &nodes, &totnode); + BLI_pbvh_search_gather(bvh, update_search_cb, SET_INT_IN_POINTER(PBVH_UpdateNormals | PBVH_UpdateDrawBuffers), + &nodes, &totnode); pbvh_update_normals(bvh, nodes, totnode, face_nors); pbvh_update_draw_buffers(bvh, nodes, totnode); @@ -1683,33 +1696,33 @@ void BLI_pbvh_draw(PBVH *bvh, float (*planes)[4], float (*face_nors)[3], if (planes) { BLI_pbvh_search_callback(bvh, BLI_pbvh_node_planes_contain_AABB, - planes, BLI_pbvh_node_draw, setMaterial); + planes, BLI_pbvh_node_draw, setMaterial); } else { BLI_pbvh_search_callback(bvh, NULL, NULL, BLI_pbvh_node_draw, setMaterial); } } -void BLI_pbvh_grids_update(PBVH *bvh, DMGridData **grids, DMGridAdjacency *gridadj, void **gridfaces) +void BLI_pbvh_grids_update(PBVH *bvh, CCGElem **grids, DMGridAdjacency *gridadj, void **gridfaces) { - bvh->grids= grids; - bvh->gridadj= gridadj; - bvh->gridfaces= gridfaces; + bvh->grids = grids; + bvh->gridadj = gridadj; + bvh->gridfaces = gridfaces; } -float (*BLI_pbvh_get_vertCos(PBVH *pbvh))[3] +float (*BLI_pbvh_get_vertCos(PBVH * pbvh))[3] { int a; - float (*vertCos)[3]= NULL; + float (*vertCos)[3] = NULL; if (pbvh->verts) { float *co; - MVert *mvert= pbvh->verts; + MVert *mvert = pbvh->verts; - vertCos= MEM_callocN(3*pbvh->totvert*sizeof(float), "BLI_pbvh_get_vertCoords"); - co= (float*)vertCos; + vertCos = MEM_callocN(3 * pbvh->totvert * sizeof(float), "BLI_pbvh_get_vertCoords"); + co = (float *)vertCos; - for (a= 0; atotvert; a++, mvert++, co+= 3) { + for (a = 0; a < pbvh->totvert; a++, mvert++, co += 3) { copy_v3_v3(co, mvert->co); } } @@ -1727,25 +1740,25 @@ void BLI_pbvh_apply_vertCos(PBVH *pbvh, float (*vertCos)[3]) /* original data and applying new coords to this arrays would lead to */ /* unneeded deformation -- duplicate verts/faces to avoid this */ - pbvh->verts= MEM_dupallocN(pbvh->verts); - pbvh->faces= MEM_dupallocN(pbvh->faces); + pbvh->verts = MEM_dupallocN(pbvh->verts); + pbvh->faces = MEM_dupallocN(pbvh->faces); - pbvh->deformed= 1; + pbvh->deformed = 1; } } if (pbvh->verts) { - MVert *mvert= pbvh->verts; + MVert *mvert = pbvh->verts; /* copy new verts coords */ - for (a= 0; a < pbvh->totvert; ++a, ++mvert) { + for (a = 0; a < pbvh->totvert; ++a, ++mvert) { copy_v3_v3(mvert->co, vertCos[a]); mvert->flag |= ME_VERT_PBVH_UPDATE; } /* coordinates are new -- normals should also be updated */ - mesh_calc_normals_tessface(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL); + BKE_mesh_calc_normals_tessface(pbvh->verts, pbvh->totvert, pbvh->faces, pbvh->totprim, NULL); - for (a= 0; a < pbvh->totnode; ++a) + for (a = 0; a < pbvh->totnode; ++a) BLI_pbvh_node_mark_update(&pbvh->nodes[a]); BLI_pbvh_update(pbvh, PBVH_UpdateBB, NULL); @@ -1760,7 +1773,7 @@ int BLI_pbvh_isDeformed(PBVH *pbvh) } /* Proxies */ -PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node) +PBVHProxyNode *BLI_pbvh_node_add_proxy(PBVH *bvh, PBVHNode *node) { int index, totverts; @@ -1772,106 +1785,111 @@ PBVHProxyNode* BLI_pbvh_node_add_proxy(PBVH* bvh, PBVHNode* node) node->proxy_count++; if (node->proxies) - node->proxies= MEM_reallocN(node->proxies, node->proxy_count*sizeof(PBVHProxyNode)); + node->proxies = MEM_reallocN(node->proxies, node->proxy_count * sizeof(PBVHProxyNode)); else - node->proxies= MEM_mallocN(sizeof(PBVHProxyNode), "PBVHNodeProxy"); + node->proxies = MEM_mallocN(sizeof(PBVHProxyNode), "PBVHNodeProxy"); if (bvh->grids) - totverts = node->totprim*bvh->gridsize*bvh->gridsize; + totverts = node->totprim * bvh->gridkey.grid_area; else totverts = node->uniq_verts; - node->proxies[index].co= MEM_callocN(sizeof(float[3])*totverts, "PBVHNodeProxy.co"); + node->proxies[index].co = MEM_callocN(sizeof(float[3]) * totverts, "PBVHNodeProxy.co"); } return node->proxies + index; } -void BLI_pbvh_node_free_proxies(PBVHNode* node) +void BLI_pbvh_node_free_proxies(PBVHNode *node) { #pragma omp critical { int p; - for (p= 0; p < node->proxy_count; p++) { + for (p = 0; p < node->proxy_count; p++) { MEM_freeN(node->proxies[p].co); - node->proxies[p].co= 0; + node->proxies[p].co = 0; } MEM_freeN(node->proxies); node->proxies = 0; - node->proxy_count= 0; + node->proxy_count = 0; } } -void BLI_pbvh_gather_proxies(PBVH* pbvh, PBVHNode*** r_array, int* r_tot) +void BLI_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot) { - PBVHNode **array= NULL, **newarray, *node; - int tot= 0, space= 0; + PBVHNode **array = NULL, **newarray, *node; + int tot = 0, space = 0; int n; - for (n= 0; n < pbvh->totnode; n++) { + for (n = 0; n < pbvh->totnode; n++) { node = pbvh->nodes + n; if (node->proxy_count > 0) { if (tot == space) { /* resize array if needed */ - space= (tot == 0)? 32: space*2; - newarray= MEM_callocN(sizeof(PBVHNode)*space, "BLI_pbvh_gather_proxies"); + space = (tot == 0) ? 32 : space * 2; + newarray = MEM_callocN(sizeof(PBVHNode) * space, "BLI_pbvh_gather_proxies"); if (array) { - memcpy(newarray, array, sizeof(PBVHNode)*tot); + memcpy(newarray, array, sizeof(PBVHNode) * tot); MEM_freeN(array); } - array= newarray; + array = newarray; } - array[tot]= node; + array[tot] = node; tot++; } } if (tot == 0 && array) { MEM_freeN(array); - array= NULL; + array = NULL; } - *r_array= array; - *r_tot= tot; + *r_array = array; + *r_tot = tot; } void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, - PBVHVertexIter *vi, int mode) + PBVHVertexIter *vi, int mode) { - struct DMGridData **grids; + struct CCGElem **grids; struct MVert *verts; int *grid_indices, *vert_indices; int totgrid, gridsize, uniq_verts, totvert; - vi->grid= 0; - vi->no= 0; - vi->fno= 0; - vi->mvert= 0; + vi->grid = 0; + vi->no = 0; + vi->fno = 0; + vi->mvert = 0; BLI_pbvh_node_get_grids(bvh, node, &grid_indices, &totgrid, NULL, &gridsize, &grids, NULL); BLI_pbvh_node_num_verts(bvh, node, &uniq_verts, &totvert); BLI_pbvh_node_get_verts(bvh, node, &vert_indices, &verts); + vi->key = &bvh->gridkey; - vi->grids= grids; - vi->grid_indices= grid_indices; - vi->totgrid= (grids)? totgrid: 1; - vi->gridsize= gridsize; + vi->grids = grids; + vi->grid_indices = grid_indices; + vi->totgrid = (grids) ? totgrid : 1; + vi->gridsize = gridsize; if (mode == PBVH_ITER_ALL) vi->totvert = totvert; else - vi->totvert= uniq_verts; - vi->vert_indices= vert_indices; - vi->mverts= verts; + vi->totvert = uniq_verts; + vi->vert_indices = vert_indices; + vi->mverts = verts; - vi->gh= NULL; + vi->gh = NULL; if (vi->grids && mode == PBVH_ITER_UNIQUE) - vi->grid_hidden= bvh->grid_hidden; + vi->grid_hidden = bvh->grid_hidden; + + vi->mask = NULL; + if (!vi->grids) + vi->vmask = CustomData_get_layer(bvh->vdata, CD_PAINT_MASK); } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 5a8a74e1ba2..1b0658be08a 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -559,7 +559,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepat m= MEM_callocN(sizeof(Main), "find_main"); BLI_addtail(mainlist, m); - lib= alloc_libblock(&m->library, ID_LI, "lib"); + lib= BKE_libblock_alloc(&m->library, ID_LI, "lib"); BLI_strncpy(lib->name, filepath, sizeof(lib->name)); BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath)); @@ -2474,10 +2474,19 @@ typedef struct tConstraintLinkData { ID *id; } tConstraintLinkData; /* callback function used to relink constraint ID-links */ -static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, void *userdata) +static void lib_link_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short isReference, void *userdata) { tConstraintLinkData *cld= (tConstraintLinkData *)userdata; - *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); + + /* for reference types, we need to increment the usercounts on load... */ + if (isReference) { + /* reference type - with usercount */ + *idpoin = newlibadr_us(cld->fd, cld->id->lib, *idpoin); + } + else { + /* target type - no usercount needed */ + *idpoin = newlibadr(cld->fd, cld->id->lib, *idpoin); + } } static void lib_link_constraints(FileData *fd, ID *id, ListBase *conlist) @@ -2566,7 +2575,7 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose) /* sync proxy active bone */ if (pose->proxy_act_bone[0]) { - Bone *bone = get_named_bone(arm, pose->proxy_act_bone); + Bone *bone = BKE_armature_find_bone_name(arm, pose->proxy_act_bone); if (bone) arm->act_bone = bone; } @@ -2576,7 +2585,7 @@ static void lib_link_pose(FileData *fd, Object *ob, bPose *pose) lib_link_constraints(fd, (ID *)ob, &pchan->constraints); /* hurms... loop in a loop, but yah... later... (ton) */ - pchan->bone= get_named_bone(arm, pchan->name); + pchan->bone= BKE_armature_find_bone_name(arm, pchan->name); pchan->custom= newlibadr_us(fd, arm->id.lib, pchan->custom); if (pchan->bone==NULL) @@ -2956,7 +2965,7 @@ static void direct_link_text(FileData *fd, Text *text) #if 0 if (text->flags & TXT_ISEXT) { - reopen_text(text); + BKE_text_reload(text); } else { #endif @@ -3801,7 +3810,7 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte * overwritten with the correct value in * bm_corners_to_loops() */ float gridsize = sqrtf(mdisps[i].totdisp); - mdisps[i].level = (int)(logf(gridsize - 1.0f) / M_LN2) + 1; + mdisps[i].level = (int)(logf(gridsize - 1.0f) / (float)M_LN2) + 1; } if ( (fd->flags & FD_FLAGS_SWITCH_ENDIAN) && (mdisps[i].disps) ) { @@ -3820,6 +3829,19 @@ static void direct_link_mdisps(FileData *fd, int count, MDisps *mdisps, int exte } } +static void direct_link_grid_paint_mask(FileData *fd, int count, GridPaintMask *grid_paint_mask) +{ + if(grid_paint_mask) { + int i; + + for(i = 0; i < count; ++i) { + GridPaintMask *gpm = &grid_paint_mask[i]; + if(gpm->data) + gpm->data = newdataadr(fd, gpm->data); + } + } +} + /*this isn't really a public api function, so prototyped here*/ static void direct_link_customdata(FileData *fd, CustomData *data, int count) { @@ -3846,6 +3868,8 @@ static void direct_link_customdata(FileData *fd, CustomData *data, int count) layer->data = newdataadr(fd, layer->data); if (layer->type == CD_MDISPS) direct_link_mdisps(fd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL); + else if(layer->type == CD_GRID_PAINT_MASK) + direct_link_grid_paint_mask(fd, count, layer->data); i++; } } @@ -3900,7 +3924,7 @@ static void direct_link_mesh(FileData *fd, Mesh *mesh) if (mesh->mpoly) { /* be clever and load polygons as mfaces */ - mesh->totface= mesh_mpoly_to_mface(&mesh->fdata, &mesh->ldata, &mesh->pdata, + mesh->totface= BKE_mesh_mpoly_to_mface(&mesh->fdata, &mesh->ldata, &mesh->pdata, mesh->totface, mesh->totloop, mesh->totpoly); CustomData_free(&mesh->pdata, mesh->totpoly); @@ -4088,7 +4112,7 @@ static void lib_link_object(FileData *fd, Main *main) warn= 1; if (ob->pose) { - free_pose(ob->pose); + BKE_pose_free(ob->pose); ob->pose= NULL; ob->mode &= ~OB_MODE_POSE; } @@ -6894,10 +6918,15 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo bNodeSocket *old_image = BLI_findlink(&node->inputs, 0); bNodeSocket *old_z = BLI_findlink(&node->inputs, 1); bNodeSocket *sock; + char basepath[FILE_MAXDIR]; + char filename[FILE_MAXFILE]; node->storage= nimf; - BLI_strncpy(nimf->base_path, old_data->name, sizeof(nimf->base_path)); + /* split off filename from the old path, to be used as socket sub-path */ + BLI_split_dirfile(old_data->name, basepath, filename, sizeof(basepath), sizeof(filename)); + + BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path)); nimf->format = old_data->im_format; /* if z buffer is saved, change the image type to multilayer exr. @@ -6905,21 +6934,32 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo * i'm just assuming here that IRIZ means IRIS with z buffer ... */ if (ELEM(old_data->im_format.imtype, R_IMF_IMTYPE_IRIZ, R_IMF_IMTYPE_OPENEXR)) { + char sockpath[FILE_MAX]; + nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER; - sock = ntreeCompositOutputFileAddSocket(ntree, node, old_image->name, &nimf->format); + + BLI_snprintf(sockpath, sizeof(sockpath), "%s_Image", filename); + sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format); + /* XXX later do_versions copies path from socket name, need to set this explicitely */ + BLI_strncpy(sock->name, sockpath, sizeof(sock->name)); if (old_image->link) { old_image->link->tosock = sock; sock->link = old_image->link; } - sock = ntreeCompositOutputFileAddSocket(ntree, node, old_z->name, &nimf->format); + + BLI_snprintf(sockpath, sizeof(sockpath), "%s_Z", filename); + sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format); + /* XXX later do_versions copies path from socket name, need to set this explicitely */ + BLI_strncpy(sock->name, sockpath, sizeof(sock->name)); if (old_z->link) { old_z->link->tosock = sock; sock->link = old_z->link; } } else { - /* saves directly to base path, which is the old image output path */ - sock = ntreeCompositOutputFileAddSocket(ntree, node, "", &nimf->format); + sock = ntreeCompositOutputFileAddSocket(ntree, node, filename, &nimf->format); + /* XXX later do_versions copies path from socket name, need to set this explicitely */ + BLI_strncpy(sock->name, filename, sizeof(sock->name)); if (old_image->link) { old_image->link->tosock = sock; sock->link = old_image->link; @@ -6989,6 +7029,52 @@ static void do_versions_nodetree_multi_file_output_path_2_64_0(bNodeTree *ntree) } } +static void do_versions_nodetree_file_output_layers_2_64_5(bNodeTree *ntree) +{ + bNode *node; + + for (node=ntree->nodes.first; node; node=node->next) { + if (node->type==CMP_NODE_OUTPUT_FILE) { + bNodeSocket *sock; + for (sock=node->inputs.first; sock; sock=sock->next) { + NodeImageMultiFileSocket *input = sock->storage; + + /* multilayer names are stored as separate strings now, + * used the path string before, so copy it over. + */ + BLI_strncpy(input->layer, input->path, sizeof(input->layer)); + + /* paths/layer names also have to be unique now, initial check */ + ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_'); + ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, input->layer, '_'); + } + } + } +} + +static void do_versions_nodetree_image_layer_2_64_5(bNodeTree *ntree) +{ + bNode *node; + + for (node=ntree->nodes.first; node; node=node->next) { + if (node->type==CMP_NODE_IMAGE) { + ImageUser *iuser= (ImageUser *)node->storage; + bNodeSocket *sock; + for (sock=node->outputs.first; sock; sock=sock->next) { + NodeImageLayer *output = MEM_callocN(sizeof(NodeImageLayer), "node image layer"); + + /* take layer index from image user (this is ignored from now on) */ + output->layer_index = iuser->layer; + /* take pass index both from current storage ptr (actually an int) */ + output->pass_index = GET_INT_FROM_POINTER(sock->storage); + + /* replace socket data pointer */ + sock->storage = output; + } + } + } +} + static void do_versions(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ @@ -7586,7 +7672,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) Curve *cu; for (la= main->lamp.first; la; la= la->id.next) { - if (la->shadow_frustum_size == 0.0) + if (la->shadow_frustum_size == 0.0f) la->shadow_frustum_size= 10.0f; } @@ -7605,6 +7691,26 @@ static void do_versions(FileData *fd, Library *lib, Main *main) } } + if (main->versionfile < 263 || (main->versionfile == 263 && main->subversionfile < 5)) + { + { + /* file output node paths are now stored in the file info struct instead socket name */ + Scene *sce; + bNodeTree *ntree; + + for (sce = main->scene.first; sce; sce=sce->id.next) { + if (sce->nodetree) { + do_versions_nodetree_file_output_layers_2_64_5(sce->nodetree); + do_versions_nodetree_image_layer_2_64_5(sce->nodetree); + } + } + for (ntree = main->nodetree.first; ntree; ntree=ntree->id.next) { + do_versions_nodetree_file_output_layers_2_64_5(ntree); + do_versions_nodetree_image_layer_2_64_5(ntree); + } + } + } + /* default values in Freestyle settings */ { Scene *sce; @@ -8335,7 +8441,7 @@ typedef struct tConstraintExpandData { Main *mainvar; } tConstraintExpandData; /* callback function used to expand constraint ID-links */ -static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, void *userdata) +static void expand_constraint_cb(bConstraint *UNUSED(con), ID **idpoin, short UNUSED(isReference), void *userdata) { tConstraintExpandData *ced= (tConstraintExpandData *)userdata; expand_doit(ced->fd, ced->mainvar, *idpoin); @@ -8778,7 +8884,7 @@ static int object_in_any_scene(Main *mainvar, Object *ob) Scene *sce; for (sce= mainvar->scene.first; sce; sce= sce->id.next) - if (object_in_scene(ob, sce)) + if (BKE_scene_base_find(sce, ob)) return 1; return 0; } @@ -8854,13 +8960,13 @@ static void give_base_to_groups(Main *mainvar, Scene *scene) if (((group->id.flag & LIB_INDIRECT)==0 && (group->id.flag & LIB_PRE_EXISTING)==0)) { Base *base; - /* add_object(...) messes with the selection */ - Object *ob= add_only_object(OB_EMPTY, group->id.name+2); + /* BKE_object_add(...) messes with the selection */ + Object *ob= BKE_object_add_only_object(OB_EMPTY, group->id.name+2); ob->type= OB_EMPTY; ob->lay= scene->lay; /* assign the base */ - base= scene_add_base(scene, ob); + base= BKE_scene_base_add(scene, ob); base->flag |= SELECT; base->object->flag= base->flag; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index 8b4471086a8..8a8705532cb 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -25,10 +25,10 @@ * */ -/** \file blender/blenloader/intern/readfile_250.c +/** \file blender/blenloader/intern/versioning_250.c * \ingroup blenloader */ - + #include "zlib.h" #ifndef WIN32 @@ -111,20 +111,20 @@ /* 2.50 patch */ static void area_add_header_region(ScrArea *sa, ListBase *lb) { - ARegion *ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - + ARegion *ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_HEADER; - if (sa->headertype==HEADERDOWN) - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + if (sa->headertype == HEADERDOWN) + ar->alignment = RGN_ALIGN_BOTTOM; else - ar->alignment= RGN_ALIGN_TOP; - + ar->alignment = RGN_ALIGN_TOP; + /* initialize view2d data for header region, to allow panning */ /* is copy from ui_view2d.c */ ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); ar->v2d.keepofs = V2D_LOCKOFS_Y; - ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; ar->v2d.flag = (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); } @@ -133,23 +133,23 @@ static void sequencer_init_preview_region(ARegion* ar) { // XXX a bit ugly still, copied from space_sequencer /* NOTE: if you change values here, also change them in space_sequencer.c, sequencer_new */ - ar->regiontype= RGN_TYPE_PREVIEW; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_PREVIEW; + ar->alignment = RGN_ALIGN_TOP; ar->flag |= RGN_FLAG_HIDDEN; - ar->v2d.keepzoom= V2D_KEEPASPECT | V2D_KEEPZOOM; - ar->v2d.minzoom= 0.00001f; - ar->v2d.maxzoom= 100000.0f; + ar->v2d.keepzoom = V2D_KEEPASPECT | V2D_KEEPZOOM; + ar->v2d.minzoom = 0.00001f; + ar->v2d.maxzoom = 100000.0f; ar->v2d.tot.xmin = -960.0f; /* 1920 width centered */ ar->v2d.tot.ymin = -540.0f; /* 1080 height centered */ ar->v2d.tot.xmax = 960.0f; ar->v2d.tot.ymax = 540.0f; - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; - ar->v2d.max[0]= 12000.0f; - ar->v2d.max[1]= 12000.0f; - ar->v2d.cur= ar->v2d.tot; - ar->v2d.align= V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y); - ar->v2d.keeptot= V2D_KEEPTOT_FREE; + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; + ar->v2d.max[0] = 12000.0f; + ar->v2d.max[1] = 12000.0f; + ar->v2d.cur = ar->v2d.tot; + ar->v2d.align = V2D_ALIGN_FREE; // (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y); + ar->v2d.keeptot = V2D_KEEPTOT_FREE; } static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) @@ -161,271 +161,271 @@ static void area_add_window_regions(ScrArea *sa, SpaceLink *sl, ListBase *lb) /* first channels for ipo action nla... */ switch (sl->spacetype) { case SPACE_IPO: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - - // for some reason, this doesn't seem to go auto like for NLA... - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + + /* for some reason, this doesn't seem to go auto like for NLA... */ + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - ar->v2d.scroll= V2D_SCROLL_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; + ar->v2d.scroll = V2D_SCROLL_RIGHT; ar->v2d.flag = RGN_FLAG_HIDDEN; break; - + case SPACE_ACTION: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll= V2D_SCROLL_BOTTOM; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; + ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; break; - + case SPACE_NLA: - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; - ar->v2d.scroll= V2D_SCROLL_BOTTOM; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; + ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - - // for some reason, some files still don't get this auto - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + + /* for some reason, some files still don't get this auto */ + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - ar->v2d.scroll= V2D_SCROLL_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; + ar->v2d.scroll = V2D_SCROLL_RIGHT; ar->v2d.flag = RGN_FLAG_HIDDEN; break; - + case SPACE_NODE: - ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); + ar = MEM_callocN(sizeof(ARegion), "nodetree area for node"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_LEFT; ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* temporarily hide it */ ar->flag = RGN_FLAG_HIDDEN; break; case SPACE_FILE: - ar= MEM_callocN(sizeof(ARegion), "nodetree area for node"); + ar = MEM_callocN(sizeof(ARegion), "nodetree area for node"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - ar= MEM_callocN(sizeof(ARegion), "ui area for file"); + ar = MEM_callocN(sizeof(ARegion), "ui area for file"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_TOP; break; case SPACE_SEQ: - ar_main = (ARegion*)lb->first; + ar_main = (ARegion*) lb->first; for (; ar_main; ar_main = ar_main->next) { if (ar_main->regiontype == RGN_TYPE_WINDOW) break; } - ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); + ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer"); BLI_insertlinkbefore(lb, ar_main, ar); sequencer_init_preview_region(ar); break; case SPACE_VIEW3D: /* toolbar */ - ar= MEM_callocN(sizeof(ARegion), "toolbar for view3d"); - + ar = MEM_callocN(sizeof(ARegion), "toolbar for view3d"); + BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_TOOLS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_TOOLS; + ar->alignment = RGN_ALIGN_LEFT; ar->flag = RGN_FLAG_HIDDEN; - + /* tool properties */ - ar= MEM_callocN(sizeof(ARegion), "tool properties for view3d"); - + ar = MEM_callocN(sizeof(ARegion), "tool properties for view3d"); + BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_TOOL_PROPS; - ar->alignment= RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->regiontype = RGN_TYPE_TOOL_PROPS; + ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; ar->flag = RGN_FLAG_HIDDEN; - + /* buttons/list view */ - ar= MEM_callocN(sizeof(ARegion), "buttons for view3d"); - + ar = MEM_callocN(sizeof(ARegion), "buttons for view3d"); + BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; #if 0 case SPACE_BUTS: /* context UI region */ - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); BLI_addtail(lb, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; - + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; + break; #endif } } /* main region */ - ar= MEM_callocN(sizeof(ARegion), "area region from do_versions"); - + ar = MEM_callocN(sizeof(ARegion), "area region from do_versions"); + BLI_addtail(lb, ar); - ar->winrct= sa->totrct; - - ar->regiontype= RGN_TYPE_WINDOW; - + ar->winrct = sa->totrct; + + ar->regiontype = RGN_TYPE_WINDOW; + if (sl) { /* if active spacetype has view2d data, copy that over to main region */ /* and we split view3d */ switch (sl->spacetype) { case SPACE_VIEW3D: blo_do_versions_view3d_split_250((View3D *)sl, lb); - break; - + break; + case SPACE_OUTLINER: - { - SpaceOops *soops= (SpaceOops *)sl; - - memcpy(&ar->v2d, &soops->v2d, sizeof(View2D)); - - ar->v2d.scroll &= ~V2D_SCROLL_LEFT; - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); - ar->v2d.keeptot = V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; - //ar->v2d.flag |= V2D_IS_INITIALISED; - } + { + SpaceOops *soops = (SpaceOops *)sl; + + memcpy(&ar->v2d, &soops->v2d, sizeof(View2D)); + + ar->v2d.scroll &= ~V2D_SCROLL_LEFT; + ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom |= (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; + //ar->v2d.flag |= V2D_IS_INITIALISED; + } break; case SPACE_TIME: - { - SpaceTime *stime= (SpaceTime *)sl; - memcpy(&ar->v2d, &stime->v2d, sizeof(View2D)); - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; - ar->v2d.keepofs |= V2D_LOCKOFS_Y; - ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; - ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0; - ar->v2d.min[1]= ar->v2d.max[1]= 20.0; - } + { + SpaceTime *stime = (SpaceTime *)sl; + memcpy(&ar->v2d, &stime->v2d, sizeof(View2D)); + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; + ar->v2d.keepofs |= V2D_LOCKOFS_Y; + ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; + ar->v2d.tot.ymin = ar->v2d.cur.ymin = -10.0; + ar->v2d.min[1] = ar->v2d.max[1] = 20.0; + } break; case SPACE_IPO: - { - SpaceIpo *sipo= (SpaceIpo *)sl; - memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D)); - - /* init mainarea view2d */ - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); - - ar->v2d.min[0]= FLT_MIN; - ar->v2d.min[1]= FLT_MIN; - - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; - - //ar->v2d.flag |= V2D_IS_INITIALISED; - break; - } - case SPACE_NLA: - { - SpaceNla *snla= (SpaceNla *)sl; - memcpy(&ar->v2d, &snla->v2d, sizeof(View2D)); - - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; - ar->v2d.tot.ymax = 0.0f; - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.align = V2D_ALIGN_NO_POS_Y; - ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; - break; - } - case SPACE_ACTION: - { - SpaceAction *saction= (SpaceAction *)sl; - - /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */ - ar->v2d.tot.xmin = -20.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; - ar->v2d.tot.xmax = (float)((sa->winx > 120)? (sa->winx) : 120); - ar->v2d.tot.ymax = 0.0f; - - ar->v2d.cur= ar->v2d.tot; - - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; - - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; + { + SpaceIpo *sipo = (SpaceIpo *)sl; + memcpy(&ar->v2d, &sipo->v2d, sizeof(View2D)); - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.keepzoom= V2D_LOCKZOOM_Y; - ar->v2d.align= V2D_ALIGN_NO_POS_Y; - ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; - - /* for old files with ShapeKey editors open + an action set, clear the action as - * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit - * only shows ShapeKey-rooted actions only) - */ - if (saction->mode == SACTCONT_SHAPEKEY) - saction->action = NULL; - break; - } + /* init mainarea view2d */ + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + + ar->v2d.min[0] = FLT_MIN; + ar->v2d.min[1] = FLT_MIN; + + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; + + //ar->v2d.flag |= V2D_IS_INITIALISED; + break; + } + case SPACE_NLA: + { + SpaceNla *snla = (SpaceNla *)sl; + memcpy(&ar->v2d, &snla->v2d, sizeof(View2D)); + + ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymax = 0.0f; + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.align = V2D_ALIGN_NO_POS_Y; + ar->v2d.flag |= V2D_VIEWSYNC_AREA_VERTICAL; + break; + } + case SPACE_ACTION: + { + SpaceAction *saction = (SpaceAction *) sl; + + /* we totally reinit the view for the Action Editor, as some old instances had some weird cruft set */ + ar->v2d.tot.xmin = -20.0f; + ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.xmax = (float)((sa->winx > 120)? (sa->winx) : 120); + ar->v2d.tot.ymax = 0.0f; + + ar->v2d.cur = ar->v2d.tot; + + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; + + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; + + ar->v2d.minzoom = 0.01f; + ar->v2d.maxzoom = 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_RIGHT); + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; + ar->v2d.align = V2D_ALIGN_NO_POS_Y; + ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; + + /* for old files with ShapeKey editors open + an action set, clear the action as + * it doesn't make sense in the new system (i.e. violates concept that ShapeKey edit + * only shows ShapeKey-rooted actions only) + */ + if (saction->mode == SACTCONT_SHAPEKEY) + saction->action = NULL; + break; + } case SPACE_SEQ: - { - SpaceSeq *sseq= (SpaceSeq *)sl; - memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D)); - - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); - ar->v2d.align= V2D_ALIGN_NO_NEG_Y; - ar->v2d.flag |= V2D_IS_INITIALISED; - break; - } + { + SpaceSeq *sseq = (SpaceSeq *)sl; + memcpy(&ar->v2d, &sseq->v2d, sizeof(View2D)); + + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.align = V2D_ALIGN_NO_NEG_Y; + ar->v2d.flag |= V2D_IS_INITIALISED; + break; + } case SPACE_NODE: - { - SpaceNode *snode= (SpaceNode *)sl; - memcpy(&ar->v2d, &snode->v2d, sizeof(View2D)); - - ar->v2d.scroll= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - ar->v2d.keepzoom= V2D_LIMITZOOM|V2D_KEEPASPECT; - break; - } + { + SpaceNode *snode = (SpaceNode *)sl; + memcpy(&ar->v2d, &snode->v2d, sizeof(View2D)); + + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.keepzoom = V2D_LIMITZOOM|V2D_KEEPASPECT; + break; + } case SPACE_BUTS: - { - SpaceButs *sbuts= (SpaceButs *)sl; - memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D)); - - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); - break; - } + { + SpaceButs *sbuts = (SpaceButs *)sl; + memcpy(&ar->v2d, &sbuts->v2d, sizeof(View2D)); + + ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + break; + } case SPACE_FILE: - { - // SpaceFile *sfile= (SpaceFile *)sl; - ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0; - ar->v2d.tot.xmax = ar->winx; - ar->v2d.tot.ymax = ar->winy; - ar->v2d.cur = ar->v2d.tot; - ar->regiontype= RGN_TYPE_WINDOW; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - break; - } + { + // SpaceFile *sfile = (SpaceFile *)sl; + ar->v2d.tot.xmin = ar->v2d.tot.ymin = 0; + ar->v2d.tot.xmax = ar->winx; + ar->v2d.tot.ymax = ar->winy; + ar->v2d.cur = ar->v2d.tot; + ar->regiontype = RGN_TYPE_WINDOW; + ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); + break; + } case SPACE_TEXT: - { - SpaceText *st= (SpaceText *)sl; - st->flags |= ST_FIND_WRAP; - } + { + SpaceText *st = (SpaceText *)sl; + st->flags |= ST_FIND_WRAP; + } //case SPACE_XXX: // FIXME... add other ones // memcpy(&ar->v2d, &((SpaceXxx *)sl)->v2d, sizeof(View2D)); // break; @@ -437,35 +437,34 @@ static void do_versions_windowmanager_2_50(bScreen *screen) { ScrArea *sa; SpaceLink *sl; - + /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - + for (sa = screen->areabase.first; sa; sa = sa->next) { /* we keep headertype variable to convert old files only */ if (sa->headertype) area_add_header_region(sa, &sa->regionbase); - + area_add_window_regions(sa, sa->spacedata.first, &sa->regionbase); - + /* space imageselect is deprecated */ - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMASEL) - sl->spacetype= SPACE_EMPTY; /* spacedata then matches */ + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IMASEL) + sl->spacetype = SPACE_EMPTY; /* spacedata then matches */ } - + /* space sound is deprecated */ - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SOUND) - sl->spacetype= SPACE_EMPTY; /* spacedata then matches */ + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_SOUND) + sl->spacetype = SPACE_EMPTY; /* spacedata then matches */ } - + /* it seems to be possible in 2.5 to have this saved, filewindow probably */ - sa->butspacetype= sa->spacetype; - + sa->butspacetype = sa->spacetype; + /* pushed back spaces also need regions! */ if (sa->spacedata.first) { - sl= sa->spacedata.first; - for (sl= sl->next; sl; sl= sl->next) { + sl = sa->spacedata.first; + for (sl = sl->next; sl; sl = sl->next) { if (sa->headertype) area_add_header_region(sa, &sl->regionbase); area_add_window_regions(sa, sl, &sl->regionbase); @@ -476,61 +475,60 @@ static void do_versions_windowmanager_2_50(bScreen *screen) static void versions_gpencil_add_main(ListBase *lb, ID *id, const char *name) { - BLI_addtail(lb, id); - id->us= 1; - id->flag= LIB_FAKEUSER; + id->us = 1; + id->flag = LIB_FAKEUSER; *( (short *)id->name )= ID_GD; - + new_id(lb, id, name); /* alphabetic insterion: is in new_id */ - + if (G.debug & G_DEBUG) - printf("Converted GPencil to ID: %s\n", id->name+2); + printf("Converted GPencil to ID: %s\n", id->name + 2); } static void do_versions_gpencil_2_50(Main *main, bScreen *screen) { ScrArea *sa; SpaceLink *sl; - + /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + for (sa = screen->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; if (v3d->gpd) { versions_gpencil_add_main(&main->gpencil, (ID *)v3d->gpd, "GPencil View3D"); - v3d->gpd= NULL; + v3d->gpd = NULL; } } - else if (sl->spacetype==SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; + else if (sl->spacetype == SPACE_NODE) { + SpaceNode *snode = (SpaceNode *) sl; if (snode->gpd) { versions_gpencil_add_main(&main->gpencil, (ID *)snode->gpd, "GPencil Node"); - snode->gpd= NULL; + snode->gpd = NULL; } } - else if (sl->spacetype==SPACE_SEQ) { - SpaceSeq *sseq= (SpaceSeq *)sl; + else if (sl->spacetype == SPACE_SEQ) { + SpaceSeq *sseq = (SpaceSeq *) sl; if (sseq->gpd) { versions_gpencil_add_main(&main->gpencil, (ID *)sseq->gpd, "GPencil Node"); - sseq->gpd= NULL; + sseq->gpd = NULL; } } - else if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; + else if (sl->spacetype == SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *) sl; #if 0 /* see comment on r28002 */ if (sima->gpd) { versions_gpencil_add_main(&main->gpencil, (ID *)sima->gpd, "GPencil Image"); - sima->gpd= NULL; + sima->gpd = NULL; } #else - sima->gpd= NULL; + sima->gpd = NULL; #endif } } - } + } } static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) @@ -542,57 +540,57 @@ static void do_version_mtex_factor_2_50(MTex **mtex_array, short idtype) if (!mtex_array) return; - for (a=0; amaptoneg; - varfac= mtex->varfac; - colfac= mtex->colfac; + neg = mtex->maptoneg; + varfac = mtex->varfac; + colfac = mtex->colfac; - if (neg & MAP_DISP) mtex->dispfac= -mtex->dispfac; - if (neg & MAP_NORM) mtex->norfac= -mtex->norfac; - if (neg & MAP_WARP) mtex->warpfac= -mtex->warpfac; + if (neg & MAP_DISP) mtex->dispfac = -mtex->dispfac; + if (neg & MAP_NORM) mtex->norfac = -mtex->norfac; + if (neg & MAP_WARP) mtex->warpfac = -mtex->warpfac; - mtex->colspecfac= (neg & MAP_COLSPEC)? -colfac: colfac; - mtex->mirrfac= (neg & MAP_COLMIR)? -colfac: colfac; - mtex->alphafac= (neg & MAP_ALPHA)? -varfac: varfac; - mtex->difffac= (neg & MAP_REF)? -varfac: varfac; - mtex->specfac= (neg & MAP_SPEC)? -varfac: varfac; - mtex->emitfac= (neg & MAP_EMIT)? -varfac: varfac; - mtex->hardfac= (neg & MAP_HAR)? -varfac: varfac; - mtex->raymirrfac= (neg & MAP_RAYMIRR)? -varfac: varfac; - mtex->translfac= (neg & MAP_TRANSLU)? -varfac: varfac; - mtex->ambfac= (neg & MAP_AMB)? -varfac: varfac; - mtex->colemitfac= (neg & MAP_EMISSION_COL)? -colfac: colfac; - mtex->colreflfac= (neg & MAP_REFLECTION_COL)? -colfac: colfac; - mtex->coltransfac= (neg & MAP_TRANSMISSION_COL)? -colfac: colfac; - mtex->densfac= (neg & MAP_DENSITY)? -varfac: varfac; - mtex->scatterfac= (neg & MAP_SCATTERING)? -varfac: varfac; - mtex->reflfac= (neg & MAP_REFLECTION)? -varfac: varfac; + mtex->colspecfac = (neg & MAP_COLSPEC)? -colfac: colfac; + mtex->mirrfac = (neg & MAP_COLMIR)? -colfac: colfac; + mtex->alphafac = (neg & MAP_ALPHA)? -varfac: varfac; + mtex->difffac = (neg & MAP_REF)? -varfac: varfac; + mtex->specfac = (neg & MAP_SPEC)? -varfac: varfac; + mtex->emitfac = (neg & MAP_EMIT)? -varfac: varfac; + mtex->hardfac = (neg & MAP_HAR)? -varfac: varfac; + mtex->raymirrfac = (neg & MAP_RAYMIRR)? -varfac: varfac; + mtex->translfac = (neg & MAP_TRANSLU)? -varfac: varfac; + mtex->ambfac = (neg & MAP_AMB)? -varfac: varfac; + mtex->colemitfac = (neg & MAP_EMISSION_COL)? -colfac: colfac; + mtex->colreflfac = (neg & MAP_REFLECTION_COL)? -colfac: colfac; + mtex->coltransfac = (neg & MAP_TRANSMISSION_COL)? -colfac: colfac; + mtex->densfac = (neg & MAP_DENSITY)? -varfac: varfac; + mtex->scatterfac = (neg & MAP_SCATTERING)? -varfac: varfac; + mtex->reflfac = (neg & MAP_REFLECTION)? -varfac: varfac; - mtex->timefac= (neg & MAP_PA_TIME)? -varfac: varfac; - mtex->lengthfac= (neg & MAP_PA_LENGTH)? -varfac: varfac; - mtex->clumpfac= (neg & MAP_PA_CLUMP)? -varfac: varfac; - mtex->kinkfac= (neg & MAP_PA_KINK)? -varfac: varfac; - mtex->roughfac= (neg & MAP_PA_ROUGH)? -varfac: varfac; - mtex->padensfac= (neg & MAP_PA_DENS)? -varfac: varfac; - mtex->lifefac= (neg & MAP_PA_LIFE)? -varfac: varfac; - mtex->sizefac= (neg & MAP_PA_SIZE)? -varfac: varfac; - mtex->ivelfac= (neg & MAP_PA_IVEL)? -varfac: varfac; + mtex->timefac = (neg & MAP_PA_TIME)? -varfac: varfac; + mtex->lengthfac = (neg & MAP_PA_LENGTH)? -varfac: varfac; + mtex->clumpfac = (neg & MAP_PA_CLUMP)? -varfac: varfac; + mtex->kinkfac = (neg & MAP_PA_KINK)? -varfac: varfac; + mtex->roughfac = (neg & MAP_PA_ROUGH)? -varfac: varfac; + mtex->padensfac = (neg & MAP_PA_DENS)? -varfac: varfac; + mtex->lifefac = (neg & MAP_PA_LIFE)? -varfac: varfac; + mtex->sizefac = (neg & MAP_PA_SIZE)? -varfac: varfac; + mtex->ivelfac = (neg & MAP_PA_IVEL)? -varfac: varfac; - mtex->shadowfac= (neg & LAMAP_SHAD)? -colfac: colfac; + mtex->shadowfac = (neg & LAMAP_SHAD)? -colfac: colfac; - mtex->zenupfac= (neg & WOMAP_ZENUP)? -colfac: colfac; - mtex->zendownfac= (neg & WOMAP_ZENDOWN)? -colfac: colfac; - mtex->blendfac= (neg & WOMAP_BLEND)? -varfac: varfac; + mtex->zenupfac = (neg & WOMAP_ZENUP)? -colfac: colfac; + mtex->zendownfac = (neg & WOMAP_ZENDOWN)? -colfac: colfac; + mtex->blendfac = (neg & WOMAP_BLEND)? -varfac: varfac; if (idtype == ID_MA) - mtex->colfac= (neg & MAP_COL)? -colfac: colfac; + mtex->colfac = (neg & MAP_COL)? -colfac: colfac; else if (idtype == ID_LA) - mtex->colfac= (neg & LAMAP_COL)? -colfac: colfac; + mtex->colfac = (neg & LAMAP_COL)? -colfac: colfac; else if (idtype == ID_WO) - mtex->colfac= (neg & WOMAP_HORIZ)? -colfac: colfac; + mtex->colfac = (neg & WOMAP_HORIZ)? -colfac: colfac; } } } @@ -603,16 +601,16 @@ static void do_version_mdef_250(Main *main) ModifierData *md; MeshDeformModifierData *mmd; - for (ob= main->object.first; ob; ob=ob->id.next) { - for (md=ob->modifiers.first; md; md=md->next) { + for (ob = main->object.first; ob; ob = ob->id.next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_MeshDeform) { - mmd= (MeshDeformModifierData*)md; + mmd = (MeshDeformModifierData*) md; if (mmd->bindcos) { /* make bindcos NULL in order to trick older versions * into thinking that the mesh was not bound yet */ - mmd->bindcagecos= mmd->bindcos; - mmd->bindcos= NULL; + mmd->bindcagecos = mmd->bindcos; + mmd->bindcos = NULL; modifier_mdef_compact_influences(md); } @@ -625,43 +623,41 @@ static void do_version_constraints_radians_degrees_250(ListBase *lb) { bConstraint *con; - for (con=lb->first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT) { + for (con = lb->first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_RIGIDBODYJOINT) { bRigidBodyJointConstraint *data = con->data; - data->axX *= (float)(M_PI/180.0); - data->axY *= (float)(M_PI/180.0); - data->axZ *= (float)(M_PI/180.0); + data->axX *= (float)(M_PI / 180.0); + data->axY *= (float)(M_PI / 180.0); + data->axZ *= (float)(M_PI / 180.0); } - else if (con->type==CONSTRAINT_TYPE_KINEMATIC) { + else if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = con->data; - data->poleangle *= (float)(M_PI/180.0); + data->poleangle *= (float)(M_PI / 180.0); } - else if (con->type==CONSTRAINT_TYPE_ROTLIMIT) { + else if (con->type == CONSTRAINT_TYPE_ROTLIMIT) { bRotLimitConstraint *data = con->data; - data->xmin *= (float)(M_PI/180.0); - data->xmax *= (float)(M_PI/180.0); - data->ymin *= (float)(M_PI/180.0); - data->ymax *= (float)(M_PI/180.0); - data->zmin *= (float)(M_PI/180.0); - data->zmax *= (float)(M_PI/180.0); + data->xmin *= (float)(M_PI / 180.0); + data->xmax *= (float)(M_PI / 180.0); + data->ymin *= (float)(M_PI / 180.0); + data->ymax *= (float)(M_PI / 180.0); + data->zmin *= (float)(M_PI / 180.0); + data->zmax *= (float)(M_PI / 180.0); } } } /* NOTE: this version patch is intended for versions < 2.52.2, but was initially introduced in 2.27 already */ -static void do_versions_seq_unique_name_all_strips( - Scene * sce, ListBase *seqbasep) +static void do_versions_seq_unique_name_all_strips(Scene * sce, ListBase *seqbasep) { Sequence * seq = seqbasep->first; while (seq) { seqbase_unique_name_recursive(&sce->ed->seqbase, seq); if (seq->seqbase.first) { - do_versions_seq_unique_name_all_strips( - sce, &seq->seqbase); + do_versions_seq_unique_name_all_strips(sce, &seq->seqbase); } - seq=seq->next; + seq = seq->next; } } @@ -669,10 +665,10 @@ static void do_version_bone_roll_256(Bone *bone) { Bone *child; float submat[3][3]; - + copy_m3_m4(submat, bone->arm_mat); mat3_to_vec_roll(submat, NULL, &bone->arm_roll); - + for (child = bone->childbase.first; child; child = child->next) do_version_bone_roll_256(child); } @@ -680,9 +676,9 @@ static void do_version_bone_roll_256(Bone *bone) static void do_versions_nodetree_dynamic_sockets(bNodeTree *ntree) { bNodeSocket *sock; - for (sock=ntree->inputs.first; sock; sock=sock->next) + for (sock = ntree->inputs.first; sock; sock = sock->next) sock->flag |= SOCK_DYNAMIC; - for (sock=ntree->outputs.first; sock; sock=sock->next) + for (sock = ntree->outputs.first; sock; sock = sock->next) sock->flag |= SOCK_DYNAMIC; } @@ -690,9 +686,6 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (G.debug & G_DEBUG) - printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); - if (main->versionfile < 250) { bScreen *screen; Scene *scene; @@ -720,8 +713,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + for (ob = main->object.first; ob; ob = ob->id.next) { + for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_SOUND) { bSoundActuator *sAct = (bSoundActuator*) act->data; if (sAct->sound) { @@ -757,55 +750,51 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) BLI_path_abs(str, main->name); seq->sound = sound_new_file(main, str); } - /* don't know, if anybody used that - * this way, but just in case, upgrade - * to new way... */ + /* don't know, if anybody used that this way, but just in case, upgrade to new way... */ if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) { - - BLI_snprintf(seq->strip->proxy->dir, - FILE_MAXDIR, "%s/BL_proxy", - seq->strip->dir); + BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s/BL_proxy", seq->strip->dir); } } SEQ_END } } - for (screen= main->screen.first; screen; screen= screen->id.next) { + for (screen = main->screen.first; screen; screen = screen->id.next) { do_versions_windowmanager_2_50(screen); do_versions_gpencil_2_50(main, screen); } - + /* shader, composite and texture node trees have id.name empty, put something in * to have them show in RNA viewer and accessible otherwise. */ - for (ma= main->mat.first; ma; ma= ma->id.next) { + for (ma = main->mat.first; ma; ma = ma->id.next) { if (ma->nodetree && ma->nodetree->id.name[0] == '\0') strcpy(ma->nodetree->id.name, "NTShader Nodetree"); - + /* which_output 0 is now "not specified" */ - for (a=0; amtex[a]) { - tx= blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex); + tx = blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex); if (tx && tx->use_nodes) ma->mtex[a]->which_output++; } } } + /* and composite trees */ - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->nodetree && sce->nodetree->id.name[0] == '\0') strcpy(sce->nodetree->id.name, "NTCompositing Nodetree"); /* move to cameras */ if (sce->r.mode & R_PANORAMA) { - for (base=sce->base.first; base; base=base->next) { - ob= blo_do_versions_newlibadr(fd, lib, base->object); + for (base = sce->base.first; base; base = base->next) { + ob = blo_do_versions_newlibadr(fd, lib, base->object); if (ob->type == OB_CAMERA && !ob->id.lib) { - cam= blo_do_versions_newlibadr(fd, lib, ob->data); + cam = blo_do_versions_newlibadr(fd, lib, ob->data); cam->flag |= CAM_PANORAMA; } } @@ -813,8 +802,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->r.mode &= ~R_PANORAMA; } } + /* and texture trees */ - for (tx= main->tex.first; tx; tx= tx->id.next) { + for (tx = main->tex.first; tx; tx = tx->id.next) { bNode *node; if (tx->nodetree) { @@ -822,19 +812,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) strcpy(tx->nodetree->id.name, "NTTexture Nodetree"); /* which_output 0 is now "not specified" */ - for (node=tx->nodetree->nodes.first; node; node=node->next) + for (node = tx->nodetree->nodes.first; node; node = node->next) if (node->type == TEX_NODE_OUTPUT) node->custom1++; } } - + /* copy standard draw flag to meshes(used to be global, is not available here) */ - for (me= main->mesh.first; me; me= me->id.next) { - me->drawflag= ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; + for (me = main->mesh.first; me; me = me->id.next) { + me->drawflag = ME_DRAWEDGES|ME_DRAWFACES|ME_DRAWCREASES; } /* particle draw and render types */ - for (part= main->particle.first; part; part= part->id.next) { + for (part = main->particle.first; part; part = part->id.next) { if (part->draw_as) { if (part->draw_as == PART_DRAW_DOT) { part->ren_as = PART_DRAW_HALO; @@ -851,22 +841,23 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) part->path_end = 1.0f; part->clength = 1.0f; } + /* set old pointcaches to have disk cache flag */ - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { //BKE_ptcache_ids_from_object(&pidlist, ob); - //for (pid=pidlist.first; pid; pid=pid->next) + //for (pid = pidlist.first; pid; pid = pid->next) // pid->cache->flag |= PTCACHE_DISK_CACHE; //BLI_freelistN(&pidlist); } /* type was a mixed flag & enum. move the 2d flag elsewhere */ - for (cu = main->curve.first; cu; cu= cu->id.next) { + for (cu = main->curve.first; cu; cu = cu->id.next) { Nurb *nu; - for (nu= cu->nurb.first; nu; nu= nu->next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { nu->flag |= (nu->type & CU_2D); nu->type &= CU_TYPE; } @@ -885,7 +876,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) for (ob = main->object.first; ob; ob = ob->id.next) { //BKE_ptcache_ids_from_object(&pidlist, ob); - //for (pid=pidlist.first; pid; pid=pid->next) { + //for (pid = pidlist.first; pid; pid = pid->next) { // if (pid->ptcaches->first == NULL) // pid->ptcaches->first = pid->ptcaches->last = pid->cache; //} @@ -899,7 +890,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* XXX - library meshes crash on loading most yoFrankie levels, * the multires pointer gets invalid - Campbell */ - if (me && me->id.lib==NULL && me->mr && me->mr->level_count > 1) { + if (me && me->id.lib == NULL && me->mr && me->mr->level_count > 1) { multires_load_old(ob, me); } @@ -909,26 +900,28 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (ob->totcol && ob->matbits == NULL) { int a; - ob->matbits= MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits"); - for (a=0; atotcol; a++) - ob->matbits[a]= ob->colbits & (1<matbits = MEM_callocN(sizeof(char)*ob->totcol, "ob->matbits"); + for (a = 0; a < ob->totcol; a++) + ob->matbits[a] = ob->colbits & (1<tex.first; tex; tex = tex->id.next) { if (tex->afmax == 0) - tex->afmax= 8; + tex->afmax = 8; } for (ma = main->mat.first; ma; ma = ma->id.next) { int a; + if (ma->mode & MA_WIRE) { - ma->material_type= MA_TYPE_WIRE; + ma->material_type = MA_TYPE_WIRE; ma->mode &= ~MA_WIRE; } + if (ma->mode & MA_HALO) { - ma->material_type= MA_TYPE_HALO; + ma->material_type = MA_TYPE_HALO; ma->mode &= ~MA_HALO; } @@ -941,15 +934,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* set new bump for unused slots */ - for (a=0; amtex[a]) { - tex= ma->mtex[a]->tex; + tex = ma->mtex[a]->tex; if (!tex) { ma->mtex[a]->texflag |= MTEX_3TAP_BUMP; ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE; } else { - tex= (Tex*)blo_do_versions_newlibadr(fd, ma->id.lib, tex); + tex = (Tex*) blo_do_versions_newlibadr(fd, ma->id.lib, tex); if (tex && tex->type == 0) { /* invalid type */ ma->mtex[a]->texflag |= MTEX_3TAP_BUMP; ma->mtex[a]->texflag |= MTEX_BUMP_OBJECTSPACE; @@ -957,7 +950,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - + /* volume rendering settings */ if (ma->vol.stepsize < 0.0001f) { ma->vol.density = 1.0f; @@ -975,24 +968,24 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } for (sce = main->scene.first; sce; sce = sce->id.next) { - ts= sce->toolsettings; + ts = sce->toolsettings; if (ts->normalsize == 0.0f || !ts->uv_selectmode || ts->vgroup_weight == 0.0f) { - ts->normalsize= 0.1f; - ts->selectmode= SCE_SELECT_VERTEX; - + ts->normalsize = 0.1f; + ts->selectmode = SCE_SELECT_VERTEX; + /* autokeying - setting should be taken from the user-prefs - * but the userprefs version may not have correct flags set + * but the userprefs version may not have correct flags set * (i.e. will result in blank box when enabled) */ - ts->autokey_mode= U.autokey_mode; - if (ts->autokey_mode == 0) - ts->autokey_mode= 2; /* 'add/replace' but not on */ - ts->uv_selectmode= UV_SELECT_VERTEX; - ts->vgroup_weight= 1.0f; + ts->autokey_mode = U.autokey_mode; + if (ts->autokey_mode == 0) + ts->autokey_mode = 2; /* 'add/replace' but not on */ + ts->uv_selectmode = UV_SELECT_VERTEX; + ts->vgroup_weight = 1.0f; } /* Game Settings */ - //Dome + /* Dome */ sce->gm.dome.angle = sce->r.domeangle; sce->gm.dome.mode = sce->r.domemode; sce->gm.dome.res = sce->r.domeres; @@ -1000,7 +993,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.dome.tilt = sce->r.dometilt; sce->gm.dome.warptext = sce->r.dometext; - //Stand Alone + /* Stand Alone */ sce->gm.playerflag |= (sce->r.fullscreen?GAME_PLAYER_FULLSCREEN:0); sce->gm.xplay = sce->r.xplay; sce->gm.yplay = sce->r.yplay; @@ -1008,31 +1001,31 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.depth = sce->r.depth; sce->gm.attrib = sce->r.attrib; - //Stereo + /* Stereo */ sce->gm.stereomode = sce->r.stereomode; /* reassigning stereomode NO_STEREO and DOME to a separeted flag*/ - if (sce->gm.stereomode == 1) { //1 = STEREO_NOSTEREO + if (sce->gm.stereomode == 1) { // 1 = STEREO_NOSTEREO sce->gm.stereoflag = STEREO_NOSTEREO; sce->gm.stereomode = STEREO_ANAGLYPH; } - else if (sce->gm.stereomode == 8) { //8 = STEREO_DOME + else if (sce->gm.stereomode == 8) { // 8 = STEREO_DOME sce->gm.stereoflag = STEREO_DOME; sce->gm.stereomode = STEREO_ANAGLYPH; } else sce->gm.stereoflag = STEREO_ENABLED; - //Framing + /* Framing */ sce->gm.framing = sce->framing; sce->gm.xplay = sce->r.xplay; sce->gm.yplay = sce->r.yplay; - sce->gm.freqplay= sce->r.freqplay; - sce->gm.depth= sce->r.depth; + sce->gm.freqplay = sce->r.freqplay; + sce->gm.depth = sce->r.depth; - //Physic (previously stored in world) + /* Physic (previously stored in world) */ sce->gm.gravity =9.8f; - sce->gm.physicsEngine= WOPHY_BULLET;// Bullet by default - sce->gm.mode = WO_DBVT_CULLING; // DBVT culling by default + sce->gm.physicsEngine = WOPHY_BULLET; /* Bullet by default */ + sce->gm.mode = WO_DBVT_CULLING; /* DBVT culling by default */ sce->gm.occlusionRes = 128; sce->gm.ticrate = 60; sce->gm.maxlogicstep = 5; @@ -1068,15 +1061,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) sce->gm.flag |= GAME_IGNORE_DEPRECATION_WARNINGS; if (fd->fileflags & G_FILE_GAME_MAT_GLSL) - sce->gm.matmode= GAME_MAT_GLSL; + sce->gm.matmode = GAME_MAT_GLSL; else if (fd->fileflags & G_FILE_GAME_MAT) - sce->gm.matmode= GAME_MAT_MULTITEX; + sce->gm.matmode = GAME_MAT_MULTITEX; else - sce->gm.matmode= GAME_MAT_TEXFACE; + sce->gm.matmode = GAME_MAT_TEXFACE; sce->gm.flag |= GAME_DISPLAY_LISTS; } - + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->flag & 8192) // OB_POSEMODE = 8192 ob->mode |= OB_MODE_POSE; @@ -1095,18 +1088,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) for (sce = main->scene.first; sce; sce = sce->id.next) if (sce->unit.scale_length == 0.0f) - sce->unit.scale_length= 1.0f; - + sce->unit.scale_length = 1.0f; + for (ob = main->object.first; ob; ob = ob->id.next) { /* fluid-sim stuff */ - FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); - if (fluidmd) fluidmd->fss->fmd = fluidmd; - + FluidsimModifierData *fluidmd = (FluidsimModifierData *) modifiers_findByType(ob, eModifierType_Fluidsim); + if (fluidmd) + fluidmd->fss->fmd = fluidmd; + /* rotation modes were added, but old objects would now default to being 'quaternion based' */ - ob->rotmode= ROT_MODE_EUL; + ob->rotmode = ROT_MODE_EUL; } - - for (ma = main->mat.first; ma; ma=ma->id.next) { + + for (ma = main->mat.first; ma; ma = ma->id.next) { if (ma->vol.reflection == 0.f) { ma->vol.reflection = 1.f; ma->vol.transmission_col[0] = ma->vol.transmission_col[1] = ma->vol.transmission_col[2] = 1.0f; @@ -1116,18 +1110,18 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) do_version_mtex_factor_2_50(ma->mtex, ID_MA); } - for (la = main->lamp.first; la; la=la->id.next) + for (la = main->lamp.first; la; la = la->id.next) do_version_mtex_factor_2_50(la->mtex, ID_LA); - for (wo = main->world.first; wo; wo=wo->id.next) + for (wo = main->world.first; wo; wo = wo->id.next) do_version_mtex_factor_2_50(wo->mtex, ID_WO); - for (tex = main->tex.first; tex; tex=tex->id.next) + for (tex = main->tex.first; tex; tex = tex->id.next) if (tex->vd) if (tex->vd->extend == 0) tex->vd->extend = TEX_CLIP; - - for (sce= main->scene.first; sce; sce= sce->id.next) { + + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->audio.main == 0.0f) sce->audio.main = 1.0f; @@ -1139,7 +1133,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* Add default gravity to scenes */ - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if ((sce->physics_settings.flag & PHYS_GLOBAL_GRAVITY) == 0 && len_v3(sce->physics_settings.gravity) == 0.0f) { @@ -1151,15 +1145,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* Assign proper global gravity weights for dynamics (only z-coordinate is taken into account) */ - if (do_gravity) for (part= main->particle.first; part; part= part->id.next) - part->effector_weights->global_gravity = part->acc[2]/-9.81f; + if (do_gravity) { + for (part = main->particle.first; part; part = part->id.next) + part->effector_weights->global_gravity = part->acc[2]/-9.81f; + } for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; if (do_gravity) { - for (md= ob->modifiers.first; md; md= md->next) { - ClothModifierData *clmd = (ClothModifierData *)modifiers_findByType(ob, eModifierType_Cloth); + for (md = ob->modifiers.first; md; md = md->next) { + ClothModifierData *clmd = (ClothModifierData *) modifiers_findByType(ob, eModifierType_Cloth); if (clmd) clmd->sim_parms->effector_weights->global_gravity = clmd->sim_parms->gravity[2]/-9.81f; } @@ -1172,7 +1168,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (ob->pd) { if (ob->pd->forcefield == PFIELD_WIND) ob->pd->shape = PFIELD_SHAPE_PLANE; - + if (ob->pd->flag & PFIELD_PLANAR) ob->pd->shape = PFIELD_SHAPE_PLANE; else if (ob->pd->flag & PFIELD_SURFACE) @@ -1186,26 +1182,26 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 6)) { Object *ob; Lamp *la; - + /* New variables for axis-angle rotations and/or quaternion rotations were added, and need proper initialization */ - for (ob= main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { /* new variables for all objects */ - ob->quat[0]= 1.0f; - ob->rotAxis[1]= 1.0f; - + ob->quat[0] = 1.0f; + ob->rotAxis[1] = 1.0f; + /* bones */ if (ob->pose) { bPoseChannel *pchan; - - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* just need to initalise rotation axis properly... */ - pchan->rotAxis[1]= 1.0f; + pchan->rotAxis[1] = 1.0f; } } } - for (la = main->lamp.first; la; la=la->id.next) - la->compressthresh= 0.05f; + for (la = main->lamp.first; la; la = la->id.next) + la->compressthresh = 0.05f; } if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 7)) { @@ -1220,48 +1216,47 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* shape keys are no longer applied to the mesh itself, but rather * to the derivedmesh/displist, so here we ensure that the basis * shape key is always set in the mesh coordinates. */ - - for (me= main->mesh.first; me; me= me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { if ((key = blo_do_versions_newlibadr(fd, lib, me->key)) && key->refkey) { - data= key->refkey->data; - tot= MIN2(me->totvert, key->refkey->totelem); + data = key->refkey->data; + tot = MIN2(me->totvert, key->refkey->totelem); - for (a=0; amvert[a].co, data); } } - for (lt= main->latt.first; lt; lt= lt->id.next) { + for (lt = main->latt.first; lt; lt = lt->id.next) { if ((key = blo_do_versions_newlibadr(fd, lib, lt->key)) && key->refkey) { - data= key->refkey->data; - tot= MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem); + data = key->refkey->data; + tot = MIN2(lt->pntsu*lt->pntsv*lt->pntsw, key->refkey->totelem); - for (a=0; adef[a].vec, data); } } - for (cu= main->curve.first; cu; cu= cu->id.next) { + for (cu = main->curve.first; cu; cu = cu->id.next) { if ((key = blo_do_versions_newlibadr(fd, lib, cu->key)) && key->refkey) { - data= key->refkey->data; + data = key->refkey->data; - for (nu=cu->nurb.first; nu; nu=nu->next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu->bezt) { BezTriple *bezt = nu->bezt; - for (a=0; apntsu; a++, bezt++) { + for (a = 0; a < nu->pntsu; a++, bezt++) { copy_v3_v3(bezt->vec[0], data); data+=3; copy_v3_v3(bezt->vec[1], data); data+=3; copy_v3_v3(bezt->vec[2], data); data+=3; - bezt->alfa= *data; data++; + bezt->alfa = *data; data++; } } else if (nu->bp) { BPoint *bp = nu->bp; - for (a=0; apntsu*nu->pntsv; a++, bp++) { - copy_v3_v3(bp->vec, data); data+=3; - bp->alfa= *data; data++; + for (a = 0; a < nu->pntsu*nu->pntsv; a++, bp++) { + copy_v3_v3(bp->vec, data); data += 3; + bp->alfa = *data; data++; } } } @@ -1271,69 +1266,72 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 8)) { { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; while (sce) { - if (sce->r.frame_step==0) - sce->r.frame_step= 1; - if (sce->r.mblur_samples==0) + if (sce->r.frame_step == 0) + sce->r.frame_step = 1; + if (sce->r.mblur_samples == 0) sce->r.mblur_samples = sce->r.osa; - + if (sce->ed && sce->ed->seqbase.first) { - do_versions_seq_unique_name_all_strips( - sce, &sce->ed->seqbase); + do_versions_seq_unique_name_all_strips(sce, &sce->ed->seqbase); } - - sce= sce->id.next; + + sce = sce->id.next; } } + { /* ensure all nodes have unique names */ - bNodeTree *ntree= main->nodetree.first; + bNodeTree *ntree = main->nodetree.first; while (ntree) { - bNode *node=ntree->nodes.first; - + bNode *node = ntree->nodes.first; + while (node) { nodeUniqueName(ntree, node); - node= node->next; + node = node->next; } - - ntree= ntree->id.next; + + ntree = ntree->id.next; } } + { - Object *ob=main->object.first; + Object *ob = main->object.first; while (ob) { /* shaded mode disabled for now */ - if (ob->dt == OB_MATERIAL) ob->dt = OB_TEXTURE; - ob=ob->id.next; + if (ob->dt == OB_MATERIAL) + ob->dt = OB_TEXTURE; + ob = ob->id.next; } } - + { bScreen *screen; ScrArea *sa; SpaceLink *sl; - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d = (View3D *)sl; - if (v3d->drawtype == OB_MATERIAL) v3d->drawtype = OB_SOLID; + + for (screen = main->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; + if (v3d->drawtype == OB_MATERIAL) + v3d->drawtype = OB_SOLID; } } } } } - + /* only convert old 2.50 files with color management */ if (main->versionfile == 250) { - Scene *sce=main->scene.first; - Material *ma=main->mat.first; - World *wo=main->world.first; - Tex *tex=main->tex.first; - int i, convert=0; - + Scene *sce = main->scene.first; + Material *ma = main->mat.first; + World *wo = main->world.first; + Tex *tex = main->tex.first; + int i, convert = 0; + /* convert to new color management system: * while previously colors were stored as srgb, * now they are stored as linear internally, @@ -1342,76 +1340,77 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* don't know what scene is active, so we'll convert if any scene has it enabled... */ while (sce) { if (sce->r.color_mgt_flag & R_COLOR_MANAGEMENT) - convert=1; - sce=sce->id.next; + convert = 1; + sce = sce->id.next; } - + if (convert) { while (ma) { if (ma->ramp_col) { ColorBand *band = (ColorBand *)ma->ramp_col; - for (i=0; itot; i++) { + for (i = 0; i < band->tot; i++) { CBData *data = band->data + i; srgb_to_linearrgb_v3_v3(&data->r, &data->r); } } + if (ma->ramp_spec) { ColorBand *band = (ColorBand *)ma->ramp_spec; - for (i=0; itot; i++) { + for (i = 0; i < band->tot; i++) { CBData *data = band->data + i; srgb_to_linearrgb_v3_v3(&data->r, &data->r); } } - + srgb_to_linearrgb_v3_v3(&ma->r, &ma->r); srgb_to_linearrgb_v3_v3(&ma->specr, &ma->specr); srgb_to_linearrgb_v3_v3(&ma->mirr, &ma->mirr); srgb_to_linearrgb_v3_v3(ma->sss_col, ma->sss_col); - ma=ma->id.next; + ma = ma->id.next; } - + while (tex) { if (tex->coba) { ColorBand *band = (ColorBand *)tex->coba; - for (i=0; itot; i++) { + for (i = 0; i < band->tot; i++) { CBData *data = band->data + i; srgb_to_linearrgb_v3_v3(&data->r, &data->r); } } - tex=tex->id.next; + tex = tex->id.next; } - + while (wo) { srgb_to_linearrgb_v3_v3(&wo->ambr, &wo->ambr); srgb_to_linearrgb_v3_v3(&wo->horr, &wo->horr); srgb_to_linearrgb_v3_v3(&wo->zenr, &wo->zenr); - wo=wo->id.next; + wo = wo->id.next; } } } } - + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 9)) { Scene *sce; Mesh *me; Object *ob; - for (sce=main->scene.first; sce; sce=sce->id.next) + for (sce = main->scene.first; sce; sce = sce->id.next) if (!sce->toolsettings->particle.selectmode) - sce->toolsettings->particle.selectmode= SCE_SELECT_PATH; + sce->toolsettings->particle.selectmode = SCE_SELECT_PATH; if (main->versionfile == 250 && main->subversionfile > 1) { - for (me=main->mesh.first; me; me=me->id.next) + for (me = main->mesh.first; me; me = me->id.next) multires_load_old_250(me); - for (ob=main->object.first; ob; ob=ob->id.next) { - MultiresModifierData *mmd = (MultiresModifierData *)modifiers_findByType(ob, eModifierType_Multires); + for (ob = main->object.first; ob; ob = ob->id.next) { + MultiresModifierData *mmd = (MultiresModifierData *) modifiers_findByType(ob, eModifierType_Multires); if (mmd) { mmd->totlvl--; mmd->lvl--; - mmd->sculptlvl= mmd->lvl; - mmd->renderlvl= mmd->lvl; + mmd->sculptlvl = mmd->lvl; + mmd->renderlvl = mmd->lvl; } } } @@ -1423,7 +1422,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* properly initialize hair clothsim data on old files */ for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData *)md; if (clmd->sim_parms->velocity_smooth < 0.01f) @@ -1440,12 +1439,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ScrArea *sa; SpaceLink *sl; - /* remove all preview window in wrong spaces */ - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype!=SPACE_SEQ) { + for (screen = main->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype != SPACE_SEQ) { ARegion *ar; ListBase *regionbase; @@ -1456,14 +1454,13 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; } - - for ( ar = regionbase->first; ar; ar = ar->next) { + for (ar = regionbase->first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_PREVIEW) break; } if (ar && (ar->regiontype == RGN_TYPE_PREVIEW)) { - SpaceType *st= BKE_spacetype_from_id(SPACE_SEQ); + SpaceType *st = BKE_spacetype_from_id(SPACE_SEQ); BKE_area_region_free(st, ar); BLI_freelinkN(regionbase, ar); } @@ -1480,11 +1477,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ScrArea *sa; SpaceLink *sl; - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { + for (screen = main->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_SEQ) { ARegion *ar; ARegion *ar_main; ListBase *regionbase; @@ -1497,15 +1493,17 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; } - if (sseq->view == 0) sseq->view = SEQ_VIEW_SEQUENCE; - if (sseq->mainb == 0) sseq->mainb = SEQ_DRAW_IMG_IMBUF; + if (sseq->view == 0) + sseq->view = SEQ_VIEW_SEQUENCE; + if (sseq->mainb == 0) + sseq->mainb = SEQ_DRAW_IMG_IMBUF; ar_main = (ARegion*)regionbase->first; for (; ar_main; ar_main = ar_main->next) { if (ar_main->regiontype == RGN_TYPE_WINDOW) break; } - ar= MEM_callocN(sizeof(ARegion), "preview area for sequencer"); + ar = MEM_callocN(sizeof(ARegion), "preview area for sequencer"); BLI_insertlinkbefore(regionbase, ar_main, ar); sequencer_init_preview_region(ar); } @@ -1520,61 +1518,61 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Object *ob; Brush *brush; Material *ma; - + /* game engine changes */ for (sce = main->scene.first; sce; sce = sce->id.next) { sce->gm.eyeseparation = 0.10f; } - + /* anim viz changes */ - for (ob= main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { /* initialize object defaults */ animviz_settings_init(&ob->avs); - - /* if armature, copy settings for pose from armature data + + /* if armature, copy settings for pose from armature data * performing initialization where appropriate */ if (ob->pose && ob->data) { - bArmature *arm= blo_do_versions_newlibadr(fd, lib, ob->data); + bArmature *arm = blo_do_versions_newlibadr(fd, lib, ob->data); if (arm) { /* XXX - why does this fail in some cases? */ - bAnimVizSettings *avs= &ob->pose->avs; - + bAnimVizSettings *avs = &ob->pose->avs; + /* ghosting settings ---------------- */ /* ranges */ - avs->ghost_bc= avs->ghost_ac= arm->ghostep; - - avs->ghost_sf= arm->ghostsf; - avs->ghost_ef= arm->ghostef; + avs->ghost_bc = avs->ghost_ac = arm->ghostep; + + avs->ghost_sf = arm->ghostsf; + avs->ghost_ef = arm->ghostef; if ((avs->ghost_sf == avs->ghost_ef) && (avs->ghost_sf == 0)) { - avs->ghost_sf= 1; - avs->ghost_ef= 100; + avs->ghost_sf = 1; + avs->ghost_ef = 100; } - + /* type */ if (arm->ghostep == 0) - avs->ghost_type= GHOST_TYPE_NONE; + avs->ghost_type = GHOST_TYPE_NONE; else - avs->ghost_type= arm->ghosttype + 1; - + avs->ghost_type = arm->ghosttype + 1; + /* stepsize */ - avs->ghost_step= arm->ghostsize; + avs->ghost_step = arm->ghostsize; if (avs->ghost_step == 0) - avs->ghost_step= 1; - + avs->ghost_step = 1; + /* path settings --------------------- */ /* ranges */ - avs->path_bc= arm->pathbc; - avs->path_ac= arm->pathac; + avs->path_bc = arm->pathbc; + avs->path_ac = arm->pathac; if ((avs->path_bc == avs->path_ac) && (avs->path_bc == 0)) - avs->path_bc= avs->path_ac= 10; - - avs->path_sf= arm->pathsf; - avs->path_ef= arm->pathef; + avs->path_bc = avs->path_ac = 10; + + avs->path_sf = arm->pathsf; + avs->path_ef = arm->pathef; if ((avs->path_sf == avs->path_ef) && (avs->path_sf == 0)) { - avs->path_sf= 1; - avs->path_ef= 250; + avs->path_sf = 1; + avs->path_ef = 250; } - + /* flags */ if (arm->pathflag & ARM_PATH_FNUMS) avs->path_viewflag |= MOTIONPATH_VIEW_FNUMS; @@ -1582,84 +1580,84 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) avs->path_viewflag |= MOTIONPATH_VIEW_KFRAS; if (arm->pathflag & ARM_PATH_KFNOS) avs->path_viewflag |= MOTIONPATH_VIEW_KFNOS; - + /* bake flags */ if (arm->pathflag & ARM_PATH_HEADS) avs->path_bakeflag |= MOTIONPATH_BAKE_HEADS; - + /* type */ if (arm->pathflag & ARM_PATH_ACFRA) avs->path_type = MOTIONPATH_TYPE_ACFRA; - + /* stepsize */ - avs->path_step= arm->pathsize; + avs->path_step = arm->pathsize; if (avs->path_step == 0) - avs->path_step= 1; + avs->path_step = 1; } else animviz_settings_init(&ob->pose->avs); } } - + /* brush texture changes */ - for (brush= main->brush.first; brush; brush= brush->id.next) { + for (brush = main->brush.first; brush; brush = brush->id.next) { default_mtex(&brush->mtex); } - for (ma= main->mat.first; ma; ma= ma->id.next) { + for (ma = main->mat.first; ma; ma = ma->id.next) { if (ma->vol.ms_spread < 0.0001f) { ma->vol.ms_spread = 0.2f; ma->vol.ms_diff = 1.f; - ma->vol.ms_intensity = 1.f; + ma->vol.ms_intensity = 1.f; } } } - + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 13)) { /* NOTE: if you do more conversion, be sure to do it outside of this and * increase subversion again, otherwise it will not be correct */ Object *ob; - + /* convert degrees to radians for internal use */ - for (ob=main->object.first; ob; ob=ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { bPoseChannel *pchan; do_version_constraints_radians_degrees_250(&ob->constraints); if (ob->pose) { - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { - pchan->limitmin[0] *= (float)(M_PI/180.0); - pchan->limitmin[1] *= (float)(M_PI/180.0); - pchan->limitmin[2] *= (float)(M_PI/180.0); - pchan->limitmax[0] *= (float)(M_PI/180.0); - pchan->limitmax[1] *= (float)(M_PI/180.0); - pchan->limitmax[2] *= (float)(M_PI/180.0); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + pchan->limitmin[0] *= (float)(M_PI / 180.0); + pchan->limitmin[1] *= (float)(M_PI / 180.0); + pchan->limitmin[2] *= (float)(M_PI / 180.0); + pchan->limitmax[0] *= (float)(M_PI / 180.0); + pchan->limitmax[1] *= (float)(M_PI / 180.0); + pchan->limitmax[2] *= (float)(M_PI / 180.0); do_version_constraints_radians_degrees_250(&pchan->constraints); } } } } - + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 14)) { /* fix for bad View2D extents for Animation Editors */ bScreen *screen; ScrArea *sa; SpaceLink *sl; - - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { + + for (screen = main->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { ListBase *regionbase; ARegion *ar; - + if (sl == sa->spacedata.first) regionbase = &sa->regionbase; else regionbase = &sl->regionbase; - + if (ELEM(sl->spacetype, SPACE_ACTION, SPACE_NLA)) { - for (ar = (ARegion*)regionbase->first; ar; ar = ar->next) { + for (ar = (ARegion*) regionbase->first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { ar->v2d.cur.ymax = ar->v2d.tot.ymax = 0.0f; ar->v2d.cur.ymin = ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; @@ -1670,38 +1668,38 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 15)) { World *wo; Material *ma; /* ambient default from 0.5f to 1.0f */ - for (ma= main->mat.first; ma; ma=ma->id.next) + for (ma = main->mat.first; ma; ma = ma->id.next) ma->amb *= 2.0f; - for (wo= main->world.first; wo; wo=wo->id.next) { + for (wo = main->world.first; wo; wo = wo->id.next) { /* ao splitting into ao/env/indirect */ - wo->ao_env_energy= wo->aoenergy; - wo->aoenergy= 1.0f; + wo->ao_env_energy = wo->aoenergy; + wo->aoenergy = 1.0f; if (wo->ao_indirect_bounces == 0) - wo->ao_indirect_bounces= 1; + wo->ao_indirect_bounces = 1; else wo->mode |= WO_INDIRECT_LIGHT; if (wo->aomix == WO_AOSUB) - wo->ao_env_energy= -wo->ao_env_energy; + wo->ao_env_energy = -wo->ao_env_energy; else if (wo->aomix == WO_AOADDSUB) wo->mode |= WO_AMB_OCC; - wo->aomix= WO_AOMUL; + wo->aomix = WO_AOMUL; /* ambient default from 0.5f to 1.0f */ mul_v3_fl(&wo->ambr, 0.5f); wo->ao_env_energy *= 0.5f; } } - + if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17)) { Scene *sce; Sequence *seq; @@ -1710,7 +1708,8 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* initialize to sane default so toggling on border shows something */ for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->r.border.xmin == 0.0f && sce->r.border.ymin == 0.0f && - sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f) { + sce->r.border.xmax == 0.0f && sce->r.border.ymax == 0.0f) + { sce->r.border.xmin = 0.0f; sce->r.border.ymin = 0.0f; sce->r.border.xmax = 1.0f; @@ -1728,15 +1727,15 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* particle brush strength factor was changed from int to float */ - for (sce= main->scene.first; sce; sce=sce->id.next) { - ParticleEditSettings *pset= &sce->toolsettings->particle; + for (sce = main->scene.first; sce; sce = sce->id.next) { + ParticleEditSettings *pset = &sce->toolsettings->particle; int a; - for (a=0; abrush[a].strength /= 100.0f; } - for (ma = main->mat.first; ma; ma=ma->id.next) + for (ma = main->mat.first; ma; ma = ma->id.next) if (ma->mode & MA_TRACEBLE) ma->shade_flag |= MA_APPROX_OCCLUSION; @@ -1746,10 +1745,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) ScrArea *sa; SpaceLink *sl; - for (screen= main->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { + for (screen = main->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_SEQ) { ARegion *ar_preview; ListBase *regionbase; @@ -1760,7 +1759,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; } - ar_preview = (ARegion*)regionbase->first; + ar_preview = (ARegion*) regionbase->first; for (; ar_preview; ar_preview = ar_preview->next) { if (ar_preview->regiontype == RGN_TYPE_PREVIEW) break; @@ -1774,20 +1773,20 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } /* sequencer changes */ } - + if (main->versionfile <= 251) { /* 2.5.1 had no subversions */ bScreen *sc; - + /* Blender 2.5.2 - subversion 0 introduced a new setting: V3D_RENDER_OVERRIDE. - * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated. + * This bit was used in the past for V3D_TRANSFORM_SNAP, which is now deprecated. * Here we clear it for old files so they don't come in with V3D_RENDER_OVERRIDE set, * which would cause cameras, lamps, etc to become invisible */ - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { View3D* v3d = (View3D *)sl; v3d->flag2 &= ~V3D_RENDER_OVERRIDE; } @@ -1801,81 +1800,84 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Object *ob; Scene *scene; bNodeTree *ntree; - - for (brush= main->brush.first; brush; brush= brush->id.next) { - if (brush->curve) brush->curve->preset = CURVE_PRESET_SMOOTH; + + for (brush = main->brush.first; brush; brush = brush->id.next) { + if (brush->curve) + brush->curve->preset = CURVE_PRESET_SMOOTH; } - + /* properly initialize active flag for fluidsim modifiers */ for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Fluidsim) { - FluidsimModifierData *fmd = (FluidsimModifierData *)md; - fmd->fss->flag |= OB_FLUIDSIM_ACTIVE; + FluidsimModifierData *fmd = (FluidsimModifierData *) md; + fmd->fss->flag |= OB_FLUIDSIM_ACTIVE; fmd->fss->flag |= OB_FLUIDSIM_OVERRIDE_TIME; } } } - + /* adjustment to color balance node values */ - for (scene= main->scene.first; scene; scene= scene->id.next) { + for (scene = main->scene.first; scene; scene = scene->id.next) { if (scene->nodetree) { - bNode *node=scene->nodetree->nodes.first; - + bNode *node = scene->nodetree->nodes.first; + while (node) { if (node->type == CMP_NODE_COLORBALANCE) { - NodeColorBalance *n= (NodeColorBalance *)node->storage; + NodeColorBalance *n = (NodeColorBalance *) node->storage; n->lift[0] += 1.f; n->lift[1] += 1.f; n->lift[2] += 1.f; } - node= node->next; + node = node->next; } } } /* check inside node groups too */ - for (ntree= main->nodetree.first; ntree; ntree=ntree->id.next) { - bNode *node=ntree->nodes.first; - + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { + bNode *node = ntree->nodes.first; + while (node) { if (node->type == CMP_NODE_COLORBALANCE) { - NodeColorBalance *n= (NodeColorBalance *)node->storage; + NodeColorBalance *n = (NodeColorBalance *) node->storage; n->lift[0] += 1.f; n->lift[1] += 1.f; n->lift[2] += 1.f; } - node= node->next; + + node = node->next; } } } - + /* old-track -> constraints (this time we're really doing it!) */ if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 2)) { Object *ob; - + for (ob = main->object.first; ob; ob = ob->id.next) blo_do_version_old_trackto_to_constraints(ob); } - + if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { bScreen *sc; - + /* Image editor scopes */ - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima = (SpaceImage *)sl; + + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *) sl; scopes_new(&sima->scopes); } } } } } - if (main->versionfile < 253) { Object *ob; @@ -1884,13 +1886,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Tex *tex; Brush *brush; - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { + + for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_NODE) { - SpaceNode *snode= (SpaceNode *)sl; + SpaceNode *snode = (SpaceNode *) sl; ListBase *regionbase; ARegion *ar; @@ -1900,22 +1903,22 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) regionbase = &sl->regionbase; if (snode->v2d.minzoom > 0.09f) - snode->v2d.minzoom= 0.09f; + snode->v2d.minzoom = 0.09f; if (snode->v2d.maxzoom < 2.31f) - snode->v2d.maxzoom= 2.31f; + snode->v2d.maxzoom = 2.31f; - for (ar= regionbase->first; ar; ar= ar->next) { + for (ar = regionbase->first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { if (ar->v2d.minzoom > 0.09f) - ar->v2d.minzoom= 0.09f; + ar->v2d.minzoom = 0.09f; if (ar->v2d.maxzoom < 2.31f) - ar->v2d.maxzoom= 2.31f; + ar->v2d.maxzoom = 2.31f; } } } else if (sl->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)sl; - + SpaceTime *stime = (SpaceTime *) sl; + /* enable all cache display */ stime->cache_display |= TIME_CACHE_DISPLAY; stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); @@ -1930,19 +1933,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* parent type to modifier */ for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->parent) { - Object *parent= (Object *)blo_do_versions_newlibadr(fd, lib, ob->parent); + Object *parent = (Object *) blo_do_versions_newlibadr(fd, lib, ob->parent); if (parent) { /* parent may not be in group */ - if (parent->type==OB_ARMATURE && ob->partype==PARSKEL) { + if (parent->type == OB_ARMATURE && ob->partype == PARSKEL) { ArmatureModifierData *amd; - bArmature *arm= (bArmature *)blo_do_versions_newlibadr(fd, lib, parent->data); + bArmature *arm = (bArmature *) blo_do_versions_newlibadr(fd, lib, parent->data); amd = (ArmatureModifierData*) modifier_new(eModifierType_Armature); amd->object = ob->parent; BLI_addtail((ListBase*)&ob->modifiers, amd); - amd->deformflag= arm->deformflag; + amd->deformflag = arm->deformflag; ob->partype = PAROBJECT; } - else if (parent->type==OB_LATTICE && ob->partype==PARSKEL) { + else if (parent->type == OB_LATTICE && ob->partype == PARSKEL) { LatticeModifierData *lmd; lmd = (LatticeModifierData*) modifier_new(eModifierType_Lattice); @@ -1950,7 +1953,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) BLI_addtail((ListBase*)&ob->modifiers, lmd); ob->partype = PAROBJECT; } - else if (parent->type==OB_CURVE && ob->partype==PARCURVE) { + else if (parent->type == OB_CURVE && ob->partype == PARCURVE) { CurveModifierData *cmd; cmd = (CurveModifierData*) modifier_new(eModifierType_Curve); @@ -1961,39 +1964,39 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - + /* initialize scene active layer */ - for (scene= main->scene.first; scene; scene=scene->id.next) { + for (scene = main->scene.first; scene; scene = scene->id.next) { int i; - for (i=0; i<20; i++) { + for (i = 0; i < 20; i++) { if (scene->lay & (1<layact= 1<layact = 1<tex.first; tex; tex= tex->id.next) { + for (tex = main->tex.first; tex; tex = tex->id.next) { /* if youre picky, this isn't correct until we do a version bump * since you could set saturation to be 0.0*/ - if (tex->saturation==0.0f) - tex->saturation= 1.0f; + if (tex->saturation == 0.0f) + tex->saturation = 1.0f; } { Curve *cu; - for (cu= main->curve.first; cu; cu= cu->id.next) { - cu->smallcaps_scale= 0.75f; + for (cu = main->curve.first; cu; cu = cu->id.next) { + cu->smallcaps_scale = 0.75f; } } - for (scene= main->scene.first; scene; scene=scene->id.next) { + for (scene = main->scene.first; scene; scene = scene->id.next) { if (scene) { Sequence *seq; SEQ_BEGIN (scene->ed, seq) { - if (seq->sat==0.0f) { - seq->sat= 1.0f; + if (seq->sat == 0.0f) { + seq->sat = 1.0f; } } SEQ_END @@ -2002,46 +2005,46 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* GSOC 2010 Sculpt - New settings for Brush */ - for (brush= main->brush.first; brush; brush= brush->id.next) { + for (brush = main->brush.first; brush; brush = brush->id.next) { /* Sanity Check */ - // infinite number of dabs + /* infinite number of dabs */ if (brush->spacing == 0) brush->spacing = 10; - // will have no effect + /* will have no effect */ if (brush->alpha == 0) brush->alpha = 0.5f; - // bad radius + /* bad radius */ if (brush->unprojected_radius == 0) brush->unprojected_radius = 0.125f; - // unusable size + /* unusable size */ if (brush->size == 0) brush->size = 35; - // can't see overlay + /* can't see overlay */ if (brush->texture_overlay_alpha == 0) brush->texture_overlay_alpha = 33; - // same as draw brush + /* same as draw brush */ if (brush->crease_pinch_factor == 0) brush->crease_pinch_factor = 0.5f; - // will sculpt no vertexes + /* will sculpt no vertexes */ if (brush->plane_trim == 0) brush->plane_trim = 0.5f; - // same as smooth stroke off + /* same as smooth stroke off */ if (brush->smooth_stroke_radius == 0) - brush->smooth_stroke_radius= 75; + brush->smooth_stroke_radius = 75; - // will keep cursor in one spot + /* will keep cursor in one spot */ if (brush->smooth_stroke_radius == 1) - brush->smooth_stroke_factor= 0.9f; + brush->smooth_stroke_factor = 0.9f; - // same as dots + /* same as dots */ if (brush->rate == 0) brush->rate = 0.1f; @@ -2049,9 +2052,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 252 || (main->versionfile == 252 && main->subversionfile < 5)) { brush->flag |= BRUSH_SPACE_ATTEN; // explicitly enable adaptive space - // spacing was originally in pixels, convert it to percentage for new version - // size should not be zero due to sanity check above - brush->spacing = (int)(100*((float)brush->spacing) / ((float)brush->size)); + /* spacing was originally in pixels, convert it to percentage for new version + * size should not be zero due to sanity check above + */ + brush->spacing = (int)(100 * ((float)brush->spacing) / ((float) brush->size)); if (brush->add_col[0] == 0 && brush->add_col[1] == 0 && @@ -2059,7 +2063,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { brush->add_col[0] = 1.00f; brush->add_col[1] = 0.39f; - brush->add_col[2] = 0.39f; + brush->add_col[2] = 0.39f; } if (brush->sub_col[0] == 0 && @@ -2077,11 +2081,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* GSOC Sculpt 2010 - Sanity check on Sculpt/Paint settings */ if (main->versionfile < 253) { Scene *sce; - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->toolsettings->sculpt_paint_unified_alpha == 0) sce->toolsettings->sculpt_paint_unified_alpha = 0.5f; - if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) + if (sce->toolsettings->sculpt_paint_unified_unprojected_radius == 0) sce->toolsettings->sculpt_paint_unified_unprojected_radius = 0.125f; if (sce->toolsettings->sculpt_paint_unified_size == 0) @@ -2090,50 +2094,50 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } if (main->versionfile < 253 || (main->versionfile == 253 && main->subversionfile < 1)) { - Object *ob; + Object *ob; - for (ob = main->object.first; ob; ob = ob->id.next) { - ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { - if (md->type == eModifierType_Smoke) { - SmokeModifierData *smd = (SmokeModifierData *)md; + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; - if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { - smd->domain->vorticity = 2.0f; - smd->domain->time_scale = 1.0f; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Smoke) { + SmokeModifierData *smd = (SmokeModifierData *)md; - if (!(smd->domain->flags & (1<<4))) - continue; + if ((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) { + smd->domain->vorticity = 2.0f; + smd->domain->time_scale = 1.0f; - /* delete old MOD_SMOKE_INITVELOCITY flag */ - smd->domain->flags &= ~(1<<4); + if (!(smd->domain->flags & (1<<4))) + continue; - /* for now just add it to all flow objects in the scene */ - { - Object *ob2; - for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) { - ModifierData *md2; - for (md2= ob2->modifiers.first; md2; md2= md2->next) { - if (md2->type == eModifierType_Smoke) { - SmokeModifierData *smd2 = (SmokeModifierData *)md2; + /* delete old MOD_SMOKE_INITVELOCITY flag */ + smd->domain->flags &= ~(1<<4); - if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { - smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY; - } + /* for now just add it to all flow objects in the scene */ + { + Object *ob2; + for (ob2 = main->object.first; ob2; ob2 = ob2->id.next) { + ModifierData *md2; + for (md2 = ob2->modifiers.first; md2; md2 = md2->next) { + if (md2->type == eModifierType_Smoke) { + SmokeModifierData *smd2 = (SmokeModifierData *)md2; + + if ((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { + smd2->flow->flags |= MOD_SMOKE_FLOW_INITVELOCITY; } } } } - - } - else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) { - smd->flow->vel_multi = 1.0f; } } + else if ((smd->type & MOD_SMOKE_TYPE_FLOW) && smd->flow) { + smd->flow->vel_multi = 1.0f; + } } } } + } if (main->versionfile < 255 || (main->versionfile == 255 && main->subversionfile < 1)) { Brush *br; @@ -2141,9 +2145,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bScreen *sc; Object *ob; - for (br= main->brush.first; br; br= br->id.next) { - if (br->ob_mode==0) - br->ob_mode= OB_MODE_ALL_PAINT; + for (br = main->brush.first; br; br = br->id.next) { + if (br->ob_mode == 0) + br->ob_mode = OB_MODE_ALL_PAINT; } for (part = main->particle.first; part; part = part->id.next) { @@ -2154,25 +2158,25 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) part->kink_amp_clump = 1.f; /* keep old files looking similar */ } - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { if (sl->spacetype == SPACE_INFO) { - SpaceInfo *sinfo= (SpaceInfo *)sl; + SpaceInfo *sinfo = (SpaceInfo *) sl; ARegion *ar; - sinfo->rpt_mask= INFO_RPT_OP; + sinfo->rpt_mask = INFO_RPT_OP; - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { ar->v2d.scroll = (V2D_SCROLL_RIGHT); ar->v2d.align = V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_NEG_Y; /* align bottom left */ ar->v2d.keepofs = V2D_LOCKOFS_X; ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_BOUNDS; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; } } } @@ -2182,30 +2186,30 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* fix rotation actuators for objects so they use real angles (radians) * since before blender went opensource this strange scalar was used: (1 / 0.02) * 2 * math.pi/360 */ - for (ob= main->object.first; ob; ob= ob->id.next) { - bActuator *act= ob->actuators.first; + for (ob = main->object.first; ob; ob = ob->id.next) { + bActuator *act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { + if (act->type == ACT_OBJECT) { /* multiply velocity with 50 in old files */ - bObjectActuator *oa= act->data; + bObjectActuator *oa = act->data; mul_v3_fl(oa->drot, 0.8726646259971648f); } - act= act->next; + act = act->next; } } } - - // init facing axis property of steering actuators - { + + /* init facing axis property of steering actuators */ + { Object *ob; for (ob = main->object.first; ob; ob = ob->id.next) { bActuator *act; - for (act= ob->actuators.first; act; act= act->next) { - if (act->type==ACT_STEERING) { + for (act = ob->actuators.first; act; act = act->next) { + if (act->type == ACT_STEERING) { bSteeringActuator* stact = act->data; - if (stact->facingaxis==0) { - stact->facingaxis=1; - } + if (stact->facingaxis == 0) { + stact->facingaxis = 1; + } } } } @@ -2217,55 +2221,55 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* ocean res is now squared, reset old ones - will be massive */ for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Ocean) { OceanModifierData *omd = (OceanModifierData *)md; omd->resolution = 7; omd->oceancache = NULL; } } - } + } } if (main->versionfile < 256) { bScreen *sc; ScrArea *sa; Key *key; - + /* Fix for sample line scope initializing with no height */ - for (sc= main->screen.first; sc; sc= sc->id.next) { - sa= sc->areabase.first; + for (sc = main->screen.first; sc; sc = sc->id.next) { + sa = sc->areabase.first; while (sa) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) { - SpaceImage *sima= (SpaceImage *)sl; - if (sima->sample_line_hist.height == 0 ) + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IMAGE) { + SpaceImage *sima = (SpaceImage *) sl; + if (sima->sample_line_hist.height == 0) sima->sample_line_hist.height = 100; } } - sa= sa->next; + sa = sa->next; } } - + /* old files could have been saved with slidermin = slidermax = 0.0, but the UI in * 2.4x would never reveal this to users as a dummy value always ended up getting used * instead */ for (key = main->key.first; key; key = key->id.next) { KeyBlock *kb; - + for (kb = key->block.first; kb; kb = kb->next) { if (IS_EQF(kb->slidermin, kb->slidermax) && IS_EQ(kb->slidermax, 0)) kb->slidermax = kb->slidermin + 1.0f; } } } - + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 1)) { /* fix for bones that didn't have arm_roll before */ - bArmature* arm; - Bone* bone; + bArmature *arm; + Bone *bone; Object *ob; for (arm = main->armature.first; arm; arm = arm->id.next) @@ -2274,7 +2278,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* fix for objects which have zero dquat's * since this is multiplied with the quat rather than added */ - for (ob= main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (is_zero_v4(ob->dquat)) { unit_qt(ob->dquat); } @@ -2286,11 +2290,11 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { bNodeTree *ntree; - + /* node sockets are not exposed automatically any more, * this mimics the old behavior by adding all unlinked sockets to groups. */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { /* XXX Only setting a flag here. Actual adding of group sockets * is done in lib_verify_nodetree, because at this point the internal * nodes may not be up-to-date! (missing lib-link) @@ -2299,22 +2303,23 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile <3)) { + if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 3)) { bScreen *sc; Brush *brush; Object *ob; ParticleSettings *part; Material *mat; int tex_nr, transp_tex; - + for (mat = main->mat.first; mat; mat = mat->id.next) { if (!(mat->mode & MA_TRANSP) && !(mat->material_type & MA_TYPE_VOLUME)) { - - transp_tex= 0; - - for (tex_nr=0; tex_nrmtex[tex_nr]) continue; - if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) transp_tex= 1; + transp_tex = 0; + + for (tex_nr = 0; tex_nr < MAX_MTEX; tex_nr++) { + if (!mat->mtex[tex_nr]) + continue; + if (mat->mtex[tex_nr]->mapto & MAP_ALPHA) + transp_tex = 1; } /* weak! material alpha could be animated */ @@ -2326,7 +2331,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } /* redraws flag in SpaceTime has been moved to Screen level */ - for (sc = main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { if (sc->redraws_flag == 0) { /* just initialize to default? */ // XXX: we could also have iterated through areas, and taken them from the first timeline available... @@ -2334,19 +2339,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } - for (brush= main->brush.first; brush; brush= brush->id.next) { + for (brush = main->brush.first; brush; brush = brush->id.next) { if (brush->height == 0) - brush->height= 0.4f; + brush->height = 0.4f; } /* replace 'rim material' option for in offset*/ for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; - for (md= ob->modifiers.first; md; md= md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Solidify) { - SolidifyModifierData *smd = (SolidifyModifierData *)md; + SolidifyModifierData *smd = (SolidifyModifierData *) md; if (smd->flag & MOD_SOLIDIFY_RIM_MATERIAL) { - smd->mat_ofs_rim= 1; + smd->mat_ofs_rim = 1; smd->flag &= ~MOD_SOLIDIFY_RIM_MATERIAL; } } @@ -2363,19 +2368,19 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 6)) { Mesh *me; - for (me= main->mesh.first; me; me= me->id.next) - mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); + for (me = main->mesh.first; me; me = me->id.next) + BKE_mesh_calc_normals_tessface(me->mvert, me->totvert, me->mface, me->totface, NULL); } if (main->versionfile < 256 || (main->versionfile == 256 && main->subversionfile < 2)) { /* update blur area sizes from 0..1 range to 0..100 percentage */ Scene *scene; bNode *node; - for (scene=main->scene.first; scene; scene=scene->id.next) + for (scene = main->scene.first; scene; scene = scene->id.next) if (scene->nodetree) - for (node=scene->nodetree->nodes.first; node; node=node->next) - if (node->type==CMP_NODE_BLUR) { - NodeBlurData *nbd= node->storage; + for (node = scene->nodetree->nodes.first; node; node = node->next) + if (node->type == CMP_NODE_BLUR) { + NodeBlurData *nbd = node->storage; nbd->percentx *= 100.0f; nbd->percenty *= 100.0f; } @@ -2386,27 +2391,29 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) * v2d->scroll caused the bug but best reset other values too which are in old blend files only. * need to make less ugly - possibly an iterator? */ bScreen *screen; - for (screen= main->screen.first; screen; screen= screen->id.next) { + + for (screen = main->screen.first; screen; screen = screen->id.next) { ScrArea *sa; /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - SpaceLink *sl= sa->spacedata.first; - if (sl->spacetype==SPACE_IMAGE) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + SpaceLink *sl = sa->spacedata.first; + if (sl->spacetype == SPACE_IMAGE) { ARegion *ar; - for (ar=sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - View2D *v2d= &ar->v2d; - v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; + View2D *v2d = &ar->v2d; + v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom = v2d->keepofs = v2d->align = 0; } } } - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) { + + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IMAGE) { ARegion *ar; - for (ar=sl->regionbase.first; ar; ar= ar->next) { + for (ar = sl->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - View2D *v2d= &ar->v2d; - v2d->minzoom= v2d->maxzoom= v2d->scroll= v2d->keeptot= v2d->keepzoom= v2d->keepofs= v2d->align= 0; + View2D *v2d = &ar->v2d; + v2d->minzoom = v2d->maxzoom = v2d->scroll = v2d->keeptot = v2d->keepzoom = v2d->keepofs = v2d->align = 0; } } } @@ -2417,14 +2424,14 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) { /* Initialize texture point density curve falloff */ Tex *tex; - for (tex= main->tex.first; tex; tex= tex->id.next) { + for (tex = main->tex.first; tex; tex = tex->id.next) { if (tex->pd) { if (tex->pd->falloff_speed_scale == 0.0f) tex->pd->falloff_speed_scale = 100.0f; - + if (!tex->pd->falloff_curve) { tex->pd->falloff_curve = curvemapping_add(1, 0, 0, 1, 1); - + tex->pd->falloff_curve->preset = CURVE_PRESET_LINE; tex->pd->falloff_curve->cm->flag &= ~CUMA_EXTEND_EXTRAPOLATE; curvemap_reset(tex->pd->falloff_curve->cm, &tex->pd->falloff_curve->clipr, tex->pd->falloff_curve->preset, CURVEMAP_SLOPE_POSITIVE); @@ -2438,10 +2445,10 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) /* add default value for behind strength of camera actuator */ Object *ob; bActuator *act; - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + for (ob = main->object.first; ob; ob = ob->id.next) { + for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_CAMERA) { - bCameraActuator *ba= act->data; + bCameraActuator *ba = act->data; ba->damping = 1.0/32.0; } @@ -2463,7 +2470,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Scene *scene; Sequence *seq; - for (scene=main->scene.first; scene; scene=scene->id.next) { + for (scene = main->scene.first; scene; scene = scene->id.next) { scene->r.ffcodecdata.audio_channels = 2; scene->audio.volume = 1.0f; SEQ_BEGIN (scene->ed, seq) @@ -2473,29 +2480,31 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) SEQ_END } } + { bScreen *screen; - for (screen= main->screen.first; screen; screen= screen->id.next) { + for (screen = main->screen.first; screen; screen = screen->id.next) { ScrArea *sa; + /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { - SpaceLink *sl= sa->spacedata.first; - if (sl->spacetype==SPACE_SEQ) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + SpaceLink *sl = sa->spacedata.first; + if (sl->spacetype == SPACE_SEQ) { ARegion *ar; - for (ar=sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { if (ar->v2d.min[1] == 4.0f) - ar->v2d.min[1]= 0.5f; + ar->v2d.min[1] = 0.5f; } } } - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_SEQ) { + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_SEQ) { ARegion *ar; - for (ar=sl->regionbase.first; ar; ar= ar->next) { + for (ar = sl->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { if (ar->v2d.min[1] == 4.0f) - ar->v2d.min[1]= 0.5f; + ar->v2d.min[1] = 0.5f; } } } @@ -2503,8 +2512,9 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } + { - /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve + /* Make "auto-clamped" handles a per-keyframe setting instead of per-FCurve * * We're only patching F-Curves in Actions here, since it is assumed that most * drivers out there won't be using this (and if they are, they're in the minority). @@ -2513,28 +2523,31 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) */ bAction *act; FCurve *fcu; - + for (act = main->action.first; act; act = act->id.next) { for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; unsigned int i = 0; - + /* only need to touch curves that had this flag set */ if ((fcu->flag & FCURVE_AUTO_HANDLES) == 0) continue; if ((fcu->totvert == 0) || (fcu->bezt == NULL)) continue; - + /* only change auto-handles to auto-clamped */ - for (bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { - if (bezt->h1 == HD_AUTO) bezt->h1 = HD_AUTO_ANIM; - if (bezt->h2 == HD_AUTO) bezt->h2 = HD_AUTO_ANIM; + for (bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { + if (bezt->h1 == HD_AUTO) + bezt->h1 = HD_AUTO_ANIM; + if (bezt->h2 == HD_AUTO) + bezt->h2 = HD_AUTO_ANIM; } - + fcu->flag &= ~FCURVE_AUTO_HANDLES; } } } + { /* convert fcurve and shape action actuators to action actuators */ Object *ob; @@ -2542,12 +2555,12 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) bIpoActuator *ia; bActionActuator *aa; - for (ob= main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + for (ob = main->object.first; ob; ob = ob->id.next) { + for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_IPO) { // Create the new actuator - ia= act->data; - aa= MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); + ia = act->data; + aa = MEM_callocN(sizeof(bActionActuator), "fcurve -> action actuator do_version"); // Copy values aa->type = ia->type; @@ -2564,8 +2577,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) // Assign the new actuator act->data = aa; - act->type= act->otype= ACT_ACTION; - + act->type = act->otype = ACT_ACTION; } else if (act->type == ACT_SHAPEACTION) { act->type = act->otype = ACT_ACTION; @@ -2582,32 +2594,36 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) Material *mat; Tex *tex; bNodeTree *ntree; - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { blo_do_versions_nodetree_default_value(ntree); ntree->update |= NTREE_UPDATE; } - for (sce=main->scene.first; sce; sce=sce->id.next) + + for (sce = main->scene.first; sce; sce = sce->id.next) if (sce->nodetree) { - blo_do_versions_nodetree_default_value(sce->nodetree); - sce->nodetree->update |= NTREE_UPDATE; - } - for (mat=main->mat.first; mat; mat=mat->id.next) + blo_do_versions_nodetree_default_value(sce->nodetree); + sce->nodetree->update |= NTREE_UPDATE; + } + + for (mat = main->mat.first; mat; mat = mat->id.next) if (mat->nodetree) { - blo_do_versions_nodetree_default_value(mat->nodetree); - mat->nodetree->update |= NTREE_UPDATE; - } - for (tex=main->tex.first; tex; tex=tex->id.next) + blo_do_versions_nodetree_default_value(mat->nodetree); + mat->nodetree->update |= NTREE_UPDATE; + } + + for (tex = main->tex.first; tex; tex = tex->id.next) if (tex->nodetree) { - blo_do_versions_nodetree_default_value(tex->nodetree); - tex->nodetree->update |= NTREE_UPDATE; - } + blo_do_versions_nodetree_default_value(tex->nodetree); + tex->nodetree->update |= NTREE_UPDATE; + } } /* add SOCK_DYNAMIC flag to existing group sockets */ { bNodeTree *ntree; /* only need to do this for trees in main, local trees are not used as groups */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) { + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) { do_versions_nodetree_dynamic_sockets(ntree); ntree->update |= NTREE_UPDATE; } @@ -2620,7 +2636,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) */ bNodeTree *ntree; /* all node trees in main->nodetree are considered groups */ - for (ntree=main->nodetree.first; ntree; ntree=ntree->id.next) + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) ntree->nodetype = NODE_GROUP; } } @@ -2671,9 +2687,4 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main) } } } - - /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ - /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ - - /* don't forget to set version number in blender.c! */ } diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 7d8905d5902..2f7ff055b91 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -25,7 +25,7 @@ * */ -/** \file blender/blenloader/intern/readfile_pre250.c +/** \file blender/blenloader/intern/versioning_legacy.c * \ingroup blenloader */ @@ -33,13 +33,6 @@ #include "zlib.h" #include -//#include // for printf fopen fwrite fclose sprintf FILE -//#include // for getenv atoi -//#include // for offsetof -//#include // for open -//#include // for strrchr strncmp strstr -//#include // for fabs -//#include /* for va_start/end */ #ifndef WIN32 # include // for read close @@ -108,9 +101,6 @@ #include "NOD_socket.h" -//XXX #include "BIF_butspace.h" // badlevel, for do_versions, patching event codes -//XXX #include "BIF_filelist.h" // badlevel too, where to move this? - elubie -//XXX #include "BIF_previewrender.h" // bedlelvel, for struct RenderInfo #include "BLO_readfile.h" #include "BLO_undofile.h" @@ -128,39 +118,53 @@ static void vcol_to_fcol(Mesh *me) unsigned int *mcol, *mcoln, *mcolmain; int a; - if (me->totface==0 || me->mcol==NULL) return; + if (me->totface == 0 || me->mcol == NULL) + return; - mcoln= mcolmain= MEM_mallocN(4*sizeof(int)*me->totface, "mcoln"); + mcoln = mcolmain = MEM_mallocN(4*sizeof(int)*me->totface, "mcoln"); mcol = (unsigned int *)me->mcol; - mface= me->mface; - for (a=me->totface; a>0; a--, mface++) { - mcoln[0]= mcol[mface->v1]; - mcoln[1]= mcol[mface->v2]; - mcoln[2]= mcol[mface->v3]; - mcoln[3]= mcol[mface->v4]; - mcoln+= 4; + mface = me->mface; + for (a = me->totface; a > 0; a--, mface++) { + mcoln[0] = mcol[mface->v1]; + mcoln[1] = mcol[mface->v2]; + mcoln[2] = mcol[mface->v3]; + mcoln[3] = mcol[mface->v4]; + mcoln += 4; } MEM_freeN(me->mcol); - me->mcol= (MCol *)mcolmain; + me->mcol = (MCol *)mcolmain; } static int map_223_keybd_code_to_224_keybd_code(int code) { switch (code) { - case 312: return 311; /* F12KEY */ - case 159: return 161; /* PADSLASHKEY */ - case 161: return 150; /* PAD0 */ - case 154: return 151; /* PAD1 */ - case 150: return 152; /* PAD2 */ - case 155: return 153; /* PAD3 */ - case 151: return 154; /* PAD4 */ - case 156: return 155; /* PAD5 */ - case 152: return 156; /* PAD6 */ - case 157: return 157; /* PAD7 */ - case 153: return 158; /* PAD8 */ - case 158: return 159; /* PAD9 */ - default: return code; + case 312: + return 311; /* F12KEY */ + case 159: + return 161; /* PADSLASHKEY */ + case 161: + return 150; /* PAD0 */ + case 154: + return 151; /* PAD1 */ + case 150: + return 152; /* PAD2 */ + case 155: + return 153; /* PAD3 */ + case 151: + return 154; /* PAD4 */ + case 156: + return 155; /* PAD5 */ + case 152: + return 156; /* PAD6 */ + case 157: + return 157; /* PAD7 */ + case 153: + return 158; /* PAD8 */ + case 158: + return 159; /* PAD9 */ + default: + return code; } } @@ -177,21 +181,22 @@ static void do_version_bone_head_tail_237(Bone *bone) mul_v3_fl(vec, bone->length); add_v3_v3v3(bone->arm_tail, bone->arm_head, vec); - for (child= bone->childbase.first; child; child= child->next) + for (child = bone->childbase.first; child; child = child->next) do_version_bone_head_tail_237(child); } static void bone_version_238(ListBase *lb) { Bone *bone; - - for (bone= lb->first; bone; bone= bone->next) { - if (bone->rad_tail==0.0f && bone->rad_head==0.0f) { - bone->rad_head= 0.25f*bone->length; - bone->rad_tail= 0.1f*bone->length; - + + for (bone = lb->first; bone; bone = bone->next) { + if (bone->rad_tail == 0.0f && bone->rad_head == 0.0f) { + bone->rad_head = 0.25f*bone->length; + bone->rad_tail = 0.1f*bone->length; + bone->dist-= bone->rad_head; - if (bone->dist<=0.0f) bone->dist= 0.0f; + if (bone->dist<=0.0f) + bone->dist = 0.0f; } bone_version_238(&bone->childbase); } @@ -200,10 +205,10 @@ static void bone_version_238(ListBase *lb) static void bone_version_239(ListBase *lb) { Bone *bone; - - for (bone= lb->first; bone; bone= bone->next) { - if (bone->layer==0) - bone->layer= 1; + + for (bone = lb->first; bone; bone = bone->next) { + if (bone->layer == 0) + bone->layer = 1; bone_version_239(&bone->childbase); } } @@ -211,25 +216,25 @@ static void bone_version_239(ListBase *lb) static void ntree_version_241(bNodeTree *ntree) { bNode *node; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_BLUR) { - if (node->storage==NULL) { - NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch"); - nbd->sizex= node->custom1; - nbd->sizey= node->custom2; - nbd->filtertype= R_FILTER_QUAD; - node->storage= nbd; + + if (ntree->type == NTREE_COMPOSIT) { + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_BLUR) { + if (node->storage == NULL) { + NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur patch"); + nbd->sizex = node->custom1; + nbd->sizey = node->custom2; + nbd->filtertype = R_FILTER_QUAD; + node->storage = nbd; } } - else if (node->type==CMP_NODE_VECBLUR) { - if (node->storage==NULL) { - NodeBlurData *nbd= MEM_callocN(sizeof(NodeBlurData), "node blur patch"); - nbd->samples= node->custom1; - nbd->maxspeed= node->custom2; - nbd->fac= 1.0f; - node->storage= nbd; + else if (node->type == CMP_NODE_VECBLUR) { + if (node->storage == NULL) { + NodeBlurData *nbd = MEM_callocN(sizeof(NodeBlurData), "node blur patch"); + nbd->samples = node->custom1; + nbd->maxspeed = node->custom2; + nbd->fac = 1.0f; + node->storage = nbd; } } } @@ -239,23 +244,24 @@ static void ntree_version_241(bNodeTree *ntree) static void ntree_version_242(bNodeTree *ntree) { bNode *node; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { - if (node->type==CMP_NODE_HUE_SAT) { + + if (ntree->type == NTREE_COMPOSIT) { + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_HUE_SAT) { if (node->storage) { - NodeHueSat *nhs= node->storage; - if (nhs->val==0.0f) nhs->val= 1.0f; + NodeHueSat *nhs = node->storage; + if (nhs->val == 0.0f) + nhs->val = 1.0f; } } } } - else if (ntree->type==NTREE_SHADER) { - for (node= ntree->nodes.first; node; node= node->next) + else if (ntree->type == NTREE_SHADER) { + for (node = ntree->nodes.first; node; node = node->next) if (node->type == SH_NODE_GEOMETRY && node->storage == NULL) - node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); + node->storage = MEM_callocN(sizeof(NodeGeometry), "NodeGeometry"); } - + } static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) @@ -266,22 +272,22 @@ static void ntree_version_245(FileData *fd, Library *lib, bNodeTree *ntree) Image *image; ImageUser *iuser; - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { + if (ntree->type == NTREE_COMPOSIT) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->type == CMP_NODE_ALPHAOVER) { if (!node->storage) { - ntf= MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); - node->storage= ntf; + ntf = MEM_callocN(sizeof(NodeTwoFloats), "NodeTwoFloats"); + node->storage = ntf; if (node->custom1) - ntf->x= 1.0f; + ntf->x = 1.0f; } } - + /* fix for temporary flag changes during 245 cycle */ - nodeid= blo_do_versions_newlibadr(fd, lib, node->id); + nodeid = blo_do_versions_newlibadr(fd, lib, node->id); if (node->storage && nodeid && GS(nodeid->name) == ID_IM) { - image= (Image*)nodeid; - iuser= node->storage; + image = (Image*)nodeid; + iuser = node->storage; if (iuser->flag & IMA_OLD_PREMUL) { iuser->flag &= ~IMA_OLD_PREMUL; iuser->flag |= IMA_DO_PREMUL; @@ -299,11 +305,12 @@ static void idproperties_fix_groups_lengths_recurse(IDProperty *prop) { IDProperty *loop; int i; - - for (loop=prop->data.group.first, i=0; loop; loop=loop->next, i++) { - if (loop->type == IDP_GROUP) idproperties_fix_groups_lengths_recurse(loop); + + for (loop = prop->data.group.first, i = 0; loop; loop = loop->next, i++) { + if (loop->type == IDP_GROUP) + idproperties_fix_groups_lengths_recurse(loop); } - + if (prop->len != i) { printf("Found and fixed bad id property group length.\n"); prop->len = i; @@ -313,8 +320,8 @@ static void idproperties_fix_groups_lengths_recurse(IDProperty *prop) static void idproperties_fix_group_lengths(ListBase idlist) { ID *id; - - for (id=idlist.first; id; id=id->next) { + + for (id = idlist.first; id; id = id->next) { if (id->properties) { idproperties_fix_groups_lengths_recurse(id->properties); } @@ -329,35 +336,35 @@ static void alphasort_version_246(FileData *fd, Library *lib, Mesh *me) int a, b, texalpha; /* verify we have a tface layer */ - for (b=0; bfdata.totlayer; b++) + for (b = 0; b < me->fdata.totlayer; b++) if (me->fdata.layers[b].type == CD_MTFACE) break; - + if (b == me->fdata.totlayer) return; /* if we do, set alpha sort if the game engine did it before */ - for (a=0, mf=me->mface; atotface; a++, mf++) { + for (a = 0, mf = me->mface; a < me->totface; a++, mf++) { if (mf->mat_nr < me->totcol) { - ma= blo_do_versions_newlibadr(fd, lib, me->mat[mf->mat_nr]); + ma = blo_do_versions_newlibadr(fd, lib, me->mat[mf->mat_nr]); texalpha = 0; /* we can't read from this if it comes from a library, * because direct_link might not have happened on it, * so ma->mtex is not pointing to valid memory yet */ if (ma && ma->id.lib) - ma= NULL; + ma = NULL; - for (b=0; ma && bmtex && ma->mtex[b] && ma->mtex[b]->mapto & MAP_ALPHA) texalpha = 1; } else { - ma= NULL; + ma = NULL; texalpha = 0; } - for (b=0; bfdata.totlayer; b++) { + for (b = 0; b < me->fdata.totlayer; b++) { if (me->fdata.layers[b].type == CD_MTFACE) { tf = ((MTFace*)me->fdata.layers[b].data) + a; @@ -389,7 +396,7 @@ static void customdata_version_242(Mesh *me) if (!me->edata.totlayer) CustomData_add_layer(&me->edata, CD_MEDGE, CD_ASSIGN, me->medge, me->totedge); - + if (!me->fdata.totlayer) { CustomData_add_layer(&me->fdata, CD_MFACE, CD_ASSIGN, me->mface, me->totface); @@ -397,40 +404,40 @@ static void customdata_version_242(Mesh *me) if (me->mcol) MEM_freeN(me->mcol); - me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface); - me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface); + me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_CALLOC, NULL, me->totface); + me->mtface = CustomData_add_layer(&me->fdata, CD_MTFACE, CD_CALLOC, NULL, me->totface); - mtf= me->mtface; - mcol= me->mcol; - tf= me->tface; + mtf = me->mtface; + mcol = me->mcol; + tf = me->tface; - for (a=0; a < me->totface; a++, mtf++, tf++, mcol+=4) { + for (a = 0; a < me->totface; a++, mtf++, tf++, mcol += 4) { memcpy(mcol, tf->col, sizeof(tf->col)); memcpy(mtf->uv, tf->uv, sizeof(tf->uv)); - mtf->flag= tf->flag; - mtf->unwrap= tf->unwrap; - mtf->mode= tf->mode; - mtf->tile= tf->tile; - mtf->tpage= tf->tpage; - mtf->transp= tf->transp; + mtf->flag = tf->flag; + mtf->unwrap = tf->unwrap; + mtf->mode = tf->mode; + mtf->tile = tf->tile; + mtf->tpage = tf->tpage; + mtf->transp = tf->transp; } MEM_freeN(me->tface); - me->tface= NULL; + me->tface = NULL; } else if (me->mcol) { - me->mcol= CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface); + me->mcol = CustomData_add_layer(&me->fdata, CD_MCOL, CD_ASSIGN, me->mcol, me->totface); } } if (me->tface) { MEM_freeN(me->tface); - me->tface= NULL; + me->tface = NULL; } - for (a=0, mtfacen=0, mcoln=0; a < me->fdata.totlayer; a++) { - layer= &me->fdata.layers[a]; + for (a = 0, mtfacen = 0, mcoln = 0; a < me->fdata.totlayer; a++) { + layer = &me->fdata.layers[a]; if (layer->type == CD_MTFACE) { if (layer->name[0] == 0) { @@ -441,8 +448,10 @@ static void customdata_version_242(Mesh *me) } else if (layer->type == CD_MCOL) { if (layer->name[0] == 0) { - if (mcoln == 0) strcpy(layer->name, "Col"); - else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); + if (mcoln == 0) + strcpy(layer->name, "Col"); + else + BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); } mcoln++; } @@ -457,8 +466,8 @@ static void customdata_version_243(Mesh *me) CustomDataLayer *layer; int a; - for (a=0; a < me->fdata.totlayer; a++) { - layer= &me->fdata.layers[a]; + for (a = 0; a < me->fdata.totlayer; a++) { + layer = &me->fdata.layers[a]; layer->active_rnd = layer->active; } } @@ -467,30 +476,30 @@ static void customdata_version_243(Mesh *me) static void do_version_ntree_242_2(bNodeTree *ntree) { bNode *node; - - if (ntree->type==NTREE_COMPOSIT) { - for (node= ntree->nodes.first; node; node= node->next) { + + if (ntree->type == NTREE_COMPOSIT) { + for (node = ntree->nodes.first; node; node = node->next) { if (ELEM3(node->type, CMP_NODE_IMAGE, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { /* only image had storage */ if (node->storage) { - NodeImageAnim *nia= node->storage; - ImageUser *iuser= MEM_callocN(sizeof(ImageUser), "ima user node"); + NodeImageAnim *nia = node->storage; + ImageUser *iuser = MEM_callocN(sizeof(ImageUser), "ima user node"); - iuser->frames= nia->frames; - iuser->sfra= nia->sfra; - iuser->offset= nia->nr-1; - iuser->cycl= nia->cyclic; - iuser->fie_ima= 2; - iuser->ok= 1; - - node->storage= iuser; + iuser->frames = nia->frames; + iuser->sfra = nia->sfra; + iuser->offset = nia->nr-1; + iuser->cycl = nia->cyclic; + iuser->fie_ima = 2; + iuser->ok = 1; + + node->storage = iuser; MEM_freeN(nia); } else { - ImageUser *iuser= node->storage= MEM_callocN(sizeof(ImageUser), "node image user"); - iuser->sfra= 1; - iuser->fie_ima= 2; - iuser->ok= 1; + ImageUser *iuser = node->storage = MEM_callocN(sizeof(ImageUser), "node image user"); + iuser->sfra = 1; + iuser->fie_ima = 2; + iuser->ok = 1; } } } @@ -501,9 +510,10 @@ static void do_version_free_effect_245(Effect *eff) { PartEff *paf; - if (eff->type==EFF_PARTICLE) { - paf= (PartEff *)eff; - if (paf->keys) MEM_freeN(paf->keys); + if (eff->type == EFF_PARTICLE) { + paf = (PartEff *)eff; + if (paf->keys) + MEM_freeN(paf->keys); } MEM_freeN(eff); } @@ -512,11 +522,11 @@ static void do_version_free_effects_245(ListBase *lb) { Effect *eff; - eff= lb->first; + eff = lb->first; while (eff) { BLI_remlink(lb, eff); do_version_free_effect_245(eff); - eff= lb->first; + eff = lb->first; } } @@ -524,10 +534,11 @@ PartEff *blo_do_version_give_parteff_245(Object *ob) { PartEff *paf; - paf= ob->effect.first; + paf = ob->effect.first; while (paf) { - if (paf->type==EFF_PARTICLE) return paf; - paf= paf->next; + if (paf->type == EFF_PARTICLE) + return paf; + paf = paf->next; } return NULL; } @@ -537,15 +548,15 @@ void blo_do_version_old_trackto_to_constraints(Object *ob) { /* create new trackto constraint from the relationship */ if (ob->track) { - bConstraint *con= add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); + bConstraint *con = add_ob_constraint(ob, "AutoTrack", CONSTRAINT_TYPE_TRACKTO); bTrackToConstraint *data = con->data; - + /* copy tracking settings from the object */ data->tar = ob->track; data->reserved1 = ob->trackflag; data->reserved2 = ob->upflag; } - + /* clear old track setting */ ob->track = NULL; } @@ -554,59 +565,63 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) { /* WATCH IT!!!: pointers from libdata have not been converted */ - if (G.debug & G_DEBUG) - printf("read file %s\n Version %d sub %d svn r%d\n", fd->relabase, main->versionfile, main->subversionfile, main->revision); - if (main->versionfile == 100) { /* tex->extend and tex->imageflag have changed: */ Tex *tex = main->tex.first; while (tex) { if (tex->id.flag & LIB_NEEDLINK) { - if (tex->extend==0) { - if (tex->xrepeat || tex->yrepeat) tex->extend= TEX_REPEAT; + if (tex->extend == 0) { + if (tex->xrepeat || tex->yrepeat) { + tex->extend = TEX_REPEAT; + } else { - tex->extend= TEX_EXTEND; - tex->xrepeat= tex->yrepeat= 1; + tex->extend = TEX_EXTEND; + tex->xrepeat = tex->yrepeat = 1; } } } - tex= tex->id.next; + tex = tex->id.next; } } + if (main->versionfile <= 101) { /* frame mapping */ Scene *sce = main->scene.first; while (sce) { - sce->r.framapto= 100; - sce->r.images= 100; - sce->r.framelen= 1.0; - sce= sce->id.next; + sce->r.framapto = 100; + sce->r.images = 100; + sce->r.framelen = 1.0; + sce = sce->id.next; } } + if (main->versionfile <= 102) { /* init halo's at 1.0 */ Material *ma = main->mat.first; while (ma) { - ma->add= 1.0; - ma= ma->id.next; + ma->add = 1.0; + ma = ma->id.next; } } + if (main->versionfile <= 103) { /* new variable in object: colbits */ Object *ob = main->object.first; int a; while (ob) { - ob->colbits= 0; + ob->colbits = 0; if (ob->totcol) { - for (a=0; atotcol; a++) { - if (ob->mat[a]) ob->colbits |= (1<totcol; a++) { + if (ob->mat[a]) + ob->colbits |= (1<id.next; + ob = ob->id.next; } } + if (main->versionfile <= 104) { /* timeoffs moved */ Object *ob = main->object.first; @@ -615,68 +630,79 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob->transflag -= 1; //ob->ipoflag |= OB_OFFS_OB; } - ob= ob->id.next; + ob = ob->id.next; } } + if (main->versionfile <= 105) { Object *ob = main->object.first; while (ob) { - ob->dupon= 1; ob->dupoff= 0; - ob->dupsta= 1; ob->dupend= 100; - ob= ob->id.next; + ob->dupon = 1; + ob->dupoff = 0; + ob->dupsta = 1; + ob->dupend = 100; + ob = ob->id.next; } } + if (main->versionfile <= 106) { /* mcol changed */ Mesh *me = main->mesh.first; while (me) { - if (me->mcol) vcol_to_fcol(me); - me= me->id.next; + if (me->mcol) + vcol_to_fcol(me); + me = me->id.next; } } + if (main->versionfile <= 107) { Object *ob; Scene *sce = main->scene.first; while (sce) { sce->r.mode |= R_GAMMA; - sce= sce->id.next; + sce = sce->id.next; } - ob= main->object.first; + ob = main->object.first; while (ob) { //ob->ipoflag |= OB_OFFS_PARENT; - if (ob->dt==0) ob->dt= OB_SOLID; - ob= ob->id.next; + if (ob->dt == 0) + ob->dt = OB_SOLID; + ob = ob->id.next; } } + if (main->versionfile <= 109) { /* new variable: gridlines */ bScreen *sc = main->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; - if (v3d->gridlines==0) v3d->gridlines= 20; + if (v3d->gridlines == 0) + v3d->gridlines = 20; } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } + if (main->versionfile <= 113) { Material *ma = main->mat.first; while (ma) { - if (ma->flaresize==0.0f) ma->flaresize= 1.0f; - ma->subsize= 1.0f; - ma->flareboost= 1.0f; - ma= ma->id.next; + if (ma->flaresize == 0.0f) + ma->flaresize = 1.0f; + ma->subsize = 1.0f; + ma->flareboost = 1.0f; + ma = ma->id.next; } } @@ -685,7 +711,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) while (tex) { if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && - (tex->bfac == 0.0f)) { + (tex->bfac == 0.0f)) + { tex->rfac = 1.0f; tex->gfac = 1.0f; tex->bfac = 1.0f; @@ -694,13 +721,15 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex = tex->id.next; } } + if (main->versionfile <= 140) { /* r-g-b-fac in texture */ Tex *tex = main->tex.first; while (tex) { if ((tex->rfac == 0.0f) && (tex->gfac == 0.0f) && - (tex->bfac == 0.0f)) { + (tex->bfac == 0.0f)) + { tex->rfac = 1.0f; tex->gfac = 1.0f; tex->bfac = 1.0f; @@ -709,86 +738,93 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex = tex->id.next; } } + if (main->versionfile <= 153) { Scene *sce = main->scene.first; while (sce) { - if (sce->r.blurfac==0.0f) sce->r.blurfac= 1.0f; - sce= sce->id.next; + if (sce->r.blurfac == 0.0f) + sce->r.blurfac = 1.0f; + sce = sce->id.next; } } + if (main->versionfile <= 163) { Scene *sce = main->scene.first; while (sce) { - if (sce->r.frs_sec==0) sce->r.frs_sec= 25; - sce= sce->id.next; + if (sce->r.frs_sec == 0) + sce->r.frs_sec = 25; + sce = sce->id.next; } } + if (main->versionfile <= 164) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; while (me) { - me->smoothresh= 30; - me= me->id.next; + me->smoothresh = 30; + me = me->id.next; } } + if (main->versionfile <= 165) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; TFace *tface; int nr; char *cp; while (me) { if (me->tface) { - nr= me->totface; - tface= me->tface; + nr = me->totface; + tface = me->tface; while (nr--) { - cp= (char *)&tface->col[0]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - cp= (char *)&tface->col[1]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - cp= (char *)&tface->col[2]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; - cp= (char *)&tface->col[3]; - if (cp[1]>126) cp[1]= 255; else cp[1]*=2; - if (cp[2]>126) cp[2]= 255; else cp[2]*=2; - if (cp[3]>126) cp[3]= 255; else cp[3]*=2; + cp = (char *)&tface->col[0]; + if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2; + if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2; + if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2; + cp = (char *)&tface->col[1]; + if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2; + if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2; + if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2; + cp = (char *)&tface->col[2]; + if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2; + if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2; + if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2; + cp = (char *)&tface->col[3]; + if (cp[1] > 126) cp[1] = 255; else cp[1] *= 2; + if (cp[2] > 126) cp[2] = 255; else cp[2] *= 2; + if (cp[3] > 126) cp[3] = 255; else cp[3] *= 2; tface++; } } - me= me->id.next; + me = me->id.next; } } if (main->versionfile <= 169) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; while (me) { - if (me->subdiv==0) me->subdiv= 1; - me= me->id.next; + if (me->subdiv == 0) + me->subdiv = 1; + me = me->id.next; } } if (main->versionfile <= 169) { - bScreen *sc= main->screen.first; + bScreen *sc = main->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_IPO) { - SpaceIpo *sipo= (SpaceIpo*) sl; - sipo->v2d.max[0]= 15000.0; + if (sl->spacetype == SPACE_IPO) { + SpaceIpo *sipo = (SpaceIpo*) sl; + sipo->v2d.max[0] = 15000.0; } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } @@ -799,7 +835,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) paf = blo_do_version_give_parteff_245(ob); if (paf) { if (paf->staticstep == 0) { - paf->staticstep= 5; + paf->staticstep = 5; } } ob = ob->id.next; @@ -807,87 +843,88 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } if (main->versionfile <= 171) { - bScreen *sc= main->screen.first; + bScreen *sc = main->screen.first; while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText*) sl; - st->lheight= 12; + if (sl->spacetype == SPACE_TEXT) { + SpaceText *st = (SpaceText*) sl; + st->lheight = 12; } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } if (main->versionfile <= 173) { int a, b; - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; while (me) { if (me->tface) { - TFace *tface= me->tface; - for (a=0; atotface; a++, tface++) { - for (b=0; b<4; b++) { - tface->uv[b][0]/= 32767.0f; - tface->uv[b][1]/= 32767.0f; + TFace *tface = me->tface; + for (a = 0; a < me->totface; a++, tface++) { + for (b = 0; b < 4; b++) { + tface->uv[b][0] /= 32767.0f; + tface->uv[b][1] /= 32767.0f; } } } - me= me->id.next; + me = me->id.next; } } if (main->versionfile <= 191) { - Object *ob= main->object.first; + Object *ob = main->object.first; Material *ma = main->mat.first; /* let faces have default add factor of 0.0 */ while (ma) { - if (!(ma->mode & MA_HALO)) ma->add = 0.0; + if (!(ma->mode & MA_HALO)) + ma->add = 0.0; ma = ma->id.next; } while (ob) { - ob->mass= 1.0f; - ob->damping= 0.1f; - /*ob->quat[1]= 1.0f;*/ /* quats arnt used yet */ - ob= ob->id.next; + ob->mass = 1.0f; + ob->damping = 0.1f; + /*ob->quat[1] = 1.0f;*/ /* quats arnt used yet */ + ob = ob->id.next; } } if (main->versionfile <= 193) { - Object *ob= main->object.first; + Object *ob = main->object.first; while (ob) { - ob->inertia= 1.0f; - ob->rdamping= 0.1f; - ob= ob->id.next; + ob->inertia = 1.0f; + ob->rdamping = 0.1f; + ob = ob->id.next; } } if (main->versionfile <= 196) { - Mesh *me= main->mesh.first; + Mesh *me = main->mesh.first; int a, b; while (me) { if (me->tface) { - TFace *tface= me->tface; - for (a=0; atotface; a++, tface++) { - for (b=0; b<4; b++) { + TFace *tface = me->tface; + for (a = 0; a < me->totface; a++, tface++) { + for (b = 0; b < 4; b++) { tface->mode |= TF_DYNAMIC; tface->mode &= ~TF_INVISIBLE; } } } - me= me->id.next; + me = me->id.next; } } if (main->versionfile <= 200) { - Object *ob= main->object.first; + Object *ob = main->object.first; while (ob) { ob->scaflag = ob->gameflag & (OB_DO_FH|OB_ROT_FH|OB_ANISOTROPIC_FRICTION|OB_GHOST|OB_RIGID_BODY|OB_BOUNDS); /* 64 is do_fh */ @@ -898,7 +935,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 201) { /* add-object + end-object are joined to edit-object actuator */ - Object *ob = main->object.first; + Object *ob = main->object.first; bProperty *prop; bActuator *act; bIpoActuator *ia; @@ -907,30 +944,30 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) while (ob) { act = ob->actuators.first; while (act) { - if (act->type==ACT_IPO) { - ia= act->data; - prop= get_ob_property(ob, ia->name); + if (act->type == ACT_IPO) { + ia = act->data; + prop = get_ob_property(ob, ia->name); if (prop) { - ia->type= ACT_IPO_FROM_PROP; + ia->type = ACT_IPO_FROM_PROP; } } - else if (act->type==ACT_ADD_OBJECT) { - aoa= act->data; - eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); - eoa->type= ACT_EDOB_ADD_OBJECT; - eoa->ob= aoa->ob; - eoa->time= aoa->time; + else if (act->type == ACT_ADD_OBJECT) { + aoa = act->data; + eoa = MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); + eoa->type = ACT_EDOB_ADD_OBJECT; + eoa->ob = aoa->ob; + eoa->time = aoa->time; MEM_freeN(aoa); - act->data= eoa; - act->type= act->otype= ACT_EDIT_OBJECT; + act->data = eoa; + act->type = act->otype = ACT_EDIT_OBJECT; } - else if (act->type==ACT_END_OBJECT) { - eoa= MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); - eoa->type= ACT_EDOB_END_OBJECT; - act->data= eoa; - act->type= act->otype= ACT_EDIT_OBJECT; + else if (act->type == ACT_END_OBJECT) { + eoa = MEM_callocN(sizeof(bEditObjectActuator), "edit ob act"); + eoa->type = ACT_EDOB_END_OBJECT; + act->data = eoa; + act->type = act->otype = ACT_EDIT_OBJECT; } - act= act->next; + act = act->next; } ob = ob->id.next; } @@ -939,25 +976,25 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 202) { /* add-object and end-object are joined to edit-object * actuator */ - Object *ob= main->object.first; + Object *ob = main->object.first; bActuator *act; bObjectActuator *oa; while (ob) { - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { - oa= act->data; + if (act->type == ACT_OBJECT) { + oa = act->data; oa->flag &= ~(ACT_TORQUE_LOCAL|ACT_DROT_LOCAL); /* this actuator didn't do local/glob rot before */ } - act= act->next; + act = act->next; } - ob= ob->id.next; + ob = ob->id.next; } } if (main->versionfile <= 204) { /* patches for new physics */ - Object *ob= main->object.first; + Object *ob = main->object.first; bActuator *act; bObjectActuator *oa; bSound *sound; @@ -966,22 +1003,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* please check this for demo20 files like * original Egypt levels etc. converted * rotation factor of 50 is not workable */ - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { - oa= act->data; + if (act->type == ACT_OBJECT) { + oa = act->data; - oa->forceloc[0]*= 25.0f; - oa->forceloc[1]*= 25.0f; - oa->forceloc[2]*= 25.0f; + oa->forceloc[0] *= 25.0f; + oa->forceloc[1] *= 25.0f; + oa->forceloc[2] *= 25.0f; - oa->forcerot[0]*= 10.0f; - oa->forcerot[1]*= 10.0f; - oa->forcerot[2]*= 10.0f; + oa->forcerot[0] *= 10.0f; + oa->forcerot[1] *= 10.0f; + oa->forcerot[2] *= 10.0f; } - act= act->next; + act = act->next; } - ob= ob->id.next; + ob = ob->id.next; } sound = main->sound.first; @@ -995,7 +1032,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile <= 205) { /* patches for new physics */ - Object *ob= main->object.first; + Object *ob = main->object.first; bActuator *act; bSensor *sens; bEditObjectActuator *oa; @@ -1009,21 +1046,21 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob->anisotropicFriction[1] = 1.0; ob->anisotropicFriction[2] = 1.0; - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_EDIT_OBJECT) { + if (act->type == ACT_EDIT_OBJECT) { /* Zero initial velocity for newly * added objects */ - oa= act->data; + oa = act->data; oa->linVelocity[0] = 0.0; oa->linVelocity[1] = 0.0; oa->linVelocity[2] = 0.0; oa->localflag = 0; } - act= act->next; + act = act->next; } - sens= ob->sensors.first; + sens = ob->sensors.first; while (sens) { /* Extra fields for radar sensors. */ if (sens->type == SENS_RADAR) { @@ -1056,7 +1093,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } sens = sens->next; } - ob= ob->id.next; + ob = ob->id.next; } /* have to check the exact multiplier */ } @@ -1070,41 +1107,40 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Object *ob; /* added alpha in obcolor */ - ob= main->object.first; + ob = main->object.first; while (ob) { - ob->col[3]= 1.0; - ob= ob->id.next; + ob->col[3] = 1.0; + ob = ob->id.next; } /* added alpha in obcolor */ - ob= main->object.first; + ob = main->object.first; while (ob) { - act= ob->actuators.first; + act = ob->actuators.first; while (act) { - if (act->type==ACT_OBJECT) { + if (act->type == ACT_OBJECT) { /* multiply velocity with 50 in old files */ - oa= act->data; + oa = act->data; if (fabsf(oa->linearvelocity[0]) >= 0.01f) oa->linearvelocity[0] *= 50.0f; if (fabsf(oa->linearvelocity[1]) >= 0.01f) oa->linearvelocity[1] *= 50.0f; if (fabsf(oa->linearvelocity[2]) >= 0.01f) oa->linearvelocity[2] *= 50.0f; - if (fabsf(oa->angularvelocity[0])>=0.01f) + if (fabsf(oa->angularvelocity[0]) >= 0.01f) oa->angularvelocity[0] *= 50.0f; - if (fabsf(oa->angularvelocity[1])>=0.01f) + if (fabsf(oa->angularvelocity[1]) >= 0.01f) oa->angularvelocity[1] *= 50.0f; - if (fabsf(oa->angularvelocity[2])>=0.01f) + if (fabsf(oa->angularvelocity[2]) >= 0.01f) oa->angularvelocity[2] *= 50.0f; } - act= act->next; + act = act->next; } - ob= ob->id.next; + ob = ob->id.next; } } if (main->versionfile <= 212) { - bSound* sound; bProperty *prop; Object *ob; @@ -1127,33 +1163,33 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = main->object.first; while (ob) { - prop= ob->prop.first; + prop = ob->prop.first; while (prop) { if (prop->type == GPROP_TIME) { // convert old GPROP_TIME values from int to float *((float *)&prop->data) = (float) prop->data; } - prop= prop->next; + prop = prop->next; } ob = ob->id.next; } - /* me->subdiv changed to reflect the actual reparametization - * better, and smeshes were removed - if it was a smesh make - * it a subsurf, and reset the subdiv level because subsurf - * takes a lot more work to calculate. - */ - for (me= main->mesh.first; me; me= me->id.next) { - if (me->flag&ME_SMESH) { - me->flag&= ~ME_SMESH; - me->flag|= ME_SUBSURF; + /* me->subdiv changed to reflect the actual reparametization + * better, and smeshes were removed - if it was a smesh make + * it a subsurf, and reset the subdiv level because subsurf + * takes a lot more work to calculate. + */ + for (me = main->mesh.first; me; me = me->id.next) { + if (me->flag & ME_SMESH) { + me->flag &= ~ME_SMESH; + me->flag |= ME_SUBSURF; - me->subdiv= 1; + me->subdiv = 1; } else { - if (me->subdiv<2) - me->subdiv= 1; + if (me->subdiv < 2) + me->subdiv = 1; else me->subdiv--; } @@ -1167,113 +1203,116 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = main->object.first; /* adapt form factor in order to get the 'old' physics - * behavior back...*/ + * behavior back... + */ while (ob) { /* in future, distinguish between different - * object bounding shapes */ + * object bounding shapes + */ ob->formfactor = 0.4f; /* patch form factor, note that inertia equiv radius - * of a rotation symmetrical obj */ + * of a rotation symmetrical obj + */ if (ob->inertia != 1.0f) { ob->formfactor /= ob->inertia * ob->inertia; } ob = ob->id.next; } - /* Began using alpha component of vertex colors, but - * old file vertex colors are undefined, reset them - * to be fully opaque. -zr - */ - for (me= main->mesh.first; me; me= me->id.next) { + /* Began using alpha component of vertex colors, but + * old file vertex colors are undefined, reset them + * to be fully opaque. -zr + */ + for (me = main->mesh.first; me; me = me->id.next) { if (me->mcol) { int i; - for (i=0; itotface*4; i++) { - MCol *mcol= &me->mcol[i]; - mcol->a= 255; + for (i = 0; i < me->totface * 4; i++) { + MCol *mcol = &me->mcol[i]; + mcol->a = 255; } } if (me->tface) { int i, j; - for (i=0; itotface; i++) { - TFace *tf= &((TFace*) me->tface)[i]; + for (i = 0; i < me->totface; i++) { + TFace *tf = &((TFace*) me->tface)[i]; - for (j=0; j<4; j++) { - char *col= (char*) &tf->col[j]; + for (j = 0; j < 4; j++) { + char *col = (char*) &tf->col[j]; - col[0]= 255; + col[0] = 255; } } } } } + if (main->versionfile <= 221) { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; - // new variables for std-alone player and runtime + /* new variables for std-alone player and runtime */ while (sce) { + sce->r.xplay = 640; + sce->r.yplay = 480; + sce->r.freqplay = 60; - sce->r.xplay= 640; - sce->r.yplay= 480; - sce->r.freqplay= 60; - - sce= sce->id.next; + sce = sce->id.next; } } + if (main->versionfile <= 222) { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; - // new variables for std-alone player and runtime + /* new variables for std-alone player and runtime */ while (sce) { + sce->r.depth = 32; - sce->r.depth= 32; - - sce= sce->id.next; + sce = sce->id.next; } } - if (main->versionfile <= 223) { VFont *vf; Image *ima; Object *ob; - for (vf= main->vfont.first; vf; vf= vf->id.next) { - if (strcmp(vf->name+strlen(vf->name)-6, ".Bfont")==0) { + for (vf = main->vfont.first; vf; vf = vf->id.next) { + if (strcmp(vf->name + strlen(vf->name)-6, ".Bfont") == 0) { strcpy(vf->name, FO_BUILTIN_NAME); } } /* Old textures animate at 25 FPS */ - for (ima = main->image.first; ima; ima=ima->id.next) { + for (ima = main->image.first; ima; ima = ima->id.next) { ima->animspeed = 25; } - /* Zr remapped some keyboard codes to be linear (stupid zr) */ - for (ob= main->object.first; ob; ob= ob->id.next) { + /* Zr remapped some keyboard codes to be linear (stupid zr) */ + for (ob = main->object.first; ob; ob = ob->id.next) { bSensor *sens; - for (sens= ob->sensors.first; sens; sens= sens->next) { - if (sens->type==SENS_KEYBOARD) { - bKeyboardSensor *ks= sens->data; + for (sens = ob->sensors.first; sens; sens = sens->next) { + if (sens->type == SENS_KEYBOARD) { + bKeyboardSensor *ks = sens->data; - ks->key= map_223_keybd_code_to_224_keybd_code(ks->key); - ks->qual= map_223_keybd_code_to_224_keybd_code(ks->qual); - ks->qual2= map_223_keybd_code_to_224_keybd_code(ks->qual2); + ks->key = map_223_keybd_code_to_224_keybd_code(ks->key); + ks->qual = map_223_keybd_code_to_224_keybd_code(ks->qual); + ks->qual2 = map_223_keybd_code_to_224_keybd_code(ks->qual2); } } } } + if (main->versionfile <= 224) { bSound* sound; Scene *sce; Mesh *me; bScreen *sc; - for (sound=main->sound.first; sound; sound=sound->id.next) { + for (sound = main->sound.first; sound; sound = sound->id.next) { if (sound->packedfile) { if (sound->newpackedfile == NULL) { sound->newpackedfile = sound->packedfile; @@ -1282,38 +1321,36 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } /* Make sure that old subsurf meshes don't have zero subdivision level for rendering */ - for (me=main->mesh.first; me; me=me->id.next) { - if ((me->flag & ME_SUBSURF) && (me->subdivr==0)) - me->subdivr=me->subdiv; + for (me = main->mesh.first; me; me = me->id.next) { + if ((me->flag & ME_SUBSURF) && (me->subdivr == 0)) + me->subdivr = me->subdiv; } - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->r.stereomode = 1; // no stereo } - /* some oldfile patch, moved from set_func_space */ - for (sc= main->screen.first; sc; sc= sc->id.next) { + /* some oldfile patch, moved from set_func_space */ + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IPO) { - SpaceSeq *sseq= (SpaceSeq*) sl; - sseq->v2d.keeptot= 0; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IPO) { + SpaceSeq *sseq = (SpaceSeq*) sl; + sseq->v2d.keeptot = 0; } } } } - } - if (main->versionfile <= 225) { World *wo; /* Use Sumo for old games */ - for (wo = main->world.first; wo; wo= wo->id.next) { + for (wo = main->world.first; wo; wo = wo->id.next) { wo->physicsEngine = 2; } } @@ -1334,11 +1371,12 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) list = &ob->constraints; /* check for already existing TrackTo constraint - * set their track and up flag correctly */ + * set their track and up flag correctly + */ if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; data->reserved1 = ob->trackflag; @@ -1351,10 +1389,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (ob->pose) { bConstraint *curcon; bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; - pchan; pchan=pchan->next) { - for (curcon = pchan->constraints.first; - curcon; curcon=curcon->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) { if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; data->reserved1 = ob->trackflag; @@ -1367,53 +1403,55 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* Change Ob->Track in real TrackTo constraint */ blo_do_version_old_trackto_to_constraints(ob); - + ob = ob->id.next; } - - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->audio.mixrate = 44100; sce->audio.flag |= AUDIO_SCRUB; sce->r.mode |= R_ENVMAP; } - // init new shader vars - for (ma= main->mat.first; ma; ma= ma->id.next) { - ma->refrac= 4.0f; - ma->roughness= 0.5f; - ma->param[0]= 0.5f; - ma->param[1]= 0.1f; - ma->param[2]= 0.1f; - ma->param[3]= 0.05f; + + /* init new shader vars */ + for (ma = main->mat.first; ma; ma = ma->id.next) { + ma->refrac = 4.0f; + ma->roughness = 0.5f; + ma->param[0] = 0.5f; + ma->param[1] = 0.1f; + ma->param[2] = 0.1f; + ma->param[3] = 0.05f; } - // patch for old wrong max view2d settings, allows zooming out more - for (sc= main->screen.first; sc; sc= sc->id.next) { + + /* patch for old wrong max view2d settings, allows zooming out more */ + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_ACTION) { - SpaceAction *sac= (SpaceAction *) sl; - sac->v2d.max[0]= 32000; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_ACTION) { + SpaceAction *sac = (SpaceAction *) sl; + sac->v2d.max[0] = 32000; } - else if (sl->spacetype==SPACE_NLA) { - SpaceNla *sla= (SpaceNla *) sl; - sla->v2d.max[0]= 32000; + else if (sl->spacetype == SPACE_NLA) { + SpaceNla *sla = (SpaceNla *) sl; + sla->v2d.max[0] = 32000; } } } } } + if (main->versionfile <= 228) { Scene *sce; bScreen *sc; Object *ob; - /* As of now, this insures that the transition from the old Track system - * to the new full constraint Track is painless for everyone.*/ + * to the new full constraint Track is painless for everyone. + */ ob = main->object.first; while (ob) { @@ -1425,7 +1463,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; data->reserved1 = ob->trackflag; @@ -1438,10 +1476,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (ob->pose) { bConstraint *curcon; bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; - pchan; pchan=pchan->next) { - for (curcon = pchan->constraints.first; - curcon; curcon=curcon->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) { if (curcon->type == CONSTRAINT_TYPE_TRACKTO) { bTrackToConstraint *data = curcon->data; data->reserved1 = ob->trackflag; @@ -1455,125 +1491,131 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob = ob->id.next; } - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->r.mode |= R_ENVMAP; } - // convert old mainb values for new button panels - for (sc= main->screen.first; sc; sc= sc->id.next) { + /* convert old mainb values for new button panels */ + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_BUTS) { - SpaceButs *sbuts= (SpaceButs *) sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_BUTS) { + SpaceButs *sbuts = (SpaceButs *) sl; - sbuts->v2d.maxzoom= 1.2f; - sbuts->align= 1; /* horizontal default */ - - if (sbuts->mainb==BUTS_LAMP) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_LAMP; + sbuts->v2d.maxzoom = 1.2f; + sbuts->align = 1; /* horizontal default */ + + if (sbuts->mainb == BUTS_LAMP) { + sbuts->mainb = CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_LAMP; } - else if (sbuts->mainb==BUTS_MAT) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_MAT; + else if (sbuts->mainb == BUTS_MAT) { + sbuts->mainb = CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_MAT; } - else if (sbuts->mainb==BUTS_TEX) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_TEX; + else if (sbuts->mainb == BUTS_TEX) { + sbuts->mainb = CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_TEX; } - else if (sbuts->mainb==BUTS_ANIM) { - sbuts->mainb= CONTEXT_OBJECT; + else if (sbuts->mainb == BUTS_ANIM) { + sbuts->mainb = CONTEXT_OBJECT; } - else if (sbuts->mainb==BUTS_WORLD) { - sbuts->mainb= CONTEXT_SCENE; - //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_WORLD; + else if (sbuts->mainb == BUTS_WORLD) { + sbuts->mainb = CONTEXT_SCENE; + //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_WORLD; } - else if (sbuts->mainb==BUTS_RENDER) { - sbuts->mainb= CONTEXT_SCENE; - //sbuts->tab[CONTEXT_SCENE]= TAB_SCENE_RENDER; + else if (sbuts->mainb == BUTS_RENDER) { + sbuts->mainb = CONTEXT_SCENE; + //sbuts->tab[CONTEXT_SCENE] = TAB_SCENE_RENDER; } - else if (sbuts->mainb==BUTS_GAME) { - sbuts->mainb= CONTEXT_LOGIC; + else if (sbuts->mainb == BUTS_GAME) { + sbuts->mainb = CONTEXT_LOGIC; } - else if (sbuts->mainb==BUTS_FPAINT) { - sbuts->mainb= CONTEXT_EDITING; + else if (sbuts->mainb == BUTS_FPAINT) { + sbuts->mainb = CONTEXT_EDITING; } - else if (sbuts->mainb==BUTS_RADIO) { - sbuts->mainb= CONTEXT_SHADING; - //sbuts->tab[CONTEXT_SHADING]= TAB_SHADING_RAD; + else if (sbuts->mainb == BUTS_RADIO) { + sbuts->mainb = CONTEXT_SHADING; + //sbuts->tab[CONTEXT_SHADING] = TAB_SHADING_RAD; } - else if (sbuts->mainb==BUTS_CONSTRAINT) { - sbuts->mainb= CONTEXT_OBJECT; + else if (sbuts->mainb == BUTS_CONSTRAINT) { + sbuts->mainb = CONTEXT_OBJECT; } - else if (sbuts->mainb==BUTS_SCRIPT) { - sbuts->mainb= CONTEXT_OBJECT; + else if (sbuts->mainb == BUTS_SCRIPT) { + sbuts->mainb = CONTEXT_OBJECT; } - else if (sbuts->mainb==BUTS_EDIT) { - sbuts->mainb= CONTEXT_EDITING; + else if (sbuts->mainb == BUTS_EDIT) { + sbuts->mainb = CONTEXT_EDITING; } - else sbuts->mainb= CONTEXT_SCENE; + else sbuts->mainb = CONTEXT_SCENE; } } } } } + /* ton: made this 230 instead of 229, * to be sure (tuho files) and this is a reliable check anyway * nevertheless, we might need to think over a fitness (initialize) - * check apart from the do_versions() */ + * check apart from the do_versions() + */ if (main->versionfile <= 230) { bScreen *sc; - // new variable blockscale, for panels in any area - for (sc= main->screen.first; sc; sc= sc->id.next) { + /* new variable blockscale, for panels in any area */ + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->blockscale==0.0f) sl->blockscale= 0.7f; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->blockscale == 0.0f) + sl->blockscale = 0.7f; /* added: 5x better zoom in for action */ - if (sl->spacetype==SPACE_ACTION) { - SpaceAction *sac= (SpaceAction *)sl; - sac->v2d.maxzoom= 50; + if (sl->spacetype == SPACE_ACTION) { + SpaceAction *sac = (SpaceAction *)sl; + sac->v2d.maxzoom = 50; } } } } } + if (main->versionfile <= 231) { /* new bit flags for showing/hiding grid floor and axes */ bScreen *sc = main->screen.first; - while (sc) { - ScrArea *sa= sc->areabase.first; - while (sa) { - SpaceLink *sl= sa->spacedata.first; - while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; - if (v3d->gridflag==0) { + while (sc) { + ScrArea *sa = sc->areabase.first; + while (sa) { + SpaceLink *sl = sa->spacedata.first; + while (sl) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; + + if (v3d->gridflag == 0) { v3d->gridflag |= V3D_SHOW_X; v3d->gridflag |= V3D_SHOW_Y; v3d->gridflag |= V3D_SHOW_FLOOR; v3d->gridflag &= ~V3D_SHOW_Z; } } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } + if (main->versionfile <= 231) { - Material *ma= main->mat.first; + Material *ma = main->mat.first; bScreen *sc = main->screen.first; Scene *sce; Lamp *la; @@ -1581,68 +1623,78 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) /* introduction of raytrace */ while (ma) { - if (ma->fresnel_tra_i==0.0f) ma->fresnel_tra_i= 1.25f; - if (ma->fresnel_mir_i==0.0f) ma->fresnel_mir_i= 1.25f; + if (ma->fresnel_tra_i == 0.0f) + ma->fresnel_tra_i = 1.25f; + if (ma->fresnel_mir_i == 0.0f) + ma->fresnel_mir_i = 1.25f; - ma->ang= 1.0; - ma->ray_depth= 2; - ma->ray_depth_tra= 2; - ma->fresnel_tra= 0.0; - ma->fresnel_mir= 0.0; + ma->ang = 1.0; + ma->ray_depth = 2; + ma->ray_depth_tra = 2; + ma->fresnel_tra = 0.0; + ma->fresnel_mir = 0.0; - ma= ma->id.next; + ma = ma->id.next; } - sce= main->scene.first; + sce = main->scene.first; while (sce) { - if (sce->r.gauss==0.0f) sce->r.gauss= 1.0f; - sce= sce->id.next; + if (sce->r.gauss == 0.0f) + sce->r.gauss = 1.0f; + sce = sce->id.next; } - la= main->lamp.first; + la = main->lamp.first; while (la) { - if (la->k==0.0f) la->k= 1.0; - if (la->ray_samp==0) la->ray_samp= 1; - if (la->ray_sampy==0) la->ray_sampy= 1; - if (la->ray_sampz==0) la->ray_sampz= 1; - if (la->area_size==0.0f) la->area_size= 1.0f; - if (la->area_sizey==0.0f) la->area_sizey= 1.0f; - if (la->area_sizez==0.0f) la->area_sizez= 1.0f; - la= la->id.next; + if (la->k == 0.0f) la->k = 1.0; + if (la->ray_samp == 0) + la->ray_samp = 1; + if (la->ray_sampy == 0) + la->ray_sampy = 1; + if (la->ray_sampz == 0) + la->ray_sampz = 1; + if (la->area_size == 0.0f) + la->area_size = 1.0f; + if (la->area_sizey == 0.0f) + la->area_sizey = 1.0f; + if (la->area_sizez == 0.0f) + la->area_sizez = 1.0f; + la = la->id.next; } - wrld= main->world.first; + wrld = main->world.first; while (wrld) { - if (wrld->range==0.0f) { - wrld->range= 1.0f/wrld->exposure; + if (wrld->range == 0.0f) { + wrld->range = 1.0f / wrld->exposure; } - wrld= wrld->id.next; + wrld = wrld->id.next; } /* new bit flags for showing/hiding grid floor and axes */ while (sc) { - ScrArea *sa= sc->areabase.first; + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; - if (v3d->gridflag==0) { + if (v3d->gridflag == 0) { v3d->gridflag |= V3D_SHOW_X; v3d->gridflag |= V3D_SHOW_Y; v3d->gridflag |= V3D_SHOW_FLOOR; v3d->gridflag &= ~V3D_SHOW_Z; } } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } - sc= sc->id.next; + sc = sc->id.next; } } + if (main->versionfile <= 232) { - Tex *tex= main->tex.first; - World *wrld= main->world.first; + Tex *tex = main->tex.first; + World *wrld = main->world.first; bScreen *sc; Scene *sce; @@ -1651,7 +1703,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex->flag |= TEX_CHECKER_ODD; } /* copied from kernel texture.c */ - if (tex->ns_outscale==0.0f) { + if (tex->ns_outscale == 0.0f) { /* musgrave */ tex->mg_H = 1.0f; tex->mg_lacunarity = 2.0f; @@ -1665,70 +1717,79 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) tex->vn_w1 = 1.0f; tex->vn_mexp = 2.5f; } - tex= tex->id.next; + tex = tex->id.next; } while (wrld) { - if (wrld->aodist==0.0f) { - wrld->aodist= 10.0f; - wrld->aobias= 0.05f; + if (wrld->aodist == 0.0f) { + wrld->aodist = 10.0f; + wrld->aobias = 0.05f; } - if (wrld->aosamp==0) wrld->aosamp= 5; - if (wrld->aoenergy==0.0f) wrld->aoenergy= 1.0f; - wrld= wrld->id.next; + if (wrld->aosamp == 0) + wrld->aosamp = 5; + if (wrld->aoenergy == 0.0f) + wrld->aoenergy = 1.0f; + wrld = wrld->id.next; } - - // new variable blockscale, for panels in any area, do again because new - // areas didnt initialize it to 0.7 yet - for (sc= main->screen.first; sc; sc= sc->id.next) { + /* new variable blockscale, for panels in any area, do again because new + * areas didnt initialize it to 0.7 yet + */ + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->blockscale==0.0f) sl->blockscale= 0.7f; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->blockscale == 0.0f) + sl->blockscale = 0.7f; /* added: 5x better zoom in for nla */ - if (sl->spacetype==SPACE_NLA) { - SpaceNla *snla= (SpaceNla *)sl; - snla->v2d.maxzoom= 50; + if (sl->spacetype == SPACE_NLA) { + SpaceNla *snla = (SpaceNla *) sl; + snla->v2d.maxzoom = 50; } } } } - sce= main->scene.first; + sce = main->scene.first; while (sce) { - if (sce->r.ocres==0) sce->r.ocres= 64; - sce= sce->id.next; + if (sce->r.ocres == 0) + sce->r.ocres = 64; + sce = sce->id.next; } } + if (main->versionfile <= 233) { bScreen *sc; - Material *ma= main->mat.first; - /* Object *ob= main->object.first; */ - + Material *ma = main->mat.first; + /* Object *ob = main->object.first; */ + while (ma) { - if (ma->rampfac_col==0.0f) ma->rampfac_col= 1.0; - if (ma->rampfac_spec==0.0f) ma->rampfac_spec= 1.0; - if (ma->pr_lamp==0) ma->pr_lamp= 3; - ma= ma->id.next; + if (ma->rampfac_col == 0.0f) + ma->rampfac_col = 1.0; + if (ma->rampfac_spec == 0.0f) + ma->rampfac_spec = 1.0; + if (ma->pr_lamp == 0) + ma->pr_lamp = 3; + ma = ma->id.next; } - + /* this should have been done loooong before! */ #if 0 /* deprecated in 2.5+ */ while (ob) { - if (ob->ipowin==0) ob->ipowin= ID_OB; - ob= ob->id.next; + if (ob->ipowin == 0) + ob->ipowin = ID_OB; + ob = ob->id.next; } #endif - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; v3d->flag |= V3D_SELECT_OUTLINE; } } @@ -1736,108 +1797,114 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - - - if (main->versionfile <= 234) { World *wo; bScreen *sc; - - // force sumo engine to be active - for (wo = main->world.first; wo; wo= wo->id.next) { - if (wo->physicsEngine==0) wo->physicsEngine = 2; + + /* force sumo engine to be active */ + for (wo = main->world.first; wo; wo = wo->id.next) { + if (wo->physicsEngine == 0) + wo->physicsEngine = 2; } - - for (sc= main->screen.first; sc; sc= sc->id.next) { + + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; v3d->flag |= V3D_ZBUF_SELECT; } - else if (sl->spacetype==SPACE_TEXT) { - SpaceText *st= (SpaceText *)sl; - if (st->tabnumber==0) st->tabnumber= 2; + else if (sl->spacetype == SPACE_TEXT) { + SpaceText *st = (SpaceText *)sl; + if (st->tabnumber == 0) + st->tabnumber = 2; } } } } } + if (main->versionfile <= 235) { - Tex *tex= main->tex.first; - Scene *sce= main->scene.first; + Tex *tex = main->tex.first; + Scene *sce = main->scene.first; Sequence *seq; Editing *ed; - + while (tex) { - if (tex->nabla==0.0f) tex->nabla= 0.025f; - tex= tex->id.next; + if (tex->nabla == 0.0f) + tex->nabla = 0.025f; + tex = tex->id.next; } while (sce) { - ed= sce->ed; + ed = sce->ed; if (ed) { SEQ_BEGIN (sce->ed, seq) { - if (seq->type==SEQ_IMAGE || seq->type==SEQ_MOVIE) + if (seq->type == SEQ_IMAGE || seq->type == SEQ_MOVIE) seq->flag |= SEQ_MAKE_PREMUL; } SEQ_END } - - sce= sce->id.next; + + sce = sce->id.next; } } + if (main->versionfile <= 236) { Object *ob; - Camera *cam= main->camera.first; + Camera *cam = main->camera.first; Material *ma; bScreen *sc; while (cam) { - if (cam->ortho_scale==0.0f) { - cam->ortho_scale= 256.0f/cam->lens; - if (cam->type==CAM_ORTHO) printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n"); + if (cam->ortho_scale == 0.0f) { + cam->ortho_scale = 256.0f / cam->lens; + if (cam->type == CAM_ORTHO) + printf("NOTE: ortho render has changed, tweak new Camera 'scale' value.\n"); } - cam= cam->id.next; + cam = cam->id.next; } /* set manipulator type */ /* force oops draw if depgraph was set*/ /* set time line var */ - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; - if (v3d->twtype==0) v3d->twtype= V3D_MANIP_TRANSLATE; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; + if (v3d->twtype == 0) + v3d->twtype = V3D_MANIP_TRANSLATE; } } } } - // init new shader vars - for (ma= main->mat.first; ma; ma= ma->id.next) { - if (ma->darkness==0.0f) { - ma->rms=0.1f; - ma->darkness=1.0f; + /* init new shader vars */ + for (ma = main->mat.first; ma; ma = ma->id.next) { + if (ma->darkness == 0.0f) { + ma->rms = 0.1f; + ma->darkness = 1.0f; } } - + /* softbody init new vars */ - for (ob= main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->soft) { - if (ob->soft->defgoal==0.0f) ob->soft->defgoal= 0.7f; - if (ob->soft->physics_speed==0.0f) ob->soft->physics_speed= 1.0f; - - if (ob->soft->interval==0) { - ob->soft->interval= 2; - ob->soft->sfra= 1; - ob->soft->efra= 100; + if (ob->soft->defgoal == 0.0f) + ob->soft->defgoal = 0.7f; + if (ob->soft->physics_speed == 0.0f) + ob->soft->physics_speed = 1.0f; + + if (ob->soft->interval == 0) { + ob->soft->interval = 2; + ob->soft->sfra = 1; + ob->soft->efra = 100; } } - if (ob->soft && ob->soft->vertgroup==0) { + if (ob->soft && ob->soft->vertgroup == 0) { bDeformGroup *locGroup = defgroup_find_name(ob, "SOFTGOAL"); if (locGroup) { /* retrieve index for that group */ @@ -1846,125 +1913,130 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } + if (main->versionfile <= 237) { bArmature *arm; bConstraint *con; Object *ob; Bone *bone; - - // armature recode checks - for (arm= main->armature.first; arm; arm= arm->id.next) { - where_is_armature(arm); - for (bone= arm->bonebase.first; bone; bone= bone->next) + /* armature recode checks */ + for (arm = main->armature.first; arm; arm = arm->id.next) { + BKE_armature_where_is(arm); + + for (bone = arm->bonebase.first; bone; bone = bone->next) do_version_bone_head_tail_237(bone); } - for (ob= main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->parent) { - Object *parent= blo_do_versions_newlibadr(fd, lib, ob->parent); - if (parent && parent->type==OB_LATTICE) + Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent); + if (parent && parent->type == OB_LATTICE) ob->partype = PARSKEL; } - // btw. armature_rebuild_pose is further only called on leave editmode - if (ob->type==OB_ARMATURE) { + /* btw. armature_rebuild_pose is further only called on leave editmode */ + if (ob->type == OB_ARMATURE) { if (ob->pose) ob->pose->flag |= POSE_RECALC; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // cannot call stuff now (pointers!), done in setup_app_data + + /* cannot call stuff now (pointers!), done in setup_app_data */ + ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; /* new generic xray option */ - arm= blo_do_versions_newlibadr(fd, lib, ob->data); + arm = blo_do_versions_newlibadr(fd, lib, ob->data); if (arm->flag & ARM_DRAWXRAY) { ob->dtx |= OB_DRAWXRAY; } } - else if (ob->type==OB_MESH) { + else if (ob->type == OB_MESH) { Mesh *me = blo_do_versions_newlibadr(fd, lib, ob->data); - + if ((me->flag&ME_SUBSURF)) { SubsurfModifierData *smd = (SubsurfModifierData*) modifier_new(eModifierType_Subsurf); - + smd->levels = MAX2(1, me->subdiv); smd->renderLevels = MAX2(1, me->subdivr); smd->subdivType = me->subsurftype; - + smd->modifier.mode = 0; - if (me->subdiv!=0) + if (me->subdiv != 0) smd->modifier.mode |= 1; - if (me->subdivr!=0) + if (me->subdivr != 0) smd->modifier.mode |= 2; - if (me->flag&ME_OPT_EDGES) + if (me->flag & ME_OPT_EDGES) smd->flags |= eSubsurfModifierFlag_ControlEdges; - + BLI_addtail(&ob->modifiers, smd); - + modifier_unique_name(&ob->modifiers, (ModifierData*)smd); } } - - // follow path constraint needs to set the 'path' option in curves... - for (con=ob->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_FOLLOWPATH) { + + /* follow path constraint needs to set the 'path' option in curves... */ + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_FOLLOWPATH) { bFollowPathConstraint *data = con->data; - Object *obc= blo_do_versions_newlibadr(fd, lib, data->tar); - - if (obc && obc->type==OB_CURVE) { - Curve *cu= blo_do_versions_newlibadr(fd, lib, obc->data); - if (cu) cu->flag |= CU_PATH; + Object *obc = blo_do_versions_newlibadr(fd, lib, data->tar); + + if (obc && obc->type == OB_CURVE) { + Curve *cu = blo_do_versions_newlibadr(fd, lib, obc->data); + if (cu) + cu->flag |= CU_PATH; } } } } } + if (main->versionfile <= 238) { Lattice *lt; Object *ob; bArmature *arm; Mesh *me; Key *key; - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; while (sce) { if (sce->toolsettings == NULL) { sce->toolsettings = MEM_callocN(sizeof(struct ToolSettings), "Tool Settings Struct"); - sce->toolsettings->cornertype=0; - sce->toolsettings->degr = 90; + sce->toolsettings->cornertype =0; + sce->toolsettings->degr = 90; sce->toolsettings->step = 9; - sce->toolsettings->turn = 1; - sce->toolsettings->extr_offs = 1; + sce->toolsettings->turn = 1; + sce->toolsettings->extr_offs = 1; sce->toolsettings->doublimit = 0.001f; sce->toolsettings->segments = 32; sce->toolsettings->rings = 32; sce->toolsettings->vertices = 32; } - sce= sce->id.next; + sce = sce->id.next; } - for (lt=main->latt.first; lt; lt=lt->id.next) { - if (lt->fu==0.0f && lt->fv==0.0f && lt->fw==0.0f) { + for (lt = main->latt.first; lt; lt = lt->id.next) { + if (lt->fu == 0.0f && lt->fv == 0.0f && lt->fw == 0.0f) { calc_lat_fudu(lt->flag, lt->pntsu, <->fu, <->du); calc_lat_fudu(lt->flag, lt->pntsv, <->fv, <->dv); calc_lat_fudu(lt->flag, lt->pntsw, <->fw, <->dw); } } - for (ob=main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; PartEff *paf; - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Subsurf) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Subsurf) { SubsurfModifierData *smd = (SubsurfModifierData*) md; smd->flags &= ~(eSubsurfModifierFlag_Incremental|eSubsurfModifierFlag_DebugIncr); } } - if ((ob->softflag&OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) { - if (ob->softflag&OB_SB_POSTDEF) { + if ((ob->softflag & OB_SB_ENABLE) && !modifiers_findByType(ob, eModifierType_Softbody)) { + if (ob->softflag & OB_SB_POSTDEF) { md = ob->modifiers.first; - while (md && modifierType_getInfo(md->type)->type==eModifierTypeType_OnlyDeform) { + while (md && modifierType_getInfo(md->type)->type == eModifierTypeType_OnlyDeform) { md = md->next; } @@ -1976,28 +2048,29 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ob->softflag &= ~OB_SB_ENABLE; } + if (ob->pose) { bPoseChannel *pchan; bConstraint *con; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - // note, pchan->bone is also lib-link stuff + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + /* note, pchan->bone is also lib-link stuff */ if (pchan->limitmin[0] == 0.0f && pchan->limitmax[0] == 0.0f) { - pchan->limitmin[0]= pchan->limitmin[1]= pchan->limitmin[2]= -180.0f; - pchan->limitmax[0]= pchan->limitmax[1]= pchan->limitmax[2]= 180.0f; - - for (con= pchan->constraints.first; con; con= con->next) { + pchan->limitmin[0] = pchan->limitmin[1] = pchan->limitmin[2] = -180.0f; + pchan->limitmax[0] = pchan->limitmax[1] = pchan->limitmax[2] = 180.0f; + + for (con = pchan->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_KINEMATIC) { bKinematicConstraint *data = (bKinematicConstraint*)con->data; data->weight = 1.0f; data->orientweight = 1.0f; data->flag &= ~CONSTRAINT_IK_ROT; - + /* enforce conversion from old IK_TOPARENT to rootbone index */ - data->rootbone= -1; - - /* update_pose_etc handles rootbone==-1 */ + data->rootbone = -1; + + /* update_pose_etc handles rootbone == -1 */ ob->pose->flag |= POSE_RECALC; - } + } } } } @@ -2013,32 +2086,32 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) paf->omat = 1; } } - - for (arm=main->armature.first; arm; arm= arm->id.next) { + + for (arm = main->armature.first; arm; arm = arm->id.next) { bone_version_238(&arm->bonebase); arm->deformflag |= ARM_DEF_VGROUP; } - for (me=main->mesh.first; me; me= me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { if (!me->medge) { - make_edges(me, 1); /* 1 = use mface->edcode */ + BKE_mesh_make_edges(me, 1); /* 1 = use mface->edcode */ } else { - mesh_strip_loose_faces(me); + BKE_mesh_strip_loose_faces(me); } } - - for (key= main->key.first; key; key= key->id.next) { + + for (key = main->key.first; key; key = key->id.next) { KeyBlock *kb; int index = 1; - for (kb= key->block.first; kb; kb= kb->next) { - if (kb==key->refkey) { - if (kb->name[0]==0) + for (kb = key->block.first; kb; kb = kb->next) { + if (kb == key->refkey) { + if (kb->name[0] == 0) strcpy(kb->name, "Basis"); } else { - if (kb->name[0]==0) { + if (kb->name[0] == 0) { BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index); } index++; @@ -2046,73 +2119,78 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } + if (main->versionfile <= 239) { bArmature *arm; Object *ob; - Scene *sce= main->scene.first; - Camera *cam= main->camera.first; - Material *ma= main->mat.first; - int set_passepartout= 0; - + Scene *sce = main->scene.first; + Camera *cam = main->camera.first; + Material *ma = main->mat.first; + int set_passepartout = 0; + /* deformflag is local in modifier now */ - for (ob=main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; - - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Armature) { + + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Armature) { ArmatureModifierData *amd = (ArmatureModifierData*) md; - if (amd->object && amd->deformflag==0) { - Object *oba= blo_do_versions_newlibadr(fd, lib, amd->object); - arm= blo_do_versions_newlibadr(fd, lib, oba->data); - amd->deformflag= arm->deformflag; + if (amd->object && amd->deformflag == 0) { + Object *oba = blo_do_versions_newlibadr(fd, lib, amd->object); + arm = blo_do_versions_newlibadr(fd, lib, oba->data); + amd->deformflag = arm->deformflag; } } } } - + /* updating stepsize for ghost drawing */ - for (arm= main->armature.first; arm; arm= arm->id.next) { - if (arm->ghostsize==0) arm->ghostsize=1; + for (arm = main->armature.first; arm; arm = arm->id.next) { + if (arm->ghostsize == 0) + arm->ghostsize = 1; bone_version_239(&arm->bonebase); - if (arm->layer==0) arm->layer= 1; + if (arm->layer == 0) + arm->layer = 1; } - - for (;sce;sce= sce->id.next) { + + for (; sce; sce = sce->id.next) { /* make 'innervert' the default subdivide type, for backwards compat */ - sce->toolsettings->cornertype=1; - + sce->toolsettings->cornertype = 1; + if (sce->r.scemode & R_PASSEPARTOUT) { - set_passepartout= 1; + set_passepartout = 1; sce->r.scemode &= ~R_PASSEPARTOUT; } /* gauss is filter variable now */ if (sce->r.mode & R_GAUSS) { - sce->r.filtertype= R_FILTER_GAUSS; + sce->r.filtertype = R_FILTER_GAUSS; sce->r.mode &= ~R_GAUSS; } } - - for (;cam; cam= cam->id.next) { + + for (; cam; cam = cam->id.next) { if (set_passepartout) cam->flag |= CAM_SHOWPASSEPARTOUT; - + /* make sure old cameras have title safe on */ if (!(cam->flag & CAM_SHOWTITLESAFE)) cam->flag |= CAM_SHOWTITLESAFE; - + /* set an appropriate camera passepartout alpha */ - if (!(cam->passepartalpha)) cam->passepartalpha = 0.2f; + if (!(cam->passepartalpha)) + cam->passepartalpha = 0.2f; } - - for (; ma; ma= ma->id.next) { - if (ma->strand_sta==0.0f) { - ma->strand_sta= ma->strand_end= 1.0f; + + for (; ma; ma = ma->id.next) { + if (ma->strand_sta == 0.0f) { + ma->strand_sta = ma->strand_end = 1.0f; ma->mode |= MA_TANGENT_STR; } - if (ma->mode & MA_TRACEBLE) ma->mode |= MA_SHADBUF; + if (ma->mode & MA_TRACEBLE) + ma->mode |= MA_SHADBUF; } } - + if (main->versionfile <= 241) { Object *ob; Tex *tex; @@ -2122,39 +2200,44 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Material *ma; bArmature *arm; bNodeTree *ntree; - - for (wo = main->world.first; wo; wo= wo->id.next) { + + for (wo = main->world.first; wo; wo = wo->id.next) { /* Migrate to Bullet for games, except for the NaN versions */ /* People can still explicitly choose for Sumo (after 2.42 is out) */ if (main->versionfile > 225) wo->physicsEngine = WOPHY_BULLET; if (WO_AODIST == wo->aomode) - wo->aocolor= WO_AOPLAIN; + wo->aocolor = WO_AOPLAIN; } - - /* updating layers still */ - for (arm= main->armature.first; arm; arm= arm->id.next) { - bone_version_239(&arm->bonebase); - if (arm->layer==0) arm->layer= 1; - } - for (sce= main->scene.first; sce; sce= sce->id.next) { - if (sce->audio.mixrate==0) sce->audio.mixrate= 44100; - if (sce->r.xparts<2) sce->r.xparts= 4; - if (sce->r.yparts<2) sce->r.yparts= 4; + /* updating layers still */ + for (arm = main->armature.first; arm; arm = arm->id.next) { + bone_version_239(&arm->bonebase); + if (arm->layer == 0) + arm->layer = 1; + } + for (sce = main->scene.first; sce; sce = sce->id.next) { + if (sce->audio.mixrate == 0) + sce->audio.mixrate = 44100; + + if (sce->r.xparts <2 ) + sce->r.xparts = 4; + if (sce->r.yparts < 2) + sce->r.yparts = 4; + /* adds default layer */ - if (sce->r.layers.first==NULL) - scene_add_render_layer(sce, NULL); + if (sce->r.layers.first == NULL) + BKE_scene_add_render_layer(sce, NULL); else { SceneRenderLayer *srl; /* new layer flag for sky, was default for solid */ - for (srl= sce->r.layers.first; srl; srl= srl->next) { + for (srl = sce->r.layers.first; srl; srl = srl->next) { if (srl->layflag & SCE_LAY_SOLID) srl->layflag |= SCE_LAY_SKY; srl->passflag &= (SCE_PASS_COMBINED|SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR); } } - + /* node version changes */ if (sce->nodetree) ntree_version_241(sce->nodetree); @@ -2172,64 +2255,65 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (sce->r.mode & R_PANORAMA) { /* all these checks to ensure saved files with svn version keep working... */ if (sce->r.xsch < sce->r.ysch) { - Object *obc= blo_do_versions_newlibadr(fd, lib, sce->camera); - if (obc && obc->type==OB_CAMERA) { - Camera *cam= blo_do_versions_newlibadr(fd, lib, obc->data); - if (cam->lens>=10.0f) { - sce->r.xsch*= sce->r.xparts; - cam->lens*= (float)sce->r.ysch/(float)sce->r.xsch; + Object *obc = blo_do_versions_newlibadr(fd, lib, sce->camera); + if (obc && obc->type == OB_CAMERA) { + Camera *cam = blo_do_versions_newlibadr(fd, lib, obc->data); + if (cam->lens >= 10.0f) { + sce->r.xsch *= sce->r.xparts; + cam->lens *= (float)sce->r.ysch / (float)sce->r.xsch; } } } } } - - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) ntree_version_241(ntree); - - for (la= main->lamp.first; la; la= la->id.next) - if (la->buffers==0) - la->buffers= 1; - - for (tex= main->tex.first; tex; tex= tex->id.next) { - if (tex->env && tex->env->viewscale==0.0f) - tex->env->viewscale= 1.0f; -// tex->imaflag |= TEX_GAUSS_MIP; + + for (la = main->lamp.first; la; la = la->id.next) + if (la->buffers == 0) + la->buffers = 1; + + for (tex = main->tex.first; tex; tex = tex->id.next) { + if (tex->env && tex->env->viewscale == 0.0f) + tex->env->viewscale = 1.0f; + //tex->imaflag |= TEX_GAUSS_MIP; } - + /* for empty drawsize and drawtype */ - for (ob=main->object.first; ob; ob= ob->id.next) { - if (ob->empty_drawsize==0.0f) { + for (ob = main->object.first; ob; ob = ob->id.next) { + if (ob->empty_drawsize == 0.0f) { ob->empty_drawtype = OB_ARROWS; ob->empty_drawsize = 1.0; } } - - for (ma= main->mat.first; ma; ma= ma->id.next) { + + for (ma = main->mat.first; ma; ma = ma->id.next) { /* stucci returns intensity from now on */ int a; - for (a=0; amtex[a] && ma->mtex[a]->tex) { - tex= blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex); - if (tex && tex->type==TEX_STUCCI) + tex = blo_do_versions_newlibadr(fd, lib, ma->mtex[a]->tex); + if (tex && tex->type == TEX_STUCCI) ma->mtex[a]->mapto &= ~(MAP_COL|MAP_SPEC|MAP_REF); } } /* transmissivity defaults */ - if (ma->tx_falloff==0.0f) ma->tx_falloff= 1.0f; + if (ma->tx_falloff == 0.0f) + ma->tx_falloff = 1.0f; } - + /* during 2.41 images with this name were used for viewer node output, lets fix that */ if (main->versionfile == 241) { Image *ima; - for (ima= main->image.first; ima; ima= ima->id.next) - if (strcmp(ima->name, "Compositor")==0) { + for (ima = main->image.first; ima; ima = ima->id.next) + if (strcmp(ima->name, "Compositor") == 0) { strcpy(ima->id.name+2, "Viewer Node"); strcpy(ima->name, "Viewer Node"); } } } - + if (main->versionfile <= 242) { Scene *sce; bScreen *sc; @@ -2243,16 +2327,16 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) BPoint *bp; bNodeTree *ntree; int a; - - for (sc= main->screen.first; sc; sc= sc->id.next) { + + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - sa= sc->areabase.first; + sa = sc->areabase.first; while (sa) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D*) sl; if (v3d->gridsubdiv == 0) v3d->gridsubdiv = 10; } @@ -2260,45 +2344,47 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sa = sa->next; } } - - for (sce= main->scene.first; sce; sce= sce->id.next) { + + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->toolsettings->select_thresh == 0.0f) - sce->toolsettings->select_thresh= 0.01f; - if (sce->toolsettings->clean_thresh == 0.0f) + sce->toolsettings->select_thresh = 0.01f; + if (sce->toolsettings->clean_thresh == 0.0f) sce->toolsettings->clean_thresh = 0.1f; - - if (sce->r.threads==0) { + + if (sce->r.threads == 0) { if (sce->r.mode & R_THREADS) - sce->r.threads= 2; + sce->r.threads = 2; else - sce->r.threads= 1; + sce->r.threads = 1; } if (sce->nodetree) ntree_version_242(sce->nodetree); } - - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) ntree_version_242(ntree); - + /* add default radius values to old curve points */ - for (cu= main->curve.first; cu; cu= cu->id.next) { - for (nu= cu->nurb.first; nu; nu= nu->next) { + for (cu = main->curve.first; cu; cu = cu->id.next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu) { if (nu->bezt) { - for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { - if (!bezt->radius) bezt->radius= 1.0; + for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { + if (!bezt->radius) + bezt->radius = 1.0; } } else if (nu->bp) { - for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { - if (!bp->radius) bp->radius= 1.0; + for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) { + if (!bp->radius) + bp->radius = 1.0; } } } } } - - for (ob = main->object.first; ob; ob= ob->id.next) { + + for (ob = main->object.first; ob; ob = ob->id.next) { ModifierData *md; ListBase *list; list = &ob->constraints; @@ -2308,23 +2394,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { switch (curcon->type) { case CONSTRAINT_TYPE_MINMAX: { bMinMaxConstraint *data = curcon->data; - if (data->sticky==1) + if (data->sticky == 1) data->flag |= MINMAX_STICKY; - else + else data->flag &= ~MINMAX_STICKY; } break; case CONSTRAINT_TYPE_ROTLIKE: { bRotateLikeConstraint *data = curcon->data; - + /* version patch from buttons_object.c */ - if (data->flag==0) + if (data->flag == 0) data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; } break; @@ -2336,184 +2422,186 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (ob->pose) { bConstraint *curcon; bPoseChannel *pchan; - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) { switch (curcon->type) { case CONSTRAINT_TYPE_MINMAX: - { - bMinMaxConstraint *data = curcon->data; - if (data->sticky==1) - data->flag |= MINMAX_STICKY; - else - data->flag &= ~MINMAX_STICKY; - } + { + bMinMaxConstraint *data = curcon->data; + if (data->sticky == 1) + data->flag |= MINMAX_STICKY; + else + data->flag &= ~MINMAX_STICKY; + } break; case CONSTRAINT_TYPE_KINEMATIC: - { - bKinematicConstraint *data = curcon->data; - if (!(data->flag & CONSTRAINT_IK_POS)) { - data->flag |= CONSTRAINT_IK_POS; - data->flag |= CONSTRAINT_IK_STRETCH; + { + bKinematicConstraint *data = curcon->data; + if (!(data->flag & CONSTRAINT_IK_POS)) { + data->flag |= CONSTRAINT_IK_POS; + data->flag |= CONSTRAINT_IK_STRETCH; + } } - } break; case CONSTRAINT_TYPE_ROTLIKE: - { - bRotateLikeConstraint *data = curcon->data; - - /* version patch from buttons_object.c */ - if (data->flag==0) - data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; - } + { + bRotateLikeConstraint *data = curcon->data; + + /* version patch from buttons_object.c */ + if (data->flag == 0) + data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z; + } break; } } } } } - + /* copy old object level track settings to curve modifers */ - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Curve) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Curve) { CurveModifierData *cmd = (CurveModifierData*) md; - if (cmd->defaxis == 0) cmd->defaxis = ob->trackflag+1; + if (cmd->defaxis == 0) + cmd->defaxis = ob->trackflag+1; } } - + } - - for (ma = main->mat.first; ma; ma= ma->id.next) { - if (ma->shad_alpha==0.0f) - ma->shad_alpha= 1.0f; + + for (ma = main->mat.first; ma; ma = ma->id.next) { + if (ma->shad_alpha == 0.0f) + ma->shad_alpha = 1.0f; if (ma->nodetree) ntree_version_242(ma->nodetree); } - for (me=main->mesh.first; me; me=me->id.next) + for (me = main->mesh.first; me; me = me->id.next) customdata_version_242(me); - - for (group= main->group.first; group; group= group->id.next) - if (group->layer==0) - group->layer= (1<<20)-1; + + for (group = main->group.first; group; group = group->id.next) + if (group->layer == 0) + group->layer = (1<<20)-1; /* now, subversion control! */ if (main->subversionfile < 3) { Image *ima; Tex *tex; - + /* Image refactor initialize */ - for (ima= main->image.first; ima; ima= ima->id.next) { - ima->source= IMA_SRC_FILE; - ima->type= IMA_TYPE_IMAGE; - - ima->gen_x= 256; ima->gen_y= 256; - ima->gen_type= 1; - - if (0==strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name)-2)) { - ima->source= IMA_SRC_VIEWER; - ima->type= IMA_TYPE_COMPOSITE; + for (ima = main->image.first; ima; ima = ima->id.next) { + ima->source = IMA_SRC_FILE; + ima->type = IMA_TYPE_IMAGE; + + ima->gen_x = 256; ima->gen_y = 256; + ima->gen_type = 1; + + if (0 == strncmp(ima->id.name+2, "Viewer Node", sizeof(ima->id.name) - 2)) { + ima->source = IMA_SRC_VIEWER; + ima->type = IMA_TYPE_COMPOSITE; } - if (0==strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name)-2)) { - ima->source= IMA_SRC_VIEWER; - ima->type= IMA_TYPE_R_RESULT; + if (0 == strncmp(ima->id.name+2, "Render Result", sizeof(ima->id.name) - 2)) { + ima->source = IMA_SRC_VIEWER; + ima->type = IMA_TYPE_R_RESULT; } - + } - for (tex= main->tex.first; tex; tex= tex->id.next) { - if (tex->type==TEX_IMAGE && tex->ima) { - ima= blo_do_versions_newlibadr(fd, lib, tex->ima); + for (tex = main->tex.first; tex; tex = tex->id.next) { + if (tex->type == TEX_IMAGE && tex->ima) { + ima = blo_do_versions_newlibadr(fd, lib, tex->ima); if (tex->imaflag & TEX_ANIM5_) - ima->source= IMA_SRC_MOVIE; + ima->source = IMA_SRC_MOVIE; if (tex->imaflag & TEX_FIELDS_) ima->flag |= IMA_FIELDS; if (tex->imaflag & TEX_STD_FIELD_) ima->flag |= IMA_STD_FIELD; } - tex->iuser.frames= tex->frames; - tex->iuser.fie_ima= (char)tex->fie_ima; - tex->iuser.offset= tex->offset; - tex->iuser.sfra= tex->sfra; - tex->iuser.cycl= (tex->imaflag & TEX_ANIMCYCLIC_)!=0; + tex->iuser.frames = tex->frames; + tex->iuser.fie_ima = (char)tex->fie_ima; + tex->iuser.offset = tex->offset; + tex->iuser.sfra = tex->sfra; + tex->iuser.cycl = (tex->imaflag & TEX_ANIMCYCLIC_)!=0; } - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) do_version_ntree_242_2(sce->nodetree); } - for (ntree= main->nodetree.first; ntree; ntree= ntree->id.next) + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) do_version_ntree_242_2(ntree); - for (ma = main->mat.first; ma; ma= ma->id.next) + for (ma = main->mat.first; ma; ma = ma->id.next) if (ma->nodetree) do_version_ntree_242_2(ma->nodetree); - - for (sc= main->screen.first; sc; sc= sc->id.next) { + + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_IMAGE) - ((SpaceImage *)sl)->iuser.fie_ima= 2; - else if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_IMAGE) + ((SpaceImage *)sl)->iuser.fie_ima = 2; + else if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; BGpic *bgpic; - for (bgpic= v3d->bgpicbase.first; bgpic; bgpic= bgpic->next) - bgpic->iuser.fie_ima= 2; + for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) + bgpic->iuser.fie_ima = 2; } } } } } - + if (main->subversionfile < 4) { - for (sce= main->scene.first; sce; sce= sce->id.next) { - sce->r.bake_mode= 1; /* prevent to include render stuff here */ - sce->r.bake_filter= 2; - sce->r.bake_osa= 5; - sce->r.bake_flag= R_BAKE_CLEAR; + for (sce = main->scene.first; sce; sce = sce->id.next) { + sce->r.bake_mode = 1; /* prevent to include render stuff here */ + sce->r.bake_filter = 2; + sce->r.bake_osa = 5; + sce->r.bake_flag = R_BAKE_CLEAR; } } if (main->subversionfile < 5) { - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { /* improved triangle to quad conversion settings */ - if (sce->toolsettings->jointrilimit==0.0f) - sce->toolsettings->jointrilimit= 0.8f; + if (sce->toolsettings->jointrilimit == 0.0f) + sce->toolsettings->jointrilimit = 0.8f; } } } + if (main->versionfile <= 243) { - Object *ob= main->object.first; + Object *ob = main->object.first; Material *ma; - for (ma=main->mat.first; ma; ma= ma->id.next) { - if (ma->sss_scale==0.0f) { - ma->sss_radius[0]= 1.0f; - ma->sss_radius[1]= 1.0f; - ma->sss_radius[2]= 1.0f; - ma->sss_col[0]= 0.8f; - ma->sss_col[1]= 0.8f; - ma->sss_col[2]= 0.8f; - ma->sss_error= 0.05f; - ma->sss_scale= 0.1f; - ma->sss_ior= 1.3f; - ma->sss_colfac= 1.0f; - ma->sss_texfac= 0.0f; + for (ma = main->mat.first; ma; ma = ma->id.next) { + if (ma->sss_scale == 0.0f) { + ma->sss_radius[0] = 1.0f; + ma->sss_radius[1] = 1.0f; + ma->sss_radius[2] = 1.0f; + ma->sss_col[0] = 0.8f; + ma->sss_col[1] = 0.8f; + ma->sss_col[2] = 0.8f; + ma->sss_error = 0.05f; + ma->sss_scale = 0.1f; + ma->sss_ior = 1.3f; + ma->sss_colfac = 1.0f; + ma->sss_texfac = 0.0f; } - if (ma->sss_front==0 && ma->sss_back==0) { - ma->sss_front= 1.0f; - ma->sss_back= 1.0f; + if (ma->sss_front == 0 && ma->sss_back == 0) { + ma->sss_front = 1.0f; + ma->sss_back = 1.0f; } - if (ma->sss_col[0]==0 && ma->sss_col[1]==0 && ma->sss_col[2]==0) { - ma->sss_col[0]= ma->r; - ma->sss_col[1]= ma->g; - ma->sss_col[2]= ma->b; + if (ma->sss_col[0] == 0 && ma->sss_col[1] == 0 && ma->sss_col[2] == 0) { + ma->sss_col[0] = ma->r; + ma->sss_col[1] = ma->g; + ma->sss_col[2] = ma->b; } } - - for (; ob; ob= ob->id.next) { + + for (; ob; ob = ob->id.next) { bDeformGroup *curdef; - - for (curdef= ob->defbase.first; curdef; curdef=curdef->next) { + + for (curdef = ob->defbase.first; curdef; curdef = curdef->next) { /* replace an empty-string name with unique name */ if (curdef->name[0] == '\0') { defgroup_unique_name(curdef, ob); @@ -2524,8 +2612,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) ModifierData *md; /* translate old mirror modifier axis values to new flags */ - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Mirror) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Mirror) { MirrorModifierData *mmd = (MirrorModifierData*) md; switch (mmd->axis) { @@ -2545,40 +2633,40 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + /* render layer added, this is not the active layer */ if (main->versionfile <= 243 || main->subversionfile < 2) { Mesh *me; - for (me=main->mesh.first; me; me=me->id.next) + for (me = main->mesh.first; me; me = me->id.next) customdata_version_243(me); - } + } } - + if (main->versionfile <= 244) { Scene *sce; bScreen *sc; Lamp *la; World *wrld; - + if (main->versionfile != 244 || main->subversionfile < 2) { - for (sce= main->scene.first; sce; sce= sce->id.next) + for (sce = main->scene.first; sce; sce = sce->id.next) sce->r.mode |= R_SSS; /* correct older action editors - incorrect scrolling */ - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - sa= sc->areabase.first; + sa = sc->areabase.first; while (sa) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_ACTION) { - SpaceAction *saction= (SpaceAction*) sl; - + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_ACTION) { + SpaceAction *saction = (SpaceAction*) sl; + saction->v2d.tot.ymin = -1000.0; saction->v2d.tot.ymax = 0.0; - + saction->v2d.cur.ymin = -75.0; saction->v2d.cur.ymax = 5.0; } @@ -2587,29 +2675,30 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - if (main->versionfile != 244 || main->subversionfile < 3) { + + if (main->versionfile != 244 || main->subversionfile < 3) { /* constraints recode version patch used to be here. Moved to 245 now... */ - - - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + + for (wrld = main->world.first; wrld; wrld = wrld->id.next) { if (wrld->mode & WO_AMB_OCC) wrld->ao_samp_method = WO_AOSAMP_CONSTANT; else wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY; - + wrld->ao_adapt_thresh = 0.005f; } - - for (la=main->lamp.first; la; la= la->id.next) { + + for (la = main->lamp.first; la; la = la->id.next) { if (la->type == LA_AREA) la->ray_samp_method = LA_SAMP_CONSTANT; else la->ray_samp_method = LA_SAMP_HALTON; - + la->adapt_thresh = 0.001f; } } } + if (main->versionfile <= 245) { Scene *sce; Object *ob; @@ -2623,69 +2712,69 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Tex *tex; ModifierData *md; ParticleSystem *psys; - + /* unless the file was created 2.44.3 but not 2.45, update the constraints */ - if ( !(main->versionfile==244 && main->subversionfile==3) && - ((main->versionfile<245) || (main->versionfile==245 && main->subversionfile==0)) ) + if (!(main->versionfile == 244 && main->subversionfile == 3) && + ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile == 0)) ) { - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { ListBase *list; list = &ob->constraints; - + /* fix up constraints due to constraint recode changes (originally at 2.44.3) */ if (list) { bConstraint *curcon; - for (curcon = list->first; curcon; curcon=curcon->next) { + for (curcon = list->first; curcon; curcon = curcon->next) { /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */ if (curcon->flag & 0x20) { curcon->ownspace = CONSTRAINT_SPACE_LOCAL; curcon->tarspace = CONSTRAINT_SPACE_LOCAL; } - + switch (curcon->type) { case CONSTRAINT_TYPE_LOCLIMIT: { - bLocLimitConstraint *data= (bLocLimitConstraint *)curcon->data; - + bLocLimitConstraint *data = (bLocLimitConstraint *) curcon->data; + /* old limit without parent option for objects */ if (data->flag2) curcon->ownspace = CONSTRAINT_SPACE_LOCAL; } - break; - } + break; + } } } - + /* correctly initialize constinv matrix */ unit_m4(ob->constinv); - + if (ob->type == OB_ARMATURE) { if (ob->pose) { bConstraint *curcon; bPoseChannel *pchan; - - for (pchan = ob->pose->chanbase.first; pchan; pchan=pchan->next) { + + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* make sure constraints are all up to date */ - for (curcon = pchan->constraints.first; curcon; curcon=curcon->next) { + for (curcon = pchan->constraints.first; curcon; curcon = curcon->next) { /* old CONSTRAINT_LOCAL check -> convert to CONSTRAINT_SPACE_LOCAL */ if (curcon->flag & 0x20) { curcon->ownspace = CONSTRAINT_SPACE_LOCAL; curcon->tarspace = CONSTRAINT_SPACE_LOCAL; } - + switch (curcon->type) { case CONSTRAINT_TYPE_ACTION: { - bActionConstraint *data= (bActionConstraint *)curcon->data; - + bActionConstraint *data = (bActionConstraint *) curcon->data; + /* 'data->local' used to mean that target was in local-space */ if (data->local) curcon->tarspace = CONSTRAINT_SPACE_LOCAL; - } - break; + } + break; } } - + /* correctly initialize constinv matrix */ unit_m4(pchan->constinv); } @@ -2693,44 +2782,44 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + /* fix all versions before 2.45 */ if (main->versionfile != 245) { /* repair preview from 242 - 244*/ - for (ima= main->image.first; ima; ima= ima->id.next) { + for (ima = main->image.first; ima; ima = ima->id.next) { ima->preview = NULL; } } /* add point caches */ - for (ob=main->object.first; ob; ob=ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->soft && !ob->soft->pointcache) - ob->soft->pointcache= BKE_ptcache_add(&ob->soft->ptcaches); + ob->soft->pointcache = BKE_ptcache_add(&ob->soft->ptcaches); - for (psys=ob->particlesystem.first; psys; psys=psys->next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { if (psys->pointcache) { - if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE)==0) { + if (psys->pointcache->flag & PTCACHE_BAKED && (psys->pointcache->flag & PTCACHE_DISK_CACHE) == 0) { printf("Old memory cache isn't supported for particles, so re-bake the simulation!\n"); psys->pointcache->flag &= ~PTCACHE_BAKED; } } else - psys->pointcache= BKE_ptcache_add(&psys->ptcaches); + psys->pointcache = BKE_ptcache_add(&psys->ptcaches); } - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Cloth) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Cloth) { ClothModifierData *clmd = (ClothModifierData*) md; if (!clmd->point_cache) - clmd->point_cache= BKE_ptcache_add(&clmd->ptcaches); + clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches); } } } /* Copy over old per-level multires vertex data * into a single vertex array in struct Multires */ - for (me = main->mesh.first; me; me=me->id.next) { + for (me = main->mesh.first; me; me = me->id.next) { if (me->mr && !me->mr->verts) { MultiresLevel *lvl = me->mr->levels.last; if (lvl) { @@ -2744,99 +2833,99 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + if (main->versionfile != 245 || main->subversionfile < 1) { - for (la=main->lamp.first; la; la= la->id.next) { - if (la->mode & LA_QUAD) la->falloff_type = LA_FALLOFF_SLIDERS; - else la->falloff_type = LA_FALLOFF_INVLINEAR; - + for (la = main->lamp.first; la; la = la->id.next) { + if (la->mode & LA_QUAD) + la->falloff_type = LA_FALLOFF_SLIDERS; + else + la->falloff_type = LA_FALLOFF_INVLINEAR; + if (la->curfalloff == NULL) { la->curfalloff = curvemapping_add(1, 0.0f, 1.0f, 1.0f, 0.0f); curvemapping_initialize(la->curfalloff); } } - } - - for (ma=main->mat.first; ma; ma= ma->id.next) { + } + + for (ma = main->mat.first; ma; ma = ma->id.next) { if (ma->samp_gloss_mir == 0) { - ma->gloss_mir = ma->gloss_tra= 1.0f; + ma->gloss_mir = ma->gloss_tra = 1.0f; ma->aniso_gloss_mir = 1.0f; - ma->samp_gloss_mir = ma->samp_gloss_tra= 18; + ma->samp_gloss_mir = ma->samp_gloss_tra = 18; ma->adapt_thresh_mir = ma->adapt_thresh_tra = 0.005f; ma->dist_mir = 0.0f; ma->fadeto_mir = MA_RAYMIR_FADETOSKY; } if (ma->strand_min == 0.0f) - ma->strand_min= 1.0f; + ma->strand_min = 1.0f; } - for (part=main->particle.first; part; part=part->id.next) { - if (part->ren_child_nbr==0) - part->ren_child_nbr= part->child_nbr; + for (part = main->particle.first; part; part = part->id.next) { + if (part->ren_child_nbr == 0) + part->ren_child_nbr = part->child_nbr; - if (part->simplify_refsize==0) { - part->simplify_refsize= 1920; - part->simplify_rate= 1.0f; - part->simplify_transition= 0.1f; - part->simplify_viewport= 0.8f; + if (part->simplify_refsize == 0) { + part->simplify_refsize = 1920; + part->simplify_rate = 1.0f; + part->simplify_transition = 0.1f; + part->simplify_viewport = 0.8f; } } - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + for (wrld = main->world.first; wrld; wrld = wrld->id.next) { if (wrld->ao_approx_error == 0.0f) - wrld->ao_approx_error= 0.25f; + wrld->ao_approx_error = 0.25f; } - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->nodetree) ntree_version_245(fd, lib, sce->nodetree); if (sce->r.simplify_shadowsamples == 0) { - sce->r.simplify_subsurf= 6; - sce->r.simplify_particles= 1.0f; - sce->r.simplify_shadowsamples= 16; - sce->r.simplify_aosss= 1.0f; + sce->r.simplify_subsurf = 6; + sce->r.simplify_particles = 1.0f; + sce->r.simplify_shadowsamples = 16; + sce->r.simplify_aosss = 1.0f; } if (sce->r.cineongamma == 0) { - sce->r.cineonblack= 95; - sce->r.cineonwhite= 685; - sce->r.cineongamma= 1.7f; + sce->r.cineonblack = 95; + sce->r.cineonwhite = 685; + sce->r.cineongamma = 1.7f; } } - for (ntree=main->nodetree.first; ntree; ntree= ntree->id.next) + for (ntree = main->nodetree.first; ntree; ntree = ntree->id.next) ntree_version_245(fd, lib, ntree); /* fix for temporary flag changes during 245 cycle */ - for (ima= main->image.first; ima; ima= ima->id.next) { + for (ima = main->image.first; ima; ima = ima->id.next) { if (ima->flag & IMA_OLD_PREMUL) { ima->flag &= ~IMA_OLD_PREMUL; ima->flag |= IMA_DO_PREMUL; } } - for (tex=main->tex.first; tex; tex=tex->id.next) { + for (tex = main->tex.first; tex; tex = tex->id.next) { if (tex->iuser.flag & IMA_OLD_PREMUL) { tex->iuser.flag &= ~IMA_OLD_PREMUL; tex->iuser.flag |= IMA_DO_PREMUL; - } - ima= blo_do_versions_newlibadr(fd, lib, tex->ima); + ima = blo_do_versions_newlibadr(fd, lib, tex->ima); if (ima && (tex->iuser.flag & IMA_DO_PREMUL)) { ima->flag &= ~IMA_OLD_PREMUL; ima->flag |= IMA_DO_PREMUL; } } } - - /* sanity check for skgen - * */ + + /* sanity check for skgen */ { Scene *sce; - for (sce=main->scene.first; sce; sce = sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[1] || sce->toolsettings->skgen_subdivisions[0] == sce->toolsettings->skgen_subdivisions[2] || sce->toolsettings->skgen_subdivisions[1] == sce->toolsettings->skgen_subdivisions[2]) @@ -2847,30 +2936,29 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 2)) { Image *ima; /* initialize 1:1 Aspect */ - for (ima= main->image.first; ima; ima= ima->id.next) { - ima->aspx = ima->aspy = 1.0f; + for (ima = main->image.first; ima; ima = ima->id.next) { + ima->aspx = ima->aspy = 1.0f; } - } if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 4)) { bArmature *arm; ModifierData *md; Object *ob; - - for (arm= main->armature.first; arm; arm= arm->id.next) + + for (arm = main->armature.first; arm; arm = arm->id.next) arm->deformflag |= ARM_DEF_B_BONE_REST; - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (md=ob->modifiers.first; md; md=md->next) { - if (md->type==eModifierType_Armature) - ((ArmatureModifierData*)md)->deformflag |= ARM_DEF_B_BONE_REST; + + for (ob = main->object.first; ob; ob = ob->id.next) { + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Armature) + ((ArmatureModifierData*) md)->deformflag |= ARM_DEF_B_BONE_REST; } } } @@ -2878,55 +2966,55 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 5)) { /* foreground color needs to be something other then black */ Scene *sce; - for (sce= main->scene.first; sce; sce=sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->r.fg_stamp[0] = sce->r.fg_stamp[1] = sce->r.fg_stamp[2] = 0.8f; sce->r.fg_stamp[3] = 1.0f; /* don't use text alpha yet */ sce->r.bg_stamp[3] = 0.25f; /* make sure the background has full alpha */ } } - + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 6)) { Scene *sce; /* fix frs_sec_base */ - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { if (sce->r.frs_sec_base == 0) { sce->r.frs_sec_base = 1; } } } - + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 7)) { Object *ob; bPoseChannel *pchan; bConstraint *con; bConstraintTarget *ct; - - for (ob = main->object.first; ob; ob= ob->id.next) { + + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->pose) { - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchan->next) { - for (con=pchan->constraints.first; con; con=con->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { if (con->type == CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data= (bPythonConstraint *)con->data; + bPythonConstraint *data = (bPythonConstraint *)con->data; if (data->tar) { /* version patching needs to be done */ - ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - + ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); + ct->tar = data->tar; BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); ct->space = con->tarspace; - + BLI_addtail(&data->targets, ct); data->tarnum++; - + /* clear old targets to avoid problems */ data->tar = NULL; - data->subtarget[0]= '\0'; + data->subtarget[0] = '\0'; } } else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; - + bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; + /* new headtail functionality makes Bone-Tip function obsolete */ if (data->flag & LOCLIKE_TIP) con->headtail = 1.0f; @@ -2934,29 +3022,29 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - - for (con=ob->constraints.first; con; con=con->next) { - if (con->type==CONSTRAINT_TYPE_PYTHON) { - bPythonConstraint *data= (bPythonConstraint *)con->data; + + for (con = ob->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_PYTHON) { + bPythonConstraint *data = (bPythonConstraint *)con->data; if (data->tar) { /* version patching needs to be done */ - ct= MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); - + ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); + ct->tar = data->tar; BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); ct->space = con->tarspace; - + BLI_addtail(&data->targets, ct); data->tarnum++; - + /* clear old targets to avoid problems */ data->tar = NULL; - data->subtarget[0]= '\0'; + data->subtarget[0] = '\0'; } } else if (con->type == CONSTRAINT_TYPE_LOCLIKE) { - bLocateLikeConstraint *data= (bLocateLikeConstraint *)con->data; - + bLocateLikeConstraint *data = (bLocateLikeConstraint *)con->data; + /* new headtail functionality makes Bone-Tip function obsolete */ if (data->flag & LOCLIKE_TIP) con->headtail = 1.0f; @@ -2967,7 +3055,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) SoftBody *sb = ob->soft; int k; - for (k=0; ktotkey; k++) { + for (k = 0; k < sb->totkey; k++) { if (sb->keys[k]) MEM_freeN(sb->keys[k]); } @@ -2983,14 +3071,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 8)) { Scene *sce; Object *ob; - PartEff *paf=NULL; + PartEff *paf = NULL; - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->soft && ob->soft->keys) { SoftBody *sb = ob->soft; int k; - for (k=0; ktotkey; k++) { + for (k = 0; k < sb->totkey; k++) { if (sb->keys[k]) MEM_freeN(sb->keys[k]); } @@ -3013,23 +3101,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) psys->pointcache = BKE_ptcache_add(&psys->ptcaches); part = psys->part = psys_new_settings("ParticleSettings", main); - + /* needed for proper libdata lookup */ blo_do_versions_oldnewmap_insert(fd->libmap, psys->part, psys->part, 0); - part->id.lib= ob->id.lib; + part->id.lib = ob->id.lib; part->id.us--; part->id.flag |= (ob->id.flag & LIB_NEEDLINK); - - psys->totpart=0; - psys->flag= PSYS_ENABLED|PSYS_CURRENT; + + psys->totpart = 0; + psys->flag = PSYS_ENABLED|PSYS_CURRENT; BLI_addtail(&ob->particlesystem, psys); - md= modifier_new(eModifierType_ParticleSystem); + md = modifier_new(eModifierType_ParticleSystem); BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); - psmd= (ParticleSystemModifierData*) md; - psmd->psys=psys; + psmd = (ParticleSystemModifierData*) md; + psmd->psys = psys; BLI_addtail(&ob->modifiers, md); /* convert settings from old particle system */ @@ -3077,7 +3165,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } part->rotmode = PART_ROT_VEL; - + part->flag |= (paf->flag & PAF_BSPLINE) ? PART_HAIR_BSPLINE : 0; part->flag |= (paf->flag & PAF_TRAND) ? PART_TRAND : 0; part->flag |= (paf->flag & PAF_EDISTR) ? PART_EDISTR : 0; @@ -3094,7 +3182,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (ob->transflag & OB_DUPLIVERTS) { Object *dup = main->object.first; - for (; dup; dup= dup->id.next) { + for (; dup; dup = dup->id.next) { if (ob == blo_do_versions_newlibadr(fd, lib, dup->parent)) { part->dup_ob = dup; ob->transflag |= OB_DUPLIPARTS; @@ -3108,7 +3196,6 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim); if (fluidmd && fluidmd->fss && fluidmd->fss->type == OB_FLUIDSIM_PARTICLE) @@ -3121,24 +3208,24 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } - for (sce= main->scene.first; sce; sce=sce->id.next) { - ParticleEditSettings *pset= &sce->toolsettings->particle; + for (sce = main->scene.first; sce; sce = sce->id.next) { + ParticleEditSettings *pset = &sce->toolsettings->particle; int a; if (pset->brush[0].size == 0) { - pset->flag= PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; - pset->emitterdist= 0.25f; - pset->totrekey= 5; - pset->totaddkey= 5; - pset->brushtype= PE_BRUSH_NONE; + pset->flag = PE_KEEP_LENGTHS|PE_LOCK_FIRST|PE_DEFLECT_EMITTER; + pset->emitterdist = 0.25f; + pset->totrekey = 5; + pset->totaddkey = 5; + pset->brushtype = PE_BRUSH_NONE; - for (a=0; abrush[a].strength= 50; - pset->brush[a].size= 50; - pset->brush[a].step= 10; + for (a = 0; a < PE_TOT_BRUSH; a++) { + pset->brush[a].strength = 50; + pset->brush[a].size = 50; + pset->brush[a].step = 10; } - pset->brush[PE_BRUSH_CUT].strength= 100; + pset->brush[PE_BRUSH_CUT].strength = 100; } } } @@ -3146,45 +3233,47 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Material *ma; int a; - for (ma=main->mat.first; ma; ma= ma->id.next) + for (ma = main->mat.first; ma; ma = ma->id.next) if (ma->mode & MA_NORMAP_TANG) - for (a=0; amtex[a] && ma->mtex[a]->tex) ma->mtex[a]->normapspace = MTEX_NSPACE_TANGENT; } - + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 10)) { Object *ob; - + /* dupliface scale */ - for (ob= main->object.first; ob; ob= ob->id.next) + for (ob = main->object.first; ob; ob = ob->id.next) ob->dupfacesca = 1.0f; } - + if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 11)) { Object *ob; bActionStrip *strip; - - /* nla-strips - scale */ - for (ob= main->object.first; ob; ob= ob->id.next) { - for (strip= ob->nlastrips.first; strip; strip= strip->next) { + + /* nla-strips - scale */ + for (ob = main->object.first; ob; ob = ob->id.next) { + for (strip = ob->nlastrips.first; strip; strip = strip->next) { float length, actlength, repeat; - + if (strip->flag & ACTSTRIP_USESTRIDE) - repeat= 1.0f; + repeat = 1.0f; else - repeat= strip->repeat; - + repeat = strip->repeat; + length = strip->end-strip->start; - if (length == 0.0f) length= 1.0f; + if (length == 0.0f) + length = 1.0f; actlength = strip->actend-strip->actstart; - + strip->scale = length / (repeat * actlength); - if (strip->scale == 0.0f) strip->scale= 1.0f; - } + if (strip->scale == 0.0f) + strip->scale = 1.0f; + } if (ob->soft) { ob->soft->inpush = ob->soft->inspring; - ob->soft->shearstiff = 1.0f; + ob->soft->shearstiff = 1.0f; } } } @@ -3192,8 +3281,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 14)) { Scene *sce; Sequence *seq; - - for (sce=main->scene.first; sce; sce=sce->id.next) { + + for (sce = main->scene.first; sce; sce = sce->id.next) { SEQ_BEGIN (sce->ed, seq) { if (seq->blend_mode == 0) @@ -3202,8 +3291,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) SEQ_END } } - - /*fix broken group lengths in id properties*/ + + /* fix broken group lengths in id properties */ if ((main->versionfile < 245) || (main->versionfile == 245 && main->subversionfile < 15)) { idproperties_fix_group_lengths(main->scene); idproperties_fix_group_lengths(main->library); @@ -3230,7 +3319,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) idproperties_fix_group_lengths(main->action); idproperties_fix_group_lengths(main->nodetree); idproperties_fix_group_lengths(main->brush); - idproperties_fix_group_lengths(main->particle); + idproperties_fix_group_lengths(main->particle); } /* sun/sky */ @@ -3239,10 +3328,10 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) bActuator *act; /* dRot actuator change direction in 2.46 */ - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + for (ob = main->object.first; ob; ob = ob->id.next) { + for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_OBJECT) { - bObjectActuator *ba= act->data; + bObjectActuator *ba = act->data; ba->drot[0] = -ba->drot[0]; ba->drot[1] = -ba->drot[1]; @@ -3251,39 +3340,39 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - - // convert fluids to modifier + + /* convert fluids to modifier */ if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { Object *ob; - - for (ob = main->object.first; ob; ob= ob->id.next) { + + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->fluidsimSettings) { FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifier_new(eModifierType_Fluidsim); BLI_addhead(&ob->modifiers, (ModifierData *)fluidmd); - + MEM_freeN(fluidmd->fss); fluidmd->fss = MEM_dupallocN(ob->fluidsimSettings); fluidmd->fss->ipo = blo_do_versions_newlibadr_us(fd, ob->id.lib, ob->fluidsimSettings->ipo); MEM_freeN(ob->fluidsimSettings); - + fluidmd->fss->lastgoodframe = INT_MAX; fluidmd->fss->flag = 0; fluidmd->fss->meshVelocities = NULL; } } } - + if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { Mesh *me; - for (me=main->mesh.first; me; me= me->id.next) + for (me = main->mesh.first; me; me = me->id.next) alphasort_version_246(fd, lib, me); } - + if (main->versionfile < 246 || (main->versionfile == 246 && main->subversionfile < 1)) { Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->pd && (ob->pd->forcefield == PFIELD_WIND)) ob->pd->f_noise = 0.0f; } @@ -3291,7 +3380,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 2)) { Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { ob->gameflag |= OB_COLLISION; ob->margin = 0.06f; } @@ -3299,9 +3388,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 3)) { Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { - // Starting from subversion 3, ACTOR is a separate feature. - // Before it was conditioning all the other dynamic flags + for (ob = main->object.first; ob; ob = ob->id.next) { + /* Starting from subversion 3, ACTOR is a separate feature. + * Before it was conditioning all the other dynamic flags */ if (!(ob->gameflag & OB_ACTOR)) ob->gameflag &= ~(OB_GHOST|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_COLLISION_RESPONSE); /* suitable default for older files */ @@ -3309,23 +3398,23 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 5)) { - Lamp *la= main->lamp.first; - for (; la; la= la->id.next) { - la->skyblendtype= MA_RAMP_ADD; - la->skyblendfac= 1.0f; + Lamp *la = main->lamp.first; + for (; la; la = la->id.next) { + la->skyblendtype = MA_RAMP_ADD; + la->skyblendfac = 1.0f; } } - + /* set the curve radius interpolation to 2.47 default - easy */ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 6)) { Curve *cu; Nurb *nu; - - for (cu= main->curve.first; cu; cu= cu->id.next) { - for (nu= cu->nurb.first; nu; nu= nu->next) { + + for (cu = main->curve.first; cu; cu = cu->id.next) { + for (nu = cu->nurb.first; nu; nu = nu->next) { if (nu) { nu->radius_interp = 3; - + /* resolu and resolv are now used differently for surfaces * rather than using the resolution to define the entire number of divisions, * use it for the number of divisions per segment @@ -3338,13 +3427,14 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } + /* direction constraint actuators were always local in previous version */ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 7)) { bActuator *act; Object *ob; - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + + for (ob = main->object.first; ob; ob = ob->id.next) { + for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_CONSTRAINT) { bConstraintActuator *coa = act->data; if (coa->type == ACT_CONST_TYPE_DIST) { @@ -3356,21 +3446,22 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 9)) { - Lamp *la= main->lamp.first; - for (; la; la= la->id.next) { - la->sky_exposure= 1.0f; + Lamp *la = main->lamp.first; + for (; la; la = la->id.next) { + la->sky_exposure = 1.0f; } } - + /* BGE message actuators needed OB prefix, very confusing */ if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) { bActuator *act; Object *ob; - - for (ob = main->object.first; ob; ob= ob->id.next) { - for (act= ob->actuators.first; act; act= act->next) { + + for (ob = main->object.first; ob; ob = ob->id.next) { + for (act = ob->actuators.first; act; act = act->next) { if (act->type == ACT_MESSAGE) { bMessageActuator *msgAct = (bMessageActuator *) act->data; + if (BLI_strnlen(msgAct->toPropName, 3) > 2) { /* strip first 2 chars, would have only worked if these were OB anyway */ memmove(msgAct->toPropName, msgAct->toPropName + 2, sizeof(msgAct->toPropName) - 2); @@ -3386,7 +3477,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 248) { Lamp *la; - for (la=main->lamp.first; la; la= la->id.next) { + for (la = main->lamp.first; la; la = la->id.next) { if (la->atm_turbidity == 0.0f) { la->sun_effect_type = 0; la->horizon_brightness = 1.0f; @@ -3405,9 +3496,9 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) { Scene *sce; - + /* Note, these will need to be added for painting */ - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->toolsettings->imapaint.seam_bleed = 2; sce->toolsettings->imapaint.normal_angle = 80; @@ -3427,47 +3518,48 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sce->toolsettings->skgen_subdivisions[1] = SKGEN_SUB_LENGTH; sce->toolsettings->skgen_subdivisions[2] = SKGEN_SUB_ANGLE; - + sce->toolsettings->skgen_retarget_angle_weight = 1.0f; sce->toolsettings->skgen_retarget_length_weight = 1.0f; sce->toolsettings->skgen_retarget_distance_weight = 1.0f; - + /* Skeleton Sketching */ sce->toolsettings->bone_sketching = 0; sce->toolsettings->skgen_retarget_roll = SK_RETARGET_ROLL_VIEW; } } + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 3)) { bScreen *sc; - + /* adjust default settings for Animation Editors */ - for (sc= main->screen.first; sc; sc= sc->id.next) { + for (sc = main->screen.first; sc; sc = sc->id.next) { ScrArea *sa; - - for (sa= sc->areabase.first; sa; sa= sa->next) { + + for (sa = sc->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - - for (sl= sa->spacedata.first; sl; sl= sl->next) { + + for (sl = sa->spacedata.first; sl; sl = sl->next) { switch (sl->spacetype) { case SPACE_ACTION: - { - SpaceAction *sact= (SpaceAction *)sl; - - sact->mode= SACTCONT_DOPESHEET; - sact->autosnap= SACTSNAP_FRAME; - } + { + SpaceAction *sact = (SpaceAction *)sl; + + sact->mode = SACTCONT_DOPESHEET; + sact->autosnap = SACTSNAP_FRAME; + } break; case SPACE_IPO: - { - SpaceIpo *sipo= (SpaceIpo *)sl; - sipo->autosnap= SACTSNAP_FRAME; - } + { + SpaceIpo *sipo = (SpaceIpo *)sl; + sipo->autosnap = SACTSNAP_FRAME; + } break; case SPACE_NLA: - { - SpaceNla *snla= (SpaceNla *)sl; - snla->autosnap= SACTSNAP_FRAME; - } + { + SpaceNla *snla = (SpaceNla *)sl; + snla->autosnap = SACTSNAP_FRAME; + } break; } } @@ -3479,18 +3571,18 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) Object *ob; /* Adjustments needed after Bullets update */ - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { ob->damping *= 0.635f; ob->rdamping = 0.1f + (0.8f * ob->rdamping); } } - + if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 4)) { Scene *sce; World *wrld; /* Dome (Fisheye) default parameters */ - for (sce= main->scene.first; sce; sce= sce->id.next) { + for (sce = main->scene.first; sce; sce = sce->id.next) { sce->r.domeangle = 180; sce->r.domemode = 1; sce->r.domeres = 4; @@ -3498,7 +3590,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) sce->r.dometilt = 0; } /* DBVT culling by default */ - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + for (wrld = main->world.first; wrld; wrld = wrld->id.next) { wrld->mode |= WO_DBVT_CULLING; wrld->occlusionRes = 128; } @@ -3507,12 +3599,13 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 5)) { Object *ob; World *wrld; - for (ob = main->object.first; ob; ob= ob->id.next) { - ob->m_contactProcessingThreshold = 1.0f; //pad3 is used for m_contactProcessingThreshold + for (ob = main->object.first; ob; ob = ob->id.next) { + /* pad3 is used for m_contactProcessingThreshold */ + ob->m_contactProcessingThreshold = 1.0f; if (ob->parent) { /* check if top parent has compound shape set and if yes, set this object * to compound shaper as well (was the behavior before, now it's optional) */ - Object *parent= blo_do_versions_newlibadr(fd, lib, ob->parent); + Object *parent = blo_do_versions_newlibadr(fd, lib, ob->parent); while (parent && parent != ob && parent->parent != NULL) { parent = blo_do_versions_newlibadr(fd, lib, parent->parent); } @@ -3522,31 +3615,31 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } } } - for (wrld=main->world.first; wrld; wrld= wrld->id.next) { + for (wrld = main->world.first; wrld; wrld = wrld->id.next) { wrld->ticrate = 60; wrld->maxlogicstep = 5; wrld->physubstep = 1; wrld->maxphystep = 5; } } - - // correct introduce of seed for wind force + + /* correct introduce of seed for wind force */ if (main->versionfile < 249 && main->subversionfile < 1) { Object *ob; - for (ob = main->object.first; ob; ob= ob->id.next) { + for (ob = main->object.first; ob; ob = ob->id.next) { if (ob->pd) - ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer()))+1) % 128; + ob->pd->seed = ((unsigned int)(ceil(PIL_check_seconds_timer())) + 1) % 128; } - + } if (main->versionfile < 249 && main->subversionfile < 2) { - Scene *sce= main->scene.first; + Scene *sce = main->scene.first; Sequence *seq; Editing *ed; - + while (sce) { - ed= sce->ed; + ed = sce->ed; if (ed) { SEQP_BEGIN (ed, seq) { @@ -3556,15 +3649,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *main) } SEQ_END } - - sce= sce->id.next; + + sce = sce->id.next; } - } - - /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ - /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ - - /* don't forget to set version number in blender.c! */ } - diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c7bd33f5fad..35347ae40a3 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -153,6 +153,7 @@ Any case: direct data is ALWAYS after the lib block #include "BKE_node.h" #include "BKE_report.h" #include "BKE_sequencer.h" +#include "BKE_subsurf.h" #include "BKE_utildefines.h" #include "BKE_modifier.h" #include "BKE_fcurve.h" @@ -734,6 +735,11 @@ static void write_nodetree(WriteData *wd, bNodeTree *ntree) for (sock=node->inputs.first; sock; sock=sock->next) writestruct(wd, DATA, "NodeImageMultiFileSocket", 1, sock->storage); } + if (node->type==CMP_NODE_IMAGE) { + /* write extra socket info */ + for (sock=node->outputs.first; sock; sock=sock->next) + writestruct(wd, DATA, "NodeImageLayer", 1, sock->storage); + } } for (link= ntree->links.first; link; link= link->next) @@ -1272,7 +1278,7 @@ static void write_pose(WriteData *wd, bPose *pose) /* write IK param */ if (pose->ikparam) { - char *structname = (char *)get_ikparam_name(pose); + char *structname = (char *)BKE_pose_ikparam_get_name(pose); if (structname) writestruct(wd, DATA, structname, 1, pose->ikparam); } @@ -1655,6 +1661,24 @@ static void write_mdisps(WriteData *wd, int count, MDisps *mdlist, int external) } } +static void write_grid_paint_mask(WriteData *wd, int count, GridPaintMask *grid_paint_mask) +{ + if(grid_paint_mask) { + int i; + + writestruct(wd, DATA, "GridPaintMask", count, grid_paint_mask); + for(i = 0; i < count; ++i) { + GridPaintMask *gpm = &grid_paint_mask[i]; + if(gpm->data) { + const int gridsize = ccg_gridsize(gpm->level); + writedata(wd, DATA, + sizeof(*gpm->data) * gridsize * gridsize, + gpm->data); + } + } + } +} + static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, int partial_type, int partial_count) { int i; @@ -1677,6 +1701,13 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data, else if (layer->type == CD_MDISPS) { write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL); } + else if (layer->type == CD_PAINT_MASK) { + float *layer_data = layer->data; + writedata(wd, DATA, sizeof(*layer_data) * count, layer_data); + } + else if (layer->type == CD_GRID_PAINT_MASK) { + write_grid_paint_mask(wd, count, layer->data); + } else { CustomData_file_write_info(layer->type, &structname, &structnum); if (structnum) { @@ -1785,8 +1816,8 @@ static void write_meshs(WriteData *wd, ListBase *idbase) /* now fill in polys to mfaces*/ - mesh->totface= mesh_mpoly_to_mface(&mesh->fdata, &backup_mesh.ldata, &backup_mesh.pdata, - mesh->totface, backup_mesh.totloop, backup_mesh.totpoly); + mesh->totface = BKE_mesh_mpoly_to_mface(&mesh->fdata, &backup_mesh.ldata, &backup_mesh.pdata, + mesh->totface, backup_mesh.totloop, backup_mesh.totpoly); mesh_update_customdata_pointers(mesh, FALSE); @@ -2709,6 +2740,9 @@ static void write_movieclips(WriteData *wd, ListBase *idbase) MovieTrackingObject *object; writestruct(wd, ID_MC, "MovieClip", 1, clip); + if (clip->id.properties) + IDP_WriteProperty(clip->id.properties, wd); + if (clip->adt) write_animdata(wd, clip->adt); diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 3bd4155d52c..38e9e6ffd53 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -214,6 +214,9 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i BLI_array_append(verts, v); BLI_array_append(edges2, e); + /* we only flag the verts to check if they are in the face more then once */ + BM_ELEM_API_FLAG_ENABLE(v, _FLAG_MV); + do { e2 = bmesh_disk_edge_next(e2, v); if (e2 != e && BM_ELEM_API_FLAG_TEST(e2, _FLAG_MF)) { @@ -269,6 +272,12 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i if (!edges2[i]) { goto err; } + + /* check if vert is in face more then once. if the flag is disabled. we've already visited */ + if (!BM_ELEM_API_FLAG_TEST(verts[i], _FLAG_MV)) { + goto err; + } + BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); } f = BM_face_create(bm, verts, edges2, len, nodouble); @@ -286,6 +295,10 @@ BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, i err: for (i = 0; i < len; i++) { BM_ELEM_API_FLAG_DISABLE(edges[i], _FLAG_MF); + /* vert count may != len */ + if (i < BLI_array_count(verts)) { + BM_ELEM_API_FLAG_DISABLE(verts[i], _FLAG_MV); + } } BLI_array_free(verts); diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index 23d0a1e3906..0827901f5c2 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -60,6 +60,7 @@ int bmesh_disk_count(BMVert *v); * on using these internal flags!*/ #define _FLAG_JF 1 /* join faces */ #define _FLAG_MF 2 /* make face */ +#define _FLAG_MV 2 /* make face, vertex */ #define BM_ELEM_API_FLAG_ENABLE(element, f) ((element)->oflags[0].pflag |= (f)) #define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f)) diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index ae1773af05e..1451625d3bb 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -34,14 +34,14 @@ #include "intern/bmesh_operators_private.h" /* own include */ -#define FACE_MARK 1 -#define FACE_ORIG 2 -#define FACE_NEW 4 -#define EDGE_MARK 1 +#define FACE_MARK 1 +#define FACE_ORIG 2 +#define FACE_NEW 4 +#define EDGE_MARK 1 -#define VERT_MARK 1 +#define VERT_MARK 1 -static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) +static int UNUSED_FUNCTION(check_hole_in_region) (BMesh * bm, BMFace * f) { BMWalker regwalker; BMIter liter2; @@ -60,8 +60,8 @@ static int UNUSED_FUNCTION(check_hole_in_region)(BMesh *bm, BMFace *f) l2 = BM_iter_new(&liter2, bm, BM_LOOPS_OF_FACE, f2); for ( ; l2; l2 = BM_iter_step(&liter2)) { l3 = l2->radial_next; - if ( BMO_elem_flag_test(bm, l3->f, FACE_MARK) != - BMO_elem_flag_test(bm, l2->f, FACE_MARK)) + if (BMO_elem_flag_test(bm, l3->f, FACE_MARK) != + BMO_elem_flag_test(bm, l2->f, FACE_MARK)) { if (!BMO_elem_flag_test(bm, l2->e, EDGE_MARK)) { return FALSE; @@ -433,8 +433,8 @@ void dummy_exec(BMesh *bm, BMOperator *op) fe = l->e; for ( ; l; l = BM_iter_step(&liter)) { f2 = BM_iter_new(&fiter, bm, - BM_FACES_OF_EDGE, l->e); - for ( ; f2; f2 = BM_iter_step(&fiter)) { + BM_FACES_OF_EDGE, l->e); + for (; f2; f2 = BM_iter_step(&fiter)) { if (f2 != f) { BM_faces_join_pair(bm, f, f2, l->e); found2 = 1; @@ -520,23 +520,28 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) const float angle_max = (float)M_PI / 2.0f; const float angle_limit = minf(angle_max, BMO_slot_float_get(op, "angle_limit")); DissolveElemWeight *weight_elems = MEM_mallocN(MAX2(einput->len, vinput->len) * - sizeof(DissolveElemWeight), __func__); + sizeof(DissolveElemWeight), __func__); int i, tot_found; BMIter iter; BMEdge *e_iter; BMEdge **earray; + int *vert_reverse_lookup; + + BMEdge **einput_arr = (BMEdge **)einput->data.p; + BMVert **vinput_arr = (BMVert **)vinput->data.p; + /* --- first edges --- */ /* wire -> tag */ - BM_ITER_MESH(e_iter, &iter, bm, BM_EDGES_OF_MESH) { + BM_ITER_MESH (e_iter, &iter, bm, BM_EDGES_OF_MESH) { BM_elem_flag_set(e_iter, BM_ELEM_TAG, BM_edge_is_wire(e_iter)); } /* go through and split edge */ for (i = 0, tot_found = 0; i < einput->len; i++) { - BMEdge *e = ((BMEdge **)einput->data.p)[i]; + BMEdge *e = einput_arr[i]; const float angle = BM_edge_calc_face_angle(e); if (angle < angle_limit) { @@ -573,10 +578,51 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) } } + /* prepare for cleanup */ + BM_mesh_elem_index_ensure(bm, BM_VERT); + vert_reverse_lookup = MEM_mallocN(sizeof(int) * bm->totvert, __func__); + fill_vn_i(vert_reverse_lookup, bm->totvert, -1); + for (i = 0, tot_found = 0; i < vinput->len; i++) { + BMVert *v = vinput_arr[i]; + vert_reverse_lookup[BM_elem_index_get(v)] = i; + } + + /* --- cleanup --- */ + earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__); + BM_ITER_MESH_INDEX (e_iter, &iter, bm, BM_EDGES_OF_MESH, i) { + earray[i] = e_iter; + } + /* remove all edges/verts left behind from dissolving, NULL'ing the vertex array so we dont re-use */ + for (i = bm->totedge - 1; i != -1; i--) { + e_iter = earray[i]; + + if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) { + /* edge has become wire */ + int vidx_reverse; + BMVert *v1 = e_iter->v1; + BMVert *v2 = e_iter->v2; + BM_edge_kill(bm, e_iter); + if (v1->e == NULL) { + vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v1)]; + if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + BM_vert_kill(bm, v1); + } + if (v2->e == NULL) { + vidx_reverse = vert_reverse_lookup[BM_elem_index_get(v2)]; + if (vidx_reverse != -1) vinput_arr[vidx_reverse] = NULL; + BM_vert_kill(bm, v2); + } + } + } + MEM_freeN(vert_reverse_lookup); + + MEM_freeN(earray); + + /* --- second verts --- */ for (i = 0, tot_found = 0; i < vinput->len; i++) { - BMVert *v = ((BMVert **)vinput->data.p)[i]; - const float angle = bm_vert_edge_face_angle(v); + BMVert *v = vinput_arr[i]; + const float angle = v ? bm_vert_edge_face_angle(v) : angle_limit; if (angle < angle_limit) { weight_elems[i].ele = (BMHeader *)v; @@ -609,25 +655,4 @@ void bmo_dissolve_limit_exec(BMesh *bm, BMOperator *op) } MEM_freeN(weight_elems); - - /* --- cleanup --- */ - earray = MEM_mallocN(sizeof(BMEdge *) * bm->totedge, __func__); - BM_ITER_MESH_INDEX(e_iter, &iter, bm, BM_EDGES_OF_MESH, i) { - earray[i] = e_iter; - } - /* remove all edges/verts left behind from dissolving */ - for (i = bm->totedge - 1; i != -1; i--) { - e_iter = earray[i]; - - if (BM_edge_is_wire(e_iter) && (BM_elem_flag_test(e_iter, BM_ELEM_TAG) == FALSE)) { - /* edge has become wire */ - BMVert *v1 = e_iter->v1; - BMVert *v2 = e_iter->v2; - BM_edge_kill(bm, e_iter); - if (v1->e == NULL) BM_vert_kill(bm, v1); - if (v2->e == NULL) BM_vert_kill(bm, v2); - } - } - - MEM_freeN(earray); } diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index 0659a42c26d..212ec33e626 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -181,7 +181,7 @@ static BMFace *copy_face(BMOperator *op, BMesh *source_mesh, * Internal Copy function. */ -static void copy_mesh(BMOperator *op, BMesh *source, BMesh *target) +static void BKE_mesh_copy(BMOperator *op, BMesh *source, BMesh *target) { BMVert *v = NULL, *v2; @@ -326,7 +326,7 @@ void bmo_dupe_exec(BMesh *bm, BMOperator *op) BMO_slot_buffer_flag_enable(bm, dupeop, "geom", BM_ALL, DUPE_INPUT); /* use the internal copy function */ - copy_mesh(dupeop, bm, bm2); + BKE_mesh_copy(dupeop, bm, bm2); /* Output */ /* First copy the input buffers to output buffers - original data */ diff --git a/source/blender/collada/AnimationExporter.cpp b/source/blender/collada/AnimationExporter.cpp index 6565a9e0c2e..5898d5da670 100644 --- a/source/blender/collada/AnimationExporter.cpp +++ b/source/blender/collada/AnimationExporter.cpp @@ -301,20 +301,20 @@ void AnimationExporter::dae_animation(Object* ob, FCurve *fcu, char* transformNa std::string target; if ( !is_param ) - target = translate_id(ob_name) - + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); + target = translate_id(ob_name) + + "/" + get_transform_sid(fcu->rna_path, -1, axis_name, true); else { if ( ob->type == OB_LAMP ) - target = get_light_id(ob) - + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); + target = get_light_id(ob) + + "/" + get_light_param_sid(fcu->rna_path, -1, axis_name, true); if ( ob->type == OB_CAMERA ) - target = get_camera_id(ob) - + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); + target = get_camera_id(ob) + + "/" + get_camera_param_sid(fcu->rna_path, -1, axis_name, true); if ( ma ) - target = translate_id(id_name(ma)) + "-effect" - +"/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); + target = translate_id(id_name(ma)) + "-effect" + + "/common/" /*profile common is only supported */ + get_transform_sid(fcu->rna_path, -1, axis_name, true); } addChannel(COLLADABU::URI(empty, sampler_id), target); @@ -371,7 +371,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B } if (!(fcu)) return; - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); if (!pchan) return; @@ -379,7 +379,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } if (fra.size()) { @@ -388,7 +388,7 @@ void AnimationExporter::sample_and_write_bone_animation_matrix(Object *ob_arm, B if (flag & ARM_RESTPOS) arm->flag = flag; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } void AnimationExporter::dae_baked_animation(std::vector &fra, Object *ob_arm, Bone *bone) @@ -739,7 +739,7 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj bPoseChannel *pchan = NULL; bPose *pose = ob_arm->pose; - pchan = get_pose_channel(pose, bone->name); + pchan = BKE_pose_channel_find_name(pose, bone->name); if (!pchan) return ""; @@ -753,10 +753,10 @@ std::string AnimationExporter::create_4x4_source(std::vector &frames, Obj for (it = frames.begin(); it != frames.end(); it++) { float mat[4][4], ipar[4][4]; - float ctime = BKE_frame_to_ctime(scene, *it); + float ctime = BKE_scene_frame_get_from_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob_arm, pchan, ctime, 1); // compute bone local mat if (bone->parent) { @@ -1206,7 +1206,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone->name); - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); if (!pchan) return; //Fill frame array with key frame values framed at \param:transform_type @@ -1227,7 +1227,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo // exit rest position if (flag & ARM_RESTPOS) { arm->flag &= ~ARM_RESTPOS; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } //v array will hold all values which will be exported. if (fra.size()) { @@ -1257,7 +1257,7 @@ void AnimationExporter::sample_and_write_bone_animation(Object *ob_arm, Bone *bo // restore restpos if (flag & ARM_RESTPOS) arm->flag = flag; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } void AnimationExporter::sample_animation(float *v, std::vector &frames, int type, Bone *bone, Object *ob_arm, bPoseChannel *pchan) @@ -1265,7 +1265,7 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i bPoseChannel *parchan = NULL; bPose *pose = ob_arm->pose; - pchan = get_pose_channel(pose, bone->name); + pchan = BKE_pose_channel_find_name(pose, bone->name); if (!pchan) return; @@ -1278,11 +1278,11 @@ void AnimationExporter::sample_animation(float *v, std::vector &frames, i for (it = frames.begin(); it != frames.end(); it++) { float mat[4][4], ipar[4][4]; - float ctime = BKE_frame_to_ctime(scene, *it); + float ctime = BKE_scene_frame_get_from_ctime(scene, *it); BKE_animsys_evaluate_animdata(scene, &ob_arm->id, ob_arm->adt, ctime, ADT_RECALC_ANIM); - where_is_pose_bone(scene, ob_arm, pchan, ctime, 1); + BKE_pose_where_is_bone(scene, ob_arm, pchan, ctime, 1); // compute bone local mat if (bone->parent) { diff --git a/source/blender/collada/AnimationImporter.cpp b/source/blender/collada/AnimationImporter.cpp index a72d51721ce..195057817dd 100644 --- a/source/blender/collada/AnimationImporter.cpp +++ b/source/blender/collada/AnimationImporter.cpp @@ -206,7 +206,7 @@ void AnimationImporter::add_fcurves_to_object(Object *ob, std::vector& if (bone_name) { /* try to find group */ - grp = action_groups_find_named(act, bone_name); + grp = BKE_action_group_find_name(act, bone_name); /* no matching groups, so add one */ if (grp == NULL) { @@ -324,7 +324,7 @@ void AnimationImporter::read_node_transform(COLLADAFW::Node *node, Object *ob) TransformReader::get_node_mat(mat, node, &uid_animated_map, ob); if (ob) { copy_m4_m4(ob->obmat, mat); - object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); } } @@ -361,7 +361,7 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) create_fcurve(3, rna_path) }; - bPoseChannel *chan = get_pose_channel(ob->pose, grp->name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, grp->name); float m4[4][4], irest[3][3]; invert_m4_m4(m4, chan->bone->arm_mat); @@ -670,7 +670,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& get_joint_rest_mat(irest_dae, root, node); invert_m4(irest_dae); - Bone *bone = get_named_bone((bArmature*)ob->data, bone_name); + Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); return; @@ -784,7 +784,7 @@ void AnimationImporter::apply_matrix_curves( Object * ob, std::vector& } if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name); chan->rotmode = ROT_MODE_QUAT; } else { @@ -1025,7 +1025,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vectordata, bone_name); + Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); return; @@ -1123,7 +1123,7 @@ void AnimationImporter::add_bone_animation_sampled(Object * ob, std::vectorpose, bone_name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name); chan->rotmode = ROT_MODE_QUAT; } @@ -1307,7 +1307,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, get_joint_rest_mat(irest_dae, root, node); invert_m4(irest_dae); - Bone *bone = get_named_bone((bArmature*)ob->data, bone_name); + Bone *bone = BKE_armature_find_bone_name((bArmature*)ob->data, bone_name); if (!bone) { fprintf(stderr, "cannot find bone \"%s\"\n", bone_name); return NULL; @@ -1515,7 +1515,7 @@ Object *AnimationImporter::translate_animation_OLD(COLLADAFW::Node *node, if (is_rotation || is_matrix) { if (is_joint) { - bPoseChannel *chan = get_pose_channel(ob->pose, bone_name); + bPoseChannel *chan = BKE_pose_channel_find_name(ob->pose, bone_name); chan->rotmode = ROT_MODE_QUAT; } else { @@ -1772,7 +1772,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No if (joint_objects.find(node->getUniqueId()) == joint_objects.end()) { Object *job = bc_add_object(scene, OB_EMPTY, (char*)get_joint_name(node)); - job->lay = object_in_scene(job, scene)->lay = 2; + job->lay = BKE_scene_base_find(scene, job)->lay = 2; mul_v3_fl(job->size, 0.5f); job->recalc |= OB_RECALC_OB; @@ -1800,7 +1800,7 @@ Object *AnimationImporter::get_joint_object(COLLADAFW::Node *root, COLLADAFW::No job->parsubstr[0] = 0; } - where_is_object(scene, job); + BKE_object_where_is_calc(scene, job); // after parenting and layer change DAG_scene_sort(CTX_data_main(C), scene); @@ -1849,7 +1849,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv bAction *act = ob->adt->action; /* try to find group */ - bActionGroup *grp = action_groups_find_named(act, bone_name); + bActionGroup *grp = BKE_action_group_find_name(act, bone_name); /* no matching groups, so add one */ if (grp == NULL) { diff --git a/source/blender/collada/ArmatureExporter.cpp b/source/blender/collada/ArmatureExporter.cpp index d5a3b4cb0a2..38a5e9b5df4 100644 --- a/source/blender/collada/ArmatureExporter.cpp +++ b/source/blender/collada/ArmatureExporter.cpp @@ -251,13 +251,13 @@ void ArmatureExporter::add_bone_node(Bone *bone, Object *ob_arm, Scene* sce, }*/ void ArmatureExporter::add_bone_transform(Object *ob_arm, Bone *bone, COLLADASW::Node& node) { - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, bone->name); float mat[4][4]; if (bone->parent) { // get bone-space matrix from armature-space - bPoseChannel *parchan = get_pose_channel(ob_arm->pose, bone->parent->name); + bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, bone->parent->name); float invpar[4][4]; invert_m4_m4(invpar, parchan->pose_mat); @@ -481,12 +481,12 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase // put armature in rest position if (!(arm->flag & ARM_RESTPOS)) { arm->flag |= ARM_RESTPOS; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } for (bDeformGroup *def = (bDeformGroup*)defbase->first; def; def = def->next) { if (is_bone_defgroup(ob_arm, def)) { - bPoseChannel *pchan = get_pose_channel(pose, def->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, def->name); float mat[4][4]; float world[4][4]; @@ -515,7 +515,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase // back from rest positon if (!(flag & ARM_RESTPOS)) { arm->flag = flag; - where_is_pose(scene, ob_arm); + BKE_pose_where_is(scene, ob_arm); } source.finish(); @@ -525,7 +525,7 @@ std::string ArmatureExporter::add_inv_bind_mats_source(Object *ob_arm, ListBase Bone *ArmatureExporter::get_bone_from_defgroup(Object *ob_arm, bDeformGroup* def) { - bPoseChannel *pchan = get_pose_channel(ob_arm->pose, def->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob_arm->pose, def->name); return pchan ? pchan->bone : NULL; } diff --git a/source/blender/collada/ArmatureImporter.cpp b/source/blender/collada/ArmatureImporter.cpp index 4316edf1e67..97de7590d07 100644 --- a/source/blender/collada/ArmatureImporter.cpp +++ b/source/blender/collada/ArmatureImporter.cpp @@ -321,7 +321,7 @@ void ArmatureImporter::set_leaf_bone_shapes(Object *ob_arm) for (it = leaf_bones.begin(); it != leaf_bones.end(); it++) { LeafBone& leaf = *it; - bPoseChannel *pchan = get_pose_channel(pose, leaf.name); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, leaf.name); if (pchan) { pchan->custom = get_empty_for_leaves(); } @@ -499,7 +499,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) std::map::iterator it; for (it = skin_by_data_uid.begin(); it != skin_by_data_uid.end(); it++) { SkinInfo *b = &it->second; - if (b == a || b->get_armature() == NULL) + if (b == a || b->BKE_armature_from_object() == NULL) continue; skin_root_joints.clear(); @@ -509,7 +509,7 @@ void ArmatureImporter::create_armature_bones(SkinInfo& skin) std::vector::iterator ri; for (ri = skin_root_joints.begin(); ri != skin_root_joints.end(); ri++) { if (a->uses_joint_or_descendant(*ri)) { - shared = b->get_armature(); + shared = b->BKE_armature_from_object(); break; } } @@ -582,13 +582,13 @@ void ArmatureImporter::set_pose(Object * ob_arm, COLLADAFW::Node * root_node, c get_node_mat(obmat, root_node, NULL, NULL); //if (*edbone) - bPoseChannel * pchan = get_pose_channel(ob_arm -> pose, bone_name); + bPoseChannel * pchan = BKE_pose_channel_find_name(ob_arm -> pose, bone_name); //else fprintf ( "", // get world-space if (parentname) { mult_m4_m4m4(mat, parent_mat, obmat); - bPoseChannel *parchan = get_pose_channel(ob_arm->pose, parentname); + bPoseChannel *parchan = BKE_pose_channel_find_name(ob_arm->pose, parentname); mult_m4_m4m4(pchan->pose_mat, parchan->pose_mat, mat ); @@ -660,7 +660,7 @@ void ArmatureImporter::make_armatures(bContext *C) // set armature parent if any Object *par = skin.get_parent(); if (par) - bc_set_parent(skin.get_armature(), par, C, false); + bc_set_parent(skin.BKE_armature_from_object(), par, C, false); // free memory stolen from SkinControllerData skin.free(); @@ -761,7 +761,7 @@ Object *ArmatureImporter::get_armature_for_joint(COLLADAFW::Node *node) SkinInfo& skin = it->second; if (skin.uses_joint_or_descendant(node)) - return skin.get_armature(); + return skin.BKE_armature_from_object(); } std::map::iterator arm; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index 1d315b6ea06..6dca7828cc2 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -122,7 +122,7 @@ bool DocumentImporter::import() loader.registerExtraDataCallbackHandler(ehandler); // deselect all to select new objects - scene_deselect_all(CTX_data_scene(mContext)); + BKE_scene_base_deselect_all(CTX_data_scene(mContext)); if (!root.loadDocument(mFilename)) { fprintf(stderr, "COLLADAFW::Root::loadDocument() returned false on 1st pass\n"); @@ -227,10 +227,10 @@ void DocumentImporter::finish() for (it = libnode_ob.begin(); it != libnode_ob.end(); it++) { Object *ob = *it; - Base *base = object_in_scene(ob, sce); + Base *base = BKE_scene_base_find(sce, ob); if (base) { BLI_remlink(&sce->base, base); - free_libblock_us(&G.main->object, base->object); + BKE_libblock_free_us(&G.main->object, base->object); if (sce->basact==base) sce->basact= NULL; MEM_freeN(base); @@ -312,7 +312,7 @@ Object* DocumentImporter::create_camera_object(COLLADAFW::InstanceCamera *camera ob->data = cam; old_cam->id.us--; if (old_cam->id.us == 0) - free_libblock(&G.main->camera, old_cam); + BKE_libblock_free(&G.main->camera, old_cam); return ob; } @@ -330,7 +330,7 @@ Object* DocumentImporter::create_lamp_object(COLLADAFW::InstanceLight *lamp, Sce ob->data = la; old_lamp->id.us--; if (old_lamp->id.us == 0) - free_libblock(&G.main->lamp, old_lamp); + BKE_libblock_free(&G.main->lamp, old_lamp); return ob; } @@ -338,9 +338,9 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod { fprintf(stderr, "create under node id=%s from node id=%s\n", instance_node ? instance_node->getOriginalId().c_str() : NULL, source_node ? source_node->getOriginalId().c_str() : NULL); - Object *obn = copy_object(source_ob); + Object *obn = BKE_object_copy(source_ob); obn->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - scene_add_base(sce, obn); + BKE_scene_base_add(sce, obn); if (instance_node) { anim_importer.read_node_transform(instance_node, obn); @@ -359,7 +359,7 @@ Object* DocumentImporter::create_instance_node(Object *source_ob, COLLADAFW::Nod } // calc new matrix and apply mult_m4_m4m4(obn->obmat, obn->obmat, mat); - object_apply_mat4(obn, obn->obmat, 0, 0); + BKE_object_apply_mat4(obn, obn->obmat, 0, 0); } } else { @@ -572,7 +572,7 @@ bool DocumentImporter::writeMaterial( const COLLADAFW::Material* cmat ) return true; const std::string& str_mat_id = cmat->getName().size() ? cmat->getName() : cmat->getOriginalId(); - Material *ma = add_material((char*)str_mat_id.c_str()); + Material *ma = BKE_material_add((char*)str_mat_id.c_str()); this->uid_effect_map[cmat->getInstantiatedEffect()] = ma; this->uid_material_map[cmat->getUniqueId()] = ma; @@ -921,7 +921,7 @@ bool DocumentImporter::writeImage( const COLLADAFW::Image* image ) BLI_split_dir_part(filename, dir, sizeof(dir)); BLI_join_dirfile(full_path, sizeof(full_path), dir, filepath.c_str()); - Image *ima = BKE_add_image_file(full_path); + Image *ima = BKE_image_load_exists(full_path); if (!ima) { fprintf(stderr, "Cannot create image.\n"); return true; @@ -949,8 +949,8 @@ bool DocumentImporter::writeLight( const COLLADAFW::Light* light ) la_id = light->getOriginalId(); la_name = light->getName(); - if (la_name.size()) lamp = (Lamp*)add_lamp((char*)la_name.c_str()); - else lamp = (Lamp*)add_lamp((char*)la_id.c_str()); + if (la_name.size()) lamp = (Lamp*)BKE_lamp_add((char*)la_name.c_str()); + else lamp = (Lamp*)BKE_lamp_add((char*)la_id.c_str()); if (!lamp) { fprintf(stderr, "Cannot create lamp.\n"); diff --git a/source/blender/collada/ExportSettings.h b/source/blender/collada/ExportSettings.h index 80e20acbe48..41fa7e1ed38 100644 --- a/source/blender/collada/ExportSettings.h +++ b/source/blender/collada/ExportSettings.h @@ -31,6 +31,7 @@ struct ExportSettings { public: bool selected; + bool apply_modifiers; bool second_life; char *filepath; }; diff --git a/source/blender/collada/GeometryExporter.cpp b/source/blender/collada/GeometryExporter.cpp index 8e4fa057daf..ba41e603a29 100644 --- a/source/blender/collada/GeometryExporter.cpp +++ b/source/blender/collada/GeometryExporter.cpp @@ -36,10 +36,18 @@ #include "GeometryExporter.h" #include "DNA_meshdata_types.h" + +extern "C" { + #include "BKE_DerivedMesh.h" + #include "BKE_main.h" + #include "BKE_global.h" + #include "BKE_library.h" +} + + #include "BKE_customdata.h" #include "BKE_material.h" #include "BKE_mesh.h" - #include "collada_internal.h" // TODO: optimize UV sets by making indexed list with duplicates removed @@ -57,6 +65,25 @@ void GeometryExporter::exportGeom(Scene *sce) closeLibrary(); } +Mesh * GeometryExporter::get_mesh(Object *ob, int apply_modifiers) +{ + Mesh *tmpmesh; + if (!apply_modifiers) + { + tmpmesh = (Mesh*)ob->data; + } + else + { + CustomDataMask mask = CD_MASK_MESH; + DerivedMesh *dm = mesh_create_derived_view(mScene, ob, mask); + tmpmesh = BKE_mesh_add("ColladaMesh"); // name is not important here + DM_to_mesh(dm, tmpmesh, ob); + dm->release(dm); + } + BKE_mesh_tessface_ensure(tmpmesh); + return tmpmesh; +} + void GeometryExporter::operator()(Object *ob) { // XXX don't use DerivedMesh, Mesh instead? @@ -64,8 +91,8 @@ void GeometryExporter::operator()(Object *ob) #if 0 DerivedMesh *dm = mesh_get_derived_final(mScene, ob, CD_MASK_BAREMESH); #endif - Mesh *me = (Mesh*)ob->data; - BKE_mesh_tessface_ensure(me); + + Mesh *me = get_mesh(ob, this->export_settings->apply_modifiers); std::string geom_id = get_geometry_id(ob); std::string geom_name = id_name(ob->data); @@ -110,11 +137,11 @@ void GeometryExporter::operator()(Object *ob) // XXX slow if (ob->totcol) { for (int a = 0; a < ob->totcol; a++) { - createPolylist(a, has_uvs, has_color, ob, geom_id, norind); + createPolylist(a, has_uvs, has_color, ob, me, geom_id, norind); } } else { - createPolylist(0, has_uvs, has_color, ob, geom_id, norind); + createPolylist(0, has_uvs, has_color, ob, me, geom_id, norind); } closeMesh(); @@ -124,7 +151,12 @@ void GeometryExporter::operator()(Object *ob) } closeGeometry(); - + + if (this->export_settings->apply_modifiers) + { + BKE_libblock_free_us(&(G.main->mesh), me); + } + #if 0 dm->release(dm); #endif @@ -135,10 +167,10 @@ void GeometryExporter::createPolylist(short material_index, bool has_uvs, bool has_color, Object *ob, + Mesh *me, std::string& geom_id, std::vector& norind) { - Mesh *me = (Mesh*)ob->data; MFace *mfaces = me->mface; int totfaces = me->totface; @@ -177,7 +209,7 @@ void GeometryExporter::createPolylist(short material_index, // sets material name if (ma) { std::ostringstream ostr; - ostr << translate_id(id_name(ma)) << material_index+1; + ostr << translate_id(id_name(ma)); polylist.setMaterial(ostr.str()); } diff --git a/source/blender/collada/GeometryExporter.h b/source/blender/collada/GeometryExporter.h index 5d79fabb713..55dc179e5e2 100644 --- a/source/blender/collada/GeometryExporter.h +++ b/source/blender/collada/GeometryExporter.h @@ -69,6 +69,7 @@ public: bool has_uvs, bool has_color, Object *ob, + Mesh *me, std::string& geom_id, std::vector& norind); @@ -98,6 +99,8 @@ private: std::set exportedGeometry; const ExportSettings *export_settings; + + Mesh * get_mesh(Object *ob, int apply_modifiers); }; struct GeometryFunctor { diff --git a/source/blender/collada/InstanceWriter.cpp b/source/blender/collada/InstanceWriter.cpp index a605bdeefcc..f83289ff5f5 100644 --- a/source/blender/collada/InstanceWriter.cpp +++ b/source/blender/collada/InstanceWriter.cpp @@ -52,7 +52,7 @@ void InstanceWriter::add_material_bindings(COLLADASW::BindMaterial& bind_materia std::string matid(get_material_id(ma)); matid = translate_id(matid); std::ostringstream ostr; - ostr << translate_id(id_name(ma)) << a+1; + ostr << translate_id(id_name(ma)); COLLADASW::InstanceMaterial im(ostr.str(), COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, matid)); // create for each uv map diff --git a/source/blender/collada/MaterialExporter.cpp b/source/blender/collada/MaterialExporter.cpp index ac1a5d32a08..48fa5b690be 100644 --- a/source/blender/collada/MaterialExporter.cpp +++ b/source/blender/collada/MaterialExporter.cpp @@ -70,7 +70,7 @@ void MaterialsExporter::operator()(Material *ma, Object *ob) { std::string name(id_name(ma)); - openMaterial(get_material_id(ma), name); + openMaterial(get_material_id(ma), get_material_id(ma)); std::string efid = translate_id(name) + "-effect"; addInstanceEffect(COLLADASW::URI(COLLADABU::Utils::EMPTY_STRING, efid)); diff --git a/source/blender/collada/MeshImporter.cpp b/source/blender/collada/MeshImporter.cpp index ba6be75e051..73d1f42b340 100644 --- a/source/blender/collada/MeshImporter.cpp +++ b/source/blender/collada/MeshImporter.cpp @@ -346,7 +346,7 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve vert += 3; } - filldisplist(&dispbase, &dispbase, 0); + BKE_displist_fill(&dispbase, &dispbase, 0); int tottri = 0; dl= (DispList*)dispbase.first; @@ -368,7 +368,7 @@ int MeshImporter::triangulate_poly(unsigned int *indices, int totvert, MVert *ve } } - freedisplist(&dispbase); + BKE_displist_free(&dispbase); return tottri; } @@ -737,7 +737,7 @@ void MeshImporter::bmeshConversion() BKE_mesh_convert_mfaces_to_mpolys(me); BKE_mesh_tessface_clear(me); - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } } } @@ -914,7 +914,7 @@ Object *MeshImporter::create_mesh_object(COLLADAFW::Node *node, COLLADAFW::Insta set_mesh(ob, uid_mesh_map[*geom_uid]); - if (old_mesh->id.us == 0) free_libblock(&G.main->mesh, old_mesh); + if (old_mesh->id.us == 0) BKE_libblock_free(&G.main->mesh, old_mesh); char layername[100]; layername[0] = '\0'; @@ -962,7 +962,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) } const std::string& str_geom_id = mesh->getName().size() ? mesh->getName() : mesh->getOriginalId(); - Mesh *me = add_mesh((char*)str_geom_id.c_str()); + Mesh *me = BKE_mesh_add((char*)str_geom_id.c_str()); me->id.us--; // is already 1 here, but will be set later in set_mesh // store the Mesh pointer to link it later with an Object @@ -976,7 +976,7 @@ bool MeshImporter::write_geometry(const COLLADAFW::Geometry* geom) read_faces(mesh, me, new_tris); - make_edges(me, 0); + BKE_mesh_make_edges(me, 0); return true; } diff --git a/source/blender/collada/SkinInfo.cpp b/source/blender/collada/SkinInfo.cpp index 0727ec21682..edc8981deab 100644 --- a/source/blender/collada/SkinInfo.cpp +++ b/source/blender/collada/SkinInfo.cpp @@ -178,7 +178,7 @@ bool SkinInfo::get_joint_inv_bind_matrix(float inv_bind_mat[][4], COLLADAFW::Nod return false; } -Object *SkinInfo::get_armature() +Object *SkinInfo::BKE_armature_from_object() { return ob_arm; } @@ -218,10 +218,11 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapobject = ob_arm; + ArmatureModifierData *amd = (ArmatureModifierData *)md; + amd->object = ob_arm; copy_m4_m4(ob->obmat, bind_shape_matrix); - object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); #if 1 bc_set_parent(ob, ob_arm, C); #else @@ -229,7 +230,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapparent = ob_arm; ob->partype = PAROBJECT; - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA; @@ -239,7 +240,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mapdata)->deformflag = ARM_DEF_VGROUP; + amd->deformflag = ARM_DEF_VGROUP; // create all vertex groups std::vector::iterator it; @@ -288,7 +289,7 @@ void SkinInfo::link_armature(bContext *C, Object *ob, std::mappose, bc_get_joint_name(node)); + return BKE_pose_channel_find_name(ob_arm->pose, bc_get_joint_name(node)); } void SkinInfo::set_parent(Object *_parent) diff --git a/source/blender/collada/SkinInfo.h b/source/blender/collada/SkinInfo.h index 7befe7168d3..894f53f07c3 100644 --- a/source/blender/collada/SkinInfo.h +++ b/source/blender/collada/SkinInfo.h @@ -105,7 +105,7 @@ public: bool get_joint_inv_bind_matrix(float inv_bind_mat[][4], COLLADAFW::Node *node); - Object *get_armature(); + Object *BKE_armature_from_object(); const COLLADAFW::UniqueId& get_controller_uid(); diff --git a/source/blender/collada/TransformWriter.cpp b/source/blender/collada/TransformWriter.cpp index 4974566bba1..fbd36cd6613 100644 --- a/source/blender/collada/TransformWriter.cpp +++ b/source/blender/collada/TransformWriter.cpp @@ -70,7 +70,7 @@ void TransformWriter::add_node_transform_ob(COLLADASW::Node& node, Object *ob) copy_v3_v3(scale, ob->size); ob->size[0] = ob->size[1] = ob->size[2] = 1.0f; - object_to_mat4(ob, C); + BKE_object_to_mat4(ob, C); copy_v3_v3(ob->size, scale); mul_serie_m4(tmat, ob->parent->obmat, ob->parentinv, C, NULL, NULL, NULL, NULL, NULL); diff --git a/source/blender/collada/collada.cpp b/source/blender/collada/collada.cpp index 70bf0556b5b..ae024ec52a7 100644 --- a/source/blender/collada/collada.cpp +++ b/source/blender/collada/collada.cpp @@ -49,13 +49,14 @@ extern "C" return 0; } - int collada_export(Scene *sce, const char *filepath, int selected, int second_life) + int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life) { ExportSettings export_settings; - export_settings.selected = selected != 0; - export_settings.second_life = second_life != 0; - export_settings.filepath = (char *)filepath; + export_settings.selected = selected != 0; + export_settings.apply_modifiers = apply_modifiers != 0; + export_settings.second_life = second_life != 0; + export_settings.filepath = (char *)filepath; /* annoying, collada crashes if file cant be created! [#27162] */ if (!BLI_exists(filepath)) { diff --git a/source/blender/collada/collada.h b/source/blender/collada/collada.h index f8afc797447..f335796f799 100644 --- a/source/blender/collada/collada.h +++ b/source/blender/collada/collada.h @@ -37,7 +37,7 @@ extern "C" { * both return 1 on success, 0 on error */ int collada_import(bContext *C, const char *filepath); - int collada_export(Scene *sce, const char *filepath, int selected, int second_life); + int collada_export(Scene *sce, const char *filepath, int selected, int apply_modifiers, int second_life); #ifdef __cplusplus } #endif diff --git a/source/blender/collada/collada_utils.cpp b/source/blender/collada/collada_utils.cpp index bd0f82fb0ac..8b7a28e5fbe 100644 --- a/source/blender/collada/collada_utils.cpp +++ b/source/blender/collada/collada_utils.cpp @@ -88,7 +88,7 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) if (is_parent_space) { float mat[4][4]; // calc par->obmat - where_is_object(sce, par); + BKE_object_where_is_calc(sce, par); // move child obmat into world space mult_m4_m4m4(mat, par->obmat, ob->obmat); @@ -96,10 +96,10 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) } // apply child obmat (i.e. decompose it into rot/loc/size) - object_apply_mat4(ob, ob->obmat, 0, 0); + BKE_object_apply_mat4(ob, ob->obmat, 0, 0); // compute parentinv - what_does_parent(sce, ob, &workob); + BKE_object_workob_calc_parent(sce, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; @@ -114,13 +114,13 @@ int bc_set_parent(Object *ob, Object *par, bContext *C, bool is_parent_space) Object *bc_add_object(Scene *scene, int type, const char *name) { - Object *ob = add_only_object(type, name); + Object *ob = BKE_object_add_only_object(type, name); - ob->data= add_obdata_from_type(type); + ob->data= BKE_object_obdata_add_from_type(type); ob->lay= scene->lay; ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - scene_select_base(scene, scene_add_base(scene, ob)); + BKE_scene_base_select(scene, BKE_scene_base_add(scene, ob)); return ob; } diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index d63d5ae2082..6ba61830cd9 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -80,10 +80,10 @@ // XXX constant defines to be moved elsewhere? /* extra padding for lengths (to go under scrollers) */ -#define EXTRA_SCROLL_PAD 100.0f +#define EXTRA_SCROLL_PAD 100.0f /* size of indent steps */ -#define INDENT_STEP_SIZE 7 +#define INDENT_STEP_SIZE 7 #define ANIM_CHAN_NAME_SIZE 256 @@ -108,10 +108,10 @@ static void acf_generic_root_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUS /* backdrop for top-level widgets (Scene and Object only) */ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -120,7 +120,7 @@ static void acf_generic_root_backdrop(bAnimContext *ac, bAnimListElem *ale, floa /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); } @@ -134,9 +134,9 @@ static void acf_generic_dataexpand_color(bAnimContext *UNUSED(ac), bAnimListElem /* backdrop for data expanders under top-level Scene/Object */ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -144,24 +144,24 @@ static void acf_generic_dataexpand_backdrop(bAnimContext *ac, bAnimListElem *ale glColor3fv(color); /* no rounded corner - just rectangular box */ - glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); + glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } /* get backdrop color for generic channels */ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, float r_color[3]) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); SpaceAction *saction = NULL; bActionGroup *grp = NULL; - short indent= (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; + short indent = (acf->get_indent_level) ? acf->get_indent_level(ac, ale) : 0; /* get context info needed... */ if ((ac->sl) && (ac->spacetype == SPACE_ACTION)) - saction= (SpaceAction *)ac->sl; + saction = (SpaceAction *)ac->sl; if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; - grp= fcu->grp; + FCurve *fcu = (FCurve *)ale->data; + grp = fcu->grp; } /* set color for normal channels @@ -169,7 +169,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa * - only use group colors if allowed to, and if actually feasible */ if ( (saction && !(saction->flag & SACTION_NODRAWGCOLORS)) && - ((grp) && (grp->customCol)) ) + ((grp) && (grp->customCol)) ) { unsigned char cp[3]; @@ -188,7 +188,7 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa } else { // FIXME: what happens when the indention is 1 greater than what it should be (due to grouping)? - int colOfs= 20 - 20*indent; + int colOfs = 20 - 20 * indent; UI_GetThemeColorShade3fv(TH_HEADER, colOfs, r_color); } } @@ -196,9 +196,9 @@ static void acf_generic_channel_color(bAnimContext *ac, bAnimListElem *ale, floa /* backdrop for generic channels */ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -206,7 +206,7 @@ static void acf_generic_channel_backdrop(bAnimContext *ac, bAnimListElem *ale, f glColor3fv(color); /* no rounded corners - just rectangular box */ - glRectf(offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); + glRectf(offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } /* Indention + Offset ------------------------------------------- */ @@ -230,11 +230,11 @@ static short acf_generic_indention_2(bAnimContext *ac, bAnimListElem *ale) /* indention which varies with the grouping status */ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - short indent= 0; + short indent = 0; /* grouped F-Curves need extra level of indention */ if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; // TODO: we need some way of specifying that the indention color should be one less... if (fcu->grp) @@ -248,7 +248,7 @@ static short acf_generic_indention_flexible(bAnimContext *UNUSED(ac), bAnimListE /* basic offset for channels derived from indention */ static short acf_generic_basic_offset(bAnimContext *ac, bAnimListElem *ale) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); if (acf && acf->get_indent_level) return acf->get_indent_level(ac, ale) * INDENT_STEP_SIZE; @@ -273,7 +273,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) case NTREE_TEXTURE: /* 2 additional levels */ - return INDENT_STEP_SIZE*2; + return INDENT_STEP_SIZE * 2; } } @@ -284,7 +284,7 @@ static short acf_nodetree_rootType_offset(bNodeTree *ntree) /* offset for groups + grouped entities */ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) { - short offset= acf_generic_basic_offset(ac, ale); + short offset = acf_generic_basic_offset(ac, ale); if (ale->id) { /* texture animdata */ @@ -301,7 +301,7 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) /* nodetree animdata */ if (GS(ale->id->name) == ID_NT) { - offset += acf_nodetree_rootType_offset((bNodeTree*)ale->id); + offset += acf_nodetree_rootType_offset((bNodeTree *)ale->id); } } @@ -314,11 +314,11 @@ static short acf_generic_group_offset(bAnimContext *ac, bAnimListElem *ale) /* name for ID block entries */ static void acf_generic_idblock_name(bAnimListElem *ale, char *name) { - ID *id= (ID *)ale->data; /* data pointed to should be an ID block */ + ID *id = (ID *)ale->data; /* data pointed to should be an ID block */ /* just copy the name... */ if (id && name) - BLI_strncpy(name, id->name+2, ANIM_CHAN_NAME_SIZE); + BLI_strncpy(name, id->name + 2, ANIM_CHAN_NAME_SIZE); } /* name property for ID block entries */ @@ -378,7 +378,7 @@ static short acf_generic_dataexpand_setting_valid(bAnimContext *ac, bAnimListEle static void acf_summary_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(ale), float r_color[3]) { // FIXME: hardcoded color - same as the 'action' line in NLA - // reddish color + // reddish color r_color[0] = 0.8f; r_color[1] = 0.2f; r_color[2] = 0.0f; @@ -387,8 +387,8 @@ static void acf_summary_color(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al /* backdrop for summary widget */ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; float color[3]; /* set backdrop drawing color */ @@ -400,7 +400,7 @@ static void acf_summary_backdrop(bAnimContext *ac, bAnimListElem *ale, float ymi * - special hack: make the top a bit higher, since we are first... */ uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT); - uiDrawBox(GL_POLYGON, 0, yminc-2, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, 0, yminc - 2, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); } /* name for summary entries */ @@ -428,12 +428,12 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, short { if (setting == ACHANNEL_SETTING_EXPAND) { /* expanded */ - *neg= 1; + *neg = 1; return ADS_FLAG_SUMMARY_COLLAPSED; } else { /* unsupported */ - *neg= 0; + *neg = 0; return 0; } } @@ -441,21 +441,21 @@ static int acf_summary_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bAnimContext *ac= (bAnimContext *)ale->data; + bAnimContext *ac = (bAnimContext *)ale->data; /* if data is valid, return pointer to active dopesheet's relevant flag * - this is restricted to DopeSheet/Action Editor only */ if ((ac->sl) && (ac->spacetype == SPACE_ACTION) && (setting == ACHANNEL_SETTING_EXPAND)) { - SpaceAction *saction= (SpaceAction *)ac->sl; - bDopeSheet *ads= &saction->ads; + SpaceAction *saction = (SpaceAction *)ac->sl; + bDopeSheet *ads = &saction->ads; /* return pointer to DopeSheet's flag */ return GET_ACF_FLAG_PTR(ads->flag, type); } else { /* can't return anything useful - unsupported */ - *type= 0; + *type = 0; return NULL; } } @@ -463,20 +463,20 @@ static void *acf_summary_setting_ptr(bAnimListElem *ale, int setting, short *typ /* all animation summary (DopeSheet only) type define */ static bAnimChannelType ACF_SUMMARY = { - "Summary", /* type name */ + "Summary", /* type name */ - acf_summary_color, /* backdrop color */ - acf_summary_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - NULL, /* offset */ - - acf_summary_name, /* name */ - NULL, /* name prop */ - acf_summary_icon, /* icon */ - - acf_summary_setting_valid, /* has setting */ - acf_summary_setting_flag, /* flag for setting */ - acf_summary_setting_ptr /* pointer for setting */ + acf_summary_color, /* backdrop color */ + acf_summary_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_summary_name, /* name */ + NULL, /* name prop */ + acf_summary_icon, /* icon */ + + acf_summary_setting_valid, /* has setting */ + acf_summary_setting_flag, /* flag for setting */ + acf_summary_setting_ptr /* pointer for setting */ }; /* Scene ------------------------------------------- */ @@ -513,21 +513,21 @@ static short acf_scene_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SCE_DS_SELECTED; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return SCE_DS_COLLAPSED; case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; default: /* unsupported */ @@ -538,10 +538,10 @@ static int acf_scene_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Scene *scene= (Scene *)ale->data; + Scene *scene = (Scene *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -565,28 +565,28 @@ static void *acf_scene_setting_ptr(bAnimListElem *ale, int setting, short *type) /* scene type define */ static bAnimChannelType ACF_SCENE = { - "Scene", /* type name */ + "Scene", /* type name */ - acf_generic_root_color, /* backdrop color */ - acf_generic_root_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - NULL, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_scene_icon, /* icon */ - - acf_scene_setting_valid, /* has setting */ - acf_scene_setting_flag, /* flag for setting */ - acf_scene_setting_ptr /* pointer for setting */ + acf_generic_root_color, /* backdrop color */ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_scene_icon, /* icon */ + + acf_scene_setting_valid, /* has setting */ + acf_scene_setting_flag, /* flag for setting */ + acf_scene_setting_ptr /* pointer for setting */ }; /* Object ------------------------------------------- */ static int acf_object_icon(bAnimListElem *ale) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; /* icon depends on object-type */ @@ -622,19 +622,19 @@ static int acf_object_icon(bAnimListElem *ale) /* name for object */ static void acf_object_name(bAnimListElem *ale, char *name) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; /* just copy the name... */ if (ob && name) - BLI_strncpy(name, ob->id.name+2, ANIM_CHAN_NAME_SIZE); + BLI_strncpy(name, ob->id.name + 2, ANIM_CHAN_NAME_SIZE); } /* check if some setting exists for this channel */ static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; switch (setting) { /* muted only in NLA */ @@ -659,21 +659,21 @@ static short acf_object_setting_valid(bAnimContext *ac, bAnimListElem *ale, int static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return SELECT; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return OB_ADS_COLLAPSED; case ACHANNEL_SETTING_MUTE: /* mute (only in NLA) */ return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; default: /* unsupported */ @@ -684,11 +684,11 @@ static int acf_object_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Base *base= (Base *)ale->data; - Object *ob= base->object; + Base *base = (Base *)ale->data; + Object *ob = base->object; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -712,20 +712,20 @@ static void *acf_object_setting_ptr(bAnimListElem *ale, int setting, short *type /* object type define */ static bAnimChannelType ACF_OBJECT = { - "Object", /* type name */ + "Object", /* type name */ - acf_generic_root_color, /* backdrop color */ - acf_generic_root_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - NULL, /* offset */ - - acf_object_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_object_icon, /* icon */ - - acf_object_setting_valid, /* has setting */ - acf_object_setting_flag, /* flag for setting */ - acf_object_setting_ptr /* pointer for setting */ + acf_generic_root_color, /* backdrop color */ + acf_generic_root_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + NULL, /* offset */ + + acf_object_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_object_icon, /* icon */ + + acf_object_setting_valid, /* has setting */ + acf_object_setting_flag, /* flag for setting */ + acf_object_setting_ptr /* pointer for setting */ }; /* Group ------------------------------------------- */ @@ -743,10 +743,10 @@ static void acf_group_color(bAnimContext *UNUSED(ac), bAnimListElem *ale, float /* backdrop for group widget */ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - short expanded= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; - short offset= (acf->get_offset) ? acf->get_offset(ac, ale) : 0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + short expanded = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_EXPAND) != 0; + short offset = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; float color[3]; /* set backdrop drawing color */ @@ -755,13 +755,13 @@ static void acf_group_backdrop(bAnimContext *ac, bAnimListElem *ale, float yminc /* rounded corners on LHS only - top only when expanded, but bottom too when collapsed */ uiSetRoundBox(expanded ? UI_CNR_TOP_LEFT : (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT)); - uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc, 8); + uiDrawBox(GL_POLYGON, offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc, 8); } /* name for group entries */ static void acf_group_name(bAnimListElem *ale, char *name) { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* just copy the name... */ if (agrp && name) @@ -783,7 +783,7 @@ static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale /* for now, all settings are supported, though some are only conditionally */ switch (setting) { case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ - return (ac->spacetype==SPACE_IPO); + return (ac->spacetype == SPACE_IPO); default: /* always supported */ return 1; @@ -794,7 +794,7 @@ static short acf_group_setting_valid(bAnimContext *ac, bAnimListElem *UNUSED(ale static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -807,8 +807,8 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) * proved to be a hazard for workflows... */ return (ac->spacetype == SPACE_IPO) ? - AGRP_EXPANDED_G : /* Graph Editor case */ - AGRP_EXPANDED; /* DopeSheet and elsewhere */ + AGRP_EXPANDED_G : /* Graph Editor case */ + AGRP_EXPANDED; /* DopeSheet and elsewhere */ } case ACHANNEL_SETTING_MUTE: /* muted */ @@ -819,7 +819,7 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) return AGRP_PROTECTED; case ACHANNEL_SETTING_VISIBLE: /* visiblity - graph editor */ - *neg= 1; + *neg = 1; return AGRP_NOTVISIBLE; } @@ -830,7 +830,7 @@ static int acf_group_setting_flag(bAnimContext *ac, int setting, short *neg) /* get pointer to the setting */ static void *acf_group_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(agrp->flag, type); @@ -839,20 +839,20 @@ static void *acf_group_setting_ptr(bAnimListElem *ale, int UNUSED(setting), shor /* group type define */ static bAnimChannelType ACF_GROUP = { - "Group", /* type name */ + "Group", /* type name */ - acf_group_color, /* backdrop color */ - acf_group_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_group_offset, /* offset */ - - acf_group_name, /* name */ - acf_group_name_prop, /* name prop */ - NULL, /* icon */ - - acf_group_setting_valid, /* has setting */ - acf_group_setting_flag, /* flag for setting */ - acf_group_setting_ptr /* pointer for setting */ + acf_group_color, /* backdrop color */ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_group_name, /* name */ + acf_group_name_prop, /* name prop */ + NULL, /* icon */ + + acf_group_setting_valid, /* has setting */ + acf_group_setting_flag, /* flag for setting */ + acf_group_setting_ptr /* pointer for setting */ }; /* F-Curve ------------------------------------------- */ @@ -866,7 +866,7 @@ static void acf_fcurve_name(bAnimListElem *ale, char *name) /* check if some setting exists for this channel */ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int setting) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; switch (setting) { /* unsupported */ @@ -878,10 +878,10 @@ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int if (fcu->bezt) return 1; else - return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT + return 0; // NOTE: in this special case, we need to draw ICON_ZOOMOUT case ACHANNEL_SETTING_VISIBLE: /* Only available in Graph Editor */ - return (ac->spacetype==SPACE_IPO); + return (ac->spacetype == SPACE_IPO); /* always available */ default: @@ -893,7 +893,7 @@ static short acf_fcurve_setting_valid(bAnimContext *ac, bAnimListElem *ale, int static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -917,7 +917,7 @@ static int acf_fcurve_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(fcu->flag, type); @@ -926,20 +926,20 @@ static void *acf_fcurve_setting_ptr(bAnimListElem *ale, int UNUSED(setting), sho /* fcurve type define */ static bAnimChannelType ACF_FCURVE = { - "F-Curve", /* type name */ + "F-Curve", /* type name */ - acf_generic_channel_color, /* backdrop color */ - acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? - acf_generic_group_offset, /* offset */ - - acf_fcurve_name, /* name */ - NULL, /* name prop */ - NULL, /* icon */ - - acf_fcurve_setting_valid, /* has setting */ - acf_fcurve_setting_flag, /* flag for setting */ - acf_fcurve_setting_ptr /* pointer for setting */ + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ // xxx rename this to f-curves only? + acf_generic_group_offset, /* offset */ + + acf_fcurve_name, /* name */ + NULL, /* name prop */ + NULL, /* icon */ + + acf_fcurve_setting_valid, /* has setting */ + acf_fcurve_setting_flag, /* flag for setting */ + acf_fcurve_setting_ptr /* pointer for setting */ }; /* Object Action Expander ------------------------------------------- */ @@ -968,14 +968,14 @@ static short acf_fillactd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ return ADT_UI_SELECTED; case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return ACT_COLLAPSED; default: /* unsupported */ @@ -986,11 +986,11 @@ static int acf_fillactd_setting_flag(bAnimContext *UNUSED(ac), int setting, shor /* get pointer to the setting */ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bAction *act= (bAction *)ale->data; - AnimData *adt= ale->adt; + bAction *act = (bAction *)ale->data; + AnimData *adt = ale->adt; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1011,20 +1011,20 @@ static void *acf_fillactd_setting_ptr(bAnimListElem *ale, int setting, short *ty /* object action expander type define */ static bAnimChannelType ACF_FILLACTD = { - "Ob-Action Filler", /* type name */ + "Ob-Action Filler", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_fillactd_icon, /* icon */ - - acf_fillactd_setting_valid, /* has setting */ - acf_fillactd_setting_flag, /* flag for setting */ - acf_fillactd_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_fillactd_icon, /* icon */ + + acf_fillactd_setting_valid, /* has setting */ + acf_fillactd_setting_flag, /* flag for setting */ + acf_fillactd_setting_ptr /* pointer for setting */ }; /* Drivers Expander ------------------------------------------- */ @@ -1058,11 +1058,11 @@ static short acf_filldrivers_setting_valid(bAnimContext *UNUSED(ac), bAnimListEl static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ - *neg= 1; + *neg = 1; return ADT_DRIVERS_COLLAPSED; default: /* unsupported */ @@ -1073,10 +1073,10 @@ static int acf_filldrivers_setting_flag(bAnimContext *UNUSED(ac), int setting, s /* get pointer to the setting */ static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short *type) { - AnimData *adt= (AnimData *)ale->data; + AnimData *adt = (AnimData *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1090,20 +1090,20 @@ static void *acf_filldrivers_setting_ptr(bAnimListElem *ale, int setting, short /* drivers expander type define */ static bAnimChannelType ACF_FILLDRIVERS = { - "Drivers Filler", /* type name */ + "Drivers Filler", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_filldrivers_name, /* name */ - NULL, /* name prop */ - acf_filldrivers_icon, /* icon */ - - acf_filldrivers_setting_valid, /* has setting */ - acf_filldrivers_setting_flag, /* flag for setting */ - acf_filldrivers_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_filldrivers_name, /* name */ + NULL, /* name prop */ + acf_filldrivers_icon, /* icon */ + + acf_filldrivers_setting_valid, /* has setting */ + acf_filldrivers_setting_flag, /* flag for setting */ + acf_filldrivers_setting_ptr /* pointer for setting */ }; @@ -1119,7 +1119,7 @@ static int acf_dsmat_icon(bAnimListElem *UNUSED(ale)) static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1129,7 +1129,7 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1143,10 +1143,10 @@ static int acf_dsmat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Material *ma= (Material *)ale->data; + Material *ma = (Material *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1166,22 +1166,22 @@ static void *acf_dsmat_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* material expander type define */ -static bAnimChannelType ACF_DSMAT= +static bAnimChannelType ACF_DSMAT = { - "Material Data Expander", /* type name */ + "Material Data Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsmat_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsmat_setting_flag, /* flag for setting */ - acf_dsmat_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsmat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmat_setting_flag, /* flag for setting */ + acf_dsmat_setting_ptr /* pointer for setting */ }; /* Lamp Expander ------------------------------------------- */ @@ -1196,7 +1196,7 @@ static int acf_dslam_icon(bAnimListElem *UNUSED(ale)) static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1206,7 +1206,7 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1220,10 +1220,10 @@ static int acf_dslam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Lamp *la= (Lamp *)ale->data; + Lamp *la = (Lamp *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1243,22 +1243,22 @@ static void *acf_dslam_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* lamp expander type define */ -static bAnimChannelType ACF_DSLAM= +static bAnimChannelType ACF_DSLAM = { - "Lamp Expander", /* type name */ + "Lamp Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dslam_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dslam_setting_flag, /* flag for setting */ - acf_dslam_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dslam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslam_setting_flag, /* flag for setting */ + acf_dslam_setting_ptr /* pointer for setting */ }; /* Texture Expander ------------------------------------------- */ @@ -1280,7 +1280,7 @@ static short acf_dstex_offset(bAnimContext *UNUSED(ac), bAnimListElem *UNUSED(al static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1290,7 +1290,7 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1304,10 +1304,10 @@ static int acf_dstex_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Tex *tex= (Tex *)ale->data; + Tex *tex = (Tex *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1327,22 +1327,22 @@ static void *acf_dstex_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* texture expander type define */ -static bAnimChannelType ACF_DSTEX= +static bAnimChannelType ACF_DSTEX = { - "Texture Data Expander", /* type name */ + "Texture Data Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_dstex_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_dstex_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dstex_setting_flag, /* flag for setting */ - acf_dstex_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_dstex_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_dstex_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dstex_setting_flag, /* flag for setting */ + acf_dstex_setting_ptr /* pointer for setting */ }; /* Camera Expander ------------------------------------------- */ @@ -1357,7 +1357,7 @@ static int acf_dscam_icon(bAnimListElem *UNUSED(ale)) static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1367,7 +1367,7 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1381,10 +1381,10 @@ static int acf_dscam_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Camera *ca= (Camera *)ale->data; + Camera *ca = (Camera *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1404,22 +1404,22 @@ static void *acf_dscam_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* camera expander type define */ -static bAnimChannelType ACF_DSCAM= +static bAnimChannelType ACF_DSCAM = { - "Camera Expander", /* type name */ + "Camera Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_dscam_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dscam_setting_flag, /* flag for setting */ - acf_dscam_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_dscam_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscam_setting_flag, /* flag for setting */ + acf_dscam_setting_ptr /* pointer for setting */ }; /* Curve Expander ------------------------------------------- */ @@ -1427,8 +1427,8 @@ static bAnimChannelType ACF_DSCAM= // TODO: just get this from RNA? static int acf_dscur_icon(bAnimListElem *ale) { - Curve *cu= (Curve *)ale->data; - short obtype= BKE_curve_type_get(cu); + Curve *cu = (Curve *)ale->data; + short obtype = BKE_curve_type_get(cu); switch (obtype) { case OB_FONT: @@ -1444,7 +1444,7 @@ static int acf_dscur_icon(bAnimListElem *ale) static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1454,7 +1454,7 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1468,10 +1468,10 @@ static int acf_dscur_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Curve *cu= (Curve *)ale->data; + Curve *cu = (Curve *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1491,22 +1491,22 @@ static void *acf_dscur_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* curve expander type define */ -static bAnimChannelType ACF_DSCUR= +static bAnimChannelType ACF_DSCUR = { - "Curve Expander", /* type name */ + "Curve Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dscur_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dscur_setting_flag, /* flag for setting */ - acf_dscur_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dscur_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dscur_setting_flag, /* flag for setting */ + acf_dscur_setting_ptr /* pointer for setting */ }; /* Shape Key Expander ------------------------------------------- */ @@ -1521,7 +1521,7 @@ static int acf_dsskey_icon(bAnimListElem *UNUSED(ale)) static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1531,7 +1531,7 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1545,10 +1545,10 @@ static int acf_dsskey_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Key *key= (Key *)ale->data; + Key *key = (Key *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1568,22 +1568,22 @@ static void *acf_dsskey_setting_ptr(bAnimListElem *ale, int setting, short *type } /* shapekey expander type define */ -static bAnimChannelType ACF_DSSKEY= +static bAnimChannelType ACF_DSSKEY = { - "Shape Key Expander", /* type name */ + "Shape Key Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsskey_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsskey_setting_flag, /* flag for setting */ - acf_dsskey_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsskey_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsskey_setting_flag, /* flag for setting */ + acf_dsskey_setting_ptr /* pointer for setting */ }; /* World Expander ------------------------------------------- */ @@ -1598,7 +1598,7 @@ static int acf_dswor_icon(bAnimListElem *UNUSED(ale)) static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1608,7 +1608,7 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1622,10 +1622,10 @@ static int acf_dswor_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) { - World *wo= (World *)ale->data; + World *wo = (World *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1645,22 +1645,22 @@ static void *acf_dswor_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* world expander type define */ -static bAnimChannelType ACF_DSWOR= +static bAnimChannelType ACF_DSWOR = { - "World Expander", /* type name */ + "World Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_dswor_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dswor_setting_flag, /* flag for setting */ - acf_dswor_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_dswor_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dswor_setting_flag, /* flag for setting */ + acf_dswor_setting_ptr /* pointer for setting */ }; /* Particle Expander ------------------------------------------- */ @@ -1675,7 +1675,7 @@ static int acf_dspart_icon(bAnimListElem *UNUSED(ale)) static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1685,7 +1685,7 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1699,10 +1699,10 @@ static int acf_dspart_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type) { - ParticleSettings *part= (ParticleSettings *)ale->data; + ParticleSettings *part = (ParticleSettings *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1722,22 +1722,22 @@ static void *acf_dspart_setting_ptr(bAnimListElem *ale, int setting, short *type } /* particle expander type define */ -static bAnimChannelType ACF_DSPART= +static bAnimChannelType ACF_DSPART = { - "Particle Data Expander", /* type name */ + "Particle Data Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dspart_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dspart_setting_flag, /* flag for setting */ - acf_dspart_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dspart_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dspart_setting_flag, /* flag for setting */ + acf_dspart_setting_ptr /* pointer for setting */ }; /* MetaBall Expander ------------------------------------------- */ @@ -1752,7 +1752,7 @@ static int acf_dsmball_icon(bAnimListElem *UNUSED(ale)) static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1762,7 +1762,7 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1776,10 +1776,10 @@ static int acf_dsmball_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *type) { - MetaBall *mb= (MetaBall *)ale->data; + MetaBall *mb = (MetaBall *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1799,22 +1799,22 @@ static void *acf_dsmball_setting_ptr(bAnimListElem *ale, int setting, short *typ } /* metaball expander type define */ -static bAnimChannelType ACF_DSMBALL= +static bAnimChannelType ACF_DSMBALL = { - "Metaball Expander", /* type name */ + "Metaball Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsmball_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsmball_setting_flag, /* flag for setting */ - acf_dsmball_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsmball_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmball_setting_flag, /* flag for setting */ + acf_dsmball_setting_ptr /* pointer for setting */ }; /* Armature Expander ------------------------------------------- */ @@ -1829,7 +1829,7 @@ static int acf_dsarm_icon(bAnimListElem *UNUSED(ale)) static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1839,7 +1839,7 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1853,10 +1853,10 @@ static int acf_dsarm_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bArmature *arm= (bArmature *)ale->data; + bArmature *arm = (bArmature *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1876,22 +1876,22 @@ static void *acf_dsarm_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* metaball expander type define */ -static bAnimChannelType ACF_DSARM= +static bAnimChannelType ACF_DSARM = { - "Armature Expander", /* type name */ + "Armature Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsarm_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsarm_setting_flag, /* flag for setting */ - acf_dsarm_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsarm_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsarm_setting_flag, /* flag for setting */ + acf_dsarm_setting_ptr /* pointer for setting */ }; /* NodeTree Expander ------------------------------------------- */ @@ -1906,7 +1906,7 @@ static int acf_dsntree_icon(bAnimListElem *UNUSED(ale)) static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) { bNodeTree *ntree = (bNodeTree *)ale->data; - short offset= acf_generic_basic_offset(ac, ale); + short offset = acf_generic_basic_offset(ac, ale); offset += acf_nodetree_rootType_offset(ntree); @@ -1917,7 +1917,7 @@ static short acf_dsntree_offset(bAnimContext *ac, bAnimListElem *ale) static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1927,7 +1927,7 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -1941,10 +1941,10 @@ static int acf_dsntree_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *type) { - bNodeTree *ntree= (bNodeTree *)ale->data; + bNodeTree *ntree = (bNodeTree *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -1955,8 +1955,8 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *typ case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (ntree->adt) return GET_ACF_FLAG_PTR(ntree->adt->flag, type); - else - return NULL; + else + return NULL; default: /* unsupported */ return NULL; @@ -1964,22 +1964,22 @@ static void *acf_dsntree_setting_ptr(bAnimListElem *ale, int setting, short *typ } /* node tree expander type define */ -static bAnimChannelType ACF_DSNTREE= +static bAnimChannelType ACF_DSNTREE = { - "Node Tree Expander", /* type name */ + "Node Tree Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_dsntree_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsntree_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsntree_setting_flag, /* flag for setting */ - acf_dsntree_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_dsntree_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsntree_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsntree_setting_flag, /* flag for setting */ + acf_dsntree_setting_ptr /* pointer for setting */ }; /* LineStyle Expander ------------------------------------------- */ @@ -2071,7 +2071,7 @@ static int acf_dsmesh_icon(bAnimListElem *UNUSED(ale)) static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2081,7 +2081,7 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2095,10 +2095,10 @@ static int acf_dsmesh_setting_flag(bAnimContext *UNUSED(ac), int setting, short /* get pointer to the setting */ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Mesh *me= (Mesh *)ale->data; + Mesh *me = (Mesh *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2109,8 +2109,8 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (me->adt) return GET_ACF_FLAG_PTR(me->adt->flag, type); - else - return NULL; + else + return NULL; default: /* unsupported */ return NULL; @@ -2118,22 +2118,22 @@ static void *acf_dsmesh_setting_ptr(bAnimListElem *ale, int setting, short *type } /* node tree expander type define */ -static bAnimChannelType ACF_DSMESH= +static bAnimChannelType ACF_DSMESH = { - "Mesh Expander", /* type name */ + "Mesh Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ // XXX this only works for compositing - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsmesh_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsmesh_setting_flag, /* flag for setting */ - acf_dsmesh_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ // XXX this only works for compositing + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsmesh_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsmesh_setting_flag, /* flag for setting */ + acf_dsmesh_setting_ptr /* pointer for setting */ }; /* Lattice Expander ------------------------------------------- */ @@ -2148,7 +2148,7 @@ static int acf_dslat_icon(bAnimListElem *UNUSED(ale)) static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2158,7 +2158,7 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2172,10 +2172,10 @@ static int acf_dslat_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Lattice *lt= (Lattice *)ale->data; + Lattice *lt = (Lattice *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2186,8 +2186,8 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) case ACHANNEL_SETTING_VISIBLE: /* visible (for Graph Editor only) */ if (lt->adt) return GET_ACF_FLAG_PTR(lt->adt->flag, type); - else - return NULL; + else + return NULL; default: /* unsupported */ return NULL; @@ -2195,22 +2195,22 @@ static void *acf_dslat_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* node tree expander type define */ -static bAnimChannelType ACF_DSLAT= +static bAnimChannelType ACF_DSLAT = { - "Lattice Expander", /* type name */ + "Lattice Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ // XXX this only works for compositing - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dslat_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dslat_setting_flag, /* flag for setting */ - acf_dslat_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ // XXX this only works for compositing + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dslat_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dslat_setting_flag, /* flag for setting */ + acf_dslat_setting_ptr /* pointer for setting */ }; /* Speaker Expander ------------------------------------------- */ @@ -2225,7 +2225,7 @@ static int acf_dsspk_icon(bAnimListElem *UNUSED(ale)) static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2235,7 +2235,7 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * return ADT_NLA_EVAL_OFF; case ACHANNEL_SETTING_VISIBLE: /* visible (only in Graph Editor) */ - *neg= 1; + *neg = 1; return ADT_CURVES_NOT_VISIBLE; case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2249,10 +2249,10 @@ static int acf_dsspk_setting_flag(bAnimContext *UNUSED(ac), int setting, short * /* get pointer to the setting */ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type) { - Speaker *spk= (Speaker *)ale->data; + Speaker *spk = (Speaker *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_EXPAND: /* expanded */ @@ -2272,22 +2272,22 @@ static void *acf_dsspk_setting_ptr(bAnimListElem *ale, int setting, short *type) } /* speaker expander type define */ -static bAnimChannelType ACF_DSSPK= +static bAnimChannelType ACF_DSSPK = { - "Speaker Expander", /* type name */ + "Speaker Expander", /* type name */ - acf_generic_dataexpand_color, /* backdrop color */ - acf_generic_dataexpand_backdrop,/* backdrop */ - acf_generic_indention_1, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idblock_nameprop, /* name prop */ - acf_dsspk_icon, /* icon */ - - acf_generic_dataexpand_setting_valid, /* has setting */ - acf_dsspk_setting_flag, /* flag for setting */ - acf_dsspk_setting_ptr /* pointer for setting */ + acf_generic_dataexpand_color, /* backdrop color */ + acf_generic_dataexpand_backdrop, /* backdrop */ + acf_generic_indention_1, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idblock_nameprop, /* name prop */ + acf_dsspk_icon, /* icon */ + + acf_generic_dataexpand_setting_valid, /* has setting */ + acf_dsspk_setting_flag, /* flag for setting */ + acf_dsspk_setting_ptr /* pointer for setting */ }; /* ShapeKey Entry ------------------------------------------- */ @@ -2295,7 +2295,7 @@ static bAnimChannelType ACF_DSSPK= /* name for ShapeKey */ static void acf_shapekey_name(bAnimListElem *ale, char *name) { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* just copy the name... */ if (kb && name) { @@ -2310,7 +2310,7 @@ static void acf_shapekey_name(bAnimListElem *ale, char *name) /* name property for ShapeKey entries */ static short acf_shapekey_nameprop(bAnimListElem *ale, PointerRNA *ptr, PropertyRNA **prop) { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* if the KeyBlock had a name, use it, otherwise use the index */ if (kb && kb->name[0]) { @@ -2342,7 +2342,7 @@ static short acf_shapekey_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_MUTE: /* mute */ @@ -2362,10 +2362,10 @@ static int acf_shapekey_setting_flag(bAnimContext *UNUSED(ac), int setting, shor /* get pointer to the setting */ static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *type) { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* clear extra return data first */ - *type= 0; + *type = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2379,22 +2379,22 @@ static void *acf_shapekey_setting_ptr(bAnimListElem *ale, int setting, short *ty } /* shapekey expander type define */ -static bAnimChannelType ACF_SHAPEKEY= +static bAnimChannelType ACF_SHAPEKEY = { - "Shape Key", /* type name */ + "Shape Key", /* type name */ - acf_generic_channel_color, /* backdrop color */ - acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_basic_offset, /* offset */ - - acf_shapekey_name, /* name */ - acf_shapekey_nameprop, /* name prop */ - NULL, /* icon */ - - acf_shapekey_setting_valid, /* has setting */ - acf_shapekey_setting_flag, /* flag for setting */ - acf_shapekey_setting_ptr /* pointer for setting */ + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_basic_offset, /* offset */ + + acf_shapekey_name, /* name */ + acf_shapekey_nameprop, /* name prop */ + NULL, /* icon */ + + acf_shapekey_setting_valid, /* has setting */ + acf_shapekey_setting_flag, /* flag for setting */ + acf_shapekey_setting_ptr /* pointer for setting */ }; /* GPencil Datablock ------------------------------------------- */ @@ -2430,7 +2430,7 @@ static short acf_gpd_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2447,7 +2447,7 @@ static int acf_gpd_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne /* get pointer to the setting */ static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - bGPdata *gpd= (bGPdata *)ale->data; + bGPdata *gpd = (bGPdata *)ale->data; /* all flags are just in gpd->flag for now... */ return GET_ACF_FLAG_PTR(gpd->flag, type); @@ -2456,20 +2456,20 @@ static void *acf_gpd_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short /* gpencil datablock type define */ static bAnimChannelType ACF_GPD = { - "GPencil Datablock", /* type name */ + "GPencil Datablock", /* type name */ - acf_gpd_color, /* backdrop color */ - acf_group_backdrop, /* backdrop */ - acf_generic_indention_0, /* indent level */ - acf_generic_group_offset, /* offset */ - - acf_generic_idblock_name, /* name */ - acf_generic_idfill_nameprop, /* name prop */ - acf_gpd_icon, /* icon */ - - acf_gpd_setting_valid, /* has setting */ - acf_gpd_setting_flag, /* flag for setting */ - acf_gpd_setting_ptr /* pointer for setting */ + acf_gpd_color, /* backdrop color */ + acf_group_backdrop, /* backdrop */ + acf_generic_indention_0, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_generic_idblock_name, /* name */ + acf_generic_idfill_nameprop, /* name prop */ + acf_gpd_icon, /* icon */ + + acf_gpd_setting_valid, /* has setting */ + acf_gpd_setting_flag, /* flag for setting */ + acf_gpd_setting_ptr /* pointer for setting */ }; /* GPencil Layer ------------------------------------------- */ @@ -2515,7 +2515,7 @@ static short acf_gpl_setting_valid(bAnimContext *UNUSED(ac), bAnimListElem *UNUS static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *neg) { /* clear extra return data first */ - *neg= 0; + *neg = 0; switch (setting) { case ACHANNEL_SETTING_SELECT: /* selected */ @@ -2536,7 +2536,7 @@ static int acf_gpl_setting_flag(bAnimContext *UNUSED(ac), int setting, short *ne /* get pointer to the setting */ static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short *type) { - bGPDlayer *gpl= (bGPDlayer *)ale->data; + bGPDlayer *gpl = (bGPDlayer *)ale->data; /* all flags are just in agrp->flag for now... */ return GET_ACF_FLAG_PTR(gpl->flag, type); @@ -2545,20 +2545,20 @@ static void *acf_gpl_setting_ptr(bAnimListElem *ale, int UNUSED(setting), short /* grease pencil layer type define */ static bAnimChannelType ACF_GPL = { - "GPencil Layer", /* type name */ + "GPencil Layer", /* type name */ - acf_generic_channel_color, /* backdrop color */ - acf_generic_channel_backdrop, /* backdrop */ - acf_generic_indention_flexible, /* indent level */ - acf_generic_group_offset, /* offset */ - - acf_gpl_name, /* name */ - acf_gpl_name_prop, /* name prop */ - NULL, /* icon */ - - acf_gpl_setting_valid, /* has setting */ - acf_gpl_setting_flag, /* flag for setting */ - acf_gpl_setting_ptr /* pointer for setting */ + acf_generic_channel_color, /* backdrop color */ + acf_generic_channel_backdrop, /* backdrop */ + acf_generic_indention_flexible, /* indent level */ + acf_generic_group_offset, /* offset */ + + acf_gpl_name, /* name */ + acf_gpl_name_prop, /* name prop */ + NULL, /* icon */ + + acf_gpl_setting_valid, /* has setting */ + acf_gpl_setting_flag, /* flag for setting */ + acf_gpl_setting_ptr /* pointer for setting */ }; /* *********************************************** */ @@ -2566,61 +2566,61 @@ static bAnimChannelType ACF_GPL = /* These globals only ever get directly accessed in this file */ static bAnimChannelType *animchannelTypeInfo[ANIMTYPE_NUM_TYPES]; -static short ACF_INIT= 1; /* when non-zero, the list needs to be updated */ +static short ACF_INIT = 1; /* when non-zero, the list needs to be updated */ /* Initialize type info definitions */ -static void ANIM_init_channel_typeinfo_data (void) +static void ANIM_init_channel_typeinfo_data(void) { - int type= 0; + int type = 0; /* start initializing if necessary... */ if (ACF_INIT) { - ACF_INIT= 0; + ACF_INIT = 0; - animchannelTypeInfo[type++]= NULL; /* None */ - animchannelTypeInfo[type++]= NULL; /* AnimData */ - animchannelTypeInfo[type++]= NULL; /* Special */ - - animchannelTypeInfo[type++]= &ACF_SUMMARY; /* Motion Summary */ - - animchannelTypeInfo[type++]= &ACF_SCENE; /* Scene */ - animchannelTypeInfo[type++]= &ACF_OBJECT; /* Object */ - animchannelTypeInfo[type++]= &ACF_GROUP; /* Group */ - animchannelTypeInfo[type++]= &ACF_FCURVE; /* F-Curve */ - - animchannelTypeInfo[type++]= &ACF_FILLACTD; /* Object Action Expander */ - animchannelTypeInfo[type++]= &ACF_FILLDRIVERS; /* Drivers Expander */ - - animchannelTypeInfo[type++]= &ACF_DSMAT; /* Material Channel */ - animchannelTypeInfo[type++]= &ACF_DSLAM; /* Lamp Channel */ - animchannelTypeInfo[type++]= &ACF_DSCAM; /* Camera Channel */ - animchannelTypeInfo[type++]= &ACF_DSCUR; /* Curve Channel */ - animchannelTypeInfo[type++]= &ACF_DSSKEY; /* ShapeKey Channel */ - animchannelTypeInfo[type++]= &ACF_DSWOR; /* World Channel */ - animchannelTypeInfo[type++]= &ACF_DSNTREE; /* NodeTree Channel */ - animchannelTypeInfo[type++]= &ACF_DSPART; /* Particle Channel */ - animchannelTypeInfo[type++]= &ACF_DSMBALL; /* MetaBall Channel */ - animchannelTypeInfo[type++]= &ACF_DSARM; /* Armature Channel */ - animchannelTypeInfo[type++]= &ACF_DSMESH; /* Mesh Channel */ - animchannelTypeInfo[type++]= &ACF_DSTEX; /* Texture Channel */ - animchannelTypeInfo[type++]= &ACF_DSLAT; /* Lattice Channel */ - animchannelTypeInfo[type++]= &ACF_DSLINESTYLE; /* LineStyle Channel */ - animchannelTypeInfo[type++]= &ACF_DSSPK; /* Speaker Channel */ - - animchannelTypeInfo[type++]= &ACF_SHAPEKEY; /* ShapeKey */ - - animchannelTypeInfo[type++]= &ACF_GPD; /* Grease Pencil Datablock */ - animchannelTypeInfo[type++]= &ACF_GPL; /* Grease Pencil Layer */ - - // TODO: these types still need to be implemented!!! - // probably need a few extra flags for these special cases... - animchannelTypeInfo[type++]= NULL; /* NLA Track */ - animchannelTypeInfo[type++]= NULL; /* NLA Action */ + animchannelTypeInfo[type++] = NULL; /* None */ + animchannelTypeInfo[type++] = NULL; /* AnimData */ + animchannelTypeInfo[type++] = NULL; /* Special */ + + animchannelTypeInfo[type++] = &ACF_SUMMARY; /* Motion Summary */ + + animchannelTypeInfo[type++] = &ACF_SCENE; /* Scene */ + animchannelTypeInfo[type++] = &ACF_OBJECT; /* Object */ + animchannelTypeInfo[type++] = &ACF_GROUP; /* Group */ + animchannelTypeInfo[type++] = &ACF_FCURVE; /* F-Curve */ + + animchannelTypeInfo[type++] = &ACF_FILLACTD; /* Object Action Expander */ + animchannelTypeInfo[type++] = &ACF_FILLDRIVERS; /* Drivers Expander */ + + animchannelTypeInfo[type++] = &ACF_DSMAT; /* Material Channel */ + animchannelTypeInfo[type++] = &ACF_DSLAM; /* Lamp Channel */ + animchannelTypeInfo[type++] = &ACF_DSCAM; /* Camera Channel */ + animchannelTypeInfo[type++] = &ACF_DSCUR; /* Curve Channel */ + animchannelTypeInfo[type++] = &ACF_DSSKEY; /* ShapeKey Channel */ + animchannelTypeInfo[type++] = &ACF_DSWOR; /* World Channel */ + animchannelTypeInfo[type++] = &ACF_DSNTREE; /* NodeTree Channel */ + animchannelTypeInfo[type++] = &ACF_DSPART; /* Particle Channel */ + animchannelTypeInfo[type++] = &ACF_DSMBALL; /* MetaBall Channel */ + animchannelTypeInfo[type++] = &ACF_DSARM; /* Armature Channel */ + animchannelTypeInfo[type++] = &ACF_DSMESH; /* Mesh Channel */ + animchannelTypeInfo[type++] = &ACF_DSTEX; /* Texture Channel */ + animchannelTypeInfo[type++] = &ACF_DSLAT; /* Lattice Channel */ + animchannelTypeInfo[type++] = &ACF_DSSPK; /* Speaker Channel */ + animchannelTypeInfo[type++] = &ACF_DSLINESTYLE; /* LineStyle Channel */ + + animchannelTypeInfo[type++] = &ACF_SHAPEKEY; /* ShapeKey */ + + animchannelTypeInfo[type++] = &ACF_GPD; /* Grease Pencil Datablock */ + animchannelTypeInfo[type++] = &ACF_GPL; /* Grease Pencil Layer */ + + // TODO: these types still need to be implemented!!! + // probably need a few extra flags for these special cases... + animchannelTypeInfo[type++] = NULL; /* NLA Track */ + animchannelTypeInfo[type++] = NULL; /* NLA Action */ } } /* Get type info from given channel type */ -bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) +bAnimChannelType *ANIM_channel_get_typeinfo(bAnimListElem *ale) { /* santiy checks */ if (ale == NULL) @@ -2641,7 +2641,7 @@ bAnimChannelType *ANIM_channel_get_typeinfo (bAnimListElem *ale) /* Print debug info string for the given channel */ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* print indents */ for (; indent_level > 0; indent_level--) @@ -2673,7 +2673,7 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) */ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { @@ -2682,44 +2682,44 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting int flag; void *ptr; - flag= acf->setting_flag(ac, setting, &negflag); - ptr= acf->setting_ptr(ale, setting, &ptrsize); + flag = acf->setting_flag(ac, setting, &negflag); + ptr = acf->setting_ptr(ale, setting, &ptrsize); /* check if flag is enabled */ if (ptr && flag) { switch (ptrsize) { - case sizeof(int): /* integer pointer for setting */ + case sizeof(int): /* integer pointer for setting */ { - int *val= (int *)ptr; + int *val = (int *)ptr; if (negflag) return ((*val) & flag) == 0; else return ((*val) & flag) != 0; } - break; + break; - case sizeof(short): /* short pointer for setting */ + case sizeof(short): /* short pointer for setting */ { - short *val= (short *)ptr; + short *val = (short *)ptr; if (negflag) return ((*val) & flag) == 0; else return ((*val) & flag) != 0; } - break; + break; - case sizeof(char): /* char pointer for setting */ + case sizeof(char): /* char pointer for setting */ { - char *val= (char *)ptr; + char *val = (char *)ptr; if (negflag) return ((*val) & flag) == 0; else return ((*val) & flag) != 0; } - break; + break; } } } @@ -2731,17 +2731,17 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting /* quick macro for use in ANIM_channel_setting_set - set flag for setting according the mode given */ #define ACF_SETTING_SET(sval, sflag, smode) \ - {\ - if (negflag) {\ - if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ + { \ + if (negflag) { \ + if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ else if (smode == ACHANNEL_SETFLAG_ADD) (sval) &= ~(sflag); \ - else (sval) |= (sflag); \ + else (sval) |= (sflag); \ } \ - else {\ - if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ + else { \ + if (smode == ACHANNEL_SETFLAG_INVERT) (sval) ^= (sflag); \ else if (smode == ACHANNEL_SETFLAG_ADD) (sval) |= (sflag); \ - else (sval) &= ~(sflag); \ - }\ + else (sval) &= ~(sflag); \ + } \ } /* Change value of some setting for a channel @@ -2750,7 +2750,7 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, int setting */ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, short mode) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); /* 1) check that the setting exists for the current context */ if ((acf) && (!acf->has_setting || acf->has_setting(ac, ale, setting))) { @@ -2759,32 +2759,32 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, int flag; void *ptr; - flag= acf->setting_flag(ac, setting, &negflag); - ptr= acf->setting_ptr(ale, setting, &ptrsize); + flag = acf->setting_flag(ac, setting, &negflag); + ptr = acf->setting_ptr(ale, setting, &ptrsize); /* check if flag is enabled */ if (ptr && flag) { switch (ptrsize) { - case sizeof(int): /* integer pointer for setting */ + case sizeof(int): /* integer pointer for setting */ { - int *val= (int *)ptr; + int *val = (int *)ptr; ACF_SETTING_SET(*val, flag, mode); } - break; + break; - case sizeof(short): /* short pointer for setting */ + case sizeof(short): /* short pointer for setting */ { - short *val= (short *)ptr; + short *val = (short *)ptr; ACF_SETTING_SET(*val, flag, mode); } - break; + break; - case sizeof(char): /* char pointer for setting */ + case sizeof(char): /* char pointer for setting */ { - char *val= (char *)ptr; + char *val = (char *)ptr; ACF_SETTING_SET(*val, flag, mode); } - break; + break; } } } @@ -2793,9 +2793,9 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, /* --------------------------- */ // XXX hardcoded size of icons -#define ICON_WIDTH 17 +#define ICON_WIDTH 17 // XXX hardcoded width of sliders -#define SLIDER_WIDTH 80 +#define SLIDER_WIDTH 80 // XXX hardcoded width of rename textboxes #define RENAME_TEXT_WIDTH 100 @@ -2803,8 +2803,8 @@ void ANIM_channel_setting_set(bAnimContext *ac, bAnimListElem *ale, int setting, // TODO: make this use UI controls for the buttons void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float ymaxc) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; short selected, offset; float y, ymid, ytext; @@ -2814,23 +2814,23 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* get initial offset */ if (acf->get_offset) - offset= acf->get_offset(ac, ale); + offset = acf->get_offset(ac, ale); else - offset= 0; + offset = 0; /* calculate appropriate y-coordinates for icon buttons * 7 is hardcoded factor for half-height of icons */ - y= (ymaxc - yminc)/2 + yminc; - ymid= y - 7; + y = (ymaxc - yminc) / 2 + yminc; + ymid = y - 7; /* y-coordinates for text is only 4 down from middle */ - ytext= y - 4; + ytext = y - 4; /* check if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) - selected= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + selected = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); else - selected= 0; + selected = 0; /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2863,7 +2863,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float if ((ac->spacetype == SPACE_IPO) && acf->has_setting(ac, ale, ACHANNEL_SETTING_VISIBLE)) { /* for F-Curves, draw color-preview of curve behind checkbox */ if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; /* F-Curve channels need to have a special 'color code' box drawn, which is colored with whatever * color the curve has stored @@ -2871,10 +2871,10 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float glColor3fv(fcu->color); /* just a solid color rect - * hardcoded 17 pixels width is slightly wider than icon width, so that + * hardcoded 17 pixels width is slightly wider than icon width, so that * there's a slight border around it */ - glRectf(offset, yminc, offset+17, ymaxc); + glRectf(offset, yminc, offset + 17, ymaxc); } /* icon is drawn as widget now... */ @@ -2909,8 +2909,8 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float // FIXME: replace hardcoded color here, and check on extents! glColor3f(1.0f, 0.0f, 0.0f); glLineWidth(2.0); - fdrawline((float)(offset), yminc, - (float)(v2d->cur.xmax), yminc); + fdrawline((float)(offset), yminc, + (float)(v2d->cur.xmax), yminc); glLineWidth(1.0); } } @@ -2934,21 +2934,21 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float switch (ac->spacetype) { case SPACE_ACTION: { - SpaceAction *saction= (SpaceAction *)ac->sl; - draw_sliders= (saction->flag & SACTION_SLIDERS); + SpaceAction *saction = (SpaceAction *)ac->sl; + draw_sliders = (saction->flag & SACTION_SLIDERS); } - break; + break; case SPACE_IPO: { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - draw_sliders= (sipo->flag & SIPO_SLIDERS); + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + draw_sliders = (sipo->flag & SIPO_SLIDERS); } - break; + break; } } /* check if there's enough space for the toggles if the sliders are drawn too */ - if ( !(draw_sliders) || ((v2d->mask.xmax-v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH/2) ) { + if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) offset += ICON_WIDTH; @@ -2972,7 +2972,7 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float * - starts from the point where the first toggle/slider starts, * - ends past the space that might be reserved for a scroller */ - glRectf(v2d->cur.xmax-(float)offset, yminc, v2d->cur.xmax+EXTRA_SCROLL_PAD, ymaxc); + glRectf(v2d->cur.xmax - (float)offset, yminc, v2d->cur.xmax + EXTRA_SCROLL_PAD, ymaxc); } } @@ -2981,13 +2981,13 @@ void ANIM_channel_draw(bAnimContext *ac, bAnimListElem *ale, float yminc, float /* callback for (normal) widget settings - send notifiers */ static void achannel_setting_widget_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } /* callback for widget settings that need flushing */ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void *setting_wrap) { - bAnimListElem *ale_setting= (bAnimListElem *)ale_npoin; + bAnimListElem *ale_setting = (bAnimListElem *)ale_npoin; bAnimContext ac; ListBase anim_data = {NULL, NULL}; int filter; @@ -2995,7 +2995,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void short on = 0; /* send notifiers before doing anything else... */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); /* verify animation context */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -3004,7 +3004,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void /* verify that we have a channel to operate on, and that it has all we need */ if (ale_setting) { /* check if the setting is on... */ - on= ANIM_channel_setting_get(&ac, ale_setting, setting); + on = ANIM_channel_setting_get(&ac, ale_setting, setting); /* on == -1 means setting not found... */ if (on == -1) @@ -3014,7 +3014,7 @@ static void achannel_setting_flush_widget_cb(bContext *C, void *ale_npoin, void return; /* get all channels that can possibly be chosen - but ignore hierarchy */ - filter= ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_CHANNELS; + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* call API method to flush the setting */ @@ -3034,25 +3034,25 @@ static void achannel_setting_rename_done_cb(bContext *C, void *ads_poin, void *U /* send notifiers */ // XXX: right notifier? - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_RENAME, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_RENAME, NULL); } /* callback for widget sliders - insert keyframes */ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poin) { - ID *id= (ID *)id_poin; - FCurve *fcu= (FCurve *)fcu_poin; + ID *id = (ID *)id_poin; + FCurve *fcu = (FCurve *)fcu_poin; ReportList *reports = CTX_wm_reports(C); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); PointerRNA id_ptr, ptr; PropertyRNA *prop; - short flag=0, done=0; + short flag = 0, done = 0; float cfra; /* get current frame */ // NOTE: this will do for now... - cfra= (float)CFRA; + cfra = (float)CFRA; /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); @@ -3067,30 +3067,30 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi flag |= INSERTKEY_REPLACE; /* insert a keyframe for this F-Curve */ - done= insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); if (done) - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } } /* callback for shapekey widget sliders - insert keyframes */ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, void *kb_poin) { - Key *key= (Key *)key_poin; - KeyBlock *kb= (KeyBlock *)kb_poin; - char *rna_path= key_get_curValue_rnaPath(key, kb); + Key *key = (Key *)key_poin; + KeyBlock *kb = (KeyBlock *)kb_poin; + char *rna_path = key_get_curValue_rnaPath(key, kb); ReportList *reports = CTX_wm_reports(C); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); PointerRNA id_ptr, ptr; PropertyRNA *prop; - short flag=0, done=0; + short flag = 0, done = 0; float cfra; /* get current frame */ // NOTE: this will do for now... - cfra= (float)CFRA; + cfra = (float)CFRA; /* get flags for keyframing */ flag = ANIM_get_keyframing_flags(scene, 1); @@ -3102,18 +3102,18 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi if (RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop)) { /* find or create new F-Curve */ // XXX is the group name for this ok? - bAction *act= verify_adt_action((ID *)key, 1); - FCurve *fcu= verify_fcurve(act, NULL, rna_path, 0, 1); + bAction *act = verify_adt_action((ID *)key, 1); + FCurve *fcu = verify_fcurve(act, NULL, rna_path, 0, 1); /* set the special 'replace' flag if on a keyframe */ if (fcurve_frame_has_keyframe(fcu, cfra, 0)) flag |= INSERTKEY_REPLACE; /* insert a keyframe for this F-Curve */ - done= insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, flag); if (done) - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); } /* free the path */ @@ -3132,32 +3132,32 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann uiBut *but = NULL; /* get the flag and the pointer to that flag */ - flag= acf->setting_flag(ac, setting, &negflag); - ptr= acf->setting_ptr(ale, setting, &ptrsize); + flag = acf->setting_flag(ac, setting, &negflag); + ptr = acf->setting_ptr(ale, setting, &ptrsize); /* enabled= ANIM_channel_setting_get(ac, ale, setting); */ /* UNUSED */ /* get the base icon for the setting */ switch (setting) { - case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */ + case ACHANNEL_SETTING_VISIBLE: /* visibility eyes */ //icon= ((enabled)? ICON_VISIBLE_IPO_ON : ICON_VISIBLE_IPO_OFF); - icon= ICON_VISIBLE_IPO_OFF; + icon = ICON_VISIBLE_IPO_OFF; if (ale->type == ANIMTYPE_FCURVE) - tooltip= "Channel is visible in Graph Editor for editing"; + tooltip = "Channel is visible in Graph Editor for editing"; else - tooltip= "Channel(s) are visible in Graph Editor for editing"; + tooltip = "Channel(s) are visible in Graph Editor for editing"; break; case ACHANNEL_SETTING_EXPAND: /* expanded triangle */ //icon= ((enabled)? ICON_TRIA_DOWN : ICON_TRIA_RIGHT); - icon= ICON_TRIA_RIGHT; - tooltip= "Make channels grouped under this channel visible"; + icon = ICON_TRIA_RIGHT; + tooltip = "Make channels grouped under this channel visible"; break; case ACHANNEL_SETTING_SOLO: /* NLA Tracks only */ //icon= ((enabled)? ICON_LAYER_ACTIVE : ICON_LAYER_USED); - icon= ICON_LAYER_USED; - tooltip= "NLA Track is the only one evaluated for the AnimData block it belongs to"; + icon = ICON_LAYER_USED; + tooltip = "NLA Track is the only one evaluated for the AnimData block it belongs to"; break; /* --- */ @@ -3165,48 +3165,48 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann case ACHANNEL_SETTING_PROTECT: /* protected lock */ // TODO: what about when there's no protect needed? //icon= ((enabled)? ICON_LOCKED : ICON_UNLOCKED); - icon= ICON_UNLOCKED; - tooltip= "Editability of keyframes for this channel"; + icon = ICON_UNLOCKED; + tooltip = "Editability of keyframes for this channel"; break; case ACHANNEL_SETTING_MUTE: /* muted speaker */ //icon= ((enabled)? ICON_MUTE_IPO_ON : ICON_MUTE_IPO_OFF); - icon= ICON_MUTE_IPO_OFF; + icon = ICON_MUTE_IPO_OFF; if (ale->type == ALE_FCURVE) - tooltip= "Does F-Curve contribute to result"; + tooltip = "Does F-Curve contribute to result"; else - tooltip= "Do channels contribute to result"; + tooltip = "Do channels contribute to result"; break; default: - tooltip= NULL; - icon= 0; + tooltip = NULL; + icon = 0; break; } /* type of button */ if (negflag) - butType= ICONTOGN; + butType = ICONTOGN; else - butType= ICONTOG; + butType = ICONTOG; /* draw button for setting */ if (ptr && flag) { switch (ptrsize) { - case sizeof(int): /* integer pointer for setting */ + case sizeof(int): /* integer pointer for setting */ but = uiDefIconButBitI(block, butType, flag, 0, icon, - xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; - case sizeof(short): /* short pointer for setting */ + case sizeof(short): /* short pointer for setting */ but = uiDefIconButBitS(block, butType, flag, 0, icon, - xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; - case sizeof(char): /* char pointer for setting */ + case sizeof(char): /* char pointer for setting */ but = uiDefIconButBitC(block, butType, flag, 0, icon, - xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); + xpos, ypos, ICON_WIDTH, ICON_WIDTH, ptr, 0, 0, 0, 0, tooltip); break; } @@ -3232,9 +3232,9 @@ static void draw_setting_widget(bAnimContext *ac, bAnimListElem *ale, bAnimChann /* Draw UI widgets the given channel */ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale, uiBlock *block, float yminc, float ymaxc, size_t channel_index) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - View2D *v2d= &ac->ar->v2d; - float y, ymid/*, ytext*/; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + View2D *v2d = &ac->ar->v2d; + float y, ymid /*, ytext*/; short offset; /* sanity checks - don't draw anything */ @@ -3243,15 +3243,15 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale /* get initial offset */ if (acf->get_offset) - offset= acf->get_offset(ac, ale); + offset = acf->get_offset(ac, ale); else - offset= 0; + offset = 0; /* calculate appropriate y-coordinates for icon buttons * 7 is hardcoded factor for half-height of icons */ - y= (ymaxc - yminc)/2 + yminc; - ymid= y - 7; + y = (ymaxc - yminc) / 2 + yminc; + ymid = y - 7; /* y-coordinates for text is only 4 down from middle */ /* ytext= y - 4; */ @@ -3292,7 +3292,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale float channel_height = ymaxc - yminc; /* if rename index matches, add widget for this */ - if (ac->ads->renameIndex == channel_index+1) { + if (ac->ads->renameIndex == channel_index + 1) { PointerRNA ptr; PropertyRNA *prop; @@ -3302,7 +3302,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale uiBlockSetEmboss(block, UI_EMBOSS); - but = uiDefButR(block, TEX, 1, "", offset+3, yminc, RENAME_TEXT_WIDTH, channel_height, + but = uiDefButR(block, TEX, 1, "", offset + 3, yminc, RENAME_TEXT_WIDTH, channel_height, &ptr, RNA_property_identifier(prop), -1, 0, 0, -1, -1, NULL); uiButSetFunc(but, achannel_setting_rename_done_cb, ac->ads, NULL); uiButActiveOnly(C, block, but); @@ -3326,30 +3326,30 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale switch (ac->spacetype) { case SPACE_ACTION: { - SpaceAction *saction= (SpaceAction *)ac->sl; - draw_sliders= (saction->flag & SACTION_SLIDERS); + SpaceAction *saction = (SpaceAction *)ac->sl; + draw_sliders = (saction->flag & SACTION_SLIDERS); } - break; + break; case SPACE_IPO: { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - draw_sliders= (sipo->flag & SIPO_SLIDERS); + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + draw_sliders = (sipo->flag & SIPO_SLIDERS); } - break; + break; } } /* check if there's enough space for the toggles if the sliders are drawn too */ - if ( !(draw_sliders) || ((v2d->mask.xmax-v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH/2) ) { + if (!(draw_sliders) || ((v2d->mask.xmax - v2d->mask.xmin) > ACHANNEL_BUTTON_WIDTH / 2) ) { /* protect... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_PROTECT)) { offset += ICON_WIDTH; - draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_PROTECT); + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_PROTECT); } /* mute... */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_MUTE)) { offset += ICON_WIDTH; - draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax-offset, ymid, ACHANNEL_SETTING_MUTE); + draw_setting_widget(ac, ale, acf, block, (int)v2d->cur.xmax - offset, ymid, ACHANNEL_SETTING_MUTE); } } @@ -3378,17 +3378,17 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale /* get destination info */ if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; - rna_path= fcu->rna_path; - array_index= fcu->array_index; + rna_path = fcu->rna_path; + array_index = fcu->array_index; } else if (ale->type == ANIMTYPE_SHAPEKEY) { - KeyBlock *kb= (KeyBlock *)ale->data; - Key *key= (Key *)ale->id; + KeyBlock *kb = (KeyBlock *)ale->data; + Key *key = (Key *)ale->id; - rna_path= key_get_curValue_rnaPath(key, kb); - free_path= 1; + rna_path = key_get_curValue_rnaPath(key, kb); + free_path = 1; } /* only if RNA-Path found */ @@ -3401,7 +3401,7 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale uiBut *but; /* create the slider button, and assign relevant callback to ensure keyframes are inserted... */ - but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax-offset, ymid, SLIDER_WIDTH, (int)ymaxc-yminc); + but = uiDefAutoButR(block, &ptr, prop, array_index, "", ICON_NONE, (int)v2d->cur.xmax - offset, ymid, SLIDER_WIDTH, (int)ymaxc - yminc); /* assign keyframing function according to slider type */ if (ale->type == ANIMTYPE_SHAPEKEY) diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index a1878de7523..e200972dd56 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -80,7 +80,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f return; /* only clear the 'active' flag for the channels of the same type */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* skip if types don't match */ if (channel_type != ale->type) continue; @@ -89,28 +89,28 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f switch (ale->type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; ACHANNEL_SET_FLAG(agrp, ACHANNEL_SETFLAG_CLEAR, AGRP_ACTIVE); } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; ACHANNEL_SET_FLAG(fcu, ACHANNEL_SETFLAG_CLEAR, FCURVE_ACTIVE); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; ACHANNEL_SET_FLAG(nlt, ACHANNEL_SETFLAG_CLEAR, NLATRACK_ACTIVE); } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -130,7 +130,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f ACHANNEL_SET_FLAG(ale->adt, ACHANNEL_SETFLAG_CLEAR, ADT_UI_ACTIVE); } } - break; + break; } } @@ -139,25 +139,25 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f switch (channel_type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)channel_data; + bActionGroup *agrp = (bActionGroup *)channel_data; agrp->flag |= AGRP_ACTIVE; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)channel_data; + FCurve *fcu = (FCurve *)channel_data; fcu->flag |= FCURVE_ACTIVE; } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)channel_data; + NlaTrack *nlt = (NlaTrack *)channel_data; nlt->flag |= NLATRACK_ACTIVE; } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -176,7 +176,7 @@ void ANIM_set_active_channel(bAnimContext *ac, void *data, short datatype, int f ale->adt->flag |= ADT_UI_ACTIVE; } } - break; + break; } } @@ -198,45 +198,45 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s /* filter data */ /* NOTE: no list visible, otherwise, we get dangling */ - filter= ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &anim_data, filter, data, datatype); /* See if we should be selecting or deselecting */ if (test) { - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (sel == 0) break; switch (ale->type) { case ANIMTYPE_SCENE: if (ale->flag & SCE_DS_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_OBJECT: - #if 0 /* for now, do not take object selection into account, since it gets too annoying */ + #if 0 /* for now, do not take object selection into account, since it gets too annoying */ if (ale->flag & SELECT) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; #endif break; case ANIMTYPE_GROUP: if (ale->flag & AGRP_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_FCURVE: if (ale->flag & FCURVE_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_SHAPEKEY: if (ale->flag & KEYBLOCK_SEL) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_NLATRACK: if (ale->flag & NLATRACK_SELECTED) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -253,24 +253,24 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s case ANIMTYPE_DSSPK: { if ((ale->adt) && (ale->adt->flag & ADT_UI_SELECTED)) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; } - break; + break; case ANIMTYPE_GPLAYER: if (ale->flag & GP_LAYER_SELECT) - sel= ACHANNEL_SETFLAG_CLEAR; + sel = ACHANNEL_SETFLAG_CLEAR; break; } } } /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_SCENE: { - Scene *scene= (Scene *)ale->data; + Scene *scene = (Scene *)ale->data; ACHANNEL_SET_FLAG(scene, sel, SCE_DS_SELECTED); @@ -278,56 +278,56 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s ACHANNEL_SET_FLAG(scene, sel, ADT_UI_SELECTED); } } - break; + break; case ANIMTYPE_OBJECT: - #if 0 /* for now, do not take object selection into account, since it gets too annoying */ - { - Base *base= (Base *)ale->data; - Object *ob= base->object; + #if 0 /* for now, do not take object selection into account, since it gets too annoying */ + { + Base *base = (Base *)ale->data; + Object *ob = base->object; - ACHANNEL_SET_FLAG(base, sel, SELECT); - ACHANNEL_SET_FLAG(ob, sel, SELECT); + ACHANNEL_SET_FLAG(base, sel, SELECT); + ACHANNEL_SET_FLAG(ob, sel, SELECT); - if (ob->adt) { - ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED); + if (ob->adt) { + ACHANNEL_SET_FLAG(ob, sel, ADT_UI_SELECTED); + } } - } #endif break; case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; ACHANNEL_SET_FLAG(agrp, sel, AGRP_SELECTED); agrp->flag &= ~AGRP_ACTIVE; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; ACHANNEL_SET_FLAG(fcu, sel, FCURVE_SELECTED); fcu->flag &= ~FCURVE_ACTIVE; } - break; + break; case ANIMTYPE_SHAPEKEY: { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; ACHANNEL_SET_FLAG(kb, sel, KEYBLOCK_SEL); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; ACHANNEL_SET_FLAG(nlt, sel, NLATRACK_SELECTED); nlt->flag &= ~NLATRACK_ACTIVE; } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -349,7 +349,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s ale->adt->flag &= ~ADT_UI_ACTIVE; } } - break; + break; case ANIMTYPE_GPLAYER: { @@ -357,7 +357,7 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s ACHANNEL_SET_FLAG(gpl, sel, GP_LAYER_SELECT); } - break; + break; } } @@ -378,21 +378,21 @@ void ANIM_deselect_anim_channels(bAnimContext *ac, void *data, short datatype, s */ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAnimListElem *ale_setting, int setting, short on) { - bAnimListElem *ale, *match=NULL; - int prevLevel=0, matchLevel=0; + bAnimListElem *ale, *match = NULL; + int prevLevel = 0, matchLevel = 0; /* sanity check */ if (ELEM(NULL, anim_data, anim_data->first)) return; /* find the channel that got changed */ - for (ale= anim_data->first; ale; ale= ale->next) { + for (ale = anim_data->first; ale; ale = ale->next) { /* compare data, and type as main way of identifying the channel */ if ((ale->data == ale_setting->data) && (ale->type == ale_setting->type)) { /* we also have to check the ID, this is assigned to, since a block may have multiple users */ // TODO: is the owner-data more revealing? if (ale->id == ale_setting->id) { - match= ale; + match = ale; break; } } @@ -402,7 +402,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn return; } else { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale_setting); + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale_setting); if (acf == NULL) { printf("ERROR: no channel info for the changed channel\n"); @@ -410,10 +410,10 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn } /* get the level of the channel that was affected - * - we define the level as simply being the offset for the start of the channel + * - we define the level as simply being the offset for the start of the channel */ - matchLevel= (acf->get_offset)? acf->get_offset(ac, ale_setting) : 0; - prevLevel= matchLevel; + matchLevel = (acf->get_offset) ? acf->get_offset(ac, ale_setting) : 0; + prevLevel = matchLevel; } /* flush up? @@ -427,11 +427,11 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn * (otherwise, it's too much work to force the parents to be active too) */ if ( ((setting == ACHANNEL_SETTING_VISIBLE) && on) || - ((setting != ACHANNEL_SETTING_VISIBLE) && on==0) ) + ((setting != ACHANNEL_SETTING_VISIBLE) && on == 0) ) { /* go backwards in the list, until the highest-ranking element (by indention has been covered) */ - for (ale= match->prev; ale; ale= ale->prev) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + for (ale = match->prev; ale; ale = ale->prev) { + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; /* if no channel info was found, skip, since this type might not have any useful info */ @@ -439,9 +439,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn continue; /* get the level of the current channel traversed - * - we define the level as simply being the offset for the start of the channel + * - we define the level as simply being the offset for the start of the channel */ - level= (acf->get_offset)? acf->get_offset(ac, ale) : 0; + level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; /* if the level is 'less than' (i.e. more important) the level we're matching * but also 'less than' the level just tried (i.e. only the 1st group above grouped F-Curves, @@ -453,7 +453,7 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn ANIM_channel_setting_set(ac, ale, setting, on); /* store this level as the 'old' level now */ - prevLevel= level; + prevLevel = level; } /* if the level is 'greater than' (i.e. less important) than the previous level... */ else if (level > prevLevel) { @@ -474,8 +474,8 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn /* flush down (always) */ { /* go forwards in the list, until the lowest-ranking element (by indention has been covered) */ - for (ale= match->next; ale; ale= ale->next) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); + for (ale = match->next; ale; ale = ale->next) { + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); int level; /* if no channel info was found, skip, since this type might not have any useful info */ @@ -483,9 +483,9 @@ void ANIM_flush_setting_anim_channels(bAnimContext *ac, ListBase *anim_data, bAn continue; /* get the level of the current channel traversed - * - we define the level as simply being the offset for the start of the channel + * - we define the level as simply being the offset for the start of the channel */ - level= (acf->get_offset)? acf->get_offset(ac, ale) : 0; + level = (acf->get_offset) ? acf->get_offset(ac, ale) : 0; /* if the level is 'greater than' (i.e. less important) the channel that was changed, * flush the new status... @@ -541,11 +541,11 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f * channel list that are empty, and linger around long after the data they * are for has disappeared (and probably won't come back). */ - // XXX: does everybody always want this? - /* XXX: there's a problem where many actions could build up in the file if multiple - * full add/delete cycles are performed on the same objects, but assume that this is rare - */ - if ((adt->action->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON)==0) { + // XXX: does everybody always want this? + /* XXX: there's a problem where many actions could build up in the file if multiple + * full add/delete cycles are performed on the same objects, but assume that this is rare + */ + if ((adt->action->curves.first == NULL) && (adt->flag & ADT_NLA_EDIT_ON) == 0) { id_us_min(&adt->action->id); adt->action = NULL; } @@ -561,9 +561,9 @@ void ANIM_fcurve_delete_from_animdata(bAnimContext *ac, AnimData *adt, FCurve *f /* ****************** Operator Utilities ********************************** */ /* poll callback for being in an Animation Editor channels list region */ -static int animedit_poll_channels_active (bContext *C) +static int animedit_poll_channels_active(bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); /* channels region test */ // TODO: could enhance with actually testing if channels region? @@ -577,9 +577,9 @@ static int animedit_poll_channels_active (bContext *C) } /* poll callback for Animation Editor channels list region + not in NLA-tweakmode for NLA */ -static int animedit_poll_channels_nla_tweakmode_off (bContext *C) +static int animedit_poll_channels_nla_tweakmode_off(bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Scene *scene = CTX_data_scene(C); /* channels region test */ @@ -604,10 +604,10 @@ static int animedit_poll_channels_nla_tweakmode_off (bContext *C) /* constants for channel rearranging */ /* WARNING: don't change exising ones without modifying rearrange func accordingly */ enum { - REARRANGE_ANIMCHAN_TOP= -2, - REARRANGE_ANIMCHAN_UP= -1, - REARRANGE_ANIMCHAN_DOWN= 1, - REARRANGE_ANIMCHAN_BOTTOM= 2 + REARRANGE_ANIMCHAN_TOP = -2, + REARRANGE_ANIMCHAN_UP = -1, + REARRANGE_ANIMCHAN_DOWN = 1, + REARRANGE_ANIMCHAN_BOTTOM = 2 }; /* defines for rearranging channels */ @@ -625,21 +625,21 @@ static EnumPropertyItem prop_animchannel_rearrange_types[] = { typedef struct tReorderChannelIsland { struct tReorderChannelIsland *next, *prev; - ListBase channels; /* channels within this region with the same state */ - int flag; /* eReorderIslandFlag */ + ListBase channels; /* channels within this region with the same state */ + int flag; /* eReorderIslandFlag */ } tReorderChannelIsland; /* flags for channel reordering islands */ typedef enum eReorderIslandFlag { - REORDER_ISLAND_SELECTED = (1<<0), /* island is selected */ - REORDER_ISLAND_UNTOUCHABLE = (1<<1), /* island should be ignored */ - REORDER_ISLAND_MOVED = (1<<2) /* island has already been moved */ + REORDER_ISLAND_SELECTED = (1 << 0), /* island is selected */ + REORDER_ISLAND_UNTOUCHABLE = (1 << 1), /* island should be ignored */ + REORDER_ISLAND_MOVED = (1 << 2) /* island has already been moved */ } eReorderIslandFlag; /* Rearrange Methods --------------------------------------------- */ -static short rearrange_island_ok (tReorderChannelIsland *island) +static short rearrange_island_ok(tReorderChannelIsland *island) { /* island must not be untouchable */ if (island->flag & REORDER_ISLAND_UNTOUCHABLE) @@ -651,7 +651,7 @@ static short rearrange_island_ok (tReorderChannelIsland *island) /* ............................. */ -static short rearrange_island_top (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_top(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { /* remove from current position */ @@ -666,11 +666,11 @@ static short rearrange_island_top (ListBase *list, tReorderChannelIsland *island return 0; } -static short rearrange_island_up (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_up(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { /* moving up = moving before the previous island, otherwise we're in the same place */ - tReorderChannelIsland *prev= island->prev; + tReorderChannelIsland *prev = island->prev; if (prev) { /* remove from current position */ @@ -686,7 +686,7 @@ static short rearrange_island_up (ListBase *list, tReorderChannelIsland *island) return 0; } -static short rearrange_island_down (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_down(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { /* moving down = moving after the next island, otherwise we're in the same place */ @@ -694,7 +694,7 @@ static short rearrange_island_down (ListBase *list, tReorderChannelIsland *islan if (next) { /* can only move past if next is not untouchable (i.e. nothing can go after it) */ - if ((next->flag & REORDER_ISLAND_UNTOUCHABLE)==0) { + if ((next->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* remove from current position */ BLI_remlink(list, island); @@ -710,7 +710,7 @@ static short rearrange_island_down (ListBase *list, tReorderChannelIsland *islan return 0; } -static short rearrange_island_bottom (ListBase *list, tReorderChannelIsland *island) +static short rearrange_island_bottom(ListBase *list, tReorderChannelIsland *island) { if (rearrange_island_ok(island)) { tReorderChannelIsland *last = list->last; @@ -719,7 +719,7 @@ static short rearrange_island_bottom (ListBase *list, tReorderChannelIsland *isl BLI_remlink(list, island); /* add before or after the last channel? */ - if ((last->flag & REORDER_ISLAND_UNTOUCHABLE)==0) { + if ((last->flag & REORDER_ISLAND_UNTOUCHABLE) == 0) { /* can add after it */ BLI_addtail(list, island); } @@ -745,7 +745,7 @@ static short rearrange_island_bottom (ListBase *list, tReorderChannelIsland *isl typedef short (*AnimChanRearrangeFp)(ListBase *list, tReorderChannelIsland *island); /* get rearranging function, given 'rearrange' mode */ -static AnimChanRearrangeFp rearrange_get_mode_func (short mode) +static AnimChanRearrangeFp rearrange_get_mode_func(short mode) { switch (mode) { case REARRANGE_ANIMCHAN_TOP: @@ -764,35 +764,35 @@ static AnimChanRearrangeFp rearrange_get_mode_func (short mode) /* Rearrange Islands Generics ------------------------------------- */ /* add channel into list of islands */ -static void rearrange_animchannel_add_to_islands (ListBase *islands, ListBase *srcList, Link *channel, short type) +static void rearrange_animchannel_add_to_islands(ListBase *islands, ListBase *srcList, Link *channel, short type) { - tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */ - short is_sel=0, is_untouchable=0; + tReorderChannelIsland *island = islands->last; /* always try to add to last island if possible */ + short is_sel = 0, is_untouchable = 0; /* get flags - selected and untouchable from the channel */ switch (type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)channel; + bActionGroup *agrp = (bActionGroup *)channel; - is_sel= SEL_AGRP(agrp); - is_untouchable= (agrp->flag & AGRP_TEMP) != 0; + is_sel = SEL_AGRP(agrp); + is_untouchable = (agrp->flag & AGRP_TEMP) != 0; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)channel; + FCurve *fcu = (FCurve *)channel; - is_sel= SEL_FCU(fcu); + is_sel = SEL_FCU(fcu); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)channel; + NlaTrack *nlt = (NlaTrack *)channel; - is_sel= SEL_NLT(nlt); + is_sel = SEL_NLT(nlt); } - break; + break; default: printf("rearrange_animchannel_add_to_islands(): don't know how to handle channels of type %d\n", type); @@ -801,8 +801,8 @@ static void rearrange_animchannel_add_to_islands (ListBase *islands, ListBase *s /* do we need to add to a new island? */ if ((island == NULL) || /* 1) no islands yet */ - ((island->flag & REORDER_ISLAND_SELECTED) == 0) || /* 2) unselected islands have single channels only - to allow up/down movement */ - (is_sel == 0)) /* 3) if channel is unselected, stop existing island (it was either wrong sel status, or full already) */ + ((island->flag & REORDER_ISLAND_SELECTED) == 0) || /* 2) unselected islands have single channels only - to allow up/down movement */ + (is_sel == 0)) /* 3) if channel is unselected, stop existing island (it was either wrong sel status, or full already) */ { /* create a new island now */ island = MEM_callocN(sizeof(tReorderChannelIsland), "tReorderChannelIsland"); @@ -820,9 +820,9 @@ static void rearrange_animchannel_add_to_islands (ListBase *islands, ListBase *s } /* flatten islands out into a single list again */ -static void rearrange_animchannel_flatten_islands (ListBase *islands, ListBase *srcList) +static void rearrange_animchannel_flatten_islands(ListBase *islands, ListBase *srcList) { - tReorderChannelIsland *island, *isn=NULL; + tReorderChannelIsland *island, *isn = NULL; /* make sure srcList is empty now */ BLI_assert(srcList->first == NULL); @@ -840,10 +840,10 @@ static void rearrange_animchannel_flatten_islands (ListBase *islands, ListBase * /* ............................. */ /* performing rearranging of channels using islands */ -static short rearrange_animchannel_islands (ListBase *list, AnimChanRearrangeFp rearrange_func, short mode, short type) +static short rearrange_animchannel_islands(ListBase *list, AnimChanRearrangeFp rearrange_func, short mode, short type) { ListBase islands = {NULL, NULL}; - Link *channel, *chanNext=NULL; + Link *channel, *chanNext = NULL; short done = 0; /* don't waste effort on an empty list */ @@ -862,7 +862,7 @@ static short rearrange_animchannel_islands (ListBase *list, AnimChanRearrangeFp */ if (islands.first != islands.last) { tReorderChannelIsland *first = (mode > 0) ? islands.last : islands.first; - tReorderChannelIsland *island, *isn=NULL; + tReorderChannelIsland *island, *isn = NULL; for (island = first; island; island = isn) { isn = (mode > 0) ? island->prev : island->next; @@ -888,7 +888,7 @@ static short rearrange_animchannel_islands (ListBase *list, AnimChanRearrangeFp * ! NLA tracks are displayed in opposite order, so directions need care * mode: REARRANGE_ANIMCHAN_* */ -static void rearrange_nla_channels (bAnimContext *UNUSED(ac), AnimData *adt, short mode) +static void rearrange_nla_channels(bAnimContext *UNUSED(ac), AnimData *adt, short mode) { AnimChanRearrangeFp rearrange_func; @@ -913,7 +913,7 @@ static void rearrange_nla_channels (bAnimContext *UNUSED(ac), AnimData *adt, sho /* Change the order drivers within AnimData block * mode: REARRANGE_ANIMCHAN_* */ -static void rearrange_driver_channels (bAnimContext *UNUSED(ac), AnimData *adt, short mode) +static void rearrange_driver_channels(bAnimContext *UNUSED(ac), AnimData *adt, short mode) { /* get rearranging function */ AnimChanRearrangeFp rearrange_func = rearrange_get_mode_func(mode); @@ -932,7 +932,7 @@ static void rearrange_driver_channels (bAnimContext *UNUSED(ac), AnimData *adt, /* Action Specific Stuff ------------------------------------------------- */ /* make sure all action-channels belong to a group (and clear action's list) */ -static void split_groups_action_temp (bAction *act, bActionGroup *tgrp) +static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) { bActionGroup *agrp; FCurve *fcu; @@ -941,37 +941,37 @@ static void split_groups_action_temp (bAction *act, bActionGroup *tgrp) return; /* Separate F-Curves into lists per group */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { if (agrp->channels.first) { - fcu= agrp->channels.last; - act->curves.first= fcu->next; + fcu = agrp->channels.last; + act->curves.first = fcu->next; - fcu= agrp->channels.first; - fcu->prev= NULL; + fcu = agrp->channels.first; + fcu->prev = NULL; - fcu= agrp->channels.last; - fcu->next= NULL; + fcu = agrp->channels.last; + fcu->next = NULL; } } /* Initialize memory for temp-group */ memset(tgrp, 0, sizeof(bActionGroup)); - tgrp->flag |= (AGRP_EXPANDED|AGRP_TEMP); + tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP); BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name)); /* Move any action-channels not already moved, to the temp group */ if (act->curves.first) { /* start of list */ - fcu= act->curves.first; - fcu->prev= NULL; - tgrp->channels.first= fcu; - act->curves.first= NULL; + fcu = act->curves.first; + fcu->prev = NULL; + tgrp->channels.first = fcu; + act->curves.first = NULL; /* end of list */ - fcu= act->curves.last; - fcu->next= NULL; - tgrp->channels.last= fcu; - act->curves.last= NULL; + fcu = act->curves.last; + fcu->next = NULL; + tgrp->channels.last = fcu; + act->curves.last = NULL; } /* Add temp-group to list */ @@ -979,17 +979,17 @@ static void split_groups_action_temp (bAction *act, bActionGroup *tgrp) } /* link lists of channels that groups have */ -static void join_groups_action_temp (bAction *act) +static void join_groups_action_temp(bAction *act) { bActionGroup *agrp; - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { ListBase tempGroup; /* add list of channels to action's channels */ - tempGroup= agrp->channels; + tempGroup = agrp->channels; BLI_movelisttolist(&act->curves, &agrp->channels); - agrp->channels= tempGroup; + agrp->channels = tempGroup; /* clear moved flag */ agrp->flag &= ~AGRP_MOVED; @@ -1005,7 +1005,7 @@ static void join_groups_action_temp (bAction *act) /* Change the order of anim-channels within action * mode: REARRANGE_ANIMCHAN_* */ -static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mode) +static void rearrange_action_channels(bAnimContext *ac, bAction *act, short mode) { bActionGroup tgrp; short do_channels; @@ -1028,7 +1028,7 @@ static void rearrange_action_channels (bAnimContext *ac, bAction *act, short mod if (do_channels) { bActionGroup *agrp; - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only consider F-Curves if they're visible (group expanded) */ if (EXPANDED_AGRP(ac, agrp)) { rearrange_animchannel_islands(&agrp->channels, rearrange_func, mode, ANIMTYPE_FCURVE); @@ -1052,7 +1052,7 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get mode */ - mode= RNA_enum_get(op->ptr, "direction"); + mode = RNA_enum_get(op->ptr, "direction"); /* method to move channels depends on the editor */ if (ac.datatype == ANIMCONT_GPENCIL) { @@ -1069,11 +1069,11 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) int filter; /* get animdata blocks */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); for (ale = anim_data.first; ale; ale = ale->next) { - AnimData *adt= ale->data; + AnimData *adt = ale->data; switch (ac.datatype) { case ANIMCONT_NLA: /* NLA-tracks only */ @@ -1100,12 +1100,12 @@ static int animchannels_rearrange_exec(bContext *C, wmOperator *op) } /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_move (wmOperatorType *ot) +static void ANIM_OT_channels_move(wmOperatorType *ot) { /* identifiers */ ot->name = "Move Channels"; @@ -1117,7 +1117,7 @@ static void ANIM_OT_channels_move (wmOperatorType *ot) ot->poll = animedit_poll_channels_nla_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", prop_animchannel_rearrange_types, REARRANGE_ANIMCHAN_DOWN, "Direction", ""); @@ -1144,15 +1144,15 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) /* do groups only first (unless in Drivers mode, where there are none) */ if (ac.datatype != ANIMCONT_DRIVERS) { /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete selected groups and their associated channels */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* only groups - don't check other types yet, since they may no-longer exist */ if (ale->type == ANIMTYPE_GROUP) { - bActionGroup *agrp= (bActionGroup *)ale->data; - AnimData *adt= ale->adt; + bActionGroup *agrp = (bActionGroup *)ale->data; + AnimData *adt = ale->adt; FCurve *fcu, *fcn; /* skip this group if no AnimData available, as we can't safely remove the F-Curves */ @@ -1160,8 +1160,8 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) continue; /* delete all of the Group's F-Curves, but no others */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcn) { - fcn= fcu->next; + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcn) { + fcn = fcu->next; /* remove from group and action, then free */ action_groups_remove_channel(adt->action, fcu); @@ -1181,34 +1181,34 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete selected data channels */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_FCURVE: { /* F-Curves if we can identify its parent */ - AnimData *adt= ale->adt; - FCurve *fcu= (FCurve *)ale->data; + AnimData *adt = ale->adt; + FCurve *fcu = (FCurve *)ale->data; /* try to free F-Curve */ ANIM_fcurve_delete_from_animdata(&ac, adt, fcu); } - break; + break; case ANIMTYPE_GPLAYER: { /* Grease Pencil layer */ - bGPdata *gpd= (bGPdata *)ale->id; - bGPDlayer *gpl= (bGPDlayer *)ale->data; + bGPdata *gpd = (bGPdata *)ale->id; + bGPDlayer *gpl = (bGPDlayer *)ale->data; /* try to delete the layer's data and the layer itself */ free_gpencil_frames(gpl); BLI_freelinkN(&gpd->layers, gpl); } - break; + break; } } @@ -1216,12 +1216,12 @@ static int animchannels_delete_exec(bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_delete (wmOperatorType *ot) +static void ANIM_OT_channels_delete(wmOperatorType *ot) { /* identifiers */ ot->name = "Delete Channels"; @@ -1233,7 +1233,7 @@ static void ANIM_OT_channels_delete (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Set Channel Visibility Operator *********************** */ @@ -1254,7 +1254,7 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) /* get list of all channels that selection may need to be flushed to * - hierarchy mustn't affect what we have access to here... */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); /* hide all channels not selected @@ -1266,15 +1266,15 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) */ if ((ac.spacetype == SPACE_IPO) && (ac.regiontype != RGN_TYPE_CHANNELS)) { /* graph editor (case 2) */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); } else { /* standard case */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_UNSEL | ANIMFILTER_NODUPLIS); } ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* clear setting first */ ANIM_channel_setting_set(&ac, ale, ACHANNEL_SETTING_VISIBLE, ACHANNEL_SETFLAG_CLEAR); @@ -1287,10 +1287,10 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* make all the selected channels visible */ - filter= (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ // TODO: find out why this is the case, and fix that if (ale->type == ANIMTYPE_OBJECT) @@ -1308,12 +1308,12 @@ static int animchannels_visibility_set_exec(bContext *C, wmOperator *UNUSED(op)) /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_visibility_set (wmOperatorType *ot) +static void ANIM_OT_channels_visibility_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Visibility"; @@ -1325,7 +1325,7 @@ static void ANIM_OT_channels_visibility_set (wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1339,7 +1339,7 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o ListBase all_data = {NULL, NULL}; bAnimListElem *ale; int filter; - short vis= ACHANNEL_SETFLAG_ADD; + short vis = ACHANNEL_SETFLAG_ADD; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1348,26 +1348,26 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o /* get list of all channels that selection may need to be flushed to * - hierarchy mustn't affect what we have access to here... */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &all_data, filter, ac.data, ac.datatype); /* filter data * - restrict this to only applying on settings we can get to in the list */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* See if we should be making showing all selected or hiding */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ if (ANIM_channel_setting_get(&ac, ale, ACHANNEL_SETTING_VISIBLE)) { - vis= ACHANNEL_SETFLAG_CLEAR; + vis = ACHANNEL_SETFLAG_CLEAR; break; } } /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* hack: skip object channels for now, since flushing those will always flush everything, but they are always included */ // TODO: find out why this is the case, and fix that if (ale->type == ANIMTYPE_OBJECT) @@ -1385,12 +1385,12 @@ static int animchannels_visibility_toggle_exec(bContext *C, wmOperator *UNUSED(o BLI_freelistN(&all_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_visibility_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Visibility"; @@ -1402,7 +1402,7 @@ static void ANIM_OT_channels_visibility_toggle (wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************** Set Flags Operator *********************** */ @@ -1433,7 +1433,7 @@ static EnumPropertyItem prop_animchannel_settings_types[] = { * onlysel: only selected channels get the flag set */ // TODO: enable a setting which turns flushing on/off? -static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, short onlysel, short flush) +static void setflag_anim_channels(bAnimContext *ac, short setting, short mode, short onlysel, short flush) { ListBase anim_data = {NULL, NULL}; ListBase all_data = {NULL, NULL}; @@ -1446,7 +1446,7 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, * - hierarchy visibility needs to be ignored so that settings can get flushed * "down" inside closed containers */ - filter= ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(ac, &all_data, filter, ac->data, ac->datatype); } @@ -1459,11 +1459,11 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, */ if ((ac->spacetype == SPACE_IPO) && (ac->regiontype != RGN_TYPE_CHANNELS)) { /* graph editor (case 2) */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); } else { /* standard case */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); } if (onlysel) filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -1471,20 +1471,20 @@ static void setflag_anim_channels (bAnimContext *ac, short setting, short mode, /* if toggling, check if disable or enable */ if (mode == ACHANNEL_SETFLAG_TOGGLE) { /* default to turn all on, unless we encounter one that's on... */ - mode= ACHANNEL_SETFLAG_ADD; + mode = ACHANNEL_SETFLAG_ADD; /* see if we should turn off instead... */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* set the setting in the appropriate way (if available) */ if (ANIM_channel_setting_get(ac, ale, setting) > 0) { - mode= ACHANNEL_SETFLAG_CLEAR; + mode = ACHANNEL_SETFLAG_CLEAR; break; } } } /* apply the setting */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* skip channel if setting is not available */ if (ANIM_channel_setting_get(ac, ale, setting) == -1) continue; @@ -1507,19 +1507,19 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) { bAnimContext ac; short mode, setting; - short flush=1; + short flush = 1; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* mode (eAnimChannels_SetFlag), setting (eAnimChannel_Settings) */ - mode= RNA_enum_get(op->ptr, "mode"); - setting= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "mode"); + setting = RNA_enum_get(op->ptr, "type"); /* check if setting is flushable */ if (setting == ACHANNEL_SETTING_EXPAND) - flush= 0; + flush = 0; /* modify setting * - only selected channels are affected @@ -1527,13 +1527,13 @@ static int animchannels_setflag_exec(bContext *C, wmOperator *op) setflag_anim_channels(&ac, setting, mode, 1, flush); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ -static void ANIM_OT_channels_setting_enable (wmOperatorType *ot) +static void ANIM_OT_channels_setting_enable(wmOperatorType *ot) { /* identifiers */ ot->name = "Enable Channel Setting"; @@ -1546,16 +1546,16 @@ static void ANIM_OT_channels_setting_enable (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_ADD, "Mode", ""); - /* setting to set */ + /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } /* duplicate of 'ANIM_OT_channels_setting_toggle' for menu title only, weak! */ -static void ANIM_OT_channels_setting_disable (wmOperatorType *ot) +static void ANIM_OT_channels_setting_disable(wmOperatorType *ot) { /* identifiers */ ot->name = "Disable Channel Setting"; @@ -1568,16 +1568,16 @@ static void ANIM_OT_channels_setting_disable (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_CLEAR, "Mode", ""); - /* setting to set */ + /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } -static void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_setting_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Channel Setting"; @@ -1590,16 +1590,16 @@ static void ANIM_OT_channels_setting_toggle (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); - /* setting to set */ + /* setting to set */ ot->prop = RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, 0, "Type", ""); } -static void ANIM_OT_channels_editable_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_editable_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Toggle Channel Editability"; @@ -1611,21 +1611,21 @@ static void ANIM_OT_channels_editable_toggle (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - /* flag-setting mode */ + /* flag-setting mode */ RNA_def_enum(ot->srna, "mode", prop_animchannel_setflag_types, ACHANNEL_SETFLAG_TOGGLE, "Mode", ""); - /* setting to set */ + /* setting to set */ RNA_def_enum(ot->srna, "type", prop_animchannel_settings_types, ACHANNEL_SETTING_PROTECT, "Type", ""); } /* ********************** Expand Channels Operator *********************** */ -static int animchannels_expand_exec (bContext *C, wmOperator *op) +static int animchannels_expand_exec(bContext *C, wmOperator *op) { bAnimContext ac; - short onlysel= 1; + short onlysel = 1; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1633,18 +1633,18 @@ static int animchannels_expand_exec (bContext *C, wmOperator *op) /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) - onlysel= 0; + onlysel = 0; /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_ADD, onlysel, 0); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_expand (wmOperatorType *ot) +static void ANIM_OT_channels_expand(wmOperatorType *ot) { /* identifiers */ ot->name = "Expand Channels"; @@ -1656,7 +1656,7 @@ static void ANIM_OT_channels_expand (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Expand all channels (not just selected ones)"); @@ -1664,10 +1664,10 @@ static void ANIM_OT_channels_expand (wmOperatorType *ot) /* ********************** Collapse Channels Operator *********************** */ -static int animchannels_collapse_exec (bContext *C, wmOperator *op) +static int animchannels_collapse_exec(bContext *C, wmOperator *op) { bAnimContext ac; - short onlysel= 1; + short onlysel = 1; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1675,18 +1675,18 @@ static int animchannels_collapse_exec (bContext *C, wmOperator *op) /* only affect selected channels? */ if (RNA_boolean_get(op->ptr, "all")) - onlysel= 0; + onlysel = 0; /* modify setting */ setflag_anim_channels(&ac, ACHANNEL_SETTING_EXPAND, ACHANNEL_SETFLAG_CLEAR, onlysel, 0); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_collapse (wmOperatorType *ot) +static void ANIM_OT_channels_collapse(wmOperatorType *ot) { /* identifiers */ ot->name = "Collapse Channels"; @@ -1698,7 +1698,7 @@ static void ANIM_OT_channels_collapse (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All", "Collapse all channels (not just selected ones)"); @@ -1706,9 +1706,9 @@ static void ANIM_OT_channels_collapse (wmOperatorType *ot) /* ******************* Reenable Disabled Operator ******************* */ -static int animchannels_enable_poll (bContext *C) +static int animchannels_enable_poll(bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); /* channels region test */ // TODO: could enhance with actually testing if channels region? @@ -1722,7 +1722,7 @@ static int animchannels_enable_poll (bContext *C) return 1; } -static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) +static int animchannels_enable_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1735,11 +1735,11 @@ static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through filtered data and clean curves */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; /* remove disabled flags from F-Curves */ @@ -1757,12 +1757,12 @@ static int animchannels_enable_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_fcurves_enable (wmOperatorType *ot) +static void ANIM_OT_channels_fcurves_enable(wmOperatorType *ot) { /* identifiers */ ot->name = "Revive Disabled F-Curves"; @@ -1774,12 +1774,12 @@ static void ANIM_OT_channels_fcurves_enable (wmOperatorType *ot) ot->poll = animchannels_enable_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************** Select All Operator *********************** */ -static int animchannels_deselectall_exec (bContext *C, wmOperator *op) +static int animchannels_deselectall_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1794,12 +1794,12 @@ static int animchannels_deselectall_exec (bContext *C, wmOperator *op) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_ADD); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) +static void ANIM_OT_channels_select_all_toggle(wmOperatorType *ot) { /* identifiers */ ot->name = "Select All"; @@ -1811,7 +1811,7 @@ static void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) ot->poll = animedit_poll_channels_nla_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -1819,14 +1819,14 @@ static void ANIM_OT_channels_select_all_toggle (wmOperatorType *ot) /* ******************** Borderselect Operator *********************** */ -static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short selectmode) +static void borderselect_anim_channels(bAnimContext *ac, rcti *rect, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; float ymin, ymax; @@ -1841,19 +1841,19 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele } /* convert border-region to view coordinates */ - UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin+2, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax-2, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, rect->xmin, rect->ymin + 2, &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, rect->xmax, rect->ymax - 2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ac->datatype == ANIMCONT_NLA) - ymin= ymax - NLACHANNEL_STEP(snla); + ymin = ymax - NLACHANNEL_STEP(snla); else - ymin= ymax - ACHANNEL_STEP; + ymin = ymax - ACHANNEL_STEP; /* if channel is within border-select region, alter it */ if (!((ymax < rectf.ymin) || (ymin > rectf.ymax))) { @@ -1864,27 +1864,27 @@ static void borderselect_anim_channels (bAnimContext *ac, rcti *rect, short sele switch (ale->type) { case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* always clear active flag after doing this */ agrp->flag &= ~AGRP_ACTIVE; } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; /* for now, it's easier just to do this here manually, as defining a new type * currently adds complications when doing other stuff */ ACHANNEL_SET_FLAG(nlt, selectmode, NLATRACK_SELECTED); } - break; + break; } } /* set minimum extent to be the maximum of the next channel */ - ymax= ymin; + ymax = ymin; } /* cleanup */ @@ -1897,7 +1897,7 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short selectmode=0; + short selectmode = 0; int gesture_mode, extend; /* get editor data */ @@ -1910,8 +1910,8 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); - extend= RNA_boolean_get(op->ptr, "extend"); + gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) ANIM_deselect_anim_channels(&ac, ac.data, ac.datatype, 1, ACHANNEL_SETFLAG_CLEAR); @@ -1925,7 +1925,7 @@ static int animchannels_borderselect_exec(bContext *C, wmOperator *op) borderselect_anim_channels(&ac, &rect, selectmode); /* send notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -1946,7 +1946,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) ot->poll = animedit_poll_channels_nla_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -1955,7 +1955,7 @@ static void ANIM_OT_channels_select_border(wmOperatorType *ot) /* ******************* Rename Operator ***************************** */ /* Allow renaming some channels by clicking on them */ -static void rename_anim_channels (bAnimContext *ac, int channel_index) +static void rename_anim_channels(bAnimContext *ac, int channel_index) { ListBase anim_data = {NULL, NULL}; bAnimChannelType *acf; @@ -1963,12 +1963,12 @@ static void rename_anim_channels (bAnimContext *ac, int channel_index) int filter; /* get the channel that was clicked on */ - /* filter channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + /* filter channels */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get channel from index */ - ale= BLI_findlink(&anim_data, channel_index); + /* get channel from index */ + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) @@ -2004,7 +2004,7 @@ static void rename_anim_channels (bAnimContext *ac, int channel_index) ED_region_tag_redraw(ac->ar); } -static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEvent *evt) +static int animchannels_rename_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *evt) { bAnimContext ac; ARegion *ar; @@ -2017,8 +2017,8 @@ static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEv return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - ar= ac.ar; - v2d= &ar->v2d; + ar = ac.ar; + v2d = &ar->v2d; /* figure out which channel user clicked in * Note: although channels technically start at y= ACHANNEL_FIRST, we need to adjust by half a channel's height @@ -2041,7 +2041,7 @@ static int animchannels_rename_invoke (bContext *C, wmOperator *UNUSED(op), wmEv return OPERATOR_FINISHED; } -static void ANIM_OT_channels_rename (wmOperatorType *ot) +static void ANIM_OT_channels_rename(wmOperatorType *ot) { /* identifiers */ ot->name = "Rename Channels"; @@ -2056,7 +2056,7 @@ static void ANIM_OT_channels_rename (wmOperatorType *ot) /* ******************** Mouse-Click Operator *********************** */ /* Handle selection changes due to clicking on channels. Settings will get caught by UI code... */ -static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_index, short selectmode) +static int mouse_anim_channels(bAnimContext *ac, float UNUSED(x), int channel_index, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -2064,12 +2064,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i int notifierFlags = 0; /* get the channel that was clicked on */ - /* filter channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + /* filter channels */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get channel from index */ - ale= BLI_findlink(&anim_data, channel_index); + /* get channel from index */ + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) @@ -2092,8 +2092,8 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i switch (ale->type) { case ANIMTYPE_SCENE: { - Scene *sce= (Scene *)ale->data; - AnimData *adt= sce->adt; + Scene *sce = (Scene *)ale->data; + AnimData *adt = sce->adt; /* set selection status */ if (selectmode == SELECT_INVERT) { @@ -2106,22 +2106,22 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if (adt) adt->flag |= ADT_UI_SELECTED; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_OBJECT: { - bDopeSheet *ads= (bDopeSheet *)ac->data; - Scene *sce= (Scene *)ads->source; - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ob->adt; + bDopeSheet *ads = (bDopeSheet *)ac->data; + Scene *sce = (Scene *)ads->source; + Base *base = (Base *)ale->data; + Object *ob = base->object; + AnimData *adt = ob->adt; /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ base->flag ^= SELECT; - ob->flag= base->flag; + ob->flag = base->flag; if (adt) adt->flag ^= ADT_UI_SELECTED; } @@ -2130,10 +2130,10 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i /* deselect all */ // TODO: should this deselect all other types of channels too? - for (b= sce->base.first; b; b= b->next) { + for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; - b->object->flag= b->flag; - if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED|ADT_UI_ACTIVE); + b->object->flag = b->flag; + if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } /* select object now */ @@ -2145,12 +2145,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if ((adt) && (adt->flag & ADT_UI_SELECTED)) adt->flag |= ADT_UI_ACTIVE; - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -2184,13 +2184,13 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i ale->adt->flag |= ADT_UI_ACTIVE; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; /* select/deselect group */ if (selectmode == SELECT_INVERT) { @@ -2205,7 +2205,7 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i ANIM_deselect_anim_channels(ac, ac->data, ac->datatype, 0, ACHANNEL_SETFLAG_CLEAR); /* only select channels in group and group itself */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) fcu->flag |= FCURVE_SELECTED; agrp->flag |= AGRP_SELECTED; } @@ -2219,12 +2219,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if (agrp->flag & AGRP_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; /* select/deselect */ if (selectmode == SELECT_INVERT) { @@ -2241,12 +2241,12 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i if (fcu->flag & FCURVE_SELECTED) ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_SHAPEKEY: { - KeyBlock *kb= (KeyBlock *)ale->data; + KeyBlock *kb = (KeyBlock *)ale->data; /* select/deselect */ if (selectmode == SELECT_INVERT) { @@ -2259,24 +2259,24 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i kb->flag |= KEYBLOCK_SEL; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_GPDATABLOCK: { - bGPdata *gpd= (bGPdata *)ale->data; + bGPdata *gpd = (bGPdata *)ale->data; /* toggle expand * - although the triangle widget already allows this, the whole channel can also be used for this purpose */ gpd->flag ^= GP_DATA_EXPAND; - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - break; + break; case ANIMTYPE_GPLAYER: { - bGPDlayer *gpl= (bGPDlayer *)ale->data; + bGPDlayer *gpl = (bGPDlayer *)ale->data; /* select/deselect */ if (selectmode == SELECT_INVERT) { @@ -2289,9 +2289,9 @@ static int mouse_anim_channels (bAnimContext *ac, float UNUSED(x), int channel_i gpl->flag |= GP_LAYER_SELECT; } - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - break; + break; default: if (G.debug & G_DEBUG) printf("Error: Invalid channel type in mouse_anim_channels()\n"); @@ -2323,16 +2323,16 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent * return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - ar= ac.ar; - v2d= &ar->v2d; + ar = ac.ar; + v2d = &ar->v2d; /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else if (RNA_boolean_get(op->ptr, "children_only")) - selectmode= -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */ + selectmode = -1; /* this is a bit of a special case for ActionGroups only... should it be removed or extended to all instead? */ else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* figure out which channel user clicked in * Note: although channels technically start at y= ACHANNEL_FIRST, we need to adjust by half a channel's height @@ -2343,15 +2343,15 @@ static int animchannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent * UI_view2d_listview_view_to_cell(v2d, ACHANNEL_NAMEWIDTH, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index); /* handle mouse-click in the relevant channel then */ - notifierFlags= mouse_anim_channels(&ac, x, channel_index, selectmode); + notifierFlags = mouse_anim_channels(&ac, x, channel_index, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|notifierFlags, NULL); + WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); return OPERATOR_FINISHED; } -static void ANIM_OT_channels_click (wmOperatorType *ot) +static void ANIM_OT_channels_click(wmOperatorType *ot) { /* identifiers */ ot->name = "Mouse Click on Channels"; @@ -2363,7 +2363,7 @@ static void ANIM_OT_channels_click (wmOperatorType *ot) ot->poll = animedit_poll_channels_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY @@ -2387,7 +2387,7 @@ void ED_operatortypes_animchannels(void) WM_operatortype_append(ANIM_OT_channels_delete); - // XXX does this need to be a separate operator? + // XXX does this need to be a separate operator? WM_operatortype_append(ANIM_OT_channels_editable_toggle); WM_operatortype_append(ANIM_OT_channels_move); @@ -2408,20 +2408,20 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* selection */ - /* click-select */ - // XXX for now, only leftmouse.... + /* click-select */ + // XXX for now, only leftmouse.... WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", TRUE); - RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "children_only", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "children_only", TRUE); - /* rename */ + /* rename */ WM_keymap_add_item(keymap, "ANIM_OT_channels_rename", LEFTMOUSE, KM_PRESS, KM_CTRL, 0); - /* deselect all */ + /* deselect all */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", AKEY, KM_PRESS, 0, 0); RNA_boolean_set(WM_keymap_add_item(keymap, "ANIM_OT_channels_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", BKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_select_border", EVT_TWEAK_L, KM_ANY, 0, 0); @@ -2431,7 +2431,7 @@ void ED_keymap_animchannels(wmKeyConfig *keyconf) /* settings */ WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_item(keymap, "ANIM_OT_channels_setting_disable", WKEY, KM_PRESS, KM_ALT, 0); /* settings - specialized hotkeys */ diff --git a/source/blender/editors/animation/anim_deps.c b/source/blender/editors/animation/anim_deps.c index b449c11ff7b..32cbbc79496 100644 --- a/source/blender/editors/animation/anim_deps.c +++ b/source/blender/editors/animation/anim_deps.c @@ -67,17 +67,17 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) FCurve *fcu; AnimData *adt; - id= ale->id; + id = ale->id; if (!id) return; /* tag AnimData for refresh so that other views will update in realtime with these changes */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if (adt) adt->recalc |= ADT_RECALC_ANIM; /* update data */ - fcu= (ale->datatype == ALE_FCURVE)? ale->key_data: NULL; + fcu = (ale->datatype == ALE_FCURVE) ? ale->key_data : NULL; if (fcu && fcu->rna_path) { /* if we have an fcurve, call the update for the property we @@ -94,7 +94,7 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) else { /* in other case we do standard depsgaph update, ideally * we'd be calling property update functions here too ... */ - DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX or do we want something more restrictive? + DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive? } } @@ -103,14 +103,14 @@ void ANIM_list_elem_update(Scene *scene, bAnimListElem *ale) void ANIM_id_update(Scene *UNUSED(scene), ID *id) { if (id) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* tag AnimData for refresh so that other views will update in realtime with these changes */ if (adt) adt->recalc |= ADT_RECALC_ANIM; /* set recalc flags */ - DAG_id_tag_update(id, OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME); // XXX or do we want something more restrictive? + DAG_id_tag_update(id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); // XXX or do we want something more restrictive? } } @@ -125,10 +125,10 @@ void ANIM_id_update(Scene *UNUSED(scene), ID *id) */ /* perform syncing updates for Action Groups */ -static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) +static void animchan_sync_group(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - bActionGroup *agrp= (bActionGroup *)ale->data; - ID *owner_id= ale->id; + bActionGroup *agrp = (bActionGroup *)ale->data; + ID *owner_id = ale->id; /* major priority is selection status * so we need both a group and an owner @@ -138,13 +138,13 @@ static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) /* for standard Objects, check if group is the name of some bone */ if (GS(owner_id->name) == ID_OB) { - Object *ob= (Object *)owner_id; + Object *ob = (Object *)owner_id; /* check if there are bones, and whether the name matches any * NOTE: this feature will only really work if groups by default contain the F-Curves for a single bone */ if (ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, agrp->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, agrp->name); /* if one matches, sync the selection status */ if (pchan) { @@ -158,10 +158,10 @@ static void animchan_sync_group (bAnimContext *UNUSED(ac), bAnimListElem *ale) } /* perform syncing updates for F-Curves */ -static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) +static void animchan_sync_fcurve(bAnimContext *UNUSED(ac), bAnimListElem *ale) { - FCurve *fcu= (FCurve *)ale->data; - ID *owner_id= ale->id; + FCurve *fcu = (FCurve *)ale->data; + ID *owner_id = ale->id; /* major priority is selection status, so refer to the checks done in anim_filter.c * skip_fcurve_selected_data() for reference about what's going on here... @@ -170,7 +170,7 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) return; if (GS(owner_id->name) == ID_OB) { - Object *ob= (Object *)owner_id; + Object *ob = (Object *)owner_id; /* only affect if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { @@ -178,8 +178,8 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) char *bone_name; /* get bone-name, and check if this bone is selected */ - bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); - pchan= get_pose_channel(ob->pose, bone_name); + bone_name = BLI_getQuotedStr(fcu->rna_path, "pose.bones["); + pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* F-Curve selection depends on whether the bone is selected */ @@ -196,12 +196,12 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) /* only affect if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; char *seq_name; /* get strip name, and check if this strip is selected */ - seq_name= BLI_getQuotedStr(fcu->rna_path, "sequences_all["); + seq_name = BLI_getQuotedStr(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); @@ -223,7 +223,7 @@ static void animchan_sync_fcurve (bAnimContext *UNUSED(ac), bAnimListElem *ale) char *node_name; /* get strip name, and check if this strip is selected */ - node_name= BLI_getQuotedStr(fcu->rna_path, "nodes["); + node_name = BLI_getQuotedStr(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); @@ -254,12 +254,12 @@ void ANIM_sync_animchannels_to_data(const bContext *C) return; /* filter data */ - /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed */ - filter= ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_CHANNELS; + /* NOTE: we want all channels, since we want to be able to set selection status on some of them even when collapsed */ + filter = ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_CHANNELS; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* flush settings as appropriate depending on the types of the channels */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_GROUP: animchan_sync_group(&ac, ale); diff --git a/source/blender/editors/animation/anim_draw.c b/source/blender/editors/animation/anim_draw.c index 236b8d18b78..0514700e120 100644 --- a/source/blender/editors/animation/anim_draw.c +++ b/source/blender/editors/animation/anim_draw.c @@ -55,7 +55,7 @@ /* TIME CODE FORMATTING */ /* Generate timecode/frame number string and store in the supplied string - * - buffer: must be at least 13 chars long + * - buffer: must be at least 13 chars long * - power: special setting for View2D grid drawing, * used to specify how detailed we need to be * - timecodes: boolean specifying whether timecodes or @@ -66,41 +66,41 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short timecodes, float cfra) { if (timecodes) { - int hours=0, minutes=0, seconds=0, frames=0; - float raw_seconds= cfra; - char neg[2]= {'\0'}; + int hours = 0, minutes = 0, seconds = 0, frames = 0; + float raw_seconds = cfra; + char neg[2] = {'\0'}; /* get cframes */ if (cfra < 0) { /* correction for negative cfraues */ - neg[0]= '-'; + neg[0] = '-'; cfra = -cfra; } if (cfra >= 3600) { /* hours */ /* XXX should we only display a single digit for hours since clips are - * VERY UNLIKELY to be more than 1-2 hours max? However, that would + * VERY UNLIKELY to be more than 1-2 hours max? However, that would * go against conventions... */ - hours= (int)cfra / 3600; - cfra= (float)fmod(cfra, 3600); + hours = (int)cfra / 3600; + cfra = (float)fmod(cfra, 3600); } if (cfra >= 60) { /* minutes */ - minutes= (int)cfra / 60; - cfra= (float)fmod(cfra, 60); + minutes = (int)cfra / 60; + cfra = (float)fmod(cfra, 60); } if (power <= 0) { /* seconds + frames * Frames are derived from 'fraction' of second. We need to perform some additional rounding * to cope with 'half' frames, etc., which should be fine in most cases */ - seconds= (int)cfra; - frames= (int)floor( (((double)cfra - (double)seconds) * FPS) + 0.5 ); + seconds = (int)cfra; + frames = (int)floor( (((double)cfra - (double)seconds) * FPS) + 0.5); } else { /* seconds (with pixel offset rounding) */ - seconds= (int)floor(cfra + 0.375f); + seconds = (int)floor(cfra + 0.375f); } switch (U.timecode_style) { @@ -124,7 +124,7 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t else sprintf(str, "%s%02d:%02d", neg, minutes, seconds); } } - break; + break; case USER_TIMECODE_SMPTE_MSF: { @@ -132,27 +132,27 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t if (hours) sprintf(str, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames); else sprintf(str, "%s%02d:%02d:%02d", neg, minutes, seconds, frames); } - break; + break; case USER_TIMECODE_MILLISECONDS: { /* reduced SMPTE. Instead of frames, milliseconds are shown */ - int ms_dp= (power <= 0) ? (1 - power) : 1; /* precision of decimal part */ - int s_pad= ms_dp+3; /* to get 2 digit whole-number part for seconds display (i.e. 3 is for 2 digits + radix, on top of full length) */ + int ms_dp = (power <= 0) ? (1 - power) : 1; /* precision of decimal part */ + int s_pad = ms_dp + 3; /* to get 2 digit whole-number part for seconds display (i.e. 3 is for 2 digits + radix, on top of full length) */ if (hours) sprintf(str, "%s%02d:%02d:%0*.*f", neg, hours, minutes, s_pad, ms_dp, cfra); else sprintf(str, "%s%02d:%0*.*f", neg, minutes, s_pad, ms_dp, cfra); } - break; + break; case USER_TIMECODE_SECONDS_ONLY: { /* only show the original seconds display */ /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ - if (power <= 0) sprintf(str, "%.*f", 1-power, raw_seconds); + if (power <= 0) sprintf(str, "%.*f", 1 - power, raw_seconds); else sprintf(str, "%d", (int)floor(raw_seconds + 0.375f)); } - break; + break; case USER_TIMECODE_SMPTE_FULL: default: @@ -160,12 +160,12 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t /* full SMPTE format */ sprintf(str, "%s%02d:%02d:%02d:%02d", neg, hours, minutes, seconds, frames); } - break; + break; } } else { /* round to whole numbers if power is >= 1 (i.e. scale is coarse) */ - if (power <= 0) sprintf(str, "%.*f", 1-power, cfra); + if (power <= 0) sprintf(str, "%.*f", 1 - power, cfra); else sprintf(str, "%d", (int)floor(cfra + 0.375f)); } } @@ -174,15 +174,15 @@ void ANIM_timecode_string_from_frame(char *str, Scene *scene, int power, short t /* CURRENT FRAME DRAWING */ /* Draw current frame number in a little green box beside the current frame indicator */ -static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) +static void draw_cfra_number(Scene *scene, View2D *v2d, float cfra, short time) { float xscale, yscale, x, y; - char numstr[32] = " t"; /* t is the character to start replacing from */ + char numstr[32] = " t"; /* t is the character to start replacing from */ short slen; /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); /* get timecode string * - padding on str-buf passed so that it doesn't sit on the frame indicator @@ -193,19 +193,19 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) ANIM_timecode_string_from_frame(&numstr[4], scene, 0, time, FRA2TIME(cfra)); else ANIM_timecode_string_from_frame(&numstr[4], scene, 1, time, cfra); - slen= (short)UI_GetStringWidth(numstr) - 1; + slen = (short)UI_GetStringWidth(numstr) - 1; /* get starting coordinates for drawing */ - x= cfra * xscale; - y= 18; + x = cfra * xscale; + y = 18; /* draw green box around/behind text */ UI_ThemeColorShade(TH_CFRAME, 0); - glRectf(x, y, x+slen, y+15); + glRectf(x, y, x + slen, y + 15); /* draw current frame number - black text */ UI_ThemeColor(TH_TEXT); - UI_DrawString(x-5, y+3, numstr); + UI_DrawString(x - 5, y + 3, numstr); /* restore view transform */ glScalef(xscale, 1.0, 1.0); @@ -214,11 +214,11 @@ static void draw_cfra_number (Scene *scene, View2D *v2d, float cfra, short time) /* General call for drawing current frame indicator in animation editor */ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); float vec[2]; /* Draw a light green line to indicate current frame */ - vec[0]= (float)(scene->r.cfra * scene->r.framelen); + vec[0] = (float)(scene->r.cfra * scene->r.framelen); UI_ThemeColor(TH_CFRAME); if (flag & DRAWCFRA_WIDE) @@ -227,11 +227,11 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) glLineWidth(2.0); glBegin(GL_LINE_STRIP); - vec[1]= v2d->cur.ymin-500.0f; /* XXX arbitrary... want it go to bottom */ - glVertex2fv(vec); + vec[1] = v2d->cur.ymin - 500.0f; /* XXX arbitrary... want it go to bottom */ + glVertex2fv(vec); - vec[1]= v2d->cur.ymax; - glVertex2fv(vec); + vec[1] = v2d->cur.ymax; + glVertex2fv(vec); glEnd(); glLineWidth(1.0); @@ -250,7 +250,7 @@ void ANIM_draw_cfra(const bContext *C, View2D *v2d, short flag) /* Draw preview range 'curtains' for highlighting where the animation data is */ void ANIM_draw_previewrange(const bContext *C, View2D *v2d) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* only draw this if preview range is set */ if (PRVRANGEON) { @@ -298,16 +298,16 @@ AnimData *ANIM_nla_mapping_get(bAnimContext *ac, bAnimListElem *ale) static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt) { /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ - AnimData *adt= (AnimData *)ked->data; - short only_keys= (short)ked->i1; + AnimData *adt = (AnimData *)ked->data; + short only_keys = (short)ked->i1; /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { - bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); - bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); + bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_UNMAP); + bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_UNMAP); } - bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); + bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_UNMAP); return 0; } @@ -316,16 +316,16 @@ static short bezt_nlamapping_restore(KeyframeEditData *ked, BezTriple *bezt) static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt) { /* AnimData block providing scaling is stored in 'data', only_keys option is stored in i1 */ - AnimData *adt= (AnimData*)ked->data; - short only_keys= (short)ked->i1; + AnimData *adt = (AnimData *)ked->data; + short only_keys = (short)ked->i1; /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { - bezt->vec[0][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_MAP); - bezt->vec[2][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_MAP); + bezt->vec[0][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[0][0], NLATIME_CONVERT_MAP); + bezt->vec[2][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[2][0], NLATIME_CONVERT_MAP); } - bezt->vec[1][0]= BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_MAP); + bezt->vec[1][0] = BKE_nla_tweakedit_remap(adt, bezt->vec[1][0], NLATIME_CONVERT_MAP); return 0; } @@ -333,25 +333,25 @@ static short bezt_nlamapping_apply(KeyframeEditData *ked, BezTriple *bezt) /* Apply/Unapply NLA mapping to all keyframes in the nominated F-Curve * - restore = whether to map points back to non-mapped time - * - only_keys = whether to only adjust the location of the center point of beztriples + * - only_keys = whether to only adjust the location of the center point of beztriples */ void ANIM_nla_mapping_apply_fcurve(AnimData *adt, FCurve *fcu, short restore, short only_keys) { - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc map_cb; /* init edit data * - AnimData is stored in 'data' * - only_keys is stored in 'i1' */ - ked.data= (void *)adt; - ked.i1= (int)only_keys; + ked.data = (void *)adt; + ked.i1 = (int)only_keys; /* get editing callback */ if (restore) - map_cb= bezt_nlamapping_restore; + map_cb = bezt_nlamapping_restore; else - map_cb= bezt_nlamapping_apply; + map_cb = bezt_nlamapping_apply; /* apply to F-Curve */ ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, map_cb, NULL); @@ -376,9 +376,9 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest /* if the radians flag is not set, default to using degrees which need conversions */ if ((scene) && (scene->unit.system_rotation == USER_UNIT_ROT_RADIANS) == 0) { if (restore) - return DEG2RADF(1.0f); /* degrees to radians */ + return DEG2RADF(1.0f); /* degrees to radians */ else - return RAD2DEGF(1.0f); /* radians to degrees */ + return RAD2DEGF(1.0f); /* radians to degrees */ } } @@ -393,18 +393,18 @@ float ANIM_unit_mapping_get_factor(Scene *scene, ID *id, FCurve *fcu, short rest /* ----------------------- */ /* helper function for ANIM_unit_mapping_apply_fcurve -> mapping callback for unit mapping */ -static short bezt_unit_mapping_apply (KeyframeEditData *ked, BezTriple *bezt) +static short bezt_unit_mapping_apply(KeyframeEditData *ked, BezTriple *bezt) { /* mapping factor is stored in f1, flags are stored in i1 */ - short only_keys= (ked->i1 & ANIM_UNITCONV_ONLYKEYS); - short sel_vs= (ked->i1 & ANIM_UNITCONV_SELVERTS); - float fac= ked->f1; + short only_keys = (ked->i1 & ANIM_UNITCONV_ONLYKEYS); + short sel_vs = (ked->i1 & ANIM_UNITCONV_SELVERTS); + float fac = ked->f1; /* adjust BezTriple handles only if allowed to */ if (only_keys == 0) { - if ((sel_vs==0) || (bezt->f1 & SELECT)) + if ((sel_vs == 0) || (bezt->f1 & SELECT)) bezt->vec[0][1] *= fac; - if ((sel_vs==0) || (bezt->f3 & SELECT)) + if ((sel_vs == 0) || (bezt->f3 & SELECT)) bezt->vec[2][1] *= fac; } @@ -425,7 +425,7 @@ void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short fla if (G.rendering) return; /* calculate mapping factor, and abort if nothing to change */ - fac= ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE)); + fac = ANIM_unit_mapping_get_factor(scene, id, fcu, (flag & ANIM_UNITCONV_RESTORE)); if (fac == 1.0f) return; @@ -434,14 +434,14 @@ void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short fla * - flags are stored in 'i1' */ memset(&ked, 0, sizeof(KeyframeEditData)); - ked.f1= (float)fac; - ked.i1= (int)flag; + ked.f1 = (float)fac; + ked.i1 = (int)flag; /* only selected? */ if (flag & ANIM_UNITCONV_ONLYSEL) - sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); else - sel_cb= NULL; + sel_cb = NULL; /* apply to F-Curve */ ANIM_fcurve_keyframes_loop(&ked, fcu, sel_cb, bezt_unit_mapping_apply, NULL); @@ -452,7 +452,7 @@ void ANIM_unit_mapping_apply_fcurve(Scene *scene, ID *id, FCurve *fcu, short fla FPoint *fpt; unsigned int i; - for (i=0, fpt=fcu->fpt; i < fcu->totvert; i++, fpt++) { + for (i = 0, fpt = fcu->fpt; i < fcu->totvert; i++, fpt++) { /* apply unit mapping */ fpt->vec[1] *= fac; } diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 809b4c8d65e..3ee3d9c6198 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -100,9 +100,9 @@ /* Get shapekey data being edited (for Action Editor -> ShapeKey mode) */ /* Note: there's a similar function in key.c (ob_get_key) */ -static Key *actedit_get_shapekeys (bAnimContext *ac) +static Key *actedit_get_shapekeys(bAnimContext *ac) { - Scene *scene= ac->scene; + Scene *scene = ac->scene; Object *ob; Key *key; @@ -114,7 +114,7 @@ static Key *actedit_get_shapekeys (bAnimContext *ac) //if (saction->pin) return NULL; /* shapekey data is stored with geometry data */ - key= ob_get_key(ob); + key = ob_get_key(ob); if (key) { if (key->type == KEY_RELATIVE) @@ -125,7 +125,7 @@ static Key *actedit_get_shapekeys (bAnimContext *ac) } /* Get data being edited in Action Editor (depending on current 'mode') */ -static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) +static short actedit_get_context(bAnimContext *ac, SpaceAction *saction) { /* get dopesheet */ ac->ads = &saction->ads; @@ -134,51 +134,61 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) switch (saction->mode) { case SACTCONT_ACTION: /* 'Action Editor' */ /* if not pinned, sync with active object */ - if (/*saction->pin == 0*/1) { + if (/*saction->pin == 0*/ 1) { if (ac->obact && ac->obact->adt) saction->action = ac->obact->adt->action; else - saction->action= NULL; + saction->action = NULL; } - ac->datatype= ANIMCONT_ACTION; - ac->data= saction->action; + ac->datatype = ANIMCONT_ACTION; + ac->data = saction->action; - ac->mode= saction->mode; + ac->mode = saction->mode; return 1; case SACTCONT_SHAPEKEY: /* 'ShapeKey Editor' */ - ac->datatype= ANIMCONT_SHAPEKEY; - ac->data= actedit_get_shapekeys(ac); + ac->datatype = ANIMCONT_SHAPEKEY; + ac->data = actedit_get_shapekeys(ac); - ac->mode= saction->mode; + /* if not pinned, sync with active object */ + if (/*saction->pin == 0*/ 1) { + Key *key = (Key *)ac->data; + + if (key && key->adt) + saction->action = key->adt->action; + else + saction->action = NULL; + } + + ac->mode = saction->mode; return 1; case SACTCONT_GPENCIL: /* Grease Pencil */ // XXX review how this mode is handled... /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - saction->ads.source= (ID *)ac->scene; + saction->ads.source = (ID *)ac->scene; - ac->datatype= ANIMCONT_GPENCIL; - ac->data= &saction->ads; + ac->datatype = ANIMCONT_GPENCIL; + ac->data = &saction->ads; - ac->mode= saction->mode; + ac->mode = saction->mode; return 1; case SACTCONT_DOPESHEET: /* DopeSheet */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - saction->ads.source= (ID *)ac->scene; + saction->ads.source = (ID *)ac->scene; - ac->datatype= ANIMCONT_DOPESHEET; - ac->data= &saction->ads; + ac->datatype = ANIMCONT_DOPESHEET; + ac->data = &saction->ads; - ac->mode= saction->mode; + ac->mode = saction->mode; return 1; default: /* unhandled yet */ - ac->datatype= ANIMCONT_NONE; - ac->data= NULL; + ac->datatype = ANIMCONT_NONE; + ac->data = NULL; - ac->mode= -1; + ac->mode = -1; return 0; } } @@ -186,12 +196,12 @@ static short actedit_get_context (bAnimContext *ac, SpaceAction *saction) /* ----------- Private Stuff - Graph Editor ------------- */ /* Get data being edited in Graph Editor (depending on current 'mode') */ -static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) +static short graphedit_get_context(bAnimContext *ac, SpaceIpo *sipo) { /* init dopesheet data if non-existant (i.e. for old files) */ if (sipo->ads == NULL) { - sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source= (ID *)ac->scene; + sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); + sipo->ads->source = (ID *)ac->scene; } ac->ads = sipo->ads; @@ -203,33 +213,33 @@ static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) /* sync settings with current view status, then return appropriate data */ switch (sipo->mode) { - case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */ + case SIPO_MODE_ANIMATION: /* Animation F-Curve Editor */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - sipo->ads->source= (ID *)ac->scene; + sipo->ads->source = (ID *)ac->scene; sipo->ads->filterflag &= ~ADS_FILTER_ONLYDRIVERS; - ac->datatype= ANIMCONT_FCURVES; - ac->data= sipo->ads; + ac->datatype = ANIMCONT_FCURVES; + ac->data = sipo->ads; - ac->mode= sipo->mode; + ac->mode = sipo->mode; return 1; - case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */ + case SIPO_MODE_DRIVERS: /* Driver F-Curve Editor */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - sipo->ads->source= (ID *)ac->scene; + sipo->ads->source = (ID *)ac->scene; sipo->ads->filterflag |= ADS_FILTER_ONLYDRIVERS; - ac->datatype= ANIMCONT_DRIVERS; - ac->data= sipo->ads; + ac->datatype = ANIMCONT_DRIVERS; + ac->data = sipo->ads; - ac->mode= sipo->mode; + ac->mode = sipo->mode; return 1; default: /* unhandled yet */ - ac->datatype= ANIMCONT_NONE; - ac->data= NULL; + ac->datatype = ANIMCONT_NONE; + ac->data = NULL; - ac->mode= -1; + ac->mode = -1; return 0; } } @@ -237,20 +247,20 @@ static short graphedit_get_context (bAnimContext *ac, SpaceIpo *sipo) /* ----------- Private Stuff - NLA Editor ------------- */ /* Get data being edited in Graph Editor (depending on current 'mode') */ -static short nlaedit_get_context (bAnimContext *ac, SpaceNla *snla) +static short nlaedit_get_context(bAnimContext *ac, SpaceNla *snla) { /* init dopesheet data if non-existant (i.e. for old files) */ if (snla->ads == NULL) - snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); ac->ads = snla->ads; /* sync settings with current view status, then return appropriate data */ /* update scene-pointer (no need to check for pinning yet, as not implemented) */ - snla->ads->source= (ID *)ac->scene; + snla->ads->source = (ID *)ac->scene; snla->ads->filterflag |= ADS_FILTER_ONLYNLA; - ac->datatype= ANIMCONT_NLA; - ac->data= snla->ads; + ac->datatype = ANIMCONT_NLA; + ac->data = snla->ads; return 1; } @@ -264,31 +274,31 @@ static short nlaedit_get_context (bAnimContext *ac, SpaceNla *snla) short ANIM_animdata_context_getdata(bAnimContext *ac) { SpaceLink *sl = ac->sl; - short ok= 0; + short ok = 0; /* context depends on editor we are currently in */ if (sl) { switch (ac->spacetype) { case SPACE_ACTION: { - SpaceAction *saction= (SpaceAction *)sl; - ok= actedit_get_context(ac, saction); + SpaceAction *saction = (SpaceAction *)sl; + ok = actedit_get_context(ac, saction); } - break; + break; case SPACE_IPO: { - SpaceIpo *sipo= (SpaceIpo *)sl; - ok= graphedit_get_context(ac, sipo); + SpaceIpo *sipo = (SpaceIpo *)sl; + ok = graphedit_get_context(ac, sipo); } - break; + break; case SPACE_NLA: { - SpaceNla *snla= (SpaceNla *)sl; - ok= nlaedit_get_context(ac, snla); + SpaceNla *snla = (SpaceNla *)sl; + ok = nlaedit_get_context(ac, snla); } - break; + break; } } @@ -306,26 +316,26 @@ short ANIM_animdata_context_getdata(bAnimContext *ac) */ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - SpaceLink *sl= CTX_wm_space_data(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + SpaceLink *sl = CTX_wm_space_data(C); + Scene *scene = CTX_data_scene(C); /* clear old context info */ if (ac == NULL) return 0; memset(ac, 0, sizeof(bAnimContext)); /* get useful default context settings from context */ - ac->scene= scene; + ac->scene = scene; if (scene) { - ac->markers= ED_context_get_markers(C); - ac->obact= (scene->basact)? scene->basact->object : NULL; + ac->markers = ED_context_get_markers(C); + ac->obact = (scene->basact) ? scene->basact->object : NULL; } - ac->sa= sa; - ac->ar= ar; - ac->sl= sl; - ac->spacetype= (sa) ? sa->spacetype : 0; - ac->regiontype= (ar) ? ar->regiontype : 0; + ac->sa = sa; + ac->ar = ar; + ac->sl = sl; + ac->spacetype = (sa) ? sa->spacetype : 0; + ac->regiontype = (ar) ? ar->regiontype : 0; /* get data context info */ return ANIM_animdata_context_getdata(ac); @@ -346,28 +356,28 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * dealt with by the recursive detection idiom in place. * * Implementation Note: - * YES the _doSubChannels variable is NOT read anywhere. BUT, this is NOT an excuse - * to go steamrolling the logic into a single-line expression as from experience, - * those are notoriously difficult to read + debug when extending later on. The code - * below is purposefully laid out so that each case noted above corresponds clearly to - * one case below. + * YES the _doSubChannels variable is NOT read anywhere. BUT, this is NOT an excuse + * to go steamrolling the logic into a single-line expression as from experience, + * those are notoriously difficult to read + debug when extending later on. The code + * below is purposefully laid out so that each case noted above corresponds clearly to + * one case below. */ #define BEGIN_ANIMFILTER_SUBCHANNELS(expanded_check) \ { \ int _filter = filter_mode; \ short _doSubChannels = 0; \ if (!(filter_mode & ANIMFILTER_LIST_VISIBLE) || (expanded_check)) \ - _doSubChannels=1; \ + _doSubChannels = 1; \ else if (!(filter_mode & ANIMFILTER_LIST_CHANNELS)) \ - _doSubChannels=2; \ - else {\ + _doSubChannels = 2; \ + else { \ filter_mode |= ANIMFILTER_TMP_PEEK; \ } \ - \ + \ { \ (void) _doSubChannels; \ } - /* ... standard sub-channel filtering can go on here now ... */ +/* ... standard sub-channel filtering can go on here now ... */ #define END_ANIMFILTER_SUBCHANNELS \ filter_mode = _filter; \ } @@ -393,9 +403,9 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * - ListBase anim_data; * - bDopeSheet *ads; * - bAnimListElem *ale; - * - size_t items; + * - size_t items; * - * - id: ID block which should have an AnimData pointer following it immediately, to use + * - id: ID block which should have an AnimData pointer following it immediately, to use * - adtOk: line or block of code to execute for AnimData-blocks case (usually ANIMDATA_ADD_ANIMDATA) * - nlaOk: line or block of code to execute for NLA tracks+strips case * - driversOk: line or block of code to execute for Drivers case @@ -412,32 +422,32 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * 4) normal keyframes: only when there is an active action */ #define ANIMDATA_FILTER_CASES(id, adtOk, nlaOk, driversOk, keysOk) \ - {\ - if ((id)->adt) {\ - if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) {\ - if (filter_mode & ANIMFILTER_ANIMDATA) {\ - adtOk\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYNLA) {\ - if (ANIMDATA_HAS_NLA(id)) {\ - nlaOk\ - }\ - else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) {\ - nlaOk\ - }\ - }\ - else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) {\ - if (ANIMDATA_HAS_DRIVERS(id)) {\ - driversOk\ - }\ - }\ - else {\ - if (ANIMDATA_HAS_KEYS(id)) {\ - keysOk\ - }\ - }\ - }\ - }\ + { \ + if ((id)->adt) { \ + if (!(filter_mode & ANIMFILTER_CURVE_VISIBLE) || !((id)->adt->flag & ADT_CURVES_NOT_VISIBLE)) { \ + if (filter_mode & ANIMFILTER_ANIMDATA) { \ + adtOk \ + } \ + else if (ads->filterflag & ADS_FILTER_ONLYNLA) { \ + if (ANIMDATA_HAS_NLA(id)) { \ + nlaOk \ + } \ + else if (!(ads->filterflag & ADS_FILTER_NLA_NOACT) && ANIMDATA_HAS_KEYS(id)) { \ + nlaOk \ + } \ + } \ + else if (ads->filterflag & ADS_FILTER_ONLYDRIVERS) { \ + if (ANIMDATA_HAS_DRIVERS(id)) { \ + driversOk \ + } \ + } \ + else { \ + if (ANIMDATA_HAS_KEYS(id)) { \ + keysOk \ + } \ + } \ + } \ + } \ } /* ............................... */ @@ -452,10 +462,10 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) if (filter_mode & ANIMFILTER_TMP_PEEK) \ return 1; \ else { \ - bAnimListElem *ale= make_new_animlistelem(channel_data, channel_type, (ID *)owner_id); \ - if (ale) {\ + bAnimListElem *ale = make_new_animlistelem(channel_data, channel_type, (ID *)owner_id); \ + if (ale) { \ BLI_addtail(anim_data, ale); \ - items++; \ + items ++; \ ale_statement \ } \ } @@ -467,13 +477,13 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) /* quick macro to test if an anim-channel representing an AnimData block is suitably active */ #define ANIMCHANNEL_ACTIVEOK(ale) \ - ( !(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE) ) + (!(filter_mode & ANIMFILTER_ACTIVE) || !(ale->adt) || (ale->adt->flag & ADT_UI_ACTIVE) ) /* quick macro to test if an anim-channel (F-Curve, Group, etc.) is selected in an acceptable way */ #define ANIMCHANNEL_SELOK(test_func) \ - ( !(filter_mode & (ANIMFILTER_SEL|ANIMFILTER_UNSEL)) || \ - ((filter_mode & ANIMFILTER_SEL) && test_func) || \ - ((filter_mode & ANIMFILTER_UNSEL) && test_func==0) ) + (!(filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) || \ + ((filter_mode & ANIMFILTER_SEL) && test_func) || \ + ((filter_mode & ANIMFILTER_UNSEL) && test_func == 0) ) /* quick macro to test if an anim-channel (F-Curve) is selected ok for editing purposes * - _SELEDIT means that only selected curves will have visible+editable keyframes @@ -484,29 +494,29 @@ short ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) * 3) test_func (i.e. selection test) - only if selected, this test will pass */ #define ANIMCHANNEL_SELEDITOK(test_func) \ - ( !(filter_mode & ANIMFILTER_SELEDIT) || \ - !(filter_mode & ANIMFILTER_FOREDIT) || \ - (test_func) ) + (!(filter_mode & ANIMFILTER_SELEDIT) || \ + !(filter_mode & ANIMFILTER_FOREDIT) || \ + (test_func) ) /* ----------- 'Private' Stuff --------------- */ /* this function allocates memory for a new bAnimListElem struct for the * provided animation channel-data. */ -static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *owner_id) +static bAnimListElem *make_new_animlistelem(void *data, short datatype, ID *owner_id) { - bAnimListElem *ale= NULL; + bAnimListElem *ale = NULL; /* only allocate memory if there is data to convert */ if (data) { /* allocate and set generic data */ - ale= MEM_callocN(sizeof(bAnimListElem), "bAnimListElem"); + ale = MEM_callocN(sizeof(bAnimListElem), "bAnimListElem"); - ale->data= data; - ale->type= datatype; + ale->data = data; + ale->type = datatype; - ale->id= owner_id; - ale->adt= BKE_animdata_from_id(owner_id); + ale->id = owner_id; + ale->adt = BKE_animdata_from_id(owner_id); /* do specifics */ switch (datatype) { @@ -515,201 +525,201 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own /* nothing to include for now... this is just a dummy wrappy around all the other channels * in the DopeSheet, and gets included at the start of the list */ - ale->key_data= NULL; - ale->datatype= ALE_ALL; + ale->key_data = NULL; + ale->datatype = ALE_ALL; } - break; + break; case ANIMTYPE_SCENE: { - Scene *sce= (Scene *)data; + Scene *sce = (Scene *)data; - ale->flag= sce->flag; + ale->flag = sce->flag; - ale->key_data= sce; - ale->datatype= ALE_SCE; + ale->key_data = sce; + ale->datatype = ALE_SCE; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_OBJECT: { - Base *base= (Base *)data; - Object *ob= base->object; + Base *base = (Base *)data; + Object *ob = base->object; - ale->flag= ob->flag; + ale->flag = ob->flag; - ale->key_data= ob; - ale->datatype= ALE_OB; + ale->key_data = ob; + ale->datatype = ALE_OB; - ale->adt= BKE_animdata_from_id(&ob->id); + ale->adt = BKE_animdata_from_id(&ob->id); } - break; + break; case ANIMTYPE_FILLACTD: { - bAction *act= (bAction *)data; + bAction *act = (bAction *)data; - ale->flag= act->flag; + ale->flag = act->flag; - ale->key_data= act; - ale->datatype= ALE_ACT; + ale->key_data = act; + ale->datatype = ALE_ACT; } - break; + break; case ANIMTYPE_FILLDRIVERS: { - AnimData *adt= (AnimData *)data; + AnimData *adt = (AnimData *)data; - ale->flag= adt->flag; + ale->flag = adt->flag; - // XXX... drivers don't show summary for now - ale->key_data= NULL; - ale->datatype= ALE_NONE; + // XXX... drivers don't show summary for now + ale->key_data = NULL; + ale->datatype = ALE_NONE; } - break; + break; case ANIMTYPE_DSMAT: { - Material *ma= (Material *)data; - AnimData *adt= ma->adt; + Material *ma = (Material *)data; + AnimData *adt = ma->adt; - ale->flag= FILTER_MAT_OBJD(ma); + ale->flag = FILTER_MAT_OBJD(ma); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSLAM: { - Lamp *la= (Lamp *)data; - AnimData *adt= la->adt; + Lamp *la = (Lamp *)data; + AnimData *adt = la->adt; - ale->flag= FILTER_LAM_OBJD(la); + ale->flag = FILTER_LAM_OBJD(la); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSCAM: { - Camera *ca= (Camera *)data; - AnimData *adt= ca->adt; + Camera *ca = (Camera *)data; + AnimData *adt = ca->adt; - ale->flag= FILTER_CAM_OBJD(ca); + ale->flag = FILTER_CAM_OBJD(ca); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSCUR: { - Curve *cu= (Curve *)data; - AnimData *adt= cu->adt; + Curve *cu = (Curve *)data; + AnimData *adt = cu->adt; - ale->flag= FILTER_CUR_OBJD(cu); + ale->flag = FILTER_CUR_OBJD(cu); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSARM: { - bArmature *arm= (bArmature *)data; - AnimData *adt= arm->adt; + bArmature *arm = (bArmature *)data; + AnimData *adt = arm->adt; - ale->flag= FILTER_ARM_OBJD(arm); + ale->flag = FILTER_ARM_OBJD(arm); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSMESH: { - Mesh *me= (Mesh *)data; - AnimData *adt= me->adt; + Mesh *me = (Mesh *)data; + AnimData *adt = me->adt; - ale->flag= FILTER_MESH_OBJD(me); + ale->flag = FILTER_MESH_OBJD(me); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSLAT: { - Lattice *lt= (Lattice *)data; - AnimData *adt= lt->adt; + Lattice *lt = (Lattice *)data; + AnimData *adt = lt->adt; - ale->flag= FILTER_LATTICE_OBJD(lt); + ale->flag = FILTER_LATTICE_OBJD(lt); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSSPK: { - Speaker *spk= (Speaker *)data; - AnimData *adt= spk->adt; + Speaker *spk = (Speaker *)data; + AnimData *adt = spk->adt; - ale->flag= FILTER_SPK_OBJD(spk); + ale->flag = FILTER_SPK_OBJD(spk); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSSKEY: { - Key *key= (Key *)data; - AnimData *adt= key->adt; + Key *key = (Key *)data; + AnimData *adt = key->adt; - ale->flag= FILTER_SKE_OBJD(key); + ale->flag = FILTER_SKE_OBJD(key); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSWOR: { - World *wo= (World *)data; - AnimData *adt= wo->adt; + World *wo = (World *)data; + AnimData *adt = wo->adt; - ale->flag= FILTER_WOR_SCED(wo); + ale->flag = FILTER_WOR_SCED(wo); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSNTREE: { - bNodeTree *ntree= (bNodeTree *)data; - AnimData *adt= ntree->adt; + bNodeTree *ntree = (bNodeTree *)data; + AnimData *adt = ntree->adt; - ale->flag= FILTER_NTREE_DATA(ntree); + ale->flag = FILTER_NTREE_DATA(ntree); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSLINESTYLE: { FreestyleLineStyle *linestyle= (FreestyleLineStyle *)data; @@ -725,110 +735,110 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own break; case ANIMTYPE_DSPART: { - ParticleSettings *part= (ParticleSettings*)ale->data; - AnimData *adt= part->adt; + ParticleSettings *part = (ParticleSettings *)ale->data; + AnimData *adt = part->adt; - ale->flag= FILTER_PART_OBJD(part); + ale->flag = FILTER_PART_OBJD(part); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_DSTEX: { - Tex *tex= (Tex *)data; - AnimData *adt= tex->adt; + Tex *tex = (Tex *)data; + AnimData *adt = tex->adt; - ale->flag= FILTER_TEX_DATA(tex); + ale->flag = FILTER_TEX_DATA(tex); - ale->key_data= (adt) ? adt->action : NULL; - ale->datatype= ALE_ACT; + ale->key_data = (adt) ? adt->action : NULL; + ale->datatype = ALE_ACT; - ale->adt= BKE_animdata_from_id(data); + ale->adt = BKE_animdata_from_id(data); } - break; + break; case ANIMTYPE_GROUP: { - bActionGroup *agrp= (bActionGroup *)data; + bActionGroup *agrp = (bActionGroup *)data; - ale->flag= agrp->flag; + ale->flag = agrp->flag; - ale->key_data= NULL; - ale->datatype= ALE_GROUP; + ale->key_data = NULL; + ale->datatype = ALE_GROUP; } - break; + break; case ANIMTYPE_FCURVE: { - FCurve *fcu= (FCurve *)data; + FCurve *fcu = (FCurve *)data; - ale->flag= fcu->flag; + ale->flag = fcu->flag; - ale->key_data= fcu; - ale->datatype= ALE_FCURVE; + ale->key_data = fcu; + ale->datatype = ALE_FCURVE; } - break; + break; case ANIMTYPE_SHAPEKEY: { - KeyBlock *kb= (KeyBlock *)data; - Key *key= (Key *)ale->id; + KeyBlock *kb = (KeyBlock *)data; + Key *key = (Key *)ale->id; - ale->flag= kb->flag; + ale->flag = kb->flag; /* whether we have keyframes depends on whether there is a Key block to find it from */ if (key) { /* index of shapekey is defined by place in key's list */ - ale->index= BLI_findindex(&key->block, kb); + ale->index = BLI_findindex(&key->block, kb); /* the corresponding keyframes are from the animdata */ if (ale->adt && ale->adt->action) { - bAction *act= ale->adt->action; + bAction *act = ale->adt->action; char *rna_path = key_get_curValue_rnaPath(key, kb); /* try to find the F-Curve which corresponds to this exactly, * then free the MEM_alloc'd string */ if (rna_path) { - ale->key_data= (void *)list_find_fcurve(&act->curves, rna_path, 0); + ale->key_data = (void *)list_find_fcurve(&act->curves, rna_path, 0); MEM_freeN(rna_path); } } - ale->datatype= (ale->key_data)? ALE_FCURVE : ALE_NONE; + ale->datatype = (ale->key_data) ? ALE_FCURVE : ALE_NONE; } } - break; + break; case ANIMTYPE_GPLAYER: { - bGPDlayer *gpl= (bGPDlayer *)data; + bGPDlayer *gpl = (bGPDlayer *)data; - ale->flag= gpl->flag; + ale->flag = gpl->flag; - ale->key_data= NULL; - ale->datatype= ALE_GPFRAME; + ale->key_data = NULL; + ale->datatype = ALE_GPFRAME; } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)data; + NlaTrack *nlt = (NlaTrack *)data; - ale->flag= nlt->flag; + ale->flag = nlt->flag; - ale->key_data= &nlt->strips; - ale->datatype= ALE_NLASTRIP; + ale->key_data = &nlt->strips; + ale->datatype = ALE_NLASTRIP; } - break; + break; case ANIMTYPE_NLAACTION: { /* nothing to include for now... nothing editable from NLA-perspective here */ - ale->key_data= NULL; - ale->datatype= ALE_NONE; + ale->key_data = NULL; + ale->datatype = ALE_NONE; } - break; + break; } } @@ -841,13 +851,13 @@ static bAnimListElem *make_new_animlistelem (void *data, short datatype, ID *own /* 'Only Selected' selected data and/or 'Include Hidden' filtering * NOTE: when this function returns true, the F-Curve is to be skipped */ -static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) +static short skip_fcurve_selected_data(bDopeSheet *ads, FCurve *fcu, ID *owner_id, int filter_mode) { /* hidden items should be skipped if we only care about visible data, but we aren't interested in hidden stuff */ short skip_hidden = (filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN); if (GS(owner_id->name) == ID_OB) { - Object *ob= (Object *)owner_id; + Object *ob = (Object *)owner_id; /* only consider if F-Curve involves pose.bones */ if ((fcu->rna_path) && strstr(fcu->rna_path, "pose.bones")) { @@ -855,15 +865,15 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ char *bone_name; /* get bone-name, and check if this bone is selected */ - bone_name= BLI_getQuotedStr(fcu->rna_path, "pose.bones["); - pchan= get_pose_channel(ob->pose, bone_name); + bone_name = BLI_getQuotedStr(fcu->rna_path, "pose.bones["); + pchan = BKE_pose_channel_find_name(ob->pose, bone_name); if (bone_name) MEM_freeN(bone_name); /* check whether to continue or skip */ if ((pchan) && (pchan->bone)) { /* if only visible channels, skip if bone not visible unless user wants channels from hidden data too */ if (skip_hidden) { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; /* skipping - not visible on currently visible layers */ if ((arm->layer & pchan->bone->layer) == 0) @@ -886,18 +896,18 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ /* only consider if F-Curve involves sequence_editor.sequences */ if ((fcu->rna_path) && strstr(fcu->rna_path, "sequences_all")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; char *seq_name; /* get strip name, and check if this strip is selected */ - seq_name= BLI_getQuotedStr(fcu->rna_path, "sequences_all["); + seq_name = BLI_getQuotedStr(fcu->rna_path, "sequences_all["); seq = get_seq_by_name(ed->seqbasep, seq_name, FALSE); if (seq_name) MEM_freeN(seq_name); /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { - if ((seq == NULL) || (seq->flag & SELECT)==0) + if ((seq == NULL) || (seq->flag & SELECT) == 0) return 1; } } @@ -911,13 +921,13 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ char *node_name; /* get strip name, and check if this strip is selected */ - node_name= BLI_getQuotedStr(fcu->rna_path, "nodes["); + node_name = BLI_getQuotedStr(fcu->rna_path, "nodes["); node = nodeFindNodebyName(ntree, node_name); if (node_name) MEM_freeN(node_name); /* can only add this F-Curve if it is selected */ if (ads->filterflag & ADS_FILTER_ONLYSEL) { - if ((node) && (node->flag & NODE_SELECT)==0) + if ((node) && (node->flag & NODE_SELECT) == 0) return 1; } } @@ -928,7 +938,7 @@ static short skip_fcurve_selected_data (bDopeSheet *ads, FCurve *fcu, ID *owner_ /* (Display-)Name-based F-Curve filtering * NOTE: when this function returns true, the F-Curve is to be skipped */ -static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id) +static short skip_fcurve_with_name(bDopeSheet *ads, FCurve *fcu, ID *owner_id) { bAnimListElem ale_dummy = {NULL}; bAnimChannelType *acf; @@ -957,14 +967,14 @@ static short skip_fcurve_with_name (bDopeSheet *ads, FCurve *fcu, ID *owner_id) } /* find the next F-Curve that is usable for inclusion */ -static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) +static FCurve *animfilter_fcurve_next(bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) { FCurve *fcu = NULL; /* loop over F-Curves - assume that the caller of this has already checked that these should be included * NOTE: we need to check if the F-Curves belong to the same group, as this gets called for groups too... */ - for (fcu= first; ((fcu) && (fcu->grp==grp)); fcu= fcu->next) { + for (fcu = first; ((fcu) && (fcu->grp == grp)); fcu = fcu->next) { /* special exception for Pose-Channel/Sequence-Strip/Node Based F-Curves: * - the 'Only Selected' and 'Include Hidden' data filters should be applied to sub-ID data which * can be independently selected/hidden, such as Pose-Channels, Sequence Strips, and Nodes. @@ -974,7 +984,7 @@ static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGr * - this will also affect things like Drivers, and also works for Bone Constraints */ if (ads && owner_id) { - if ((ads->filterflag & ADS_FILTER_ONLYSEL) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN)==0) { + if ((ads->filterflag & ADS_FILTER_ONLYSEL) || (ads->filterflag & ADS_FILTER_INCL_HIDDEN) == 0) { if (skip_fcurve_selected_data(ads, fcu, owner_id, filter_mode)) continue; } @@ -1006,7 +1016,7 @@ static FCurve *animfilter_fcurve_next (bDopeSheet *ads, FCurve *first, bActionGr return NULL; } -static size_t animfilter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) +static size_t animfilter_fcurves(ListBase *anim_data, bDopeSheet *ads, FCurve *first, bActionGroup *grp, int filter_mode, ID *owner_id) { FCurve *fcu; size_t items = 0; @@ -1028,7 +1038,7 @@ static size_t animfilter_fcurves (ListBase *anim_data, bDopeSheet *ads, FCurve * return items; } -static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *UNUSED(act), bActionGroup *agrp, int filter_mode, ID *owner_id) +static size_t animfilter_act_group(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *UNUSED(act), bActionGroup *agrp, int filter_mode, ID *owner_id) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1037,12 +1047,12 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope /* if we care about the selection status of the channels, * but the group isn't expanded (1)... - * (1) this only matters if we actually care about the hierarchy though. + * (1) this only matters if we actually care about the hierarchy though. * - Hierarchy matters: this hack should be applied * - Hierarchy ignored: cases like [#21276] won't work properly, unless we skip this hack */ - if ( ((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp)==0) && /* care about hierarchy but group isn't expanded */ - (filter_mode & (ANIMFILTER_SEL|ANIMFILTER_UNSEL)) ) /* care about selection status */ + if ( ((filter_mode & ANIMFILTER_LIST_VISIBLE) && EXPANDED_AGRP(ac, agrp) == 0) && /* care about hierarchy but group isn't expanded */ + (filter_mode & (ANIMFILTER_SEL | ANIMFILTER_UNSEL)) ) /* care about selection status */ { /* if the group itself isn't selected appropriately, we shouldn't consider it's children either */ if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) == 0) @@ -1056,7 +1066,7 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope * - pasting keyframes * - creating ghost curves in Graph Editor */ - filter_mode &= ~(ANIMFILTER_SEL|ANIMFILTER_UNSEL|ANIMFILTER_LIST_VISIBLE); + filter_mode &= ~(ANIMFILTER_SEL | ANIMFILTER_UNSEL | ANIMFILTER_LIST_VISIBLE); } /* add grouped F-Curves */ @@ -1090,7 +1100,7 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope //filter_mode = ofilter; /* filter selection of channel specially here again, since may be open and not subject to previous test */ - if ( ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) { + if (ANIMCHANNEL_SELOK(SEL_AGRP(agrp)) ) { ANIMCHANNEL_NEW_CHANNEL(agrp, ANIMTYPE_GROUP, owner_id); } } @@ -1105,7 +1115,7 @@ static size_t animfilter_act_group (bAnimContext *ac, ListBase *anim_data, bDope return items; } -static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, ID *owner_id) +static size_t animfilter_action(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAction *act, int filter_mode, ID *owner_id) { bActionGroup *agrp; FCurve *lastchan = NULL; @@ -1123,7 +1133,7 @@ static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeShe for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* store reference to last channel of group */ if (agrp->channels.last) - lastchan= agrp->channels.last; + lastchan = agrp->channels.last; /* action group's channels */ items += animfilter_act_group(ac, anim_data, ads, act, agrp, filter_mode, owner_id); @@ -1131,7 +1141,7 @@ static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeShe /* un-grouped F-Curves (only if we're not only considering those channels in the active group) */ if (!(filter_mode & ANIMFILTER_ACTGROUPED)) { - FCurve *firstfcu = (lastchan)? (lastchan->next) : (act->curves.first); + FCurve *firstfcu = (lastchan) ? (lastchan->next) : (act->curves.first); items += animfilter_fcurves(anim_data, ads, firstfcu, NULL, filter_mode, owner_id); } @@ -1147,10 +1157,10 @@ static size_t animfilter_action (bAnimContext *ac, ListBase *anim_data, bDopeShe * - for normal filtering (i.e. for editing), we only need the NLA-tracks but they can be in 'normal' evaluation * order, i.e. first to last. Otherwise, some tools may get screwed up. */ -static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, ID *owner_id) +static size_t animfilter_nla(bAnimContext *UNUSED(ac), ListBase *anim_data, bDopeSheet *ads, AnimData *adt, int filter_mode, ID *owner_id) { NlaTrack *nlt; - NlaTrack *first=NULL, *next=NULL; + NlaTrack *first = NULL, *next = NULL; size_t items = 0; /* if showing channels, include active action */ @@ -1167,26 +1177,26 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo */ ANIMCHANNEL_NEW_CHANNEL_FULL((void *)(&adt->action), ANIMTYPE_NLAACTION, owner_id, { - ale->data= adt->action ? adt->action : NULL; + ale->data = adt->action ? adt->action : NULL; }); } } /* first track to include will be the last one if we're filtering by channels */ - first= adt->nla_tracks.last; + first = adt->nla_tracks.last; } else { /* first track to include will the the first one (as per normal) */ - first= adt->nla_tracks.first; + first = adt->nla_tracks.first; } /* loop over NLA Tracks - assume that the caller of this has already checked that these should be included */ - for (nlt= first; nlt; nlt= next) { + for (nlt = first; nlt; nlt = next) { /* 'next' NLA-Track to use depends on whether we're filtering for drawing or not */ if (filter_mode & ANIMFILTER_LIST_CHANNELS) - next= nlt->prev; + next = nlt->prev; else - next= nlt->next; + next = nlt->next; /* if we're in NLA-tweakmode, don't show this track if it was disabled (due to tweaking) for now * - active track should still get shown though (even though it has disabled flag set) @@ -1212,14 +1222,14 @@ static size_t animfilter_nla (bAnimContext *UNUSED(ac), ListBase *anim_data, bDo } /* determine what animation data from AnimData block should get displayed */ -static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) +static size_t animfilter_block_data(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *id, int filter_mode) { AnimData *adt = BKE_animdata_from_id(id); size_t items = 0; /* image object datablocks have no anim-data so check for NULL */ if (adt) { - IdAdtTemplate *iat = (IdAdtTemplate*)id; + IdAdtTemplate *iat = (IdAdtTemplate *)id; /* NOTE: this macro is used instead of inlining the logic here, since this sort of filtering is still needed * in a few places in he rest of the code still - notably for the few cases where special mode-based @@ -1248,7 +1258,7 @@ static size_t animfilter_block_data (bAnimContext *ac, ListBase *anim_data, bDop /* Include ShapeKey Data for ShapeKey Editor */ -static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, Key *key, int filter_mode) +static size_t animdata_filter_shapekey(bAnimContext *ac, ListBase *anim_data, Key *key, int filter_mode) { size_t items = 0; @@ -1257,7 +1267,7 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K KeyBlock *kb; /* loop through the channels adding ShapeKeys as appropriate */ - for (kb= key->block.first; kb; kb= kb->next) { + for (kb = key->block.first; kb; kb = kb->next) { /* skip the first one, since that's the non-animatable basis */ // XXX maybe in future this may become handy? if (kb == key->block.first) continue; @@ -1265,7 +1275,7 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K /* only work with this channel and its subchannels if it is editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_SHAPEKEY(kb)) { /* only include this track if selected in a way consistent with the filtering requirements */ - if ( ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb)) ) { + if (ANIMCHANNEL_SELOK(SEL_SHAPEKEY(kb)) ) { // TODO: consider 'active' too? /* owner-id here must be key so that the F-Curve can be resolved... */ @@ -1282,7 +1292,7 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K ANIMCHANNEL_NEW_CHANNEL(key->adt, ANIMTYPE_ANIMDATA, key); } else if (key->adt->action) { - items= animfilter_action(ac, anim_data, NULL, key->adt->action, filter_mode, (ID *)key); + items = animfilter_action(ac, anim_data, NULL, key->adt->action, filter_mode, (ID *)key); } } } @@ -1291,15 +1301,15 @@ static size_t animdata_filter_shapekey (bAnimContext *ac, ListBase *anim_data, K return items; } -static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, int filter_mode) +static size_t animdata_filter_gpencil_data(ListBase *anim_data, bGPdata *gpd, int filter_mode) { bGPDlayer *gpl; size_t items = 0; /* loop over layers as the conditions are acceptable */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { /* only if selected */ - if ( ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) { + if (ANIMCHANNEL_SELOK(SEL_GPL(gpl)) ) { /* only if editable */ if (!(filter_mode & ANIMFILTER_FOREDIT) || EDITABLE_GPL(gpl)) { /* active... */ @@ -1316,7 +1326,7 @@ static size_t animdata_filter_gpencil_data (ListBase *anim_data, bGPdata *gpd, i /* Grab all Grease Pencil datablocks in file */ // TODO: should this be amalgamated with the dopesheet filtering code? -static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), int filter_mode) +static size_t animdata_filter_gpencil(ListBase *anim_data, void *UNUSED(data), int filter_mode) { bGPdata *gpd; size_t items = 0; @@ -1359,7 +1369,7 @@ static size_t animdata_filter_gpencil (ListBase *anim_data, void *UNUSED(data), /* NOTE: owner_id is scene, material, or texture block, which is the direct owner of the node tree in question */ // TODO: how to handle group nodes is still unclear... -static size_t animdata_filter_ds_nodetree (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) +static size_t animdata_filter_ds_nodetree(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, bNodeTree *ntree, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1442,11 +1452,11 @@ static size_t animdata_filter_ds_linestyle (bAnimContext *ac, ListBase *anim_dat } /* NOTE: owner_id is either material, lamp, or world block, which is the direct owner of the texture stack in question */ -static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode) +static size_t animdata_filter_ds_textures(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, ID *owner_id, int filter_mode) { MTex **mtex = NULL; - size_t items=0; - int a=0; + size_t items = 0; + int a = 0; /* get datatype specific data first */ if (owner_id == NULL) @@ -1455,22 +1465,22 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data switch (GS(owner_id->name)) { case ID_MA: { - Material *ma= (Material *)owner_id; - mtex= (MTex**)(&ma->mtex); + Material *ma = (Material *)owner_id; + mtex = (MTex **)(&ma->mtex); } - break; + break; case ID_LA: { - Lamp *la= (Lamp *)owner_id; - mtex= (MTex**)(&la->mtex); + Lamp *la = (Lamp *)owner_id; + mtex = (MTex **)(&la->mtex); } - break; + break; case ID_WO: { - World *wo= (World *)owner_id; - mtex= (MTex**)(&wo->mtex); + World *wo = (World *)owner_id; + mtex = (MTex **)(&wo->mtex); } - break; + break; default: { /* invalid/unsupported option */ @@ -1481,8 +1491,8 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data } /* firstly check that we actuallly have some textures, by gathering all textures in a temp list */ - for (a=0; a < MAX_MTEX; a++) { - Tex *tex= (mtex[a]) ? mtex[a]->tex : NULL; + for (a = 0; a < MAX_MTEX; a++) { + Tex *tex = (mtex[a]) ? mtex[a]->tex : NULL; ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1527,51 +1537,83 @@ static size_t animdata_filter_ds_textures (bAnimContext *ac, ListBase *anim_data return items; } -static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) + +static size_t animdata_filter_ds_material(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Material *ma, int filter_mode) { - size_t items=0; - int a=0; + ListBase tmp_data = {NULL, NULL}; + size_t tmp_items = 0; + size_t items = 0; - /* firstly check that we actuallly have some materials, by gathering all materials in a temp list */ - for (a=1; a <= ob->totcol; a++) { - Material *ma= give_current_material(ob, a); - ListBase tmp_data = {NULL, NULL}; - size_t tmp_items = 0; - - /* if no material returned, skip - so that we don't get weird blank entries... */ - if (ma == NULL) continue; - - /* add material's animation data to temp collection */ - BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) - { - /* material's animation data */ - tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); - - /* textures */ - if (!(ads->filterflag & ADS_FILTER_NOTEX)) - tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); - - /* nodes */ - if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) - tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); - } - END_ANIMFILTER_SUBCHANNELS; - - /* did we find anything? */ - if (tmp_items) { - /* include material-expand widget first */ - // hmm... do we need to store the index of this material in the array anywhere? - if (filter_mode & ANIMFILTER_LIST_CHANNELS) { - /* check if filtering by active status */ - if (ANIMCHANNEL_ACTIVEOK(ma)) { - ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); - } - } + /* add material's animation data to temp collection */ + BEGIN_ANIMFILTER_SUBCHANNELS(FILTER_MAT_OBJD(ma)) + { + /* material's animation data */ + tmp_items += animfilter_block_data(ac, &tmp_data, ads, (ID *)ma, filter_mode); - /* now add the list of collected channels */ - BLI_movelisttolist(anim_data, &tmp_data); - BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); - items += tmp_items; + /* textures */ + if (!(ads->filterflag & ADS_FILTER_NOTEX)) + tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, (ID *)ma, filter_mode); + + /* nodes */ + if ((ma->nodetree) && !(ads->filterflag & ADS_FILTER_NONTREE)) + tmp_items += animdata_filter_ds_nodetree(ac, &tmp_data, ads, (ID *)ma, ma->nodetree, filter_mode); + } + END_ANIMFILTER_SUBCHANNELS; + + /* did we find anything? */ + if (tmp_items) { + /* include material-expand widget first */ + // hmm... do we need to store the index of this material in the array anywhere? + if (filter_mode & ANIMFILTER_LIST_CHANNELS) { + /* check if filtering by active status */ + if (ANIMCHANNEL_ACTIVEOK(ma)) { + ANIMCHANNEL_NEW_CHANNEL(ma, ANIMTYPE_DSMAT, ma); + } + } + + /* now add the list of collected channels */ + BLI_movelisttolist(anim_data, &tmp_data); + BLI_assert((tmp_data.first == tmp_data.last) && (tmp_data.first == NULL)); + items += tmp_items; + } + + return items; +} + +static size_t animdata_filter_ds_materials(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +{ + short has_nested = 0; + size_t items = 0; + int a = 0; + + /* first pass: take the materials referenced via the Material slots of the object */ + for (a = 1; a <= ob->totcol; a++) { + Material *ma = give_current_material(ob, a); + + /* if material is valid, try to add relevant contents from here */ + if (ma) { + /* add channels */ + items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); + + /* for optimising second pass - check if there's a nested material here to come back for */ + if (has_nested == 0) + has_nested = give_node_material(ma) != NULL; + } + } + + /* second pass: go through a second time looking for "nested" materials (material.material references) + * + * NOTE: here we ignore the expanded status of the parent, as it could be too confusing as to why these are + * disappearing/not available, since the relationships between these is not that clear + */ + if (has_nested) { + for (a = 1; a <= ob->totcol; a++) { + Material *base = give_current_material(ob, a); + Material *ma = give_node_material(base); + + /* add channels from the nested material if it exists */ + if (ma) + items += animdata_filter_ds_material(ac, anim_data, ads, ma, filter_mode); } } @@ -1579,12 +1621,12 @@ static size_t animdata_filter_ds_materials (bAnimContext *ac, ListBase *anim_dat return items; } -static size_t animdata_filter_ds_particles (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +static size_t animdata_filter_ds_particles(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { ParticleSystem *psys; - size_t items= 0; + size_t items = 0; - for (psys = ob->particlesystem.first; psys; psys=psys->next) { + for (psys = ob->particlesystem.first; psys; psys = psys->next) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1621,85 +1663,85 @@ static size_t animdata_filter_ds_particles (bAnimContext *ac, ListBase *anim_dat return items; } -static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +static size_t animdata_filter_ds_obdata(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; - size_t items= 0; + size_t items = 0; - IdAdtTemplate *iat= ob->data; - short type=0, expanded=0; + IdAdtTemplate *iat = ob->data; + short type = 0, expanded = 0; /* get settings based on data type */ switch (ob->type) { case OB_CAMERA: /* ------- Camera ------------ */ { - Camera *ca= (Camera *)ob->data; + Camera *ca = (Camera *)ob->data; if (ads->filterflag & ADS_FILTER_NOCAM) return 0; - type= ANIMTYPE_DSCAM; - expanded= FILTER_CAM_OBJD(ca); + type = ANIMTYPE_DSCAM; + expanded = FILTER_CAM_OBJD(ca); } - break; + break; case OB_LAMP: /* ---------- Lamp ----------- */ { - Lamp *la= (Lamp *)ob->data; + Lamp *la = (Lamp *)ob->data; if (ads->filterflag & ADS_FILTER_NOLAM) return 0; - type= ANIMTYPE_DSLAM; - expanded= FILTER_LAM_OBJD(la); + type = ANIMTYPE_DSLAM; + expanded = FILTER_LAM_OBJD(la); } - break; + break; case OB_CURVE: /* ------- Curve ---------- */ case OB_SURF: /* ------- Nurbs Surface ---------- */ case OB_FONT: /* ------- Text Curve ---------- */ { - Curve *cu= (Curve *)ob->data; + Curve *cu = (Curve *)ob->data; if (ads->filterflag & ADS_FILTER_NOCUR) return 0; - type= ANIMTYPE_DSCUR; - expanded= FILTER_CUR_OBJD(cu); + type = ANIMTYPE_DSCUR; + expanded = FILTER_CUR_OBJD(cu); } - break; + break; case OB_MBALL: /* ------- MetaBall ---------- */ { - MetaBall *mb= (MetaBall *)ob->data; + MetaBall *mb = (MetaBall *)ob->data; if (ads->filterflag & ADS_FILTER_NOMBA) return 0; - type= ANIMTYPE_DSMBALL; - expanded= FILTER_MBALL_OBJD(mb); + type = ANIMTYPE_DSMBALL; + expanded = FILTER_MBALL_OBJD(mb); } - break; + break; case OB_ARMATURE: /* ------- Armature ---------- */ { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; if (ads->filterflag & ADS_FILTER_NOARM) return 0; - type= ANIMTYPE_DSARM; - expanded= FILTER_ARM_OBJD(arm); + type = ANIMTYPE_DSARM; + expanded = FILTER_ARM_OBJD(arm); } - break; + break; case OB_MESH: /* ------- Mesh ---------- */ { - Mesh *me= (Mesh *)ob->data; + Mesh *me = (Mesh *)ob->data; if (ads->filterflag & ADS_FILTER_NOMESH) return 0; - type= ANIMTYPE_DSMESH; - expanded= FILTER_MESH_OBJD(me); + type = ANIMTYPE_DSMESH; + expanded = FILTER_MESH_OBJD(me); } - break; + break; case OB_LATTICE: /* ---- Lattice ---- */ { Lattice *lt = (Lattice *)ob->data; @@ -1707,18 +1749,18 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, if (ads->filterflag & ADS_FILTER_NOLAT) return 0; - type= ANIMTYPE_DSLAT; - expanded= FILTER_LATTICE_OBJD(lt); + type = ANIMTYPE_DSLAT; + expanded = FILTER_LATTICE_OBJD(lt); } - break; + break; case OB_SPEAKER: /* ---------- Speaker ----------- */ { - Speaker *spk= (Speaker *)ob->data; + Speaker *spk = (Speaker *)ob->data; - type= ANIMTYPE_DSSPK; - expanded= FILTER_SPK_OBJD(spk); + type = ANIMTYPE_DSSPK; + expanded = FILTER_SPK_OBJD(spk); } - break; + break; } /* add object data animation channels */ @@ -1729,13 +1771,13 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, /* sub-data filtering... */ switch (ob->type) { - case OB_LAMP: /* lamp - textures */ + case OB_LAMP: /* lamp - textures */ { /* textures */ if (!(ads->filterflag & ADS_FILTER_NOTEX)) tmp_items += animdata_filter_ds_textures(ac, &tmp_data, ads, ob->data, filter_mode); } - break; + break; } } END_ANIMFILTER_SUBCHANNELS; @@ -1761,7 +1803,7 @@ static size_t animdata_filter_ds_obdata (bAnimContext *ac, ListBase *anim_data, } /* shapekey-level animation */ -static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode) +static size_t animdata_filter_ds_keyanim(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, Key *key, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1795,27 +1837,27 @@ static size_t animdata_filter_ds_keyanim (bAnimContext *ac, ListBase *anim_data, } /* object-level animation */ -static size_t animdata_filter_ds_obanim (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) +static size_t animdata_filter_ds_obanim(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Object *ob, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; AnimData *adt = ob->adt; - short type=0, expanded=1; + short type = 0, expanded = 1; void *cdata = NULL; /* determine the type of expander channels to use */ // this is the best way to do this for now... ANIMDATA_FILTER_CASES(ob, - {/* AnimData - no channel, but consider data */}, - {/* NLA - no channel, but consider data */}, - {/* Drivers */ + { /* AnimData - no channel, but consider data */ }, + { /* NLA - no channel, but consider data */ }, + { /* Drivers */ type = ANIMTYPE_FILLDRIVERS; cdata = adt; expanded = EXPANDED_DRVD(adt); }, - {/* Keyframes */ + { /* Keyframes */ type = ANIMTYPE_FILLACTD; cdata = adt->action; expanded = EXPANDED_ACTC(adt->action); @@ -1850,17 +1892,17 @@ static size_t animdata_filter_ds_obanim (bAnimContext *ac, ListBase *anim_data, } /* get animation channels from object2 */ -static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode) +static size_t animdata_filter_dopesheet_ob(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Base *base, int filter_mode) { ListBase tmp_data = {NULL, NULL}; - Object *ob= base->object; + Object *ob = base->object; size_t tmp_items = 0; size_t items = 0; /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_OBJC(ob)) { - Key *key= ob_get_key(ob); + Key *key = ob_get_key(ob); /* object-level animation */ if ((ob->adt) && !(ads->filterflag & ADS_FILTER_NOOBJ)) { @@ -1914,7 +1956,7 @@ static size_t animdata_filter_dopesheet_ob (bAnimContext *ac, ListBase *anim_dat return items; } -static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode) +static size_t animdata_filter_ds_world(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, World *wo, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -1956,27 +1998,27 @@ static size_t animdata_filter_ds_world (bAnimContext *ac, ListBase *anim_data, b return items; } -static size_t animdata_filter_ds_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) +static size_t animdata_filter_ds_scene(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; size_t items = 0; AnimData *adt = sce->adt; - short type=0, expanded=1; + short type = 0, expanded = 1; void *cdata = NULL; /* determine the type of expander channels to use */ // this is the best way to do this for now... ANIMDATA_FILTER_CASES(sce, - {/* AnimData - no channel, but consider data */}, - {/* NLA - no channel, but consider data */}, - {/* Drivers */ + { /* AnimData - no channel, but consider data */}, + { /* NLA - no channel, but consider data */}, + { /* Drivers */ type = ANIMTYPE_FILLDRIVERS; cdata = adt; expanded = EXPANDED_DRVD(adt); }, - {/* Keyframes */ + { /* Keyframes */ type = ANIMTYPE_FILLACTD; cdata = adt->action; expanded = EXPANDED_ACTC(adt->action); @@ -2010,7 +2052,7 @@ static size_t animdata_filter_ds_scene (bAnimContext *ac, ListBase *anim_data, b return items; } -static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) +static size_t animdata_filter_dopesheet_scene(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, Scene *sce, int filter_mode) { ListBase tmp_data = {NULL, NULL}; size_t tmp_items = 0; @@ -2019,8 +2061,8 @@ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_ /* filter data contained under object first */ BEGIN_ANIMFILTER_SUBCHANNELS(EXPANDED_SCEC(sce)) { - bNodeTree *ntree= sce->nodetree; - World *wo= sce->world; + bNodeTree *ntree = sce->nodetree; + World *wo = sce->world; /* Action, Drivers, or NLA for Scene */ if ((ads->filterflag & ADS_FILTER_NOSCE) == 0) { @@ -2068,17 +2110,17 @@ static size_t animdata_filter_dopesheet_scene (bAnimContext *ac, ListBase *anim_ } // TODO: implement pinning... (if and when pinning is done, what we need to do is to provide freeing mechanisms - to protect against data that was deleted) -static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode) +static size_t animdata_filter_dopesheet(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, int filter_mode) { - Scene *sce= (Scene *)ads->source; + Scene *sce = (Scene *)ads->source; Base *base; size_t items = 0; /* check that we do indeed have a scene */ - if ((ads->source == NULL) || (GS(ads->source->name)!=ID_SCE)) { + if ((ads->source == NULL) || (GS(ads->source->name) != ID_SCE)) { printf("DopeSheet Error: Not scene!\n"); if (G.debug & G_DEBUG) - printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source)?ads->source->name:NULL); + printf("\tPointer = %p, Name = '%s'\n", (void *)ads->source, (ads->source) ? ads->source->name : NULL); return 0; } @@ -2094,10 +2136,10 @@ static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, items += animdata_filter_dopesheet_scene(ac, anim_data, ads, sce, filter_mode); /* loop over all bases (i.e.objects) in the scene */ - for (base= sce->base.first; base; base= base->next) { + for (base = sce->base.first; base; base = base->next) { /* check if there's an object (all the relevant checks are done in the ob-function) */ if (base->object) { - Object *ob= base->object; + Object *ob = base->object; /* firstly, check if object can be included, by the following factors: * - if only visible, must check for layer and also viewport visibility @@ -2110,7 +2152,7 @@ static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, */ if ((filter_mode & ANIMFILTER_DATA_VISIBLE) && !(ads->filterflag & ADS_FILTER_INCL_HIDDEN)) { /* layer visibility - we check both object and base, since these may not be in sync yet */ - if ((sce->lay & (ob->lay|base->lay))==0) continue; + if ((sce->lay & (ob->lay | base->lay)) == 0) continue; /* outliner restrict-flag */ if (ob->restrictflag & OB_RESTRICT_VIEW) continue; @@ -2149,9 +2191,9 @@ static size_t animdata_filter_dopesheet (bAnimContext *ac, ListBase *anim_data, } /* Summary track for DopeSheet/Action Editor - * - return code is whether the summary lets the other channels get drawn + * - return code is whether the summary lets the other channels get drawn */ -static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items) +static short animdata_filter_dopesheet_summary(bAnimContext *ac, ListBase *anim_data, int filter_mode, size_t *items) { bDopeSheet *ads = NULL; @@ -2161,8 +2203,8 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim * being applicable. */ if ((ac && ac->sl) && (ac->spacetype == SPACE_ACTION)) { - SpaceAction *saction= (SpaceAction *)ac->sl; - ads= &saction->ads; + SpaceAction *saction = (SpaceAction *)ac->sl; + ads = &saction->ads; } else { /* invalid space type - skip this summary channels */ @@ -2174,7 +2216,7 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim * - only useful for DopeSheet/Action/etc. editors where it is actually useful */ if ((filter_mode & ANIMFILTER_LIST_CHANNELS) && (ads->filterflag & ADS_FILTER_SUMMARY)) { - bAnimListElem *ale= make_new_animlistelem(ac, ANIMTYPE_SUMMARY, NULL); + bAnimListElem *ale = make_new_animlistelem(ac, ANIMTYPE_SUMMARY, NULL); if (ale) { BLI_addtail(anim_data, ale); (*items)++; @@ -2194,7 +2236,7 @@ static short animdata_filter_dopesheet_summary (bAnimContext *ac, ListBase *anim /* ......................... */ /* filter data associated with a channel - usually for handling summary-channels in DopeSheet */ -static size_t animdata_filter_animchan (bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode) +static size_t animdata_filter_animchan(bAnimContext *ac, ListBase *anim_data, bDopeSheet *ads, bAnimListElem *channel, int filter_mode) { size_t items = 0; @@ -2220,14 +2262,14 @@ static size_t animdata_filter_animchan (bAnimContext *ac, ListBase *anim_data, b /* ----------- Cleanup API --------------- */ /* Remove entries with invalid types in animation channel list */ -static size_t animdata_filter_remove_invalid (ListBase *anim_data) +static size_t animdata_filter_remove_invalid(ListBase *anim_data) { bAnimListElem *ale, *next; size_t items = 0; /* only keep entries with valid types */ - for (ale= anim_data->first; ale; ale= next) { - next= ale->next; + for (ale = anim_data->first; ale; ale = next) { + next = ale->next; if (ale->type == ANIMTYPE_NONE) BLI_freelinkN(anim_data, ale); @@ -2239,7 +2281,7 @@ static size_t animdata_filter_remove_invalid (ListBase *anim_data) } /* Remove duplicate entries in animation channel list */ -static size_t animdata_filter_remove_duplis (ListBase *anim_data) +static size_t animdata_filter_remove_duplis(ListBase *anim_data) { bAnimListElem *ale, *next; GHash *gh; @@ -2248,7 +2290,7 @@ static size_t animdata_filter_remove_duplis (ListBase *anim_data) /* build new hashtable to efficiently store and retrieve which entries have been * encountered already while searching */ - gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "animdata_filter_duplis_remove gh"); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "animdata_filter_duplis_remove gh"); /* loop through items, removing them from the list if a similar item occurs already */ for (ale = anim_data->first; ale; ale = next) { @@ -2281,7 +2323,7 @@ static size_t animdata_filter_remove_duplis (ListBase *anim_data) /* This function filters the active data source to leave only animation channels suitable for * usage by the caller. It will return the length of the list * - * *anim_data: is a pointer to a ListBase, to which the filtered animation channels + * *anim_data: is a pointer to a ListBase, to which the filtered animation channels * will be placed for use. * filter_mode: how should the data be filtered - bitmapping accessed flags */ @@ -2294,31 +2336,31 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* firstly filter the data */ switch (datatype) { - case ANIMCONT_ACTION: /* 'Action Editor' */ + case ANIMCONT_ACTION: /* 'Action Editor' */ { - Object *obact= ac->obact; + Object *obact = ac->obact; SpaceAction *saction = (SpaceAction *)ac->sl; - bDopeSheet *ads = (saction)? &saction->ads : NULL; + bDopeSheet *ads = (saction) ? &saction->ads : NULL; /* the check for the DopeSheet summary is included here since the summary works here too */ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) items += animfilter_action(ac, anim_data, ads, data, filter_mode, (ID *)obact); } - break; + break; case ANIMCONT_SHAPEKEY: /* 'ShapeKey Editor' */ { /* the check for the DopeSheet summary is included here since the summary works here too */ if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) - items= animdata_filter_shapekey(ac, anim_data, data, filter_mode); + items = animdata_filter_shapekey(ac, anim_data, data, filter_mode); } - break; + break; case ANIMCONT_GPENCIL: { - items= animdata_filter_gpencil(anim_data, data, filter_mode); + items = animdata_filter_gpencil(anim_data, data, filter_mode); } - break; + break; case ANIMCONT_DOPESHEET: /* 'DopeSheet Editor' */ { @@ -2326,7 +2368,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo if (animdata_filter_dopesheet_summary(ac, anim_data, filter_mode, &items)) items += animdata_filter_dopesheet(ac, anim_data, data, filter_mode); } - break; + break; case ANIMCONT_FCURVES: /* Graph Editor -> FCurves/Animation Editing */ case ANIMCONT_DRIVERS: /* Graph Editor -> Drivers Editing */ @@ -2335,7 +2377,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* all of these editors use the basic DopeSheet data for filtering options, but don't have all the same features */ items = animdata_filter_dopesheet(ac, anim_data, data, filter_mode); } - break; + break; case ANIMCONT_CHANNEL: /* animation channel */ { @@ -2344,7 +2386,7 @@ size_t ANIM_animdata_filter(bAnimContext *ac, ListBase *anim_data, int filter_mo /* based on the channel type, filter relevant data for this */ items = animdata_filter_animchan(ac, anim_data, ads, data, filter_mode); } - break; + break; } /* remove any 'weedy' entries */ diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h index bfc70c79404..7d1209a3033 100644 --- a/source/blender/editors/animation/anim_intern.h +++ b/source/blender/editors/animation/anim_intern.h @@ -40,14 +40,14 @@ extern ListBase builtin_keyingsets; /* Main Keyframe Management operators: * These handle keyframes management from various spaces. They only make use of - * Keying Sets. + * Keying Sets. */ void ANIM_OT_keyframe_insert(struct wmOperatorType *ot); void ANIM_OT_keyframe_delete(struct wmOperatorType *ot); /* Main Keyframe Management operators: * These handle keyframes management from various spaces. They will handle the menus - * required for each space. + * required for each space. */ void ANIM_OT_keyframe_insert_menu(struct wmOperatorType *ot); void ANIM_OT_keyframe_delete_v3d(struct wmOperatorType *ot); diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 4be3f79060e..593010fae09 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -78,9 +78,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* try to resolve the path */ if (RNA_path_resolve(&id_ptr, fcu->rna_path, &ptr, &prop)) { - const char *structname=NULL, *propname=NULL; + const char *structname = NULL, *propname = NULL; char arrayindbuf[16]; - const char *arrayname=NULL; + const char *arrayname = NULL; short free_structname = 0; /* For now, name will consist of 3 parts: struct-name, property name, array index @@ -104,44 +104,44 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) */ if (strstr(fcu->rna_path, "bones") && strstr(fcu->rna_path, "constraints")) { /* perform string 'chopping' to get "Bone Name : Constraint Name" */ - char *pchanName= BLI_getQuotedStr(fcu->rna_path, "bones["); - char *constName= BLI_getQuotedStr(fcu->rna_path, "constraints["); + char *pchanName = BLI_getQuotedStr(fcu->rna_path, "bones["); + char *constName = BLI_getQuotedStr(fcu->rna_path, "constraints["); /* assemble the string to display in the UI... */ - structname= BLI_sprintfN("%s : %s", pchanName, constName); - free_structname= 1; + structname = BLI_sprintfN("%s : %s", pchanName, constName); + free_structname = 1; /* free the temp names */ if (pchanName) MEM_freeN(pchanName); if (constName) MEM_freeN(constName); } else if (ptr.data != ptr.id.data) { - PropertyRNA *nameprop= RNA_struct_name_property(ptr.type); + PropertyRNA *nameprop = RNA_struct_name_property(ptr.type); if (nameprop) { /* this gets a string which will need to be freed */ - structname= RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL); - free_structname= 1; + structname = RNA_property_string_get_alloc(&ptr, nameprop, NULL, 0, NULL); + free_structname = 1; } else - structname= RNA_struct_ui_name(ptr.type); + structname = RNA_struct_ui_name(ptr.type); } /* Property Name is straightforward */ - propname= RNA_property_ui_name(prop); + propname = RNA_property_ui_name(prop); /* Array Index - only if applicable */ if (RNA_property_array_length(&ptr, prop)) { - char c= RNA_property_array_item_char(prop, fcu->array_index); + char c = RNA_property_array_item_char(prop, fcu->array_index); /* we need to write the index to a temp buffer (in py syntax) */ if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c); else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index); - arrayname= &arrayindbuf[0]; + arrayname = &arrayindbuf[0]; } else { /* no array index */ - arrayname= ""; + arrayname = ""; } /* putting this all together into the buffer */ @@ -160,7 +160,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* Icon for this property's owner: * use the struct's icon if it is set */ - icon= RNA_struct_ui_icon(ptr.type); + icon = RNA_struct_ui_icon(ptr.type); /* valid path - remove the invalid tag since we now know how to use it saving * users manual effort to reenable using "Revive Disabled FCurves" [#29629] @@ -173,7 +173,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* icon for this should be the icon for the base ID */ // TODO: or should we just use the error icon? - icon= RNA_struct_ui_icon(id_ptr.type); + icon = RNA_struct_ui_icon(id_ptr.type); /* tag F-Curve as disabled - as not usable path */ fcu->flag |= FCURVE_DISABLED; @@ -187,7 +187,7 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* ------------------------------- Color Codes for F-Curve Channels ---------------------------- */ /* step between the major distinguishable color bands of the primary colors */ -#define HSV_BANDWIDTH 0.3f +#define HSV_BANDWIDTH 0.3f /* used to determine the color of F-Curves with FCURVE_COLOR_AUTO_RAINBOW set */ //void fcurve_rainbow (unsigned int cur, unsigned int tot, float *out) @@ -202,8 +202,8 @@ void getcolor_fcurve_rainbow(int cur, int tot, float *out) * 4 - for 'even' numbers of curves - there should be a majority of quartets of curves * so the base color is simply one of the three primary colors */ - grouping= (4 - (tot % 2)); - hue= HSV_BANDWIDTH * (float)(cur % grouping); + grouping = (4 - (tot % 2)); + hue = HSV_BANDWIDTH * (float)(cur % grouping); /* 'Value' (i.e. darkness) needs to vary so that larger sets of three will be * 'darker' (i.e. smaller value), so that they don't look that similar to previous ones. @@ -214,15 +214,15 @@ void getcolor_fcurve_rainbow(int cur, int tot, float *out) /* the base color can get offset a bit so that the colors aren't so identical */ hue += fac * HSV_BANDWIDTH; - if (hue > 1.0f) hue= fmod(hue, 1.0f); + if (hue > 1.0f) hue = fmod(hue, 1.0f); /* saturation adjustments for more visible range */ - if ((hue > 0.5f) && (hue < 0.8f)) sat= 0.5f; - else sat= 0.6f; + if ((hue > 0.5f) && (hue < 0.8f)) sat = 0.5f; + else sat = 0.6f; /* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */ - val= 1.0f; + val = 1.0f; /* finally, conver this to RGB colors */ - hsv_to_rgb(hue, sat, val, out, out+1, out+2); + hsv_to_rgb(hue, sat, val, out, out + 1, out + 2); } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2527cb7eb40..ea344e7e332 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -81,7 +81,7 @@ static ListBase *context_get_markers(Scene *scene, ScrArea *sa) SpaceAction *saction = (SpaceAction *)sa->spacedata.first; /* local markers can only be shown when there's only a single active action to grab them from - * - flag only takes effect when there's an action, otherwise it can get too confusing? + * - flag only takes effect when there's an action, otherwise it can get too confusing? */ if (ELEM(saction->mode, SACTCONT_ACTION, SACTCONT_SHAPEKEY) && (saction->action)) { if (saction->flag & SACTION_POSEMARKERS_SHOW) { @@ -139,23 +139,23 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f case TFM_TIME_EXTEND: { /* apply delta if marker is on the right side of the current frame */ - if ((side=='B') || - (side=='L' && marker->frame < cfra) || - (side=='R' && marker->frame >= cfra)) + if ((side == 'B') || + (side == 'L' && marker->frame < cfra) || + (side == 'R' && marker->frame >= cfra)) { marker->frame += (int)floorf(value + 0.5f); changed++; } } - break; + break; case TFM_TIME_SCALE: { /* rescale the distance between the marker and the current frame */ - marker->frame= cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); + marker->frame = cfra + (int)floorf(((float)(marker->frame - cfra) * value) + 0.5f); changed++; } - break; + break; } } } @@ -167,18 +167,18 @@ int ED_markers_post_apply_transform(ListBase *markers, Scene *scene, int mode, f /* Get the marker that is closest to this point */ /* XXX for select, the min_dist should be small */ -TimeMarker *ED_markers_find_nearest_marker (ListBase *markers, float x) +TimeMarker *ED_markers_find_nearest_marker(ListBase *markers, float x) { - TimeMarker *marker, *nearest=NULL; - float dist, min_dist= 1000000; + TimeMarker *marker, *nearest = NULL; + float dist, min_dist = 1000000; if (markers) { - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { dist = ABS((float)marker->frame - x); if (dist < min_dist) { - min_dist= dist; - nearest= marker; + min_dist = dist; + nearest = marker; } } } @@ -189,7 +189,7 @@ TimeMarker *ED_markers_find_nearest_marker (ListBase *markers, float x) /* Return the time of the marker that occurs on a frame closest to the given time */ int ED_markers_find_nearest_marker_time(ListBase *markers, float x) { - TimeMarker *nearest= ED_markers_find_nearest_marker(markers, x); + TimeMarker *nearest = ED_markers_find_nearest_marker(markers, x); return (nearest) ? (nearest->frame) : (int)floor(x + 0.5f); } @@ -209,11 +209,11 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la } if (markers->first && markers->last) { - TimeMarker *fm= markers->first; - TimeMarker *lm= markers->last; + TimeMarker *fm = markers->first; + TimeMarker *lm = markers->last; - min= (float)fm->frame; - max= (float)lm->frame; + min = (float)fm->frame; + max = (float)lm->frame; } else { *first = 0.0f; @@ -223,39 +223,39 @@ void ED_markers_get_minmax(ListBase *markers, short sel, float *first, float *la /* count how many markers are usable - see later */ if (sel) { - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) selcount++; } } else - selcount= BLI_countlist(markers); + selcount = BLI_countlist(markers); /* if only selected are to be considered, only consider the selected ones * (optimization for not searching list) */ if (selcount > 1) { - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (sel) { if (marker->flag & SELECT) { if (marker->frame < min) - min= (float)marker->frame; + min = (float)marker->frame; if (marker->frame > max) - max= (float)marker->frame; + max = (float)marker->frame; } } else { if (marker->frame < min) - min= (float)marker->frame; + min = (float)marker->frame; if (marker->frame > max) - max= (float)marker->frame; + max = (float)marker->frame; } } } /* set the min/max values */ - *first= min; - *last= max; + *first = min; + *last = max; } /* --------------------------------- */ @@ -266,26 +266,26 @@ static void add_marker_to_cfra_elem(ListBase *lb, TimeMarker *marker, short only CfraElem *ce, *cen; /* should this one only be considered if it is selected? */ - if ((only_sel) && ((marker->flag & SELECT)==0)) + if ((only_sel) && ((marker->flag & SELECT) == 0)) return; /* insertion sort - try to find a previous cfra elem */ - for (ce= lb->first; ce; ce= ce->next) { + for (ce = lb->first; ce; ce = ce->next) { if (ce->cfra == marker->frame) { /* do because of double keys */ if (marker->flag & SELECT) - ce->sel= marker->flag; + ce->sel = marker->flag; return; } else if (ce->cfra > marker->frame) break; } - cen= MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); + cen = MEM_callocN(sizeof(CfraElem), "add_to_cfra_elem"); if (ce) BLI_insertlinkbefore(lb, ce, cen); else BLI_addtail(lb, cen); - cen->cfra= marker->frame; - cen->sel= marker->flag; + cen->cfra = marker->frame; + cen->sel = marker->flag; } /* This function makes a list of all the markers. The only_sel @@ -299,7 +299,7 @@ void ED_markers_make_cfra_list(ListBase *markers, ListBase *lb, short only_sel) if (markers == NULL) return; - for (marker= markers->first; marker; marker= marker->next) + for (marker = markers->first; marker; marker = marker->next) add_marker_to_cfra_elem(lb, marker, only_sel); } @@ -349,15 +349,15 @@ void debug_markers_print_list(ListBase *markers) static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) { float xpos, ypixels, xscale, yscale; - int icon_id= 0; + int icon_id = 0; xpos = marker->frame; /* no time correction for framelen! space is drawn with old values */ - ypixels= v2d->mask.ymax-v2d->mask.ymin; + ypixels = v2d->mask.ymax - v2d->mask.ymin; UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -377,8 +377,8 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) glColor4ub(0, 0, 0, 96); glBegin(GL_LINES); - glVertex2f((xpos*xscale)+0.5f, 12.0f); - glVertex2f((xpos*xscale)+0.5f, (v2d->cur.ymax+12.0f)*yscale); + glVertex2f((xpos * xscale) + 0.5f, 12.0f); + glVertex2f((xpos * xscale) + 0.5f, (v2d->cur.ymax + 12.0f) * yscale); glEnd(); setlinestyle(0); @@ -386,16 +386,16 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* 5 px to offset icon to align properly, space / pixels corrects for zoom */ if (flag & DRAW_MARKERS_LOCAL) { - icon_id= (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : - (marker->flag & SELECT) ? ICON_PMARKER_SEL : - ICON_PMARKER; + icon_id = (marker->flag & ACTIVE) ? ICON_PMARKER_ACT : + (marker->flag & SELECT) ? ICON_PMARKER_SEL : + ICON_PMARKER; } else { - icon_id= (marker->flag & SELECT) ? ICON_MARKER_HLT : - ICON_MARKER; + icon_id = (marker->flag & SELECT) ? ICON_MARKER_HLT : + ICON_MARKER; } - UI_icon_draw(xpos*xscale-5.0f, 16.0f, icon_id); + UI_icon_draw(xpos * xscale - 5.0f, 16.0f, icon_id); glDisable(GL_BLEND); @@ -405,18 +405,18 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) if (marker->flag & SELECT) { UI_ThemeColor(TH_TEXT_HI); - x= xpos*xscale + 4.0f; - y= (ypixels <= 39.0f)? (ypixels-10.0f) : 29.0f; + x = xpos * xscale + 4.0f; + y = (ypixels <= 39.0f) ? (ypixels - 10.0f) : 29.0f; } else { UI_ThemeColor(TH_TEXT); - if ((marker->frame <= cfra) && (marker->frame+5 > cfra)) { - x= xpos*xscale + 4.0f; - y= (ypixels <= 39.0f)? (ypixels - 10.0f) : 29.0f; + if ((marker->frame <= cfra) && (marker->frame + 5 > cfra)) { + x = xpos * xscale + 4.0f; + y = (ypixels <= 39.0f) ? (ypixels - 10.0f) : 29.0f; } else { - x= xpos*xscale + 4.0f; - y= 17.0f; + x = xpos * xscale + 4.0f; + y = 17.0f; } } @@ -424,7 +424,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) if (marker->camera && (marker->camera->restrictflag & OB_RESTRICT_RENDER)) { float col[4]; glGetFloatv(GL_CURRENT_COLOR, col); - col[3]= 0.4; + col[3] = 0.4; glColor4fv(col); } #endif @@ -438,7 +438,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag) /* Draw Scene-Markers in time window */ void draw_markers_time(const bContext *C, int flag) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); View2D *v2d; TimeMarker *marker; Scene *scene; @@ -450,14 +450,14 @@ void draw_markers_time(const bContext *C, int flag) v2d = UI_view2d_fromcontext(C); /* unselected markers are drawn at the first time */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if ((marker->flag & SELECT) == 0) { draw_marker(v2d, marker, scene->r.cfra, flag); } } /* selected markers are drawn later */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { draw_marker(v2d, marker, scene->r.cfra, flag); } @@ -549,32 +549,32 @@ static int ed_markers_opwrap_invoke(bContext *C, wmOperator *op, wmEvent *evt) /* add TimeMarker at curent frame */ static int ed_marker_add(bContext *C, wmOperator *UNUSED(op)) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; - int frame= CTX_data_scene(C)->r.cfra; + int frame = CTX_data_scene(C)->r.cfra; if (markers == NULL) return OPERATOR_CANCELLED; /* prefer not having 2 markers at the same place, * though the user can move them to overlap once added */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->frame == frame) return OPERATOR_CANCELLED; } /* deselect all */ - for (marker= markers->first; marker; marker= marker->next) + for (marker = markers->first; marker; marker = marker->next) marker->flag &= ~SELECT; marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); - marker->flag= SELECT; - marker->frame= frame; + marker->flag = SELECT; + marker->frame = frame; BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); // XXX - temp code only BLI_addtail(markers, marker); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -592,7 +592,7 @@ static void MARKER_OT_add(wmOperatorType *ot) ot->poll = ED_operator_animview_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** transform markers *************************** */ @@ -623,7 +623,7 @@ static void MARKER_OT_add(wmOperatorType *ot) typedef struct MarkerMove { SpaceLink *slink; ListBase *markers; - int event_type; /* store invoke-event, to verify */ + int event_type; /* store invoke-event, to verify */ int *oldframe, evtx, firstx; NumInput num; } MarkerMove; @@ -632,32 +632,32 @@ typedef struct MarkerMove { /* return 0 if not OK */ static int ed_marker_move_init(bContext *C, wmOperator *op) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); MarkerMove *mm; TimeMarker *marker; - int totmark=0; + int totmark = 0; int a; if (markers == NULL) return 0; - for (marker= markers->first; marker; marker= marker->next) + for (marker = markers->first; marker; marker = marker->next) if (marker->flag & SELECT) totmark++; - if (totmark==0) return 0; + if (totmark == 0) return 0; - op->customdata= mm= MEM_callocN(sizeof(MarkerMove), "Markermove"); - mm->slink= CTX_wm_space_data(C); - mm->markers= markers; - mm->oldframe= MEM_callocN(totmark*sizeof(int), "MarkerMove oldframe"); + op->customdata = mm = MEM_callocN(sizeof(MarkerMove), "Markermove"); + mm->slink = CTX_wm_space_data(C); + mm->markers = markers; + mm->oldframe = MEM_callocN(totmark * sizeof(int), "MarkerMove oldframe"); initNumInput(&mm->num); mm->num.idx_max = 0; /* one axis */ mm->num.flag |= NUM_NO_FRACTION; mm->num.increment = 1.0f; - for (a=0, marker= markers->first; marker; marker= marker->next) { + for (a = 0, marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - mm->oldframe[a]= marker->frame; + mm->oldframe[a] = marker->frame; a++; } } @@ -668,12 +668,12 @@ static int ed_marker_move_init(bContext *C, wmOperator *op) /* free stuff */ static void ed_marker_move_exit(bContext *C, wmOperator *op) { - MarkerMove *mm= op->customdata; + MarkerMove *mm = op->customdata; /* free data */ MEM_freeN(mm->oldframe); MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; /* clear custom header prints */ ED_area_headerprint(CTX_wm_area(C), NULL); @@ -682,11 +682,11 @@ static void ed_marker_move_exit(bContext *C, wmOperator *op) static int ed_marker_move_invoke(bContext *C, wmOperator *op, wmEvent *evt) { if (ed_marker_move_init(C, op)) { - MarkerMove *mm= op->customdata; + MarkerMove *mm = op->customdata; - mm->evtx= evt->x; - mm->firstx= evt->x; - mm->event_type= evt->type; + mm->evtx = evt->x; + mm->firstx = evt->x; + mm->event_type = evt->type; /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -708,14 +708,14 @@ static int ed_marker_move_invoke_wrapper(bContext *C, wmOperator *op, wmEvent *e /* note, init has to be called succesfully */ static void ed_marker_move_apply(wmOperator *op) { - MarkerMove *mm= op->customdata; + MarkerMove *mm = op->customdata; TimeMarker *marker; int a, offs; - offs= RNA_int_get(op->ptr, "frames"); - for (a=0, marker= mm->markers->first; marker; marker= marker->next) { + offs = RNA_int_get(op->ptr, "frames"); + for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - marker->frame= mm->oldframe[a] + offs; + marker->frame = mm->oldframe[a] + offs; a++; } } @@ -728,8 +728,8 @@ static int ed_marker_move_cancel(bContext *C, wmOperator *op) ed_marker_move_apply(op); ed_marker_move_exit(C, op); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_CANCELLED; } @@ -738,10 +738,10 @@ static int ed_marker_move_cancel(bContext *C, wmOperator *op) static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) { - Scene *scene= CTX_data_scene(C); - MarkerMove *mm= op->customdata; - View2D *v2d= UI_view2d_fromcontext(C); - TimeMarker *marker, *selmarker=NULL; + Scene *scene = CTX_data_scene(C); + MarkerMove *mm = op->customdata; + View2D *v2d = UI_view2d_fromcontext(C); + TimeMarker *marker, *selmarker = NULL; float dx, fac; char str[256]; @@ -756,7 +756,7 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) ed_marker_move_cancel(C, op); return OPERATOR_CANCELLED; } - /* else continue; <--- see if release event should be caught for tweak-end */ + /* else continue; <--- see if release event should be caught for tweak-end */ case RETKEY: case PADENTER: @@ -764,8 +764,8 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) case MIDDLEMOUSE: if (WM_modal_tweak_exit(evt, mm->event_type)) { ed_marker_move_exit(C, op); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } break; @@ -773,44 +773,44 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) if (hasNumInput(&mm->num)) break; - dx= v2d->mask.xmax-v2d->mask.xmin; - dx= (v2d->cur.xmax-v2d->cur.xmin)/dx; + dx = v2d->mask.xmax - v2d->mask.xmin; + dx = (v2d->cur.xmax - v2d->cur.xmin) / dx; - if (evt->x != mm->evtx) { /* XXX maybe init for firsttime */ - int a, offs, totmark=0; + if (evt->x != mm->evtx) { /* XXX maybe init for first time */ + int a, offs, totmark = 0; - mm->evtx= evt->x; + mm->evtx = evt->x; - fac= ((float)(evt->x - mm->firstx)*dx); + fac = ((float)(evt->x - mm->firstx) * dx); if (mm->slink->spacetype == SPACE_TIME) - apply_keyb_grid(evt->shift, evt->ctrl, &fac, 0.0, FPS, 0.1*FPS, 0); + apply_keyb_grid(evt->shift, evt->ctrl, &fac, 0.0, FPS, 0.1 * FPS, 0); else apply_keyb_grid(evt->shift, evt->ctrl, &fac, 0.0, 1.0, 0.1, 0 /*was: U.flag & USER_AUTOGRABGRID*/); - offs= (int)fac; + offs = (int)fac; RNA_int_set(op->ptr, "frames", offs); ed_marker_move_apply(op); /* cruft below is for header print */ - for (a=0, marker= mm->markers->first; marker; marker= marker->next) { + for (a = 0, marker = mm->markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - selmarker= marker; + selmarker = marker; a++; totmark++; } } - if (totmark==1) { + if (totmark == 1) { /* we print current marker value */ if (mm->slink->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)mm->slink; + SpaceTime *stime = (SpaceTime *)mm->slink; if (stime->flag & TIME_DRAWFRAMES) BLI_snprintf(str, sizeof(str), "Marker %d offset %d", selmarker->frame, offs); else BLI_snprintf(str, sizeof(str), "Marker %.2f offset %.2f", FRA2TIME(selmarker->frame), FRA2TIME(offs)); } else if (mm->slink->spacetype == SPACE_ACTION) { - SpaceAction *saction= (SpaceAction *)mm->slink; + SpaceAction *saction = (SpaceAction *)mm->slink; if (saction->flag & SACTION_DRAWTIME) BLI_snprintf(str, sizeof(str), "Marker %.2f offset %.2f", FRA2TIME(selmarker->frame), FRA2TIME(offs)); else @@ -823,14 +823,14 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) else { /* we only print the offset */ if (mm->slink->spacetype == SPACE_TIME) { - SpaceTime *stime= (SpaceTime *)mm->slink; + SpaceTime *stime = (SpaceTime *)mm->slink; if (stime->flag & TIME_DRAWFRAMES) BLI_snprintf(str, sizeof(str), "Marker offset %d ", offs); else BLI_snprintf(str, sizeof(str), "Marker offset %.2f ", FRA2TIME(offs)); } else if (mm->slink->spacetype == SPACE_ACTION) { - SpaceAction *saction= (SpaceAction *)mm->slink; + SpaceAction *saction = (SpaceAction *)mm->slink; if (saction->flag & SACTION_DRAWTIME) BLI_snprintf(str, sizeof(str), "Marker offset %.2f ", FRA2TIME(offs)); else @@ -841,13 +841,13 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) } } - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); ED_area_headerprint(CTX_wm_area(C), str); } } - if (evt->val==KM_PRESS) { + if (evt->val == KM_PRESS) { float vec[3]; char str_tx[256]; @@ -862,8 +862,8 @@ static int ed_marker_move_modal(bContext *C, wmOperator *op, wmEvent *evt) BLI_snprintf(str, sizeof(str), "Marker offset %s", str_tx); ED_area_headerprint(CTX_wm_area(C), str); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); } } @@ -895,7 +895,7 @@ static void MARKER_OT_move(wmOperatorType *ot) ot->cancel = ed_marker_move_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; /* rna storage */ RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); @@ -922,7 +922,7 @@ static void MARKER_OT_move(wmOperatorType *ot) /* duplicate selected TimeMarkers */ static void ed_marker_duplicate_apply(bContext *C) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *newmarker; if (markers == NULL) @@ -931,19 +931,19 @@ static void ed_marker_duplicate_apply(bContext *C) /* go through the list of markers, duplicate selected markers and add duplicated copies * to the beginning of the list (unselect original markers) */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { /* unselect selected marker */ marker->flag &= ~SELECT; /* create and set up new marker */ newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); - newmarker->flag= SELECT; - newmarker->frame= marker->frame; + newmarker->flag = SELECT; + newmarker->frame = marker->frame; BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name)); #ifdef DURIAN_CAMERA_SWITCH - newmarker->camera= marker->camera; + newmarker->camera = marker->camera; #endif /* new marker is added to the beginning of list */ @@ -956,7 +956,7 @@ static void ed_marker_duplicate_apply(bContext *C) static int ed_marker_duplicate_exec(bContext *C, wmOperator *op) { ed_marker_duplicate_apply(C); - ed_marker_move_exec(C, op); /* assumes frs delta set */ + ed_marker_move_exec(C, op); /* assumes frs delta set */ return OPERATOR_FINISHED; @@ -988,7 +988,7 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) ot->cancel = ed_marker_move_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna storage */ RNA_def_int(ot->srna, "frames", 0, INT_MIN, INT_MAX, "Frames", "", INT_MIN, INT_MAX); @@ -1000,9 +1000,9 @@ static void MARKER_OT_duplicate(wmOperatorType *ot) static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned char shift) { TimeMarker *marker; - int select=0; + int select = 0; - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { /* if Shift is not set, then deselect Markers */ if (!shift) marker->flag &= ~SELECT; @@ -1019,20 +1019,20 @@ static void select_timeline_marker_frame(ListBase *markers, int frame, unsigned static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) { - ListBase *markers= ED_context_get_markers(C); - View2D *v2d= UI_view2d_fromcontext(C); + ListBase *markers = ED_context_get_markers(C); + View2D *v2d = UI_view2d_fromcontext(C); float viewx; int x, y, cfra; if (markers == NULL) return OPERATOR_PASS_THROUGH; - x= evt->x - CTX_wm_region(C)->winrct.xmin; - y= evt->y - CTX_wm_region(C)->winrct.ymin; + x = evt->x - CTX_wm_region(C)->winrct.xmin; + y = evt->y - CTX_wm_region(C)->winrct.ymin; UI_view2d_region_to_view(v2d, x, y, &viewx, NULL); - cfra= ED_markers_find_nearest_marker_time(markers, viewx); + cfra = ED_markers_find_nearest_marker_time(markers, viewx); if (extend) select_timeline_marker_frame(markers, cfra, 1); @@ -1042,25 +1042,25 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) #ifdef DURIAN_CAMERA_SWITCH if (camera) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Base *base; TimeMarker *marker; - int sel= 0; + int sel = 0; if (!extend) - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); - for (marker= markers->first; marker; marker= marker->next) { - if (marker->frame==cfra) { - sel= (marker->flag & SELECT); + for (marker = markers->first; marker; marker = marker->next) { + if (marker->frame == cfra) { + sel = (marker->flag & SELECT); break; } } - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->camera) { - if (marker->frame==cfra) { - base= object_in_scene(marker->camera, scene); + if (marker->frame == cfra) { + base = BKE_scene_base_find(scene, marker->camera); if (base) { ED_base_object_select(base, sel); if (sel) @@ -1070,25 +1070,25 @@ static int ed_marker_select(bContext *C, wmEvent *evt, int extend, int camera) } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } #else (void)camera; #endif - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); /* allowing tweaks, but needs OPERATOR_FINISHED, otherwise renaming fails... [#25987] */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } static int ed_marker_select_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - short extend= RNA_boolean_get(op->ptr, "extend"); - short camera= 0; + short extend = RNA_boolean_get(op->ptr, "extend"); + short camera = 0; #ifdef DURIAN_CAMERA_SWITCH - camera= RNA_boolean_get(op->ptr, "camera"); + camera = RNA_boolean_get(op->ptr, "camera"); #endif return ed_marker_select(C, evt, extend, camera); } @@ -1110,7 +1110,7 @@ static void MARKER_OT_select(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection"); #ifdef DURIAN_CAMERA_SWITCH @@ -1128,29 +1128,29 @@ static void MARKER_OT_select(wmOperatorType *ot) * * callbacks: * - * exec() has to be filled in by user + * exec() has to be filled in by user * - * invoke() default WM function - * adds modal handler + * invoke() default WM function + * adds modal handler * - * modal() default WM function - * accept modal events while doing it, calls exec(), handles ESC and border drawing + * modal() default WM function + * accept modal events while doing it, calls exec(), handles ESC and border drawing * - * poll() has to be filled in by user for context + * poll() has to be filled in by user for context */ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) { - View2D *v2d= UI_view2d_fromcontext(C); - ListBase *markers= ED_context_get_markers(C); + View2D *v2d = UI_view2d_fromcontext(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; float xminf, xmaxf, yminf, ymaxf; - int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); - int xmin= RNA_int_get(op->ptr, "xmin"); - int xmax= RNA_int_get(op->ptr, "xmax"); - int ymin= RNA_int_get(op->ptr, "ymin"); - int ymax= RNA_int_get(op->ptr, "ymax"); - int extend= RNA_boolean_get(op->ptr, "extend"); + int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); + int xmin = RNA_int_get(op->ptr, "xmin"); + int xmax = RNA_int_get(op->ptr, "xmax"); + int ymin = RNA_int_get(op->ptr, "ymin"); + int ymax = RNA_int_get(op->ptr, "ymax"); + int extend = RNA_boolean_get(op->ptr, "extend"); UI_view2d_region_to_view(v2d, xmin, ymin, &xminf, &yminf); UI_view2d_region_to_view(v2d, xmax, ymax, &xmaxf, &ymaxf); @@ -1159,7 +1159,7 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) return 0; /* XXX marker context */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if ((marker->frame > xminf) && (marker->frame <= xmaxf)) { switch (gesture_mode) { case GESTURE_MODAL_SELECT: @@ -1175,8 +1175,8 @@ static int ed_marker_border_select_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return 1; } @@ -1202,7 +1202,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -1212,7 +1212,7 @@ static void MARKER_OT_select_border(wmOperatorType *ot) static int ed_marker_select_all_exec(bContext *C, wmOperator *op) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; int action = RNA_enum_get(op->ptr, "action"); @@ -1223,22 +1223,22 @@ static int ed_marker_select_all_exec(bContext *C, wmOperator *op) action = (ED_markers_get_first_selected(markers) != NULL) ? SEL_DESELECT : SEL_SELECT; } - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { switch (action) { - case SEL_SELECT: - marker->flag |= SELECT; - break; - case SEL_DESELECT: - marker->flag &= ~SELECT; - break; - case SEL_INVERT: - marker->flag ^= SELECT; - break; + case SEL_SELECT: + marker->flag |= SELECT; + break; + case SEL_DESELECT: + marker->flag &= ~SELECT; + break; + case SEL_INVERT: + marker->flag ^= SELECT; + break; } } - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -1256,7 +1256,7 @@ static void MARKER_OT_select_all(wmOperatorType *ot) ot->poll = ed_markers_poll_markers_exist; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_select_all(ot); @@ -1267,24 +1267,24 @@ static void MARKER_OT_select_all(wmOperatorType *ot) /* remove selected TimeMarkers */ static int ed_marker_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker, *nmarker; - short changed= 0; + short changed = 0; if (markers == NULL) return OPERATOR_CANCELLED; - for (marker= markers->first; marker; marker= nmarker) { - nmarker= marker->next; + for (marker = markers->first; marker; marker = nmarker) { + nmarker = marker->next; if (marker->flag & SELECT) { BLI_freelinkN(markers, marker); - changed= 1; + changed = 1; } } if (changed) { - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); } return OPERATOR_FINISHED; @@ -1309,7 +1309,7 @@ static void MARKER_OT_delete(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1318,13 +1318,13 @@ static void MARKER_OT_delete(wmOperatorType *ot) /* rename first selected TimeMarker */ static int ed_marker_rename_exec(bContext *C, wmOperator *op) { - TimeMarker *marker= ED_markers_get_first_selected(ED_context_get_markers(C)); + TimeMarker *marker = ED_markers_get_first_selected(ED_context_get_markers(C)); if (marker) { RNA_string_get(op->ptr, "name", marker->name); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -1357,7 +1357,7 @@ static void MARKER_OT_rename(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedMarker", sizeof(((TimeMarker *)NULL)->name), "Name", "New name for marker"); @@ -1368,11 +1368,11 @@ static void MARKER_OT_rename(wmOperatorType *ot) static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) { - ListBase *markers= ED_context_get_markers(C); - Scene *scene_to= BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); + ListBase *markers = ED_context_get_markers(C); + Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); TimeMarker *marker, *marker_new; - if (scene_to==NULL) { + if (scene_to == NULL) { BKE_report(op->reports, RPT_ERROR, "Scene not found"); return OPERATOR_CANCELLED; } @@ -1383,10 +1383,10 @@ static int ed_marker_make_links_scene_exec(bContext *C, wmOperator *op) } /* copy markers */ - for (marker= markers->first; marker; marker= marker->next) { + for (marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { - marker_new= MEM_dupallocN(marker); - marker_new->prev= marker_new->next = NULL; + marker_new = MEM_dupallocN(marker); + marker_new->prev = marker_new->next = NULL; BLI_addtail(&scene_to->markers, marker_new); } @@ -1410,10 +1410,10 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); + prop = RNA_def_enum(ot->srna, "scene", DummyRNA_NULL_items, 0, "Scene", ""); RNA_def_enum_funcs(prop, RNA_scene_itemf); ot->prop = prop; @@ -1424,25 +1424,25 @@ static void MARKER_OT_make_links_scene(wmOperatorType *ot) static int ed_marker_camera_bind_exec(bContext *C, wmOperator *UNUSED(op)) { - bScreen *sc= CTX_wm_screen(C); - Scene *scene= CTX_data_scene(C); + bScreen *sc = CTX_wm_screen(C); + Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); - ListBase *markers= ED_context_get_markers(C); + ListBase *markers = ED_context_get_markers(C); TimeMarker *marker; - marker= ED_markers_get_first_selected(markers); + marker = ED_markers_get_first_selected(markers); if (marker == NULL) return OPERATOR_CANCELLED; - marker->camera= ob; + marker->camera = ob; /* camera may have changes */ - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); BKE_screen_view3d_scene_sync(sc); - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_SCENE|NA_EDITED, scene); /* so we get view3d redraws */ + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); /* so we get view3d redraws */ return OPERATOR_FINISHED; } @@ -1460,7 +1460,7 @@ static void MARKER_OT_camera_bind(wmOperatorType *ot) ot->poll = ed_markers_poll_selected_markers; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } #endif @@ -1501,7 +1501,7 @@ void ED_marker_keymap(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", FALSE); RNA_boolean_set(kmi->ptr, "camera", TRUE); - kmi = WM_keymap_add_item(keymap, "MARKER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "MARKER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); RNA_boolean_set(kmi->ptr, "camera", TRUE); #else diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c index 8286e81b792..119df33dd91 100644 --- a/source/blender/editors/animation/anim_ops.c +++ b/source/blender/editors/animation/anim_ops.c @@ -62,7 +62,7 @@ /* Check if the operator can be run from the current context */ static int change_frame_poll(bContext *C) { - ScrArea *curarea= CTX_wm_area(C); + ScrArea *curarea = CTX_wm_area(C); /* XXX temp? prevent changes during render */ if (G.rendering) return 0; @@ -77,17 +77,17 @@ static int change_frame_poll(bContext *C) /* Set the new frame number */ static void change_frame_apply(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); /* set the new frame number */ - CFRA= RNA_int_get(op->ptr, "frame"); + CFRA = RNA_int_get(op->ptr, "frame"); FRAMENUMBER_MIN_CLAMP(CFRA); SUBFRA = 0.f; /* do updates */ sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } /* ---- */ @@ -105,14 +105,14 @@ static int change_frame_exec(bContext *C, wmOperator *op) /* Get frame from mouse coordinates */ static int frame_from_event(bContext *C, wmEvent *event) { - ARegion *region= CTX_wm_region(C); + ARegion *region = CTX_wm_region(C); float viewx; /* convert from region coordinates to View2D 'tot' space */ UI_view2d_region_to_view(®ion->v2d, event->mval[0], event->mval[1], &viewx, NULL); /* round result to nearest int (frames are ints!) */ - return (int)floor(viewx+0.5f); + return (int)floor(viewx + 0.5f); } /* Modal Operator init */ @@ -150,7 +150,7 @@ static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event) /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ - if (event->val==KM_RELEASE) + if (event->val == KM_RELEASE) return OPERATOR_FINISHED; break; } @@ -172,7 +172,7 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) ot->poll = change_frame_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -182,14 +182,14 @@ static void ANIM_OT_change_frame(wmOperatorType *ot) static int previewrange_define_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); float sfra, efra; int xmin, xmax; /* get min/max values from border select rect (already in region coordinates, not screen) */ - xmin= RNA_int_get(op->ptr, "xmin"); - xmax= RNA_int_get(op->ptr, "xmax"); + xmin = RNA_int_get(op->ptr, "xmin"); + xmax = RNA_int_get(op->ptr, "xmax"); /* convert min/max values to frames (i.e. region to 'tot' rect) */ UI_view2d_region_to_view(&ar->v2d, xmin, 0, &sfra, NULL); @@ -201,14 +201,14 @@ static int previewrange_define_exec(bContext *C, wmOperator *op) */ FRAMENUMBER_MIN_CLAMP(sfra); FRAMENUMBER_MIN_CLAMP(efra); - if (efra < sfra) efra= sfra; + if (efra < sfra) efra = sfra; scene->r.flag |= SCER_PRV_RANGE; - scene->r.psfra= (int)floor(sfra + 0.5f); - scene->r.pefra= (int)floor(efra + 0.5f); + scene->r.psfra = (int)floor(sfra + 0.5f); + scene->r.pefra = (int)floor(efra + 0.5f); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -229,13 +229,13 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) ot->poll = ED_operator_animview_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ - /* used to define frame range */ + /* used to define frame range */ RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX); - /* these are not used, but are needed by borderselect gesture operator stuff */ + /* these are not used, but are needed by borderselect gesture operator stuff */ RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX); RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX); } @@ -244,8 +244,8 @@ static void ANIM_OT_previewrange_set(wmOperatorType *ot) static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - ScrArea *curarea= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *curarea = CTX_wm_area(C); /* sanity checks */ if (ELEM(NULL, scene, curarea)) @@ -253,8 +253,8 @@ static int previewrange_clear_exec(bContext *C, wmOperator *UNUSED(op)) /* simply clear values */ scene->r.flag &= ~SCER_PRV_RANGE; - scene->r.psfra= 0; - scene->r.pefra= 0; + scene->r.psfra = 0; + scene->r.pefra = 0; ED_area_tag_redraw(curarea); @@ -274,7 +274,7 @@ static void ANIM_OT_previewrange_clear(wmOperatorType *ot) ot->poll = ED_operator_animview_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** registration **********************************/ @@ -319,7 +319,7 @@ void ED_keymap_anim(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* frame management */ - /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */ + /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons */ WM_keymap_add_item(keymap, "ANIM_OT_change_frame", ACTIONMOUSE, KM_PRESS, 0, 0); kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index a4bc0cc854c..0cc92394a40 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -78,7 +78,7 @@ void free_anim_drivers_copybuf(void); * 1 - add new Driver FCurve, * -1 - add new Driver FCurve without driver stuff (for pasting) */ -FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_index, short add) +FCurve *verify_driver_fcurve(ID *id, const char rna_path[], const int array_index, short add) { AnimData *adt; FCurve *fcu; @@ -88,9 +88,9 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind return NULL; /* init animdata if none available yet */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) - adt= BKE_id_add_animdata(id); + adt = BKE_id_add_animdata(id); if (adt == NULL) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ return NULL; @@ -100,22 +100,22 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind * - add if not found and allowed to add one * TODO: add auto-grouping support? how this works will need to be resolved */ - fcu= list_find_fcurve(&adt->drivers, rna_path, array_index); + fcu = list_find_fcurve(&adt->drivers, rna_path, array_index); if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ - fcu= MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); /* store path - make copy, and store that */ - fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); - fcu->array_index= array_index; + fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); + fcu->array_index = array_index; /* if add is negative, don't init this data yet, since it will be filled in by the pasted driver */ if (add > 0) { /* add some new driver data */ - fcu->driver= MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); + fcu->driver = MEM_callocN(sizeof(ChannelDriver), "ChannelDriver"); /* add simple generator modifier for driver so that there is some visible representation */ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_GENERATOR); @@ -133,7 +133,7 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind /* Driver Management API */ /* Main Driver Management API calls: - * Add a new driver for the specified property on the given ID block + * Add a new driver for the specified property on the given ID block */ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short flag, int type) { @@ -147,18 +147,18 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - id->name, rna_path); + "Could not add Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + id->name, rna_path); return 0; } /* key entire array convenience method */ if (array_index == -1) { - array_index_max= RNA_property_array_length(&ptr, prop); - array_index= 0; + array_index_max = RNA_property_array_length(&ptr, prop); + array_index = 0; } else - array_index_max= array_index; + array_index_max = array_index; /* maximum index should be greater than the start index */ if (array_index == array_index_max) @@ -167,40 +167,40 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { /* create F-Curve with Driver */ - fcu= verify_driver_fcurve(id, rna_path, array_index, 1); + fcu = verify_driver_fcurve(id, rna_path, array_index, 1); if (fcu && fcu->driver) { - ChannelDriver *driver= fcu->driver; + ChannelDriver *driver = fcu->driver; /* set the type of the driver */ - driver->type= type; + driver->type = type; /* creating drivers for buttons will create the driver(s) with type * "scripted expression" so that their values won't be lost immediately, * so here we copy those values over to the driver's expression */ if (type == DRIVER_TYPE_PYTHON) { - PropertyType proptype= RNA_property_type(prop); - int array= RNA_property_array_length(&ptr, prop); - char *expression= driver->expression; - int val, maxlen= sizeof(driver->expression); + PropertyType proptype = RNA_property_type(prop); + int array = RNA_property_array_length(&ptr, prop); + char *expression = driver->expression; + int val, maxlen = sizeof(driver->expression); float fval; if (proptype == PROP_BOOLEAN) { - if (!array) val= RNA_property_boolean_get(&ptr, prop); - else val= RNA_property_boolean_get_index(&ptr, prop, array_index); + if (!array) val = RNA_property_boolean_get(&ptr, prop); + else val = RNA_property_boolean_get_index(&ptr, prop, array_index); - BLI_strncpy(expression, (val)? "True": "False", maxlen); + BLI_strncpy(expression, (val) ? "True" : "False", maxlen); } else if (proptype == PROP_INT) { - if (!array) val= RNA_property_int_get(&ptr, prop); - else val= RNA_property_int_get_index(&ptr, prop, array_index); + if (!array) val = RNA_property_int_get(&ptr, prop); + else val = RNA_property_int_get_index(&ptr, prop, array_index); BLI_snprintf(expression, maxlen, "%d", val); } else if (proptype == PROP_FLOAT) { - if (!array) fval= RNA_property_float_get(&ptr, prop); - else fval= RNA_property_float_get_index(&ptr, prop, array_index); + if (!array) fval = RNA_property_float_get(&ptr, prop); + else fval = RNA_property_float_get_index(&ptr, prop, array_index); BLI_snprintf(expression, maxlen, "%.3f", fval); } @@ -227,25 +227,25 @@ short ANIM_add_driver(ReportList *reports, ID *id, const char rna_path[], int ar } /* Main Driver Management API calls: - * Remove the driver for the specified property on the given ID block (if available) + * Remove the driver for the specified property on the given ID block (if available) */ short ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_path[], int array_index, short UNUSED(flag)) { AnimData *adt; FCurve *fcu; - int success= 0; + int success = 0; /* we don't check the validity of the path here yet, but it should be ok... */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if (adt) { if (array_index == -1) { /* step through all drivers, removing all of those with the same base path */ - FCurve *fcu_iter= adt->drivers.first; + FCurve *fcu_iter = adt->drivers.first; while ((fcu = iter_step_fcurve(fcu_iter, rna_path)) != NULL) { /* store the next fcurve for looping */ - fcu_iter= fcu->next; + fcu_iter = fcu->next; /* remove F-Curve from driver stack, then free it */ BLI_remlink(&adt->drivers, fcu); @@ -258,9 +258,9 @@ short ANIM_remove_driver(ReportList *UNUSED(reports), ID *id, const char rna_pat else { /* find the matching driver and remove it only * Note: here is one of the places where we don't want new F-Curve + Driver added! - * so 'add' var must be 0 + * so 'add' var must be 0 */ - fcu= verify_driver_fcurve(id, rna_path, array_index, 0); + fcu = verify_driver_fcurve(id, rna_path, array_index, 0); if (fcu) { BLI_remlink(&adt->drivers, fcu); free_fcurve(fcu); @@ -286,7 +286,7 @@ void free_anim_drivers_copybuf(void) /* free the buffer F-Curve if it exists, as if it were just another F-Curve */ if (channeldriver_copypaste_buf) free_fcurve(channeldriver_copypaste_buf); - channeldriver_copypaste_buf= NULL; + channeldriver_copypaste_buf = NULL; } /* Checks if there is a driver in the copy/paste buffer */ @@ -298,7 +298,7 @@ short ANIM_driver_can_paste(void) /* ------------------- */ /* Main Driver Management API calls: - * Make a copy of the driver for the specified property on the given ID block + * Make a copy of the driver for the specified property on the given ID block */ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) { @@ -310,13 +310,13 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - id->name, rna_path); + "Could not find Driver to copy, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + id->name, rna_path); return 0; } /* try to get F-Curve with Driver */ - fcu= verify_driver_fcurve(id, rna_path, array_index, 0); + fcu = verify_driver_fcurve(id, rna_path, array_index, 0); /* clear copy/paste buffer first (for consistency with other copy/paste buffers) */ free_anim_drivers_copybuf(); @@ -327,13 +327,13 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a * so that we don't end up wasting memory storing the path which won't get used ever... */ char *tmp_path = fcu->rna_path; - fcu->rna_path= NULL; + fcu->rna_path = NULL; /* make a copy of the F-Curve with */ - channeldriver_copypaste_buf= copy_fcurve(fcu); + channeldriver_copypaste_buf = copy_fcurve(fcu); /* restore the path */ - fcu->rna_path= tmp_path; + fcu->rna_path = tmp_path; /* copied... */ return 1; @@ -344,7 +344,7 @@ short ANIM_copy_driver(ReportList *reports, ID *id, const char rna_path[], int a } /* Main Driver Management API calls: - * Add a new driver for the specified property on the given ID block or replace an existing one + * Add a new driver for the specified property on the given ID block or replace an existing one * with the driver + driver-curve data from the buffer */ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int array_index, short UNUSED(flag)) @@ -357,8 +357,8 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - id->name, rna_path); + "Could not paste Driver, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + id->name, rna_path); return 0; } @@ -369,25 +369,25 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int } /* create Driver F-Curve, but without data which will be copied across... */ - fcu= verify_driver_fcurve(id, rna_path, array_index, -1); + fcu = verify_driver_fcurve(id, rna_path, array_index, -1); if (fcu) { /* copy across the curve data from the buffer curve * NOTE: this step needs care to not miss new settings */ - /* keyframes/samples */ - fcu->bezt= MEM_dupallocN(channeldriver_copypaste_buf->bezt); - fcu->fpt= MEM_dupallocN(channeldriver_copypaste_buf->fpt); - fcu->totvert= channeldriver_copypaste_buf->totvert; + /* keyframes/samples */ + fcu->bezt = MEM_dupallocN(channeldriver_copypaste_buf->bezt); + fcu->fpt = MEM_dupallocN(channeldriver_copypaste_buf->fpt); + fcu->totvert = channeldriver_copypaste_buf->totvert; - /* modifiers */ + /* modifiers */ copy_fmodifiers(&fcu->modifiers, &channeldriver_copypaste_buf->modifiers); - /* extrapolation mode */ - fcu->extend= channeldriver_copypaste_buf->extend; + /* extrapolation mode */ + fcu->extend = channeldriver_copypaste_buf->extend; - /* the 'juicy' stuff - the driver */ - fcu->driver= fcurve_copy_driver(channeldriver_copypaste_buf->driver); + /* the 'juicy' stuff - the driver */ + fcu->driver = fcurve_copy_driver(channeldriver_copypaste_buf->driver); } /* done */ @@ -407,7 +407,7 @@ short ANIM_paste_driver(ReportList *reports, ID *id, const char rna_path[], int * * > returns: MEM_alloc'd string representing the path to the property from the given PointerRNA */ -static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *prop) +static char *get_driver_path_hack(bContext *C, PointerRNA *ptr, PropertyRNA *prop) { ID *id = (ID *)ptr->id.data; ScrArea *sa = CTX_wm_area(C); @@ -431,17 +431,17 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr Material *ma = give_current_material(ob, ob->actcol); /* assumes: material will only be shown if it is active objects's active material it's ok */ - if ((ID*)ma == id) { + if ((ID *)ma == id) { /* create new path */ // TODO: use RNA path functions to construct instead? path = BLI_sprintfN("material_slots[\"%s\"].material.%s", - ma->id.name+2, basepath); + ma->id.name + 2, basepath); /* free old one */ MEM_freeN(basepath); } } - break; + break; case ID_TE: /* textures */ { @@ -449,17 +449,17 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr Tex *tex = give_current_material_texture(ma); /* assumes: texture will only be shown if it is active material's active texture it's ok */ - if ((ID*)tex == id) { + if ((ID *)tex == id) { /* create new path */ // TODO: use RNA path functions to construct step by step instead? path = BLI_sprintfN("material_slots[\"%s\"].material.texture_slots[\"%s\"].texture.%s", - ma->id.name+2, tex->id.name+2, basepath); + ma->id.name + 2, tex->id.name + 2, basepath); /* free old one */ MEM_freeN(basepath); } } - break; + break; } /* fix RNA pointer, as we've now changed the ID root by changing the paths */ @@ -476,25 +476,25 @@ static char *get_driver_path_hack (bContext *C, PointerRNA *ptr, PropertyRNA *pr /* Add Driver Button Operator ------------------------ */ -static int add_driver_button_exec (bContext *C, wmOperator *op) +static int add_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; - int index, all= RNA_boolean_get(op->ptr, "all"); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; + int index, all = RNA_boolean_get(op->ptr, "all"); /* try to create driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (all) - index= -1; + index = -1; if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); short flags = CREATEDRIVER_WITH_DEFAULT_DVAR; if (path) { - success+= ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); + success += ANIM_add_driver(op->reports, ptr.id.data, path, index, flags, DRIVER_TYPE_PYTHON); MEM_freeN(path); } @@ -506,10 +506,10 @@ static int add_driver_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_driver_button_add(wmOperatorType *ot) @@ -524,7 +524,7 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some animatable property to do this /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Create drivers for all elements of the array"); @@ -532,23 +532,23 @@ void ANIM_OT_driver_button_add(wmOperatorType *ot) /* Remove Driver Button Operator ------------------------ */ -static int remove_driver_button_exec (bContext *C, wmOperator *op) +static int remove_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; - int index, all= RNA_boolean_get(op->ptr, "all"); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; + int index, all = RNA_boolean_get(op->ptr, "all"); /* try to find driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (all) - index= -1; + index = -1; if (ptr.id.data && ptr.data && prop) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); - success= ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_remove_driver(op->reports, ptr.id.data, path, index, 0); MEM_freeN(path); } @@ -558,10 +558,10 @@ static int remove_driver_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_driver_button_remove(wmOperatorType *ot) @@ -576,7 +576,7 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some driver to be able to do this... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Delete drivers for all elements of the array"); @@ -584,22 +584,22 @@ void ANIM_OT_driver_button_remove(wmOperatorType *ot) /* Copy Driver Button Operator ------------------------ */ -static int copy_driver_button_exec (bContext *C, wmOperator *op) +static int copy_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; int index; /* try to create driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); if (path) { /* only copy the driver for the button that this was involved for */ - success= ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_copy_driver(op->reports, ptr.id.data, path, index, 0); uiContextAnimUpdate(C); @@ -608,7 +608,7 @@ static int copy_driver_button_exec (bContext *C, wmOperator *op) } /* since we're just copying, we don't really need to do anything else...*/ - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_copy_driver_button(wmOperatorType *ot) @@ -623,27 +623,27 @@ void ANIM_OT_copy_driver_button(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some driver to be able to do this... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Paste Driver Button Operator ------------------------ */ -static int paste_driver_button_exec (bContext *C, wmOperator *op) +static int paste_driver_button_exec(bContext *C, wmOperator *op) { - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; - short success= 0; + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; + short success = 0; int index; /* try to create driver using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - char *path= get_driver_path_hack(C, &ptr, prop); + char *path = get_driver_path_hack(C, &ptr, prop); if (path) { /* only copy the driver for the button that this was involved for */ - success= ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); + success = ANIM_paste_driver(op->reports, ptr.id.data, path, index, 0); uiContextAnimUpdate(C); @@ -652,7 +652,7 @@ static int paste_driver_button_exec (bContext *C, wmOperator *op) } /* since we're just copying, we don't really need to do anything else...*/ - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_paste_driver_button(wmOperatorType *ot) @@ -667,7 +667,7 @@ void ANIM_OT_paste_driver_button(wmOperatorType *ot) //op->poll= ??? // TODO: need to have some driver to be able to do this... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************** */ diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 9b46729b489..24cae5d8652 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -69,23 +69,23 @@ // XXX! -------------------------------- /* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */ -#define UI_FLT_MAX 10000.0f +#define UI_FLT_MAX 10000.0f -#define B_REDR 1 -#define B_FMODIFIER_REDRAW 20 +#define B_REDR 1 +#define B_FMODIFIER_REDRAW 20 /* macro for use here to draw background box and set height */ // XXX for now, roundbox has it's callback func set to NULL to not intercept events #define DRAW_BACKDROP(height) \ { \ - uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco-height, width+3, height-1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \ + uiDefBut(block, ROUNDBOX, B_REDR, "", -3, yco - height, width + 3, height - 1, NULL, 5.0, 0.0, 12.0, (float)rb_col, ""); \ } /* callback to verify modifier data */ -static void validate_fmodifier_cb (bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg)) +static void validate_fmodifier_cb(bContext *UNUSED(C), void *fcm_v, void *UNUSED(arg)) { - FModifier *fcm= (FModifier *)fcm_v; - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + FModifier *fcm = (FModifier *)fcm_v; + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); /* call the verify callback on the modifier if applicable */ if (fmi && fmi->verify_data) @@ -93,10 +93,10 @@ static void validate_fmodifier_cb (bContext *UNUSED(C), void *fcm_v, void *UNUSE } /* callback to remove the given modifier */ -static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v) +static void delete_fmodifier_cb(bContext *C, void *fmods_v, void *fcm_v) { ListBase *modifiers = (ListBase *)fmods_v; - FModifier *fcm= (FModifier *)fcm_v; + FModifier *fcm = (FModifier *)fcm_v; /* remove the given F-Modifier from the active modifier-stack */ remove_fmodifier(modifiers, fcm); @@ -105,7 +105,7 @@ static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v) /* send notifiers */ // XXX for now, this is the only way to get updates in all the right places... but would be nice to have a special one in this case - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* --------------- */ @@ -113,7 +113,7 @@ static void delete_fmodifier_cb (bContext *C, void *fmods_v, void *fcm_v) /* draw settings for generator modifier */ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, short width) { - FMod_Generator *data= (FMod_Generator *)fcm->data; + FMod_Generator *data = (FMod_Generator *)fcm->data; uiLayout /* *col, */ /* UNUSED */ *row; uiBlock *block; uiBut *but; @@ -124,12 +124,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s /* basic settings (backdrop + mode selector + some padding) */ /* col= uiLayoutColumn(layout, 1); */ /* UNUSED */ - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockBeginAlign(block); - but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + but = uiDefButR(block, MENU, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "mode", -1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); - uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width-30, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL); + uiDefButR(block, TOG, B_FMODIFIER_REDRAW, NULL, 0, 0, width - 30, UI_UNIT_Y, &ptr, "use_additive", -1, 0, 0, -1, -1, NULL); uiBlockEndAlign(block); /* now add settings for individual modes */ @@ -141,20 +141,20 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); - but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width-30, 19, - &data->poly_order, 1, 100, 0, 0, - TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); + but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 10, 0, width - 30, 19, + &data->poly_order, 1, 100, 0, 0, + TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); /* draw controls for each coefficient and a + sign at end of row */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); - cp= data->coefficients; - for (i=0; (i < data->arraysize) && (cp); i++, cp++) { + cp = data->coefficients; + for (i = 0; (i < data->arraysize) && (cp); i++, cp++) { /* To align with first line */ if (i) uiDefBut(block, LABEL, 1, " ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -173,12 +173,12 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s sprintf(xval, "x^%u", i); uiDefBut(block, LABEL, 1, xval, 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, TIP_("Power of x")); - if ( (i != (data->arraysize - 1)) || ((i==0) && data->arraysize==2) ) { + if ( (i != (data->arraysize - 1)) || ((i == 0) && data->arraysize == 2) ) { uiDefBut(block, LABEL, 1, "+", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* next coefficient on a new row */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); } else { /* For alignement in UI! */ @@ -194,20 +194,20 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s unsigned int i; /* draw polynomial order selector */ - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); - but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width-30, 19, - &data->poly_order, 1, 100, 0, 0, - TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); + but = uiDefButI(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Poly Order:"), 0, 0, width - 30, 19, + &data->poly_order, 1, 100, 0, 0, + TIP_("'Order' of the Polynomial (for a polynomial with n terms, 'order' is n-1)")); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); /* draw controls for each pair of coefficients */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); - cp= data->coefficients; - for (i=0; (i < data->poly_order) && (cp); i++, cp+=2) { + cp = data->coefficients; + for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) { /* To align with first line */ if (i) uiDefBut(block, LABEL, 1, " ", 0, 0, 50, 20, NULL, 0.0, 0.0, 0, 0, ""); @@ -222,22 +222,22 @@ static void draw_modifier__generator(uiLayout *layout, ID *id, FModifier *fcm, s uiDefBut(block, LABEL, 1, "x +", 0, 0, 40, 20, NULL, 0.0, 0.0, 0, 0, ""); - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp+1, -UI_FLT_MAX, UI_FLT_MAX, + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, "", 0, 0, 100, 20, cp + 1, -UI_FLT_MAX, UI_FLT_MAX, 10, 3, TIP_("Second coefficient")); /* closing bracket and '+' sign */ - if ( (i != (data->poly_order - 1)) || ((i==0) && data->poly_order==2) ) { + if ( (i != (data->poly_order - 1)) || ((i == 0) && data->poly_order == 2) ) { uiDefBut(block, LABEL, 1, ") +", 0, 0, 30, 20, NULL, 0.0, 0.0, 0, 0, ""); /* set up new row for the next pair of coefficients*/ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); } else uiDefBut(block, LABEL, 1, ")", 0, 0, 20, 20, NULL, 0.0, 0.0, 0, 0, ""); } } - break; + break; } } @@ -253,15 +253,15 @@ static void draw_modifier__fn_generator(uiLayout *layout, ID *id, FModifier *fcm RNA_pointer_create(id, &RNA_FModifierFunctionGenerator, fcm, &ptr); /* add the settings */ - col= uiLayoutColumn(layout, 1); - uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); - uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); - - col= uiLayoutColumn(layout, 0); // no grouping for now - uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "value_offset", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemR(col, &ptr, "function_type", 0, "", ICON_NONE); + uiItemR(col, &ptr, "use_additive", UI_ITEM_R_TOGGLE, NULL, ICON_NONE); + + col = uiLayoutColumn(layout, 0); // no grouping for now + uiItemR(col, &ptr, "amplitude", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "phase_multiplier", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "phase_offset", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "value_offset", 0, NULL, ICON_NONE); } /* --------------- */ @@ -278,19 +278,19 @@ static void draw_modifier__cycles(uiLayout *layout, ID *id, FModifier *fcm, shor /* split into 2 columns * NOTE: the mode comboboxes shouldn't get labels, otherwise there isn't enough room */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* before range */ - col= uiLayoutColumn(split, 1); - uiItemL(col, IFACE_("Before:"), ICON_NONE); - uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); - uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemL(col, IFACE_("Before:"), ICON_NONE); + uiItemR(col, &ptr, "mode_before", 0, "", ICON_NONE); + uiItemR(col, &ptr, "cycles_before", 0, NULL, ICON_NONE); /* after range */ - col= uiLayoutColumn(split, 1); - uiItemL(col, IFACE_("After:"), ICON_NONE); - uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); - uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemL(col, IFACE_("After:"), ICON_NONE); + uiItemR(col, &ptr, "mode_after", 0, "", ICON_NONE); + uiItemR(col, &ptr, "cycles_after", 0, NULL, ICON_NONE); } /* --------------- */ @@ -308,33 +308,33 @@ static void draw_modifier__noise(uiLayout *layout, ID *id, FModifier *fcm, short uiItemR(layout, &ptr, "blend_type", 0, NULL, ICON_NONE); /* split into 2 columns */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* col 1 */ - col= uiLayoutColumn(split, 0); - uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 0); + uiItemR(col, &ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "strength", 0, NULL, ICON_NONE); /* col 2 */ - col= uiLayoutColumn(split, 0); - uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 0); + uiItemR(col, &ptr, "phase", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "depth", 0, NULL, ICON_NONE); } /* --------------- */ -#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f +#define BINARYSEARCH_FRAMEEQ_THRESH 0.0001f /* Binary search algorithm for finding where to insert Envelope Data Point. * Returns the index to insert at (data already at that index will be offset if replace is 0) */ -static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float frame, int arraylen, short *exists) +static int binarysearch_fcm_envelopedata_index(FCM_EnvelopeData array[], float frame, int arraylen, short *exists) { - int start=0, end=arraylen; - int loopbreaker= 0, maxloop= arraylen * 2; + int start = 0, end = arraylen; + int loopbreaker = 0, maxloop = arraylen * 2; /* initialize exists-flag first */ - *exists= 0; + *exists = 0; /* sneaky optimisations (don't go through searching process if...): * - keyframe to be added is to be added out of current bounds @@ -349,7 +349,7 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float float framenum; /* 'First' Point (when only one point, this case is used) */ - framenum= array[0].time; + framenum = array[0].time; if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) { *exists = 1; return 0; @@ -358,9 +358,9 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float return 0; /* 'Last' Point */ - framenum= array[(arraylen-1)].time; + framenum = array[(arraylen - 1)].time; if (IS_EQT(frame, framenum, BINARYSEARCH_FRAMEEQ_THRESH)) { - *exists= 1; + *exists = 1; return (arraylen - 1); } else if (frame > framenum) @@ -369,12 +369,12 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float /* most of the time, this loop is just to find where to put it - * - 'loopbreaker' is just here to prevent infinite loops + * - 'loopbreaker' is just here to prevent infinite loops */ - for (loopbreaker=0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { + for (loopbreaker = 0; (start <= end) && (loopbreaker < maxloop); loopbreaker++) { /* compute and get midpoint */ - int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ - float midfra= array[mid].time; + int mid = start + ((end - start) / 2); /* we calculate the midpoint this way to avoid int overflows... */ + float midfra = array[mid].time; /* check if exactly equal to midpoint */ if (IS_EQT(frame, midfra, BINARYSEARCH_FRAMEEQ_THRESH)) { @@ -384,13 +384,13 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float /* repeat in upper/lower half */ if (frame > midfra) - start= mid + 1; + start = mid + 1; else if (frame < midfra) - end= mid - 1; + end = mid - 1; } /* print error if loop-limit exceeded */ - if (loopbreaker == (maxloop-1)) { + if (loopbreaker == (maxloop - 1)) { printf("Error: binarysearch_fcm_envelopedata_index() was taking too long\n"); // include debug info @@ -403,91 +403,91 @@ static int binarysearch_fcm_envelopedata_index (FCM_EnvelopeData array[], float /* callback to add new envelope data point */ // TODO: should we have a separate file for things like this? -static void fmod_envelope_addpoint_cb (bContext *C, void *fcm_dv, void *UNUSED(arg)) +static void fmod_envelope_addpoint_cb(bContext *C, void *fcm_dv, void *UNUSED(arg)) { - Scene *scene= CTX_data_scene(C); - FMod_Envelope *env= (FMod_Envelope *)fcm_dv; + Scene *scene = CTX_data_scene(C); + FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; FCM_EnvelopeData fed; /* init template data */ - fed.min= -1.0f; - fed.max= 1.0f; - fed.time= (float)scene->r.cfra; // XXX make this int for ease of use? - fed.f1= fed.f2= 0; + fed.min = -1.0f; + fed.max = 1.0f; + fed.time = (float)scene->r.cfra; // XXX make this int for ease of use? + fed.f1 = fed.f2 = 0; /* check that no data exists for the current frame... */ if (env->data) { short exists = -1; - int i= binarysearch_fcm_envelopedata_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); + int i = binarysearch_fcm_envelopedata_index(env->data, (float)(scene->r.cfra), env->totvert, &exists); /* binarysearch_...() will set exists by default to 0, so if it is non-zero, that means that the point exists already */ if (exists) return; /* add new */ - fedn= MEM_callocN((env->totvert+1)*sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); + fedn = MEM_callocN((env->totvert + 1) * sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); /* add the points that should occur before the point to be pasted */ if (i > 0) - memcpy(fedn, env->data, i*sizeof(FCM_EnvelopeData)); + memcpy(fedn, env->data, i * sizeof(FCM_EnvelopeData)); /* add point to paste at index i */ - *(fedn + i)= fed; + *(fedn + i) = fed; /* add the points that occur after the point to be pasted */ if (i < env->totvert) - memcpy(fedn+i+1, env->data+i, (env->totvert-i)*sizeof(FCM_EnvelopeData)); + memcpy(fedn + i + 1, env->data + i, (env->totvert - i) * sizeof(FCM_EnvelopeData)); /* replace (+ free) old with new */ MEM_freeN(env->data); - env->data= fedn; + env->data = fedn; env->totvert++; } else { - env->data= MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); - *(env->data)= fed; + env->data = MEM_callocN(sizeof(FCM_EnvelopeData), "FCM_EnvelopeData"); + *(env->data) = fed; - env->totvert= 1; + env->totvert = 1; } } /* callback to remove envelope data point */ // TODO: should we have a separate file for things like this? -static void fmod_envelope_deletepoint_cb (bContext *UNUSED(C), void *fcm_dv, void *ind_v) +static void fmod_envelope_deletepoint_cb(bContext *UNUSED(C), void *fcm_dv, void *ind_v) { - FMod_Envelope *env= (FMod_Envelope *)fcm_dv; + FMod_Envelope *env = (FMod_Envelope *)fcm_dv; FCM_EnvelopeData *fedn; - int index= GET_INT_FROM_POINTER(ind_v); + int index = GET_INT_FROM_POINTER(ind_v); /* check that no data exists for the current frame... */ if (env->totvert > 1) { /* allocate a new smaller array */ - fedn= MEM_callocN(sizeof(FCM_EnvelopeData)*(env->totvert-1), "FCM_EnvelopeData"); + fedn = MEM_callocN(sizeof(FCM_EnvelopeData) * (env->totvert - 1), "FCM_EnvelopeData"); - memcpy(fedn, env->data, sizeof(FCM_EnvelopeData)*(index)); - memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData)*((env->totvert - index)-1)); + memcpy(fedn, env->data, sizeof(FCM_EnvelopeData) * (index)); + memcpy(fedn + index, env->data + (index + 1), sizeof(FCM_EnvelopeData) * ((env->totvert - index) - 1)); /* free old array, and set the new */ MEM_freeN(env->data); - env->data= fedn; + env->data = fedn; env->totvert--; } else { /* just free array, since the only vert was deleted */ if (env->data) { MEM_freeN(env->data); - env->data= NULL; + env->data = NULL; } - env->totvert= 0; + env->totvert = 0; } } /* draw settings for envelope modifier */ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, short UNUSED(width)) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed; uiLayout *col, *row; uiBlock *block; @@ -499,45 +499,45 @@ static void draw_modifier__envelope(uiLayout *layout, ID *id, FModifier *fcm, sh RNA_pointer_create(id, &RNA_FModifierEnvelope, fcm, &ptr); /* general settings */ - col= uiLayoutColumn(layout, 1); - uiItemL(col, IFACE_("Envelope:"), ICON_NONE); - uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); - - row= uiLayoutRow(col, 1); - uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); - uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemL(col, IFACE_("Envelope:"), ICON_NONE); + uiItemR(col, &ptr, "reference_value", 0, NULL, ICON_NONE); + + row = uiLayoutRow(col, 1); + uiItemR(row, &ptr, "default_min", 0, IFACE_("Min"), ICON_NONE); + uiItemR(row, &ptr, "default_max", 0, IFACE_("Max"), ICON_NONE); /* control points header */ // TODO: move this control-point control stuff to using the new special widgets for lists // the current way is far too cramped - row= uiLayoutRow(layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 0); + block = uiLayoutGetBlock(row); - uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); + uiDefBut(block, LABEL, 1, IFACE_("Control Points:"), 0, 0, 150, 20, NULL, 0.0, 0.0, 0, 0, ""); - but = uiDefBut(block, BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 150, 19, - NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame")); - uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL); + but = uiDefBut(block, BUT, B_FMODIFIER_REDRAW, IFACE_("Add Point"), 0, 0, 150, 19, + NULL, 0, 0, 0, 0, TIP_("Add a new control-point to the envelope on the current frame")); + uiButSetFunc(but, fmod_envelope_addpoint_cb, env, NULL); /* control points list */ - for (i=0, fed=env->data; i < env->totvert; i++, fed++) { + for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* get a new row to operate on */ - row= uiLayoutRow(layout, 1); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(layout, 1); + block = uiLayoutGetBlock(row); uiBlockBeginAlign(block); - but=uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 90, 20, - &fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs")); - uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); + but = uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Fra:"), 0, 0, 90, 20, + &fed->time, -MAXFRAMEF, MAXFRAMEF, 10, 1, TIP_("Frame that envelope point occurs")); + uiButSetFunc(but, validate_fmodifier_cb, fcm, NULL); - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 100, 20, - &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point")); - uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 100, 20, - &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Maximum bound of envelope at this point")); - - but = uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 0, 0, 18, 20, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete envelope control point")); - uiButSetFunc(but, fmod_envelope_deletepoint_cb, env, SET_INT_IN_POINTER(i)); + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Min:"), 0, 0, 100, 20, + &fed->min, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Minimum bound of envelope at this point")); + uiDefButF(block, NUM, B_FMODIFIER_REDRAW, IFACE_("Max:"), 0, 0, 100, 20, + &fed->max, -UI_FLT_MAX, UI_FLT_MAX, 10, 2, TIP_("Maximum bound of envelope at this point")); + + but = uiDefIconBut(block, BUT, B_FMODIFIER_REDRAW, ICON_X, 0, 0, 18, 20, + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete envelope control point")); + uiButSetFunc(but, fmod_envelope_deletepoint_cb, env, SET_INT_IN_POINTER(i)); uiBlockBeginAlign(block); } } @@ -558,17 +558,17 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ /* split into 2 columns */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* x-minimum */ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_min_x", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "min_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_min_y", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "min_y", 0, NULL, ICON_NONE); } /* row 2: maximum */ @@ -576,17 +576,17 @@ static void draw_modifier__limits(uiLayout *layout, ID *id, FModifier *fcm, shor /* row= uiLayoutRow(layout, 0); */ /* UNUSED */ /* split into 2 columns */ - split= uiLayoutSplit(layout, 0.5f, 0); + split = uiLayoutSplit(layout, 0.5f, 0); /* x-minimum */ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_max_x", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "max_x", 0, NULL, ICON_NONE); /* y-minimum*/ - col= uiLayoutColumn(split, 1); - uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); + col = uiLayoutColumn(split, 1); + uiItemR(col, &ptr, "use_max_y", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "max_y", 0, NULL, ICON_NONE); } } @@ -602,36 +602,36 @@ static void draw_modifier__stepped(uiLayout *layout, ID *id, FModifier *fcm, sho RNA_pointer_create(id, &RNA_FModifierStepped, fcm, &ptr); /* block 1: "stepping" settings */ - col= uiLayoutColumn(layout, 0); - uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); - uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 0); + uiItemR(col, &ptr, "frame_step", 0, NULL, ICON_NONE); + uiItemR(col, &ptr, "frame_offset", 0, NULL, ICON_NONE); /* block 2: start range settings */ - col= uiLayoutColumn(layout, 1); - uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemR(col, &ptr, "use_frame_start", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); - uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_start")); + uiItemR(sub, &ptr, "frame_start", 0, NULL, ICON_NONE); /* block 3: end range settings */ - col= uiLayoutColumn(layout, 1); - uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemR(col, &ptr, "use_frame_end", 0, NULL, ICON_NONE); - sub = uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); - uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&ptr, "use_frame_end")); + uiItemR(sub, &ptr, "frame_end", 0, NULL, ICON_NONE); } /* --------------- */ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifiers, FModifier *fcm) { - FModifierTypeInfo *fmi= fmodifier_get_typeinfo(fcm); + FModifierTypeInfo *fmi = fmodifier_get_typeinfo(fcm); uiLayout *box, *row, *sub, *col; uiBlock *block; uiBut *but; - short width= 314; + short width = 314; PointerRNA ptr; /* init the RNA-pointer */ @@ -640,13 +640,13 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* draw header */ { /* get layout-row + UI-block for this */ - box= uiLayoutBox(layout); + box = uiLayoutBox(layout); - row= uiLayoutRow(box, 0); - block= uiLayoutGetBlock(row); // err... + row = uiLayoutRow(box, 0); + block = uiLayoutGetBlock(row); // err... /* left-align -------------------------------------------- */ - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -664,7 +664,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier uiItemL(sub, "", ICON_NONE); /* right-align ------------------------------------------- */ - sub= uiLayoutRow(row, 1); + sub = uiLayoutRow(row, 1); uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_RIGHT); @@ -675,7 +675,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* delete button */ but = uiDefIconBut(block, BUT, B_REDR, ICON_X, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier")); + NULL, 0.0, 0.0, 0.0, 0.0, TIP_("Delete F-Curve Modifier")); uiButSetFunc(but, delete_fmodifier_cb, modifiers, fcm); uiBlockSetEmboss(block, UI_EMBOSS); @@ -684,7 +684,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier /* when modifier is expanded, draw settings */ if (fcm->flag & FMODIFIER_FLAG_EXPANDED) { /* set up the flexible-box layout which acts as the backdrop for the modifier settings */ - box= uiLayoutBox(layout); + box = uiLayoutBox(layout); /* draw settings for individual modifiers */ switch (fcm->type) { @@ -729,7 +729,7 @@ void ANIM_uiTemplate_fmodifier_draw(uiLayout *layout, ID *id, ListBase *modifier col = uiLayoutColumn(box, 1); /* top row: use restricted range */ - row= uiLayoutRow(col, 1); + row = uiLayoutRow(col, 1); uiItemR(row, &ptr, "use_restricted_range", 0, NULL, ICON_NONE); if (fcm->flag & FMODIFIER_FLAG_RANGERESTRICT) { @@ -822,7 +822,7 @@ short ANIM_fmodifiers_paste_from_buf(ListBase *modifiers, short replace) free_fmodifiers(modifiers); /* now copy over all the modifiers in the buffer to the end of the list */ - for (fcm= fmodifier_copypaste_buf.first; fcm; fcm= fcm->next) { + for (fcm = fmodifier_copypaste_buf.first; fcm; fcm = fcm->next) { /* make a copy of it */ FModifier *fcmN = copy_fmodifier(fcm); diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index cc5cb42a783..cb7dc7ac206 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -63,7 +63,7 @@ #include "BKE_key.h" #include "BKE_material.h" -#include "BKE_global.h" // XXX remove me! +#include "BKE_global.h" // XXX remove me! #include "BIF_gl.h" @@ -82,8 +82,8 @@ /* NOTE: this is exported to other modules that use the ActKeyColumns for finding keyframes */ short compare_ak_cfraPtr(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - float *cframe= data; + ActKeyColumn *ak = (ActKeyColumn *)node; + float *cframe = data; if (*cframe < ak->cfra) return -1; @@ -96,10 +96,10 @@ short compare_ak_cfraPtr(void *node, void *data) /* --------------- */ /* Comparator callback used for ActKeyColumns and BezTriple */ -static short compare_ak_bezt (void *node, void *data) +static short compare_ak_bezt(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + BezTriple *bezt = (BezTriple *)data; if (bezt->vec[1][0] < ak->cfra) return -1; @@ -110,15 +110,15 @@ static short compare_ak_bezt (void *node, void *data) } /* New node callback used for building ActKeyColumns from BezTriples */ -static DLRBT_Node *nalloc_ak_bezt (void *data) +static DLRBT_Node *nalloc_ak_bezt(void *data) { - ActKeyColumn *ak= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn"); - BezTriple *bezt= (BezTriple *)data; + ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumn"); + BezTriple *bezt = (BezTriple *)data; /* store settings based on state of BezTriple */ - ak->cfra= bezt->vec[1][0]; - ak->sel= BEZSELECTED(bezt) ? SELECT : 0; - ak->key_type= BEZKEYTYPE(bezt); + ak->cfra = bezt->vec[1][0]; + ak->sel = BEZSELECTED(bezt) ? SELECT : 0; + ak->key_type = BEZKEYTYPE(bezt); /* set 'modified', since this is used to identify long keyframes */ ak->modified = 1; @@ -127,10 +127,10 @@ static DLRBT_Node *nalloc_ak_bezt (void *data) } /* Node updater callback used for building ActKeyColumns from BezTriples */ -static void nupdate_ak_bezt (void *node, void *data) +static void nupdate_ak_bezt(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + BezTriple *bezt = (BezTriple *)data; /* set selection status and 'touched' status */ if (BEZSELECTED(bezt)) ak->sel = SELECT; @@ -138,16 +138,16 @@ static void nupdate_ak_bezt (void *node, void *data) /* for keyframe type, 'proper' keyframes have priority over breakdowns (and other types for now) */ if (BEZKEYTYPE(bezt) == BEZT_KEYTYPE_KEYFRAME) - ak->key_type= BEZT_KEYTYPE_KEYFRAME; + ak->key_type = BEZT_KEYTYPE_KEYFRAME; } /* ......... */ /* Comparator callback used for ActKeyColumns and GPencil frame */ -static short compare_ak_gpframe (void *node, void *data) +static short compare_ak_gpframe(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - bGPDframe *gpf= (bGPDframe *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + bGPDframe *gpf = (bGPDframe *)data; if (gpf->framenum < ak->cfra) return -1; @@ -158,14 +158,14 @@ static short compare_ak_gpframe (void *node, void *data) } /* New node callback used for building ActKeyColumns from GPencil frames */ -static DLRBT_Node *nalloc_ak_gpframe (void *data) +static DLRBT_Node *nalloc_ak_gpframe(void *data) { - ActKeyColumn *ak= MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF"); - bGPDframe *gpf= (bGPDframe *)data; + ActKeyColumn *ak = MEM_callocN(sizeof(ActKeyColumn), "ActKeyColumnGPF"); + bGPDframe *gpf = (bGPDframe *)data; /* store settings based on state of BezTriple */ - ak->cfra= gpf->framenum; - ak->sel= (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0; + ak->cfra = gpf->framenum; + ak->sel = (gpf->flag & GP_FRAME_SELECT) ? SELECT : 0; /* set 'modified', since this is used to identify long keyframes */ ak->modified = 1; @@ -174,10 +174,10 @@ static DLRBT_Node *nalloc_ak_gpframe (void *data) } /* Node updater callback used for building ActKeyColumns from GPencil frames */ -static void nupdate_ak_gpframe (void *node, void *data) +static void nupdate_ak_gpframe(void *node, void *data) { - ActKeyColumn *ak= (ActKeyColumn *)node; - bGPDframe *gpf= (bGPDframe *)data; + ActKeyColumn *ak = (ActKeyColumn *)node; + bGPDframe *gpf = (bGPDframe *)data; /* set selection status and 'touched' status */ if (gpf->flag & GP_FRAME_SELECT) ak->sel = SELECT; @@ -207,36 +207,36 @@ static void add_gpframe_to_keycolumns_list(DLRBT_Tree *keys, bGPDframe *gpf) /* ActBeztColumns (Helpers for Long Keyframes) ------------------------------ */ /* maximum size of default buffer for BezTriple columns */ -#define MAX_ABK_BUFSIZE 4 +#define MAX_ABK_BUFSIZE 4 /* BezTriple Container Node */ // NOTE: only used internally while building Long Keyframes for now, but may be useful externally? typedef struct ActBeztColumn { /* Tree Node interface ---------------- */ - /* ListBase linkage */ + /* ListBase linkage */ struct ActBeztColumn *next, *prev; - /* sorting-tree linkage */ - struct ActBeztColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */ - struct ActBeztColumn *parent; /* parent of this node in the tree */ - char tree_col; /* DLRB_BLACK or DLRB_RED */ + /* sorting-tree linkage */ + struct ActBeztColumn *left, *right; /* 'children' of this node, less than and greater than it (respectively) */ + struct ActBeztColumn *parent; /* parent of this node in the tree */ + char tree_col; /* DLRB_BLACK or DLRB_RED */ char pad; /* BezTriple Store -------------------- */ - short numBezts; /* number of BezTriples on this frame */ - float cfra; /* frame that the BezTriples occur on */ + short numBezts; /* number of BezTriples on this frame */ + float cfra; /* frame that the BezTriples occur on */ - BezTriple *bezts[MAX_ABK_BUFSIZE]; /* buffer of pointers to BezTriples on the same frame */ + BezTriple *bezts[MAX_ABK_BUFSIZE]; /* buffer of pointers to BezTriples on the same frame */ //BezTriple **bezts_extra; /* secondary buffer of pointers if need be */ } ActBeztColumn; /* --------------- */ /* Comparator callback used for ActBeztColumns and BezTriple */ -static short compare_abk_bezt (void *node, void *data) +static short compare_abk_bezt(void *node, void *data) { - ActBeztColumn *abk= (ActBeztColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActBeztColumn *abk = (ActBeztColumn *)node; + BezTriple *bezt = (BezTriple *)data; if (bezt->vec[1][0] < abk->cfra) return -1; @@ -247,23 +247,23 @@ static short compare_abk_bezt (void *node, void *data) } /* New node callback used for building ActBeztColumns from BezTriples */ -static DLRBT_Node *nalloc_abk_bezt (void *data) +static DLRBT_Node *nalloc_abk_bezt(void *data) { - ActBeztColumn *abk= MEM_callocN(sizeof(ActBeztColumn), "ActKeyColumn"); - BezTriple *bezt= (BezTriple *)data; + ActBeztColumn *abk = MEM_callocN(sizeof(ActBeztColumn), "ActKeyColumn"); + BezTriple *bezt = (BezTriple *)data; /* store the BeztTriple in the buffer, and keep track of its frame number */ - abk->cfra= bezt->vec[1][0]; - abk->bezts[abk->numBezts++]= bezt; + abk->cfra = bezt->vec[1][0]; + abk->bezts[abk->numBezts++] = bezt; return (DLRBT_Node *)abk; } /* Node updater callback used for building ActBeztColumns from BezTriples */ -static void nupdate_abk_bezt (void *node, void *data) +static void nupdate_abk_bezt(void *node, void *data) { - ActBeztColumn *abk= (ActBeztColumn *)node; - BezTriple *bezt= (BezTriple *)data; + ActBeztColumn *abk = (ActBeztColumn *)node; + BezTriple *bezt = (BezTriple *)data; /* just add the BezTriple to the buffer if there's space, or allocate a new one */ if (abk->numBezts >= MAX_ABK_BUFSIZE) { @@ -274,14 +274,14 @@ static void nupdate_abk_bezt (void *node, void *data) } else { /* just store an extra one */ - abk->bezts[abk->numBezts++]= bezt; + abk->bezts[abk->numBezts++] = bezt; } } /* --------------- */ /* Return the BezTriple in the given ActBeztColumn that matches the requested value */ -static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) +static BezTriple *abk_get_bezt_with_value(ActBeztColumn *abk, float value) { BezTriple *bezt; int i; @@ -293,12 +293,12 @@ static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) /* look over each BezTriple in this container */ for (i = 0; i < abk->numBezts; i++) { /* only do exact match for now... */ - if (/*i >= MAX_ABK_BUFSIZE*/0) { + if (/*i >= MAX_ABK_BUFSIZE*/ 0) { // TODO: this case needs special handling } else { /* just use the default buffer */ - bezt= abk->bezts[i]; + bezt = abk->bezts[i]; if (bezt->vec[1][1] == value) return bezt; @@ -314,8 +314,8 @@ static BezTriple *abk_get_bezt_with_value (ActBeztColumn *abk, float value) /* NOTE: this is exported to other modules that use the ActKeyBlocks for finding long-keyframes */ short compare_ab_cfraPtr(void *node, void *data) { - ActKeyBlock *ab= (ActKeyBlock *)node; - float *cframe= data; + ActKeyBlock *ab = (ActKeyBlock *)node; + float *cframe = data; if (*cframe < ab->start) return -1; @@ -330,13 +330,13 @@ short compare_ab_cfraPtr(void *node, void *data) /* Create a ActKeyColumn for a pair of BezTriples */ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn) { - ActKeyBlock *ab= MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock"); + ActKeyBlock *ab = MEM_callocN(sizeof(ActKeyBlock), "ActKeyBlock"); - ab->start= prev->vec[1][0]; - ab->end= beztn->vec[1][0]; - ab->val= beztn->vec[1][1]; + ab->start = prev->vec[1][0]; + ab->end = beztn->vec[1][0]; + ab->val = beztn->vec[1][1]; - ab->sel= (BEZSELECTED(prev) || BEZSELECTED(beztn)) ? SELECT : 0; + ab->sel = (BEZSELECTED(prev) || BEZSELECTED(beztn)) ? SELECT : 0; ab->modified = 1; return ab; @@ -344,44 +344,44 @@ static ActKeyBlock *bezts_to_new_actkeyblock(BezTriple *prev, BezTriple *beztn) static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, BezTriple *beztn) { - ActKeyBlock *new_ab= NULL; + ActKeyBlock *new_ab = NULL; ActBeztColumn *abk; BezTriple *prev; /* get the BezTriple immediately before the given one which has the same value */ - /* the keyframes immediately before the ones containing the specified keyframe */ - abk= (ActBeztColumn *)BLI_dlrbTree_search_prev(beztTree, compare_abk_bezt, beztn); - /* if applicable, the BezTriple with the same value */ - prev= (abk) ? abk_get_bezt_with_value(abk, beztn->vec[1][1]) : NULL; + /* the keyframes immediately before the ones containing the specified keyframe */ + abk = (ActBeztColumn *)BLI_dlrbTree_search_prev(beztTree, compare_abk_bezt, beztn); + /* if applicable, the BezTriple with the same value */ + prev = (abk) ? abk_get_bezt_with_value(abk, beztn->vec[1][1]) : NULL; /* check if block needed - same value(s)? * -> firstly, handles must have same central value as each other * -> secondly, handles which control that section of the curve must be constant */ if ((!prev) || (!beztn)) return; - if (IS_EQF(beztn->vec[1][1], prev->vec[1][1])==0) return; - if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1])==0) return; - if (IS_EQF(prev->vec[1][1], prev->vec[2][1])==0) return; + if (IS_EQF(beztn->vec[1][1], prev->vec[1][1]) == 0) return; + if (IS_EQF(beztn->vec[1][1], beztn->vec[0][1]) == 0) return; + if (IS_EQF(prev->vec[1][1], prev->vec[2][1]) == 0) return; /* if there are no blocks already, just add as root */ if (blocks->root == NULL) { /* just add this as the root, then call the tree-balancing functions to validate */ - new_ab= bezts_to_new_actkeyblock(prev, beztn); - blocks->root= (DLRBT_Node *)new_ab; + new_ab = bezts_to_new_actkeyblock(prev, beztn); + blocks->root = (DLRBT_Node *)new_ab; } else { - ActKeyBlock *ab, *abn=NULL; + ActKeyBlock *ab, *abn = NULL; /* try to find a keyblock that starts on the previous beztriple, and add a new one if none start there * Note: we can't search from end to try to optimize this as it causes errors there's - * an A ___ B |---| B situation + * an A ___ B |---| B situation */ // FIXME: here there is a bug where we are trying to get the summary for the following channels // A|--------------|A ______________ B|--------------|B // A|------------------------------------------------|A // A|----|A|---|A|-----------------------------------|A - for (ab= blocks->root; ab; ab= abn) { + for (ab = blocks->root; ab; ab = abn) { /* check if this is a match, or whether we go left or right */ if (ab->start == prev->vec[1][0]) { /* set selection status and 'touched' status */ @@ -392,24 +392,24 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, return; } else { - ActKeyBlock **abnp= NULL; + ActKeyBlock **abnp = NULL; /* check if go left or right, but if not available, add new node */ if (ab->start < prev->vec[1][0]) - abnp= &ab->right; + abnp = &ab->right; else - abnp= &ab->left; + abnp = &ab->left; /* if this does not exist, add a new node, otherwise continue... */ if (*abnp == NULL) { /* add a new node representing this, and attach it to the relevant place */ - new_ab= bezts_to_new_actkeyblock(prev, beztn); - new_ab->parent= ab; - *abnp= new_ab; + new_ab = bezts_to_new_actkeyblock(prev, beztn); + new_ab->parent = ab; + *abnp = new_ab; break; } else - abn= *abnp; + abn = *abnp; } } } @@ -421,7 +421,7 @@ static void add_bezt_to_keyblocks_list(DLRBT_Tree *blocks, DLRBT_Tree *beztTree, /* --------- */ /* Handle the 'touched' status of ActKeyColumn tree nodes */ -static void set_touched_actkeycolumn (ActKeyColumn *ak) +static void set_touched_actkeycolumn(ActKeyColumn *ak) { /* sanity check */ if (ak == NULL) @@ -429,7 +429,7 @@ static void set_touched_actkeycolumn (ActKeyColumn *ak) /* deal with self first */ if (ak->modified) { - ak->modified= 0; + ak->modified = 0; ak->totcurve++; } @@ -439,7 +439,7 @@ static void set_touched_actkeycolumn (ActKeyColumn *ak) } /* Handle the 'touched' status of ActKeyBlock tree nodes */ -static void set_touched_actkeyblock (ActKeyBlock *ab) +static void set_touched_actkeyblock(ActKeyBlock *ab) { /* sanity check */ if (ab == NULL) @@ -447,7 +447,7 @@ static void set_touched_actkeyblock (ActKeyBlock *ab) /* deal with self first */ if (ab->modified) { - ab->modified= 0; + ab->modified = 0; ab->totcurve++; } @@ -469,17 +469,17 @@ short actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys) return 0; /* find out how many curves occur at each keyframe */ - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); - startCurves = (ak)? ak->totcurve: 0; + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->start); + startCurves = (ak) ? ak->totcurve : 0; - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); - endCurves = (ak)? ak->totcurve: 0; + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(keys, compare_ak_cfraPtr, &ab->end); + endCurves = (ak) ? ak->totcurve : 0; /* only draw keyblock if it appears in at all of the keyframes at lowest end */ if (!startCurves && !endCurves) return 0; - totCurves = (startCurves>endCurves)? endCurves: startCurves; + totCurves = (startCurves > endCurves) ? endCurves : startCurves; return (ab->totcurve >= totCurves); } @@ -487,52 +487,54 @@ short actkeyblock_is_valid(ActKeyBlock *ab, DLRBT_Tree *keys) /* 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 */ + {0.0f, 1.0f}, /* top vert */ + {1.0f, 0.0f}, /* mid-right */ + {0.0f, -1.0f}, /* bottom vert */ + {-1.0f, 0.0f} /* mid-left */ }; /* draw a simple diamond shape with OpenGL */ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, short key_type, short mode, float alpha) { - static GLuint displist1=0; - static GLuint displist2=0; + static GLuint displist1 = 0; + static GLuint displist2 = 0; /* initialize 2 display lists for diamond shape - one empty, one filled */ if (displist1 == 0) { - displist1= glGenLists(1); - glNewList(displist1, GL_COMPILE); + 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(); + 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); + 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(); + 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(); } /* tweak size of keyframe shape according to type of keyframe - * - 'proper' keyframes have key_type=0, so get drawn at full size + * - 'proper' keyframes have key_type=0, so get drawn at full size */ - hsize -= 0.5f*key_type; + hsize -= 0.5f * key_type; /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, hsize, 1.0f); + glScalef(1.0f / xscale * hsize, hsize, 1.0f); /* anti-aliased lines for more consistent appearance */ glEnable(GL_LINE_SMOOTH); @@ -546,29 +548,29 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, if (sel) glColor4f(0.33f, 0.75f, 0.93f, alpha); else glColor4f(0.70f, 0.86f, 0.91f, alpha); } - break; + break; case BEZT_KEYTYPE_EXTREME: /* redish frames for now */ { if (sel) glColor4f(0.95f, 0.5f, 0.5f, alpha); else glColor4f(0.91f, 0.70f, 0.80f, alpha); } - break; + break; case BEZT_KEYTYPE_JITTER: /* greenish frames for now? */ { if (sel) glColor4f(0.38f, 0.75f, 0.26f, alpha); else glColor4f(0.58f, 0.90f, 0.46f, alpha); } - break; + break; case BEZT_KEYTYPE_KEYFRAME: /* traditional yellowish frames for now */ default: { - if (sel) UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255*(1.0f-alpha)); + if (sel) UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); else glColor4f(0.91f, 0.91f, 0.91f, alpha); } - break; + break; } glCallList(displist2); @@ -584,7 +586,7 @@ void draw_keyframe_shape(float x, float y, float xscale, float hsize, short sel, glDisable(GL_LINE_SMOOTH); /* restore view transform */ - glScalef(xscale/hsize, 1.0f/hsize, 1.0); + glScalef(xscale / hsize, 1.0f / hsize, 1.0f); glTranslatef(-x, -y, 0.0f); } @@ -601,7 +603,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa /* draw keyblocks */ if (blocks) { - for (ab= blocks->first; ab; ab= ab->next) { + for (ab = blocks->first; ab; ab = ab->next) { if (actkeyblock_is_valid(ab, keys)) { /* draw block */ if (ab->sel) @@ -609,7 +611,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa else UI_ThemeColor4(TH_STRIP); - glRectf(ab->start, ypos-5, ab->end, ypos+5); + glRectf(ab->start, ypos - 5, ab->end, ypos + 5); } } } @@ -618,9 +620,9 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa if (keys) { /* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */ // TODO: allow this opacity factor to be themed? - float kalpha = (channelLocked)? 0.35f : 1.0f; + float kalpha = (channelLocked) ? 0.35f : 1.0f; - for (ak= keys->first; ak; ak= ak->next) { + for (ak = keys->first; ak; ak = ak->next) { /* optimization: if keyframe doesn't appear within 5 units (screenspace) in visible area, don't draw * - this might give some improvements, since we current have to flip between view/region matrices */ @@ -646,12 +648,12 @@ void draw_summary_channel(View2D *v2d, bAnimContext *ac, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - summary_to_keylist(ac, &keys, &blocks); + summary_to_keylist(ac, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -664,12 +666,12 @@ void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - scene_to_keylist(ads, sce, &keys, &blocks); + scene_to_keylist(ads, sce, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -682,12 +684,12 @@ void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - ob_to_keylist(ads, ob, &keys, &blocks); + ob_to_keylist(ads, ob, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -700,12 +702,12 @@ void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - fcurve_to_keylist(adt, fcu, &keys, &blocks); + fcurve_to_keylist(adt, fcu, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, (fcu->flag & FCURVE_PROTECTED)); + draw_keylist(v2d, &keys, &blocks, ypos, (fcu->flag & FCURVE_PROTECTED)); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -718,12 +720,12 @@ void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float y BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - agroup_to_keylist(adt, agrp, &keys, &blocks); + agroup_to_keylist(adt, agrp, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, (agrp->flag & AGRP_PROTECTED)); + draw_keylist(v2d, &keys, &blocks, ypos, (agrp->flag & AGRP_PROTECTED)); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -736,12 +738,12 @@ void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos) BLI_dlrbTree_init(&keys); BLI_dlrbTree_init(&blocks); - action_to_keylist(adt, act, &keys, &blocks); + action_to_keylist(adt, act, &keys, &blocks); BLI_dlrbTree_linkedlist_sync(&keys); BLI_dlrbTree_linkedlist_sync(&blocks); - draw_keylist(v2d, &keys, &blocks, ypos, 0); + draw_keylist(v2d, &keys, &blocks, ypos, 0); BLI_dlrbTree_free(&keys); BLI_dlrbTree_free(&blocks); @@ -753,11 +755,11 @@ void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos) BLI_dlrbTree_init(&keys); - gpl_to_keylist(ads, gpl, &keys); + gpl_to_keylist(ads, gpl, &keys); BLI_dlrbTree_linkedlist_sync(&keys); - draw_keylist(v2d, &keys, NULL, ypos, (gpl->flag & GP_LAYER_LOCKED)); + draw_keylist(v2d, &keys, NULL, ypos, (gpl->flag & GP_LAYER_LOCKED)); BLI_dlrbTree_free(&keys); } @@ -772,11 +774,11 @@ void summary_to_keylist(bAnimContext *ac, DLRBT_Tree *keys, DLRBT_Tree *blocks) int filter; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through each F-Curve, grabbing the keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); BLI_freelistN(&anim_data); @@ -806,11 +808,11 @@ void scene_to_keylist(bDopeSheet *ads, Scene *sce, DLRBT_Tree *keys, DLRBT_Tree ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, grabbing the keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); BLI_freelistN(&anim_data); @@ -842,11 +844,11 @@ void ob_to_keylist(bDopeSheet *ads, Object *ob, DLRBT_Tree *keys, DLRBT_Tree *bl ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, grabbing the keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) fcurve_to_keylist(ale->adt, ale->data, keys, blocks); BLI_freelistN(&anim_data); @@ -868,10 +870,10 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree */ if (blocks) { /* init new tree */ - beztTree= BLI_dlrbTree_new(); + beztTree = BLI_dlrbTree_new(); /* populate tree with the BezTriples */ - for (v=0, bezt=fcu->bezt; v < fcu->totvert; v++, bezt++) + for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) BLI_dlrbTree_add(beztTree, compare_abk_bezt, nalloc_abk_bezt, nupdate_abk_bezt, bezt); /* make sure that it is suitable for linked-list searching too */ @@ -879,7 +881,7 @@ void fcurve_to_keylist(AnimData *adt, FCurve *fcu, DLRBT_Tree *keys, DLRBT_Tree } /* loop through beztriples, making ActKeysColumns and ActKeyBlocks */ - for (v=0, bezt=fcu->bezt; v < fcu->totvert; v++, bezt++) { + for (v = 0, bezt = fcu->bezt; v < fcu->totvert; v++, bezt++) { add_bezt_to_keycolumns_list(keys, bezt); if (blocks) add_bezt_to_keyblocks_list(blocks, beztTree, bezt); } @@ -908,7 +910,7 @@ void agroup_to_keylist(AnimData *adt, bActionGroup *agrp, DLRBT_Tree *keys, DLRB if (agrp) { /* loop through F-Curves */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) { + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) { fcurve_to_keylist(adt, fcu, keys, blocks); } } @@ -920,7 +922,7 @@ void action_to_keylist(AnimData *adt, bAction *act, DLRBT_Tree *keys, DLRBT_Tree if (act) { /* loop through F-Curves */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { fcurve_to_keylist(adt, fcu, keys, blocks); } } @@ -933,7 +935,7 @@ void gpl_to_keylist(bDopeSheet *UNUSED(ads), bGPDlayer *gpl, DLRBT_Tree *keys) if (gpl && keys) { /* although the frames should already be in an ordered list, they are not suitable for displaying yet */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) add_gpframe_to_keycolumns_list(keys, gpf); } } diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 4e59216a39c..b92d0fb345a 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -102,9 +102,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi /* set the F-Curve into the editdata so that it can be accessed */ if (ked) { - ked->fcu= fcu; - ked->curIndex= 0; - ked->curflags= ok; + ked->fcu = fcu; + ked->curIndex = 0; + ked->curflags = ok; } /* if function to apply to bezier curves is set, then loop through executing it on beztriples */ @@ -113,16 +113,16 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi * (this is should be more efficient than checking for it in every loop) */ if (key_ok) { - for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) { + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { if (ked) { /* advance the index, and reset the ok flags (to not influence the result) */ - ked->curIndex= i; - ked->curflags= 0; + ked->curIndex = i; + ked->curflags = 0; } /* Only operate on this BezTriple if it fullfills the criteria of the validation func */ if ( (ok = key_ok(ked, bezt)) ) { - if (ked) ked->curflags= ok; + if (ked) ked->curflags = ok; /* Exit with return-code '1' if function returns positive * This is useful if finding if some BezTriple satisfies a condition. @@ -132,8 +132,8 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi } } else { - for (bezt=fcu->bezt, i=0; i < fcu->totvert; bezt++, i++) { - if (ked) ked->curIndex= i; + for (bezt = fcu->bezt, i = 0; i < fcu->totvert; bezt++, i++) { + if (ked) ked->curIndex = i; /* Exit with return-code '1' if function returns positive * This is useful if finding if some BezTriple satisfies a condition. @@ -145,9 +145,9 @@ short ANIM_fcurve_keyframes_loop(KeyframeEditData *ked, FCurve *fcu, KeyframeEdi /* unset the F-Curve from the editdata now that it's done */ if (ked) { - ked->fcu= NULL; - ked->curIndex= 0; - ked->curflags= 0; + ked->fcu = NULL; + ked->curIndex = 0; + ked->curflags = 0; } /* if fcu_cb (F-Curve post-editing callback) has been specified then execute it */ @@ -170,7 +170,7 @@ static short agrp_keyframes_loop(KeyframeEditData *ked, bActionGroup *agrp, Keyf return 0; /* only iterate over the F-Curves that are in this group */ - for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) { + for (fcu = agrp->channels.first; fcu && fcu->grp == agrp; fcu = fcu->next) { if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) return 1; } @@ -188,7 +188,7 @@ static short act_keyframes_loop(KeyframeEditData *ked, bAction *act, KeyframeEdi return 0; /* just loop through all F-Curves */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { if (ANIM_fcurve_keyframes_loop(ked, fcu, key_ok, key_cb, fcu_cb)) return 1; } @@ -203,7 +203,7 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - int ret=0; + int ret = 0; bAnimListElem dummychan = {NULL}; Base dummybase = {NULL}; @@ -224,12 +224,12 @@ static short ob_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Object *o ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ - for (ale= anim_data.first; ale; ale= ale->next) { - if (ANIM_fcurve_keyframes_loop(ked, (FCurve*)ale->data, key_ok, key_cb, fcu_cb)) { + for (ale = anim_data.first; ale; ale = ale->next) { + if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { ret = 1; break; } @@ -248,7 +248,7 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - int ret=0; + int ret = 0; bAnimListElem dummychan = {NULL}; @@ -266,12 +266,12 @@ static short scene_keyframes_loop(KeyframeEditData *ked, bDopeSheet *ads, Scene ac.datatype = ANIMCONT_CHANNEL; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; // curves only + filter = ANIMFILTER_DATA_VISIBLE; // curves only ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through each F-Curve, applying the operation as required, but stopping on the first one */ - for (ale= anim_data.first; ale; ale= ale->next) { - if (ANIM_fcurve_keyframes_loop(ked, (FCurve*)ale->data, key_ok, key_cb, fcu_cb)) { + for (ale = anim_data.first; ale; ale = ale->next) { + if (ANIM_fcurve_keyframes_loop(ked, (FCurve *)ale->data, key_ok, key_cb, fcu_cb)) { ret = 1; break; } @@ -288,19 +288,19 @@ static short summary_keyframes_loop(KeyframeEditData *ked, bAnimContext *ac, Key { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ret_code=0; + int filter, ret_code = 0; /* sanity check */ if (ac == NULL) return 0; /* get F-Curves to take keyframes from */ - filter= ANIMFILTER_DATA_VISIBLE; + filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through each F-Curve, working on the keyframes until the first curve aborts */ - for (ale= anim_data.first; ale; ale= ale->next) { - ret_code= ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); + for (ale = anim_data.first; ale; ale = ale->next) { + ret_code = ANIM_fcurve_keyframes_loop(ked, ale->data, key_ok, key_cb, fcu_cb); if (ret_code) break; @@ -388,16 +388,16 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) bAnimListElem *ale; int filter; /* when not in graph view, don't use handles */ - SpaceIpo *sipo= (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL; + SpaceIpo *sipo = (ac->spacetype == SPACE_IPO) ? (SpaceIpo *)ac->sl : NULL; const short use_handle = sipo ? !(sipo->flag & SIPO_NOHANDLES) : FALSE; /* filter animation data */ - filter= ANIMFILTER_DATA_VISIBLE; + filter = ANIMFILTER_DATA_VISIBLE; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop over F-Curves that are likely to have been edited, and check them */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = ale->key_data; /* make sure keyframes in F-Curve are all in order, and handles are in valid positions */ sort_time_fcurve(fcu); @@ -439,7 +439,7 @@ static short ok_bezier_frame(KeyframeEditData *ked, BezTriple *bezt) /* frame is stored in f1 property (this float accuracy check may need to be dropped?) */ #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][0], ked->f1) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -452,7 +452,7 @@ static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt) /* frame range is stored in float properties */ #define KEY_CHECK_OK(_index) ((bezt->vec[_index][0] > ked->f1) && (bezt->vec[_index][0] < ked->f2)) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -462,7 +462,7 @@ static short ok_bezier_framerange(KeyframeEditData *ked, BezTriple *bezt) static short ok_bezier_selected(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { /* this macro checks all beztriple handles for selection... - * only one of the verts has to be selected for this to be ok... + * only one of the verts has to be selected for this to be ok... */ if (BEZSELECTED(bezt)) return KEYFRAME_OK_ALL; @@ -479,7 +479,7 @@ static short ok_bezier_value(KeyframeEditData *ked, BezTriple *bezt) * - should value be stored in f2 instead so that we won't have conflicts when using f1 for frames too? */ #define KEY_CHECK_OK(_index) IS_EQF(bezt->vec[_index][1], ked->f1) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -492,7 +492,7 @@ static short ok_bezier_valuerange(KeyframeEditData *ked, BezTriple *bezt) /* value range is stored in float properties */ #define KEY_CHECK_OK(_index) ((bezt->vec[_index][1] > ked->f1) && (bezt->vec[_index][1] < ked->f2)) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -506,7 +506,7 @@ static short ok_bezier_region(KeyframeEditData *ked, BezTriple *bezt) short ok = 0; #define KEY_CHECK_OK(_index) BLI_in_rctf(ked->data, bezt->vec[_index][0], bezt->vec[_index][1]) - KEYFRAME_OK_CHECKS(KEY_CHECK_OK); + KEYFRAME_OK_CHECKS(KEY_CHECK_OK); #undef KEY_CHECK_OK /* return ok flags */ @@ -525,7 +525,7 @@ KeyframeEditFunc ANIM_editkeyframes_ok(short mode) return ok_bezier_frame; case BEZT_OK_FRAMERANGE: /* only if bezt falls within the specified frame range (floats) */ return ok_bezier_framerange; - case BEZT_OK_SELECTED: /* only if bezt is selected (self) */ + case BEZT_OK_SELECTED: /* only if bezt is selected (self) */ return ok_bezier_selected; case BEZT_OK_VALUE: /* only if bezt value matches (float) */ return ok_bezier_value; @@ -566,10 +566,10 @@ short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt) { /* only if selected */ if (bezt->f2 & SELECT) { - CfraElem *ce= MEM_callocN(sizeof(CfraElem), "cfraElem"); + CfraElem *ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked->list, ce); - ce->cfra= bezt->vec[1][0]; + ce->cfra = bezt->vec[1][0]; } return 0; @@ -580,15 +580,15 @@ short bezt_to_cfraelem(KeyframeEditData *ked, BezTriple *bezt) */ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) { - KeyframeEditCD_Remap *rmap= (KeyframeEditCD_Remap*)ked->data; + KeyframeEditCD_Remap *rmap = (KeyframeEditCD_Remap *)ked->data; const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin); /* perform transform on all three handles unless indicated otherwise */ // TODO: need to include some checks for that - bezt->vec[0][0]= scale*(bezt->vec[0][0] - rmap->oldMin) + rmap->newMin; - bezt->vec[1][0]= scale*(bezt->vec[1][0] - rmap->oldMin) + rmap->newMin; - bezt->vec[2][0]= scale*(bezt->vec[2][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[0][0] = scale * (bezt->vec[0][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[1][0] = scale * (bezt->vec[1][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[2][0] = scale * (bezt->vec[2][0] - rmap->oldMin) + rmap->newMin; } /* ******************************************* */ @@ -598,27 +598,27 @@ void bezt_remap_times(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_nearest(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)(floorf(bezt->vec[1][0]+0.5f)); + bezt->vec[1][0] = (float)(floorf(bezt->vec[1][0] + 0.5f)); return 0; } /* snaps the keyframe to the neares second */ static short snap_bezier_nearestsec(KeyframeEditData *ked, BezTriple *bezt) { - const Scene *scene= ked->scene; + const Scene *scene = ked->scene; const float secf = (float)FPS; if (bezt->f2 & SELECT) - bezt->vec[1][0]= ((float)floor(bezt->vec[1][0]/secf + 0.5f) * secf); + bezt->vec[1][0] = ((float)floor(bezt->vec[1][0] / secf + 0.5f) * secf); return 0; } /* snaps the keyframe to the current frame */ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) { - const Scene *scene= ked->scene; + const Scene *scene = ked->scene; if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)CFRA; + bezt->vec[1][0] = (float)CFRA; return 0; } @@ -626,7 +626,7 @@ static short snap_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][0]= (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]); + bezt->vec[1][0] = (float)ED_markers_find_nearest_marker_time(&ked->list, bezt->vec[1][0]); return 0; } @@ -634,10 +634,10 @@ static short snap_bezier_nearmarker(KeyframeEditData *ked, BezTriple *bezt) static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) { - bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1]; + bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1]; - if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1= HD_ALIGN; - if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2= HD_ALIGN; + if (ELEM3(bezt->h1, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h1 = HD_ALIGN; + if (ELEM3(bezt->h2, HD_AUTO, HD_AUTO_ANIM, HD_VECT)) bezt->h2 = HD_ALIGN; } return 0; } @@ -646,7 +646,7 @@ static short snap_bezier_horizontal(KeyframeEditData *UNUSED(ked), BezTriple *be static short snap_bezier_value(KeyframeEditData *ked, BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->vec[1][1]= ked->f1; + bezt->vec[1][1] = ked->f1; return 0; } @@ -675,12 +675,12 @@ KeyframeEditFunc ANIM_editkeyframes_snap(short type) static short mirror_bezier_cframe(KeyframeEditData *ked, BezTriple *bezt) { - const Scene *scene= ked->scene; + const Scene *scene = ked->scene; float diff; if (bezt->f2 & SELECT) { - diff= ((float)CFRA - bezt->vec[1][0]); - bezt->vec[1][0]= ((float)CFRA + diff); + diff = ((float)CFRA - bezt->vec[1][0]); + bezt->vec[1][0] = ((float)CFRA + diff); } return 0; @@ -691,8 +691,8 @@ static short mirror_bezier_yaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) float diff; if (bezt->f2 & SELECT) { - diff= (0.0f - bezt->vec[1][0]); - bezt->vec[1][0]= (0.0f + diff); + diff = (0.0f - bezt->vec[1][0]); + bezt->vec[1][0] = (0.0f + diff); } return 0; @@ -703,8 +703,8 @@ static short mirror_bezier_xaxis(KeyframeEditData *UNUSED(ked), BezTriple *bezt) float diff; if (bezt->f2 & SELECT) { - diff= (0.0f - bezt->vec[1][1]); - bezt->vec[1][1]= (0.0f + diff); + diff = (0.0f - bezt->vec[1][1]); + bezt->vec[1][1] = (0.0f + diff); } return 0; @@ -714,8 +714,8 @@ static short mirror_bezier_marker(KeyframeEditData *ked, BezTriple *bezt) { /* mirroring time stored in f1 */ if (bezt->f2 & SELECT) { - const float diff= (ked->f1 - bezt->vec[1][0]); - bezt->vec[1][0]= (ked->f1 + diff); + const float diff = (ked->f1 - bezt->vec[1][0]); + bezt->vec[1][0] = (ked->f1 + diff); } return 0; @@ -727,8 +727,8 @@ static short mirror_bezier_value(KeyframeEditData *ked, BezTriple *bezt) /* value to mirror over is stored in the custom data -> first float value slot */ if (bezt->f2 & SELECT) { - diff= (ked->f1 - bezt->vec[1][1]); - bezt->vec[1][1]= (ked->f1 + diff); + diff = (ked->f1 - bezt->vec[1][1]); + bezt->vec[1][1] = (ked->f1 + diff); } return 0; @@ -763,17 +763,17 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short type) #define ENSURE_HANDLES_MATCH(bezt) \ if (bezt->h1 != bezt->h2) { \ if (ELEM3(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \ - bezt->h1= HD_FREE; \ + bezt->h1 = HD_FREE; \ if (ELEM3(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \ - bezt->h2= HD_FREE; \ + bezt->h2 = HD_FREE; \ } /* Sets the selected bezier handles to type 'auto' */ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= HD_AUTO; - if (bezt->f3 & SELECT) bezt->h2= HD_AUTO; + if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO; + if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO; ENSURE_HANDLES_MATCH(bezt); } @@ -786,8 +786,8 @@ static short set_bezier_auto(KeyframeEditData *UNUSED(ked), BezTriple *bezt) static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if ((bezt->f1 & SELECT) || (bezt->f3 & SELECT)) { - if (bezt->f1 & SELECT) bezt->h1= HD_AUTO_ANIM; - if (bezt->f3 & SELECT) bezt->h2= HD_AUTO_ANIM; + if (bezt->f1 & SELECT) bezt->h1 = HD_AUTO_ANIM; + if (bezt->f3 & SELECT) bezt->h2 = HD_AUTO_ANIM; ENSURE_HANDLES_MATCH(bezt); } @@ -797,8 +797,8 @@ static short set_bezier_auto_clamped(KeyframeEditData *UNUSED(ked), BezTriple *b /* Sets the selected bezier handles to type 'vector' */ static short set_bezier_vector(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) bezt->h1= HD_VECT; - if (bezt->f3 & SELECT) bezt->h2= HD_VECT; + if (bezt->f1 & SELECT) bezt->h1 = HD_VECT; + if (bezt->f3 & SELECT) bezt->h2 = HD_VECT; return 0; } @@ -815,16 +815,16 @@ static short bezier_isfree(KeyframeEditData *UNUSED(ked), BezTriple *bezt) /* Sets selected bezier handles to type 'align' */ static short set_bezier_align(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) bezt->h1= HD_ALIGN; - if (bezt->f3 & SELECT) bezt->h2= HD_ALIGN; + if (bezt->f1 & SELECT) bezt->h1 = HD_ALIGN; + if (bezt->f3 & SELECT) bezt->h2 = HD_ALIGN; return 0; } /* Sets selected bezier handles to type 'free' */ static short set_bezier_free(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { - if (bezt->f1 & SELECT) bezt->h1= HD_FREE; - if (bezt->f3 & SELECT) bezt->h2= HD_FREE; + if (bezt->f1 & SELECT) bezt->h1 = HD_FREE; + if (bezt->f3 & SELECT) bezt->h2 = HD_FREE; return 0; } @@ -855,21 +855,21 @@ KeyframeEditFunc ANIM_editkeyframes_handles(short code) static short set_bezt_constant(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->ipo= BEZT_IPO_CONST; + bezt->ipo = BEZT_IPO_CONST; return 0; } static short set_bezt_linear(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->ipo= BEZT_IPO_LIN; + bezt->ipo = BEZT_IPO_LIN; return 0; } static short set_bezt_bezier(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - bezt->ipo= BEZT_IPO_BEZ; + bezt->ipo = BEZT_IPO_BEZ; return 0; } @@ -892,28 +892,28 @@ KeyframeEditFunc ANIM_editkeyframes_ipo(short code) static short set_keytype_keyframe(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_KEYFRAME; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_KEYFRAME; return 0; } static short set_keytype_breakdown(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_BREAKDOWN; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_BREAKDOWN; return 0; } static short set_keytype_extreme(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_EXTREME; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_EXTREME; return 0; } static short set_keytype_jitter(KeyframeEditData *UNUSED(ked), BezTriple *bezt) { if (bezt->f2 & SELECT) - BEZKEYTYPE(bezt)= BEZT_KEYTYPE_JITTER; + BEZKEYTYPE(bezt) = BEZT_KEYTYPE_JITTER; return 0; } @@ -1017,32 +1017,32 @@ KeyframeEditFunc ANIM_editkeyframes_select(short selectmode) static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt) { - FCurve *fcu= ked->fcu; - char *map= ked->data; - int i= ked->curIndex; + FCurve *fcu = ked->fcu; + char *map = ked->data; + int i = ked->curIndex; /* if current is selected, just make sure it stays this way */ if (BEZSELECTED(bezt)) { - map[i]= 1; + map[i] = 1; return 0; } /* if previous is selected, that means that selection should extend across */ if (i > 0) { - BezTriple *prev= bezt - 1; + BezTriple *prev = bezt - 1; if (BEZSELECTED(prev)) { - map[i]= 1; + map[i] = 1; return 0; } } /* if next is selected, that means that selection should extend across */ - if (i < (fcu->totvert-1)) { - BezTriple *next= bezt + 1; + if (i < (fcu->totvert - 1)) { + BezTriple *next = bezt + 1; if (BEZSELECTED(next)) { - map[i]= 1; + map[i] = 1; return 0; } } @@ -1052,9 +1052,9 @@ static short selmap_build_bezier_more(KeyframeEditData *ked, BezTriple *bezt) static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) { - FCurve *fcu= ked->fcu; - char *map= ked->data; - int i= ked->curIndex; + FCurve *fcu = ked->fcu; + char *map = ked->data; + int i = ked->curIndex; /* if current is selected, check the left/right keyframes * since it might need to be deselected (but otherwise no) @@ -1062,7 +1062,7 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) if (BEZSELECTED(bezt)) { /* if previous is not selected, we're on the tip of an iceberg */ if (i > 0) { - BezTriple *prev= bezt - 1; + BezTriple *prev = bezt - 1; if (BEZSELECTED(prev) == 0) return 0; @@ -1073,19 +1073,19 @@ static short selmap_build_bezier_less(KeyframeEditData *ked, BezTriple *bezt) } /* if next is not selected, we're on the tip of an iceberg */ - if (i < (fcu->totvert-1)) { - BezTriple *next= bezt + 1; + if (i < (fcu->totvert - 1)) { + BezTriple *next = bezt + 1; if (BEZSELECTED(next) == 0) return 0; } - else if (i == (fcu->totvert-1)) { + else if (i == (fcu->totvert - 1)) { /* current keyframe is selected at an endpoint, so should get deselected */ return 0; } /* if we're still here, that means that keyframe should remain untouched */ - map[i]= 1; + map[i] = 1; } return 0; @@ -1109,8 +1109,8 @@ KeyframeEditFunc ANIM_editkeyframes_buildselmap(short mode) /* flush selection map values to the given beztriple */ short bezt_selmap_flush(KeyframeEditData *ked, BezTriple *bezt) { - char *map= ked->data; - short on= map[ked->curIndex]; + char *map = ked->data; + short on = map[ked->curIndex]; /* select or deselect based on whether the map allows it or not */ if (on) { diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index c54f8c5bd25..05c87e98f9b 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -90,13 +90,13 @@ void delete_fcurve_key(FCurve *fcu, int index, short do_recalc) index += fcu->totvert; /* Delete this keyframe */ - memmove(&fcu->bezt[index], &fcu->bezt[index+1], sizeof(BezTriple)*(fcu->totvert-index-1)); + memmove(&fcu->bezt[index], &fcu->bezt[index + 1], sizeof(BezTriple) * (fcu->totvert - index - 1)); fcu->totvert--; if (fcu->totvert == 0) { if (fcu->bezt) MEM_freeN(fcu->bezt); - fcu->bezt= NULL; + fcu->bezt = NULL; } /* recalc handles - only if it won't cause problems */ @@ -109,13 +109,13 @@ void delete_fcurve_keys(FCurve *fcu) { int i; - if (fcu->bezt==NULL) /* ignore baked curves */ + if (fcu->bezt == NULL) /* ignore baked curves */ return; /* Delete selected BezTriples */ - for (i=0; i < fcu->totvert; i++) { + for (i = 0; i < fcu->totvert; i++) { if (fcu->bezt[i].f2 & SELECT) { - memmove(&fcu->bezt[i], &fcu->bezt[i+1], sizeof(BezTriple)*(fcu->totvert-i-1)); + memmove(&fcu->bezt[i], &fcu->bezt[i + 1], sizeof(BezTriple) * (fcu->totvert - i - 1)); fcu->totvert--; i--; } @@ -131,9 +131,9 @@ void clear_fcurve_keys(FCurve *fcu) { if (fcu->bezt) MEM_freeN(fcu->bezt); - fcu->bezt= NULL; + fcu->bezt = NULL; - fcu->totvert= 0; + fcu->totvert = 0; } /* ---------------- */ @@ -148,20 +148,20 @@ void duplicate_fcurve_keys(FCurve *fcu) if (ELEM(NULL, fcu, fcu->bezt)) return; - for (i=0; i < fcu->totvert; i++) { + for (i = 0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { /* Expand the list */ - newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert+1), "beztriple"); + newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple"); - memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i+1)); - memcpy(newbezt+i+1, fcu->bezt+i, sizeof(BezTriple)); - memcpy(newbezt+i+2, fcu->bezt+i+1, sizeof (BezTriple) *(fcu->totvert-(i+1))); + memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); + memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); + memcpy(newbezt + i + 2, fcu->bezt + i + 1, sizeof (BezTriple) * (fcu->totvert - (i + 1))); fcu->totvert++; /* reassign pointers... (free old, and add new) */ MEM_freeN(fcu->bezt); - fcu->bezt=newbezt; + fcu->bezt = newbezt; /* Unselect the current key */ BEZ_DESEL(&fcu->bezt[i]); @@ -200,20 +200,20 @@ void clean_fcurve(FCurve *fcu, float thresh) /* Loop through BezTriples, comparing them. Skip any that do * not fit the criteria for "ok" points. */ - for (i=1; ivec[1][0]; next[1]= beztn->vec[1][1]; + beztn = (old_bezts + (i + 1)); + next[0] = beztn->vec[1][0]; next[1] = beztn->vec[1][1]; } else { beztn = NULL; next[0] = next[1] = 0.0f; } - lastb= (fcu->bezt + (fcu->totvert - 1)); - bezt= (old_bezts + i); + lastb = (fcu->bezt + (fcu->totvert - 1)); + bezt = (old_bezts + i); /* get references for quicker access */ prev[0] = lastb->vec[1][0]; prev[1] = lastb->vec[1][1]; @@ -226,7 +226,7 @@ void clean_fcurve(FCurve *fcu, float thresh) * current is further away than the next one is to the previous. */ if (beztn && (IS_EQT(cur[0], next[0], thresh)) && - (IS_EQT(next[1], prev[1], thresh)==0)) + (IS_EQT(next[1], prev[1], thresh) == 0)) { /* only add if current is further away from previous */ if (cur[1] > next[1]) { @@ -276,8 +276,8 @@ void clean_fcurve(FCurve *fcu, float thresh) /* temp struct used for smooth_fcurve */ typedef struct tSmooth_Bezt { - float *h1, *h2, *h3; /* bezt->vec[0,1,2][1] */ - float y1, y2, y3; /* averaged before/new/after y-values */ + float *h1, *h2, *h3; /* bezt->vec[0,1,2][1] */ + float y1, y2, y3; /* averaged before/new/after y-values */ } tSmooth_Bezt; /* Use a weighted moving-means method to reduce intensity of fluctuations */ @@ -288,8 +288,8 @@ void smooth_fcurve(FCurve *fcu) int i, x, totSel = 0; /* first loop through - count how many verts are selected */ - bezt= fcu->bezt; - for (i=0; i < fcu->totvert; i++, bezt++) { + bezt = fcu->bezt; + for (i = 0; i < fcu->totvert; i++, bezt++) { if (BEZSELECTED(bezt)) totSel++; } @@ -299,11 +299,11 @@ void smooth_fcurve(FCurve *fcu) tSmooth_Bezt *tarray, *tsb; /* allocate memory in one go */ - tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); + tsb = tarray = MEM_callocN(totSel * sizeof(tSmooth_Bezt), "tSmooth_Bezt Array"); /* populate tarray with data of selected points */ - bezt= fcu->bezt; - for (i=0, x=0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { + bezt = fcu->bezt; + for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { if (BEZSELECTED(bezt)) { /* tsb simply needs pointer to vec, and index */ tsb->h1 = &bezt->vec[0][1]; @@ -311,7 +311,7 @@ void smooth_fcurve(FCurve *fcu) tsb->h3 = &bezt->vec[2][1]; /* advance to the next tsb to populate */ - if (x < totSel-1) + if (x < totSel - 1) tsb++; else break; @@ -321,19 +321,19 @@ void smooth_fcurve(FCurve *fcu) /* calculate the new smoothed F-Curve's with weighted averages: * - this is done with two passes to avoid progressive corruption errors * - uses 5 points for each operation (which stores in the relevant handles) - * - previous: w/a ratio = 3:5:2:1:1 - * - next: w/a ratio = 1:1:2:5:3 + * - previous: w/a ratio = 3:5:2:1:1 + * - next: w/a ratio = 1:1:2:5:3 */ /* round 1: calculate smoothing deltas and new values */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { + tsb = tarray; + for (i = 0; i < totSel; i++, tsb++) { /* don't touch end points (otherwise, curves slowly explode, as we don't have enough data there) */ - if (ELEM(i, 0, (totSel-1)) == 0) { + if (ELEM(i, 0, (totSel - 1)) == 0) { const tSmooth_Bezt *tP1 = tsb - 1; - const tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL); + const tSmooth_Bezt *tP2 = (i - 2 > 0) ? (tsb - 2) : (NULL); const tSmooth_Bezt *tN1 = tsb + 1; - const tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL); + const tSmooth_Bezt *tN2 = (i + 2 < totSel) ? (tsb + 2) : (NULL); const float p1 = *tP1->h2; const float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2); @@ -342,18 +342,18 @@ void smooth_fcurve(FCurve *fcu) const float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2); /* calculate previous and next, then new position by averaging these */ - tsb->y1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12; - tsb->y3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12; + tsb->y1 = (3 * p2 + 5 * p1 + 2 * c1 + n1 + n2) / 12; + tsb->y3 = (p2 + p1 + 2 * c1 + 5 * n1 + 3 * n2) / 12; tsb->y2 = (tsb->y1 + tsb->y3) / 2; } } /* round 2: apply new values */ - tsb= tarray; - for (i=0; i < totSel; i++, tsb++) { + tsb = tarray; + for (i = 0; i < totSel; i++, tsb++) { /* don't touch end points, as their values were't touched above */ - if (ELEM(i, 0, (totSel-1)) == 0) { + if (ELEM(i, 0, (totSel - 1)) == 0) { /* y2 takes the average of the 2 points */ *tsb->h2 = tsb->y2; @@ -382,42 +382,42 @@ typedef struct tempFrameValCache { /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ void sample_fcurve(FCurve *fcu) { - BezTriple *bezt, *start=NULL, *end=NULL; + BezTriple *bezt, *start = NULL, *end = NULL; tempFrameValCache *value_cache, *fp; int sfra, range; int i, n, nIndex; - if (fcu->bezt==NULL) /* ignore baked */ + if (fcu->bezt == NULL) /* ignore baked */ return; /* find selected keyframes... once pair has been found, add keyframes */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if selected, and which end this is */ if (BEZSELECTED(bezt)) { if (start) { /* set end */ - end= bezt; + end = bezt; /* cache values then add keyframes using these values, as adding * keyframes while sampling will affect the outcome... * - only start sampling+adding from index=1, so that we don't overwrite original keyframe */ - range= (int)( ceil(end->vec[1][0] - start->vec[1][0]) ); - sfra= (int)( floor(start->vec[1][0]) ); + range = (int)(ceil(end->vec[1][0] - start->vec[1][0]) ); + sfra = (int)(floor(start->vec[1][0]) ); if (range) { - value_cache= MEM_callocN(sizeof(tempFrameValCache)*range, "IcuFrameValCache"); + value_cache = MEM_callocN(sizeof(tempFrameValCache) * range, "IcuFrameValCache"); - /* sample values */ - for (n=1, fp=value_cache; nframe= (float)(sfra + n); - fp->val= evaluate_fcurve(fcu, fp->frame); + /* sample values */ + for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { + fp->frame = (float)(sfra + n); + fp->val = evaluate_fcurve(fcu, fp->frame); } - /* add keyframes with these, tagging as 'breakdowns' */ - for (n=1, fp=value_cache; nframe, fp->val, 1); - BEZKEYTYPE(fcu->bezt + nIndex)= BEZT_KEYTYPE_BREAKDOWN; + /* add keyframes with these, tagging as 'breakdowns' */ + for (n = 1, fp = value_cache; n < range && fp; n++, fp++) { + nIndex = insert_vert_fcurve(fcu, fp->frame, fp->val, 1); + BEZKEYTYPE(fcu->bezt + nIndex) = BEZT_KEYTYPE_BREAKDOWN; } /* free temp cache */ @@ -429,13 +429,13 @@ void sample_fcurve(FCurve *fcu) } /* bezt was selected, so it now marks the start of a whole new chain to search */ - start= bezt; - end= NULL; + start = bezt; + end = NULL; } else { /* just set start keyframe */ - start= bezt; - end= NULL; + start = bezt; + end = NULL; } } } @@ -455,23 +455,23 @@ void sample_fcurve(FCurve *fcu) /* globals for copy/paste data (like for other copy/paste buffers) */ static ListBase animcopybuf = {NULL, NULL}; -static float animcopy_firstframe= 999999999.0f; -static float animcopy_lastframe= -999999999.0f; -static float animcopy_cfra= 0.0; +static float animcopy_firstframe = 999999999.0f; +static float animcopy_lastframe = -999999999.0f; +static float animcopy_cfra = 0.0; /* datatype for use in copy/paste buffer */ typedef struct tAnimCopybufItem { struct tAnimCopybufItem *next, *prev; - ID *id; /* ID which owns the curve */ - bActionGroup *grp; /* Action Group */ - char *rna_path; /* RNA-Path */ - int array_index; /* array index */ + ID *id; /* ID which owns the curve */ + bActionGroup *grp; /* Action Group */ + char *rna_path; /* RNA-Path */ + int array_index; /* array index */ - int totvert; /* number of keyframes stored for this channel */ - BezTriple *bezt; /* keyframes in buffer */ + int totvert; /* number of keyframes stored for this channel */ + BezTriple *bezt; /* keyframes in buffer */ - short id_type; /* Result of GS(id->name)*/ + short id_type; /* Result of GS(id->name)*/ } tAnimCopybufItem; @@ -482,8 +482,8 @@ void free_anim_copybuf(void) tAnimCopybufItem *aci, *acn; /* free each buffer element */ - for (aci= animcopybuf.first; aci; aci= acn) { - acn= aci->next; + for (aci = animcopybuf.first; aci; aci = acn) { + acn = aci->next; /* free keyframes */ if (aci->bezt) @@ -498,9 +498,9 @@ void free_anim_copybuf(void) } /* restore initial state */ - animcopybuf.first= animcopybuf.last= NULL; - animcopy_firstframe= 999999999.0f; - animcopy_lastframe= -999999999.0f; + animcopybuf.first = animcopybuf.last = NULL; + animcopy_firstframe = 999999999.0f; + animcopy_lastframe = -999999999.0f; } /* ------------------- */ @@ -509,14 +509,14 @@ void free_anim_copybuf(void) short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) { bAnimListElem *ale; - Scene *scene= ac->scene; + Scene *scene = ac->scene; /* clear buffer first */ free_anim_copybuf(); /* assume that each of these is an F-Curve */ - for (ale= anim_data->first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data->first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; tAnimCopybufItem *aci; BezTriple *bezt, *nbezt, *newbuf; int i; @@ -529,42 +529,42 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) continue; /* init copybuf item info */ - aci= MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem"); - aci->id= ale->id; - aci->id_type= GS(ale->id->name); - aci->grp= fcu->grp; - aci->rna_path= MEM_dupallocN(fcu->rna_path); - aci->array_index= fcu->array_index; + aci = MEM_callocN(sizeof(tAnimCopybufItem), "AnimCopybufItem"); + aci->id = ale->id; + aci->id_type = GS(ale->id->name); + aci->grp = fcu->grp; + aci->rna_path = MEM_dupallocN(fcu->rna_path); + aci->array_index = fcu->array_index; BLI_addtail(&animcopybuf, aci); /* add selected keyframes to buffer */ // TODO: currently, we resize array everytime we add a new vert - this works ok as long as it is assumed only a few keys are copied - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (BEZSELECTED(bezt)) { /* add to buffer */ - newbuf= MEM_callocN(sizeof(BezTriple)*(aci->totvert+1), "copybuf beztriple"); + newbuf = MEM_callocN(sizeof(BezTriple) * (aci->totvert + 1), "copybuf beztriple"); /* assume that since we are just re-sizing the array, just copy all existing data across */ if (aci->bezt) - memcpy(newbuf, aci->bezt, sizeof(BezTriple)*(aci->totvert)); + memcpy(newbuf, aci->bezt, sizeof(BezTriple) * (aci->totvert)); /* copy current beztriple across too */ - nbezt= &newbuf[aci->totvert]; - *nbezt= *bezt; + nbezt = &newbuf[aci->totvert]; + *nbezt = *bezt; /* ensure copy buffer is selected so pasted keys are selected */ BEZ_SEL(nbezt); /* free old array and set the new */ if (aci->bezt) MEM_freeN(aci->bezt); - aci->bezt= newbuf; + aci->bezt = newbuf; aci->totvert++; /* check if this is the earliest frame encountered so far */ if (bezt->vec[1][0] < animcopy_firstframe) - animcopy_firstframe= bezt->vec[1][0]; + animcopy_firstframe = bezt->vec[1][0]; if (bezt->vec[1][0] > animcopy_lastframe) - animcopy_lastframe= bezt->vec[1][0]; + animcopy_lastframe = bezt->vec[1][0]; } } @@ -575,7 +575,7 @@ short copy_animedit_keys(bAnimContext *ac, ListBase *anim_data) return -1; /* in case 'relative' paste method is used */ - animcopy_cfra= CFRA; + animcopy_cfra = CFRA; /* everything went fine */ return 0; @@ -588,7 +588,7 @@ static tAnimCopybufItem *pastebuf_match_path_full(FCurve *fcu, const short from_ { tAnimCopybufItem *aci; - for (aci= animcopybuf.first; aci; aci= aci->next) { + for (aci = animcopybuf.first; aci; aci = aci->next) { /* check that paths exist */ if (to_simple || (aci->rna_path && fcu->rna_path)) { if (to_simple || (strcmp(aci->rna_path, fcu->rna_path) == 0)) { @@ -606,7 +606,7 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f { tAnimCopybufItem *aci; - for (aci= animcopybuf.first; aci; aci= aci->next) { + for (aci = animcopybuf.first; aci; aci = aci->next) { /* check that paths exist */ if (aci->rna_path && fcu->rna_path) { /* find the property of the fcurve and compare against the end of the tAnimCopybufItem @@ -627,12 +627,12 @@ static tAnimCopybufItem *pastebuf_match_path_property(FCurve *fcu, const short f RNA_path_resolve(&id_ptr, aci->rna_path, &rptr, &prop); if (prop) { - const char *identifier= RNA_property_identifier(prop); + const char *identifier = RNA_property_identifier(prop); int len_id = strlen(identifier); int len_path = strlen(fcu->rna_path); if (len_id <= len_path) { /* note, paths which end with "] will fail with this test - Animated ID Props */ - if (strcmp(identifier, fcu->rna_path + (len_path-len_id))==0) { + if (strcmp(identifier, fcu->rna_path + (len_path - len_id)) == 0) { if ((from_single) || (aci->array_index == fcu->array_index)) break; } @@ -653,7 +653,7 @@ static tAnimCopybufItem *pastebuf_match_index_only(FCurve *fcu, const short from { tAnimCopybufItem *aci; - for (aci= animcopybuf.first; aci; aci= aci->next) { + for (aci = animcopybuf.first; aci; aci = aci->next) { /* check that paths exist */ if ((from_single) || (aci->array_index == fcu->array_index)) { break; @@ -672,7 +672,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float int i; /* First de-select existing FCuvre */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { bezt->f2 &= ~SELECT; } @@ -693,19 +693,19 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float float f_min; float f_max; - if (merge_mode==KEYFRAME_PASTE_MERGE_OVER_RANGE) { - f_min= aci->bezt[0].vec[1][0] + offset; - f_max= aci->bezt[aci->totvert-1].vec[1][0] + offset; + if (merge_mode == KEYFRAME_PASTE_MERGE_OVER_RANGE) { + f_min = aci->bezt[0].vec[1][0] + offset; + f_max = aci->bezt[aci->totvert - 1].vec[1][0] + offset; } else { /* Entire Range */ - f_min= animcopy_firstframe + offset; - f_max= animcopy_lastframe + offset; + f_min = animcopy_firstframe + offset; + f_max = animcopy_lastframe + offset; } /* remove keys in range */ if (f_min < f_max) { /* select verts in range for removal */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if ((f_min < bezt[0].vec[1][0]) && (bezt[0].vec[1][0] < f_max)) { bezt->f2 |= SELECT; } @@ -719,7 +719,7 @@ static void paste_animedit_keys_fcurve(FCurve *fcu, tAnimCopybufItem *aci, float } /* just start pasting, with the the first keyframe on the current frame, and so on */ - for (i=0, bezt=aci->bezt; i < aci->totvert; i++, bezt++) { + for (i = 0, bezt = aci->bezt; i < aci->totvert; i++, bezt++) { /* temporarily apply offset to src beztriple while copying */ bezt->vec[0][0] += offset; bezt->vec[1][0] += offset; @@ -765,10 +765,10 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, { bAnimListElem *ale; - const Scene *scene= (ac->scene); + const Scene *scene = (ac->scene); - const short from_single= (animcopybuf.first == animcopybuf.last); - const short to_simple= (anim_data->first == anim_data->last); + const short from_single = (animcopybuf.first == animcopybuf.last); + const short to_simple = (anim_data->first == anim_data->last); float offset = 0.0f; int pass; @@ -787,16 +787,16 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, /* mathods of offset */ switch (offset_mode) { case KEYFRAME_PASTE_OFFSET_CFRA_START: - offset= (float)(CFRA - animcopy_firstframe); + offset = (float)(CFRA - animcopy_firstframe); break; case KEYFRAME_PASTE_OFFSET_CFRA_END: - offset= (float)(CFRA - animcopy_lastframe); + offset = (float)(CFRA - animcopy_lastframe); break; case KEYFRAME_PASTE_OFFSET_CFRA_RELATIVE: - offset= (float)(CFRA - animcopy_cfra); + offset = (float)(CFRA - animcopy_cfra); break; case KEYFRAME_PASTE_OFFSET_NONE: - offset= 0.0f; + offset = 0.0f; break; } @@ -805,44 +805,44 @@ short paste_animedit_keys(bAnimContext *ac, ListBase *anim_data, FCurve *fcu; tAnimCopybufItem *aci; - ale= anim_data->first; - fcu= (FCurve *)ale->data; /* destination F-Curve */ - aci= animcopybuf.first; + ale = anim_data->first; + fcu = (FCurve *)ale->data; /* destination F-Curve */ + aci = animcopybuf.first; paste_animedit_keys_fcurve(fcu, aci, offset, merge_mode); } else { /* from selected channels - * This "passes" system aims to try to find "matching" channels to paste keyframes - * into with increasingly loose matching heuristics. The process finishes when at least - * one F-Curve has been pasted into. + * This "passes" system aims to try to find "matching" channels to paste keyframes + * into with increasingly loose matching heuristics. The process finishes when at least + * one F-Curve has been pasted into. */ - for (pass= 0; pass < 3; pass++) { - unsigned int totmatch= 0; + for (pass = 0; pass < 3; pass++) { + unsigned int totmatch = 0; - for (ale= anim_data->first; ale; ale= ale->next) { + for (ale = anim_data->first; ale; ale = ale->next) { /* find buffer item to paste from * - if names don't matter (i.e. only 1 channel in buffer), don't check id/group * - if names do matter, only check if id-type is ok for now (group check is not that important) * - most importantly, rna-paths should match (array indices are unimportant for now) */ - FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */ - tAnimCopybufItem *aci= NULL; + FCurve *fcu = (FCurve *)ale->data; /* destination F-Curve */ + tAnimCopybufItem *aci = NULL; switch (pass) { case 0: /* most strict, must be exact path match data_path & index */ - aci= pastebuf_match_path_full(fcu, from_single, to_simple); + aci = pastebuf_match_path_full(fcu, from_single, to_simple); break; case 1: /* less strict, just compare property names */ - aci= pastebuf_match_path_property(fcu, from_single, to_simple); + aci = pastebuf_match_path_property(fcu, from_single, to_simple); break; case 2: /* Comparing properties gave no results, so just do index comparisons */ - aci= pastebuf_match_index_only(fcu, from_single, to_simple); + aci = pastebuf_match_index_only(fcu, from_single, to_simple); break; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 9d51b42f1a2..2a68d32557a 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -121,14 +121,14 @@ short ANIM_get_keyframing_flags(Scene *scene, short incl_mode) /* Get (or add relevant data to be able to do so) the Active Action for the given * Animation Data block, given an ID block where the Animation Data should reside. */ -bAction *verify_adt_action (ID *id, short add) +bAction *verify_adt_action(ID *id, short add) { AnimData *adt; /* init animdata if none available yet */ - adt= BKE_animdata_from_id(id); + adt = BKE_animdata_from_id(id); if ((adt == NULL) && (add)) - adt= BKE_id_add_animdata(id); + adt = BKE_id_add_animdata(id); if (adt == NULL) { /* if still none (as not allowed to add, or ID doesn't have animdata for some reason) */ printf("ERROR: Couldn't add AnimData (ID = %s)\n", (id) ? (id->name) : ""); @@ -138,9 +138,9 @@ bAction *verify_adt_action (ID *id, short add) /* init action if none available yet */ // TODO: need some wizardry to handle NLA stuff correct if ((adt->action == NULL) && (add)) { - char actname[sizeof(id->name)-2]; - BLI_snprintf(actname, sizeof(actname), "%sAction", id->name+2); - adt->action= add_empty_action(actname); + char actname[sizeof(id->name) - 2]; + BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); + adt->action = add_empty_action(actname); } /* return the action */ @@ -150,7 +150,7 @@ bAction *verify_adt_action (ID *id, short add) /* Get (or add relevant data to be able to do so) F-Curve from the Active Action, * for the given Animation Data block. This assumes that all the destinations are valid. */ -FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], const int array_index, short add) +FCurve *verify_fcurve(bAction *act, const char group[], const char rna_path[], const int array_index, short add) { bActionGroup *grp; FCurve *fcu; @@ -164,30 +164,30 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], * TODO: add auto-grouping support? how this works will need to be resolved */ if (act) - fcu= list_find_fcurve(&act->curves, rna_path, array_index); + fcu = list_find_fcurve(&act->curves, rna_path, array_index); else - fcu= NULL; + fcu = NULL; if ((fcu == NULL) && (add)) { /* use default settings to make a F-Curve */ - fcu= MEM_callocN(sizeof(FCurve), "FCurve"); + fcu = MEM_callocN(sizeof(FCurve), "FCurve"); - fcu->flag = (FCURVE_VISIBLE|FCURVE_SELECTED); - if (act->curves.first==NULL) - fcu->flag |= FCURVE_ACTIVE; /* first one added active */ + fcu->flag = (FCURVE_VISIBLE | FCURVE_SELECTED); + if (act->curves.first == NULL) + fcu->flag |= FCURVE_ACTIVE; /* first one added active */ /* store path - make copy, and store that */ - fcu->rna_path= BLI_strdupn(rna_path, strlen(rna_path)); - fcu->array_index= array_index; + fcu->rna_path = BLI_strdupn(rna_path, strlen(rna_path)); + fcu->array_index = array_index; /* if a group name has been provided, try to add or find a group, then add F-Curve to it */ if (group) { /* try to find group */ - grp= action_groups_find_named(act, group); + grp = BKE_action_group_find_name(act, group); /* no matching groups, so add one */ if (grp == NULL) - grp= action_groups_add_new(act, group); + grp = action_groups_add_new(act, group); /* add F-Curve to group */ action_groups_add_channel(act, grp, fcu); @@ -212,11 +212,11 @@ FCurve *verify_fcurve (bAction *act, const char group[], const char rna_path[], * suitable place in chronological order. * * NOTE: any recalculate of the F-Curve that needs to be done will need to - * be done by the caller. + * be done by the caller. */ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) { - int i= 0; + int i = 0; /* are there already keyframes? */ if (fcu->bezt) { @@ -228,17 +228,17 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) /* sanity check: 'i' may in rare cases exceed arraylen */ if ((i >= 0) && (i < fcu->totvert)) { /* just change the values when replacing, so as to not overwrite handles */ - BezTriple *dst= (fcu->bezt + i); - float dy= bezt->vec[1][1] - dst->vec[1][1]; + BezTriple *dst = (fcu->bezt + i); + float dy = bezt->vec[1][1] - dst->vec[1][1]; /* just apply delta value change to the handle values */ dst->vec[0][1] += dy; dst->vec[1][1] += dy; dst->vec[2][1] += dy; - dst->f1= bezt->f1; - dst->f2= bezt->f2; - dst->f3= bezt->f3; + dst->f1 = bezt->f1; + dst->f2 = bezt->f2; + dst->f3 = bezt->f3; // TODO: perform some other operations? } @@ -246,22 +246,22 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) /* keyframing modes allow to not replace keyframe */ else if ((flag & INSERTKEY_REPLACE) == 0) { /* insert new - if we're not restricted to replacing keyframes only */ - BezTriple *newb= MEM_callocN((fcu->totvert+1)*sizeof(BezTriple), "beztriple"); + BezTriple *newb = MEM_callocN((fcu->totvert + 1) * sizeof(BezTriple), "beztriple"); /* add the beztriples that should occur before the beztriple to be pasted (originally in fcu) */ if (i > 0) - memcpy(newb, fcu->bezt, i*sizeof(BezTriple)); + memcpy(newb, fcu->bezt, i * sizeof(BezTriple)); /* add beztriple to paste at index i */ - *(newb + i)= *bezt; + *(newb + i) = *bezt; /* add the beztriples that occur after the beztriple to be pasted (originally in fcu) */ if (i < fcu->totvert) - memcpy(newb+i+1, fcu->bezt+i, (fcu->totvert-i)*sizeof(BezTriple)); + memcpy(newb + i + 1, fcu->bezt + i, (fcu->totvert - i) * sizeof(BezTriple)); /* replace (+ free) old with new, only if necessary to do so */ MEM_freeN(fcu->bezt); - fcu->bezt= newb; + fcu->bezt = newb; fcu->totvert++; } @@ -272,11 +272,11 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) * // NOTE: maybe we may want to allow this later when doing samples -> bezt conversions, * // but for now, having both is asking for trouble */ - else if ((flag & INSERTKEY_REPLACE)==0 && (fcu->fpt==NULL)) { + else if ((flag & INSERTKEY_REPLACE) == 0 && (fcu->fpt == NULL)) { /* create new keyframes array */ - fcu->bezt= MEM_callocN(sizeof(BezTriple), "beztriple"); - *(fcu->bezt)= *bezt; - fcu->totvert= 1; + fcu->bezt = MEM_callocN(sizeof(BezTriple), "beztriple"); + *(fcu->bezt) = *bezt; + fcu->totvert = 1; } /* cannot add anything */ else { @@ -297,25 +297,25 @@ int insert_bezt_fcurve(FCurve *fcu, BezTriple *bezt, short flag) */ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag) { - BezTriple beztr= {{{0}}}; + BezTriple beztr = {{{0}}}; unsigned int oldTot = fcu->totvert; int a; /* set all three points, for nicer start position * NOTE: +/- 1 on vec.x for left and right handles is so that 'free' handles work ok... */ - beztr.vec[0][0]= x-1.0f; - beztr.vec[0][1]= y; - beztr.vec[1][0]= x; - beztr.vec[1][1]= y; - beztr.vec[2][0]= x+1.0f; - beztr.vec[2][1]= y; - beztr.f1= beztr.f2= beztr.f3= SELECT; - beztr.h1= beztr.h2= U.keyhandles_new; /* use default handle type here */ + beztr.vec[0][0] = x - 1.0f; + beztr.vec[0][1] = y; + beztr.vec[1][0] = x; + beztr.vec[1][1] = y; + beztr.vec[2][0] = x + 1.0f; + beztr.vec[2][1] = y; + beztr.f1 = beztr.f2 = beztr.f3 = SELECT; + beztr.h1 = beztr.h2 = U.keyhandles_new; /* use default handle type here */ //BEZKEYTYPE(&beztr)= scene->keytype; /* default keyframe type */ /* use default interpolation mode, with exceptions for int/discrete values */ - beztr.ipo= U.ipo_new; + beztr.ipo = U.ipo_new; if (fcu->flag & FCURVE_DISCRETE_VALUES) beztr.ipo = BEZT_IPO_CONST; @@ -323,7 +323,7 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag) beztr.ipo = BEZT_IPO_LIN; /* add temp beztriple to keyframes */ - a= insert_bezt_fcurve(fcu, &beztr, flag); + a = insert_bezt_fcurve(fcu, &beztr, flag); /* what if 'a' is a negative index? * for now, just exit to prevent any segfaults @@ -338,18 +338,18 @@ int insert_vert_fcurve(FCurve *fcu, float x, float y, short flag) calchandles_fcurve(fcu); /* set handletype and interpolation */ - if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE)==0) { - BezTriple *bezt= (fcu->bezt + a); + if ((fcu->totvert > 2) && (flag & INSERTKEY_REPLACE) == 0) { + BezTriple *bezt = (fcu->bezt + a); /* set interpolation from previous (if available), but only if we didn't just replace some keyframe - * - replacement is indicated by no-change in number of verts + * - replacement is indicated by no-change in number of verts * - when replacing, the user may have specified some interpolation that should be kept */ if (fcu->totvert > oldTot) { if (a > 0) - bezt->ipo= (bezt-1)->ipo; - else if (a < fcu->totvert-1) - bezt->ipo= (bezt+1)->ipo; + bezt->ipo = (bezt - 1)->ipo; + else if (a < fcu->totvert - 1) + bezt->ipo = (bezt + 1)->ipo; } /* don't recalculate handles if fast is set @@ -379,33 +379,33 @@ enum { * 2. Keyframe to be added on frame where two keyframes are already situated * 3. Keyframe lies at point that intersects the linear line between two keyframes */ -static short new_key_needed (FCurve *fcu, float cFrame, float nValue) +static short new_key_needed(FCurve *fcu, float cFrame, float nValue) { - BezTriple *bezt=NULL, *prev=NULL; + BezTriple *bezt = NULL, *prev = NULL; int totCount, i; float valA = 0.0f, valB = 0.0f; /* safety checking */ if (fcu == NULL) return KEYNEEDED_JUSTADD; - totCount= fcu->totvert; + totCount = fcu->totvert; if (totCount == 0) return KEYNEEDED_JUSTADD; /* loop through checking if any are the same */ - bezt= fcu->bezt; - for (i=0; ibezt; + for (i = 0; i < totCount; i++) { + float prevPosi = 0.0f, prevVal = 0.0f; + float beztPosi = 0.0f, beztVal = 0.0f; /* get current time+value */ - beztPosi= bezt->vec[1][0]; - beztVal= bezt->vec[1][1]; + beztPosi = bezt->vec[1][0]; + beztVal = bezt->vec[1][1]; if (prev) { /* there is a keyframe before the one currently being examined */ /* get previous time+value */ - prevPosi= prev->vec[1][0]; - prevVal= prev->vec[1][1]; + prevPosi = prev->vec[1][0]; + prevVal = prev->vec[1][1]; /* keyframe to be added at point where there are already two similar points? */ if (IS_EQF(prevPosi, cFrame) && IS_EQF(beztPosi, cFrame) && IS_EQF(beztPosi, prevPosi)) { @@ -422,7 +422,7 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) float realVal; /* get real value of curve at that point */ - realVal= evaluate_fcurve(fcu, cFrame); + realVal = evaluate_fcurve(fcu, cFrame); /* compare whether it's the same as proposed */ if (IS_EQF(realVal, nValue)) @@ -448,13 +448,13 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) /* just add a keyframe if there's only one keyframe * and the new one occurs before the existing one does. */ - if ((cFrame < beztPosi) && (totCount==1)) + if ((cFrame < beztPosi) && (totCount == 1)) return KEYNEEDED_JUSTADD; } /* continue. frame to do not yet passed (or other conditions not met) */ - if (i < (totCount-1)) { - prev= bezt; + if (i < (totCount - 1)) { + prev = bezt; bezt++; } else @@ -468,13 +468,13 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) * -> Otherwise, a keyframe is just added. 1.0 is added so that fake-2nd-to-last * keyframe is not equal to last keyframe. */ - bezt= (fcu->bezt + (fcu->totvert - 1)); - valA= bezt->vec[1][1]; + bezt = (fcu->bezt + (fcu->totvert - 1)); + valA = bezt->vec[1][1]; if (prev) - valB= prev->vec[1][1]; + valB = prev->vec[1][1]; else - valB= bezt->vec[1][1] + 1.0f; + valB = bezt->vec[1][1] + 1.0f; if (IS_EQF(valA, nValue) && IS_EQF(valA, valB)) return KEYNEEDED_DELPREV; @@ -485,31 +485,31 @@ static short new_key_needed (FCurve *fcu, float cFrame, float nValue) /* ------------------ RNA Data-Access Functions ------------------ */ /* Try to read value using RNA-properties obtained already */ -static float setting_get_rna_value (PointerRNA *ptr, PropertyRNA *prop, int index) +static float setting_get_rna_value(PointerRNA *ptr, PropertyRNA *prop, int index) { - float value= 0.0f; + float value = 0.0f; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: if (RNA_property_array_length(ptr, prop)) - value= (float)RNA_property_boolean_get_index(ptr, prop, index); + value = (float)RNA_property_boolean_get_index(ptr, prop, index); else - value= (float)RNA_property_boolean_get(ptr, prop); + value = (float)RNA_property_boolean_get(ptr, prop); break; case PROP_INT: if (RNA_property_array_length(ptr, prop)) - value= (float)RNA_property_int_get_index(ptr, prop, index); + value = (float)RNA_property_int_get_index(ptr, prop, index); else - value= (float)RNA_property_int_get(ptr, prop); + value = (float)RNA_property_int_get(ptr, prop); break; case PROP_FLOAT: if (RNA_property_array_length(ptr, prop)) - value= RNA_property_float_get_index(ptr, prop, index); + value = RNA_property_float_get_index(ptr, prop, index); else - value= RNA_property_float_get(ptr, prop); + value = RNA_property_float_get(ptr, prop); break; case PROP_ENUM: - value= (float)RNA_property_enum_get(ptr, prop); + value = (float)RNA_property_enum_get(ptr, prop); break; default: break; @@ -534,12 +534,12 @@ enum { * blocktypes, when using "standard" keying but 'Visual Keying' option in Auto-Keying * settings is on. */ -static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) +static short visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) { - bConstraint *con= NULL; - short searchtype= VISUALKEY_NONE; + bConstraint *con = NULL; + short searchtype = VISUALKEY_NONE; short has_parent = FALSE; - const char *identifier= NULL; + const char *identifier = NULL; /* validate data */ // TODO: this check is probably not needed, but it won't hurt @@ -547,25 +547,25 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 0; /* get first constraint and determine type of keyframe constraints to check for - * - constraints can be on either Objects or PoseChannels, so we only check if the + * - constraints can be on either Objects or PoseChannels, so we only check if the * ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for * those structs, allowing us to identify the owner of the data */ if (ptr->type == &RNA_Object) { /* Object */ - Object *ob= (Object *)ptr->data; + Object *ob = (Object *)ptr->data; - con= ob->constraints.first; - identifier= RNA_property_identifier(prop); - has_parent= (ob->parent != NULL); + con = ob->constraints.first; + identifier = RNA_property_identifier(prop); + has_parent = (ob->parent != NULL); } else if (ptr->type == &RNA_PoseBone) { /* Pose Channel */ - bPoseChannel *pchan= (bPoseChannel *)ptr->data; + bPoseChannel *pchan = (bPoseChannel *)ptr->data; - con= pchan->constraints.first; - identifier= RNA_property_identifier(prop); - has_parent= (pchan->parent != NULL); + con = pchan->constraints.first; + identifier = RNA_property_identifier(prop); + has_parent = (pchan->parent != NULL); } /* check if any data to search using */ @@ -578,10 +578,10 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 0; } else if (strstr(identifier, "location")) { - searchtype= VISUALKEY_LOC; + searchtype = VISUALKEY_LOC; } else if (strstr(identifier, "rotation")) { - searchtype= VISUALKEY_ROT; + searchtype = VISUALKEY_ROT; } else { printf("%s failed: identifier - '%s'\n", __func__, identifier); @@ -596,7 +596,7 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) return 1; /* constraints */ - for (; con; con= con->next) { + for (; con; con = con->next) { /* only consider constraint if it is not disabled, and has influence */ if (con->flag & CONSTRAINT_DISABLE) continue; if (con->enforce == 0.0f) continue; @@ -616,28 +616,28 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) /* single-transform constraits */ case CONSTRAINT_TYPE_TRACKTO: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_ROTLIMIT: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_LOCLIMIT: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; case CONSTRAINT_TYPE_ROTLIKE: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_DISTLIMIT: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; case CONSTRAINT_TYPE_LOCLIKE: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; case CONSTRAINT_TYPE_LOCKTRACK: - if (searchtype==VISUALKEY_ROT) return 1; + if (searchtype == VISUALKEY_ROT) return 1; break; case CONSTRAINT_TYPE_MINMAX: - if (searchtype==VISUALKEY_LOC) return 1; + if (searchtype == VISUALKEY_LOC) return 1; break; default: @@ -654,18 +654,18 @@ static short visualkey_can_use (PointerRNA *ptr, PropertyRNA *prop) * In the event that it is not possible to perform visual keying, try to fall-back * to using the default method. Assumes that all data it has been passed is valid. */ -static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_index) +static float visualkey_get_value(PointerRNA *ptr, PropertyRNA *prop, int array_index) { - const char *identifier= RNA_property_identifier(prop); + const char *identifier = RNA_property_identifier(prop); /* handle for Objects or PoseChannels only - * - constraints can be on either Objects or PoseChannels, so we only check if the + * - constraints can be on either Objects or PoseChannels, so we only check if the * ptr->type is RNA_Object or RNA_PoseBone, which are the RNA wrapping-info for - * those structs, allowing us to identify the owner of the data + * those structs, allowing us to identify the owner of the data * - assume that array_index will be sane */ if (ptr->type == &RNA_Object) { - Object *ob= (Object *)ptr->data; + Object *ob = (Object *)ptr->data; /* only Location or Rotation keyframes are supported now */ if (strstr(identifier, "location")) { @@ -699,7 +699,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ } else if (ptr->type == &RNA_PoseBone) { Object *ob = (Object *)ptr->id.data; /* we assume that this is always set, and is an object */ - bPoseChannel *pchan= (bPoseChannel *)ptr->data; + bPoseChannel *pchan = (bPoseChannel *)ptr->data; float tmat[4][4]; /* Although it is not strictly required for this particular space conversion, @@ -752,7 +752,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ /* ------------------------- Insert Key API ------------------------- */ /* Secondary Keyframing API call: - * Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary + * Use this when validation of necessary animation data is not necessary, since an RNA-pointer to the necessary * data being keyframed, and a pointer to the F-Curve to use have both been provided. * * The flag argument is used for special settings that alter the behavior of @@ -761,7 +761,7 @@ static float visualkey_get_value (PointerRNA *ptr, PropertyRNA *prop, int array_ */ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float cfra, short flag) { - float curval= 0.0f; + float curval = 0.0f; /* no F-Curve to add keyframe to? */ if (fcu == NULL) { @@ -771,13 +771,13 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* F-Curve not editable? */ if (fcurve_is_keyframable(fcu) == 0) { BKE_reportf(reports, RPT_ERROR, - "F-Curve with path = '%s' [%d] cannot be keyframed. Ensure that it is not locked or sampled. Also, try removing F-Modifiers", - fcu->rna_path, fcu->array_index); + "F-Curve with path = '%s' [%d] cannot be keyframed. Ensure that it is not locked or sampled. Also, try removing F-Modifiers", + fcu->rna_path, fcu->array_index); return 0; } /* if no property given yet, try to validate from F-Curve info */ - if ((ptr.id.data == NULL) && (ptr.data==NULL)) { + if ((ptr.id.data == NULL) && (ptr.data == NULL)) { BKE_report(reports, RPT_ERROR, "No RNA-pointer available to retrieve values for keyframing from"); return 0; } @@ -787,21 +787,21 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* try to get property we should be affecting */ if ((RNA_path_resolve(&ptr, fcu->rna_path, &tmp_ptr, &prop) == 0) || (prop == NULL)) { /* property not found... */ - const char *idname= (ptr.id.data) ? ((ID *)ptr.id.data)->name : ""; + const char *idname = (ptr.id.data) ? ((ID *)ptr.id.data)->name : ""; BKE_reportf(reports, RPT_ERROR, - "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - idname, fcu->rna_path); + "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + idname, fcu->rna_path); return 0; } else { /* property found, so overwrite 'ptr' to make later code easier */ - ptr= tmp_ptr; + ptr = tmp_ptr; } } /* set additional flags for the F-Curve (i.e. only integer values) */ - fcu->flag &= ~(FCURVE_INT_VALUES|FCURVE_DISCRETE_VALUES); + fcu->flag &= ~(FCURVE_INT_VALUES | FCURVE_DISCRETE_VALUES); switch (RNA_property_type(prop)) { case PROP_FLOAT: /* do nothing */ @@ -815,23 +815,23 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p * values at all) interpolation between all points * - however, we must also ensure that evaluated values are only integers still */ - fcu->flag |= (FCURVE_DISCRETE_VALUES|FCURVE_INT_VALUES); + fcu->flag |= (FCURVE_DISCRETE_VALUES | FCURVE_INT_VALUES); break; } /* obtain value to give keyframe */ if ( (flag & INSERTKEY_MATRIX) && - (visualkey_can_use(&ptr, prop)) ) + (visualkey_can_use(&ptr, prop)) ) { /* visual-keying is only available for object and pchan datablocks, as * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ - curval= visualkey_get_value(&ptr, prop, fcu->array_index); + curval = visualkey_get_value(&ptr, prop, fcu->array_index); } else { /* read value from system */ - curval= setting_get_rna_value(&ptr, prop, fcu->array_index); + curval = setting_get_rna_value(&ptr, prop, fcu->array_index); } /* only insert keyframes where they are needed */ @@ -839,7 +839,7 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p short insert_mode; /* check whether this curve really needs a new keyframe */ - insert_mode= new_key_needed(fcu, cfra, curval); + insert_mode = new_key_needed(fcu, cfra, curval); /* insert new keyframe at current frame */ if (insert_mode) @@ -848,7 +848,7 @@ short insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *p /* delete keyframe immediately before/after newly added */ switch (insert_mode) { case KEYNEEDED_DELPREV: - delete_fcurve_key(fcu, fcu->totvert-2, 1); + delete_fcurve_key(fcu, fcu->totvert - 2, 1); break; case KEYNEEDED_DELNEXT: delete_fcurve_key(fcu, 1, 1); @@ -885,8 +885,8 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou PointerRNA id_ptr, ptr; PropertyRNA *prop = NULL; FCurve *fcu; - int array_index_max= array_index+1; - int ret= 0; + int array_index_max = array_index + 1; + int ret = 0; /* validate pointer first - exit if failure */ if (id == NULL) { @@ -897,33 +897,33 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou RNA_id_pointer_create(id, &id_ptr); if ((RNA_path_resolve(&id_ptr, rna_path, &ptr, &prop) == 0) || (prop == NULL)) { BKE_reportf(reports, RPT_ERROR, - "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", - (id)? id->name : "", rna_path); + "Could not insert keyframe, as RNA Path is invalid for the given ID (ID = %s, Path = %s)", + (id) ? id->name : "", rna_path); return 0; } /* if no action is provided, keyframe to the default one attached to this ID-block */ if (act == NULL) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* get action to add F-Curve+keyframe to */ - act= verify_adt_action(id, 1); + act = verify_adt_action(id, 1); if (act == NULL) { BKE_reportf(reports, RPT_ERROR, - "Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)", - id->name, rna_path); + "Could not insert keyframe, as this type does not support animation data (ID = %s, Path = %s)", + id->name, rna_path); return 0; } /* apply NLA-mapping to frame to use (if applicable) */ - cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } /* key entire array convenience method */ if (array_index == -1) { - array_index= 0; - array_index_max= RNA_property_array_length(&ptr, prop); + array_index = 0; + array_index_max = RNA_property_array_length(&ptr, prop); /* for single properties, increase max_index so that the property itself gets included, * but don't do this for standard arrays since that can cause corruption issues @@ -939,7 +939,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * - if we're replacing keyframes only, DO NOT create new F-Curves if they do not exist yet * but still try to get the F-Curve if it exists... */ - fcu= verify_fcurve(act, group, rna_path, array_index, (flag & INSERTKEY_REPLACE)==0); + fcu = verify_fcurve(act, group, rna_path, array_index, (flag & INSERTKEY_REPLACE) == 0); /* we may not have a F-Curve when we're replacing only... */ if (fcu) { @@ -949,7 +949,7 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou * is determined by the array index for the F-Curve */ if (ELEM5(RNA_property_subtype(prop), PROP_TRANSLATION, PROP_XYZ, PROP_EULER, PROP_COLOR, PROP_COORDS)) { - fcu->color_mode= FCURVE_COLOR_AUTO_RGB; + fcu->color_mode = FCURVE_COLOR_AUTO_RGB; } } @@ -973,11 +973,11 @@ short insert_keyframe(ReportList *reports, ID *id, bAction *act, const char grou */ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short UNUSED(flag)) { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); PointerRNA id_ptr, ptr; PropertyRNA *prop; - int array_index_max= array_index+1; - int ret= 0; + int array_index_max = array_index + 1; + int ret = 0; /* sanity checks */ if (ELEM(NULL, id, adt)) { @@ -994,17 +994,17 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* get F-Curve * Note: here is one of the places where we don't want new Action + F-Curve added! - * so 'add' var must be 0 + * so 'add' var must be 0 */ if (act == NULL) { /* if no action is provided, use the default one attached to this ID-block - * - if it doesn't exist, then we're out of options... + * - if it doesn't exist, then we're out of options... */ if (adt->action) { - act= adt->action; + act = adt->action; /* apply NLA-mapping to frame to use (if applicable) */ - cfra= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); } else { BKE_reportf(reports, RPT_ERROR, "No Action to delete keyframes from for ID = %s\n", id->name); @@ -1014,8 +1014,8 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* key entire array convenience method */ if (array_index == -1) { - array_index= 0; - array_index_max= RNA_property_array_length(&ptr, prop); + array_index = 0; + array_index_max = RNA_property_array_length(&ptr, prop); /* for single properties, increase max_index so that the property itself gets included, * but don't do this for standard arrays since that can cause corruption issues @@ -1027,7 +1027,7 @@ short delete_keyframe(ReportList *reports, ID *id, bAction *act, const char grou /* will only loop once unless the array index was -1 */ for (; array_index < array_index_max; array_index++) { - FCurve *fcu= verify_fcurve(act, group, rna_path, array_index, 0); + FCurve *fcu = verify_fcurve(act, group, rna_path, array_index, 0); short found = -1; int i; @@ -1075,9 +1075,9 @@ enum { */ static int modify_key_op_poll(bContext *C) { - ScrArea *sa= CTX_wm_area(C); - Scene *scene= CTX_data_scene(C); - SpaceOops *so= CTX_wm_space_outliner(C); + ScrArea *sa = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *so = CTX_wm_space_outliner(C); /* if no area or active scene */ if (ELEM(NULL, sa, scene)) @@ -1099,13 +1099,13 @@ static int modify_key_op_poll(bContext *C) /* Insert Key Operator ------------------------ */ -static int insert_key_exec (bContext *C, wmOperator *op) +static int insert_key_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= NULL; - int type= RNA_enum_get(op->ptr, "type"); - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = NULL; + int type = RNA_enum_get(op->ptr, "type"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; /* type is the Keying Set the user specified to use when calling the operator: @@ -1114,11 +1114,11 @@ static int insert_key_exec (bContext *C, wmOperator *op) * - type < 0: use a builtin Keying Set */ if (type == 0) - type= scene->active_keyingset; + type = scene->active_keyingset; if (type > 0) - ks= BLI_findlink(&scene->keyingsets, type-1); + ks = BLI_findlink(&scene->keyingsets, type - 1); else - ks= BLI_findlink(&builtin_keyingsets, -type-1); + ks = BLI_findlink(&builtin_keyingsets, -type - 1); /* report failures */ if (ks == NULL) { @@ -1127,7 +1127,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) } /* try to insert keyframes for the channels specified by KeyingSet */ - success= ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); + success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_INSERT, cfra); if (G.debug & G_DEBUG) BKE_reportf(op->reports, RPT_INFO, "KeyingSet '%s' - Successfully added %d Keyframes\n", ks->name, success); @@ -1142,7 +1142,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "Successfully added %d Keyframes for KeyingSet '%s'", success, ks->name); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else BKE_report(op->reports, RPT_WARNING, "Keying Set failed to insert any keyframes"); @@ -1167,10 +1167,10 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) ot->poll = modify_key_op_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1178,8 +1178,8 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) /* confirm whether a keyframe was added by showing a popup * - by default, this is enabled, since this operator is assumed to be called independently */ - prop= RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", - "Show a popup when the keyframes get successfully added"); + prop = RNA_def_boolean(ot->srna, "confirm_success", 1, "Confirm Successful Insert", + "Show a popup when the keyframes get successfully added"); RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -1188,9 +1188,9 @@ void ANIM_OT_keyframe_insert(wmOperatorType *ot) * then calls the menu if necessary before */ -static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int insert_key_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); /* if prompting or no active Keying Set, show the menu */ if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) { @@ -1229,10 +1229,10 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot) ot->poll = ED_operator_areaactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1241,27 +1241,27 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot) * - by default, this is disabled so that if a menu is shown, this doesn't come up too */ // XXX should this just be always on? - prop= RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", - "Show a popup when the keyframes get successfully added"); + prop = RNA_def_boolean(ot->srna, "confirm_success", 0, "Confirm Successful Insert", + "Show a popup when the keyframes get successfully added"); RNA_def_property_flag(prop, PROP_HIDDEN); /* whether the menu should always be shown * - by default, the menu should only be shown when there is no active Keying Set (2.5 behavior), * although in some cases it might be useful to always shown (pre 2.5 behavior) */ - prop= RNA_def_boolean(ot->srna, "always_prompt", 0, "Always Show Menu", ""); + prop = RNA_def_boolean(ot->srna, "always_prompt", 0, "Always Show Menu", ""); RNA_def_property_flag(prop, PROP_HIDDEN); } /* Delete Key Operator ------------------------ */ -static int delete_key_exec (bContext *C, wmOperator *op) +static int delete_key_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= NULL; - int type= RNA_enum_get(op->ptr, "type"); - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = NULL; + int type = RNA_enum_get(op->ptr, "type"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap short success; /* type is the Keying Set the user specified to use when calling the operator: @@ -1270,11 +1270,11 @@ static int delete_key_exec (bContext *C, wmOperator *op) * - type < 0: use a builtin Keying Set */ if (type == 0) - type= scene->active_keyingset; + type = scene->active_keyingset; if (type > 0) - ks= BLI_findlink(&scene->keyingsets, type-1); + ks = BLI_findlink(&scene->keyingsets, type - 1); else - ks= BLI_findlink(&builtin_keyingsets, -type-1); + ks = BLI_findlink(&builtin_keyingsets, -type - 1); /* report failure */ if (ks == NULL) { @@ -1283,7 +1283,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) } /* try to delete keyframes for the channels specified by KeyingSet */ - success= ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); + success = ANIM_apply_keyingset(C, NULL, NULL, ks, MODIFYKEY_MODE_DELETE, cfra); if (G.debug & G_DEBUG) printf("KeyingSet '%s' - Successfully removed %d Keyframes\n", ks->name, success); @@ -1298,7 +1298,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) BKE_reportf(op->reports, RPT_INFO, "Successfully removed %d Keyframes for KeyingSet '%s'", success, ks->name); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } else BKE_report(op->reports, RPT_WARNING, "Keying Set failed to remove any keyframes"); @@ -1323,10 +1323,10 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) ot->poll = modify_key_op_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); RNA_def_property_flag(prop, PROP_HIDDEN); ot->prop = prop; @@ -1346,31 +1346,31 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) * -- Joshua Leung, Jan 2009 */ -static int delete_key_v3d_exec (bContext *C, wmOperator *op) +static int delete_key_v3d_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap // XXX more comprehensive tests will be needed - CTX_DATA_BEGIN (C, Object*, ob, selected_objects) + CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - ID *id= (ID *)ob; + ID *id = (ID *)ob; FCurve *fcu, *fcn; - short success= 0; + short success = 0; /* loop through all curves in animdata and delete keys on this frame */ if ((ob->adt) && (ob->adt->action)) { - AnimData *adt= ob->adt; - bAction *act= adt->action; + AnimData *adt = ob->adt; + bAction *act = adt->action; - for (fcu= act->curves.first; fcu; fcu= fcn) { - fcn= fcu->next; - success+= delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); + for (fcu = act->curves.first; fcu; fcu = fcn) { + fcn = fcu->next; + success += delete_keyframe(op->reports, id, NULL, NULL, fcu->rna_path, fcu->array_index, cfra, 0); } } - BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully had %d keyframes removed", id->name+2, success); + BKE_reportf(op->reports, RPT_INFO, "Ob '%s' - Successfully had %d keyframes removed", id->name + 2, success); ob->recalc |= OB_RECALC_OB; } @@ -1379,7 +1379,7 @@ static int delete_key_v3d_exec (bContext *C, wmOperator *op) /* send updates */ DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); return OPERATOR_FINISHED; } @@ -1398,22 +1398,22 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) ot->poll = ED_operator_areaactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Insert Key Button Operator ------------------------ */ -static int insert_key_button_exec (bContext *C, wmOperator *op) +static int insert_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; char *path; - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap - short success= 0; - int a, index, length, all= RNA_boolean_get(op->ptr, "all"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + short success = 0; + int a, index, length, all = RNA_boolean_get(op->ptr, "all"); short flag = 0; /* flags for inserting keyframes */ @@ -1423,29 +1423,29 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) uiContextActiveProperty(C, &ptr, &prop, &index); if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { if (all) { - length= RNA_property_array_length(&ptr, prop); + length = RNA_property_array_length(&ptr, prop); - if (length) index= 0; - else length= 1; + if (length) index = 0; + else length = 1; } else - length= 1; + length = 1; - for (a=0; areports, ptr.id.data, NULL, NULL, path, index+a, cfra, flag); + for (a = 0; a < length; a++) + success += insert_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, cfra, flag); MEM_freeN(path); } else if (ptr.type == &RNA_NlaStrip) { /* handle special vars for NLA-strips */ - NlaStrip *strip= (NlaStrip *)ptr.data; - FCurve *fcu= list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), flag); + NlaStrip *strip = (NlaStrip *)ptr.data; + FCurve *fcu = list_find_fcurve(&strip->fcurves, RNA_property_identifier(prop), flag); - success+= insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0); + success += insert_keyframe_direct(op->reports, ptr, prop, fcu, cfra, 0); } else { if (G.debug & G_DEBUG) @@ -1468,10 +1468,10 @@ static int insert_key_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) @@ -1479,7 +1479,7 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) /* identifiers */ ot->name = "Insert Keyframe (Buttons)"; ot->idname = "ANIM_OT_keyframe_insert_button"; - ot->description = "Insert a keyframe keyframe for current UI-active property"; + ot->description = "Insert a keyframe for current UI-active property"; /* callbacks */ ot->exec = insert_key_button_exec; @@ -1494,35 +1494,35 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) /* Delete Key Button Operator ------------------------ */ -static int delete_key_button_exec (bContext *C, wmOperator *op) +static int delete_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - PointerRNA ptr= {{NULL}}; - PropertyRNA *prop= NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + PointerRNA ptr = {{NULL}}; + PropertyRNA *prop = NULL; char *path; - float cfra= (float)CFRA; // XXX for now, don't bother about all the yucky offset crap - short success= 0; - int a, index, length, all= RNA_boolean_get(op->ptr, "all"); + float cfra = (float)CFRA; // XXX for now, don't bother about all the yucky offset crap + short success = 0; + int a, index, length, all = RNA_boolean_get(op->ptr, "all"); /* try to insert keyframe using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { if (all) { - length= RNA_property_array_length(&ptr, prop); + length = RNA_property_array_length(&ptr, prop); - if (length) index= 0; - else length= 1; + if (length) index = 0; + else length = 1; } else - length= 1; + length = 1; - for (a=0; areports, ptr.id.data, NULL, NULL, path, index+a, cfra, 0); + for (a = 0; a < length; a++) + success += delete_keyframe(op->reports, ptr.id.data, NULL, NULL, path, index + a, cfra, 0); MEM_freeN(path); } @@ -1541,10 +1541,10 @@ static int delete_key_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* send notifiers that keyframes have been changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) @@ -1570,7 +1570,7 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) int autokeyframe_cfra_can_key(Scene *scene, ID *id) { - float cfra= (float)CFRA; // XXX for now, this will do + float cfra = (float)CFRA; // XXX for now, this will do /* only filter if auto-key mode requires this */ if (IS_AUTOKEY_ON(scene) == 0) @@ -1580,7 +1580,7 @@ int autokeyframe_cfra_can_key(Scene *scene, ID *id) /* can insert anytime we like... */ return 1; } - else /* REPLACE */ { + else { /* REPLACE */ /* for whole block - only key if there's a keyframe on that frame already * this is a valid assumption when we're blocking + tweaking */ @@ -1601,12 +1601,12 @@ short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) return 0; /* we either include all regardless of muting, or only non-muted */ - if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED)==0) { + if ((filter & ANIMFILTER_KEYS_MUTED) || (fcu->flag & FCURVE_MUTED) == 0) { short replace = -1; int i = binarysearch_bezt_index(fcu->bezt, frame, fcu->totvert, &replace); /* binarysearch_bezt_index will set replace to be 0 or 1 - * - obviously, 1 represents a match + * - obviously, 1 represents a match */ if (replace) { /* sanity check: 'i' may in rare cases exceed arraylen */ @@ -1621,7 +1621,7 @@ short fcurve_frame_has_keyframe(FCurve *fcu, float frame, short filter) /* Checks whether an Action has a keyframe for a given frame * Since we're only concerned whether a keyframe exists, we can simply loop until a match is found... */ -static short action_frame_has_keyframe (bAction *act, float frame, short filter) +static short action_frame_has_keyframe(bAction *act, float frame, short filter) { FCurve *fcu; @@ -1636,7 +1636,7 @@ static short action_frame_has_keyframe (bAction *act, float frame, short filter) /* loop over F-Curves, using binary-search to try to find matches * - this assumes that keyframes are only beztriples */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { /* only check if there are keyframes (currently only of type BezTriple) */ if (fcu->bezt && fcu->totvert) { if (fcurve_frame_has_keyframe(fcu, frame, filter)) @@ -1649,7 +1649,7 @@ static short action_frame_has_keyframe (bAction *act, float frame, short filter) } /* Checks whether an Object has a keyframe for a given frame */ -static short object_frame_has_keyframe (Object *ob, float frame, short filter) +static short object_frame_has_keyframe(Object *ob, float frame, short filter) { /* error checking */ if (ob == NULL) @@ -1662,26 +1662,26 @@ static short object_frame_has_keyframe (Object *ob, float frame, short filter) } /* try shapekey keyframes (if available, and allowed by filter) */ - if ( !(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) { - Key *key= ob_get_key(ob); + if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOSKEY) ) { + Key *key = ob_get_key(ob); /* shapekeys can have keyframes ('Relative Shape Keys') * or depend on time (old 'Absolute Shape Keys') */ - /* 1. test for relative (with keyframes) */ + /* 1. test for relative (with keyframes) */ if (id_frame_has_keyframe((ID *)key, frame, filter)) return 1; - /* 2. test for time */ + /* 2. test for time */ // TODO... yet to be implemented (this feature may evolve before then anyway) } /* try materials */ - if ( !(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) { + if (!(filter & ANIMFILTER_KEYS_LOCAL) && !(filter & ANIMFILTER_KEYS_NOMAT) ) { /* if only active, then we can skip a lot of looping */ if (filter & ANIMFILTER_KEYS_ACTIVE) { - Material *ma= give_current_material(ob, (ob->actcol + 1)); + Material *ma = give_current_material(ob, (ob->actcol + 1)); /* we only retrieve the active material... */ if (id_frame_has_keyframe((ID *)ma, frame, filter)) @@ -1691,8 +1691,8 @@ static short object_frame_has_keyframe (Object *ob, float frame, short filter) int a; /* loop over materials */ - for (a=0; atotcol; a++) { - Material *ma= give_current_material(ob, a+1); + for (a = 0; a < ob->totcol; a++) { + Material *ma = give_current_material(ob, a + 1); if (id_frame_has_keyframe((ID *)ma, frame, filter)) return 1; @@ -1723,15 +1723,15 @@ short id_frame_has_keyframe(ID *id, float frame, short filter) // XXX TODO... for now, just use 'normal' behavior // break; - default: /* 'normal type' */ + default: /* 'normal type' */ { - AnimData *adt= BKE_animdata_from_id(id); + AnimData *adt = BKE_animdata_from_id(id); /* only check keyframes in active action */ if (adt) return action_frame_has_keyframe(adt->action, frame, filter); } - break; + break; } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 925cffca288..cd914f9ff9a 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -75,16 +75,16 @@ */ /* poll callback for adding default KeyingSet */ -static int keyingset_poll_default_add (bContext *C) +static int keyingset_poll_default_add(bContext *C) { /* as long as there's an active Scene, it's fine */ return (CTX_data_scene(C) != NULL); } /* poll callback for editing active KeyingSet */ -static int keyingset_poll_active_edit (bContext *C) +static int keyingset_poll_active_edit(bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); if (scene == NULL) return 0; @@ -94,9 +94,9 @@ static int keyingset_poll_active_edit (bContext *C) } /* poll callback for editing active KeyingSet Path */ -static int keyingset_poll_activePath_edit (bContext *C) +static int keyingset_poll_activePath_edit(bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; if (scene == NULL) @@ -104,7 +104,7 @@ static int keyingset_poll_activePath_edit (bContext *C) if (scene->active_keyingset <= 0) return 0; else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* there must be an active KeyingSet and an active path */ return ((ks) && (ks->paths.first) && (ks->active_path > 0)); @@ -113,10 +113,10 @@ static int keyingset_poll_activePath_edit (bContext *C) /* Add a Default (Empty) Keying Set ------------------------- */ -static int add_default_keyingset_exec (bContext *C, wmOperator *UNUSED(op)) +static int add_default_keyingset_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - short flag=0, keyingflag=0; + Scene *scene = CTX_data_scene(C); + short flag = 0, keyingflag = 0; /* validate flags * - absolute KeyingSets should be created by default @@ -129,10 +129,10 @@ static int add_default_keyingset_exec (bContext *C, wmOperator *UNUSED(op)) /* call the API func, and set the active keyingset index */ BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -151,9 +151,9 @@ void ANIM_OT_keying_set_add(wmOperatorType *ot) /* Remove 'Active' Keying Set ------------------------- */ -static int remove_active_keyingset_exec (bContext *C, wmOperator *op) +static int remove_active_keyingset_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; /* verify the Keying Set to use: @@ -169,7 +169,7 @@ static int remove_active_keyingset_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* free KeyingSet's data, then remove it from the scene */ BKE_keyingset_free(ks); @@ -179,7 +179,7 @@ static int remove_active_keyingset_exec (bContext *C, wmOperator *op) scene->active_keyingset--; /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -198,9 +198,9 @@ void ANIM_OT_keying_set_remove(wmOperatorType *ot) /* Add Empty Keying Set Path ------------------------- */ -static int add_empty_ks_path_exec (bContext *C, wmOperator *op) +static int add_empty_ks_path_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks; KS_Path *ksp; @@ -213,16 +213,16 @@ static int add_empty_ks_path_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* don't use the API method for this, since that checks on values... */ - ksp= MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty"); + ksp = MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty"); BLI_addtail(&ks->paths, ksp); - ks->active_path= BLI_countlist(&ks->paths); + ks->active_path = BLI_countlist(&ks->paths); - ksp->groupmode= KSP_GROUP_KSNAME; // XXX? - ksp->idtype= ID_OB; - ksp->flag= KSP_FLAG_WHOLE_ARRAY; + ksp->groupmode = KSP_GROUP_KSNAME; // XXX? + ksp->idtype = ID_OB; + ksp->flag = KSP_FLAG_WHOLE_ARRAY; return OPERATOR_FINISHED; } @@ -241,14 +241,14 @@ void ANIM_OT_keying_set_path_add(wmOperatorType *ot) /* Remove Active Keying Set Path ------------------------- */ -static int remove_active_ks_path_exec (bContext *C, wmOperator *op) +static int remove_active_ks_path_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* if there is a KeyingSet, find the nominated path to remove */ if (ks) { - KS_Path *ksp= BLI_findlink(&ks->paths, ks->active_path-1); + KS_Path *ksp = BLI_findlink(&ks->paths, ks->active_path - 1); if (ksp) { /* remove the active path from the KeyingSet */ @@ -287,24 +287,24 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot) /* Add to KeyingSet Button Operator ------------------------ */ -static int add_keyingset_button_exec (bContext *C, wmOperator *op) +static int add_keyingset_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; - PropertyRNA *prop= NULL; - PointerRNA ptr= {{NULL}}; + PropertyRNA *prop = NULL; + PointerRNA ptr = {{NULL}}; char *path = NULL; - short success= 0; - int index=0, pflag=0; - int all= RNA_boolean_get(op->ptr, "all"); + short success = 0; + int index = 0, pflag = 0; + int all = RNA_boolean_get(op->ptr, "all"); /* verify the Keying Set to use: * - use the active one for now (more control over this can be added later) * - add a new one if it doesn't exist */ if (scene->active_keyingset == 0) { - short flag=0, keyingflag=0; + short flag = 0, keyingflag = 0; /* validate flags * - absolute KeyingSets should be created by default @@ -317,23 +317,23 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) keyingflag |= INSERTKEY_XYZ2RGB; /* call the API func, and set the active keyingset index */ - ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag); + ks = BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); } else if (scene->active_keyingset < 0) { BKE_report(op->reports, RPT_ERROR, "Cannot add property to built in Keying Set"); return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* try to add to keyingset using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); /* check if property is able to be added */ if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop)) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { /* set flags */ @@ -344,13 +344,13 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) * necessary if we want the entire array for most cases to get included without the user * having to worry about where they clicked */ - index= 0; + index = 0; } /* add path to this setting */ BKE_keyingset_add_path(ks, ptr.id.data, NULL, path, index, pflag, KSP_GROUP_KSNAME); - ks->active_path= BLI_countlist(&ks->paths); - success= 1; + ks->active_path = BLI_countlist(&ks->paths); + success = 1; /* free the temp path created */ MEM_freeN(path); @@ -362,10 +362,10 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyingset_button_add(wmOperatorType *ot) @@ -380,7 +380,7 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) //op->poll= ??? /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "all", 1, "All", "Add all elements of the array to a Keying Set"); @@ -388,16 +388,16 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) /* Remove from KeyingSet Button Operator ------------------------ */ -static int remove_keyingset_button_exec (bContext *C, wmOperator *op) +static int remove_keyingset_button_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; - PropertyRNA *prop= NULL; - PointerRNA ptr= {{NULL}}; + PropertyRNA *prop = NULL; + PointerRNA ptr = {{NULL}}; char *path = NULL; - short success= 0; - int index=0; + short success = 0; + int index = 0; /* verify the Keying Set to use: * - use the active one for now (more control over this can be added later) @@ -412,23 +412,23 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* try to add to keyingset using property retrieved from UI */ uiContextActiveProperty(C, &ptr, &prop, &index); if (ptr.id.data && ptr.data && prop) { - path= RNA_path_from_ID_to_property(&ptr, prop); + path = RNA_path_from_ID_to_property(&ptr, prop); if (path) { KS_Path *ksp; /* try to find a path matching this description */ - ksp= BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); + ksp = BKE_keyingset_find_path(ks, ptr.id.data, ks->name, path, index, KSP_GROUP_KSNAME); if (ksp) { BKE_keyingset_free_path(ks, ksp); - success= 1; + success = 1; } /* free temp path used */ @@ -442,10 +442,10 @@ static int remove_keyingset_button_exec (bContext *C, wmOperator *op) DAG_ids_flush_update(bmain, 0); /* for now, only send ND_KEYS for KeyingSets */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); } - return (success)? OPERATOR_FINISHED: OPERATOR_CANCELLED; + return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; } void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) @@ -460,7 +460,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) //op->poll= ??? /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************************************* */ @@ -468,7 +468,7 @@ void ANIM_OT_keyingset_button_remove(wmOperatorType *ot) /* Change Active KeyingSet Operator ------------------------ */ /* This operator checks if a menu should be shown for choosing the KeyingSet to make the active one */ -static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { uiPopupMenu *pup; uiLayout *layout; @@ -482,7 +482,7 @@ static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *U return OPERATOR_CANCELLED; } -static int keyingset_active_menu_exec (bContext *C, wmOperator *op) +static int keyingset_active_menu_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); int type = RNA_enum_get(op->ptr, "type"); @@ -491,7 +491,7 @@ static int keyingset_active_menu_exec (bContext *C, wmOperator *op) scene->active_keyingset = type; /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -511,10 +511,10 @@ void ANIM_OT_keying_set_active_set(wmOperatorType *ot) ot->poll = ED_operator_areaactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* keyingset to use (dynamic enum) */ - prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); /* RNA_def_property_flag(prop, PROP_HIDDEN);*/ } @@ -531,7 +531,7 @@ ListBase builtin_keyingsets = {NULL, NULL}; /* --------------- */ /* Find KeyingSet type info given a name */ -KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]) +KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]) { /* sanity checks */ if ((name == NULL) || (name[0] == 0)) @@ -542,9 +542,9 @@ KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]) } /* Find builtin KeyingSet by name */ -KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[]) +KeyingSet *ANIM_builtin_keyingset_get_named(KeyingSet *prevKS, const char name[]) { - KeyingSet *ks, *first=NULL; + KeyingSet *ks, *first = NULL; /* sanity checks any name to check? */ if (name[0] == 0) @@ -552,12 +552,12 @@ KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[ /* get first KeyingSet to use */ if (prevKS && prevKS->next) - first= prevKS->next; + first = prevKS->next; else - first= builtin_keyingsets.first; + first = builtin_keyingsets.first; /* loop over KeyingSets checking names */ - for (ks= first; ks; ks= ks->next) { + for (ks = first; ks; ks = ks->next) { if (strcmp(name, ks->idname) == 0) return ks; } @@ -601,7 +601,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) /* find relevant builtin KeyingSets which use this, and remove them */ // TODO: this isn't done now, since unregister is really only used atm when we // reload the scripts, which kindof defeats the purpose of "builtin"? - for (ks= builtin_keyingsets.first; ks; ks= ksn) { + for (ks = builtin_keyingsets.first; ks; ks = ksn) { ksn = ks->next; /* remove if matching typeinfo name */ @@ -610,7 +610,7 @@ void ANIM_keyingset_info_unregister(Main *bmain, KeyingSetInfo *ksi) BKE_keyingset_free(ks); BLI_remlink(&builtin_keyingsets, ks); - for (scene= bmain->scene.first; scene; scene= scene->id.next) + for (scene = bmain->scene.first; scene; scene = scene->id.next) BLI_remlink_safe(&scene->keyingsets, ks); MEM_freeN(ks); @@ -628,8 +628,8 @@ void ANIM_keyingset_infos_exit(void) KeyingSetInfo *ksi, *next; /* free type infos */ - for (ksi=keyingset_type_infos.first; ksi; ksi=next) { - next= ksi->next; + for (ksi = keyingset_type_infos.first; ksi; ksi = next) { + next = ksi->next; /* free extra RNA data, and remove from list */ if (ksi->ext.free) @@ -647,7 +647,7 @@ void ANIM_keyingset_infos_exit(void) /* Getters for Active/Indices ----------------------------- */ /* Get the active Keying Set for the Scene provided */ -KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene) +KeyingSet *ANIM_scene_get_active_keyingset(Scene *scene) { /* if no scene, we've got no hope of finding the Keying Set */ if (scene == NULL) @@ -659,9 +659,9 @@ KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene) * - < 0: a builtin keying set */ if (scene->active_keyingset > 0) - return BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + return BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); else - return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset)-1); + return BLI_findlink(&builtin_keyingsets, (-scene->active_keyingset) - 1); } /* Get the index of the Keying Set provided, for the given Scene */ @@ -699,7 +699,7 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK { /* get KeyingSet to use * - use the active KeyingSet if defined (and user wants to use it for all autokeying), - * or otherwise key transforms only + * or otherwise key transforms only */ if (IS_AUTOKEY_FLAG(scene, ONLYKEYINGSET) && (scene->active_keyingset)) return ANIM_scene_get_active_keyingset(scene); @@ -712,13 +712,13 @@ KeyingSet *ANIM_get_keyingset_for_autokeying(Scene *scene, const char *tranformK /* Menu of All Keying Sets ----------------------------- */ /* Dynamically populate an enum of Keying Sets */ -EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) +EnumPropertyItem *ANIM_keying_sets_enum_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free) { Scene *scene = CTX_data_scene(C); KeyingSet *ks; - EnumPropertyItem *item= NULL, item_tmp= {0}; - int totitem= 0; - int i= 0; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; if (C == NULL) { return DummyRNA_DEFAULT_items; @@ -729,9 +729,9 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p */ if (scene->active_keyingset) { /* active Keying Set */ - item_tmp.identifier= "__ACTIVE__"; - item_tmp.name= "Active Keying Set"; - item_tmp.value= i; + item_tmp.identifier = "__ACTIVE__"; + item_tmp.name = "Active Keying Set"; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); /* separator */ @@ -744,12 +744,12 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { - for (ks= scene->keyingsets.first; ks; ks= ks->next, i++) { + for (ks = scene->keyingsets.first; ks; ks = ks->next, i++) { if (ANIM_keyingset_context_ok_poll(C, ks)) { item_tmp.identifier = ks->idname; item_tmp.name = ks->name; item_tmp.description = ks->description; - item_tmp.value= i; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } @@ -759,20 +759,20 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p } /* builtin Keying Sets */ - i= -1; - for (ks= builtin_keyingsets.first; ks; ks= ks->next, i--) { + i = -1; + for (ks = builtin_keyingsets.first; ks; ks = ks->next, i--) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) { item_tmp.identifier = ks->idname; item_tmp.name = ks->name; item_tmp.description = ks->description; - item_tmp.value= i; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } @@ -786,7 +786,7 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) { if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* get the associated 'type info' for this KeyingSet */ if (ksi == NULL) @@ -803,12 +803,12 @@ short ANIM_keyingset_context_ok_poll(bContext *C, KeyingSet *ks) /* Special 'Overrides' Iterator for Relative KeyingSets ------ */ /* 'Data Sources' for relative Keying Set 'overrides' - * - this is basically a wrapper for PointerRNA's in a linked list + * - this is basically a wrapper for PointerRNA's in a linked list * - do not allow this to be accessed from outside for now */ typedef struct tRKS_DSource { struct tRKS_DSource *next, *prev; - PointerRNA ptr; /* the whole point of this exercise! */ + PointerRNA ptr; /* the whole point of this exercise! */ } tRKS_DSource; @@ -816,7 +816,7 @@ typedef struct tRKS_DSource { * relative Keying Sets, with the main usage of this being operators * requiring Auto Keyframing. Internal Use Only! */ -static void RKS_ITER_overrides_list (KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ListBase *dsources) +static void RKS_ITER_overrides_list(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks, ListBase *dsources) { tRKS_DSource *ds; @@ -868,7 +868,7 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) /* if relative Keying Sets, poll and build up the paths */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) { - KeyingSetInfo *ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + KeyingSetInfo *ksi = ANIM_keyingset_info_find_name(ks->typeinfo); /* clear all existing paths * NOTE: BKE_keyingset_free() frees all of the paths for the KeyingSet, but not the set itself @@ -910,11 +910,11 @@ short ANIM_validate_keyingset(bContext *C, ListBase *dsources, KeyingSet *ks) */ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); KS_Path *ksp; - int kflag=0, success= 0; - char *groupname= NULL; + int kflag = 0, success = 0; + char *groupname = NULL; /* sanity checks */ if (ks == NULL) @@ -923,13 +923,13 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe /* get flags to use */ if (mode == MODIFYKEY_MODE_INSERT) { /* use KeyingSet's flags as base */ - kflag= ks->keyingflag; + kflag = ks->keyingflag; /* suppliment with info from the context */ kflag |= ANIM_get_keyframing_flags(scene, 1); } else if (mode == MODIFYKEY_MODE_DELETE) - kflag= 0; + kflag = 0; /* if relative Keying Sets, poll and build up the paths */ success = ANIM_validate_keyingset(C, dsources, ks); @@ -940,15 +940,15 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe } /* apply the paths as specified in the KeyingSet now */ - for (ksp= ks->paths.first; ksp; ksp= ksp->next) { + for (ksp = ks->paths.first; ksp; ksp = ksp->next) { int arraylen, i; short kflag2; /* skip path if no ID pointer is specified */ if (ksp->id == NULL) { BKE_reportf(reports, RPT_WARNING, - "Skipping path in Keying Set, as it has no ID (KS = '%s', Path = '%s'[%d])", - ks->name, ksp->rna_path, ksp->array_index); + "Skipping path in Keying Set, as it has no ID (KS = '%s', Path = '%s'[%d])", + ks->name, ksp->rna_path, ksp->array_index); continue; } @@ -957,17 +957,17 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe /* get pointer to name of group to add channels to */ if (ksp->groupmode == KSP_GROUP_NONE) - groupname= NULL; + groupname = NULL; else if (ksp->groupmode == KSP_GROUP_KSNAME) - groupname= ks->name; + groupname = ks->name; else - groupname= ksp->group; + groupname = ksp->group; /* init arraylen and i - arraylen should be greater than i so that * normal non-array entries get keyframed correctly */ - i= ksp->array_index; - arraylen= i; + i = ksp->array_index; + arraylen = i; /* get length of array if whole array option is enabled */ if (ksp->flag & KSP_FLAG_WHOLE_ARRAY) { @@ -976,7 +976,7 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe RNA_id_pointer_create(ksp->id, &id_ptr); if (RNA_path_resolve(&id_ptr, ksp->rna_path, &ptr, &prop) && prop) - arraylen= RNA_property_array_length(&ptr, prop); + arraylen = RNA_property_array_length(&ptr, prop); } /* we should do at least one step */ @@ -998,15 +998,15 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe switch (GS(ksp->id->name)) { case ID_OB: /* Object (or Object-Related) Keyframes */ { - Object *ob= (Object *)ksp->id; + Object *ob = (Object *)ksp->id; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; // XXX: only object transforms only? + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: only object transforms only? } - break; + break; } /* send notifiers for updates (this doesn't require context to work!) */ - WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* return the number of channels successfully affected */ diff --git a/source/blender/editors/armature/BIF_generate.h b/source/blender/editors/armature/BIF_generate.h index 1d8ee8e2c62..583178dd2b7 100644 --- a/source/blender/editors/armature/BIF_generate.h +++ b/source/blender/editors/armature/BIF_generate.h @@ -32,7 +32,7 @@ struct BArcIterator; struct bArmature; struct ListBase; -typedef int(NextSubdivisionFunc)(struct ToolSettings*, struct BArcIterator*, int, int, float[3], float[3]); +typedef int (NextSubdivisionFunc)(struct ToolSettings *, struct BArcIterator *, int, int, float[3], float[3]); float calcArcCorrelation(struct BArcIterator *iter, int start, int end, float v0[3], float n[3]); @@ -40,7 +40,7 @@ int nextFixedSubdivision(struct ToolSettings *toolsettings, struct BArcIterator int nextLengthSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]); int nextAdaptativeSubdivision(struct ToolSettings *toolsettings, struct BArcIterator *iter, int start, int end, float head[3], float p[3]); -struct EditBone * subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion); +struct EditBone *subdivideArcBy(struct ToolSettings *toolsettings, struct bArmature *arm, ListBase *editbones, struct BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion); void setBoneRollFromNormal(struct EditBone *bone, float *no, float invmat[][4], float tmat[][3]); diff --git a/source/blender/editors/armature/BIF_retarget.h b/source/blender/editors/armature/BIF_retarget.h index c878b0c36df..2ea0e0ab0d7 100644 --- a/source/blender/editors/armature/BIF_retarget.h +++ b/source/blender/editors/armature/BIF_retarget.h @@ -22,7 +22,6 @@ * \ingroup edarmature */ - #ifndef __BIF_RETARGET_H__ #define __BIF_RETARGET_H__ @@ -49,21 +48,21 @@ struct RigEdge; #define USE_THREADS typedef struct RigGraph { - ListBase arcs; - ListBase nodes; + ListBase arcs; + ListBase nodes; float length; - FreeArc free_arc; - FreeNode free_node; - RadialSymmetry radial_symmetry; - AxialSymmetry axial_symmetry; + FreeArc free_arc; + FreeNode free_node; + RadialSymmetry radial_symmetry; + AxialSymmetry axial_symmetry; /*********************************/ - int flag; + int flag; - ListBase controls; - ListBase* editbones; + ListBase controls; + ListBase *editbones; struct RigNode *head; ReebGraph *link_mesh; @@ -71,8 +70,8 @@ typedef struct RigGraph { struct ThreadedWorker *worker; - GHash *bones_map; /* map of editbones by name */ - GHash *controls_map; /* map of rigcontrols by bone pointer */ + GHash *bones_map; /* map of editbones by name */ + GHash *controls_map; /* map of rigcontrols by bone pointer */ struct Object *ob; } RigGraph; @@ -123,16 +122,16 @@ typedef struct RigEdge { } RigEdge; /* Graph flags */ -#define RIG_FREE_BONELIST 1 +#define RIG_FREE_BONELIST 1 /* Control flags */ -#define RIG_CTRL_HEAD_DONE 1 -#define RIG_CTRL_TAIL_DONE 2 -#define RIG_CTRL_PARENT_DEFORM 4 -#define RIG_CTRL_FIT_ROOT 8 -#define RIG_CTRL_FIT_BONE 16 +#define RIG_CTRL_HEAD_DONE 1 +#define RIG_CTRL_TAIL_DONE 2 +#define RIG_CTRL_PARENT_DEFORM 4 +#define RIG_CTRL_FIT_ROOT 8 +#define RIG_CTRL_FIT_BONE 16 -#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE|RIG_CTRL_TAIL_DONE) +#define RIG_CTRL_DONE (RIG_CTRL_HEAD_DONE | RIG_CTRL_TAIL_DONE) /* Control tail flags */ typedef enum { @@ -147,10 +146,10 @@ typedef struct RigControl { struct EditBone *bone; struct EditBone *link; struct EditBone *link_tail; - float up_axis[3]; - float offset[3]; - float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */ - int flag; + float up_axis[3]; + float offset[3]; + float qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */ + int flag; LinkTailMode tail_mode; } RigControl; diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h index 72d261ec187..0760b384ecd 100644 --- a/source/blender/editors/armature/armature_intern.h +++ b/source/blender/editors/armature/armature_intern.h @@ -117,6 +117,7 @@ void POSE_OT_group_select(struct wmOperatorType *ot); void POSE_OT_group_deselect(struct wmOperatorType *ot); void POSE_OT_paths_calculate(struct wmOperatorType *ot); +void POSE_OT_paths_update(struct wmOperatorType *ot); void POSE_OT_paths_clear(struct wmOperatorType *ot); void POSE_OT_autoside_names(struct wmOperatorType *ot); @@ -149,19 +150,19 @@ void SKETCH_OT_select(struct wmOperatorType *ot); typedef struct tPChanFCurveLink { struct tPChanFCurveLink *next, *prev; - ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */ - struct bPoseChannel *pchan; /* Pose Channel which data is attached to */ + ListBase fcurves; /* F-Curves for this PoseChannel (wrapped with LinkData) */ + struct bPoseChannel *pchan; /* Pose Channel which data is attached to */ - char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */ + char *pchan_path; /* RNA Path to this Pose Channel (needs to be freed when we're done) */ - float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */ + float oldloc[3]; /* transform values at start of operator (to be restored before each modal step) */ float oldrot[3]; float oldscale[3]; float oldquat[4]; float oldangle; float oldaxis[3]; - struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */ + struct IDProperty *oldprops; /* copy of custom properties at start of operator (to be restored before each modal step) */ } tPChanFCurveLink; /* ----------- */ diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c index aeecbc1fd28..f3461f71391 100644 --- a/source/blender/editors/armature/armature_ops.c +++ b/source/blender/editors/armature/armature_ops.c @@ -133,6 +133,7 @@ void ED_operatortypes_armature(void) WM_operatortype_append(POSE_OT_group_deselect); WM_operatortype_append(POSE_OT_paths_calculate); + WM_operatortype_append(POSE_OT_paths_update); WM_operatortype_append(POSE_OT_paths_clear); WM_operatortype_append(POSE_OT_autoside_names); @@ -171,18 +172,20 @@ void ED_operatormacros_armature(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_duplicate_move", "Duplicate", + "Make copies of the selected bones within the same armature and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Make copies of the selected bones within the same armature and move them"; WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); } - ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move", "Extrude", + "Create new bones from the selected joints and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Create new bones from the selected joints and move them"; - otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); + otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", FALSE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -190,10 +193,11 @@ void ED_operatormacros_armature(void) // XXX would it be nicer to just be able to have standard extrude_move, but set the forked property separate? // that would require fixing a properties bug 19733 - ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked", "Extrude Forked", + "Create new bones from the selected joints and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Create new bones from the selected joints and move them"; - otmacro=WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); + otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude"); RNA_boolean_set(otmacro->ptr, "forked", TRUE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -233,7 +237,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "unselected", TRUE); WM_keymap_add_item(keymap, "ARMATURE_OT_reveal", HKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_align", AKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_calculate_roll", NKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_switch_direction", FKEY, KM_PRESS, KM_ALT, 0); @@ -244,23 +248,23 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", TRUE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "ARMATURE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", TRUE); WM_keymap_add_item(keymap, "ARMATURE_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0); @@ -275,27 +279,27 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "ARMATURE_OT_fill", FKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_merge", MKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "ARMATURE_OT_separate", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); - /* set flags */ + /* set flags */ WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0); - /* armature/bone layers */ + /* armature/bone layers */ WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ARMATURE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - /* special transforms: */ - /* 1) envelope/b-bone size */ - kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); - /* 2) set roll */ + /* special transforms: */ + /* 1) envelope/b-bone size */ + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); + /* 2) set roll */ kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", RKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL); + RNA_enum_set(kmi->ptr, "mode", TFM_BONE_ROLL); - /* menus */ + /* menus */ WM_keymap_add_menu(keymap, "VIEW3D_MT_armature_specials", WKEY, KM_PRESS, 0, 0); /* Pose ------------------------ */ @@ -330,60 +334,60 @@ void ED_keymap_armature(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "flipped", FALSE); - kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "POSE_OT_paste", VKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "flipped", TRUE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); WM_keymap_add_item(keymap, "POSE_OT_select_parent", PKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_PARENT); + RNA_boolean_set(kmi->ptr, "extend", TRUE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "POSE_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); - RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "direction", BONE_SELECT_CHILD); + RNA_boolean_set(kmi->ptr, "extend", TRUE); WM_keymap_add_item(keymap, "POSE_OT_select_linked", LKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "POSE_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_select_flip_active", FKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/KM_SHIFT, 0); - WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "POSE_OT_constraint_add_with_targets", CKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSE_OT_constraints_clear", CKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + WM_keymap_add_item(keymap, "POSE_OT_ik_add", IKEY, KM_PRESS, /*KM_CTRL|*/ KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSE_OT_ik_clear", IKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_group", GKEY, KM_PRESS, KM_CTRL, 0); - /* set flags */ + /* set flags */ WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_toggle", WKEY, KM_PRESS, KM_SHIFT, 0); - WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_enable", WKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_add_menu(keymap, "VIEW3D_MT_bone_options_disable", WKEY, KM_PRESS, KM_ALT, 0); - /* armature/bone layers */ + /* armature/bone layers */ WM_keymap_add_item(keymap, "ARMATURE_OT_layers_show_all", ACCENTGRAVEKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "POSE_OT_armature_layers", MKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSE_OT_bone_layers", MKEY, KM_PRESS, 0, 0); - /* special transforms: */ - /* 1) envelope/b-bone size */ - kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); + /* special transforms: */ + /* 1) envelope/b-bone size */ + kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_enum_set(kmi->ptr, "mode", TFM_BONESIZE); - /* keyframes management */ + /* keyframes management */ WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0); + WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0); /* Pose -> PoseLib ------------- */ /* only set in posemode, by space_view3d listener */ @@ -391,12 +395,15 @@ void ED_keymap_armature(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "POSELIB_OT_pose_add", LKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "POSELIB_OT_pose_remove", LKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + WM_keymap_add_item(keymap, "POSELIB_OT_pose_rename", LKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); /* Pose -> Pose Sliding ------------- */ /* only set in posemode, by space_view3d listener */ WM_keymap_add_item(keymap, "POSE_OT_push", EKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "POSE_OT_relax", EKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "POSE_OT_breakdown", EKEY, KM_PRESS, KM_SHIFT, 0); + + /* menus */ + WM_keymap_add_menu(keymap, "VIEW3D_MT_pose_specials", WKEY, KM_PRESS, 0, 0); } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index a2e95622bcf..f698153eb7f 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -102,7 +102,7 @@ void ED_armature_sync_selection(ListBase *edbo) { EditBone *ebo; - for (ebo=edbo->first; ebo; ebo= ebo->next) { + for (ebo = edbo->first; ebo; ebo = ebo->next) { /* if bone is not selectable, we shouldn't alter this setting... */ if ((ebo->flag & BONE_UNSELECTABLE) == 0) { if ((ebo->flag & BONE_CONNECTED) && (ebo->parent)) { @@ -122,18 +122,18 @@ void ED_armature_sync_selection(ListBase *edbo) void ED_armature_validate_active(struct bArmature *arm) { - EditBone *ebone= arm->act_edbone; + EditBone *ebone = arm->act_edbone; if (ebone) { if (ebone->flag & BONE_HIDDEN_A) - arm->act_edbone= NULL; + arm->act_edbone = NULL; } } static void bone_free(bArmature *arm, EditBone *bone) { - if (arm->act_edbone==bone) - arm->act_edbone= NULL; + if (arm->act_edbone == bone) + arm->act_edbone = NULL; if (bone->prop) { IDP_FreeProperty(bone->prop); @@ -148,9 +148,9 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone) EditBone *curBone; /* Find any bones that refer to this bone */ - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { - if (curBone->parent==exBone) { - curBone->parent=exBone->parent; + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { + if (curBone->parent == exBone) { + curBone->parent = exBone->parent; curBone->flag &= ~BONE_CONNECTED; } } @@ -161,7 +161,7 @@ void ED_armature_edit_bone_remove(bArmature *arm, EditBone *exBone) /* context: editmode armature */ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) { - EditBone *eboflip= NULL; + EditBone *eboflip = NULL; char name[MAXBONENAME]; if (ebo == NULL) @@ -169,9 +169,9 @@ EditBone *ED_armature_bone_get_mirrored(ListBase *edbo, EditBone *ebo) flip_side_name(name, ebo->name, FALSE); - for (eboflip= edbo->first; eboflip; eboflip=eboflip->next) { + for (eboflip = edbo->first; eboflip; eboflip = eboflip->next) { if (ebo != eboflip) { - if (!strcmp (name, eboflip->name)) + if (!strcmp(name, eboflip->name)) break; } } @@ -187,10 +187,10 @@ static void armature_select_mirrored(bArmature *arm) if (arm->flag & ARM_MIRROR_EDIT) { EditBone *curBone, *ebone_mirr; - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { - ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone); + ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); if (ebone_mirr) ebone_mirr->flag |= BONE_SELECTED; } @@ -205,16 +205,16 @@ static void armature_tag_select_mirrored(bArmature *arm) EditBone *curBone; /* always untag */ - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { curBone->flag &= ~BONE_DONE; } /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (arm->layer & curBone->layer) { - if (curBone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL)) { - EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone); + if (curBone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL)) { + EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); if (ebone_mirr && (ebone_mirr->flag & BONE_SELECTED) == 0) { ebone_mirr->flag |= BONE_DONE; } @@ -222,10 +222,10 @@ static void armature_tag_select_mirrored(bArmature *arm) } } - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { - EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, curBone); - curBone->flag |= ebone_mirr->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, curBone); + curBone->flag |= ebone_mirr->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); } } } @@ -237,9 +237,9 @@ static void armature_tag_unselect(bArmature *arm) { EditBone *curBone; - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (curBone->flag & BONE_DONE) { - curBone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL|BONE_DONE); + curBone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL | BONE_DONE); } } } @@ -247,16 +247,16 @@ static void armature_tag_unselect(bArmature *arm) /* converts Bones to EditBone list, used for tools as well */ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone *actBone) { - EditBone *eBone; - EditBone *eBoneAct= NULL; - EditBone *eBoneTest= NULL; - Bone *curBone; + EditBone *eBone; + EditBone *eBoneAct = NULL; + EditBone *eBoneTest = NULL; + Bone *curBone; - for (curBone=bones->first; curBone; curBone=curBone->next) { - eBone= MEM_callocN(sizeof(EditBone), "make_editbone"); + for (curBone = bones->first; curBone; curBone = curBone->next) { + eBone = MEM_callocN(sizeof(EditBone), "make_editbone"); /* Copy relevant data from bone to eBone */ - eBone->parent= parent; + eBone->parent = parent; BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name)); eBone->flag = curBone->flag; @@ -295,32 +295,32 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone eBone->roll = curBone->arm_roll; /* rest of stuff copy */ - eBone->length= curBone->length; - eBone->dist= curBone->dist; - eBone->weight= curBone->weight; - eBone->xwidth= curBone->xwidth; - eBone->zwidth= curBone->zwidth; - eBone->ease1= curBone->ease1; - eBone->ease2= curBone->ease2; - eBone->rad_head= curBone->rad_head; - eBone->rad_tail= curBone->rad_tail; + eBone->length = curBone->length; + eBone->dist = curBone->dist; + eBone->weight = curBone->weight; + eBone->xwidth = curBone->xwidth; + eBone->zwidth = curBone->zwidth; + eBone->ease1 = curBone->ease1; + eBone->ease2 = curBone->ease2; + eBone->rad_head = curBone->rad_head; + eBone->rad_tail = curBone->rad_tail; eBone->segments = curBone->segments; eBone->layer = curBone->layer; if (curBone->prop) - eBone->prop= IDP_CopyProperty(curBone->prop); + eBone->prop = IDP_CopyProperty(curBone->prop); BLI_addtail(edbo, eBone); /* Add children if necessary */ if (curBone->childbase.first) { - eBoneTest= make_boneList(edbo, &curBone->childbase, eBone, actBone); + eBoneTest = make_boneList(edbo, &curBone->childbase, eBone, actBone); if (eBoneTest) - eBoneAct= eBoneTest; + eBoneAct = eBoneTest; } - if (curBone==actBone) - eBoneAct= eBone; + if (curBone == actBone) + eBoneAct = eBone; } return eBoneAct; @@ -328,7 +328,7 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone /* nasty stuff for converting roll in editbones into bones */ /* also sets restposition in armature (arm_mat) */ -static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) +static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist) { Bone *curBone; EditBone *ebone; @@ -338,13 +338,13 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) float imat[3][3]; float delta[3]; - for (curBone=bonelist->first; curBone; curBone=curBone->next) { + for (curBone = bonelist->first; curBone; curBone = curBone->next) { /* sets local matrix and arm_mat (restpos) */ - where_is_armature_bone(curBone, curBone->parent); + BKE_armature_where_is_bone(curBone, curBone->parent); /* Find the associated editbone */ - for (ebone = editbonelist->first; ebone; ebone=ebone->next) - if ((Bone*)ebone->temp == curBone) + for (ebone = editbonelist->first; ebone; ebone = ebone->next) + if ((Bone *)ebone->temp == curBone) break; if (ebone) { @@ -358,16 +358,16 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) invert_m3_m3(imat, premat); mul_m3_m3m3(difmat, imat, postmat); #if 0 - printf ("Bone %s\n", curBone->name); + printf("Bone %s\n", curBone->name); print_m4("premat", premat); print_m4("postmat", postmat); print_m4("difmat", difmat); - printf ("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); + printf("Roll = %f\n", RAD2DEGF(-atan2(difmat[2][0], difmat[2][2]))); #endif curBone->roll = (float)-atan2(difmat[2][0], difmat[2][2]); /* and set restposition again */ - where_is_armature_bone(curBone, curBone->parent); + BKE_armature_where_is_bone(curBone, curBone->parent); } fix_bonelist_roll(&curBone->childbase, editbonelist); } @@ -376,25 +376,25 @@ static void fix_bonelist_roll (ListBase *bonelist, ListBase *editbonelist) /* put EditMode back in Object */ void ED_armature_from_edit(Object *obedit) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *eBone, *neBone; - Bone *newBone; + Bone *newBone; Object *obt; /* armature bones */ - free_bonelist(&arm->bonebase); + BKE_armature_bonelist_free(&arm->bonebase); /* remove zero sized bones, this gives instable restposes */ - for (eBone=arm->edbo->first; eBone; eBone= neBone) { - float len= len_v3v3(eBone->head, eBone->tail); - neBone= eBone->next; - if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ + for (eBone = arm->edbo->first; eBone; eBone = neBone) { + float len = len_v3v3(eBone->head, eBone->tail); + neBone = eBone->next; + if (len <= 0.000001f) { /* FLT_EPSILON is too large? */ EditBone *fBone; /* Find any bones that refer to this bone */ - for (fBone=arm->edbo->first; fBone; fBone= fBone->next) { - if (fBone->parent==eBone) - fBone->parent= eBone->parent; + for (fBone = arm->edbo->first; fBone; fBone = fBone->next) { + if (fBone->parent == eBone) + fBone->parent = eBone->parent; } if (G.debug & G_DEBUG) printf("Warning: removed zero sized bone: %s\n", eBone->name); @@ -403,23 +403,23 @@ void ED_armature_from_edit(Object *obedit) } /* Copy the bones from the editData into the armature */ - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { - newBone= MEM_callocN(sizeof(Bone), "bone"); - eBone->temp= newBone; /* Associate the real Bones with the EditBones */ + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + newBone = MEM_callocN(sizeof(Bone), "bone"); + eBone->temp = newBone; /* Associate the real Bones with the EditBones */ BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name)); copy_v3_v3(newBone->arm_head, eBone->head); copy_v3_v3(newBone->arm_tail, eBone->tail); newBone->arm_roll = eBone->roll; - newBone->flag= eBone->flag; + newBone->flag = eBone->flag; if (eBone == arm->act_edbone) { /* don't change active selection, this messes up separate which uses * editmode toggle and can separate active bone which is de-selected originally */ /* newBone->flag |= BONE_SELECTED; */ /* important, editbones can be active with only 1 point selected */ - arm->act_edbone= NULL; - arm->act_bone= newBone; + arm->act_edbone = NULL; + arm->act_bone = newBone; } newBone->roll = 0.0f; @@ -428,29 +428,29 @@ void ED_armature_from_edit(Object *obedit) newBone->xwidth = eBone->xwidth; newBone->zwidth = eBone->zwidth; - newBone->ease1= eBone->ease1; - newBone->ease2= eBone->ease2; - newBone->rad_head= eBone->rad_head; - newBone->rad_tail= eBone->rad_tail; - newBone->segments= eBone->segments; + newBone->ease1 = eBone->ease1; + newBone->ease2 = eBone->ease2; + newBone->rad_head = eBone->rad_head; + newBone->rad_tail = eBone->rad_tail; + newBone->segments = eBone->segments; newBone->layer = eBone->layer; if (eBone->prop) - newBone->prop= IDP_CopyProperty(eBone->prop); + newBone->prop = IDP_CopyProperty(eBone->prop); } /* Fix parenting in a separate pass to ensure ebone->bone connections * are valid at this point */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { - newBone= (Bone *)eBone->temp; + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + newBone = (Bone *)eBone->temp; if (eBone->parent) { - newBone->parent= (Bone *)eBone->parent->temp; + newBone->parent = (Bone *)eBone->parent->temp; BLI_addtail(&newBone->parent->childbase, newBone); { float M_parentRest[3][3]; float iM_parentRest[3][3]; - float delta[3]; + float delta[3]; /* Get the parent's matrix (rotation only) */ sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head); @@ -476,13 +476,13 @@ void ED_armature_from_edit(Object *obedit) } /* Make a pass through the new armature to fix rolling */ - /* also builds restposition again (like where_is_armature) */ + /* also builds restposition again (like BKE_armature_where_is) */ fix_bonelist_roll(&arm->bonebase, arm->edbo); /* so all users of this armature should get rebuilt */ - for (obt= G.main->object.first; obt; obt= obt->id.next) { - if (obt->data==arm) - armature_rebuild_pose(obt, arm); + for (obt = G.main->object.first; obt; obt = obt->id.next) { + if (obt->data == arm) + BKE_pose_rebuild(obt, arm); } DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); @@ -491,8 +491,8 @@ void ED_armature_from_edit(Object *obedit) void ED_armature_apply_transform(Object *ob, float mat[4][4]) { EditBone *ebone; - bArmature *arm= ob->data; - float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ + bArmature *arm = ob->data; + float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */ float mat3[3][3]; copy_m3_m4(mat3, mat); @@ -502,8 +502,8 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) ED_armature_to_edit(ob); /* Do the rotations */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { - float delta[3], tmat[3][3]; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + float delta[3], tmat[3][3]; /* find the current bone's roll matrix */ sub_v3_v3v3(delta, ebone->tail, ebone->head); @@ -519,13 +519,13 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) /* apply the transfiormed roll back */ mat3_to_vec_roll(tmat, NULL, &ebone->roll); - ebone->rad_head *= scale; - ebone->rad_tail *= scale; - ebone->dist *= scale; + ebone->rad_head *= scale; + ebone->rad_tail *= scale; + ebone->dist *= scale; /* we could be smarter and scale by the matrix along the x & z axis */ - ebone->xwidth *= scale; - ebone->zwidth *= scale; + ebone->xwidth *= scale; + ebone->zwidth *= scale; } /* Turn the list into an armature */ @@ -537,15 +537,15 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) /* 0 == do center, 1 == center new, 2 == center cursor */ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode, int around) { - Object *obedit= scene->obedit; // XXX get from context + Object *obedit = scene->obedit; // XXX get from context EditBone *ebone; - bArmature *arm= ob->data; + bArmature *arm = ob->data; float cent[3]; /* Put the armature into editmode */ if (ob != obedit) { ED_armature_to_edit(ob); - obedit= NULL; /* we cant use this so behave as if there is no obedit */ + obedit = NULL; /* we cant use this so behave as if there is no obedit */ } /* Find the centerpoint */ @@ -555,20 +555,20 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode mul_m4_v3(ob->imat, cent); } else { - if (around==V3D_CENTROID) { - int total= 0; + if (around == V3D_CENTROID) { + int total = 0; zero_v3(cent); - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { - total+=2; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + total += 2; add_v3_v3(cent, ebone->head); add_v3_v3(cent, ebone->tail); } - mul_v3_fl(cent, 1.0f/(float)total); + mul_v3_fl(cent, 1.0f / (float)total); } else { float min[3], max[3]; INIT_MINMAX(min, max); - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { DO_MINMAX(ebone->head, min, max); DO_MINMAX(ebone->tail, min, max); } @@ -577,19 +577,19 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode } /* Do the adjustments */ - for (ebone= arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { sub_v3_v3(ebone->head, cent); sub_v3_v3(ebone->tail, cent); } /* Turn the list into an armature */ - if (obedit==NULL) { + if (obedit == NULL) { ED_armature_from_edit(ob); ED_armature_edit_free(ob); } /* Adjust object location for new centerpoint */ - if (centermode && obedit==NULL) { + if (centermode && obedit == NULL) { mul_mat3_m4_v3(ob->obmat, cent); /* ommit translation part */ add_v3_v3(ob->loc, cent); } @@ -598,7 +598,7 @@ void docenter_armature(Scene *scene, Object *ob, float cursor[3], int centermode /* ---------------------- */ /* checks if an EditBone with a matching name already, returning the matching bone if it exists */ -static EditBone *editbone_name_exists (ListBase *edbo, const char *name) +static EditBone *editbone_name_exists(ListBase *edbo, const char *name) { return BLI_findstring(edbo, name, offsetof(EditBone, name)); } @@ -606,54 +606,54 @@ static EditBone *editbone_name_exists (ListBase *edbo, const char *name) /* note: there's a unique_bone_name() too! */ static int editbone_unique_check(void *arg, const char *name) { - struct {ListBase *lb;void *bone;} *data= arg; - EditBone *dupli= editbone_name_exists(data->lb, name); + struct {ListBase *lb; void *bone; } *data = arg; + EditBone *dupli = editbone_name_exists(data->lb, name); return dupli && dupli != data->bone; } void unique_editbone_name(ListBase *edbo, char *name, EditBone *bone) { - struct {ListBase *lb; void *bone;} data; - data.lb= edbo; - data.bone= bone; + struct {ListBase *lb; void *bone; } data; + data.lb = edbo; + data.bone = bone; BLI_uniquename_cb(editbone_unique_check, &data, "Bone", '.', name, sizeof(bone->name)); } /* helper for apply_armature_pose2bones - fixes parenting of objects that are bone-parented to armature */ -static void applyarmature_fix_boneparents (Scene *scene, Object *armob) +static void applyarmature_fix_boneparents(Scene *scene, Object *armob) { Object workob, *ob; /* go through all objects in database */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* if parent is bone in this armature, apply corrections */ if ((ob->parent == armob) && (ob->partype == PARBONE)) { /* apply current transform from parent (not yet destroyed), * then calculate new parent inverse matrix */ - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } } } /* set the current pose as the restpose */ -static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) +static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object - bArmature *arm= get_armature(ob); + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object + bArmature *arm = BKE_armature_from_object(ob); bPose *pose; bPoseChannel *pchan; EditBone *curbone; /* don't check if editmode (should be done by caller) */ - if (ob->type!=OB_ARMATURE) + if (ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Cannot apply pose to lib-linked armature"); //error_libdata(); return OPERATOR_CANCELLED; } @@ -667,10 +667,10 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) ED_armature_to_edit(ob); /* get pose of active object and move it out of posemode */ - pose= ob->pose; + pose = ob->pose; - for (pchan=pose->chanbase.first; pchan; pchan=pchan->next) { - curbone= editbone_name_exists(arm->edbo, pchan->name); + for (pchan = pose->chanbase.first; pchan; pchan = pchan->next) { + curbone = editbone_name_exists(arm->edbo, pchan->name); /* simply copy the head/tail values from pchan over to curbone */ copy_v3_v3(curbone->head, pchan->pose_head); @@ -697,7 +697,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) mat3_to_eul(eul, tmat); /* just use this euler-y as new roll value */ - curbone->roll= eul[1]; + curbone->roll = eul[1]; } /* clear transform values for pchan */ @@ -705,7 +705,7 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) zero_v3(pchan->eul); unit_qt(pchan->quat); unit_axis_angle(pchan->rotAxis, &pchan->rotAngle); - pchan->size[0]= pchan->size[1]= pchan->size[2]= 1.0f; + pchan->size[0] = pchan->size[1] = pchan->size[2] = 1.0f; /* set anim lock */ curbone->flag |= BONE_UNKEYED; @@ -716,13 +716,13 @@ static int apply_armature_pose2bones_exec (bContext *C, wmOperator *op) ED_armature_edit_free(ob); /* flush positions of posebones */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* fix parenting of objects which are bone-parented */ applyarmature_fix_boneparents(scene, ob); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -739,17 +739,17 @@ void POSE_OT_armature_apply(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* set the current pose as the restpose */ -static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); // must be active object, not edit-object /* don't check if editmode (should be done by caller) */ - if (ob->type!=OB_ARMATURE) + if (ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; /* loop over all selected pchans @@ -766,14 +766,14 @@ static int pose_visual_transform_apply_exec (bContext *C, wmOperator *UNUSED(op) * change, thus changing the result we may be trying to record. */ copy_m4_m4(delta_mat, pchan->chan_mat); - pchan_apply_mat4(pchan, delta_mat, TRUE); + BKE_pchan_apply_mat4(pchan, delta_mat, TRUE); } CTX_DATA_END; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -790,7 +790,7 @@ void POSE_OT_visual_transform_apply(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ---------------------- */ @@ -804,13 +804,13 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann bConstraint *con; /* let's go through all objects in database */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* do some object-type specific things */ if (ob->type == OB_ARMATURE) { - pose= ob->pose; - for (pchant= pose->chanbase.first; pchant; pchant= pchant->next) { - for (con= pchant->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + pose = ob->pose; + for (pchant = pose->chanbase.first; pchant; pchant = pchant->next) { + for (con = pchant->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -818,12 +818,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == srcArm) { if (ct->subtarget[0] == '\0') { ct->tar = tarArm; } - else if (strcmp(ct->subtarget, pchan->name)==0) { + else if (strcmp(ct->subtarget, pchan->name) == 0) { ct->tar = tarArm; BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget)); } @@ -836,15 +836,15 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* action constraint? */ if (con->type == CONSTRAINT_TYPE_ACTION) { - bActionConstraint *data= con->data; // XXX old animation system + bActionConstraint *data = con->data; // XXX old animation system bAction *act; bActionChannel *achan; if (data->act) { - act= data->act; + act = data->act; - for (achan= act->chanbase.first; achan; achan= achan->next) { - if (strcmp(achan->name, pchan->name)==0) + for (achan = act->chanbase.first; achan; achan = achan->next) { + if (strcmp(achan->name, pchan->name) == 0) BLI_strncpy(achan->name, curbone->name, sizeof(achan->name)); } } @@ -856,8 +856,8 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* fix object-level constraints */ if (ob != srcArm) { - for (con= ob->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -865,12 +865,12 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == srcArm) { if (ct->subtarget[0] == '\0') { ct->tar = tarArm; } - else if (strcmp(ct->subtarget, pchan->name)==0) { + else if (strcmp(ct->subtarget, pchan->name) == 0) { ct->tar = tarArm; BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget)); } @@ -886,7 +886,7 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* See if an object is parented to this armature */ if (ob->parent && (ob->parent == srcArm)) { /* Is object parented to a bone of this src armature? */ - if (ob->partype==PARBONE) { + if (ob->partype == PARBONE) { /* bone name in object */ if (!strcmp(ob->parsubstr, pchan->name)) BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr)); @@ -901,17 +901,17 @@ static void joined_armature_fix_links(Object *tarArm, Object *srcArm, bPoseChann /* join armature exec is exported for use in object->join objects operator... */ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - bArmature *arm= (ob)? ob->data: NULL; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + bArmature *arm = (ob) ? ob->data : NULL; bPose *pose, *opose; bPoseChannel *pchan, *pchann; EditBone *curbone; - float mat[4][4], oimat[4][4]; + float mat[4][4], oimat[4][4]; /* Ensure we're not in editmode and that the active object is an armature*/ - if (!ob || ob->type!=OB_ARMATURE) + if (!ob || ob->type != OB_ARMATURE) return OPERATOR_CANCELLED; if (!arm || arm->edbo) return OPERATOR_CANCELLED; @@ -920,19 +920,19 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_to_edit(ob); /* get pose of active object and move it out of posemode */ - pose= ob->pose; + pose = ob->pose; ob->mode &= ~OB_MODE_POSE; - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - if ((base->object->type==OB_ARMATURE) && (base->object!=ob)) { - bArmature *curarm= base->object->data; + if ((base->object->type == OB_ARMATURE) && (base->object != ob)) { + bArmature *curarm = base->object->data; /* Make a list of editbones in current armature */ ED_armature_to_edit(base->object); /* Get Pose of current armature */ - opose= base->object->pose; + opose = base->object->pose; base->object->mode &= ~OB_MODE_POSE; //BASACT->flag &= ~OB_MODE_POSE; @@ -941,9 +941,9 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) mult_m4_m4m4(mat, oimat, base->object->obmat); /* Copy bones and posechannels from the object to the edit armature */ - for (pchan=opose->chanbase.first; pchan; pchan=pchann) { - pchann= pchan->next; - curbone= editbone_name_exists(curarm->edbo, pchan->name); + for (pchan = opose->chanbase.first; pchan; pchan = pchann) { + pchann = pchan->next; + curbone = editbone_name_exists(curarm->edbo, pchan->name); /* Get new name */ unique_editbone_name(arm->edbo, curbone->name, NULL); @@ -991,8 +991,8 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) BLI_remlink(&opose->chanbase, pchan); BLI_addtail(&pose->chanbase, pchan); - free_pose_channels_hash(opose); - free_pose_channels_hash(pose); + BKE_pose_channels_hash_free(opose); + BKE_pose_channels_hash_free(pose); } ED_base_object_free_and_unlink(bmain, scene, base); @@ -1000,12 +1000,12 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); // because we removed object(s) + DAG_scene_sort(bmain, scene); /* because we removed object(s) */ ED_armature_from_edit(ob); ED_armature_edit_free(ob); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); return OPERATOR_FINISHED; } @@ -1021,16 +1021,16 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) ListBase *opchans, *npchans; /* get reference to list of bones in original and new armatures */ - opchans= &origArm->pose->chanbase; - npchans= &newArm->pose->chanbase; + opchans = &origArm->pose->chanbase; + npchans = &newArm->pose->chanbase; /* let's go through all objects in database */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { /* do some object-type specific things */ if (ob->type == OB_ARMATURE) { - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -1038,7 +1038,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm @@ -1046,12 +1046,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (ct->subtarget[0] != 0) { if (ct->tar == origArm) { if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= newArm; + ct->tar = newArm; } } else if (ct->tar == newArm) { if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= origArm; + ct->tar = origArm; } } } @@ -1067,8 +1067,8 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) /* fix object-level constraints */ if (ob != origArm) { - for (con= ob->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = ob->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -1076,7 +1076,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { /* any targets which point to original armature are redirected to the new one only if: * - the target isn't origArm/newArm itself * - the target is one that can be found in newArm/origArm @@ -1084,12 +1084,12 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) if (ct->subtarget[0] != '\0') { if (ct->tar == origArm) { if (BLI_findstring(npchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= newArm; + ct->tar = newArm; } } else if (ct->tar == newArm) { if (BLI_findstring(opchans, ct->subtarget, offsetof(bPoseChannel, name))) { - ct->tar= origArm; + ct->tar = origArm; } } } @@ -1107,7 +1107,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) /* Is object parented to a bone of this src armature? */ if ((ob->partype == PARBONE) && (ob->parsubstr[0] != '\0')) { if (BLI_findstring(npchans, ob->parsubstr, offsetof(bPoseChannel, name))) { - ob->parent= newArm; + ob->parent = newArm; } } } @@ -1120,7 +1120,7 @@ static void separated_armature_fix_links(Object *origArm, Object *newArm) */ static void separate_armature_bones(Object *ob, short sel) { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; bPoseChannel *pchan, *pchann; EditBone *curbone; @@ -1128,35 +1128,35 @@ static void separate_armature_bones(Object *ob, short sel) ED_armature_to_edit(ob); /* go through pose-channels, checking if a bone should be removed */ - for (pchan=ob->pose->chanbase.first; pchan; pchan=pchann) { - pchann= pchan->next; - curbone= editbone_name_exists(arm->edbo, pchan->name); + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchann) { + pchann = pchan->next; + curbone = editbone_name_exists(arm->edbo, pchan->name); /* check if bone needs to be removed */ if ( (sel && (curbone->flag & BONE_SELECTED)) || - (!sel && !(curbone->flag & BONE_SELECTED)) ) + (!sel && !(curbone->flag & BONE_SELECTED)) ) { EditBone *ebo; bPoseChannel *pchn; /* clear the bone->parent var of any bone that had this as its parent */ - for (ebo= arm->edbo->first; ebo; ebo= ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { if (ebo->parent == curbone) { - ebo->parent= NULL; - ebo->temp= NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */ + ebo->parent = NULL; + ebo->temp = NULL; /* this is needed to prevent random crashes with in ED_armature_from_edit */ ebo->flag &= ~BONE_CONNECTED; } } /* clear the pchan->parent var of any pchan that had this as its parent */ - for (pchn= ob->pose->chanbase.first; pchn; pchn=pchn->next) { + for (pchn = ob->pose->chanbase.first; pchn; pchn = pchn->next) { if (pchn->parent == pchan) - pchn->parent= NULL; + pchn->parent = NULL; } /* free any of the extra-data this pchan might have */ - free_pose_channel(pchan); - free_pose_channels_hash(ob->pose); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(ob->pose); /* get rid of unneeded bone */ bone_free(arm, curbone); @@ -1170,11 +1170,11 @@ static void separate_armature_bones(Object *ob, short sel) } /* separate selected bones into their armature */ -static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) +static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); Object *oldob, *newob; Base *oldbase, *newbase; @@ -1197,14 +1197,14 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) // TODO: use context iterators for this? CTX_DATA_BEGIN (C, Base *, base, visible_bases) { - if (base->object==obedit) base->flag |= 1; + if (base->object == obedit) base->flag |= 1; else base->flag &= ~1; } CTX_DATA_END; /* 1) store starting settings and exit editmode */ - oldob= obedit; - oldbase= BASACT; + oldob = obedit; + oldbase = BASACT; oldob->mode &= ~OB_MODE_POSE; //oldbase->flag &= ~OB_POSEMODE; @@ -1212,8 +1212,8 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) ED_armature_edit_free(obedit); /* 2) duplicate base */ - newbase= ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ - newob= newbase->object; + newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ + newob = newbase->object; newbase->flag &= ~SELECT; @@ -1225,17 +1225,17 @@ static int separate_armature_exec (bContext *C, wmOperator *UNUSED(op)) /* 4) fix links before depsgraph flushes */ // err... or after? separated_armature_fix_links(oldob, newob); - DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ - DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ + DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ + DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ /* 5) restore original conditions */ - obedit= oldob; + obedit = oldob; ED_armature_to_edit(obedit); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); /* recalc/redraw + cleanup */ WM_cursor_wait(0); @@ -1256,20 +1256,20 @@ void ARMATURE_OT_separate(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************** END tools on Editmode Armature **************** */ /* **************** PoseMode & EditMode *************************** */ /* only for opengl selection indices */ -Bone *get_indexed_bone (Object *ob, int index) +Bone *get_indexed_bone(Object *ob, int index) { bPoseChannel *pchan; - if (ob->pose==NULL) return NULL; - index>>=16; // bone selection codes use left 2 bytes + if (ob->pose == NULL) return NULL; + index >>= 16; // bone selection codes use left 2 bytes - pchan= BLI_findlink(&ob->pose->chanbase, index); + pchan = BLI_findlink(&ob->pose->chanbase, index); return pchan ? pchan->bone : NULL; } @@ -1277,22 +1277,22 @@ Bone *get_indexed_bone (Object *ob, int index) /* only bones from base are checked on */ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short findunsel) { - Object *obedit= scene->obedit; // XXX get from context + Object *obedit = scene->obedit; // XXX get from context Bone *bone; EditBone *ebone; - void *firstunSel=NULL, *firstSel=NULL, *data; + void *firstunSel = NULL, *firstSel = NULL, *data; unsigned int hitresult; - short i, takeNext=0, sel; + short i, takeNext = 0, sel; - for (i=0; i< hits; i++) { - hitresult = buffer[3+(i*4)]; + for (i = 0; i < hits; i++) { + hitresult = buffer[3 + (i * 4)]; - if (!(hitresult & BONESEL_NOSEL)) { // -1 - if (hitresult & BONESEL_ANY) { // to avoid including objects in selection + if (!(hitresult & BONESEL_NOSEL)) { // -1 + if (hitresult & BONESEL_ANY) { // to avoid including objects in selection hitresult &= ~(BONESEL_ANY); /* Determine what the current bone is */ - if (obedit==NULL || base->object!=obedit) { + if (obedit == NULL || base->object != obedit) { /* no singular posemode, so check for correct object */ if (base->selcol == (hitresult & 0xFFFF)) { bone = get_indexed_bone(base->object, hitresult); @@ -1305,12 +1305,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * data = bone; } else { - data= NULL; - sel= 0; + data = NULL; + sel = 0; } } else { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; ebone = BLI_findlink(arm->edbo, hitresult); if (findunsel) @@ -1323,12 +1323,12 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * if (data) { if (sel) { - if (!firstSel) firstSel= data; - takeNext=1; + if (!firstSel) firstSel = data; + takeNext = 1; } else { if (!firstunSel) - firstunSel=data; + firstunSel = data; if (takeNext) return data; } @@ -1348,7 +1348,7 @@ static void *get_bone_from_selectbuffer(Scene *scene, Base *base, unsigned int * /* used by posemode as well editmode */ /* only checks scene->basact! */ /* x and y are mouse coords (area space) */ -static void *get_nearest_bone (bContext *C, short findunsel, int x, int y) +static void *get_nearest_bone(bContext *C, short findunsel, int x, int y) { ViewContext vc; rcti rect; @@ -1362,9 +1362,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y) rect.ymin = rect.ymax = y; glInitNames(); - hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); - if (hits>0) + if (hits > 0) return get_bone_from_selectbuffer(vc.scene, vc.scene->basact, buffer, hits, findunsel); return NULL; @@ -1373,9 +1373,9 @@ static void *get_nearest_bone (bContext *C, short findunsel, int x, int y) /* Get the first available child of an editbone */ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_visibility) { - EditBone *curbone, *chbone=NULL; + EditBone *curbone, *chbone = NULL; - for (curbone= arm->edbo->first; curbone; curbone= curbone->next) { + for (curbone = arm->edbo->first; curbone; curbone = curbone->next) { if (curbone->parent == pabone) { if (use_visibility) { if ((arm->layer & curbone->layer) && !(pabone->flag & BONE_HIDDEN_A)) { @@ -1394,7 +1394,7 @@ static EditBone *editbone_get_child(bArmature *arm, EditBone *pabone, short use_ /* **************** Posemode stuff ********************** */ -static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend) +static void selectconnected_posebonechildren(Object *ob, Bone *bone, int extend) { Bone *curBone; @@ -1402,7 +1402,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend if (!(bone->flag & BONE_CONNECTED) || (bone->flag & BONE_UNSELECTABLE)) return; - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name (ob->action, bone->name, !(shift)); if (extend) @@ -1410,7 +1410,7 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend else bone->flag |= BONE_SELECTED; - for (curBone=bone->childbase.first; curBone; curBone=curBone->next) + for (curBone = bone->childbase.first; curBone; curBone = curBone->next) selectconnected_posebonechildren(ob, curBone, extend); } @@ -1418,25 +1418,25 @@ static void selectconnected_posebonechildren (Object *ob, Bone *bone, int extend /* previously known as "selectconnected_posearmature" */ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *ob= CTX_data_edit_object(C); - Bone *bone, *curBone, *next= NULL; - int extend= RNA_boolean_get(op->ptr, "extend"); + Object *ob = CTX_data_edit_object(C); + Bone *bone, *curBone, *next = NULL; + int extend = RNA_boolean_get(op->ptr, "extend"); view3d_operator_needs_opengl(C); if (extend) - bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]); else - bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]); if (!bone) return OPERATOR_CANCELLED; /* Select parents */ - for (curBone=bone; curBone; curBone=next) { + for (curBone = bone; curBone; curBone = next) { /* ignore bone if cannot be selected */ if ((curBone->flag & BONE_UNSELECTABLE) == 0) { - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name (ob->action, curBone->name, !(shift)); if (extend) @@ -1445,26 +1445,26 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, wmEvent *ev curBone->flag |= BONE_SELECTED; if (curBone->flag & BONE_CONNECTED) - next=curBone->parent; + next = curBone->parent; else - next=NULL; + next = NULL; } else - next= NULL; + next = NULL; } /* Select children */ - for (curBone=bone->childbase.first; curBone; curBone=next) + for (curBone = bone->childbase.first; curBone; curBone = next) selectconnected_posebonechildren(ob, curBone, extend); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } static int pose_select_linked_poll(bContext *C) { - return ( ED_operator_view3d_active(C) && ED_operator_posemode(C) ); + return (ED_operator_view3d_active(C) && ED_operator_posemode(C) ); } void POSE_OT_select_linked(wmOperatorType *ot) @@ -1480,7 +1480,7 @@ void POSE_OT_select_linked(wmOperatorType *ot) ot->poll = pose_select_linked_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -1495,70 +1495,70 @@ static int armature_select_linked_invoke(bContext *C, wmOperator *op, wmEvent *e { bArmature *arm; EditBone *bone, *curBone, *next; - int extend= RNA_boolean_get(op->ptr, "extend"); - Object *obedit= CTX_data_edit_object(C); - arm= obedit->data; + int extend = RNA_boolean_get(op->ptr, "extend"); + Object *obedit = CTX_data_edit_object(C); + arm = obedit->data; view3d_operator_needs_opengl(C); if (extend) - bone= get_nearest_bone(C, 0, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 0, event->mval[0], event->mval[1]); else - bone= get_nearest_bone(C, 1, event->mval[0], event->mval[1]); + bone = get_nearest_bone(C, 1, event->mval[0], event->mval[1]); if (!bone) return OPERATOR_CANCELLED; /* Select parents */ - for (curBone=bone; curBone; curBone=next) { + for (curBone = bone; curBone; curBone = next) { if ((curBone->flag & BONE_UNSELECTABLE) == 0) { if (extend) { - curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } else { - curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } if (curBone->flag & BONE_CONNECTED) - next=curBone->parent; + next = curBone->parent; else - next=NULL; + next = NULL; } /* Select children */ while (bone) { - for (curBone=arm->edbo->first; curBone; curBone=next) { + for (curBone = arm->edbo->first; curBone; curBone = next) { next = curBone->next; - if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE)==0) { + if ((curBone->parent == bone) && (curBone->flag & BONE_UNSELECTABLE) == 0) { if (curBone->flag & BONE_CONNECTED) { if (extend) - curBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); else - curBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - bone=curBone; + curBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + bone = curBone; break; } else { - bone=NULL; + bone = NULL; break; } } } if (!curBone) - bone=NULL; + bone = NULL; } ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } static int armature_select_linked_poll(bContext *C) { - return ( ED_operator_view3d_active(C) && ED_operator_editarmature(C) ); + return (ED_operator_view3d_active(C) && ED_operator_editarmature(C) ); } void ARMATURE_OT_select_linked(wmOperatorType *ot) @@ -1574,7 +1574,7 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) ot->poll = armature_select_linked_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties s*/ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -1582,71 +1582,71 @@ void ARMATURE_OT_select_linked(wmOperatorType *ot) /* does bones and points */ /* note that BONE ROOT only gets drawn for root bones (or without IK) */ -static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) +static EditBone *get_nearest_editbonepoint(ViewContext *vc, const int mval[2], ListBase *edbo, int findunsel, int *selmask) { EditBone *ebone; rcti rect; unsigned int buffer[MAXPICKBUF]; - unsigned int hitresult, besthitresult=BONESEL_NOSEL; - int i, mindep= 4; + unsigned int hitresult, besthitresult = BONESEL_NOSEL; + int i, mindep = 4; short hits; glInitNames(); - rect.xmin = mval[0]-5; - rect.xmax = mval[0]+5; - rect.ymin = mval[1]-5; - rect.ymax = mval[1]+5; - - hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); - if (hits==0) { - rect.xmin = mval[0]-12; - rect.xmax = mval[0]+12; - rect.ymin = mval[1]-12; - rect.ymax = mval[1]+12; - hits= view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); + rect.xmin = mval[0] - 5; + rect.xmax = mval[0] + 5; + rect.ymin = mval[1] - 5; + rect.ymax = mval[1] + 5; + + hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); + if (hits == 0) { + rect.xmin = mval[0] - 12; + rect.xmax = mval[0] + 12; + rect.ymin = mval[1] - 12; + rect.ymax = mval[1] + 12; + hits = view3d_opengl_select(vc, buffer, MAXPICKBUF, &rect); } /* See if there are any selected bones in this group */ - if (hits>0) { + if (hits > 0) { - if (hits==1) { + if (hits == 1) { if (!(buffer[3] & BONESEL_NOSEL)) - besthitresult= buffer[3]; + besthitresult = buffer[3]; } else { - for (i=0; i< hits; i++) { - hitresult= buffer[3+(i*4)]; + for (i = 0; i < hits; i++) { + hitresult = buffer[3 + (i * 4)]; if (!(hitresult & BONESEL_NOSEL)) { int dep; ebone = BLI_findlink(edbo, hitresult & ~BONESEL_ANY); /* clicks on bone points get advantage */ - if ( hitresult & (BONESEL_ROOT|BONESEL_TIP)) { + if (hitresult & (BONESEL_ROOT | BONESEL_TIP)) { /* but also the unselected one */ if (findunsel) { - if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL)==0) - dep= 1; - else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL)==0) - dep= 1; + if ( (hitresult & BONESEL_ROOT) && (ebone->flag & BONE_ROOTSEL) == 0) + dep = 1; + else if ( (hitresult & BONESEL_TIP) && (ebone->flag & BONE_TIPSEL) == 0) + dep = 1; else - dep= 2; + dep = 2; } - else dep= 2; + else dep = 2; } else { /* bone found */ if (findunsel) { - if ((ebone->flag & BONE_SELECTED)==0) - dep= 2; + if ((ebone->flag & BONE_SELECTED) == 0) + dep = 2; else - dep= 3; + dep = 3; } - else dep= 3; + else dep = 3; } if (dep < mindep) { - mindep= dep; - besthitresult= hitresult; + mindep = dep; + besthitresult = hitresult; } } } @@ -1654,7 +1654,7 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], if (!(besthitresult & BONESEL_NOSEL)) { - ebone= BLI_findlink(edbo, besthitresult & ~BONESEL_ANY); + ebone = BLI_findlink(edbo, besthitresult & ~BONESEL_ANY); *selmask = 0; if (besthitresult & BONESEL_ROOT) @@ -1675,9 +1675,9 @@ static EditBone *get_nearest_editbonepoint (ViewContext *vc, const int mval[2], static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) { bArmature *arm; - EditBone *curBone, *ebone_next; + EditBone *curBone, *ebone_next; bConstraint *con; - Object *obedit= CTX_data_edit_object(C); // XXX get from context + Object *obedit = CTX_data_edit_object(C); // XXX get from context arm = obedit->data; /* cancel if nothing selected */ @@ -1689,31 +1689,31 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* First erase any associated pose channel */ if (obedit->pose) { bPoseChannel *pchan, *pchan_next; - for (pchan=obedit->pose->chanbase.first; pchan; pchan= pchan_next) { - pchan_next= pchan->next; + for (pchan = obedit->pose->chanbase.first; pchan; pchan = pchan_next) { + pchan_next = pchan->next; curBone = editbone_name_exists(arm->edbo, pchan->name); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { - free_pose_channel(pchan); - free_pose_channels_hash(obedit->pose); - BLI_freelinkN (&obedit->pose->chanbase, pchan); + BKE_pose_channel_free(pchan); + BKE_pose_channels_hash_free(obedit->pose); + BLI_freelinkN(&obedit->pose->chanbase, pchan); } else { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == obedit) { if (ct->subtarget[0]) { curBone = editbone_name_exists(arm->edbo, ct->subtarget); if (curBone && (curBone->flag & BONE_SELECTED) && (arm->layer & curBone->layer)) { con->flag |= CONSTRAINT_DISABLE; - ct->subtarget[0]= 0; + ct->subtarget[0] = 0; } } } @@ -1728,11 +1728,11 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) } - for (curBone=arm->edbo->first; curBone; curBone= ebone_next) { - ebone_next= curBone->next; + for (curBone = arm->edbo->first; curBone; curBone = ebone_next) { + ebone_next = curBone->next; if (arm->layer & curBone->layer) { if (curBone->flag & BONE_SELECTED) { - if (curBone==arm->act_edbone) arm->act_edbone= NULL; + if (curBone == arm->act_edbone) arm->act_edbone = NULL; ED_armature_edit_bone_remove(arm, curBone); } } @@ -1741,7 +1741,7 @@ static int armature_delete_selected_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -1759,7 +1759,7 @@ void ARMATURE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* toggle==0: deselect @@ -1768,35 +1768,35 @@ void ARMATURE_OT_delete(wmOperatorType *ot) */ void ED_armature_deselect_all(Object *obedit, int toggle) { - bArmature *arm= obedit->data; - EditBone *eBone; - int sel=1; + bArmature *arm = obedit->data; + EditBone *eBone; + int sel = 1; - if (toggle==1) { + if (toggle == 1) { /* Determine if there are any selected bones * and therefore whether we are selecting or deselecting */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { // if (arm->layer & eBone->layer) { if (eBone->flag & (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL)) { - sel=0; + sel = 0; break; } // } } } - else sel= toggle; + else sel = toggle; /* Set the flags */ - for (eBone=arm->edbo->first;eBone;eBone=eBone->next) { - if (sel==2) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { + if (sel == 2) { /* invert selection of bone */ if (EBONE_VISIBLE(arm, eBone)) { eBone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if (arm->act_edbone==eBone) - arm->act_edbone= NULL; + if (arm->act_edbone == eBone) + arm->act_edbone = NULL; } } - else if (sel==1) { + else if (sel == 1) { /* select bone */ if (EBONE_VISIBLE(arm, eBone)) { eBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); @@ -1807,8 +1807,8 @@ void ED_armature_deselect_all(Object *obedit, int toggle) else { /* deselect bone */ eBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if (arm->act_edbone==eBone) - arm->act_edbone= NULL; + if (arm->act_edbone == eBone) + arm->act_edbone = NULL; } } @@ -1817,12 +1817,12 @@ void ED_armature_deselect_all(Object *obedit, int toggle) void ED_armature_deselect_all_visible(Object *obedit) { - bArmature *arm= obedit->data; - EditBone *ebone; + bArmature *arm = obedit->data; + EditBone *ebone; - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ - if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE)==0) { + if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) { ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } } @@ -1834,27 +1834,27 @@ void ED_armature_deselect_all_visible(Object *obedit) static int ebone_select_flag(EditBone *ebone) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { - return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED|BONE_TIPSEL)); + return ((ebone->parent->flag & BONE_TIPSEL) ? BONE_ROOTSEL : 0) | (ebone->flag & (BONE_SELECTED | BONE_TIPSEL)); } else { - return ebone->flag & (BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + return ebone->flag & (BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); } } /* context: editmode armature in view3d */ int mouse_armature(bContext *C, const int mval[2], int extend) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; ViewContext vc; EditBone *nearBone = NULL; - int selmask; + int selmask; view3d_set_viewcontext(C, &vc); BIF_sk_selectStroke(C, mval, extend); - nearBone= get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask); + nearBone = get_nearest_editbonepoint(&vc, mval, arm->edbo, 1, &selmask); if (nearBone) { if (!extend) @@ -1870,7 +1870,7 @@ int mouse_armature(bContext *C, const int mval[2], int extend) /* hold shift inverts this bone's selection */ if (nearBone->flag & BONE_SELECTED) { /* deselect this bone */ - nearBone->flag &= ~(BONE_TIPSEL|BONE_SELECTED); + nearBone->flag &= ~(BONE_TIPSEL | BONE_SELECTED); /* only deselect parent tip if it is not selected */ if (!(nearBone->parent->flag & BONE_SELECTED)) nearBone->parent->flag &= ~BONE_TIPSEL; @@ -1891,11 +1891,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend) if (extend) { /* hold shift inverts this bone's selection */ if (nearBone->flag & BONE_SELECTED) - nearBone->flag &= ~(BONE_TIPSEL|BONE_ROOTSEL); + nearBone->flag &= ~(BONE_TIPSEL | BONE_ROOTSEL); else - nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL); + nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL); } - else nearBone->flag |= (BONE_TIPSEL|BONE_ROOTSEL); + else nearBone->flag |= (BONE_TIPSEL | BONE_ROOTSEL); } } else { @@ -1910,11 +1910,11 @@ int mouse_armature(bContext *C, const int mval[2], int extend) if (nearBone) { /* then now check for active status */ if (ebone_select_flag(nearBone)) { - arm->act_edbone= nearBone; + arm->act_edbone = nearBone; } } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, vc.obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, vc.obedit); return 1; } @@ -1923,13 +1923,13 @@ int mouse_armature(bContext *C, const int mval[2], int extend) void ED_armature_edit_free(struct Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; EditBone *eBone; /* Clear the editbones list */ if (arm->edbo) { if (arm->edbo->first) { - for (eBone=arm->edbo->first; eBone; eBone=eBone->next) { + for (eBone = arm->edbo->first; eBone; eBone = eBone->next) { if (eBone->prop) { IDP_FreeProperty(eBone->prop); MEM_freeN(eBone->prop); @@ -1939,19 +1939,19 @@ void ED_armature_edit_free(struct Object *ob) BLI_freelistN(arm->edbo); } MEM_freeN(arm->edbo); - arm->edbo= NULL; + arm->edbo = NULL; } } /* Put armature in EditMode */ void ED_armature_to_edit(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; ED_armature_edit_free(ob); - arm->edbo= MEM_callocN(sizeof(ListBase), "edbo armature"); - arm->act_edbone= make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone); - arm->act_bone= NULL; + arm->edbo = MEM_callocN(sizeof(ListBase), "edbo armature"); + arm->act_edbone = make_boneList(arm->edbo, &arm->bonebase, NULL, arm->act_bone); + arm->act_bone = NULL; // BIF_freeTemplates(); /* force template update when entering editmode */ } @@ -1977,7 +1977,7 @@ float ED_rollBoneToVector(EditBone *bone, const float align_axis[3], const short sub_v3_v3v3(align_axis_proj, align_axis, vec); if (axis_only) { - if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI/2.0)) { + if (angle_v3v3(align_axis_proj, mat[2]) > (float)(M_PI / 2.0)) { negate_v3(align_axis_proj); } } @@ -2010,44 +2010,44 @@ static EnumPropertyItem prop_calc_roll_types[] = { static int armature_calc_roll_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - const short type= RNA_enum_get(op->ptr, "type"); - const short axis_only= RNA_boolean_get(op->ptr, "axis_only"); - const short axis_flip= RNA_boolean_get(op->ptr, "axis_flip"); + Object *ob = CTX_data_edit_object(C); + const short type = RNA_enum_get(op->ptr, "type"); + const short axis_only = RNA_boolean_get(op->ptr, "axis_only"); + const short axis_flip = RNA_boolean_get(op->ptr, "axis_flip"); float imat[3][3]; - bArmature *arm= ob->data; + bArmature *arm = ob->data; EditBone *ebone; copy_m3_m4(imat, ob->obmat); invert_m3(imat); - if (type==7) { /* Cursor */ - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); /* can be NULL */ + if (type == 7) { /* Cursor */ + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ float cursor_local[3]; - float *cursor= give_cursor(scene, v3d); + float *cursor = give_cursor(scene, v3d); copy_v3_v3(cursor_local, cursor); mul_m3_v3(imat, cursor_local); /* cursor */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { float cursor_rel[3]; sub_v3_v3v3(cursor_rel, cursor_local, ebone->head); if (axis_flip) negate_v3(cursor_rel); - ebone->roll= ED_rollBoneToVector(ebone, cursor_rel, axis_only); + ebone->roll = ED_rollBoneToVector(ebone, cursor_rel, axis_only); } } } else { - float vec[3]= {0.0f, 0.0f, 0.0f}; - if (type==6) { /* View */ - RegionView3D *rv3d= CTX_wm_region_view3d(C); - if (rv3d==NULL) { + float vec[3] = {0.0f, 0.0f, 0.0f}; + if (type == 6) { /* View */ + RegionView3D *rv3d = CTX_wm_region_view3d(C); + if (rv3d == NULL) { BKE_report(op->reports, RPT_ERROR, "No region view3d available"); return OPERATOR_CANCELLED; } @@ -2055,10 +2055,10 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) copy_v3_v3(vec, rv3d->viewinv[2]); mul_m3_v3(imat, vec); } - else if (type==5) { + else if (type == 5) { float mat[3][3], nor[3]; - ebone= (EditBone *)arm->act_edbone; - if (ebone==NULL) { + ebone = (EditBone *)arm->act_edbone; + if (ebone == NULL) { BKE_report(op->reports, RPT_ERROR, "No active bone set"); return OPERATOR_CANCELLED; } @@ -2069,34 +2069,34 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) } else { /* Axis */ assert(type >= 0 && type <= 5); - if (type<3) vec[type]= 1.0f; - else vec[type-2]= -1.0f; + if (type < 3) vec[type] = 1.0f; + else vec[type - 2] = -1.0f; mul_m3_v3(imat, vec); } if (axis_flip) negate_v3(vec); - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) { /* roll func is a callback which assumes that all is well */ - ebone->roll= ED_rollBoneToVector(ebone, vec, axis_only); + ebone->roll = ED_rollBoneToVector(ebone, vec, axis_only); } } } if (arm->flag & ARM_MIRROR_EDIT) { - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if ((EBONE_VISIBLE(arm, ebone) && EBONE_EDITABLE(ebone)) == 0) { - EditBone *ebone_mirr= ED_armature_bone_get_mirrored(arm->edbo, ebone); + EditBone *ebone_mirr = ED_armature_bone_get_mirrored(arm->edbo, ebone); if (ebone_mirr && (EBONE_VISIBLE(arm, ebone_mirr) && EBONE_EDITABLE(ebone_mirr))) { - ebone->roll= -ebone_mirr->roll; + ebone->roll = -ebone_mirr->roll; } } } } /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2114,7 +2114,7 @@ void ARMATURE_OT_calculate_roll(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_calc_roll_types, 0, "Type", ""); @@ -2131,61 +2131,61 @@ typedef struct UndoArmature { static void undoBones_to_editBones(void *uarmv, void *armv, void *UNUSED(data)) { - UndoArmature *uarm= uarmv; - bArmature *arm= armv; + UndoArmature *uarm = uarmv; + bArmature *arm = armv; EditBone *ebo, *newebo; BLI_freelistN(arm->edbo); /* copy */ - for (ebo= uarm->lb.first; ebo; ebo= ebo->next) { - newebo= MEM_dupallocN(ebo); - ebo->temp= newebo; + for (ebo = uarm->lb.first; ebo; ebo = ebo->next) { + newebo = MEM_dupallocN(ebo); + ebo->temp = newebo; BLI_addtail(arm->edbo, newebo); } /* active bone */ if (uarm->act_edbone) { - ebo= uarm->act_edbone; - arm->act_edbone= ebo->temp; + ebo = uarm->act_edbone; + arm->act_edbone = ebo->temp; } else - arm->act_edbone= NULL; + arm->act_edbone = NULL; /* set pointers */ - for (newebo= arm->edbo->first; newebo; newebo= newebo->next) { - if (newebo->parent) newebo->parent= newebo->parent->temp; + for (newebo = arm->edbo->first; newebo; newebo = newebo->next) { + if (newebo->parent) newebo->parent = newebo->parent->temp; } /* be sure they don't hang ever */ - for (newebo= arm->edbo->first; newebo; newebo= newebo->next) { - newebo->temp= NULL; + for (newebo = arm->edbo->first; newebo; newebo = newebo->next) { + newebo->temp = NULL; } } static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata)) { - bArmature *arm= armv; + bArmature *arm = armv; UndoArmature *uarm; EditBone *ebo, *newebo; - uarm= MEM_callocN(sizeof(UndoArmature), "listbase undo"); + uarm = MEM_callocN(sizeof(UndoArmature), "listbase undo"); /* copy */ - for (ebo= arm->edbo->first; ebo; ebo= ebo->next) { - newebo= MEM_dupallocN(ebo); - ebo->temp= newebo; + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { + newebo = MEM_dupallocN(ebo); + ebo->temp = newebo; BLI_addtail(&uarm->lb, newebo); } /* active bone */ if (arm->act_edbone) { - ebo= arm->act_edbone; - uarm->act_edbone= ebo->temp; + ebo = arm->act_edbone; + uarm->act_edbone = ebo->temp; } /* set pointers */ - for (newebo= uarm->lb.first; newebo; newebo= newebo->next) { - if (newebo->parent) newebo->parent= newebo->parent->temp; + for (newebo = uarm->lb.first; newebo; newebo = newebo->next) { + if (newebo->parent) newebo->parent = newebo->parent->temp; } return uarm; @@ -2193,7 +2193,7 @@ static void *editBones_to_undoBones(void *armv, void *UNUSED(obdata)) static void free_undoBones(void *uarmv) { - UndoArmature *uarm= uarmv; + UndoArmature *uarm = uarmv; BLI_freelistN(&uarm->lb); MEM_freeN(uarm); @@ -2201,8 +2201,8 @@ static void free_undoBones(void *uarmv) static void *get_armature_edit(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_ARMATURE) { + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_ARMATURE) { return obedit->data; } return NULL; @@ -2223,7 +2223,7 @@ void undo_push_armature(bContext *C, const char *name) /* default bone add, returns it selected, but without tail set */ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) { - EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone"); + EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); BLI_strncpy(bone->name, name, sizeof(bone->name)); unique_editbone_name(arm->edbo, bone->name, NULL); @@ -2231,16 +2231,16 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) BLI_addtail(arm->edbo, bone); bone->flag |= BONE_TIPSEL; - bone->weight= 1.0f; - bone->dist= 0.25f; - bone->xwidth= 0.1f; - bone->zwidth= 0.1f; - bone->ease1= 1.0f; - bone->ease2= 1.0f; - bone->rad_head= 0.10f; - bone->rad_tail= 0.05f; - bone->segments= 1; - bone->layer= arm->layer; + bone->weight = 1.0f; + bone->dist = 0.25f; + bone->xwidth = 0.1f; + bone->zwidth = 0.1f; + bone->ease1 = 1.0f; + bone->ease2 = 1.0f; + bone->rad_head = 0.10f; + bone->rad_tail = 0.05f; + bone->segments = 1; + bone->layer = arm->layer; return bone; } @@ -2248,10 +2248,10 @@ EditBone *ED_armature_edit_bone_add(bArmature *arm, const char *name) /* v3d and rv3d are allowed to be NULL */ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; - float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; - EditBone *bone; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; + float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; + EditBone *bone; /* Get inverse point for head and orientation for tail */ invert_m4_m4(obedit->imat, obedit->obmat); @@ -2268,16 +2268,16 @@ void add_primitive_bone(Scene *scene, View3D *v3d, RegionView3D *rv3d) ED_armature_deselect_all(obedit, 0); /* Create a bone */ - bone= ED_armature_edit_bone_add(arm, "Bone"); + bone = ED_armature_edit_bone_add(arm, "Bone"); - arm->act_edbone= bone; + arm->act_edbone = bone; copy_v3_v3(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z } @@ -2290,25 +2290,25 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) bArmature *arm; EditBone *ebone, *newbone, *flipbone; float *curs, mat[3][3], imat[3][3]; - int a, to_root= 0; + int a, to_root = 0; Object *obedit; Scene *scene; scene = CTX_data_scene(C); - v3d= CTX_wm_view3d(C); - obedit= CTX_data_edit_object(C); - arm= obedit->data; + v3d = CTX_wm_view3d(C); + obedit = CTX_data_edit_object(C); + arm = obedit->data; /* find the active or selected bone */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_TIPSEL || arm->act_edbone == ebone) break; } } - if (ebone==NULL) { - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + if (ebone == NULL) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL || arm->act_edbone == ebone) break; @@ -2317,60 +2317,60 @@ static int armature_click_extrude_exec(bContext *C, wmOperator *UNUSED(op)) if (ebone == NULL) return OPERATOR_CANCELLED; - to_root= 1; + to_root = 1; } ED_armature_deselect_all(obedit, 0); /* we re-use code for mirror editing... */ - flipbone= NULL; + flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) - flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); - for (a=0; a<2; a++) { - if (a==1) { - if (flipbone==NULL) + for (a = 0; a < 2; a++) { + if (a == 1) { + if (flipbone == NULL) break; else { SWAP(EditBone *, flipbone, ebone); } } - newbone= ED_armature_edit_bone_add(arm, ebone->name); - arm->act_edbone= newbone; + newbone = ED_armature_edit_bone_add(arm, ebone->name); + arm->act_edbone = newbone; if (to_root) { copy_v3_v3(newbone->head, ebone->head); - newbone->rad_head= ebone->rad_tail; - newbone->parent= ebone->parent; + newbone->rad_head = ebone->rad_tail; + newbone->parent = ebone->parent; } else { copy_v3_v3(newbone->head, ebone->tail); - newbone->rad_head= ebone->rad_tail; - newbone->parent= ebone; + newbone->rad_head = ebone->rad_tail; + newbone->parent = ebone; newbone->flag |= BONE_CONNECTED; } - curs= give_cursor(scene, v3d); + curs = give_cursor(scene, v3d); copy_v3_v3(newbone->tail, curs); sub_v3_v3v3(newbone->tail, newbone->tail, obedit->obmat[3]); - if (a==1) - newbone->tail[0]= -newbone->tail[0]; + if (a == 1) + newbone->tail[0] = -newbone->tail[0]; copy_m3_m4(mat, obedit->obmat); invert_m3_m3(imat, mat); mul_m3_v3(imat, newbone->tail); - newbone->length= len_v3v3(newbone->head, newbone->tail); - newbone->rad_tail= newbone->length*0.05f; - newbone->dist= newbone->length*0.25f; + newbone->length = len_v3v3(newbone->head, newbone->tail); + newbone->rad_tail = newbone->length * 0.05f; + newbone->dist = newbone->length * 0.25f; } ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -2387,11 +2387,11 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e float *fp = NULL, tvec[3], oldcurs[3], mval_f[2]; int retv; - scene= CTX_data_scene(C); - ar= CTX_wm_region(C); + scene = CTX_data_scene(C); + ar = CTX_wm_region(C); v3d = CTX_wm_view3d(C); - fp= give_cursor(scene, v3d); + fp = give_cursor(scene, v3d); copy_v3_v3(oldcurs, fp); @@ -2400,7 +2400,7 @@ static int armature_click_extrude_invoke(bContext *C, wmOperator *op, wmEvent *e copy_v3_v3(fp, tvec); /* extrude to the where new cursor is and store the operation result */ - retv= armature_click_extrude_exec(C, op); + retv = armature_click_extrude_exec(C, op); /* restore previous 3d cursor position */ copy_v3_v3(fp, oldcurs); @@ -2421,17 +2421,17 @@ void ARMATURE_OT_click_extrude(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ } /* adds an EditBone between the nominated locations (should be in the right space) */ -static EditBone *add_points_bone (Object *obedit, float head[], float tail[]) +static EditBone *add_points_bone(Object *obedit, float head[], float tail[]) { EditBone *ebo; - ebo= ED_armature_edit_bone_add(obedit->data, "Bone"); + ebo = ED_armature_edit_bone_add(obedit->data, "Bone"); copy_v3_v3(ebo->head, head); copy_v3_v3(ebo->tail, tail); @@ -2445,7 +2445,7 @@ static EditBone *get_named_editbone(ListBase *edbo, char *name) EditBone *eBone; if (name) { - for (eBone=edbo->first; eBone; eBone=eBone->next) { + for (eBone = edbo->first; eBone; eBone = eBone->next) { if (!strcmp(name, eBone->name)) return eBone; } @@ -2481,20 +2481,20 @@ void updateDuplicateSubtargetObjects(EditBone *dupBone, ListBase *editbones, Obj bConstraint *curcon; ListBase *conlist; - if ( (pchan = verify_pose_channel(dst_ob->pose, dupBone->name)) ) { + if ( (pchan = BKE_pose_channel_verify(dst_ob->pose, dupBone->name)) ) { if ( (conlist = &pchan->constraints) ) { - for (curcon = conlist->first; curcon; curcon=curcon->next) { + for (curcon = conlist->first; curcon; curcon = curcon->next) { /* does this constraint have a subtarget in * this armature? */ - bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon); + bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == src_ob) && (ct->subtarget[0])) { ct->tar = dst_ob; /* update target */ oldtarget = get_named_editbone(editbones, ct->subtarget); @@ -2544,7 +2544,7 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase /* copy the ID property */ if (curBone->prop) - eBone->prop= IDP_CopyProperty(curBone->prop); + eBone->prop = IDP_CopyProperty(curBone->prop); /* Lets duplicate the list of constraints that the * current bone has. @@ -2552,15 +2552,15 @@ EditBone *duplicateEditBoneObjects(EditBone *curBone, const char *name, ListBase if (src_ob->pose) { bPoseChannel *chanold, *channew; - chanold = verify_pose_channel(src_ob->pose, curBone->name); + chanold = BKE_pose_channel_verify(src_ob->pose, curBone->name); if (chanold) { /* WARNING: this creates a new posechannel, but there will not be an attached bone * yet as the new bones created here are still 'EditBones' not 'Bones'. */ - channew= verify_pose_channel(dst_ob->pose, eBone->name); + channew = BKE_pose_channel_verify(dst_ob->pose, eBone->name); if (channew) { - duplicate_pose_channel_data(channew, chanold); + BKE_pose_channel_copy_data(channew, chanold); } } } @@ -2577,12 +2577,12 @@ EditBone *duplicateEditBone(EditBone *curBone, const char *name, ListBase *editb static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) { bArmature *arm; - EditBone *eBone = NULL; - EditBone *curBone; - EditBone *firstDup=NULL; /* The beginning of the duplicated bones in the edbo list */ + EditBone *eBone = NULL; + EditBone *curBone; + EditBone *firstDup = NULL; /* The beginning of the duplicated bones in the edbo list */ - Object *obedit= CTX_data_edit_object(C); - arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + arm = obedit->data; /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) @@ -2594,7 +2594,7 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* Select mirrored bones */ if (arm->flag & ARM_MIRROR_EDIT) { - for (curBone=arm->edbo->first; curBone; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { eBone = ED_armature_bone_get_mirrored(arm->edbo, curBone); @@ -2607,24 +2607,24 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* Find the selected bones and duplicate them as needed */ - for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { - eBone= duplicateEditBone(curBone, curBone->name, arm->edbo, obedit); + eBone = duplicateEditBone(curBone, curBone->name, arm->edbo, obedit); if (!firstDup) - firstDup=eBone; + firstDup = eBone; } } } /* Run though the list and fix the pointers */ - for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) { if (curBone->flag & BONE_SELECTED) { - eBone=(EditBone*) curBone->temp; + eBone = (EditBone *) curBone->temp; if (!curBone->parent) { /* If this bone has no parent, @@ -2636,13 +2636,13 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* If this bone has a parent that was duplicated, * Set the duplicate->parent to the curBone->parent->temp */ - eBone->parent= (EditBone *)curBone->parent->temp; + eBone->parent = (EditBone *)curBone->parent->temp; } else { /* If this bone has a parent that IS not selected, * Set the duplicate->parent to the curBone->parent */ - eBone->parent=(EditBone*) curBone->parent; + eBone->parent = (EditBone *) curBone->parent; eBone->flag &= ~BONE_CONNECTED; } @@ -2656,20 +2656,20 @@ static int armature_duplicate_selected_exec(bContext *C, wmOperator *UNUSED(op)) /* correct the active bone */ if (arm->act_edbone) { - eBone= arm->act_edbone; + eBone = arm->act_edbone; if (eBone->temp) - arm->act_edbone= eBone->temp; + arm->act_edbone = eBone->temp; } /* Deselect the old bones and select the new ones */ - for (curBone=arm->edbo->first; curBone && curBone!=firstDup; curBone=curBone->next) { + for (curBone = arm->edbo->first; curBone && curBone != firstDup; curBone = curBone->next) { if (EBONE_VISIBLE(arm, curBone)) curBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } ED_armature_validate_active(arm); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -2687,7 +2687,7 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -2698,27 +2698,27 @@ void ARMATURE_OT_duplicate(wmOperatorType *ot) typedef struct EditBonePoint { struct EditBonePoint *next, *prev; - EditBone *head_owner; /* EditBone which uses this point as a 'head' point */ - EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */ + EditBone *head_owner; /* EditBone which uses this point as a 'head' point */ + EditBone *tail_owner; /* EditBone which uses this point as a 'tail' point */ - float vec[3]; /* the actual location of the point in local/EditMode space */ + float vec[3]; /* the actual location of the point in local/EditMode space */ } EditBonePoint; /* find chain-tips (i.e. bones without children) */ -static void chains_find_tips (ListBase *edbo, ListBase *list) +static void chains_find_tips(ListBase *edbo, ListBase *list) { EditBone *curBone, *ebo; LinkData *ld; /* note: this is potentially very slow ... there's got to be a better way */ - for (curBone= edbo->first; curBone; curBone= curBone->next) { - short stop= 0; + for (curBone = edbo->first; curBone; curBone = curBone->next) { + short stop = 0; /* is this bone contained within any existing chain? (skip if so) */ - for (ld= list->first; ld; ld= ld->next) { - for (ebo= ld->data; ebo; ebo= ebo->parent) { + for (ld = list->first; ld; ld = ld->next) { + for (ebo = ld->data; ebo; ebo = ebo->parent) { if (ebo == curBone) { - stop= 1; + stop = 1; break; } } @@ -2729,12 +2729,12 @@ static void chains_find_tips (ListBase *edbo, ListBase *list) if (stop) continue; /* is any existing chain part of the chain formed by this bone? */ - stop= 0; - for (ebo= curBone->parent; ebo; ebo= ebo->parent) { - for (ld= list->first; ld; ld= ld->next) { + stop = 0; + for (ebo = curBone->parent; ebo; ebo = ebo->parent) { + for (ld = list->first; ld; ld = ld->next) { if (ld->data == ebo) { - ld->data= curBone; - stop= 1; + ld->data = curBone; + stop = 1; break; } } @@ -2745,19 +2745,19 @@ static void chains_find_tips (ListBase *edbo, ListBase *list) if (stop) continue; /* add current bone to a new chain */ - ld= MEM_callocN(sizeof(LinkData), "BoneChain"); - ld->data= curBone; + ld = MEM_callocN(sizeof(LinkData), "BoneChain"); + ld->data = curBone; BLI_addtail(list, ld); } } /* --------------------- */ -static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) +static void fill_add_joint(EditBone *ebo, short eb_tail, ListBase *points) { EditBonePoint *ebp; float vec[3]; - short found= 0; + short found = 0; if (eb_tail) { copy_v3_v3(vec, ebo->tail); @@ -2766,20 +2766,20 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) copy_v3_v3(vec, ebo->head); } - for (ebp= points->first; ebp; ebp= ebp->next) { + for (ebp = points->first; ebp; ebp = ebp->next) { if (equals_v3v3(ebp->vec, vec)) { if (eb_tail) { if ((ebp->head_owner) && (ebp->head_owner->parent == ebo)) { /* so this bone's tail owner is this bone */ - ebp->tail_owner= ebo; - found= 1; + ebp->tail_owner = ebo; + found = 1; break; } } else { if ((ebp->tail_owner) && (ebo->parent == ebp->tail_owner)) { /* so this bone's head owner is this bone */ - ebp->head_owner= ebo; + ebp->head_owner = ebo; found = 1; break; } @@ -2789,15 +2789,15 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) /* allocate a new point if no existing point was related */ if (found == 0) { - ebp= MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); + ebp = MEM_callocN(sizeof(EditBonePoint), "EditBonePoint"); if (eb_tail) { copy_v3_v3(ebp->vec, ebo->tail); - ebp->tail_owner= ebo; + ebp->tail_owner = ebo; } else { copy_v3_v3(ebp->vec, ebo->head); - ebp->head_owner= ebo; + ebp->head_owner = ebo; } BLI_addtail(points, ebp); @@ -2805,12 +2805,12 @@ static void fill_add_joint (EditBone *ebo, short eb_tail, ListBase *points) } /* bone adding between selected joints */ -static int armature_fill_bones_exec (bContext *C, wmOperator *op) +static int armature_fill_bones_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= (obedit) ? obedit->data : NULL; - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = (obedit) ? obedit->data : NULL; + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); ListBase points = {NULL, NULL}; int count; @@ -2829,11 +2829,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* the number of joints determines how we fill: - * 1) between joint and cursor (joint=head, cursor=tail) - * 2) between the two joints (order is dependent on active-bone/hierachy) - * 3+) error (a smarter method involving finding chains needs to be worked out + * 1) between joint and cursor (joint=head, cursor=tail) + * 2) between the two joints (order is dependent on active-bone/hierachy) + * 3+) error (a smarter method involving finding chains needs to be worked out */ - count= BLI_countlist(&points); + count = BLI_countlist(&points); if (count == 0) { BKE_report(op->reports, RPT_ERROR, "No joints selected"); @@ -2844,7 +2844,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) float curs[3]; /* Get Points - selected joint */ - ebp= (EditBonePoint *)points.first; + ebp = (EditBonePoint *)points.first; /* Get points - cursor (tail) */ invert_m4_m4(obedit->imat, obedit->obmat); @@ -2859,15 +2859,15 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) short headtail = 0; /* check that the points don't belong to the same bone */ - ebp= (EditBonePoint *)points.first; - ebp2= ebp->next; + ebp = (EditBonePoint *)points.first; + ebp2 = ebp->next; - if ((ebp->head_owner==ebp2->tail_owner) && (ebp->head_owner!=NULL)) { + if ((ebp->head_owner == ebp2->tail_owner) && (ebp->head_owner != NULL)) { BKE_report(op->reports, RPT_ERROR, "Same bone selected..."); BLI_freelistN(&points); return OPERATOR_CANCELLED; } - if ((ebp->tail_owner==ebp2->head_owner) && (ebp->tail_owner!=NULL)) { + if ((ebp->tail_owner == ebp2->head_owner) && (ebp->tail_owner != NULL)) { BKE_report(op->reports, RPT_ERROR, "Same bone selected..."); BLI_freelistN(&points); return OPERATOR_CANCELLED; @@ -2887,11 +2887,11 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* get distances */ sub_v3_v3v3(vecA, ebp->vec, curs); sub_v3_v3v3(vecB, ebp2->vec, curs); - distA= len_v3(vecA); - distB= len_v3(vecB); + distA = len_v3(vecA); + distB = len_v3(vecB); /* compare distances - closer one therefore acts as direction for bone to go */ - headtail= (distA < distB) ? 2 : 1; + headtail = (distA < distB) ? 2 : 1; } else if (ebp->head_owner) { headtail = 1; @@ -2912,22 +2912,22 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) /* add new bone and parent it to the appropriate end */ if (headtail) { - EditBone *newbone= add_points_bone(obedit, head, tail); + EditBone *newbone = add_points_bone(obedit, head, tail); /* do parenting (will need to set connected flag too) */ if (headtail == 2) { /* ebp tail or head - tail gets priority */ if (ebp->tail_owner) - newbone->parent= ebp->tail_owner; + newbone->parent = ebp->tail_owner; else - newbone->parent= ebp->head_owner; + newbone->parent = ebp->head_owner; } else { /* ebp2 tail or head - tail gets priority */ if (ebp2->tail_owner) - newbone->parent= ebp2->tail_owner; + newbone->parent = ebp2->tail_owner; else - newbone->parent= ebp2->head_owner; + newbone->parent = ebp2->head_owner; } newbone->flag |= BONE_CONNECTED; @@ -2941,7 +2941,7 @@ static int armature_fill_bones_exec (bContext *C, wmOperator *op) } /* updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); /* free points */ BLI_freelistN(&points); @@ -2961,7 +2961,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------------------- */ @@ -2971,7 +2971,7 @@ void ARMATURE_OT_fill(wmOperatorType *ot) */ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone *endchild, ListBase *chains) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *ebo, *ebone, *newbone; LinkData *chain; float head[3], tail[3]; @@ -2989,23 +2989,23 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone * - tail = head/tail of end (default tail) * - parent = parent of start */ - if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED)==0) { + if ((start->flag & BONE_TIPSEL) && (start->flag & BONE_SELECTED) == 0) { copy_v3_v3(head, start->tail); } else { copy_v3_v3(head, start->head); } - if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED)==0) { + if ((end->flag & BONE_ROOTSEL) && (end->flag & BONE_SELECTED) == 0) { copy_v3_v3(tail, end->head); } else { copy_v3_v3(tail, end->tail); } - newbone= add_points_bone(obedit, head, tail); + newbone = add_points_bone(obedit, head, tail); newbone->parent = start->parent; /* TODO, copy more things to the new bone */ - newbone->flag= start->flag & (BONE_HINGE|BONE_NO_DEFORM|BONE_NO_SCALE|BONE_NO_CYCLICOFFSET|BONE_NO_LOCAL_LOCATION|BONE_DONE); + newbone->flag = start->flag & (BONE_HINGE | BONE_NO_DEFORM | BONE_NO_SCALE | BONE_NO_CYCLICOFFSET | BONE_NO_LOCAL_LOCATION | BONE_DONE); /* step 2a: reparent any side chains which may be parented to any bone in the chain of bones to merge * - potentially several tips for side chains leading to some tree exist... @@ -3037,24 +3037,24 @@ static void bones_merge(Object *obedit, EditBone *start, EditBone *end, EditBone /* step 2b: parent child of end to newbone (child from this chain) */ if (endchild) - endchild->parent= newbone; + endchild->parent = newbone; /* step 3: delete all bones between and including start and end */ - for (ebo= end; ebo; ebo= ebone) { - ebone= (ebo == start) ? (NULL) : (ebo->parent); + for (ebo = end; ebo; ebo = ebone) { + ebone = (ebo == start) ? (NULL) : (ebo->parent); bone_free(arm, ebo); } - newbone->flag |= (BONE_ROOTSEL|BONE_TIPSEL|BONE_SELECTED); + newbone->flag |= (BONE_ROOTSEL | BONE_TIPSEL | BONE_SELECTED); ED_armature_sync_selection(arm->edbo); } -static int armature_merge_exec (bContext *C, wmOperator *op) +static int armature_merge_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= (obedit) ? obedit->data : NULL; - short type= RNA_enum_get(op->ptr, "type"); + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = (obedit) ? obedit->data : NULL; + short type = RNA_enum_get(op->ptr, "type"); /* sanity checks */ if (ELEM(NULL, obedit, arm)) @@ -3074,28 +3074,28 @@ static int armature_merge_exec (bContext *C, wmOperator *op) if (chains.first == NULL) return OPERATOR_CANCELLED; /* each 'chain' is the last bone in the chain (with no children) */ - for (chain= chains.first; chain; chain= nchain) { - EditBone *bstart= NULL, *bend= NULL; - EditBone *bchild= NULL, *child=NULL; + for (chain = chains.first; chain; chain = nchain) { + EditBone *bstart = NULL, *bend = NULL; + EditBone *bchild = NULL, *child = NULL; /* temporarily remove chain from list of chains */ - nchain= chain->next; + nchain = chain->next; BLI_remlink(&chains, chain); /* only consider bones that are visible and selected */ - for (ebo=chain->data; ebo; child=ebo, ebo=ebo->parent) { + for (ebo = chain->data; ebo; child = ebo, ebo = ebo->parent) { /* check if visible + selected */ - if ( EBONE_VISIBLE(arm, ebo) && - ((ebo->flag & BONE_CONNECTED) || (ebo->parent==NULL)) && - (ebo->flag & BONE_SELECTED) ) + if (EBONE_VISIBLE(arm, ebo) && + ((ebo->flag & BONE_CONNECTED) || (ebo->parent == NULL)) && + (ebo->flag & BONE_SELECTED) ) { /* set either end or start (end gets priority, unless it is already set) */ if (bend == NULL) { - bend= ebo; - bchild= child; + bend = ebo; + bchild = child; } else - bstart= ebo; + bstart = ebo; } else { /* chain is broken... merge any continous segments then clear */ @@ -3123,7 +3123,7 @@ static int armature_merge_exec (bContext *C, wmOperator *op) /* updates */ ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, obedit); return OPERATOR_FINISHED; } @@ -3146,7 +3146,7 @@ void ARMATURE_OT_merge(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", merge_types, 0, "Type", ""); @@ -3157,19 +3157,19 @@ void ARMATURE_OT_merge(wmOperatorType *ot) static int armature_hide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; EditBone *ebone; - const int invert= RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0; + const int invert = RNA_boolean_get(op->ptr, "unselected") ? BONE_SELECTED : 0; /* cancel if nothing selected */ if (CTX_DATA_COUNT(C, selected_bones) == 0) return OPERATOR_CANCELLED; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if ((ebone->flag & BONE_SELECTED) != invert) { - ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag |= BONE_HIDDEN_A; } } @@ -3177,7 +3177,7 @@ static int armature_hide_exec(bContext *C, wmOperator *op) ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3194,7 +3194,7 @@ void ARMATURE_OT_hide(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -3202,14 +3202,14 @@ void ARMATURE_OT_hide(wmOperatorType *ot) static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { - ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag &= ~BONE_HIDDEN_A; } } @@ -3217,7 +3217,7 @@ static int armature_reveal_exec(bContext *C, wmOperator *UNUSED(op)) ED_armature_validate_active(arm); ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3234,20 +3234,20 @@ void ARMATURE_OT_reveal(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } #if 0 // remove this? static void hide_selected_armature_bones(Scene *scene) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_SELECTED) { - ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag |= BONE_HIDDEN_A; } } @@ -3258,14 +3258,14 @@ static void hide_selected_armature_bones(Scene *scene) static void hide_unselected_armature_bones(Scene *scene) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { - bArmature *arm= obedit->data; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { + bArmature *arm = obedit->data; if (EBONE_VISIBLE(arm, ebone)) { - if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL)); + if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL)) ; else { ebone->flag |= BONE_HIDDEN_A; } @@ -3278,14 +3278,14 @@ static void hide_unselected_armature_bones(Scene *scene) void show_all_armature_bones(Scene *scene) { - Object *obedit= scene->obedit; // XXX get from context - bArmature *arm= obedit->data; + Object *obedit = scene->obedit; // XXX get from context + bArmature *arm = obedit->data; EditBone *ebone; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (arm->layer & ebone->layer) { if (ebone->flag & BONE_HIDDEN_A) { - ebone->flag |= (BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag |= (BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); ebone->flag &= ~BONE_HIDDEN_A; } } @@ -3302,15 +3302,15 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) { Object *obedit; bArmature *arm; - EditBone *newbone, *ebone, *flipbone, *first=NULL; - int a, totbone= 0, do_extrude; + EditBone *newbone, *ebone, *flipbone, *first = NULL; + int a, totbone = 0, do_extrude; int forked = RNA_boolean_get(op->ptr, "forked"); - obedit= CTX_data_edit_object(C); - arm= obedit->data; + obedit = CTX_data_edit_object(C); + arm = obedit->data; /* since we allow root extrude too, we have to make sure selection is OK */ - for (ebone = arm->edbo->first; ebone; ebone=ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { if (ebone->flag & BONE_ROOTSEL) { if (ebone->parent && (ebone->flag & BONE_CONNECTED)) { @@ -3322,36 +3322,36 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) } /* Duplicate the necessary bones */ - for (ebone = arm->edbo->first; ((ebone) && (ebone!=first)); ebone=ebone->next) { + for (ebone = arm->edbo->first; ((ebone) && (ebone != first)); ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone)) { /* we extrude per definition the tip */ - do_extrude= 0; - if (ebone->flag & (BONE_TIPSEL|BONE_SELECTED)) - do_extrude= 1; + do_extrude = 0; + if (ebone->flag & (BONE_TIPSEL | BONE_SELECTED)) + do_extrude = 1; else if (ebone->flag & BONE_ROOTSEL) { /* but, a bone with parent deselected we do the root... */ - if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)); - else do_extrude= 2; + if (ebone->parent && (ebone->parent->flag & BONE_TIPSEL)) ; + else do_extrude = 2; } if (do_extrude) { /* we re-use code for mirror editing... */ - flipbone= NULL; + flipbone = NULL; if (arm->flag & ARM_MIRROR_EDIT) { - flipbone= ED_armature_bone_get_mirrored(arm->edbo, ebone); + flipbone = ED_armature_bone_get_mirrored(arm->edbo, ebone); if (flipbone) { - forked= 0; // we extrude 2 different bones - if (flipbone->flag & (BONE_TIPSEL|BONE_ROOTSEL|BONE_SELECTED)) + forked = 0; // we extrude 2 different bones + if (flipbone->flag & (BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED)) /* don't want this bone to be selected... */ - flipbone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + flipbone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } - if ((flipbone==NULL) && (forked)) - flipbone= ebone; + if ((flipbone == NULL) && (forked)) + flipbone = ebone; } - for (a=0; a<2; a++) { - if (a==1) { - if (flipbone==NULL) + for (a = 0; a < 2; a++) { + if (a == 1) { + if (flipbone == NULL) break; else { SWAP(EditBone *, flipbone, ebone); @@ -3361,43 +3361,43 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) totbone++; newbone = MEM_callocN(sizeof(EditBone), "extrudebone"); - if (do_extrude==1) { + if (do_extrude == 1) { copy_v3_v3(newbone->head, ebone->tail); copy_v3_v3(newbone->tail, newbone->head); newbone->parent = ebone; - newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone + newbone->flag = ebone->flag & BONE_TIPSEL; // copies it, in case mirrored bone if (newbone->parent) newbone->flag |= BONE_CONNECTED; } else { copy_v3_v3(newbone->head, ebone->head); copy_v3_v3(newbone->tail, ebone->head); - newbone->parent= ebone->parent; + newbone->parent = ebone->parent; - newbone->flag= BONE_TIPSEL; + newbone->flag = BONE_TIPSEL; if (newbone->parent && (ebone->flag & BONE_CONNECTED)) { newbone->flag |= BONE_CONNECTED; } } - newbone->weight= ebone->weight; - newbone->dist= ebone->dist; - newbone->xwidth= ebone->xwidth; - newbone->zwidth= ebone->zwidth; - newbone->ease1= ebone->ease1; - newbone->ease2= ebone->ease2; - newbone->rad_head= ebone->rad_tail; // don't copy entire bone... - newbone->rad_tail= ebone->rad_tail; - newbone->segments= 1; - newbone->layer= ebone->layer; - - BLI_strncpy (newbone->name, ebone->name, sizeof(newbone->name)); - - if (flipbone && forked) { // only set if mirror edit - if (strlen(newbone->name)<30) { - if (a==0) strcat(newbone->name, "_L"); + newbone->weight = ebone->weight; + newbone->dist = ebone->dist; + newbone->xwidth = ebone->xwidth; + newbone->zwidth = ebone->zwidth; + newbone->ease1 = ebone->ease1; + newbone->ease2 = ebone->ease2; + newbone->rad_head = ebone->rad_tail; // don't copy entire bone... + newbone->rad_tail = ebone->rad_tail; + newbone->segments = 1; + newbone->layer = ebone->layer; + + BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name)); + + if (flipbone && forked) { // only set if mirror edit + if (strlen(newbone->name) < 30) { + if (a == 0) strcat(newbone->name, "_L"); else strcat(newbone->name, "_R"); } } @@ -3409,24 +3409,24 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) first = newbone; /* restore ebone if we were flipping */ - if (a==1 && flipbone) + if (a == 1 && flipbone) SWAP(EditBone *, flipbone, ebone); } } /* Deselect the old bone */ - ebone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ebone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); } } /* if only one bone, make this one active */ - if (totbone==1 && first) arm->act_edbone= first; + if (totbone == 1 && first) arm->act_edbone = first; - if (totbone==0) return OPERATOR_CANCELLED; + if (totbone == 0) return OPERATOR_CANCELLED; /* Transform the endpoints */ ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3443,7 +3443,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "forked", 0, "Forked", ""); @@ -3454,7 +3454,7 @@ void ARMATURE_OT_extrude(wmOperatorType *ot) static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); Object *obedit = CTX_data_edit_object(C); EditBone *bone; float obmat[3][3], curs[3], viewmat[3][3], totmat[3][3], imat[3][3]; @@ -3479,17 +3479,17 @@ static int armature_bone_primitive_add_exec(bContext *C, wmOperator *op) ED_armature_deselect_all(obedit, 0); /* Create a bone */ - bone= ED_armature_edit_bone_add(obedit->data, name); + bone = ED_armature_edit_bone_add(obedit->data, name); copy_v3_v3(bone->head, curs); if (rv3d && (U.flag & USER_ADD_VIEWALIGNED)) - add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 + add_v3_v3v3(bone->tail, bone->head, imat[1]); // bone with unit length 1 else - add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z + add_v3_v3v3(bone->tail, bone->head, imat[2]); // bone with unit length 1, pointing up Z /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3506,7 +3506,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone"); @@ -3523,28 +3523,28 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot) static int armature_subdivide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - bArmature *arm= obedit->data; + Object *obedit = CTX_data_edit_object(C); + bArmature *arm = obedit->data; EditBone *newbone, *tbone; int numcuts, i; /* there may not be a number_cuts property defined (for 'simple' subdivide) */ - numcuts= RNA_int_get(op->ptr, "number_cuts"); + numcuts = RNA_int_get(op->ptr, "number_cuts"); /* loop over all editable bones */ // XXX the old code did this in reverse order though! CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { - for (i=numcuts+1; i>1; i--) { + for (i = numcuts + 1; i > 1; i--) { /* compute cut ratio first */ - float cutratio= 1.0f / (float)i; - float cutratioI= 1.0f - cutratio; + float cutratio = 1.0f / (float)i; + float cutratioI = 1.0f - cutratio; float val1[3]; float val2[3]; float val3[3]; - newbone= MEM_mallocN(sizeof(EditBone), "ebone subdiv"); + newbone = MEM_mallocN(sizeof(EditBone), "ebone subdiv"); *newbone = *ebone; BLI_addtail(arm->edbo, newbone); @@ -3553,33 +3553,33 @@ static int armature_subdivide_exec(bContext *C, wmOperator *op) copy_v3_v3(val2, ebone->tail); copy_v3_v3(val3, newbone->head); - val3[0]= val1[0]*cutratio + val2[0]*cutratioI; - val3[1]= val1[1]*cutratio + val2[1]*cutratioI; - val3[2]= val1[2]*cutratio + val2[2]*cutratioI; + val3[0] = val1[0] * cutratio + val2[0] * cutratioI; + val3[1] = val1[1] * cutratio + val2[1] * cutratioI; + val3[2] = val1[2] * cutratio + val2[2] * cutratioI; copy_v3_v3(newbone->head, val3); copy_v3_v3(newbone->tail, ebone->tail); copy_v3_v3(ebone->tail, newbone->head); - newbone->rad_head= 0.5f * (ebone->rad_head + ebone->rad_tail); - ebone->rad_tail= newbone->rad_head; + newbone->rad_head = 0.5f * (ebone->rad_head + ebone->rad_tail); + ebone->rad_tail = newbone->rad_head; newbone->flag |= BONE_CONNECTED; unique_editbone_name(arm->edbo, newbone->name, NULL); /* correct parent bones */ - for (tbone = arm->edbo->first; tbone; tbone=tbone->next) { - if (tbone->parent==ebone) - tbone->parent= newbone; + for (tbone = arm->edbo->first; tbone; tbone = tbone->next) { + if (tbone->parent == ebone) + tbone->parent = newbone; } - newbone->parent= ebone; + newbone->parent = ebone; } } CTX_DATA_END; /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, obedit); return OPERATOR_FINISHED; } @@ -3598,7 +3598,7 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties */ prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10); @@ -3616,8 +3616,8 @@ void ARMATURE_OT_subdivide(wmOperatorType *ot) static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; ListBase chains = {NULL, NULL}; LinkData *chain; @@ -3628,16 +3628,16 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) armature_tag_select_mirrored(arm); /* loop over chains, only considering selected and visible bones */ - for (chain= chains.first; chain; chain= chain->next) { - EditBone *ebo, *child=NULL, *parent=NULL; + for (chain = chains.first; chain; chain = chain->next) { + EditBone *ebo, *child = NULL, *parent = NULL; /* loop over bones in chain */ - for (ebo= chain->data; ebo; ebo= parent) { + for (ebo = chain->data; ebo; ebo = parent) { /* parent is this bone's original parent * - we store this, as the next bone that is checked is this one * but the value of ebo->parent may change here... */ - parent= ebo->parent; + parent = ebo->parent; /* only if selected and editable */ if (EBONE_VISIBLE(arm, ebo) && EBONE_EDITABLE(ebo)) { @@ -3650,7 +3650,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) * - use 'child' as new parent * - connected flag is only set if points are coincidental */ - ebo->parent= child; + ebo->parent = child; if ((child) && equals_v3v3(ebo->head, child->tail)) ebo->flag |= BONE_CONNECTED; else @@ -3659,14 +3659,14 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) /* get next bones * - child will become the new parent of next bone */ - child= ebo; + child = ebo; } else { /* not swapping this bone, however, if its 'parent' got swapped, unparent us from it * as it will be facing in opposite direction */ if ((parent) && (EBONE_VISIBLE(arm, parent) && EBONE_EDITABLE(parent))) { - ebo->parent= NULL; + ebo->parent = NULL; ebo->flag &= ~BONE_CONNECTED; } @@ -3674,7 +3674,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) * - child will become new parent of next bone (not swapping occurred, * so set to NULL to prevent infinite-loop) */ - child= NULL; + child = NULL; } } } @@ -3685,7 +3685,7 @@ static int armature_switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) armature_tag_unselect(arm); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -3702,13 +3702,13 @@ void ARMATURE_OT_switch_direction(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Parenting *********************** */ /* armature parenting options */ #define ARM_PAR_CONNECT 1 -#define ARM_PAR_OFFSET 2 +#define ARM_PAR_OFFSET 2 /* check for null, before calling! */ static void bone_connect_to_existing_parent(EditBone *bone) @@ -3727,12 +3727,12 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo selbone->parent->flag &= ~(BONE_TIPSEL); /* make actbone the parent of selbone */ - selbone->parent= actbone; + selbone->parent = actbone; /* in actbone tree we cannot have a loop */ - for (ebone= actbone->parent; ebone; ebone= ebone->parent) { - if (ebone->parent==selbone) { - ebone->parent= NULL; + for (ebone = actbone->parent; ebone; ebone = ebone->parent) { + if (ebone->parent == selbone) { + ebone->parent = NULL; ebone->flag &= ~BONE_CONNECTED; } } @@ -3743,16 +3743,16 @@ static void bone_connect_to_new_parent(ListBase *edbo, EditBone *selbone, EditBo sub_v3_v3v3(offset, actbone->tail, selbone->head); copy_v3_v3(selbone->head, actbone->tail); - selbone->rad_head= actbone->rad_tail; + selbone->rad_head = actbone->rad_tail; add_v3_v3(selbone->tail, offset); /* offset for all its children */ - for (ebone = edbo->first; ebone; ebone=ebone->next) { + for (ebone = edbo->first; ebone; ebone = ebone->next) { EditBone *par; - for (par= ebone->parent; par; par= par->parent) { - if (par==selbone) { + for (par = ebone->parent; par; par = par->parent) { + if (par == selbone) { add_v3_v3(ebone->head, offset); add_v3_v3(ebone->tail, offset); break; @@ -3774,8 +3774,8 @@ static EnumPropertyItem prop_editarm_make_parent_types[] = { static int armature_parent_set_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; EditBone *actbone = CTX_data_active_bone(C); EditBone *actmirb = NULL; short val = RNA_enum_get(op->ptr, "type"); @@ -3793,9 +3793,9 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) - actmirb= actbone; + actmirb = actbone; } /* if there is only 1 selected bone, we assume that that is the active bone, @@ -3817,7 +3817,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) * - the context iterator contains both selected bones and their mirrored copies, * so we assume that unselected bones are mirrored copies of some selected bone * - since the active one (and/or its mirror) will also be selected, we also need - * to check that we are not trying to operate on them, since such an operation + * to check that we are not trying to operate on them, since such an operation * would cause errors */ @@ -3836,7 +3836,7 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -3844,14 +3844,14 @@ static int armature_parent_set_exec(bContext *C, wmOperator *op) static int armature_parent_set_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { EditBone *actbone = CTX_data_active_bone(C); - uiPopupMenu *pup= uiPupMenuBegin(C, "Make Parent ", ICON_NONE); - uiLayout *layout= uiPupMenuLayout(pup); + uiPopupMenu *pup = uiPupMenuBegin(C, "Make Parent ", ICON_NONE); + uiLayout *layout = uiPupMenuLayout(pup); int allchildbones = 0; CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) { if (ebone != actbone) { - if (ebone->parent != actbone) allchildbones= 1; + if (ebone->parent != actbone) allchildbones = 1; } } CTX_DATA_END; @@ -3880,7 +3880,7 @@ void ARMATURE_OT_parent_set(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "type", prop_editarm_make_parent_types, 0, "ParentType", "Type of parenting"); } @@ -3898,14 +3898,14 @@ static void editbone_clear_parent(EditBone *ebone, int mode) ebone->parent->flag &= ~(BONE_TIPSEL); } - if (mode==1) ebone->parent= NULL; + if (mode == 1) ebone->parent = NULL; ebone->flag &= ~BONE_CONNECTED; } static int armature_parent_clear_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; int val = RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -3917,7 +3917,7 @@ static int armature_parent_clear_exec(bContext *C, wmOperator *op) ED_armature_sync_selection(arm->edbo); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -3935,7 +3935,7 @@ void ARMATURE_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->prop = RNA_def_enum(ot->srna, "type", prop_editarm_clear_parent_types, 0, "ClearType", "What way to clear parenting"); } @@ -3955,7 +3955,7 @@ static int armature_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); return OPERATOR_FINISHED; } @@ -3972,7 +3972,7 @@ void ARMATURE_OT_select_inverse(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int armature_de_select_all_exec(bContext *C, wmOperator *op) @@ -3993,30 +3993,30 @@ static int armature_de_select_all_exec(bContext *C, wmOperator *op) /* ignore bone if selection can't change */ if ((ebone->flag & BONE_UNSELECTABLE) == 0) { switch (action) { - case SEL_SELECT: - ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - if (ebone->parent) - ebone->parent->flag |= (BONE_TIPSEL); - break; - case SEL_DESELECT: - ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - break; - case SEL_INVERT: - if (ebone->flag & BONE_SELECTED) { - ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - } - else { + case SEL_SELECT: ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); if (ebone->parent) ebone->parent->flag |= (BONE_TIPSEL); - } - break; + break; + case SEL_DESELECT: + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + break; + case SEL_INVERT: + if (ebone->flag & BONE_SELECTED) { + ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } + else { + ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + if (ebone->parent) + ebone->parent->flag |= (BONE_TIPSEL); + } + break; } } } CTX_DATA_END; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); return OPERATOR_FINISHED; } @@ -4033,7 +4033,7 @@ void ARMATURE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -4077,7 +4077,7 @@ static void select_similar_length(bArmature *arm, EditBone *ebone_act, const flo for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_UNSELECTABLE) == 0) { if ((ebone->length >= len_min) && - (ebone->length <= len_max)) + (ebone->length <= len_max)) { ED_armature_edit_bone_select(ebone); } @@ -4227,30 +4227,30 @@ void ARMATURE_OT_select_similar(wmOperatorType *ot) { static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); Object *ob; bArmature *arm; EditBone *curbone, *pabone, *chbone; int direction = RNA_enum_get(op->ptr, "direction"); int add_to_sel = RNA_boolean_get(op->ptr, "extend"); - ob= obedit; - arm= (bArmature *)ob->data; + ob = obedit; + arm = (bArmature *)ob->data; - for (curbone= arm->edbo->first; curbone; curbone= curbone->next) { + for (curbone = arm->edbo->first; curbone; curbone = curbone->next) { /* only work on bone if it is visible and its selection can change */ - if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE)==0) { + if (EBONE_VISIBLE(arm, curbone) && (curbone->flag & BONE_UNSELECTABLE) == 0) { if (curbone == arm->act_edbone) { if (direction == BONE_SELECT_PARENT) { if (curbone->parent == NULL) continue; else pabone = curbone->parent; if (EBONE_VISIBLE(arm, pabone)) { - pabone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_edbone= pabone; - if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; + pabone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_edbone = pabone; + if (pabone->parent) pabone->parent->flag |= BONE_TIPSEL; - if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + if (!add_to_sel) curbone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); break; } @@ -4259,12 +4259,12 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) chbone = editbone_get_child(arm, curbone, 1); if (chbone == NULL) continue; - if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE)==0) { - chbone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_edbone= chbone; + if (EBONE_VISIBLE(arm, chbone) && (chbone->flag & BONE_UNSELECTABLE) == 0) { + chbone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_edbone = chbone; if (!add_to_sel) { - curbone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL); + curbone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL); if (curbone->parent) curbone->parent->flag &= ~BONE_TIPSEL; } break; @@ -4276,17 +4276,17 @@ static int armature_select_hierarchy_exec(bContext *C, wmOperator *op) ED_armature_sync_selection(arm->edbo); - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { - {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, - {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, - {0, NULL, 0, NULL, NULL} + static EnumPropertyItem direction_items[] = { + {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, + {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, + {0, NULL, 0, NULL, NULL} }; /* identifiers */ @@ -4299,7 +4299,7 @@ void ARMATURE_OT_select_hierarchy(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_enum(ot->srna, "direction", direction_items, @@ -4329,7 +4329,7 @@ static void fix_editbone_connected_children(ListBase *edbo, EditBone *ebone) { EditBone *selbone; - for (selbone = edbo->first; selbone; selbone=selbone->next) { + for (selbone = edbo->first; selbone; selbone = selbone->next) { if ((selbone->parent) && (selbone->parent == ebone) && (selbone->flag & BONE_CONNECTED)) { fix_connected_bone(selbone); fix_editbone_connected_children(edbo, selbone); @@ -4361,10 +4361,10 @@ static void bone_align_to_bone(ListBase *edbo, EditBone *selbone, EditBone *actb static int armature_align_bones_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (bArmature *)ob->data; - EditBone *actbone= CTX_data_active_bone(C); - EditBone *actmirb= NULL; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (bArmature *)ob->data; + EditBone *actbone = CTX_data_active_bone(C); + EditBone *actmirb = NULL; /* there must be an active bone */ if (actbone == NULL) { @@ -4379,9 +4379,9 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) * - if there's no mirrored copy of actbone (i.e. actbone = "parent.C" or "parent") * then just use actbone. Useful when doing upper arm to spine. */ - actmirb= ED_armature_bone_get_mirrored(arm->edbo, actbone); + actmirb = ED_armature_bone_get_mirrored(arm->edbo, actbone); if (actmirb == NULL) - actmirb= actbone; + actmirb = actbone; } /* if there is only 1 selected bone, we assume that that is the active bone, @@ -4422,7 +4422,7 @@ static int armature_align_bones_exec(bContext *C, wmOperator *op) /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -4440,14 +4440,14 @@ void ARMATURE_OT_align(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Pose tools ********************* */ // XXX bone_looper is only to be used when we want to access settings (i.e. editability/visibility/selected) that context doesn't offer static int bone_looper(Object *ob, Bone *bone, void *data, - int (*bone_func)(Object *, Bone *, void *)) + int (*bone_func)(Object *, Bone *, void *)) { /* We want to apply the function bone_func to every bone * in an armature -- feed bone_looper the first bone and @@ -4477,49 +4477,49 @@ static int bone_looper(Object *ob, Bone *bone, void *data, /* assumes scene obact and basact is still on old situation */ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, short hits, short extend) { - Object *ob= base->object; + Object *ob = base->object; Bone *nearBone; if (!ob || !ob->pose) return 0; - nearBone= get_bone_from_selectbuffer(scene, base, buffer, hits, 1); + nearBone = get_bone_from_selectbuffer(scene, base, buffer, hits, 1); /* if the bone cannot be affected, don't do anything */ if ((nearBone) && !(nearBone->flag & BONE_UNSELECTABLE)) { - Object *ob_act= OBACT; - bArmature *arm= ob->data; + Object *ob_act = OBACT; + bArmature *arm = ob->data; /* since we do unified select, we don't shift+select a bone if the * armature object was not active yet. * note, special exception for armature mode so we can do multi-select * we could check for multi-select explicitly but think its fine to * always give predictable behavior in weight paint mode - campbell */ - if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT)==0))) { + if (!extend || ((ob_act && (ob_act != ob) && (ob_act->mode & OB_MODE_WEIGHT_PAINT) == 0))) { ED_pose_deselectall(ob, 0); - nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_bone= nearBone; + nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_bone = nearBone; - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name(ob->action, nearBone->name, 1); } else { if (nearBone->flag & BONE_SELECTED) { /* if not active, we make it active */ if (nearBone != arm->act_bone) { - arm->act_bone= nearBone; + arm->act_bone = nearBone; } else { - nearBone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + nearBone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name(ob->action, nearBone->name, 0); } } else { - nearBone->flag |= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - arm->act_bone= nearBone; + nearBone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + arm->act_bone = nearBone; - // XXX old cruft! use notifiers instead + // XXX old cruft! use notifiers instead //select_actionchannel_by_name(ob->action, nearBone->name, 1); } } @@ -4534,7 +4534,7 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor } - return nearBone!=NULL; + return nearBone != NULL; } /* test==0: deselect all @@ -4544,16 +4544,16 @@ int ED_do_pose_selectbuffer(Scene *scene, Base *base, unsigned int *buffer, shor */ void ED_pose_deselectall(Object *ob, int test) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; - int selectmode= 0; + int selectmode = 0; /* we call this from outliner too */ if (ELEM(NULL, ob, ob->pose)) return; /* Determine if we're selecting or deselecting */ - if (test==1) { - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + if (test == 1) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) break; @@ -4561,21 +4561,21 @@ void ED_pose_deselectall(Object *ob, int test) } if (pchan == NULL) - selectmode= 1; + selectmode = 1; } else if (test == 2) - selectmode= 2; + selectmode = 2; /* Set the flags accordingly */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { /* ignore the pchan if it isn't visible or if its selection cannot be changed */ - if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) { - if (test==3) { - pchan->bone->flag ^= (BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); + if ((pchan->bone->layer & arm->layer) && !(pchan->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) { + if (test == 3) { + pchan->bone->flag ^= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); } else { - if (selectmode==0) pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - else if (selectmode==1) pchan->bone->flag |= BONE_SELECTED; + if (selectmode == 0) pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + else if (selectmode == 1) pchan->bone->flag |= BONE_SELECTED; } } } @@ -4611,7 +4611,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) if (!(ob->mode & OB_MODE_WEIGHT_PAINT) || !(bone->flag & BONE_HIDDEN_P)) { if (!(bone->flag & BONE_NO_DEFORM)) { - if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; @@ -4619,7 +4619,7 @@ static int bone_skinnable_cb(Object *ob, Bone *bone, void *datap) if (data->list != NULL) { hbone = (Bone ***) &data->list; - for (a=0; amode & OB_MODE_WEIGHT_PAINT); - bArmature *arm= data->armob->data; + bArmature *arm = data->armob->data; if (!wpmode || !(bone->flag & BONE_HIDDEN_P)) { - if (!(bone->flag & BONE_NO_DEFORM)) { - if (data->heat && data->armob->pose && get_pose_channel(data->armob->pose, bone->name)) + if (!(bone->flag & BONE_NO_DEFORM)) { + if (data->heat && data->armob->pose && BKE_pose_channel_find_name(data->armob->pose, bone->name)) segments = bone->segments; else segments = 1; @@ -4690,7 +4690,7 @@ static int dgroup_skinnable_cb(Object *ob, Bone *bone, void *datap) if (data->list != NULL) { hgroup = (bDeformGroup ***) &data->list; - for (a=0; atotvert; i++) { - iflip = (dgroupflip)? mesh_get_x_mirror_vert(ob, i): 0; + for (i = 0; i < mesh->totvert; i++) { + iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, i) : 0; /* for each skinnable bone */ - for (j=0; j < numbones; ++j) { + for (j = 0; j < numbones; ++j) { if (!selected[j]) continue; @@ -4732,22 +4732,22 @@ static void envelope_bone_weighting(Object *ob, Mesh *mesh, float (*verts)[3], i dgroup = dgrouplist[j]; /* store the distance-factor from the vertex to the bone */ - distance = distfactor_to_bone (verts[i], root[j], tip[j], - bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); + distance = distfactor_to_bone(verts[i], root[j], tip[j], + bone->rad_head * scale, bone->rad_tail * scale, bone->dist * scale); /* add the vert to the deform group if weight!=0.0 */ if (distance != 0.0f) - ED_vgroup_vert_add (ob, dgroup, i, distance, WEIGHT_REPLACE); + ED_vgroup_vert_add(ob, dgroup, i, distance, WEIGHT_REPLACE); else - ED_vgroup_vert_remove (ob, dgroup, i); + ED_vgroup_vert_remove(ob, dgroup, i); /* do same for mirror */ if (dgroupflip && dgroupflip[j] && iflip >= 0) { if (distance != 0.0f) - ED_vgroup_vert_add (ob, dgroupflip[j], iflip, distance, - WEIGHT_REPLACE); + ED_vgroup_vert_add(ob, dgroupflip[j], iflip, distance, + WEIGHT_REPLACE); else - ED_vgroup_vert_remove (ob, dgroupflip[j], iflip); + ED_vgroup_vert_remove(ob, dgroupflip[j], iflip); } } } @@ -4767,7 +4767,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, * when parenting, or simply the original mesh coords. */ - bArmature *arm= par->data; + bArmature *arm = par->data; Bone **bonelist, *bone; bDeformGroup **dgrouplist, **dgroupflip; bDeformGroup *dgroup; @@ -4781,8 +4781,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, struct { Object *armob; void *list; int heat; } looper_data; looper_data.armob = par; - looper_data.heat= heat; - looper_data.list= NULL; + looper_data.heat = heat; + looper_data.list = NULL; /* count the number of skinnable bones */ numbones = bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); @@ -4792,26 +4792,26 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* create an array of pointer to bones that are skinnable * and fill it with all of the skinnable bones */ - bonelist = MEM_callocN(numbones*sizeof(Bone *), "bonelist"); - looper_data.list= bonelist; + bonelist = MEM_callocN(numbones * sizeof(Bone *), "bonelist"); + looper_data.list = bonelist; bone_looper(ob, arm->bonebase.first, &looper_data, bone_skinnable_cb); /* create an array of pointers to the deform groups that * coorespond to the skinnable bones (creating them * as necessary. */ - dgrouplist = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgrouplist"); - dgroupflip = MEM_callocN(numbones*sizeof(bDeformGroup *), "dgroupflip"); + dgrouplist = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgrouplist"); + dgroupflip = MEM_callocN(numbones * sizeof(bDeformGroup *), "dgroupflip"); - looper_data.list= dgrouplist; + looper_data.list = dgrouplist; bone_looper(ob, arm->bonebase.first, &looper_data, dgroup_skinnable_cb); /* create an array of root and tip positions transformed into * global coords */ - root = MEM_callocN(numbones*sizeof(float)*3, "root"); - tip = MEM_callocN(numbones*sizeof(float)*3, "tip"); - selected = MEM_callocN(numbones*sizeof(int), "selected"); + root = MEM_callocN(numbones * sizeof(float) * 3, "root"); + tip = MEM_callocN(numbones * sizeof(float) * 3, "tip"); + selected = MEM_callocN(numbones * sizeof(int), "selected"); - for (j=0; j < numbones; ++j) { + for (j = 0; j < numbones; ++j) { bone = bonelist[j]; dgroup = dgrouplist[j]; @@ -4821,7 +4821,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, segments = 1; bbone = NULL; - if ((par->pose) && (pchan=get_pose_channel(par->pose, bone->name))) { + if ((par->pose) && (pchan = BKE_pose_channel_find_name(par->pose, bone->name))) { if (bone->segments > 1) { segments = bone->segments; bbone = b_bone_spline_setup(pchan, 1); @@ -4835,8 +4835,8 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* compute root and tip */ if (bbone) { mul_v3_m4v3(root[j], bone->arm_mat, bbone[segments].mat[3]); - if ((segments+1) < bone->segments) { - mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments+1].mat[3]); + if ((segments + 1) < bone->segments) { + mul_v3_m4v3(tip[j], bone->arm_mat, bbone[segments + 1].mat[3]); } else { copy_v3_v3(tip[j], bone->arm_tail); @@ -4869,15 +4869,15 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } /* create verts */ - mesh = (Mesh*)ob->data; - verts = MEM_callocN(mesh->totvert*sizeof(*verts), "closestboneverts"); + mesh = (Mesh *)ob->data; + verts = MEM_callocN(mesh->totvert * sizeof(*verts), "closestboneverts"); if (wpmode) { /* if in weight paint mode, use final verts from derivedmesh */ DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); if (dm->foreachMappedVert) { - dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void*)verts); + dm->foreachMappedVert(dm, add_vgroups__mapFunc, (void *)verts); vertsfilled = 1; } @@ -4892,7 +4892,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } /* transform verts to global space */ - for (i=0; i < mesh->totvert; i++) { + for (i = 0; i < mesh->totvert; i++) { if (!vertsfilled) copy_v3_v3(verts[i], mesh->mvert[i].co); mul_m4_v3(ob->obmat, verts[i]); @@ -4900,9 +4900,9 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, /* compute the weights based on gathered vertices and bones */ if (heat) { - const char *error= NULL; + const char *error = NULL; heat_bone_weighting(ob, mesh, verts, numbones, dgrouplist, dgroupflip, - root, tip, selected, &error); + root, tip, selected, &error); if (error) { BKE_report(reports, RPT_WARNING, error); @@ -4910,7 +4910,7 @@ static void add_verts_to_dgroups(ReportList *reports, Scene *scene, Object *ob, } else { envelope_bone_weighting(ob, mesh, verts, numbones, bonelist, dgrouplist, - dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); + dgroupflip, root, tip, selected, mat4_to_scale(par->obmat)); } /* only generated in some cases but can call anyway */ @@ -4931,7 +4931,7 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, /* Lets try to create some vertex groups * based on the bones of the parent armature. */ - bArmature *arm= par->data; + bArmature *arm = par->data; if (mode == ARM_GROUPS_NAME) { /* Traverse the bone list, trying to create empty vertex @@ -4955,41 +4955,41 @@ void create_vgroups_from_armature(ReportList *reports, Scene *scene, Object *ob, /* clear scale of pose-channel */ static void pchan_clear_scale(bPoseChannel *pchan) { - if ((pchan->protectflag & OB_LOCK_SCALEX)==0) - pchan->size[0]= 1.0f; - if ((pchan->protectflag & OB_LOCK_SCALEY)==0) - pchan->size[1]= 1.0f; - if ((pchan->protectflag & OB_LOCK_SCALEZ)==0) - pchan->size[2]= 1.0f; + if ((pchan->protectflag & OB_LOCK_SCALEX) == 0) + pchan->size[0] = 1.0f; + if ((pchan->protectflag & OB_LOCK_SCALEY) == 0) + pchan->size[1] = 1.0f; + if ((pchan->protectflag & OB_LOCK_SCALEZ) == 0) + pchan->size[2] = 1.0f; } /* clear location of pose-channel */ static void pchan_clear_loc(bPoseChannel *pchan) { - if ((pchan->protectflag & OB_LOCK_LOCX)==0) - pchan->loc[0]= 0.0f; - if ((pchan->protectflag & OB_LOCK_LOCY)==0) - pchan->loc[1]= 0.0f; - if ((pchan->protectflag & OB_LOCK_LOCZ)==0) - pchan->loc[2]= 0.0f; + if ((pchan->protectflag & OB_LOCK_LOCX) == 0) + pchan->loc[0] = 0.0f; + if ((pchan->protectflag & OB_LOCK_LOCY) == 0) + pchan->loc[1] = 0.0f; + if ((pchan->protectflag & OB_LOCK_LOCZ) == 0) + pchan->loc[2] = 0.0f; } /* clear rotation of pose-channel */ static void pchan_clear_rot(bPoseChannel *pchan) { - if (pchan->protectflag & (OB_LOCK_ROTX|OB_LOCK_ROTY|OB_LOCK_ROTZ|OB_LOCK_ROTW)) { + if (pchan->protectflag & (OB_LOCK_ROTX | OB_LOCK_ROTY | OB_LOCK_ROTZ | OB_LOCK_ROTW)) { /* check if convert to eulers for locking... */ if (pchan->protectflag & OB_LOCK_ROT4D) { /* perform clamping on a component by component basis */ if (pchan->rotmode == ROT_MODE_AXISANGLE) { if ((pchan->protectflag & OB_LOCK_ROTW) == 0) - pchan->rotAngle= 0.0f; + pchan->rotAngle = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTX) == 0) - pchan->rotAxis[0]= 0.0f; + pchan->rotAxis[0] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTY) == 0) - pchan->rotAxis[1]= 0.0f; + pchan->rotAxis[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) - pchan->rotAxis[2]= 0.0f; + pchan->rotAxis[2] = 0.0f; /* check validity of axis - axis should never be 0,0,0 (if so, then we make it rotate about y) */ if (IS_EQF(pchan->rotAxis[0], pchan->rotAxis[1]) && IS_EQF(pchan->rotAxis[1], pchan->rotAxis[2])) @@ -4997,22 +4997,22 @@ static void pchan_clear_rot(bPoseChannel *pchan) } else if (pchan->rotmode == ROT_MODE_QUAT) { if ((pchan->protectflag & OB_LOCK_ROTW) == 0) - pchan->quat[0]= 1.0f; + pchan->quat[0] = 1.0f; if ((pchan->protectflag & OB_LOCK_ROTX) == 0) - pchan->quat[1]= 0.0f; + pchan->quat[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTY) == 0) - pchan->quat[2]= 0.0f; + pchan->quat[2] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) - pchan->quat[3]= 0.0f; + pchan->quat[3] = 0.0f; } else { /* the flag may have been set for the other modes, so just ignore the extra flag... */ if ((pchan->protectflag & OB_LOCK_ROTX) == 0) - pchan->eul[0]= 0.0f; + pchan->eul[0] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTY) == 0) - pchan->eul[1]= 0.0f; + pchan->eul[1] = 0.0f; if ((pchan->protectflag & OB_LOCK_ROTZ) == 0) - pchan->eul[2]= 0.0f; + pchan->eul[2] = 0.0f; } } else { @@ -5021,7 +5021,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) float qlen = 0.0f; if (pchan->rotmode == ROT_MODE_QUAT) { - qlen= normalize_qt_qt(quat1, pchan->quat); + qlen = normalize_qt_qt(quat1, pchan->quat); quat_to_eul(oldeul, quat1); } else if (pchan->rotmode == ROT_MODE_AXISANGLE) { @@ -5031,14 +5031,14 @@ static void pchan_clear_rot(bPoseChannel *pchan) copy_v3_v3(oldeul, pchan->eul); } - eul[0]= eul[1]= eul[2]= 0.0f; + eul[0] = eul[1] = eul[2] = 0.0f; if (pchan->protectflag & OB_LOCK_ROTX) - eul[0]= oldeul[0]; + eul[0] = oldeul[0]; if (pchan->protectflag & OB_LOCK_ROTY) - eul[1]= oldeul[1]; + eul[1] = oldeul[1]; if (pchan->protectflag & OB_LOCK_ROTZ) - eul[2]= oldeul[2]; + eul[2] = oldeul[2]; if (pchan->rotmode == ROT_MODE_QUAT) { eul_to_quat(pchan->quat, eul); @@ -5047,7 +5047,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) mul_qt_fl(pchan->quat, qlen); /* quaternions flip w sign to accumulate rotations correctly */ - if ((quat1[0]<0.0f && pchan->quat[0]>0.0f) || (quat1[0]>0.0f && pchan->quat[0]<0.0f)) { + if ((quat1[0] < 0.0f && pchan->quat[0] > 0.0f) || (quat1[0] > 0.0f && pchan->quat[0] < 0.0f)) { mul_qt_fl(pchan->quat, -1.0f); } } @@ -5058,7 +5058,7 @@ static void pchan_clear_rot(bPoseChannel *pchan) copy_v3_v3(pchan->eul, eul); } } - } // Duplicated in source/blender/editors/object/object_transform.c + } /* Duplicated in source/blender/editors/object/object_transform.c */ else { if (pchan->rotmode == ROT_MODE_QUAT) { unit_qt(pchan->quat); @@ -5085,10 +5085,10 @@ static void pchan_clear_transforms(bPoseChannel *pchan) /* generic exec for clear-pose operators */ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, - void (*clear_func)(bPoseChannel*), const char default_ksName[]) + void (*clear_func)(bPoseChannel *), const char default_ksName[]) { - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); short autokey = 0; /* sanity checks */ @@ -5098,7 +5098,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, } /* only clear relevant transforms for selected bones */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* run provided clearing function */ clear_func(pchan); @@ -5136,7 +5136,7 @@ static int pose_clear_transform_generic_exec(bContext *C, wmOperator *op, DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -5160,7 +5160,7 @@ void POSE_OT_scale_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5181,7 +5181,7 @@ void POSE_OT_rot_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5202,7 +5202,7 @@ void POSE_OT_loc_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5223,7 +5223,7 @@ void POSE_OT_transforms_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** selections ********************** */ @@ -5232,11 +5232,11 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) { int action = RNA_enum_get(op->ptr, "action"); - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int multipaint = scene->toolsettings->multipaint; if (action == SEL_TOGGLE) { - action= CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT; + action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT; } /* Set the flags */ @@ -5244,26 +5244,26 @@ static int pose_de_select_all_exec(bContext *C, wmOperator *op) { /* select pchan only if selectable, but deselect works always */ switch (action) { - case SEL_SELECT: - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) - pchan->bone->flag |= BONE_SELECTED; - break; - case SEL_DESELECT: - pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - break; - case SEL_INVERT: - if (pchan->bone->flag & BONE_SELECTED) { - pchan->bone->flag &= ~(BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL); - } - else if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { + case SEL_SELECT: + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag |= BONE_SELECTED; - } - break; + break; + case SEL_DESELECT: + pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + break; + case SEL_INVERT: + if (pchan->bone->flag & BONE_SELECTED) { + pchan->bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); + } + else if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { + pchan->bone->flag |= BONE_SELECTED; + } + break; } } CTX_DATA_END; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, NULL); if (multipaint) { Object *ob = ED_object_context(C); @@ -5285,24 +5285,24 @@ void POSE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bPoseChannel *pchan, *parent; /* Determine if there is an active bone */ - pchan=CTX_data_active_pose_bone(C); + pchan = CTX_data_active_pose_bone(C); if (pchan) { - bArmature *arm= ob->data; - parent=pchan->parent; - if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P|BONE_UNSELECTABLE))) { + bArmature *arm = ob->data; + parent = pchan->parent; + if ((parent) && !(parent->bone->flag & (BONE_HIDDEN_P | BONE_UNSELECTABLE))) { parent->bone->flag |= BONE_SELECTED; - arm->act_bone= parent->bone; + arm->act_bone = parent->bone; } else { return OPERATOR_CANCELLED; @@ -5312,7 +5312,7 @@ static int pose_select_parent_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -5329,7 +5329,7 @@ void POSE_OT_select_parent(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -5337,14 +5337,14 @@ void POSE_OT_select_parent(wmOperatorType *ot) static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->layer & bone->layer) { if (bone->flag & BONE_SELECTED) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; - if (arm->act_bone==bone) - arm->act_bone= NULL; + if (arm->act_bone == bone) + arm->act_bone = NULL; } } return 0; @@ -5352,14 +5352,14 @@ static int hide_selected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->layer & bone->layer) { // hrm... typo here? - if ((bone->flag & BONE_SELECTED)==0) { + if ((bone->flag & BONE_SELECTED) == 0) { bone->flag |= BONE_HIDDEN_P; - if (arm->act_bone==bone) - arm->act_bone= NULL; + if (arm->act_bone == bone) + arm->act_bone = NULL; } } return 0; @@ -5368,8 +5368,8 @@ static int hide_unselected_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr /* active object is armature in posemode, poll checked */ static int pose_hide_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= ob->data; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = ob->data; if (RNA_boolean_get(op->ptr, "unselected")) bone_looper(ob, arm->bonebase.first, NULL, hide_unselected_pose_bone_cb); @@ -5377,7 +5377,7 @@ static int pose_hide_exec(bContext *C, wmOperator *op) bone_looper(ob, arm->bonebase.first, NULL, hide_selected_pose_bone_cb); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -5394,7 +5394,7 @@ void POSE_OT_hide(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", ""); @@ -5402,7 +5402,7 @@ void POSE_OT_hide(wmOperatorType *ot) static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->layer & bone->layer) { if (bone->flag & BONE_HIDDEN_P) { @@ -5417,13 +5417,13 @@ static int show_pose_bone_cb(Object *ob, Bone *bone, void *UNUSED(ptr)) /* active object is armature in posemode, poll checked */ static int pose_reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= ob->data; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = ob->data; bone_looper(ob, arm->bonebase.first, NULL, show_pose_bone_cb); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -5440,14 +5440,14 @@ void POSE_OT_reveal(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************* RENAMING DISASTERS ************ */ static int bone_unique_check(void *arg, const char *name) { - return get_named_bone((bArmature *)arg, name) != NULL; + return BKE_armature_find_bone_name((bArmature *)arg, name) != NULL; } static void unique_bone_name(bArmature *arm, char *name) @@ -5461,14 +5461,14 @@ static void constraint_bone_name_fix(Object *ob, ListBase *conlist, char *oldnam bConstraint *curcon; bConstraintTarget *ct; - for (curcon = conlist->first; curcon; curcon=curcon->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(curcon); + for (curcon = conlist->first; curcon; curcon = curcon->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(curcon); ListBase targets = {NULL, NULL}; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(curcon, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { if (!strcmp(ct->subtarget, oldname) ) BLI_strncpy(ct->subtarget, newname, MAXBONENAME); @@ -5500,7 +5500,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { - EditBone *eBone= editbone_name_exists(arm->edbo, oldname); + EditBone *eBone = editbone_name_exists(arm->edbo, oldname); if (eBone) { unique_editbone_name(arm->edbo, newname, NULL); @@ -5509,7 +5509,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n else return; } else { - Bone *bone= get_named_bone(arm, oldname); + Bone *bone = BKE_armature_find_bone_name(arm, oldname); if (bone) { unique_bone_name(arm, newname); @@ -5519,16 +5519,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } /* do entire dbase - objects */ - for (ob= G.main->object.first; ob; ob= ob->id.next) { + for (ob = G.main->object.first; ob; ob = ob->id.next) { ModifierData *md; /* we have the object using the armature */ - if (arm==ob->data) { + if (arm == ob->data) { Object *cob; /* Rename the pose channel, if it exists */ if (ob->pose) { - bPoseChannel *pchan = get_pose_channel(ob->pose, oldname); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, oldname); if (pchan) { BLI_strncpy(pchan->name, newname, MAXBONENAME); @@ -5543,12 +5543,12 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } /* Update any object constraints to use the new bone name */ - for (cob= G.main->object.first; cob; cob= cob->id.next) { + for (cob = G.main->object.first; cob; cob = cob->id.next) { if (cob->constraints.first) constraint_bone_name_fix(ob, &cob->constraints, oldname, newname); if (cob->pose) { bPoseChannel *pchan; - for (pchan = cob->pose->chanbase.first; pchan; pchan=pchan->next) { + for (pchan = cob->pose->chanbase.first; pchan; pchan = pchan->next) { constraint_bone_name_fix(ob, &pchan->constraints, oldname, newname); } } @@ -5557,7 +5557,7 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* See if an object is parented to this armature */ if (ob->parent && (ob->parent->data == arm)) { - if (ob->partype==PARBONE) { + if (ob->partype == PARBONE) { /* bone name in object */ if (!strcmp(ob->parsubstr, oldname)) BLI_strncpy(ob->parsubstr, newname, MAXBONENAME); @@ -5565,14 +5565,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } if (modifiers_usesArmature(ob, arm)) { - bDeformGroup *dg= defgroup_find_name(ob, oldname); + bDeformGroup *dg = defgroup_find_name(ob, oldname); if (dg) { BLI_strncpy(dg->name, newname, MAXBONENAME); } } /* fix modifiers that might be using this name */ - for (md= ob->modifiers.first; md; md= md->next) { + for (md = ob->modifiers.first; md; md = md->next) { if (md->type == eModifierType_Hook) { HookModifierData *hmd = (HookModifierData *)md; @@ -5596,14 +5596,14 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n /* correct view locking */ { bScreen *screen; - for (screen= G.main->screen.first; screen; screen= screen->id.next) { + for (screen = G.main->screen.first; screen; screen = screen->id.next) { ScrArea *sa; /* add regions */ - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { SpaceLink *sl; - for (sl= sa->spacedata.first; sl; sl= sl->next) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D *)sl; + for (sl = sa->spacedata.first; sl; sl = sl->next) { + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; if (v3d->ob_centre && v3d->ob_centre->data == arm) { if (!strcmp(v3d->ob_centre_bone, oldname)) { BLI_strncpy(v3d->ob_centre_bone, newname, MAXBONENAME); @@ -5618,16 +5618,16 @@ void ED_armature_bone_rename(bArmature *arm, const char *oldnamep, const char *n } -static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) +static int armature_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= CTX_data_edit_object(C); + Object *ob = CTX_data_edit_object(C); bArmature *arm; char newname[MAXBONENAME]; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -5641,7 +5641,7 @@ static int armature_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -5658,21 +5658,21 @@ void ARMATURE_OT_flip_names(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int armature_autoside_names_exec (bContext *C, wmOperator *op) +static int armature_autoside_names_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); + Object *ob = CTX_data_edit_object(C); bArmature *arm; char newname[MAXBONENAME]; - short axis= RNA_enum_get(op->ptr, "type"); + short axis = RNA_enum_get(op->ptr, "type"); /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -5687,15 +5687,15 @@ static int armature_autoside_names_exec (bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } void ARMATURE_OT_autoside_names(wmOperatorType *ot) { - static EnumPropertyItem axis_items[]= { - {0, "XAXIS", 0, "X-Axis", "Left/Right"}, + static EnumPropertyItem axis_items[] = { + {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, {0, NULL, 0, NULL, NULL}}; @@ -5711,7 +5711,7 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* settings */ ot->prop = RNA_def_enum(ot->srna, "type", axis_items, 0, "Axis", "Axis tag names with"); @@ -5723,27 +5723,27 @@ void ARMATURE_OT_autoside_names(wmOperatorType *ot) /* context; editmode armature, with mirror editing enabled */ void transform_armature_mirror_update(Object *obedit) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *ebo, *eboflip; - for (ebo= arm->edbo->first; ebo; ebo=ebo->next) { + for (ebo = arm->edbo->first; ebo; ebo = ebo->next) { /* no layer check, correct mirror is more important */ - if (ebo->flag & (BONE_TIPSEL|BONE_ROOTSEL)) { - eboflip= ED_armature_bone_get_mirrored(arm->edbo, ebo); + if (ebo->flag & (BONE_TIPSEL | BONE_ROOTSEL)) { + eboflip = ED_armature_bone_get_mirrored(arm->edbo, ebo); if (eboflip) { /* we assume X-axis flipping for now */ if (ebo->flag & BONE_TIPSEL) { EditBone *children; - eboflip->tail[0]= -ebo->tail[0]; - eboflip->tail[1]= ebo->tail[1]; - eboflip->tail[2]= ebo->tail[2]; - eboflip->rad_tail= ebo->rad_tail; - eboflip->roll= -ebo->roll; + eboflip->tail[0] = -ebo->tail[0]; + eboflip->tail[1] = ebo->tail[1]; + eboflip->tail[2] = ebo->tail[2]; + eboflip->rad_tail = ebo->rad_tail; + eboflip->roll = -ebo->roll; /* Also move connected children, in case children's name aren't mirrored properly */ - for (children=arm->edbo->first; children; children=children->next) { + for (children = arm->edbo->first; children; children = children->next) { if (children->parent == eboflip && children->flag & BONE_CONNECTED) { copy_v3_v3(children->head, eboflip->tail); children->rad_head = ebo->rad_tail; @@ -5751,11 +5751,11 @@ void transform_armature_mirror_update(Object *obedit) } } if (ebo->flag & BONE_ROOTSEL) { - eboflip->head[0]= -ebo->head[0]; - eboflip->head[1]= ebo->head[1]; - eboflip->head[2]= ebo->head[2]; - eboflip->rad_head= ebo->rad_head; - eboflip->roll= -ebo->roll; + eboflip->head[0] = -ebo->head[0]; + eboflip->head[1] = ebo->head[1]; + eboflip->head[2] = ebo->head[2]; + eboflip->rad_head = ebo->rad_head; + eboflip->roll = -ebo->roll; /* Also move connected parent, in case parent's name isn't mirrored properly */ if (eboflip->parent && eboflip->flag & BONE_CONNECTED) { @@ -5765,10 +5765,10 @@ void transform_armature_mirror_update(Object *obedit) } } if (ebo->flag & BONE_SELECTED) { - eboflip->dist= ebo->dist; - eboflip->roll= -ebo->roll; - eboflip->xwidth= ebo->xwidth; - eboflip->zwidth= ebo->zwidth; + eboflip->dist = ebo->dist; + eboflip->roll = -ebo->roll; + eboflip->xwidth = ebo->xwidth; + eboflip->zwidth = ebo->zwidth; } } } @@ -5784,14 +5784,14 @@ void transform_armature_mirror_update(Object *obedit) /**************************************** SUBDIVISION ALGOS ******************************************/ -EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) +EditBone *subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) { - bArmature *arm= obedit->data; + bArmature *arm = obedit->data; EditBone *lastBone = NULL; if (scene->toolsettings->skgen_options & SKGEN_CUT_ANGLE) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; float *previous = NULL, *current = NULL; EditBone *child = NULL; EditBone *parent = NULL; @@ -5799,7 +5799,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode float angleLimit = (float)cos(scene->toolsettings->skgen_angle_limit * M_PI / 180.0f); parent = ED_armature_edit_bone_add(arm, "Bone"); - parent->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + parent->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; copy_v3_v3(parent->head, head->p); root = parent; @@ -5809,8 +5809,8 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode previous = iter->p; for (IT_next(iter); - IT_stopped(iter) == 0; - previous = iter->p, IT_next(iter)) + IT_stopped(iter) == 0; + previous = iter->p, IT_next(iter)) { float vec1[3], vec2[3]; float len1, len2; @@ -5829,7 +5829,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode child = ED_armature_edit_bone_add(arm, "Bone"); copy_v3_v3(child->head, parent->tail); child->parent = parent; - child->flag |= BONE_CONNECTED|BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + child->flag |= BONE_CONNECTED | BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; parent = child; /* new child is next parent */ } @@ -5840,7 +5840,7 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode * to let subsequent subdivision methods do their thing. * */ if (parent == root) { - if (parent==arm->act_edbone) arm->act_edbone= NULL; + if (parent == arm->act_edbone) arm->act_edbone = NULL; ED_armature_edit_bone_remove(arm, parent); parent = NULL; } @@ -5851,16 +5851,16 @@ EditBone * subdivideByAngle(Scene *scene, Object *obedit, ReebArc *arc, ReebNode return lastBone; } -EditBone * test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) +EditBone *test_subdivideByCorrelation(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) { EditBone *lastBone = NULL; if (scene->toolsettings->skgen_options & SKGEN_CUT_CORRELATION) { - float invmat[4][4]= MAT4_UNITY; - float tmat[3][3]= MAT3_UNITY; + float invmat[4][4] = MAT4_UNITY; + float tmat[3][3] = MAT3_UNITY; ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; - bArmature *arm= obedit->data; + BArcIterator *iter = (BArcIterator *)&arc_iter; + bArmature *arm = obedit->data; initArcIterator(iter, arc, head); @@ -5894,17 +5894,17 @@ float arcLengthRatio(ReebArc *arc) return embedLength / arcLength; } -EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) +EditBone *test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, ReebNode *head, ReebNode *tail) { EditBone *lastBone = NULL; if ((scene->toolsettings->skgen_options & SKGEN_CUT_LENGTH) && - arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio) + arcLengthRatio(arc) >= G.scene->toolsettings->skgen_length_ratio) { - float invmat[4][4]= MAT4_UNITY; - float tmat[3][3]= MAT3_UNITY; + float invmat[4][4] = MAT4_UNITY; + float tmat[3][3] = MAT3_UNITY; ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; - bArmature *arm= obedit->data; + BArcIterator *iter = (BArcIterator *)&arc_iter; + bArmature *arm = obedit->data; initArcIterator(iter, arc, head); @@ -5918,7 +5918,7 @@ EditBone * test_subdivideByLength(Scene *scene, Object *obedit, ReebArc *arc, Re void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) { - Object *obedit= scene->obedit; // XXX get from context + Object *obedit = scene->obedit; // XXX get from context GHash *arcBoneMap = NULL; ReebArc *arc = NULL; ReebNode *node = NULL; @@ -5932,22 +5932,22 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) ED_armature_edit_free(obedit); } - dst = add_object(scene, OB_ARMATURE); - ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot - obedit= scene->basact->object; + dst = BKE_object_add(scene, OB_ARMATURE); + ED_object_base_init_transform(NULL, scene->basact, NULL, NULL); // XXX NULL is C, loc, rot + obedit = scene->basact->object; /* Copy orientation from source */ copy_v3_v3(dst->loc, src->obmat[3]); mat4_to_eul(dst->rot, src->obmat); mat4_to_size(dst->size, src->obmat); - where_is_object(scene, obedit); + BKE_object_where_is_calc(scene, obedit); ED_armature_to_edit(obedit); arcBoneMap = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "SkeletonFromReebGraph gh"); - BLI_markdownSymmetry((BGraph*)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rg, rg->nodes.first, scene->toolsettings->skgen_symmetry_limit); for (arc = rg->arcs.first; arc; arc = arc->next) { @@ -6008,9 +6008,9 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) } if (lastBone == NULL) { - EditBone *bone; + EditBone *bone; bone = ED_armature_edit_bone_add(obedit->data, "Bone"); - bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; copy_v3_v3(bone->head, head->p); copy_v3_v3(bone->tail, tail->p); @@ -6029,7 +6029,7 @@ void generateSkeletonFromReebGraph(Scene *scene, ReebGraph *rg) int i; for (i = 0; i < node->degree; i++) { - arc = (ReebArc*)node->arcs[i]; + arc = (ReebArc *)node->arcs[i]; /* if arc is incoming into the node */ if ((arc->head == node && arc->flag == -1) || diff --git a/source/blender/editors/armature/editarmature_generate.c b/source/blender/editors/armature/editarmature_generate.c index 5b56f5fe7fe..7f966dbc884 100644 --- a/source/blender/editors/armature/editarmature_generate.c +++ b/source/blender/editors/armature/editarmature_generate.c @@ -257,7 +257,7 @@ int nextLengthSubdivision(ToolSettings *toolsettings, BArcIterator *iter, int st return -1; } -EditBone * subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion) +EditBone *subdivideArcBy(ToolSettings *toolsettings, bArmature *arm, ListBase *UNUSED(editbones), BArcIterator *iter, float invmat[][4], float tmat[][3], NextSubdivisionFunc next_subdividion) { EditBone *lastBone = NULL; EditBone *child = NULL; diff --git a/source/blender/editors/armature/editarmature_retarget.c b/source/blender/editors/armature/editarmature_retarget.c index a97823ebcc8..566dbc901b8 100644 --- a/source/blender/editors/armature/editarmature_retarget.c +++ b/source/blender/editors/armature/editarmature_retarget.c @@ -70,15 +70,15 @@ /************ RIG RETARGET DATA STRUCTURES ***************/ typedef struct MemoNode { - float weight; - int next; + float weight; + int next; } MemoNode; typedef struct RetargetParam { - RigGraph *rigg; - RigArc *iarc; - RigNode *inode_start; - bContext *context; + RigGraph *rigg; + RigArc *iarc; + RigNode *inode_start; + bContext *context; } RetargetParam; typedef enum @@ -128,7 +128,7 @@ static int countEditBoneChildren(ListBase *list, EditBone *parent) return count; } -static EditBone* nextEditBoneChild(ListBase *list, EditBone *parent, int n) +static EditBone *nextEditBoneChild(ListBase *list, EditBone *parent, int n) { EditBone *ebone; @@ -247,12 +247,12 @@ float rollBoneByQuat(EditBone *bone, float old_up_axis[3], float qrot[4]) static void RIG_freeRigArc(BArc *arc) { - BLI_freelistN(&((RigArc*)arc)->edges); + BLI_freelistN(&((RigArc *)arc)->edges); } void RIG_freeRigGraph(BGraph *rg) { - RigGraph *rigg = (RigGraph*)rg; + RigGraph *rigg = (RigGraph *)rg; BNode *node; BArc *arc; @@ -270,7 +270,7 @@ void RIG_freeRigGraph(BGraph *rg) BLI_freelistN(&rg->arcs); for (node = rg->nodes.first; node; node = node->next) { - BLI_freeNode(rg, (BNode*)node); + BLI_freeNode(rg, (BNode *)node); } BLI_freelistN(&rg->nodes); @@ -311,7 +311,7 @@ static RigGraph *newRigGraph(void) // } // else // { - totthread = BLI_system_thread_count(); + totthread = BLI_system_thread_count(); // } rg->worker = BLI_create_worker(exec_retargetArctoArc, totthread, 20); /* fix number of threads */ @@ -428,13 +428,13 @@ static void renameTemplateBone(char *name, char *template_name, ListBase *editbo { int i, j; - for (i = 0, j = 0; i < (MAXBONENAME-1) && j < (MAXBONENAME-1) && template_name[i] != '\0'; i++) { + for (i = 0, j = 0; i < (MAXBONENAME - 1) && j < (MAXBONENAME - 1) && template_name[i] != '\0'; i++) { if (template_name[i] == '&') { - if (template_name[i+1] == 'S' || template_name[i+1] == 's') { + if (template_name[i + 1] == 'S' || template_name[i + 1] == 's') { j += sprintf(name + j, "%s", side_string); i++; } - else if (template_name[i+1] == 'N' || template_name[i+1] == 'n') { + else if (template_name[i + 1] == 'N' || template_name[i + 1] == 'n') { j += sprintf(name + j, "%s", num_string); i++; } @@ -471,7 +471,7 @@ static RigControl *cloneControl(RigGraph *rg, RigGraph *src_rg, RigControl *src_ renameTemplateBone(name, src_ctrl->bone->name, rg->editbones, side_string, num_string); ctrl->bone = duplicateEditBoneObjects(src_ctrl->bone, name, rg->editbones, src_rg->ob, rg->ob); - ctrl->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + ctrl->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); BLI_ghash_insert(ptr_hash, src_ctrl->bone, ctrl->bone); ctrl->link = src_ctrl->link; @@ -514,7 +514,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * char name[MAXBONENAME]; renameTemplateBone(name, src_edge->bone->name, rg->editbones, side_string, num_string); edge->bone = duplicateEditBoneObjects(src_edge->bone, name, rg->editbones, src_rg->ob, rg->ob); - edge->bone->flag &= ~(BONE_TIPSEL|BONE_SELECTED|BONE_ROOTSEL); + edge->bone->flag &= ~(BONE_TIPSEL | BONE_SELECTED | BONE_ROOTSEL); BLI_ghash_insert(ptr_hash, src_edge->bone, edge->bone); } @@ -526,7 +526,7 @@ static RigArc *cloneArc(RigGraph *rg, RigGraph *src_rg, RigArc *src_arc, GHash * static RigGraph *cloneRigGraph(RigGraph *src, ListBase *editbones, Object *ob, char *side_string, char *num_string) { - GHash *ptr_hash; + GHash *ptr_hash; RigNode *node; RigArc *arc; RigControl *ctrl; @@ -691,7 +691,7 @@ static int RIG_parentControl(RigControl *ctrl, EditBone *link) } /* if there's already a link - * overwrite only if new link is higher in the chain */ + * overwrite only if new link is higher in the chain */ if (ctrl->link && flag == ctrl->flag) { EditBone *bone = NULL; @@ -732,9 +732,9 @@ static void RIG_reconnectControlBones(RigGraph *rg) int found = 0; /* DO SOME MAGIC HERE */ - for (pchan= rg->ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -744,7 +744,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) cti->get_constraint_targets(con, &targets); - for (target_index = 0, ct= targets.first; ct; target_index++, ct= ct->next) { + for (target_index = 0, ct = targets.first; ct; target_index++, ct = ct->next) { if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { /* SET bone link to bone corresponding to pchan */ EditBone *link = BLI_ghash_lookup(rg->bones_map, pchan->name); @@ -857,9 +857,9 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* check constraints first */ /* DO SOME MAGIC HERE */ - for (pchan= rg->ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (pchan = rg->ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; @@ -867,7 +867,7 @@ static void RIG_reconnectControlBones(RigGraph *rg) if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == rg->ob) && strcmp(ct->subtarget, ctrl->bone->name) == 0) { /* SET bone link to ctrl corresponding to pchan */ RigControl *link = BLI_ghash_lookup(rg->controls_map, pchan->name); @@ -918,8 +918,8 @@ static void RIG_reconnectControlBones(RigGraph *rg) /* look on deform bones first */ BLI_ghashIterator_init(&ghi, rg->bones_map); - for ( ; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { - EditBone *bone = (EditBone*)BLI_ghashIterator_getValue(&ghi); + for (; !BLI_ghashIterator_isDone(&ghi); BLI_ghashIterator_step(&ghi)) { + EditBone *bone = (EditBone *)BLI_ghashIterator_getValue(&ghi); /* don't link with parent */ if (bone->parent != ctrl->bone) { @@ -972,9 +972,9 @@ static void RIG_joinArcs(RigGraph *rg, RigNode *node, RigArc *joined_arc1, RigAr joined_arc2->edges.first = joined_arc2->edges.last = NULL; - BLI_removeArc((BGraph*)rg, (BArc*)joined_arc2); + BLI_removeArc((BGraph *)rg, (BArc *)joined_arc2); - BLI_removeNode((BGraph*)rg, (BNode*)node); + BLI_removeNode((BGraph *)rg, (BNode *)node); } static void RIG_removeNormalNodes(RigGraph *rg) @@ -1020,12 +1020,12 @@ static void RIG_removeUneededOffsets(RigGraph *rg) MEM_freeN(first_edge); } else if (arc->head->degree == 1) { - RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001f); + RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001f); if (new_node) { BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head); } else { RigEdge *next_edge = first_edge->next; @@ -1062,7 +1062,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) } if (other_arc == NULL) { - RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, first_edge->tail, 0.001); + RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, first_edge->tail, 0.001); if (new_node) { /* remove null edge in other arcs too */ @@ -1070,13 +1070,13 @@ static void RIG_removeUneededOffsets(RigGraph *rg) if (other_arc != arc) { RigEdge *test_edge; if (other_arc->head == arc->head) { - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)other_arc, (BNode*)new_node, (BNode*)other_arc->head); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->head); test_edge = other_arc->edges.first; BLI_remlink(&other_arc->edges, test_edge); MEM_freeN(test_edge); } else if (other_arc->tail == arc->head) { - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)other_arc, (BNode*)new_node, (BNode*)other_arc->tail); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)other_arc, (BNode *)new_node, (BNode *)other_arc->tail); test_edge = other_arc->edges.last; BLI_remlink(&other_arc->edges, test_edge); MEM_freeN(test_edge); @@ -1086,7 +1086,7 @@ static void RIG_removeUneededOffsets(RigGraph *rg) BLI_remlink(&arc->edges, first_edge); MEM_freeN(first_edge); - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->head); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->head); } else { RigEdge *next_edge = first_edge->next; @@ -1125,14 +1125,14 @@ static void RIG_removeUneededOffsets(RigGraph *rg) MEM_freeN(last_edge); } else if (arc->tail->degree == 1) { - RigNode *new_node = (RigNode*)BLI_FindNodeByPosition((BGraph*)rg, last_edge->head, 0.001f); + RigNode *new_node = (RigNode *)BLI_FindNodeByPosition((BGraph *)rg, last_edge->head, 0.001f); if (new_node) { RigEdge *previous_edge = last_edge->prev; BLI_remlink(&arc->edges, last_edge); MEM_freeN(last_edge); - BLI_replaceNodeInArc((BGraph*)rg, (BArc*)arc, (BNode*)new_node, (BNode*)arc->tail); + BLI_replaceNodeInArc((BGraph *)rg, (BArc *)arc, (BNode *)new_node, (BNode *)arc->tail); /* set previous angle to 0, since there's no following edges */ if (previous_edge) { @@ -1235,7 +1235,7 @@ static void RIG_findHead(RigGraph *rg) if (BLI_countlist(&rg->arcs) == 1) { RigArc *arc = rg->arcs.first; - rg->head = (RigNode*)arc->head; + rg->head = (RigNode *)arc->head; } else { RigArc *arc; @@ -1243,7 +1243,7 @@ static void RIG_findHead(RigGraph *rg) for (arc = rg->arcs.first; arc; arc = arc->next) { RigEdge *edge = arc->edges.last; - if (edge->bone->flag & (BONE_TIPSEL|BONE_SELECTED)) { + if (edge->bone->flag & (BONE_TIPSEL | BONE_SELECTED)) { rg->head = arc->tail; break; } @@ -1323,7 +1323,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc) { RigEdge *edge; - RIG_printNode((RigNode*)arc->head, "head"); + RIG_printNode((RigNode *)arc->head, "head"); for (edge = arc->edges.first; edge; edge = edge->next) { printf("\tinner joints %0.3f %0.3f %0.3f\n", edge->tail[0], edge->tail[1], edge->tail[2]); @@ -1336,7 +1336,7 @@ void RIG_printArc(RigGraph *rg, RigArc *arc) } printf("symmetry level: %i flag: %i group %i\n", arc->symmetry_level, arc->symmetry_flag, arc->symmetry_group); - RIG_printNode((RigNode*)arc->tail, "tail"); + RIG_printNode((RigNode *)arc->tail, "tail"); } void RIG_printGraph(RigGraph *rg) @@ -1380,27 +1380,27 @@ RigGraph *RIG_graphFromArmature(const bContext *C, Object *ob, bArmature *arm) rg->ob = ob; /* Do the rotations */ - for (ebone = rg->editbones->first; ebone; ebone=ebone->next) { + for (ebone = rg->editbones->first; ebone; ebone = ebone->next) { if (ebone->parent == NULL) { RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 0); } } - BLI_removeDoubleNodes((BGraph*)rg, 0.001); + BLI_removeDoubleNodes((BGraph *)rg, 0.001); RIG_removeNormalNodes(rg); RIG_removeUneededOffsets(rg); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); RIG_findHead(rg); - BLI_markdownSymmetry((BGraph*)rg, (BNode*)rg->head, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit); RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */ - if (BLI_isGraphCyclic((BGraph*)rg)) { + if (BLI_isGraphCyclic((BGraph *)rg)) { printf("armature cyclic\n"); } @@ -1428,27 +1428,27 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm rg->ob = ob; /* Do the rotations */ - for (ebone = rg->editbones->first; ebone; ebone=ebone->next) { + for (ebone = rg->editbones->first; ebone; ebone = ebone->next) { if (ebone->parent == NULL) { RIG_arcFromBoneChain(rg, rg->editbones, ebone, NULL, 1); } } - BLI_removeDoubleNodes((BGraph*)rg, 0.001); + BLI_removeDoubleNodes((BGraph *)rg, 0.001); RIG_removeNormalNodes(rg); RIG_removeUneededOffsets(rg); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); RIG_findHead(rg); - BLI_markdownSymmetry((BGraph*)rg, (BNode*)rg->head, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rg, (BNode *)rg->head, scene->toolsettings->skgen_symmetry_limit); RIG_reconnectControlBones(rg); /* after symmetry, because we use levels to find best match */ - if (BLI_isGraphCyclic((BGraph*)rg)) { + if (BLI_isGraphCyclic((BGraph *)rg)) { printf("armature cyclic\n"); } @@ -1459,7 +1459,7 @@ static RigGraph *armatureSelectedToGraph(bContext *C, Object *ob, bArmature *arm #if 0 static EditBone *add_editbonetolist(char *name, ListBase *list) { - EditBone *bone= MEM_callocN(sizeof(EditBone), "eBone"); + EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); BLI_strncpy(bone->name, name, sizeof(bone->name)); unique_editbone_name(list, bone->name, NULL); @@ -1467,16 +1467,16 @@ static EditBone *add_editbonetolist(char *name, ListBase *list) BLI_addtail(list, bone); bone->flag |= BONE_TIPSEL; - bone->weight= 1.0F; - bone->dist= 0.25F; - bone->xwidth= 0.1; - bone->zwidth= 0.1; - bone->ease1= 1.0; - bone->ease2= 1.0; - bone->rad_head= 0.10; - bone->rad_tail= 0.05; - bone->segments= 1; - bone->layer= 1;//arm->layer; + bone->weight = 1.0F; + bone->dist = 0.25F; + bone->xwidth = 0.1; + bone->zwidth = 0.1; + bone->ease1 = 1.0; + bone->ease2 = 1.0; + bone->rad_head = 0.10; + bone->rad_tail = 0.05; + bone->segments = 1; + bone->layer = 1; //arm->layer; return bone; } @@ -1887,7 +1887,7 @@ static void copyMemoPositions(int *positions, MemoNode *table, int nb_positions, } } -static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight) +static MemoNode *solveJoints(MemoNode *table, BArcIterator *iter, float **vec_cache, int nb_joints, int nb_positions, int previous, int current, RigEdge *edge, int joints_left, float angle_weight, float length_weight, float distance_weight) { MemoNode *node; int index = indexMemoNode(nb_positions, previous, current, joints_left); @@ -1910,8 +1910,8 @@ static MemoNode * solveJoints(MemoNode *table, BArcIterator *iter, float **vec_c MemoNode *min_node = NULL; float *vec0 = vec_cache[previous]; float *vec1 = vec_cache[current]; - float min_weight= 0.0f; - int min_next= 0; + float min_weight = 0.0f; + int min_next = 0; int next; for (next = current + 1; next <= nb_positions - (joints_left - 1); next++) { @@ -1969,7 +1969,7 @@ static int testFlipArc(RigArc *iarc, RigNode *inode_start) static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; RigEdge *edge; EmbedBucket *bucket = NULL; ReebNode *node_start, *node_end; @@ -2019,7 +2019,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, #ifndef USE_THREADS MemoNode *result; #endif - float **positions_cache = MEM_callocN(sizeof(float*) * (nb_positions + 2), "positions cache"); + float **positions_cache = MEM_callocN(sizeof(float *) * (nb_positions + 2), "positions cache"); int i; positions_cache[0] = node_start->p; @@ -2084,7 +2084,7 @@ static void retargetArctoArcAggresive(bContext *C, RigGraph *rigg, RigArc *iarc, static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode *inode_start) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; ReebArc *earc = iarc->link_mesh; ReebNode *node_start, *node_end; RigEdge *edge; @@ -2096,12 +2096,12 @@ static void retargetArctoArcLength(bContext *C, RigGraph *rigg, RigArc *iarc, Ri if (testFlipArc(iarc, inode_start)) { - node_start = (ReebNode*)earc->tail; - node_end = (ReebNode*)earc->head; + node_start = (ReebNode *)earc->tail; + node_end = (ReebNode *)earc->head; } else { - node_start = (ReebNode*)earc->head; - node_end = (ReebNode*)earc->tail; + node_start = (ReebNode *)earc->head; + node_end = (ReebNode *)earc->tail; } initArcIterator(iter, earc, node_start); @@ -2183,7 +2183,7 @@ static void retargetArctoArc(bContext *C, RigGraph *rigg, RigArc *iarc, RigNode void *exec_retargetArctoArc(void *param) { - RetargetParam *p = (RetargetParam*)param; + RetargetParam *p = (RetargetParam *)param; RigGraph *rigg = p->rigg; RigArc *iarc = p->iarc; bContext *C = p->context; @@ -2224,8 +2224,8 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); int ishape, eshape; - ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)inode, NULL, 0) % SHAPE_LEVELS; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; inode->link_mesh = enode; @@ -2234,7 +2234,7 @@ static void matchMultiResolutionNode(RigGraph *rigg, RigNode *inode, ReebNode *t enode = enode->link_down; reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); /* replace with call to link_down once that exists */ - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; } } @@ -2243,7 +2243,7 @@ static void markMultiResolutionChildArc(ReebNode *end_enode, ReebNode *enode) int i; for (i = 0; i < enode->degree; i++) { - ReebArc *earc = (ReebArc*)enode->arcs[i]; + ReebArc *earc = (ReebArc *)enode->arcs[i]; if (earc->flag == ARC_FREE) { earc->flag = ARC_TAKEN; @@ -2260,7 +2260,7 @@ static void markMultiResolutionArc(ReebArc *start_earc) { if (start_earc->link_up) { ReebArc *earc; - for (earc = start_earc->link_up ; earc; earc = earc->link_up) { + for (earc = start_earc->link_up; earc; earc = earc->link_up) { earc->flag = ARC_TAKEN; if (earc->tail->index != start_earc->tail->index) { @@ -2276,8 +2276,8 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc ReebGraph *reebg = BIF_graphForMultiNode(rigg->link_mesh, enode); int ishape, eshape; - ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)start_node, (BArc*)next_iarc, 1) % SHAPE_LEVELS; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, (BArc*)next_earc, 1) % SHAPE_LEVELS; + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)start_node, (BArc *)next_iarc, 1) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS; while (ishape != eshape && next_earc->link_up) { next_earc->flag = ARC_TAKEN; // mark previous as taken, to prevent backtrack on lower levels @@ -2285,7 +2285,7 @@ static void matchMultiResolutionArc(RigGraph *rigg, RigNode *start_node, RigArc next_earc = next_earc->link_up; reebg = reebg->link_up; enode = next_earc->head; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, (BArc*)next_earc, 1) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, (BArc *)next_earc, 1) % SHAPE_LEVELS; } next_earc->flag = ARC_USED; @@ -2307,15 +2307,15 @@ static void matchMultiResolutionStartingNode(RigGraph *rigg, ReebGraph *reebg, R enode = reebg->nodes.first; - ishape = BLI_subtreeShape((BGraph*)rigg, (BNode*)inode, NULL, 0) % SHAPE_LEVELS; - eshape = BLI_subtreeShape((BGraph*)rigg->link_mesh, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + ishape = BLI_subtreeShape((BGraph *)rigg, (BNode *)inode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)rigg->link_mesh, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; while (ishape != eshape && reebg->link_up) { reebg = reebg->link_up; enode = reebg->nodes.first; - eshape = BLI_subtreeShape((BGraph*)reebg, (BNode*)enode, NULL, 0) % SHAPE_LEVELS; + eshape = BLI_subtreeShape((BGraph *)reebg, (BNode *)enode, NULL, 0) % SHAPE_LEVELS; } inode->link_mesh = enode; @@ -2340,7 +2340,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta // } for (i = 0; i < enode->degree; i++) { - next_earc = (ReebArc*)enode->arcs[i]; + next_earc = (ReebArc *)enode->arcs[i]; // if (next_earc->flag == ARC_FREE) // { @@ -2351,9 +2351,9 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta // } if (next_earc->flag == ARC_FREE && - next_earc->symmetry_flag == symmetry_flag && - next_earc->symmetry_group == symmetry_group && - next_earc->symmetry_level == symmetry_level) + next_earc->symmetry_flag == symmetry_flag && + next_earc->symmetry_group == symmetry_group && + next_earc->symmetry_level == symmetry_level) { // printf("CORRESPONDING ARC FOUND\n"); // printf("flag %i -- level %i -- flag %i -- group %i\n", next_earc->flag, next_earc->symmetry_level, next_earc->symmetry_flag, next_earc->symmetry_group); @@ -2394,7 +2394,7 @@ static void findCorrespondingArc(RigGraph *rigg, RigArc *start_arc, RigNode *sta /* Emergency matching */ for (i = 0; i < enode->degree; i++) { - next_earc = (ReebArc*)enode->arcs[i]; + next_earc = (ReebArc *)enode->arcs[i]; if (next_earc->flag == ARC_FREE && next_earc->symmetry_level == symmetry_level) { // printf("USING:\n"); @@ -2420,14 +2420,14 @@ static void retargetSubgraph(bContext *C, RigGraph *rigg, RigArc *start_arc, Rig retargetArctoArc(C, rigg, start_arc, start_node); enode = BIF_otherNodeFromIndex(earc, enode); - inode = (RigNode*)BLI_otherNode((BArc*)start_arc, (BNode*)inode); + inode = (RigNode *)BLI_otherNode((BArc *)start_arc, (BNode *)inode); /* match with lowest node with correct shape */ matchMultiResolutionNode(rigg, inode, enode); } for (i = 0; i < inode->degree; i++) { - RigArc *next_iarc = (RigArc*)inode->arcs[i]; + RigArc *next_iarc = (RigArc *)inode->arcs[i]; /* no back tracking */ if (next_iarc != start_arc) { @@ -2448,7 +2448,7 @@ static void finishRetarget(RigGraph *rigg) static void adjustGraphs(bContext *C, RigGraph *rigg) { - bArmature *arm= rigg->ob->data; + bArmature *arm = rigg->ob->data; RigArc *arc; for (arc = rigg->arcs.first; arc; arc = arc->next) { @@ -2468,7 +2468,7 @@ static void adjustGraphs(bContext *C, RigGraph *rigg) static void retargetGraphs(bContext *C, RigGraph *rigg) { - bArmature *arm= rigg->ob->data; + bArmature *arm = rigg->ob->data; ReebGraph *reebg = rigg->link_mesh; RigNode *inode; @@ -2534,7 +2534,7 @@ int RIG_nbJoints(RigGraph *rg) static void BIF_freeRetarget(void) { if (GLOBAL_RIGG) { - RIG_freeRigGraph((BGraph*)GLOBAL_RIGG); + RIG_freeRigGraph((BGraph *)GLOBAL_RIGG); GLOBAL_RIGG = NULL; } } @@ -2544,7 +2544,7 @@ void BIF_retargetArmature(bContext *C) ReebGraph *reebg; double start_time, end_time; double gstart_time, gend_time; - double reeb_time, rig_time=0.0, retarget_time=0.0, total_time; + double reeb_time, rig_time = 0.0, retarget_time = 0.0, total_time; gstart_time = start_time = PIL_check_seconds_timer(); @@ -2555,11 +2555,11 @@ void BIF_retargetArmature(bContext *C) printf("Reeb Graph created\n"); - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { Object *ob = base->object; - if (ob->type==OB_ARMATURE) { + if (ob->type == OB_ARMATURE) { RigGraph *rigg; bArmature *arm; @@ -2658,9 +2658,9 @@ void BIF_retargetArc(bContext *C, ReebArc *earc, RigGraph *template_rigg) /* free template if it comes from the edit armature */ if (free_template) { - RIG_freeRigGraph((BGraph*)template_rigg); + RIG_freeRigGraph((BGraph *)template_rigg); } - RIG_freeRigGraph((BGraph*)rigg); + RIG_freeRigGraph((BGraph *)rigg); ED_armature_validate_active(armedit); diff --git a/source/blender/editors/armature/editarmature_sketch.c b/source/blender/editors/armature/editarmature_sketch.c index 09b0226c58c..2201bcf7224 100644 --- a/source/blender/editors/armature/editarmature_sketch.c +++ b/source/blender/editors/armature/editarmature_sketch.c @@ -70,31 +70,31 @@ -typedef int (*GestureDetectFct)(bContext*, SK_Gesture*, SK_Sketch *); -typedef void (*GestureApplyFct)(bContext*, SK_Gesture*, SK_Sketch *); +typedef int (*GestureDetectFct)(bContext *, SK_Gesture *, SK_Sketch *); +typedef void (*GestureApplyFct)(bContext *, SK_Gesture *, SK_Sketch *); typedef struct SK_GestureAction { char name[64]; - GestureDetectFct detect; - GestureApplyFct apply; + GestureDetectFct detect; + GestureApplyFct apply; } SK_GestureAction; #if 0 /* UNUSED 2.5 */ static SK_Point boneSnap; #endif -static int LAST_SNAP_POINT_VALID = 0; -static float LAST_SNAP_POINT[3]; +static int LAST_SNAP_POINT_VALID = 0; +static float LAST_SNAP_POINT[3]; typedef struct SK_StrokeIterator { - HeadFct head; - TailFct tail; - PeekFct peek; - NextFct next; - NextNFct nextN; - PreviousFct previous; - StoppedFct stopped; + HeadFct head; + TailFct tail; + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; float *p, *no; float size; @@ -127,30 +127,29 @@ void sk_applyReverseGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch); int sk_detectConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch); void sk_applyConvertGesture(bContext *C, SK_Gesture *gest, SK_Sketch *sketch); -SK_Sketch* contextSketch(const bContext *c, int create); -SK_Sketch* viewcontextSketch(ViewContext *vc, int create); +SK_Sketch *contextSketch(const bContext *c, int create); +SK_Sketch *viewcontextSketch(ViewContext *vc, int create); void sk_resetOverdraw(SK_Sketch *sketch); int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk); /******************** GESTURE ACTIONS ******************************/ -static SK_GestureAction GESTURE_ACTIONS[] = - { - {"Cut", sk_detectCutGesture, sk_applyCutGesture}, - {"Trim", sk_detectTrimGesture, sk_applyTrimGesture}, - {"Command", sk_detectCommandGesture, sk_applyCommandGesture}, - {"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture}, - {"Merge", sk_detectMergeGesture, sk_applyMergeGesture}, - {"Reverse", sk_detectReverseGesture, sk_applyReverseGesture}, - {"Convert", sk_detectConvertGesture, sk_applyConvertGesture}, - {"", NULL, NULL} - }; +static SK_GestureAction GESTURE_ACTIONS[] = { + {"Cut", sk_detectCutGesture, sk_applyCutGesture}, + {"Trim", sk_detectTrimGesture, sk_applyTrimGesture}, + {"Command", sk_detectCommandGesture, sk_applyCommandGesture}, + {"Delete", sk_detectDeleteGesture, sk_applyDeleteGesture}, + {"Merge", sk_detectMergeGesture, sk_applyMergeGesture}, + {"Reverse", sk_detectReverseGesture, sk_applyReverseGesture}, + {"Convert", sk_detectConvertGesture, sk_applyConvertGesture}, + {"", NULL, NULL} +}; /******************** TEMPLATES UTILS *************************/ static char *TEMPLATES_MENU = NULL; -static int TEMPLATES_CURRENT = 0; +static int TEMPLATES_CURRENT = 0; static GHash *TEMPLATES_HASH = NULL; static RigGraph *TEMPLATE_RIGG = NULL; @@ -169,7 +168,7 @@ void BIF_makeListTemplates(const bContext *C) TEMPLATES_HASH = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "makeListTemplates gh"); TEMPLATES_CURRENT = 0; - for ( base = FIRSTBASE; base; base = base->next ) { + for (base = FIRSTBASE; base; base = base->next) { Object *ob = base->object; if (ob != obedit && ob->type == OB_ARMATURE) { @@ -205,7 +204,7 @@ const char *BIF_listTemplates(const bContext *UNUSED(C)) Object *ob = BLI_ghashIterator_getValue(&ghi); int key = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(&ghi)); - p += sprintf(p, "|%s%%x%i", ob->id.name+2, key); + p += sprintf(p, "|%s%%x%i", ob->id.name + 2, key); BLI_ghashIterator_step(&ghi); } @@ -237,7 +236,7 @@ int BIF_currentTemplate(const bContext *C) return TEMPLATES_CURRENT; } -static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob) +static RigGraph *sk_makeTemplateGraph(const bContext *C, Object *ob) { Object *obedit = CTX_data_edit_object(C); if (ob == obedit) { @@ -246,7 +245,7 @@ static RigGraph* sk_makeTemplateGraph(const bContext *C, Object *ob) if (ob != NULL) { if (TEMPLATE_RIGG && TEMPLATE_RIGG->ob != ob) { - RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); + RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG); TEMPLATE_RIGG = NULL; } @@ -275,7 +274,7 @@ int BIF_nbJointsTemplate(const bContext *C) } } -const char * BIF_nameBoneTemplate(const bContext *C) +const char *BIF_nameBoneTemplate(const bContext *C) { ToolSettings *ts = CTX_data_tool_settings(C); SK_Sketch *stk = contextSketch(C, 1); @@ -308,7 +307,7 @@ void BIF_freeTemplates(bContext *UNUSED(C)) } if (TEMPLATE_RIGG != NULL) { - RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); + RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG); TEMPLATE_RIGG = NULL; } } @@ -323,7 +322,7 @@ void BIF_setTemplate(bContext *C, int index) ts->skgen_template = NULL; if (TEMPLATE_RIGG != NULL) { - RIG_freeRigGraph((BGraph*)TEMPLATE_RIGG); + RIG_freeRigGraph((BGraph *)TEMPLATE_RIGG); } TEMPLATE_RIGG = NULL; } @@ -349,21 +348,21 @@ static void sk_autoname(bContext *C, ReebArc *arc) if (side[0] == '\0') { valid = 1; } - else if (strcmp(side, "R")==0 || strcmp(side, "L")==0) { + else if (strcmp(side, "R") == 0 || strcmp(side, "L") == 0) { valid = 1; caps = 1; } - else if (strcmp(side, "r")==0 || strcmp(side, "l")==0) { + else if (strcmp(side, "r") == 0 || strcmp(side, "l") == 0) { valid = 1; caps = 0; } if (valid) { if (arc->head->p[0] < 0) { - BLI_snprintf(side, 8, caps?"R":"r"); + BLI_snprintf(side, 8, caps ? "R" : "r"); } else { - BLI_snprintf(side, 8, caps?"L":"l"); + BLI_snprintf(side, 8, caps ? "L" : "l"); } } } @@ -433,7 +432,7 @@ static void sk_retargetStroke(bContext *C, SK_Stroke *stk) MEM_freeN(arc->head); MEM_freeN(arc->tail); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); } /**************************************************************/ @@ -473,7 +472,7 @@ static void sk_drawEdge(GLUquadric *quad, SK_Point *pt0, SK_Point *pt1, float si angle = angle_normalized_v3v3(vec2, vec1); - glRotatef(angle * (float)(180.0/M_PI) + 180.0f, axis[0], axis[1], axis[2]); + glRotatef(angle * (float)(180.0 / M_PI) + 180.0f, axis[0], axis[1], axis[2]); gluCylinder(quad, sk_clampPointSize(pt1, size), sk_clampPointSize(pt0, size), length, 8, 8); } @@ -493,7 +492,7 @@ static void sk_drawNormal(GLUquadric *quad, SK_Point *pt, float size, float heig angle = angle_normalized_v3v3(vec2, pt->no); - glRotatef(angle * (float)(180.0/M_PI), axis[0], axis[1], axis[2]); + glRotatef(angle * (float)(180.0 / M_PI), axis[0], axis[1], axis[2]); glColor3f(0, 1, 1); gluCylinder(quad, sk_clampPointSize(pt, size), 0, sk_clampPointSize(pt, height), 10, 2); @@ -569,7 +568,7 @@ static void sk_drawStroke(SK_Stroke *stk, int id, float color[3], int start, int static void drawSubdividedStrokeBy(ToolSettings *toolsettings, BArcIterator *iter, NextSubdivisionFunc next_subdividion) { - SK_Stroke *stk = ((SK_StrokeIterator*)iter)->stroke; + SK_Stroke *stk = ((SK_StrokeIterator *)iter)->stroke; float head[3], tail[3]; int bone_start = 0; int end = iter->length; @@ -622,7 +621,7 @@ static void sk_drawStrokeSubdivision(ToolSettings *toolsettings, SK_Stroke *stk) else { if (i - head_index > 1) { SK_StrokeIterator sk_iter; - BArcIterator *iter = (BArcIterator*)&sk_iter; + BArcIterator *iter = (BArcIterator *)&sk_iter; initStrokeIterator(iter, stk, head_index, i); @@ -733,10 +732,10 @@ void sk_resetOverdraw(SK_Sketch *sketch) int sk_hasOverdraw(SK_Sketch *sketch, SK_Stroke *stk) { - return sketch->over.target && - sketch->over.count >= SK_OVERDRAW_LIMIT && - (sketch->over.target == stk || stk == NULL) && - (sketch->over.start != -1 || sketch->over.end != -1); + return sketch->over.target && + sketch->over.count >= SK_OVERDRAW_LIMIT && + (sketch->over.target == stk || stk == NULL) && + (sketch->over.start != -1 || sketch->over.end != -1); } static void sk_updateOverdraw(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_DrawData *dd) @@ -991,8 +990,8 @@ static int sk_getStrokeSnapPoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, S BLI_freelistN(&sketch->depth_peels); sketch->depth_peels.first = sketch->depth_peels.last = NULL; - mvalf[0]= dd->mval[0]; - mvalf[1]= dd->mval[1]; + mvalf[0] = dd->mval[0]; + mvalf[1] = dd->mval[1]; peelObjectsContext(C, &sketch->depth_peels, mvalf, SNAP_ALL); if (stk->nb_points > 0 && stk->points[stk->nb_points - 1].type == PT_CONTINUOUS) { @@ -1195,12 +1194,12 @@ static void sk_getStrokePoint(bContext *C, SK_Point *pt, SK_Sketch *sketch, SK_S /********************************************/ -static void* headPoint(void *arg); -static void* tailPoint(void *arg); -static void* nextPoint(void *arg); -static void* nextNPoint(void *arg, int n); -static void* peekPoint(void *arg, int n); -static void* previousPoint(void *arg); +static void *headPoint(void *arg); +static void *tailPoint(void *arg); +static void *nextPoint(void *arg); +static void *nextNPoint(void *arg, int n); +static void *peekPoint(void *arg, int n); +static void *previousPoint(void *arg); static int iteratorStopped(void *arg); static void initIteratorFct(SK_StrokeIterator *iter) @@ -1214,7 +1213,7 @@ static void initIteratorFct(SK_StrokeIterator *iter) iter->stopped = iteratorStopped; } -static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index) +static SK_Point *setIteratorValues(SK_StrokeIterator *iter, int index) { SK_Point *pt = NULL; @@ -1235,7 +1234,7 @@ static SK_Point* setIteratorValues(SK_StrokeIterator *iter, int index) void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; initIteratorFct(iter); iter->stroke = stk; @@ -1257,9 +1256,9 @@ void initStrokeIterator(BArcIterator *arg, SK_Stroke *stk, int start, int end) } -static void* headPoint(void *arg) +static void *headPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; result = &(iter->stroke->points[iter->start - iter->stride]); @@ -1270,9 +1269,9 @@ static void* headPoint(void *arg) return result; } -static void* tailPoint(void *arg) +static void *tailPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; result = &(iter->stroke->points[iter->end + iter->stride]); @@ -1283,9 +1282,9 @@ static void* tailPoint(void *arg) return result; } -static void* nextPoint(void *arg) +static void *nextPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; iter->index++; @@ -1296,9 +1295,9 @@ static void* nextPoint(void *arg) return result; } -static void* nextNPoint(void *arg, int n) +static void *nextNPoint(void *arg, int n) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; iter->index += n; @@ -1311,9 +1310,9 @@ static void* nextNPoint(void *arg, int n) return result; } -static void* peekPoint(void *arg, int n) +static void *peekPoint(void *arg, int n) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; int index = iter->index + n; @@ -1325,9 +1324,9 @@ static void* peekPoint(void *arg, int n) return result; } -static void* previousPoint(void *arg) +static void *previousPoint(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; SK_Point *result = NULL; if (iter->index > 0) { @@ -1340,7 +1339,7 @@ static void* previousPoint(void *arg) static int iteratorStopped(void *arg) { - SK_StrokeIterator *iter = (SK_StrokeIterator*)arg; + SK_StrokeIterator *iter = (SK_StrokeIterator *)arg; if (iter->index >= iter->length) { return 1; @@ -1383,7 +1382,7 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk) if (i - head_index > 1) { SK_StrokeIterator sk_iter; - BArcIterator *iter = (BArcIterator*)&sk_iter; + BArcIterator *iter = (BArcIterator *)&sk_iter; initStrokeIterator(iter, stk, head_index, i); @@ -1410,12 +1409,12 @@ static void sk_convertStroke(bContext *C, SK_Stroke *stk) } new_parent = bone; - bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; /* move to end of chain */ while (bone->parent != NULL) { bone = bone->parent; - bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } if (parent != NULL) { @@ -1594,7 +1593,7 @@ static int sk_getIntersections(bContext *C, ListBase *list, SK_Sketch *sketch, S static int sk_getSegments(SK_Stroke *segments, SK_Stroke *gesture) { SK_StrokeIterator sk_iter; - BArcIterator *iter = (BArcIterator*)&sk_iter; + BArcIterator *iter = (BArcIterator *)&sk_iter; float CORRELATION_THRESHOLD = 0.99f; float *vec; @@ -1706,7 +1705,7 @@ int sk_detectCommandGesture(bContext *UNUSED(C), SK_Gesture *gest, SK_Sketch *UN SK_Intersection *isect, *self_isect; /* get the the last intersection of the first pair */ - for ( isect = gest->intersections.first; isect; isect = isect->next ) { + for (isect = gest->intersections.first; isect; isect = isect->next) { if (isect->stroke == isect->next->stroke) { isect = isect->next; break; @@ -1801,7 +1800,7 @@ int sk_detectMergeGesture(bContext *C, SK_Gesture *gest, SK_Sketch *UNUSED(sketc dist = MAX2(ABS(start_val[0] - end_val[0]), ABS(start_val[1] - end_val[1])); /* if gesture is a circle */ - if ( dist <= 20 ) { + if (dist <= 20) { SK_Intersection *isect; /* check if it circled around an exact point */ @@ -1971,14 +1970,14 @@ static int sk_selectStroke(bContext *C, SK_Sketch *sketch, const int mval[2], in view3d_set_viewcontext(C, &vc); - rect.xmin = mval[0]-5; - rect.xmax = mval[0]+5; - rect.ymin = mval[1]-5; - rect.ymax = mval[1]+5; + rect.xmin = mval[0] - 5; + rect.xmax = mval[0] + 5; + rect.ymin = mval[1] - 5; + rect.ymax = mval[1] + 5; hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); - if (hits>0) { + if (hits > 0) { int besthitresult = -1; if (hits == 1) { @@ -2027,7 +2026,7 @@ static void sk_queueRedrawSketch(SK_Sketch *sketch) static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, int with_names) { - ToolSettings *ts= scene->toolsettings; + ToolSettings *ts = scene->toolsettings; SK_Stroke *stk; glClear(GL_DEPTH_BUFFER_BIT); @@ -2053,7 +2052,7 @@ static void sk_drawSketch(Scene *scene, View3D *UNUSED(v3d), SK_Sketch *sketch, sk_adjustIndexes(sketch, &start, &end); } - sk_drawStroke(stk, -1, (stk->selected==1?selected_rgb:unselected_rgb), start, end); + sk_drawStroke(stk, -1, (stk->selected == 1 ? selected_rgb : unselected_rgb), start, end); if (stk->selected == 1) { sk_drawStrokeSubdivision(ts, stk); @@ -2204,11 +2203,11 @@ static int sk_draw_stroke(bContext *C, SK_Sketch *sketch, SK_Stroke *stk, SK_Dra static int ValidSketchViewContext(ViewContext *vc) { Object *obedit = vc->obedit; - Scene *scene= vc->scene; + Scene *scene = vc->scene; if (obedit && - obedit->type == OB_ARMATURE && - scene->toolsettings->bone_sketching & BONE_SKETCHING) + obedit->type == OB_ARMATURE && + scene->toolsettings->bone_sketching & BONE_SKETCHING) { return 1; } @@ -2247,7 +2246,7 @@ static int sketch_delete(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(ev sk_deleteSelectedStrokes(sketch); // allqueue(REDRAWVIEW3D, 0); } - WM_event_add_notifier(C, NC_SCREEN|ND_SKETCH|NA_REMOVED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_SKETCH | NA_REMOVED, NULL); return OPERATOR_FINISHED; } @@ -2303,7 +2302,7 @@ void BIF_selectAllSketch(bContext *C, int mode) } #endif -SK_Sketch* contextSketch(const bContext *C, int create) +SK_Sketch *contextSketch(const bContext *C, int create) { Object *obedit = CTX_data_edit_object(C); SK_Sketch *sketch = NULL; @@ -2320,7 +2319,7 @@ SK_Sketch* contextSketch(const bContext *C, int create) return sketch; } -SK_Sketch* viewcontextSketch(ViewContext *vc, int create) +SK_Sketch *viewcontextSketch(ViewContext *vc, int create) { Object *obedit = vc->obedit; SK_Sketch *sketch = NULL; @@ -2442,51 +2441,51 @@ static int sketch_draw_modal(bContext *C, wmOperator *op, wmEvent *event, short int retval = OPERATOR_RUNNING_MODAL; switch (event->type) { - case LEFTCTRLKEY: - case RIGHTCTRLKEY: - snap = event->ctrl; - RNA_boolean_set(op->ptr, "snap", snap); - break; - case MOUSEMOVE: - case INBETWEEN_MOUSEMOVE: - dd->mval[0] = event->mval[0]; - dd->mval[1] = event->mval[1]; - sk_draw_stroke(C, sketch, stk, dd, snap); - ED_area_tag_redraw(CTX_wm_area(C)); - break; - case ESCKEY: - op->type->cancel(C, op); - ED_area_tag_redraw(CTX_wm_area(C)); - retval = OPERATOR_CANCELLED; - break; - case LEFTMOUSE: - if (event->val == KM_RELEASE) { - if (gesture == 0) { - sk_endContinuousStroke(stk); - sk_filterLastContinuousStroke(stk); - sk_updateNextPoint(sketch, stk); - ED_area_tag_redraw(CTX_wm_area(C)); - MEM_freeN(op->customdata); - retval = OPERATOR_FINISHED; - } - else { - sk_endContinuousStroke(stk); - sk_filterLastContinuousStroke(stk); - - if (stk->nb_points > 1) { - /* apply gesture here */ - sk_applyGesture(C, sketch); + case LEFTCTRLKEY: + case RIGHTCTRLKEY: + snap = event->ctrl; + RNA_boolean_set(op->ptr, "snap", snap); + break; + case MOUSEMOVE: + case INBETWEEN_MOUSEMOVE: + dd->mval[0] = event->mval[0]; + dd->mval[1] = event->mval[1]; + sk_draw_stroke(C, sketch, stk, dd, snap); + ED_area_tag_redraw(CTX_wm_area(C)); + break; + case ESCKEY: + op->type->cancel(C, op); + ED_area_tag_redraw(CTX_wm_area(C)); + retval = OPERATOR_CANCELLED; + break; + case LEFTMOUSE: + if (event->val == KM_RELEASE) { + if (gesture == 0) { + sk_endContinuousStroke(stk); + sk_filterLastContinuousStroke(stk); + sk_updateNextPoint(sketch, stk); + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(op->customdata); + retval = OPERATOR_FINISHED; } + else { + sk_endContinuousStroke(stk); + sk_filterLastContinuousStroke(stk); - sk_freeStroke(stk); - sketch->gesture = NULL; + if (stk->nb_points > 1) { + /* apply gesture here */ + sk_applyGesture(C, sketch); + } - ED_area_tag_redraw(CTX_wm_area(C)); - MEM_freeN(op->customdata); - retval = OPERATOR_FINISHED; + sk_freeStroke(stk); + sketch->gesture = NULL; + + ED_area_tag_redraw(CTX_wm_area(C)); + MEM_freeN(op->customdata); + retval = OPERATOR_FINISHED; + } } - } - break; + break; } return retval; @@ -2517,7 +2516,7 @@ static int sketch_draw_preview(bContext *C, wmOperator *op, wmEvent *event) ED_area_tag_redraw(CTX_wm_area(C)); } - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } /* ============================================== Poll Functions ============================================= */ @@ -2528,8 +2527,8 @@ int ED_operator_sketch_mode_active_stroke(bContext *C) SK_Sketch *sketch = contextSketch(C, 0); if (ts->bone_sketching & BONE_SKETCHING && - sketch != NULL && - sketch->active_stroke != NULL) + sketch != NULL && + sketch->active_stroke != NULL) { return 1; } @@ -2544,9 +2543,9 @@ static int ED_operator_sketch_mode_gesture(bContext *C) SK_Sketch *sketch = contextSketch(C, 0); if (ts->bone_sketching & BONE_SKETCHING && - (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 && - sketch != NULL && - sketch->active_stroke == NULL) + (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0 && + sketch != NULL && + sketch->active_stroke == NULL) { return 1; } @@ -2561,9 +2560,9 @@ int ED_operator_sketch_full_mode(bContext *C) ToolSettings *ts = CTX_data_tool_settings(C); if (obedit && - obedit->type == OB_ARMATURE && - ts->bone_sketching & BONE_SKETCHING && - (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0) + obedit->type == OB_ARMATURE && + ts->bone_sketching & BONE_SKETCHING && + (ts->bone_sketching & BONE_SKETCHING_QUICK) == 0) { return 1; } @@ -2578,8 +2577,8 @@ int ED_operator_sketch_mode(const bContext *C) ToolSettings *ts = CTX_data_tool_settings(C); if (obedit && - obedit->type == OB_ARMATURE && - ts->bone_sketching & BONE_SKETCHING) + obedit->type == OB_ARMATURE && + ts->bone_sketching & BONE_SKETCHING) { return 1; } @@ -2595,6 +2594,7 @@ void SKETCH_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name = "Delete"; ot->idname = "SKETCH_OT_delete"; + ot->description = "Delete a sketch stroke"; /* api callbacks */ ot->invoke = sketch_delete; @@ -2610,6 +2610,7 @@ void SKETCH_OT_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select"; ot->idname = "SKETCH_OT_select"; + ot->description = "Select a sketch stroke"; /* api callbacks */ ot->invoke = sketch_select; @@ -2625,6 +2626,7 @@ void SKETCH_OT_cancel_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "Cancel Stroke"; ot->idname = "SKETCH_OT_cancel_stroke"; + ot->description = "Cancel the current sketch stroke"; /* api callbacks */ ot->invoke = sketch_cancel; @@ -2640,6 +2642,7 @@ void SKETCH_OT_convert(wmOperatorType *ot) /* identifiers */ ot->name = "Convert"; ot->idname = "SKETCH_OT_convert"; + ot->description = "Convert the selected sketch strokes to bone chains"; /* api callbacks */ ot->invoke = sketch_convert; @@ -2655,6 +2658,7 @@ void SKETCH_OT_finish_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "End Stroke"; ot->idname = "SKETCH_OT_finish_stroke"; + ot->description = "End and keep the current sketch stroke"; /* api callbacks */ ot->invoke = sketch_finish; @@ -2670,6 +2674,7 @@ void SKETCH_OT_draw_preview(wmOperatorType *ot) /* identifiers */ ot->name = "Draw Preview"; ot->idname = "SKETCH_OT_draw_preview"; + ot->description = "Draw preview of current sketch stroke (internal use)"; /* api callbacks */ ot->invoke = sketch_draw_preview; @@ -2687,6 +2692,7 @@ void SKETCH_OT_draw_stroke(wmOperatorType *ot) /* identifiers */ ot->name = "Draw Stroke"; ot->idname = "SKETCH_OT_draw_stroke"; + ot->description = "Start to draw a sketch stroke"; /* api callbacks */ ot->invoke = sketch_draw_stroke; @@ -2706,6 +2712,7 @@ void SKETCH_OT_gesture(wmOperatorType *ot) /* identifiers */ ot->name = "Gesture"; ot->idname = "SKETCH_OT_gesture"; + ot->description = "Start to draw a gesture stroke"; /* api callbacks */ ot->invoke = sketch_draw_gesture; diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 3828c025bcd..ccba3599318 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -80,40 +80,40 @@ static void error(const char *str) { printf("error: %s\n", str); } /************************** Laplacian System *****************************/ struct LaplacianSystem { - NLContext context; /* opennl context */ + NLContext context; /* opennl context */ int totvert, totface; - float **verts; /* vertex coordinates */ - float *varea; /* vertex weights for laplacian computation */ - char *vpinned; /* vertex pinning */ - int (*faces)[3]; /* face vertex indices */ - float (*fweights)[3]; /* cotangent weights per face */ + float **verts; /* vertex coordinates */ + float *varea; /* vertex weights for laplacian computation */ + char *vpinned; /* vertex pinning */ + int (*faces)[3]; /* face vertex indices */ + float (*fweights)[3]; /* cotangent weights per face */ - int areaweights; /* use area in cotangent weights? */ - int storeweights; /* store cotangent weights in fweights */ - int nlbegun; /* nlBegin(NL_SYSTEM/NL_MATRIX) done */ + int areaweights; /* use area in cotangent weights? */ + int storeweights; /* store cotangent weights in fweights */ + int nlbegun; /* nlBegin(NL_SYSTEM/NL_MATRIX) done */ - EdgeHash *edgehash; /* edge hash for construction */ + EdgeHash *edgehash; /* edge hash for construction */ struct HeatWeighting { MFace *mface; int totvert; int totface; - float (*verts)[3]; /* vertex coordinates */ - float (*vnors)[3]; /* vertex normals */ + float (*verts)[3]; /* vertex coordinates */ + float (*vnors)[3]; /* vertex normals */ - float (*root)[3]; /* bone root */ - float (*tip)[3]; /* bone tip */ + float (*root)[3]; /* bone root */ + float (*tip)[3]; /* bone tip */ float (*source)[3]; /* vertex source */ int numsource; - float *H; /* diagonal H matrix */ - float *p; /* values from all p vectors */ - float *mindist; /* minimum distance to a bone for all vertices */ + float *H; /* diagonal H matrix */ + float *p; /* values from all p vectors */ + float *mindist; /* minimum distance to a bone for all vertices */ - BVHTree *bvhtree; /* ray tracing acceleration structure */ - MFace **vface; /* a face that the vertex belongs to */ + BVHTree *bvhtree; /* ray tracing acceleration structure */ + MFace **vface; /* a face that the vertex belongs to */ } heat; #ifdef RIGID_DEFORM @@ -143,9 +143,9 @@ static void laplacian_increase_edge_count(EdgeHash *edgehash, int v1, int v2) void **p = BLI_edgehash_lookup_p(edgehash, v1, v2); if (p) - *p = (void*)((intptr_t)*p + (intptr_t)1); + *p = (void *)((intptr_t)*p + (intptr_t)1); else - BLI_edgehash_insert(edgehash, v1, v2, (void*)(intptr_t)1); + BLI_edgehash_insert(edgehash, v1, v2, (void *)(intptr_t)1); } static int laplacian_edge_count(EdgeHash *edgehash, int v1, int v2) @@ -166,81 +166,81 @@ static float cotan_weight(float *v1, float *v2, float *v3) if (clen == 0.0f) return 0.0f; - return dot_v3v3(a, b)/clen; + return dot_v3v3(a, b) / clen; } static void laplacian_triangle_area(LaplacianSystem *sys, int i1, int i2, int i3) { float t1, t2, t3, len1, len2, len3, area; - float *varea= sys->varea, *v1, *v2, *v3; + float *varea = sys->varea, *v1, *v2, *v3; int obtuse = 0; - v1= sys->verts[i1]; - v2= sys->verts[i2]; - v3= sys->verts[i3]; + v1 = sys->verts[i1]; + v2 = sys->verts[i2]; + v3 = sys->verts[i3]; - t1= cotan_weight(v1, v2, v3); - t2= cotan_weight(v2, v3, v1); - t3= cotan_weight(v3, v1, v2); + t1 = cotan_weight(v1, v2, v3); + t2 = cotan_weight(v2, v3, v1); + t3 = cotan_weight(v3, v1, v2); - if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse= 1; - else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse= 2; - else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse= 3; + if (angle_v3v3v3(v2, v1, v3) > DEG2RADF(90.0f)) obtuse = 1; + else if (angle_v3v3v3(v1, v2, v3) > DEG2RADF(90.0f)) obtuse = 2; + else if (angle_v3v3v3(v1, v3, v2) > DEG2RADF(90.0f)) obtuse = 3; if (obtuse > 0) { - area= area_tri_v3(v1, v2, v3); + area = area_tri_v3(v1, v2, v3); - varea[i1] += (obtuse == 1)? area: area*0.5f; - varea[i2] += (obtuse == 2)? area: area*0.5f; - varea[i3] += (obtuse == 3)? area: area*0.5f; + varea[i1] += (obtuse == 1) ? area : area * 0.5f; + varea[i2] += (obtuse == 2) ? area : area * 0.5f; + varea[i3] += (obtuse == 3) ? area : area * 0.5f; } else { - len1= len_v3v3(v2, v3); - len2= len_v3v3(v1, v3); - len3= len_v3v3(v1, v2); + len1 = len_v3v3(v2, v3); + len2 = len_v3v3(v1, v3); + len3 = len_v3v3(v1, v2); - t1 *= len1*len1; - t2 *= len2*len2; - t3 *= len3*len3; + t1 *= len1 * len1; + t2 *= len2 * len2; + t3 *= len3 * len3; - varea[i1] += (t2 + t3)*0.25f; - varea[i2] += (t1 + t3)*0.25f; - varea[i3] += (t1 + t2)*0.25f; + varea[i1] += (t2 + t3) * 0.25f; + varea[i2] += (t1 + t3) * 0.25f; + varea[i3] += (t1 + t2) * 0.25f; } } static void laplacian_triangle_weights(LaplacianSystem *sys, int f, int i1, int i2, int i3) { float t1, t2, t3; - float *varea= sys->varea, *v1, *v2, *v3; + float *varea = sys->varea, *v1, *v2, *v3; - v1= sys->verts[i1]; - v2= sys->verts[i2]; - v3= sys->verts[i3]; + v1 = sys->verts[i1]; + v2 = sys->verts[i2]; + v3 = sys->verts[i3]; /* instead of *0.5 we divided by the number of faces of the edge, it still * needs to be verified that this is indeed the correct thing to do! */ - t1= cotan_weight(v1, v2, v3)/laplacian_edge_count(sys->edgehash, i2, i3); - t2= cotan_weight(v2, v3, v1)/laplacian_edge_count(sys->edgehash, i3, i1); - t3= cotan_weight(v3, v1, v2)/laplacian_edge_count(sys->edgehash, i1, i2); + t1 = cotan_weight(v1, v2, v3) / laplacian_edge_count(sys->edgehash, i2, i3); + t2 = cotan_weight(v2, v3, v1) / laplacian_edge_count(sys->edgehash, i3, i1); + t3 = cotan_weight(v3, v1, v2) / laplacian_edge_count(sys->edgehash, i1, i2); - nlMatrixAdd(i1, i1, (t2+t3)*varea[i1]); - nlMatrixAdd(i2, i2, (t1+t3)*varea[i2]); - nlMatrixAdd(i3, i3, (t1+t2)*varea[i3]); + nlMatrixAdd(i1, i1, (t2 + t3) * varea[i1]); + nlMatrixAdd(i2, i2, (t1 + t3) * varea[i2]); + nlMatrixAdd(i3, i3, (t1 + t2) * varea[i3]); - nlMatrixAdd(i1, i2, -t3*varea[i1]); - nlMatrixAdd(i2, i1, -t3*varea[i2]); + nlMatrixAdd(i1, i2, -t3 * varea[i1]); + nlMatrixAdd(i2, i1, -t3 * varea[i2]); - nlMatrixAdd(i2, i3, -t1*varea[i2]); - nlMatrixAdd(i3, i2, -t1*varea[i3]); + nlMatrixAdd(i2, i3, -t1 * varea[i2]); + nlMatrixAdd(i3, i2, -t1 * varea[i3]); - nlMatrixAdd(i3, i1, -t2*varea[i3]); - nlMatrixAdd(i1, i3, -t2*varea[i1]); + nlMatrixAdd(i3, i1, -t2 * varea[i3]); + nlMatrixAdd(i1, i3, -t2 * varea[i1]); if (sys->storeweights) { - sys->fweights[f][0]= t1*varea[i1]; - sys->fweights[f][1]= t2*varea[i2]; - sys->fweights[f][2]= t3*varea[i3]; + sys->fweights[f][0] = t1 * varea[i1]; + sys->fweights[f][1] = t2 * varea[i2]; + sys->fweights[f][2] = t3 * varea[i3]; } } @@ -248,17 +248,17 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac { LaplacianSystem *sys; - sys= MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem"); + sys = MEM_callocN(sizeof(LaplacianSystem), "LaplacianSystem"); - sys->verts= MEM_callocN(sizeof(float*)*totvert, "LaplacianSystemVerts"); - sys->vpinned= MEM_callocN(sizeof(char)*totvert, "LaplacianSystemVpinned"); - sys->faces= MEM_callocN(sizeof(int)*3*totface, "LaplacianSystemFaces"); + sys->verts = MEM_callocN(sizeof(float *) * totvert, "LaplacianSystemVerts"); + sys->vpinned = MEM_callocN(sizeof(char) * totvert, "LaplacianSystemVpinned"); + sys->faces = MEM_callocN(sizeof(int) * 3 * totface, "LaplacianSystemFaces"); - sys->totvert= 0; - sys->totface= 0; + sys->totvert = 0; + sys->totface = 0; - sys->areaweights= 1; - sys->storeweights= 0; + sys->areaweights = 1; + sys->storeweights = 0; /* create opennl context */ nlNewContext(); @@ -266,53 +266,53 @@ static LaplacianSystem *laplacian_system_construct_begin(int totvert, int totfac if (lsq) nlSolverParameteri(NL_LEAST_SQUARES, NL_TRUE); - sys->context= nlGetCurrent(); + sys->context = nlGetCurrent(); return sys; } void laplacian_add_vertex(LaplacianSystem *sys, float *co, int pinned) { - sys->verts[sys->totvert]= co; - sys->vpinned[sys->totvert]= pinned; + sys->verts[sys->totvert] = co; + sys->vpinned[sys->totvert] = pinned; sys->totvert++; } void laplacian_add_triangle(LaplacianSystem *sys, int v1, int v2, int v3) { - sys->faces[sys->totface][0]= v1; - sys->faces[sys->totface][1]= v2; - sys->faces[sys->totface][2]= v3; + sys->faces[sys->totface][0] = v1; + sys->faces[sys->totface][1] = v2; + sys->faces[sys->totface][2] = v3; sys->totface++; } static void laplacian_system_construct_end(LaplacianSystem *sys) { int (*face)[3]; - int a, totvert=sys->totvert, totface=sys->totface; + int a, totvert = sys->totvert, totface = sys->totface; laplacian_begin_solve(sys, 0); - sys->varea= MEM_callocN(sizeof(float)*totvert, "LaplacianSystemVarea"); + sys->varea = MEM_callocN(sizeof(float) * totvert, "LaplacianSystemVarea"); - sys->edgehash= BLI_edgehash_new(); - for (a=0, face=sys->faces; atotface; a++, face++) { + sys->edgehash = BLI_edgehash_new(); + for (a = 0, face = sys->faces; a < sys->totface; a++, face++) { laplacian_increase_edge_count(sys->edgehash, (*face)[0], (*face)[1]); laplacian_increase_edge_count(sys->edgehash, (*face)[1], (*face)[2]); laplacian_increase_edge_count(sys->edgehash, (*face)[2], (*face)[0]); } if (sys->areaweights) - for (a=0, face=sys->faces; atotface; a++, face++) + for (a = 0, face = sys->faces; a < sys->totface; a++, face++) laplacian_triangle_area(sys, (*face)[0], (*face)[1], (*face)[2]); - for (a=0; aareaweights) { if (sys->varea[a] != 0.0f) - sys->varea[a]= 0.5f/sys->varea[a]; + sys->varea[a] = 0.5f / sys->varea[a]; } else - sys->varea[a]= 1.0f; + sys->varea[a] = 1.0f; /* for heat weighting */ if (sys->heat.H) @@ -320,21 +320,21 @@ static void laplacian_system_construct_end(LaplacianSystem *sys) } if (sys->storeweights) - sys->fweights= MEM_callocN(sizeof(float)*3*totface, "LaplacianFWeight"); + sys->fweights = MEM_callocN(sizeof(float) * 3 * totface, "LaplacianFWeight"); - for (a=0, face=sys->faces; afaces; a < totface; a++, face++) laplacian_triangle_weights(sys, a, (*face)[0], (*face)[1], (*face)[2]); MEM_freeN(sys->faces); - sys->faces= NULL; + sys->faces = NULL; if (sys->varea) { MEM_freeN(sys->varea); - sys->varea= NULL; + sys->varea = NULL; } BLI_edgehash_free(sys->edgehash, NULL); - sys->edgehash= NULL; + sys->edgehash = NULL; } static void laplacian_system_delete(LaplacianSystem *sys) @@ -357,7 +357,7 @@ void laplacian_begin_solve(LaplacianSystem *sys, int index) nlBegin(NL_SYSTEM); if (index >= 0) { - for (a=0; atotvert; a++) { + for (a = 0; a < sys->totvert; a++) { if (sys->vpinned[a]) { nlSetVariable(0, a, sys->verts[a][index]); nlLockVariable(a); @@ -395,10 +395,10 @@ float laplacian_system_get_solution(int v) /* From "Automatic Rigging and Animation of 3D Characters" * Ilya Baran and Jovan Popovic, SIGGRAPH 2007 */ -#define C_WEIGHT 1.0f -#define WEIGHT_LIMIT_START 0.05f -#define WEIGHT_LIMIT_END 0.025f -#define DISTANCE_EPSILON 1e-4f +#define C_WEIGHT 1.0f +#define WEIGHT_LIMIT_START 0.05f +#define WEIGHT_LIMIT_END 0.025f +#define DISTANCE_EPSILON 1e-4f typedef struct BVHCallbackUserData { float start[3]; @@ -408,7 +408,7 @@ typedef struct BVHCallbackUserData { static void bvh_callback(void *userdata, int index, const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) { - BVHCallbackUserData *data = (struct BVHCallbackUserData*)userdata; + BVHCallbackUserData *data = (struct BVHCallbackUserData *)userdata; MFace *mf = data->sys->heat.mface + index; float (*verts)[3] = data->sys->heat.verts; float lambda, uv[2], n[3], dir[3]; @@ -444,27 +444,27 @@ static void heat_ray_tree_create(LaplacianSystem *sys) int a; sys->heat.bvhtree = BLI_bvhtree_new(totface, 0.0f, 4, 6); - sys->heat.vface = MEM_callocN(sizeof(MFace*)*totvert, "HeatVFaces"); + sys->heat.vface = MEM_callocN(sizeof(MFace *) * totvert, "HeatVFaces"); - for (a=0; av1], bb, bb+3); - DO_MINMAX(verts[mf->v2], bb, bb+3); - DO_MINMAX(verts[mf->v3], bb, bb+3); + INIT_MINMAX(bb, bb + 3); + DO_MINMAX(verts[mf->v1], bb, bb + 3); + DO_MINMAX(verts[mf->v2], bb, bb + 3); + DO_MINMAX(verts[mf->v3], bb, bb + 3); if (mf->v4) { - DO_MINMAX(verts[mf->v4], bb, bb+3); + DO_MINMAX(verts[mf->v4], bb, bb + 3); } BLI_bvhtree_insert(sys->heat.bvhtree, a, bb, 2); //Setup inverse pointers to use on isect.orig - sys->heat.vface[mf->v1]= mf; - sys->heat.vface[mf->v2]= mf; - sys->heat.vface[mf->v3]= mf; - if (mf->v4) sys->heat.vface[mf->v4]= mf; + sys->heat.vface[mf->v1] = mf; + sys->heat.vface[mf->v2] = mf; + sys->heat.vface[mf->v3] = mf; + if (mf->v4) sys->heat.vface[mf->v4] = mf; } BLI_bvhtree_balance(sys->heat.bvhtree); @@ -478,16 +478,16 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) float end[3]; int visible; - mface= sys->heat.vface[vertex]; + mface = sys->heat.vface[vertex]; if (!mface) return 1; - data.sys= sys; + data.sys = sys; copy_v3_v3(data.start, sys->heat.verts[vertex]); if (sys->heat.root) /* bone */ closest_to_line_segment_v3(end, data.start, - sys->heat.root[source], sys->heat.tip[source]); + sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ copy_v3_v3(end, sys->heat.source[source]); @@ -499,7 +499,7 @@ static int heat_ray_source_visible(LaplacianSystem *sys, int vertex, int source) hit.index = -1; hit.dist = normalize_v3(data.vec); - visible= BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void*)&data) == -1; + visible = BLI_bvhtree_ray_cast(sys->heat.bvhtree, data.start, data.vec, 0.0f, &hit, bvh_callback, (void *)&data) == -1; return visible; } @@ -511,26 +511,26 @@ static float heat_source_distance(LaplacianSystem *sys, int vertex, int source) /* compute euclidian distance */ if (sys->heat.root) /* bone */ closest_to_line_segment_v3(closest, sys->heat.verts[vertex], - sys->heat.root[source], sys->heat.tip[source]); + sys->heat.root[source], sys->heat.tip[source]); else /* vertex */ copy_v3_v3(closest, sys->heat.source[source]); sub_v3_v3v3(d, sys->heat.verts[vertex], closest); - dist= normalize_v3(d); + dist = normalize_v3(d); /* if the vertex normal does not point along the bone, increase distance */ - cosine= dot_v3v3(d, sys->heat.vnors[vertex]); + cosine = dot_v3v3(d, sys->heat.vnors[vertex]); - return dist/(0.5f*(cosine + 1.001f)); + return dist / (0.5f * (cosine + 1.001f)); } static int heat_source_closest(LaplacianSystem *sys, int vertex, int source) { float dist; - dist= heat_source_distance(sys, vertex, source); + dist = heat_source_distance(sys, vertex, source); - if (dist <= sys->heat.mindist[vertex]*(1.0f + DISTANCE_EPSILON)) + if (dist <= sys->heat.mindist[vertex] * (1.0f + DISTANCE_EPSILON)) if (heat_ray_source_visible(sys, vertex, source)) return 1; @@ -542,34 +542,34 @@ static void heat_set_H(LaplacianSystem *sys, int vertex) float dist, mindist, h; int j, numclosest = 0; - mindist= 1e10; + mindist = 1e10; /* compute minimum distance */ - for (j=0; jheat.numsource; j++) { - dist= heat_source_distance(sys, vertex, j); + for (j = 0; j < sys->heat.numsource; j++) { + dist = heat_source_distance(sys, vertex, j); if (dist < mindist) - mindist= dist; + mindist = dist; } - sys->heat.mindist[vertex]= mindist; + sys->heat.mindist[vertex] = mindist; /* count number of sources with approximately this minimum distance */ - for (j=0; jheat.numsource; j++) + for (j = 0; j < sys->heat.numsource; j++) if (heat_source_closest(sys, vertex, j)) numclosest++; - sys->heat.p[vertex]= (numclosest > 0)? 1.0f/numclosest: 0.0f; + sys->heat.p[vertex] = (numclosest > 0) ? 1.0f / numclosest : 0.0f; /* compute H entry */ if (numclosest > 0) { - mindist= maxf(mindist, 1e-4f); - h= numclosest*C_WEIGHT/(mindist*mindist); + mindist = maxf(mindist, 1e-4f); + h = numclosest * C_WEIGHT / (mindist * mindist); } else - h= 0.0f; + h = 0.0f; - sys->heat.H[vertex]= h; + sys->heat.H[vertex] = h; } static void heat_calc_vnormals(LaplacianSystem *sys) @@ -577,12 +577,12 @@ static void heat_calc_vnormals(LaplacianSystem *sys) float fnor[3]; int a, v1, v2, v3, (*face)[3]; - sys->heat.vnors= MEM_callocN(sizeof(float)*3*sys->totvert, "HeatVNors"); + sys->heat.vnors = MEM_callocN(sizeof(float) * 3 * sys->totvert, "HeatVNors"); - for (a=0, face=sys->faces; atotface; a++, face++) { - v1= (*face)[0]; - v2= (*face)[1]; - v3= (*face)[2]; + for (a = 0, face = sys->faces; a < sys->totface; a++, face++) { + v1 = (*face)[0]; + v2 = (*face)[1]; + v3 = (*face)[2]; normal_tri_v3(fnor, sys->verts[v1], sys->verts[v2], sys->verts[v3]); @@ -591,27 +591,27 @@ static void heat_calc_vnormals(LaplacianSystem *sys) add_v3_v3(sys->heat.vnors[v3], fnor); } - for (a=0; atotvert; a++) + for (a = 0; a < sys->totvert; a++) normalize_v3(sys->heat.vnors[a]); } static void heat_laplacian_create(LaplacianSystem *sys) { MFace *mface = sys->heat.mface, *mf; - int totface= sys->heat.totface; - int totvert= sys->heat.totvert; + int totface = sys->heat.totface; + int totvert = sys->heat.totvert; int a; /* heat specific definitions */ - sys->heat.mindist= MEM_callocN(sizeof(float)*totvert, "HeatMinDist"); - sys->heat.H= MEM_callocN(sizeof(float)*totvert, "HeatH"); - sys->heat.p= MEM_callocN(sizeof(float)*totvert, "HeatP"); + sys->heat.mindist = MEM_callocN(sizeof(float) * totvert, "HeatMinDist"); + sys->heat.H = MEM_callocN(sizeof(float) * totvert, "HeatH"); + sys->heat.p = MEM_callocN(sizeof(float) * totvert, "HeatP"); /* add verts and faces to laplacian */ - for (a=0; aheat.verts[a], 0); - for (a=0, mf=mface; av1, mf->v2, mf->v3); if (mf->v4) laplacian_add_triangle(sys, mf->v1, mf->v3, mf->v4); @@ -620,7 +620,7 @@ static void heat_laplacian_create(LaplacianSystem *sys) /* for distance computation in set_H */ heat_calc_vnormals(sys); - for (a=0; amvert; - int use_vert_sel= FALSE; - int use_face_sel= FALSE; + int use_vert_sel = FALSE; + int use_face_sel = FALSE; - *err_str= NULL; + *err_str = NULL; /* count triangles and create mask */ - if ( (use_face_sel= (me->editflag & ME_EDIT_PAINT_MASK) != 0) || - (use_vert_sel= ((me->editflag & ME_EDIT_VERT_SEL) != 0))) + if ( (use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) || + (use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0))) { - mask= MEM_callocN(sizeof(int)*me->totvert, "heat_bone_weighting mask"); + mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask"); } - for (a = 0, mp=me->mpoly; a < me->totpoly; mp++, a++) { + for (a = 0, mp = me->mpoly; a < me->totpoly; mp++, a++) { /* (added selectedVerts content for vertex mask, they used to just equal 1) */ if (use_vert_sel) { for (j = 0, ml = me->mloop + mp->loopstart; j < mp->totloop; j++, ml++) { @@ -702,13 +702,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* create laplacian */ sys = laplacian_system_construct_begin(me->totvert, tottri, 1); - sys->heat.mface= me->mface; - sys->heat.totface= me->totface; - sys->heat.totvert= me->totvert; - sys->heat.verts= verts; - sys->heat.root= root; - sys->heat.tip= tip; - sys->heat.numsource= numsource; + sys->heat.mface = me->mface; + sys->heat.totface = me->totface; + sys->heat.totvert = me->totvert; + sys->heat.verts = verts; + sys->heat.root = root; + sys->heat.tip = tip; + sys->heat.numsource = numsource; heat_ray_tree_create(sys); heat_laplacian_create(sys); @@ -716,23 +716,23 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, laplacian_system_construct_end(sys); if (dgroupflip) { - vertsflipped = MEM_callocN(sizeof(int)*me->totvert, "vertsflipped"); - for (a=0; atotvert; a++) + vertsflipped = MEM_callocN(sizeof(int) * me->totvert, "vertsflipped"); + for (a = 0; a < me->totvert; a++) vertsflipped[a] = mesh_get_x_mirror_vert(ob, a); } /* compute weights per bone */ - for (j=0; jtotvert; a++) { + for (a = 0; a < me->totvert; a++) { if (mask && !mask[a]) continue; @@ -745,30 +745,30 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, /* fill right hand side */ laplacian_begin_solve(sys, -1); - for (a=0; atotvert; a++) + for (a = 0; a < me->totvert; a++) if (heat_source_closest(sys, a, j)) laplacian_add_right_hand_side(sys, a, - sys->heat.H[a]*sys->heat.p[a]); + sys->heat.H[a] * sys->heat.p[a]); /* solve */ if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for (a=0; atotvert; a++) { + for (a = 0; a < me->totvert; a++) { if (mask && !mask[a]) continue; - solution= laplacian_system_get_solution(a); + solution = laplacian_system_get_solution(a); if (bbone) { if (solution > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, solution, - WEIGHT_ADD); + WEIGHT_ADD); } else { - weight= heat_limit_weight(solution); + weight = heat_limit_weight(solution); if (weight > 0.0f) ED_vgroup_vert_add(ob, dgrouplist[j], a, weight, - WEIGHT_REPLACE); + WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgrouplist[j], a); } @@ -778,13 +778,13 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, if (bbone) { if (solution > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], - solution, WEIGHT_ADD); + solution, WEIGHT_ADD); } else { - weight= heat_limit_weight(solution); + weight = heat_limit_weight(solution); if (weight > 0.0f) ED_vgroup_vert_add(ob, dgroupflip[j], vertsflipped[a], - weight, WEIGHT_REPLACE); + weight, WEIGHT_REPLACE); else ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } @@ -792,24 +792,24 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource, } } else if (*err_str == NULL) { - *err_str= "Bone Heat Weighting: failed to find solution for one or more bones"; + *err_str = "Bone Heat Weighting: failed to find solution for one or more bones"; break; } /* remove too small vertex weights */ if (bbone && lastsegment) { - for (a=0; atotvert; a++) { + for (a = 0; a < me->totvert; a++) { if (mask && !mask[a]) continue; - weight= ED_vgroup_vert_weight(ob, dgrouplist[j], a); - weight= heat_limit_weight(weight); + weight = ED_vgroup_vert_weight(ob, dgrouplist[j], a); + weight = heat_limit_weight(weight); if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgrouplist[j], a); if (vertsflipped && dgroupflip[j] && vertsflipped[a] >= 0) { - weight= ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]); - weight= heat_limit_weight(weight); + weight = ED_vgroup_vert_weight(ob, dgroupflip[j], vertsflipped[a]); + weight = heat_limit_weight(weight); if (weight <= 0.0f) ED_vgroup_vert_remove(ob, dgroupflip[j], vertsflipped[a]); } @@ -848,10 +848,10 @@ static void rigid_add_half_edge_to_R(LaplacianSystem *sys, EditVert *v1, EditVer sub_v3_v3v3(e_, v1->co, v2->co); /* formula (5) */ - for (i=0; i<3; i++) { - sys->rigid.R[v1->tmp.l][i][0] += w*e[0]*e_[i]; - sys->rigid.R[v1->tmp.l][i][1] += w*e[1]*e_[i]; - sys->rigid.R[v1->tmp.l][i][2] += w*e[2]*e_[i]; + for (i = 0; i < 3; i++) { + sys->rigid.R[v1->tmp.l][i][0] += w * e[0] * e_[i]; + sys->rigid.R[v1->tmp.l][i][1] += w * e[1] * e_[i]; + sys->rigid.R[v1->tmp.l][i][2] += w * e[2] * e_[i]; } } @@ -897,7 +897,7 @@ static void rigid_add_edge_to_rhs(LaplacianSystem *sys, EditVert *v1, EditVert * void rigid_deform_iteration() { - LaplacianSystem *sys= RigidDeformSystem; + LaplacianSystem *sys = RigidDeformSystem; EditMesh *em; EditVert *eve; EditFace *efa; @@ -907,13 +907,13 @@ void rigid_deform_iteration() return; nlMakeCurrent(sys->context); - em= sys->rigid.mesh; + em = sys->rigid.mesh; /* compute R */ - memset(sys->rigid.R, 0, sizeof(float)*3*3*sys->totvert); - memset(sys->rigid.rhs, 0, sizeof(float)*3*sys->totvert); + memset(sys->rigid.R, 0, sizeof(float) * 3 * 3 * sys->totvert); + memset(sys->rigid.rhs, 0, sizeof(float) * 3 * sys->totvert); - for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a = 0, efa = em->faces.first; efa; efa = efa->next, a++) { rigid_add_edge_to_R(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_R(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_R(sys, efa->v3, efa->v1, sys->fweights[a][1]); @@ -926,13 +926,13 @@ void rigid_deform_iteration() } } - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) { rigid_orthogonalize_R(sys->rigid.R[a]); - eve->tmp.l= a; + eve->tmp.l = a; } /* compute right hand sides for solving */ - for (a=0, efa=em->faces.first; efa; efa=efa->next, a++) { + for (a = 0, efa = em->faces.first; efa; efa = efa->next, a++) { rigid_add_edge_to_rhs(sys, efa->v1, efa->v2, sys->fweights[a][2]); rigid_add_edge_to_rhs(sys, efa->v2, efa->v3, sys->fweights[a][0]); rigid_add_edge_to_rhs(sys, efa->v3, efa->v1, sys->fweights[a][1]); @@ -946,21 +946,21 @@ void rigid_deform_iteration() } /* solve for positions, for X, Y and Z separately */ - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { laplacian_begin_solve(sys, i); - for (a=0; atotvert; a++) + for (a = 0; a < sys->totvert; a++) if (!sys->vpinned[a]) laplacian_add_right_hand_side(sys, a, sys->rigid.rhs[a][i]); if (laplacian_system_solve(sys)) { - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) - eve->co[i]= laplacian_system_get_solution(a); + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) + eve->co[i] = laplacian_system_get_solution(a); } else { if (!sys->rigid.thrownerror) { error("RigidDeform: failed to find solution"); - sys->rigid.thrownerror= 1; + sys->rigid.thrownerror = 1; } break; } @@ -975,17 +975,17 @@ static void rigid_laplacian_create(LaplacianSystem *sys) int a; /* add verts and faces to laplacian */ - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) { + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) { laplacian_add_vertex(sys, eve->co, eve->pinned); - eve->tmp.l= a; + eve->tmp.l = a; } - for (efa=em->faces.first; efa; efa=efa->next) { + for (efa = em->faces.first; efa; efa = efa->next) { laplacian_add_triangle(sys, - efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l); + efa->v1->tmp.l, efa->v2->tmp.l, efa->v3->tmp.l); if (efa->v4) laplacian_add_triangle(sys, - efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l); + efa->v1->tmp.l, efa->v3->tmp.l, efa->v4->tmp.l); } } @@ -997,10 +997,10 @@ void rigid_deform_begin(EditMesh *em) int a, totvert, totface; /* count vertices, triangles */ - for (totvert=0, eve=em->verts.first; eve; eve=eve->next) + for (totvert = 0, eve = em->verts.first; eve; eve = eve->next) totvert++; - for (totface=0, efa=em->faces.first; efa; efa=efa->next) { + for (totface = 0, efa = em->faces.first; efa; efa = efa->next) { totface++; if (efa->v4) totface++; } @@ -1008,16 +1008,16 @@ void rigid_deform_begin(EditMesh *em) /* create laplacian */ sys = laplacian_system_construct_begin(totvert, totface, 0); - sys->rigid.mesh= em; - sys->rigid.R = MEM_callocN(sizeof(float)*3*3*totvert, "RigidDeformR"); - sys->rigid.rhs = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformRHS"); - sys->rigid.origco = MEM_callocN(sizeof(float)*3*totvert, "RigidDeformCo"); + sys->rigid.mesh = em; + sys->rigid.R = MEM_callocN(sizeof(float) * 3 * 3 * totvert, "RigidDeformR"); + sys->rigid.rhs = MEM_callocN(sizeof(float) * 3 * totvert, "RigidDeformRHS"); + sys->rigid.origco = MEM_callocN(sizeof(float) * 3 * totvert, "RigidDeformCo"); - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) copy_v3_v3(sys->rigid.origco[a], eve->co); - sys->areaweights= 0; - sys->storeweights= 1; + sys->areaweights = 0; + sys->storeweights = 1; rigid_laplacian_create(sys); @@ -1036,7 +1036,7 @@ void rigid_deform_end(int cancel) int a; if (cancel) - for (a=0, eve=em->verts.first; eve; eve=eve->next, a++) + for (a = 0, eve = em->verts.first; eve; eve = eve->next, a++) if (!eve->pinned) copy_v3_v3(eve->co, sys->rigid.origco[a]); @@ -1068,8 +1068,9 @@ void rigid_deform_end(int cancel) #define MESHDEFORM_MIN_INFLUENCE 0.0005f -static int MESHDEFORM_OFFSET[7][3] = - {{0, 0, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}}; +static int MESHDEFORM_OFFSET[7][3] = { + {0, 0, 0}, {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1} +}; typedef struct MDefBoundIsect { float co[3], uvw[4]; @@ -1154,7 +1155,7 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* calculate U parameter and test bounds */ u = dot_v3v3(tvec, pvec) * inv_det; - if (u < -EPSILON || u > 1.0f+EPSILON) + if (u < -EPSILON || u > 1.0f + EPSILON) return 0; /* prepare to test V parameter */ @@ -1162,16 +1163,16 @@ static int meshdeform_tri_intersect(float orig[3], float end[3], float vert0[3], /* calculate V parameter and test bounds */ v = dot_v3v3(dir, qvec) * inv_det; - if (v < -EPSILON || u + v > 1.0f+EPSILON) + if (v < -EPSILON || u + v > 1.0f + EPSILON) return 0; - isectco[0]= (1.0f - u - v)*vert0[0] + u*vert1[0] + v*vert2[0]; - isectco[1]= (1.0f - u - v)*vert0[1] + u*vert1[1] + v*vert2[1]; - isectco[2]= (1.0f - u - v)*vert0[2] + u*vert1[2] + v*vert2[2]; + isectco[0] = (1.0f - u - v) * vert0[0] + u * vert1[0] + v * vert2[0]; + isectco[1] = (1.0f - u - v) * vert0[1] + u * vert1[1] + v * vert2[1]; + isectco[2] = (1.0f - u - v) * vert0[2] + u * vert1[2] + v * vert2[2]; - uvw[0]= 1.0f - u - v; - uvw[1]= u; - uvw[2]= v; + uvw[0] = 1.0f - u - v; + uvw[1] = u; + uvw[2] = v; /* check if it is within the length of the line segment */ sub_v3_v3v3(isectdir, isectco, orig); @@ -1189,16 +1190,16 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) { MFace *mface; float face[4][3], co[3], uvw[3], len, nor[3], end[3]; - int f, hit, is= 0, totface; + int f, hit, is = 0, totface; - isec->labda= 1e10; + isec->labda = 1e10; - mface= mdb->cagedm->getTessFaceArray(mdb->cagedm); - totface= mdb->cagedm->getNumTessFaces(mdb->cagedm); + mface = mdb->cagedm->getTessFaceArray(mdb->cagedm); + totface = mdb->cagedm->getNumTessFaces(mdb->cagedm); add_v3_v3v3(end, isec->start, isec->vec); - for (f=0; fcagecos[mface->v1]); copy_v3_v3(face[1], mdb->cagecos[mface->v2]); copy_v3_v3(face[2], mdb->cagecos[mface->v3]); @@ -1211,22 +1212,22 @@ static int meshdeform_intersect(MeshDeformBind *mdb, MeshDeformIsect *isec) normal_tri_v3(nor, face[0], face[1], face[2]); } else { - hit= meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw); + hit = meshdeform_tri_intersect(isec->start, end, face[0], face[2], face[3], co, uvw); normal_tri_v3(nor, face[0], face[2], face[3]); } } else { - hit= meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); + hit = meshdeform_tri_intersect(isec->start, end, face[0], face[1], face[2], co, uvw); normal_tri_v3(nor, face[0], face[1], face[2]); } if (hit) { - len= len_v3v3(isec->start, co)/len_v3v3(isec->start, end); + len = len_v3v3(isec->start, co) / len_v3v3(isec->start, end); if (len < isec->labda) { - isec->labda= len; + isec->labda = len; isec->face = mface; - isec->isect= (dot_v3v3(isec->vec, nor) <= 0.0f); - is= 1; + isec->isect = (dot_v3v3(isec->vec, nor) <= 0.0f); + is = 1; } } } @@ -1241,42 +1242,42 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, float float (*cagecos)[3]; MFace *mface; float vert[4][3], len, end[3]; - static float epsilon[3]= {0, 0, 0}; //1e-4, 1e-4, 1e-4}; + static float epsilon[3] = {0, 0, 0}; //1e-4, 1e-4, 1e-4}; /* setup isec */ memset(&isec, 0, sizeof(isec)); - isec.labda= 1e10f; + isec.labda = 1e10f; add_v3_v3v3(isec.start, co1, epsilon); add_v3_v3v3(end, co2, epsilon); sub_v3_v3v3(isec.vec, end, isec.start); if (meshdeform_intersect(mdb, &isec)) { - len= isec.labda; - mface=(MFace*)isec.face; + len = isec.labda; + mface = (MFace *)isec.face; /* create MDefBoundIsect */ - isect= BLI_memarena_alloc(mdb->memarena, sizeof(*isect)); + isect = BLI_memarena_alloc(mdb->memarena, sizeof(*isect)); /* compute intersection coordinate */ - isect->co[0]= co1[0] + isec.vec[0]*len; - isect->co[1]= co1[1] + isec.vec[1]*len; - isect->co[2]= co1[2] + isec.vec[2]*len; + isect->co[0] = co1[0] + isec.vec[0] * len; + isect->co[1] = co1[1] + isec.vec[1] * len; + isect->co[2] = co1[2] + isec.vec[2] * len; - isect->len= len_v3v3(co1, isect->co); + isect->len = len_v3v3(co1, isect->co); if (isect->len < MESHDEFORM_LEN_THRESHOLD) - isect->len= MESHDEFORM_LEN_THRESHOLD; + isect->len = MESHDEFORM_LEN_THRESHOLD; - isect->v[0]= mface->v1; - isect->v[1]= mface->v2; - isect->v[2]= mface->v3; - isect->v[3]= mface->v4; - isect->nvert= (mface->v4)? 4: 3; + isect->v[0] = mface->v1; + isect->v[1] = mface->v2; + isect->v[2] = mface->v3; + isect->v[3] = mface->v4; + isect->nvert = (mface->v4) ? 4 : 3; - isect->facing= isec.isect; + isect->facing = isec.isect; /* compute mean value coordinates for interpolation */ - cagecos= mdb->cagecos; + cagecos = mdb->cagecos; copy_v3_v3(vert[0], cagecos[mface->v1]); copy_v3_v3(vert[1], cagecos[mface->v2]); copy_v3_v3(vert[2], cagecos[mface->v3]); @@ -1295,10 +1296,10 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) float outside[3], start[3], dir[3]; int i; - for (i=1; i<=6; i++) { - outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f)*MESHDEFORM_OFFSET[i][0]; - outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f)*MESHDEFORM_OFFSET[i][1]; - outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f)*MESHDEFORM_OFFSET[i][2]; + for (i = 1; i <= 6; i++) { + outside[0] = co[0] + (mdb->max[0] - mdb->min[0] + 1.0f) * MESHDEFORM_OFFSET[i][0]; + outside[1] = co[1] + (mdb->max[1] - mdb->min[1] + 1.0f) * MESHDEFORM_OFFSET[i][1]; + outside[2] = co[2] + (mdb->max[2] - mdb->min[2] + 1.0f) * MESHDEFORM_OFFSET[i][2]; copy_v3_v3(start, co); sub_v3_v3v3(dir, outside, start); @@ -1316,7 +1317,7 @@ static int meshdeform_inside_cage(MeshDeformBind *mdb, float *co) static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) { - int size= mdb->size; + int size = mdb->size; x += MESHDEFORM_OFFSET[n][0]; y += MESHDEFORM_OFFSET[n][1]; @@ -1329,7 +1330,7 @@ static int meshdeform_index(MeshDeformBind *mdb, int x, int y, int z, int n) if (z < 0 || z >= mdb->size) return -1; - return x + y*size + z*size*size; + return x + y * size + z * size * size; } static void meshdeform_cell_center(MeshDeformBind *mdb, int x, int y, int z, int n, float *center) @@ -1338,9 +1339,9 @@ static void meshdeform_cell_center(MeshDeformBind *mdb, int x, int y, int z, int y += MESHDEFORM_OFFSET[n][1]; z += MESHDEFORM_OFFSET[n][2]; - center[0]= mdb->min[0] + x*mdb->width[0] + mdb->halfwidth[0]; - center[1]= mdb->min[1] + y*mdb->width[1] + mdb->halfwidth[1]; - center[2]= mdb->min[2] + z*mdb->width[2] + mdb->halfwidth[2]; + center[0] = mdb->min[0] + x * mdb->width[0] + mdb->halfwidth[0]; + center[1] = mdb->min[1] + y * mdb->width[1] + mdb->halfwidth[1]; + center[2] = mdb->min[2] + z * mdb->width[2] + mdb->halfwidth[2]; } static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int z) @@ -1349,72 +1350,72 @@ static void meshdeform_add_intersections(MeshDeformBind *mdb, int x, int y, int float center[3], ncenter[3]; int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); meshdeform_cell_center(mdb, x, y, z, 0, center); /* check each outgoing edge for intersection */ - for (i=1; i<=6; i++) { + for (i = 1; i <= 6; i++) { if (meshdeform_index(mdb, x, y, z, i) == -1) continue; meshdeform_cell_center(mdb, x, y, z, i, ncenter); - isect= meshdeform_ray_tree_intersect(mdb, center, ncenter); + isect = meshdeform_ray_tree_intersect(mdb, center, ncenter); if (isect) { - mdb->boundisect[a][i-1]= isect; - mdb->tag[a]= MESHDEFORM_TAG_BOUNDARY; + mdb->boundisect[a][i - 1] = isect; + mdb->tag[a] = MESHDEFORM_TAG_BOUNDARY; } } } static void meshdeform_bind_floodfill(MeshDeformBind *mdb) { - int *stack, *tag= mdb->tag; - int a, b, i, xyz[3], stacksize, size= mdb->size; + int *stack, *tag = mdb->tag; + int a, b, i, xyz[3], stacksize, size = mdb->size; - stack= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformBindStack"); + stack = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindStack"); /* we know lower left corner is EXTERIOR because of padding */ - tag[0]= MESHDEFORM_TAG_EXTERIOR; - stack[0]= 0; - stacksize= 1; + tag[0] = MESHDEFORM_TAG_EXTERIOR; + stack[0] = 0; + stacksize = 1; /* floodfill exterior tag */ while (stacksize > 0) { - a= stack[--stacksize]; + a = stack[--stacksize]; - xyz[2]= a/(size*size); - xyz[1]= (a - xyz[2]*size*size)/size; - xyz[0]= a - xyz[1]*size - xyz[2]*size*size; + xyz[2] = a / (size * size); + xyz[1] = (a - xyz[2] * size * size) / size; + xyz[0] = a - xyz[1] * size - xyz[2] * size * size; - for (i=1; i<=6; i++) { - b= meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i); + for (i = 1; i <= 6; i++) { + b = meshdeform_index(mdb, xyz[0], xyz[1], xyz[2], i); if (b != -1) { if (tag[b] == MESHDEFORM_TAG_UNTYPED || - (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i-1])) { - tag[b]= MESHDEFORM_TAG_EXTERIOR; - stack[stacksize++]= b; + (tag[b] == MESHDEFORM_TAG_BOUNDARY && !mdb->boundisect[a][i - 1])) { + tag[b] = MESHDEFORM_TAG_EXTERIOR; + stack[stacksize++] = b; } } } } /* other cells are interior */ - for (a=0; asemibound[a]) @@ -1432,7 +1433,7 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect { int a; - for (a=0; anvert; a++) + for (a = 0; a < isect->nvert; a++) if (isect->v[a] == cagevert) return isect->uvw[a]; @@ -1441,32 +1442,32 @@ static float meshdeform_boundary_phi(MeshDeformBind *UNUSED(mdb), MDefBoundIsect static float meshdeform_interp_w(MeshDeformBind *mdb, float *gridvec, float *UNUSED(vec), int UNUSED(cagevert)) { - float dvec[3], ivec[3], wx, wy, wz, result=0.0f; - float weight, totweight= 0.0f; + float dvec[3], ivec[3], wx, wy, wz, result = 0.0f; + float weight, totweight = 0.0f; int i, a, x, y, z; - for (i=0; i<3; i++) { - ivec[i]= (int)gridvec[i]; - dvec[i]= gridvec[i] - ivec[i]; + for (i = 0; i < 3; i++) { + ivec[i] = (int)gridvec[i]; + dvec[i] = gridvec[i] - ivec[i]; } - for (i=0; i<8; i++) { - if (i & 1) { x= ivec[0]+1; wx= dvec[0]; } - else { x= ivec[0]; wx= 1.0f-dvec[0]; } + for (i = 0; i < 8; i++) { + if (i & 1) { x = ivec[0] + 1; wx = dvec[0]; } + else { x = ivec[0]; wx = 1.0f - dvec[0]; } - if (i & 2) { y= ivec[1]+1; wy= dvec[1]; } - else { y= ivec[1]; wy= 1.0f-dvec[1]; } + if (i & 2) { y = ivec[1] + 1; wy = dvec[1]; } + else { y = ivec[1]; wy = 1.0f - dvec[1]; } - if (i & 4) { z= ivec[2]+1; wz= dvec[2]; } - else { z= ivec[2]; wz= 1.0f-dvec[2]; } + if (i & 4) { z = ivec[2] + 1; wz = dvec[2]; } + else { z = ivec[2]; wz = 1.0f - dvec[2]; } - CLAMP(x, 0, mdb->size-1); - CLAMP(y, 0, mdb->size-1); - CLAMP(z, 0, mdb->size-1); + CLAMP(x, 0, mdb->size - 1); + CLAMP(y, 0, mdb->size - 1); + CLAMP(z, 0, mdb->size - 1); - a= meshdeform_index(mdb, x, y, z, 0); - weight= wx*wy*wz; - result += weight*mdb->phi[a]; + a = meshdeform_index(mdb, x, y, z, 0); + weight = wx * wy * wz; + result += weight * mdb->phi[a]; totweight += weight; } @@ -1480,33 +1481,33 @@ static void meshdeform_check_semibound(MeshDeformBind *mdb, int x, int y, int z) { int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[a] != MESHDEFORM_TAG_EXTERIOR) return; - for (i=1; i<=6; i++) - if (mdb->boundisect[a][i-1]) - mdb->semibound[a]= 1; + for (i = 1; i <= 6; i++) + if (mdb->boundisect[a][i - 1]) + mdb->semibound[a] = 1; } static float meshdeform_boundary_total_weight(MeshDeformBind *mdb, int x, int y, int z) { - float weight, totweight= 0.0f; + float weight, totweight = 0.0f; int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); /* count weight for neighbor cells */ - for (i=1; i<=6; i++) { + for (i = 1; i <= 6; i++) { if (meshdeform_index(mdb, x, y, z, i) == -1) continue; - if (mdb->boundisect[a][i-1]) - weight= 1.0f/mdb->boundisect[a][i-1]->len; + if (mdb->boundisect[a][i - 1]) + weight = 1.0f / mdb->boundisect[a][i - 1]->len; else if (!mdb->semibound[a]) - weight= 1.0f/mdb->width[0]; + weight = 1.0f / mdb->width[0]; else - weight= 0.0f; + weight = 0.0f; totweight += weight; } @@ -1520,21 +1521,21 @@ static void meshdeform_matrix_add_cell(MeshDeformBind *mdb, int x, int y, int z) float weight, totweight; int i, a, acenter; - acenter= meshdeform_index(mdb, x, y, z, 0); + acenter = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[acenter], 1.0f); - totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for (i=1; i<=6; i++) { - a= meshdeform_index(mdb, x, y, z, i); + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); + for (i = 1; i <= 6; i++) { + a = meshdeform_index(mdb, x, y, z, i); if (a == -1 || mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) continue; - isect= mdb->boundisect[acenter][i-1]; + isect = mdb->boundisect[acenter][i - 1]; if (!isect) { - weight= (1.0f/mdb->width[0])/totweight; + weight = (1.0f / mdb->width[0]) / totweight; nlMatrixAdd(mdb->varidx[acenter], mdb->varidx[a], -weight); } } @@ -1546,21 +1547,21 @@ static void meshdeform_matrix_add_rhs(MeshDeformBind *mdb, int x, int y, int z, float rhs, weight, totweight; int i, a, acenter; - acenter= meshdeform_index(mdb, x, y, z, 0); + acenter = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[acenter] == MESHDEFORM_TAG_EXTERIOR) return; - totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for (i=1; i<=6; i++) { - a= meshdeform_index(mdb, x, y, z, i); + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); + for (i = 1; i <= 6; i++) { + a = meshdeform_index(mdb, x, y, z, i); if (a == -1) continue; - isect= mdb->boundisect[acenter][i-1]; + isect = mdb->boundisect[acenter][i - 1]; if (isect) { - weight= (1.0f/isect->len)/totweight; - rhs= weight*meshdeform_boundary_phi(mdb, isect, cagevert); + weight = (1.0f / isect->len) / totweight; + rhs = weight * meshdeform_boundary_phi(mdb, isect, cagevert); nlRightHandSideAdd(0, mdb->varidx[acenter], rhs); } } @@ -1572,19 +1573,19 @@ static void meshdeform_matrix_add_semibound_phi(MeshDeformBind *mdb, int x, int float rhs, weight, totweight; int i, a; - a= meshdeform_index(mdb, x, y, z, 0); + a = meshdeform_index(mdb, x, y, z, 0); if (!mdb->semibound[a]) return; - mdb->phi[a]= 0.0f; + mdb->phi[a] = 0.0f; - totweight= meshdeform_boundary_total_weight(mdb, x, y, z); - for (i=1; i<=6; i++) { - isect= mdb->boundisect[a][i-1]; + totweight = meshdeform_boundary_total_weight(mdb, x, y, z); + for (i = 1; i <= 6; i++) { + isect = mdb->boundisect[a][i - 1]; if (isect) { - weight= (1.0f/isect->len)/totweight; - rhs= weight*meshdeform_boundary_phi(mdb, isect, cagevert); + weight = (1.0f / isect->len) / totweight; + rhs = weight * meshdeform_boundary_phi(mdb, isect, cagevert); mdb->phi[a] += rhs; } } @@ -1595,14 +1596,14 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y float phi, totweight; int i, a, acenter; - acenter= meshdeform_index(mdb, x, y, z, 0); + acenter = meshdeform_index(mdb, x, y, z, 0); if (mdb->tag[acenter] != MESHDEFORM_TAG_EXTERIOR || mdb->semibound[acenter]) return; - phi= 0.0f; - totweight= 0.0f; - for (i=1; i<=6; i++) { - a= meshdeform_index(mdb, x, y, z, i); + phi = 0.0f; + totweight = 0.0f; + for (i = 1; i <= 6; i++) { + a = meshdeform_index(mdb, x, y, z, i); if (a != -1 && mdb->semibound[a]) { phi += mdb->phi[a]; @@ -1611,7 +1612,7 @@ static void meshdeform_matrix_add_exterior_phi(MeshDeformBind *mdb, int x, int y } if (totweight != 0.0f) - mdb->phi[acenter]= phi/totweight; + mdb->phi[acenter] = phi / totweight; } static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind *mdb) @@ -1622,9 +1623,9 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind char message[256]; /* setup variable indices */ - mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx"); - for (a=0, totvar=0; asize3; a++) - mdb->varidx[a]= (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR)? -1: totvar++; + mdb->varidx = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformDSvaridx"); + for (a = 0, totvar = 0; a < mdb->size3; a++) + mdb->varidx[a] = (mdb->tag[a] == MESHDEFORM_TAG_EXTERIOR) ? -1 : totvar++; if (totvar == 0) { MEM_freeN(mdb->varidx); @@ -1635,7 +1636,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind /* setup opennl solver */ nlNewContext(); - context= nlGetCurrent(); + context = nlGetCurrent(); nlSolverParameteri(NL_NB_VARIABLES, totvar); nlSolverParameteri(NL_NB_ROWS, totvar); @@ -1645,22 +1646,22 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind nlBegin(NL_MATRIX); /* build matrix */ - for (z=0; zsize; z++) - for (y=0; ysize; y++) - for (x=0; xsize; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_cell(mdb, x, y, z); /* solve for each cage vert */ - for (a=0; atotcagevert; a++) { + for (a = 0; a < mdb->totcagevert; a++) { if (a != 0) { nlBegin(NL_SYSTEM); nlBegin(NL_MATRIX); } /* fill in right hand side and solve */ - for (z=0; zsize; z++) - for (y=0; ysize; y++) - for (x=0; xsize; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_rhs(mdb, x, y, z, a); nlEnd(NL_MATRIX); @@ -1671,32 +1672,32 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind #endif if (nlSolveAdvanced(NULL, NL_TRUE)) { - for (z=0; zsize; z++) - for (y=0; ysize; y++) - for (x=0; xsize; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_semibound_phi(mdb, x, y, z, a); - for (z=0; zsize; z++) - for (y=0; ysize; y++) - for (x=0; xsize; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_matrix_add_exterior_phi(mdb, x, y, z, a); - for (b=0; bsize3; b++) { + for (b = 0; b < mdb->size3; b++) { if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) - mdb->phi[b]= nlGetVariable(0, mdb->varidx[b]); + mdb->phi[b] = nlGetVariable(0, mdb->varidx[b]); mdb->totalphi[b] += mdb->phi[b]; } if (mdb->weights) { /* static bind : compute weights for each vertex */ - for (b=0; btotvert; b++) { + for (b = 0; b < mdb->totvert; b++) { if (mdb->inside[b]) { copy_v3_v3(vec, mdb->vertexcos[b]); - gridvec[0]= (vec[0] - mdb->min[0] - mdb->halfwidth[0])/mdb->width[0]; - gridvec[1]= (vec[1] - mdb->min[1] - mdb->halfwidth[1])/mdb->width[1]; - gridvec[2]= (vec[2] - mdb->min[2] - mdb->halfwidth[2])/mdb->width[2]; + gridvec[0] = (vec[0] - mdb->min[0] - mdb->halfwidth[0]) / mdb->width[0]; + gridvec[1] = (vec[1] - mdb->min[1] - mdb->halfwidth[1]) / mdb->width[1]; + gridvec[2] = (vec[2] - mdb->min[2] - mdb->halfwidth[2]) / mdb->width[2]; - mdb->weights[b*mdb->totcagevert + a]= meshdeform_interp_w(mdb, gridvec, vec, a); + mdb->weights[b * mdb->totcagevert + a] = meshdeform_interp_w(mdb, gridvec, vec, a); } } } @@ -1704,13 +1705,13 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind MDefBindInfluence *inf; /* dynamic bind */ - for (b=0; bsize3; b++) { + for (b = 0; b < mdb->size3; b++) { if (mdb->phi[b] >= MESHDEFORM_MIN_INFLUENCE) { - inf= BLI_memarena_alloc(mdb->memarena, sizeof(*inf)); - inf->vertex= a; - inf->weight= mdb->phi[b]; - inf->next= mdb->dyngrid[b]; - mdb->dyngrid[b]= inf; + inf = BLI_memarena_alloc(mdb->memarena, sizeof(*inf)); + inf->vertex = a; + inf->weight = mdb->phi[b]; + inf->next = mdb->dyngrid[b]; + mdb->dyngrid[b] = inf; } } } @@ -1721,17 +1722,17 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind break; } - BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a+1, mdb->totcagevert); - progress_bar((float)(a+1)/(float)(mdb->totcagevert), message); + BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d |||", a + 1, mdb->totcagevert); + progress_bar((float)(a + 1) / (float)(mdb->totcagevert), message); } #if 0 /* sanity check */ - for (b=0; bsize3; b++) + for (b = 0; b < mdb->size3; b++) if (mdb->tag[b] != MESHDEFORM_TAG_EXTERIOR) if (fabs(mdb->totalphi[b] - 1.0f) > 1e-4) printf("totalphi deficiency [%s|%d] %d: %.10f\n", - (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR)? "interior": "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); + (mdb->tag[b] == MESHDEFORM_TAG_INTERIOR) ? "interior" : "boundary", mdb->semibound[b], mdb->varidx[b], mdb->totalphi[b]); #endif /* free */ @@ -1751,78 +1752,78 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* compute bounding box of the cage mesh */ INIT_MINMAX(mdb->min, mdb->max); - for (a=0; atotcagevert; a++) + for (a = 0; a < mdb->totcagevert; a++) DO_MINMAX(mdb->cagecos[a], mdb->min, mdb->max); /* allocate memory */ - mdb->size= (2<<(mmd->gridsize-1)) + 2; - mdb->size3= mdb->size*mdb->size*mdb->size; - mdb->tag= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformBindTag"); - mdb->phi= MEM_callocN(sizeof(float)*mdb->size3, "MeshDeformBindPhi"); - mdb->totalphi= MEM_callocN(sizeof(float)*mdb->size3, "MeshDeformBindTotalPhi"); - mdb->boundisect= MEM_callocN(sizeof(*mdb->boundisect)*mdb->size3, "MDefBoundIsect"); - mdb->semibound= MEM_callocN(sizeof(int)*mdb->size3, "MDefSemiBound"); + mdb->size = (2 << (mmd->gridsize - 1)) + 2; + mdb->size3 = mdb->size * mdb->size * mdb->size; + mdb->tag = MEM_callocN(sizeof(int) * mdb->size3, "MeshDeformBindTag"); + mdb->phi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindPhi"); + mdb->totalphi = MEM_callocN(sizeof(float) * mdb->size3, "MeshDeformBindTotalPhi"); + mdb->boundisect = MEM_callocN(sizeof(*mdb->boundisect) * mdb->size3, "MDefBoundIsect"); + mdb->semibound = MEM_callocN(sizeof(int) * mdb->size3, "MDefSemiBound"); - mdb->inside= MEM_callocN(sizeof(int)*mdb->totvert, "MDefInside"); + mdb->inside = MEM_callocN(sizeof(int) * mdb->totvert, "MDefInside"); if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) - mdb->dyngrid= MEM_callocN(sizeof(MDefBindInfluence*)*mdb->size3, "MDefDynGrid"); + mdb->dyngrid = MEM_callocN(sizeof(MDefBindInfluence *) * mdb->size3, "MDefDynGrid"); else - mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); + mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights"); - mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); + mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); BLI_memarena_use_calloc(mdb->memarena); /* make bounding box equal size in all directions, add padding, and compute * width of the cells */ maxwidth = -1.0f; - for (a=0; a<3; a++) - if (mdb->max[a]-mdb->min[a] > maxwidth) - maxwidth= mdb->max[a]-mdb->min[a]; + for (a = 0; a < 3; a++) + if (mdb->max[a] - mdb->min[a] > maxwidth) + maxwidth = mdb->max[a] - mdb->min[a]; - for (a=0; a<3; a++) { - center[a]= (mdb->min[a]+mdb->max[a])*0.5f; - mdb->min[a]= center[a] - maxwidth*0.5f; - mdb->max[a]= center[a] + maxwidth*0.5f; + for (a = 0; a < 3; a++) { + center[a] = (mdb->min[a] + mdb->max[a]) * 0.5f; + mdb->min[a] = center[a] - maxwidth * 0.5f; + mdb->max[a] = center[a] + maxwidth * 0.5f; - mdb->width[a]= (mdb->max[a]-mdb->min[a])/(mdb->size-4); - mdb->min[a] -= 2.1f*mdb->width[a]; - mdb->max[a] += 2.1f*mdb->width[a]; + mdb->width[a] = (mdb->max[a] - mdb->min[a]) / (mdb->size - 4); + mdb->min[a] -= 2.1f * mdb->width[a]; + mdb->max[a] += 2.1f * mdb->width[a]; - mdb->width[a]= (mdb->max[a]-mdb->min[a])/mdb->size; - mdb->halfwidth[a]= mdb->width[a]*0.5f; + mdb->width[a] = (mdb->max[a] - mdb->min[a]) / mdb->size; + mdb->halfwidth[a] = mdb->width[a] * 0.5f; } progress_bar(0, "Setting up mesh deform system"); - totinside= 0; - for (a=0; atotvert; a++) { + totinside = 0; + for (a = 0; a < mdb->totvert; a++) { copy_v3_v3(vec, mdb->vertexcos[a]); - mdb->inside[a]= meshdeform_inside_cage(mdb, vec); + mdb->inside[a] = meshdeform_inside_cage(mdb, vec); if (mdb->inside[a]) totinside++; } /* free temporary MDefBoundIsects */ BLI_memarena_free(mdb->memarena); - mdb->memarena= BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); + mdb->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, "harmonic coords arena"); /* start with all cells untyped */ - for (a=0; asize3; a++) - mdb->tag[a]= MESHDEFORM_TAG_UNTYPED; + for (a = 0; a < mdb->size3; a++) + mdb->tag[a] = MESHDEFORM_TAG_UNTYPED; /* detect intersections and tag boundary cells */ - for (z=0; zsize; z++) - for (y=0; ysize; y++) - for (x=0; xsize; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_add_intersections(mdb, x, y, z); /* compute exterior and interior tags */ meshdeform_bind_floodfill(mdb); - for (z=0; zsize; z++) - for (y=0; ysize; y++) - for (x=0; xsize; x++) + for (z = 0; z < mdb->size; z++) + for (y = 0; y < mdb->size; y++) + for (x = 0; x < mdb->size; x++) meshdeform_check_semibound(mdb, x, y, z); /* solve */ @@ -1830,45 +1831,45 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa /* assign results */ if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { - mmd->totinfluence= 0; - for (a=0; asize3; a++) - for (inf=mdb->dyngrid[a]; inf; inf=inf->next) + mmd->totinfluence = 0; + for (a = 0; a < mdb->size3; a++) + for (inf = mdb->dyngrid[a]; inf; inf = inf->next) mmd->totinfluence++; /* convert MDefBindInfluences to smaller MDefInfluences */ - mmd->dyngrid= MEM_callocN(sizeof(MDefCell)*mdb->size3, "MDefDynGrid"); - mmd->dyninfluences= MEM_callocN(sizeof(MDefInfluence)*mmd->totinfluence, "MDefInfluence"); - offset= 0; - for (a=0; asize3; a++) { - cell= &mmd->dyngrid[a]; - cell->offset= offset; + mmd->dyngrid = MEM_callocN(sizeof(MDefCell) * mdb->size3, "MDefDynGrid"); + mmd->dyninfluences = MEM_callocN(sizeof(MDefInfluence) * mmd->totinfluence, "MDefInfluence"); + offset = 0; + for (a = 0; a < mdb->size3; a++) { + cell = &mmd->dyngrid[a]; + cell->offset = offset; - totweight= 0.0f; - mdinf= mmd->dyninfluences + cell->offset; - for (inf=mdb->dyngrid[a]; inf; inf=inf->next, mdinf++) { - mdinf->weight= inf->weight; - mdinf->vertex= inf->vertex; + totweight = 0.0f; + mdinf = mmd->dyninfluences + cell->offset; + for (inf = mdb->dyngrid[a]; inf; inf = inf->next, mdinf++) { + mdinf->weight = inf->weight; + mdinf->vertex = inf->vertex; totweight += mdinf->weight; cell->totinfluence++; } if (totweight > 0.0f) { - mdinf= mmd->dyninfluences + cell->offset; - for (b=0; btotinfluence; b++, mdinf++) + mdinf = mmd->dyninfluences + cell->offset; + for (b = 0; b < cell->totinfluence; b++, mdinf++) mdinf->weight /= totweight; } offset += cell->totinfluence; } - mmd->dynverts= mdb->inside; - mmd->dyngridsize= mdb->size; + mmd->dynverts = mdb->inside; + mmd->dyngridsize = mdb->size; copy_v3_v3(mmd->dyncellmin, mdb->min); - mmd->dyncellwidth= mdb->width[0]; + mmd->dyncellwidth = mdb->width[0]; MEM_freeN(mdb->dyngrid); } else { - mmd->bindweights= mdb->weights; + mmd->bindweights = mdb->weights; MEM_freeN(mdb->inside); } @@ -1884,16 +1885,16 @@ static void harmonic_coordinates_bind(Scene *UNUSED(scene), MeshDeformModifierDa static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifierData *mmd, MeshDeformBind *mdb) { LaplacianSystem *sys; - MFace *mface= dm->getTessFaceArray(dm), *mf; - int totvert= dm->getNumVerts(dm); - int totface= dm->getNumTessFaces(dm); + MFace *mface = dm->getTessFaceArray(dm), *mf; + int totvert = dm->getNumVerts(dm); + int totface = dm->getNumTessFaces(dm); float solution, weight; int a, tottri, j, thrownerror = 0; - mdb->weights= MEM_callocN(sizeof(float)*mdb->totvert*mdb->totcagevert, "MDefWeights"); + mdb->weights = MEM_callocN(sizeof(float) * mdb->totvert * mdb->totcagevert, "MDefWeights"); /* count triangles */ - for (tottri=0, a=0, mf=mface; av4) tottri++; } @@ -1901,12 +1902,12 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie /* create laplacian */ sys = laplacian_system_construct_begin(totvert, tottri, 1); - sys->heat.mface= mface; - sys->heat.totface= totface; - sys->heat.totvert= totvert; - sys->heat.verts= mdb->vertexcos; + sys->heat.mface = mface; + sys->heat.totface = totface; + sys->heat.totvert = totvert; + sys->heat.verts = mdb->vertexcos; sys->heat.source = mdb->cagecos; - sys->heat.numsource= mdb->totcagevert; + sys->heat.numsource = mdb->totcagevert; heat_ray_tree_create(sys); heat_laplacian_create(sys); @@ -1914,30 +1915,30 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie laplacian_system_construct_end(sys); /* compute weights per bone */ - for (j=0; jtotcagevert; j++) { + for (j = 0; j < mdb->totcagevert; j++) { /* fill right hand side */ laplacian_begin_solve(sys, -1); - for (a=0; aheat.H[a]*sys->heat.p[a]); + sys->heat.H[a] * sys->heat.p[a]); /* solve */ if (laplacian_system_solve(sys)) { /* load solution into vertex groups */ - for (a=0; a 0.0f) - mdb->weights[a*mdb->totcagevert + j] = weight; + mdb->weights[a * mdb->totcagevert + j] = weight; } } else if (!thrownerror) { error("Mesh Deform Heat Weighting:" - " failed to find solution for one or more vertices"); - thrownerror= 1; + " failed to find solution for one or more vertices"); + thrownerror = 1; break; } } @@ -1946,7 +1947,7 @@ static void heat_weighting_bind(Scene *scene, DerivedMesh *dm, MeshDeformModifie heat_system_free(sys); laplacian_system_delete(sys); - mmd->bindweights= mdb->weights; + mmd->bindweights = mdb->weights; } #endif @@ -1962,19 +1963,19 @@ void mesh_deform_bind(Scene *scene, MeshDeformModifierData *mmd, float *vertexco memset(&mdb, 0, sizeof(MeshDeformBind)); /* get mesh and cage mesh */ - mdb.vertexcos= MEM_callocN(sizeof(float)*3*totvert, "MeshDeformCos"); - mdb.totvert= totvert; + mdb.vertexcos = MEM_callocN(sizeof(float) * 3 * totvert, "MeshDeformCos"); + mdb.totvert = totvert; - mdb.cagedm= mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); - mdb.totcagevert= mdb.cagedm->getNumVerts(mdb.cagedm); - mdb.cagecos= MEM_callocN(sizeof(*mdb.cagecos)*mdb.totcagevert, "MeshDeformBindCos"); + mdb.cagedm = mesh_create_derived_no_deform(scene, mmd->object, NULL, CD_MASK_BAREMESH); + mdb.totcagevert = mdb.cagedm->getNumVerts(mdb.cagedm); + mdb.cagecos = MEM_callocN(sizeof(*mdb.cagecos) * mdb.totcagevert, "MeshDeformBindCos"); copy_m4_m4(mdb.cagemat, cagemat); - mvert= mdb.cagedm->getVertArray(mdb.cagedm); - for (a=0; agetVertArray(mdb.cagedm); + for (a = 0; a < mdb.totcagevert; a++) copy_v3_v3(mdb.cagecos[a], mvert[a].co); - for (a=0; abindcagecos= (float*)mdb.cagecos; - mmd->totvert= mdb.totvert; - mmd->totcagevert= mdb.totcagevert; + mmd->bindcagecos = (float *)mdb.cagecos; + mmd->totvert = mdb.totvert; + mmd->totcagevert = mdb.totcagevert; copy_m4_m4(mmd->bindmat, mmd->object->obmat); /* transform bindcagecos to world space */ - for (a=0; aobject->obmat, mmd->bindcagecos+a*3); + for (a = 0; a < mdb.totcagevert; a++) + mul_m4_v3(mmd->object->obmat, mmd->bindcagecos + a * 3); /* free */ mdb.cagedm->release(mdb.cagedm); MEM_freeN(mdb.vertexcos); /* compact weights */ - modifier_mdef_compact_influences((ModifierData*)mmd); + modifier_mdef_compact_influences((ModifierData *)mmd); end_progress_bar(); waitcursor(0); diff --git a/source/blender/editors/armature/meshlaplacian.h b/source/blender/editors/armature/meshlaplacian.h index 095de4ac9a9..da512f2df12 100644 --- a/source/blender/editors/armature/meshlaplacian.h +++ b/source/blender/editors/armature/meshlaplacian.h @@ -62,9 +62,9 @@ float laplacian_system_get_solution(int v); /* Heat Weighting */ void heat_bone_weighting(struct Object *ob, struct Mesh *me, float (*verts)[3], - int numbones, struct bDeformGroup **dgrouplist, - struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], - int *selected, const char **error); + int numbones, struct bDeformGroup **dgrouplist, + struct bDeformGroup **dgroupflip, float (*root)[3], float (*tip)[3], + int *selected, const char **error); #ifdef RIGID_DEFORM /* As-Rigid-As-Possible Deformation */ diff --git a/source/blender/editors/armature/poseSlide.c b/source/blender/editors/armature/poseSlide.c index 40dc0a7cd36..824a39374fd 100644 --- a/source/blender/editors/armature/poseSlide.c +++ b/source/blender/editors/armature/poseSlide.c @@ -91,63 +91,63 @@ /* Temporary data shared between these operators */ typedef struct tPoseSlideOp { - Scene *scene; /* current scene */ - ScrArea *sa; /* area that we're operating in (needed for modal()) */ - ARegion *ar; /* region that we're operating in (needed for modal()) */ - Object *ob; /* active object that Pose Info comes from */ - bArmature *arm; /* armature for pose */ + Scene *scene; /* current scene */ + ScrArea *sa; /* area that we're operating in (needed for modal()) */ + ARegion *ar; /* region that we're operating in (needed for modal()) */ + Object *ob; /* active object that Pose Info comes from */ + bArmature *arm; /* armature for pose */ + + ListBase pfLinks; /* links between posechannels and f-curves */ + DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */ + + int cframe; /* current frame number */ + int prevFrame; /* frame before current frame (blend-from) */ + int nextFrame; /* frame after current frame (blend-to) */ - ListBase pfLinks; /* links between posechannels and f-curves */ - DLRBT_Tree keys; /* binary tree for quicker searching for keyframes (when applicable) */ + int mode; /* sliding mode (ePoseSlide_Modes) */ + int flag; // unused for now, but can later get used for storing runtime settings.... - int cframe; /* current frame number */ - int prevFrame; /* frame before current frame (blend-from) */ - int nextFrame; /* frame after current frame (blend-to) */ - - int mode; /* sliding mode (ePoseSlide_Modes) */ - int flag; // unused for now, but can later get used for storing runtime settings.... - - float percentage; /* 0-1 value for determining the influence of whatever is relevant */ + float percentage; /* 0-1 value for determining the influence of whatever is relevant */ } tPoseSlideOp; /* Pose Sliding Modes */ typedef enum ePoseSlide_Modes { - POSESLIDE_PUSH = 0, /* exaggerate the pose... */ - POSESLIDE_RELAX, /* soften the pose... */ - POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */ + POSESLIDE_PUSH = 0, /* exaggerate the pose... */ + POSESLIDE_RELAX, /* soften the pose... */ + POSESLIDE_BREAKDOWN, /* slide between the endpoint poses, finding a 'soft' spot */ } ePoseSlide_Modes; /* ------------------------------------ */ /* operator init */ -static int pose_slide_init (bContext *C, wmOperator *op, short mode) +static int pose_slide_init(bContext *C, wmOperator *op, short mode) { tPoseSlideOp *pso; - bAction *act= NULL; + bAction *act = NULL; /* init slide-op data */ - pso= op->customdata= MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); + pso = op->customdata = MEM_callocN(sizeof(tPoseSlideOp), "tPoseSlideOp"); /* get info from context */ - pso->scene= CTX_data_scene(C); - pso->ob= object_pose_armature_get(CTX_data_active_object(C)); - pso->arm= (pso->ob)? pso->ob->data : NULL; - pso->sa= CTX_wm_area(C); /* only really needed when doing modal() */ - pso->ar= CTX_wm_region(C); /* only really needed when doing modal() */ + pso->scene = CTX_data_scene(C); + pso->ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + pso->arm = (pso->ob) ? pso->ob->data : NULL; + pso->sa = CTX_wm_area(C); /* only really needed when doing modal() */ + pso->ar = CTX_wm_region(C); /* only really needed when doing modal() */ - pso->cframe= pso->scene->r.cfra; - pso->mode= mode; + pso->cframe = pso->scene->r.cfra; + pso->mode = mode; /* set range info from property values - these may get overridden for the invoke() */ - pso->percentage= RNA_float_get(op->ptr, "percentage"); - pso->prevFrame= RNA_int_get(op->ptr, "prev_frame"); - pso->nextFrame= RNA_int_get(op->ptr, "next_frame"); + pso->percentage = RNA_float_get(op->ptr, "percentage"); + pso->prevFrame = RNA_int_get(op->ptr, "prev_frame"); + pso->nextFrame = RNA_int_get(op->ptr, "next_frame"); /* check the settings from the context */ if (ELEM4(NULL, pso->ob, pso->arm, pso->ob->adt, pso->ob->adt->action)) return 0; else - act= pso->ob->adt->action; + act = pso->ob->adt->action; /* for each Pose-Channel which gets affected, get the F-Curves for that channel * and set the relevant transform flags... @@ -155,7 +155,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode) poseAnim_mapping_get(C, &pso->pfLinks, pso->ob, act); /* set depsgraph flags */ - /* make sure the lock is set OK, unlock can be accidentally saved? */ + /* make sure the lock is set OK, unlock can be accidentally saved? */ pso->ob->pose->flag |= POSE_LOCKED; pso->ob->pose->flag &= ~POSE_DO_UNLOCK; @@ -171,7 +171,7 @@ static int pose_slide_init (bContext *C, wmOperator *op, short mode) /* exiting the operator - free data */ static void pose_slide_exit(wmOperator *op) { - tPoseSlideOp *pso= op->customdata; + tPoseSlideOp *pso = op->customdata; /* if data exists, clear its data and exit */ if (pso) { @@ -186,36 +186,36 @@ static void pose_slide_exit(wmOperator *op) } /* cleanup */ - op->customdata= NULL; + op->customdata = NULL; } /* ------------------------------------ */ /* helper for apply() / reset() - refresh the data */ -static void pose_slide_refresh (bContext *C, tPoseSlideOp *pso) +static void pose_slide_refresh(bContext *C, tPoseSlideOp *pso) { /* wrapper around the generic version, allowing us to add some custom stuff later still */ poseAnim_mapping_refresh(C, pso->scene, pso->ob); } /* helper for apply() - perform sliding for some value */ -static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) +static void pose_slide_apply_val(tPoseSlideOp *pso, FCurve *fcu, float *val) { float cframe = (float)pso->cframe; float sVal, eVal; float w1, w2; /* get keyframe values for endpoint poses to blend with */ - /* previous/start */ - sVal= evaluate_fcurve(fcu, (float)pso->prevFrame); - /* next/end */ - eVal= evaluate_fcurve(fcu, (float)pso->nextFrame); + /* previous/start */ + sVal = evaluate_fcurve(fcu, (float)pso->prevFrame); + /* next/end */ + eVal = evaluate_fcurve(fcu, (float)pso->nextFrame); /* calculate the relative weights of the endpoints */ if (pso->mode == POSESLIDE_BREAKDOWN) { /* get weights from the percentage control */ - w1= pso->percentage; /* this must come second */ - w2= 1.0f - w1; /* this must come first */ + w1 = pso->percentage; /* this must come second */ + w2 = 1.0f - w1; /* this must come first */ } else { /* - these weights are derived from the relative distance of these @@ -228,8 +228,8 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) w2 = (float)pso->nextFrame - cframe; wtot = w1 + w2; - w1 = (w1/wtot); - w2 = (w2/wtot); + w1 = (w1 / wtot); + w2 = (w2 / wtot); } /* depending on the mode, calculate the new value @@ -243,13 +243,13 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) * - numerator should be larger than denominator to 'expand' the result * - perform this weighting a number of times given by the percentage... */ - int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed + int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed while (iters-- > 0) { - (*val)= ( -((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; + (*val) = (-((sVal * w2) + (eVal * w1)) + ((*val) * 6.0f) ) / 5.0f; } } - break; + break; case POSESLIDE_RELAX: /* make the current pose more like its surrounding ones */ { @@ -257,36 +257,36 @@ static void pose_slide_apply_val (tPoseSlideOp *pso, FCurve *fcu, float *val) * - numerator should be smaller than denominator to 'relax' the result * - perform this weighting a number of times given by the percentage... */ - int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed + int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed while (iters-- > 0) { - (*val)= ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; + (*val) = ( ((sVal * w2) + (eVal * w1)) + ((*val) * 5.0f) ) / 6.0f; } } - break; + break; case POSESLIDE_BREAKDOWN: /* make the current pose slide around between the endpoints */ { /* perform simple linear interpolation - coefficient for start must come from pso->percentage... */ // TODO: make this use some kind of spline interpolation instead? - (*val)= ((sVal * w2) + (eVal * w1)); + (*val) = ((sVal * w2) + (eVal * w1)); } - break; + break; } } /* helper for apply() - perform sliding for some 3-element vector */ -static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[]) +static void pose_slide_apply_vec3(tPoseSlideOp *pso, tPChanFCurveLink *pfl, float vec[3], const char propName[]) { - LinkData *ld=NULL; - char *path=NULL; + LinkData *ld = NULL; + char *path = NULL; /* get the path to use... */ - path= BLI_sprintfN("%s.%s", pfl->pchan_path, propName); + path = BLI_sprintfN("%s.%s", pfl->pchan_path, propName); /* using this path, find each matching F-Curve for the variables we're interested in */ - while ( (ld= poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { - FCurve *fcu= (FCurve *)ld->data; + while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { + FCurve *fcu = (FCurve *)ld->data; /* just work on these channels one by one... there's no interaction between values */ pose_slide_apply_val(pso, fcu, &vec[fcu->array_index]); @@ -297,7 +297,7 @@ static void pose_slide_apply_vec3 (tPoseSlideOp *pso, tPChanFCurveLink *pfl, flo } /* helper for apply() - perform sliding for custom properties */ -static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) +static void pose_slide_apply_props(tPoseSlideOp *pso, tPChanFCurveLink *pfl) { PointerRNA ptr = {{NULL}}; LinkData *ld; @@ -337,7 +337,7 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) pose_slide_apply_val(pso, fcu, &tval); RNA_property_float_set(&ptr, prop, tval); } - break; + break; case PROP_BOOLEAN: case PROP_ENUM: case PROP_INT: @@ -346,7 +346,7 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) pose_slide_apply_val(pso, fcu, &tval); RNA_property_int_set(&ptr, prop, (int)tval); } - break; + break; default: /* cannot handle */ //printf("Cannot Pose Slide non-numerical property\n"); @@ -358,37 +358,37 @@ static void pose_slide_apply_props (tPoseSlideOp *pso, tPChanFCurveLink *pfl) } /* helper for apply() - perform sliding for quaternion rotations (using quat blending) */ -static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) +static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) { - FCurve *fcu_w=NULL, *fcu_x=NULL, *fcu_y=NULL, *fcu_z=NULL; - bPoseChannel *pchan= pfl->pchan; - LinkData *ld=NULL; - char *path=NULL; + FCurve *fcu_w = NULL, *fcu_x = NULL, *fcu_y = NULL, *fcu_z = NULL; + bPoseChannel *pchan = pfl->pchan; + LinkData *ld = NULL; + char *path = NULL; float cframe; /* get the path to use - this should be quaternion rotations only (needs care) */ - path= BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion"); + path = BLI_sprintfN("%s.%s", pfl->pchan_path, "rotation_quaternion"); /* get the current frame number */ - cframe= (float)pso->cframe; + cframe = (float)pso->cframe; /* using this path, find each matching F-Curve for the variables we're interested in */ - while ( (ld= poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { - FCurve *fcu= (FCurve *)ld->data; + while ( (ld = poseAnim_mapping_getNextFCurve(&pfl->fcurves, ld, path)) ) { + FCurve *fcu = (FCurve *)ld->data; /* assign this F-Curve to one of the relevant pointers... */ switch (fcu->array_index) { case 3: /* z */ - fcu_z= fcu; + fcu_z = fcu; break; case 2: /* y */ - fcu_y= fcu; + fcu_y = fcu; break; case 1: /* x */ - fcu_x= fcu; + fcu_x = fcu; break; case 0: /* w */ - fcu_w= fcu; + fcu_w = fcu; break; } } @@ -428,18 +428,18 @@ static void pose_slide_apply_quat (tPoseSlideOp *pso, tPChanFCurveLink *pfl) } else { float quat_interp[4], quat_orig[4]; - int iters= (int)ceil(10.0f*pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed + int iters = (int)ceil(10.0f * pso->percentage); // TODO: maybe a sensitivity ctrl on top of this is needed /* perform this blending several times until a satisfactory result is reached */ while (iters-- > 0) { /* calculate the interpolation between the endpoints */ - interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe-pso->prevFrame) / (pso->nextFrame-pso->prevFrame)); + interp_qt_qtqt(quat_interp, quat_prev, quat_next, (cframe - pso->prevFrame) / (pso->nextFrame - pso->prevFrame)); /* make a copy of the original rotation */ copy_qt_qt(quat_orig, pchan->quat); /* tricky interpolations - blending between original and new */ - interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f/6.0f); + interp_qt_qtqt(pchan->quat, quat_orig, quat_interp, 1.0f / 6.0f); } } } @@ -461,13 +461,13 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) } /* for each link, handle each set of transforms */ - for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) { + for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { /* valid transforms for each PoseChannel should have been noted already * - sliding the pose should be a straightforward exercise for location+rotation, * but rotations get more complicated since we may want to use quaternion blending * for quaternions instead... */ - bPoseChannel *pchan= pfl->pchan; + bPoseChannel *pchan = pfl->pchan; if (pchan->flag & POSE_LOC) { /* calculate these for the 'location' vector, and use location curves */ @@ -505,14 +505,14 @@ static void pose_slide_apply(bContext *C, tPoseSlideOp *pso) } /* perform autokeyframing after changes were made + confirmed */ -static void pose_slide_autoKeyframe (bContext *C, tPoseSlideOp *pso) +static void pose_slide_autoKeyframe(bContext *C, tPoseSlideOp *pso) { /* wrapper around the generic call */ poseAnim_mapping_autoKeyframe(C, pso->scene, pso->ob, &pso->pfLinks, (float)pso->cframe); } /* reset changes made to current pose */ -static void pose_slide_reset (tPoseSlideOp *pso) +static void pose_slide_reset(tPoseSlideOp *pso) { /* wrapper around the generic call, so that custom stuff can be added later */ poseAnim_mapping_reset(&pso->pfLinks); @@ -521,7 +521,7 @@ static void pose_slide_reset (tPoseSlideOp *pso) /* ------------------------------------ */ /* draw percentage indicator in header */ -static void pose_slide_draw_status (tPoseSlideOp *pso) +static void pose_slide_draw_status(tPoseSlideOp *pso) { char status_str[32]; char mode_str[32]; @@ -543,24 +543,24 @@ static void pose_slide_draw_status (tPoseSlideOp *pso) break; } - BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f)); + BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage * 100.0f)); ED_area_headerprint(pso->sa, status_str); } /* common code for invoke() methods */ -static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp *pso) +static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *pso) { tPChanFCurveLink *pfl; - AnimData *adt= pso->ob->adt; - wmWindow *win= CTX_wm_window(C); + AnimData *adt = pso->ob->adt; + wmWindow *win = CTX_wm_window(C); /* for each link, add all its keyframes to the search tree */ - for (pfl= pso->pfLinks.first; pfl; pfl= pfl->next) { + for (pfl = pso->pfLinks.first; pfl; pfl = pfl->next) { LinkData *ld; /* do this for each F-Curve */ - for (ld= pfl->fcurves.first; ld; ld= ld->next) { - FCurve *fcu= (FCurve *)ld->data; + for (ld = pfl->fcurves.first; ld; ld = ld->next) { + FCurve *fcu = (FCurve *)ld->data; fcurve_to_keylist(adt, fcu, &pso->keys, NULL); } } @@ -568,34 +568,34 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp * /* consolidate these keyframes, and figure out the nearest ones */ BLI_dlrbTree_linkedlist_sync(&pso->keys); - /* cancel if no keyframes found... */ + /* cancel if no keyframes found... */ if (pso->keys.root) { ActKeyColumn *ak; - float cframe= (float)pso->cframe; + float cframe = (float)pso->cframe; /* firstly, check if the current frame is a keyframe... */ - ak= (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe); + ak = (ActKeyColumn *)BLI_dlrbTree_search_exact(&pso->keys, compare_ak_cfraPtr, &cframe); if (ak == NULL) { /* current frame is not a keyframe, so search */ - ActKeyColumn *pk= (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe); - ActKeyColumn *nk= (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe); + ActKeyColumn *pk = (ActKeyColumn *)BLI_dlrbTree_search_prev(&pso->keys, compare_ak_cfraPtr, &cframe); + ActKeyColumn *nk = (ActKeyColumn *)BLI_dlrbTree_search_next(&pso->keys, compare_ak_cfraPtr, &cframe); /* new set the frames */ - /* prev frame */ - pso->prevFrame= (pk)? (pk->cfra) : (pso->cframe - 1); + /* prev frame */ + pso->prevFrame = (pk) ? (pk->cfra) : (pso->cframe - 1); RNA_int_set(op->ptr, "prev_frame", pso->prevFrame); - /* next frame */ - pso->nextFrame= (nk)? (nk->cfra) : (pso->cframe + 1); + /* next frame */ + pso->nextFrame = (nk) ? (nk->cfra) : (pso->cframe + 1); RNA_int_set(op->ptr, "next_frame", pso->nextFrame); } else { /* current frame itself is a keyframe, so just take keyframes on either side */ - /* prev frame */ - pso->prevFrame= (ak->prev)? (ak->prev->cfra) : (pso->cframe - 1); + /* prev frame */ + pso->prevFrame = (ak->prev) ? (ak->prev->cfra) : (pso->cframe - 1); RNA_int_set(op->ptr, "prev_frame", pso->prevFrame); - /* next frame */ - pso->nextFrame= (ak->next)? (ak->next->cfra) : (pso->cframe + 1); + /* next frame */ + pso->nextFrame = (ak->next) ? (ak->next->cfra) : (pso->cframe + 1); RNA_int_set(op->ptr, "next_frame", pso->nextFrame); } } @@ -624,13 +624,13 @@ static int pose_slide_invoke_common (bContext *C, wmOperator *op, tPoseSlideOp * } /* common code for modal() */ -static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) +static int pose_slide_modal(bContext *C, wmOperator *op, wmEvent *evt) { - tPoseSlideOp *pso= op->customdata; - wmWindow *win= CTX_wm_window(C); + tPoseSlideOp *pso = op->customdata; + wmWindow *win = CTX_wm_window(C); switch (evt->type) { - case LEFTMOUSE: /* confirm */ + case LEFTMOUSE: /* confirm */ { /* return to normal cursor and header status */ ED_area_headerprint(pso->sa, NULL); @@ -644,7 +644,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) return OPERATOR_FINISHED; } - case ESCKEY: /* cancel */ + case ESCKEY: /* cancel */ case RIGHTMOUSE: { /* return to normal cursor and header status */ @@ -669,7 +669,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) /* calculate percentage based on position of mouse (we only use x-axis for now. * since this is more convenient for users to do), and store new percentage value */ - pso->percentage= (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); + pso->percentage = (evt->x - pso->ar->winrct.xmin) / ((float)pso->ar->winx); RNA_float_set(op->ptr, "percentage", pso->percentage); /* update percentage indicator in header */ @@ -681,11 +681,11 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) /* apply... */ pose_slide_apply(C, pso); } - break; + break; default: /* unhandled event (maybe it was some view manip? */ /* allow to pass through */ - return OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH; + return OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH; } /* still running... */ @@ -693,7 +693,7 @@ static int pose_slide_modal (bContext *C, wmOperator *op, wmEvent *evt) } /* common code for cancel() */ -static int pose_slide_cancel (bContext *UNUSED(C), wmOperator *op) +static int pose_slide_cancel(bContext *UNUSED(C), wmOperator *op) { /* cleanup and done */ pose_slide_exit(op); @@ -701,7 +701,7 @@ static int pose_slide_cancel (bContext *UNUSED(C), wmOperator *op) } /* common code for exec() methods */ -static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *pso) +static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso) { /* settings should have been set up ok for applying, so just apply! */ pose_slide_apply(C, pso); @@ -716,7 +716,7 @@ static int pose_slide_exec_common (bContext *C, wmOperator *op, tPoseSlideOp *ps } /* common code for defining RNA properties */ -static void pose_slide_opdef_properties (wmOperatorType *ot) +static void pose_slide_opdef_properties(wmOperatorType *ot) { RNA_def_int(ot->srna, "prev_frame", 0, MINAFRAME, MAXFRAME, "Previous Keyframe", "Frame number of keyframe immediately before the current frame", 0, 50); RNA_def_int(ot->srna, "next_frame", 0, MINAFRAME, MAXFRAME, "Next Keyframe", "Frame number of keyframe immediately after the current frame", 0, 50); @@ -726,7 +726,7 @@ static void pose_slide_opdef_properties (wmOperatorType *ot) /* ------------------------------------ */ /* invoke() - for 'push' mode */ -static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_slide_push_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { tPoseSlideOp *pso; @@ -736,14 +736,14 @@ static int pose_slide_push_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED( return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } /* exec() - for push */ -static int pose_slide_push_exec (bContext *C, wmOperator *op) +static int pose_slide_push_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; @@ -753,7 +753,7 @@ static int pose_slide_push_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -774,7 +774,7 @@ void POSE_OT_push(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -783,7 +783,7 @@ void POSE_OT_push(wmOperatorType *ot) /* ........................ */ /* invoke() - for 'relax' mode */ -static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_slide_relax_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { tPoseSlideOp *pso; @@ -793,14 +793,14 @@ static int pose_slide_relax_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } /* exec() - for relax */ -static int pose_slide_relax_exec (bContext *C, wmOperator *op) +static int pose_slide_relax_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; @@ -810,7 +810,7 @@ static int pose_slide_relax_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -831,7 +831,7 @@ void POSE_OT_relax(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -840,7 +840,7 @@ void POSE_OT_relax(wmOperatorType *ot) /* ........................ */ /* invoke() - for 'breakdown' mode */ -static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_slide_breakdown_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { tPoseSlideOp *pso; @@ -850,14 +850,14 @@ static int pose_slide_breakdown_invoke (bContext *C, wmOperator *op, wmEvent *UN return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common setup work */ return pose_slide_invoke_common(C, op, pso); } /* exec() - for breakdown */ -static int pose_slide_breakdown_exec (bContext *C, wmOperator *op) +static int pose_slide_breakdown_exec(bContext *C, wmOperator *op) { tPoseSlideOp *pso; @@ -867,7 +867,7 @@ static int pose_slide_breakdown_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - pso= op->customdata; + pso = op->customdata; /* do common exec work */ return pose_slide_exec_common(C, op, pso); @@ -888,7 +888,7 @@ void POSE_OT_breakdown(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -899,18 +899,18 @@ void POSE_OT_breakdown(wmOperatorType *ot) /* "termination conditions" - i.e. when we stop */ typedef enum ePosePropagate_Termination { - /* stop after the current hold ends */ + /* stop after the current hold ends */ POSE_PROPAGATE_SMART_HOLDS = 0, - /* only do on the last keyframe */ + /* only do on the last keyframe */ POSE_PROPAGATE_LAST_KEY, - /* stop after the next keyframe */ + /* stop after the next keyframe */ POSE_PROPAGATE_NEXT_KEY, - /* stop after the specified frame */ + /* stop after the specified frame */ POSE_PROPAGATE_BEFORE_FRAME, - /* stop when we run out of keyframes */ + /* stop when we run out of keyframes */ POSE_PROPAGATE_BEFORE_END, - /* only do on the frames where markers are selected */ + /* only do on the frames where markers are selected */ POSE_PROPAGATE_SELECTED_MARKERS } ePosePropagate_Termination; @@ -927,15 +927,15 @@ typedef union tPosePropagate_ModeData { /* get frame on which the "hold" for the bone ends * XXX: this may not really work that well if a bone moves on some channels and not others - * if this happens to be a major issue, scrap this, and just make this happen + * if this happens to be a major issue, scrap this, and just make this happen * independently per F-Curve */ -static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink *pfl, float startFrame) +static float pose_propagate_get_boneHoldEndFrame(Object *ob, tPChanFCurveLink *pfl, float startFrame) { DLRBT_Tree keys, blocks; ActKeyBlock *ab; - AnimData *adt= ob->adt; + AnimData *adt = ob->adt; LinkData *ld; float endFrame = startFrame; @@ -958,8 +958,8 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink * if (actkeyblock_is_valid(ab, &keys) == 0) { /* There are only two cases for no-exact match: - * 1) the current frame is just before another key but not on a key itself - * 2) the current frame is on a key, but that key doesn't link to the next + * 1) the current frame is just before another key but not on a key itself + * 2) the current frame is on a key, but that key doesn't link to the next * * If we've got the first case, then we can search for another block, * otherwise forget it, as we'd be overwriting some valid data. @@ -1025,11 +1025,11 @@ static float pose_propagate_get_boneHoldEndFrame (Object *ob, tPChanFCurveLink * } /* get reference value from F-Curve using RNA */ -static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) +static short pose_propagate_get_refVal(Object *ob, FCurve *fcu, float *value) { PointerRNA id_ptr, ptr; PropertyRNA *prop; - short found= FALSE; + short found = FALSE; /* base pointer is always the object -> id_ptr */ RNA_id_pointer_create(&ob->id, &id_ptr); @@ -1039,41 +1039,41 @@ static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) if (RNA_property_array_check(prop)) { /* array */ if (fcu->array_index < RNA_property_array_length(&ptr, prop)) { - found= TRUE; + found = TRUE; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - *value= (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); + *value = (float)RNA_property_boolean_get_index(&ptr, prop, fcu->array_index); break; case PROP_INT: - *value= (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); + *value = (float)RNA_property_int_get_index(&ptr, prop, fcu->array_index); break; case PROP_FLOAT: - *value= RNA_property_float_get_index(&ptr, prop, fcu->array_index); + *value = RNA_property_float_get_index(&ptr, prop, fcu->array_index); break; default: - found= FALSE; + found = FALSE; break; } } } else { /* not an array */ - found= TRUE; + found = TRUE; switch (RNA_property_type(prop)) { case PROP_BOOLEAN: - *value= (float)RNA_property_boolean_get(&ptr, prop); + *value = (float)RNA_property_boolean_get(&ptr, prop); break; case PROP_INT: - *value= (float)RNA_property_int_get(&ptr, prop); + *value = (float)RNA_property_int_get(&ptr, prop); break; case PROP_ENUM: - *value= (float)RNA_property_enum_get(&ptr, prop); + *value = (float)RNA_property_enum_get(&ptr, prop); break; case PROP_FLOAT: - *value= RNA_property_float_get(&ptr, prop); + *value = RNA_property_float_get(&ptr, prop); break; default: - found= FALSE; + found = FALSE; break; } } @@ -1083,8 +1083,8 @@ static short pose_propagate_get_refVal (Object *ob, FCurve *fcu, float *value) } /* propagate just works along each F-Curve in turn */ -static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, - float startFrame, tPosePropagate_ModeData modeData) +static void pose_propagate_fcurve(wmOperator *op, Object *ob, FCurve *fcu, + float startFrame, tPosePropagate_ModeData modeData) { const int mode = RNA_enum_get(op->ptr, "mode"); @@ -1092,7 +1092,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, float refVal = 0.0f; short keyExists; int i, match; - short first=1; + short first = 1; /* skip if no keyframes to edit */ if ((fcu->bezt == NULL) || (fcu->totvert < 2)) @@ -1102,13 +1102,13 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, * doesn't need to firstly keyframe the pose (though this doesn't mean that * they can't either) */ - if ( !pose_propagate_get_refVal(ob, fcu, &refVal)) + if (!pose_propagate_get_refVal(ob, fcu, &refVal)) return; /* find the first keyframe to start propagating from * - if there's a keyframe on the current frame, we probably want to save this value there too * since it may be as of yet unkeyed - * - if starting before the starting frame, don't touch the key, as it may have had some valid + * - if starting before the starting frame, don't touch the key, as it may have had some valid * values */ match = binarysearch_bezt_index(fcu->bezt, startFrame, fcu->totvert, &keyExists); @@ -1132,7 +1132,7 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, } else if (mode == POSE_PROPAGATE_LAST_KEY) { /* only affect this frame if it will be the last one */ - if (i != (fcu->totvert-1)) + if (i != (fcu->totvert - 1)) continue; } else if (mode == POSE_PROPAGATE_SELECTED_MARKERS) { @@ -1162,11 +1162,11 @@ static void pose_propagate_fcurve (wmOperator *op, Object *ob, FCurve *fcu, /* --------------------------------- */ -static int pose_propagate_exec (bContext *C, wmOperator *op) +static int pose_propagate_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bAction *act= (ob && ob->adt)? ob->adt->action : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bAction *act = (ob && ob->adt) ? ob->adt->action : NULL; ListBase pflinks = {NULL, NULL}; tPChanFCurveLink *pfl; @@ -1210,7 +1210,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) } /* go through propagating pose to keyframes, curve by curve */ - for (ld = pfl->fcurves.first; ld; ld= ld->next) + for (ld = pfl->fcurves.first; ld; ld = ld->next) pose_propagate_fcurve(op, ob, (FCurve *)ld->data, (float)CFRA, modeData); } @@ -1230,7 +1230,7 @@ static int pose_propagate_exec (bContext *C, wmOperator *op) void POSE_OT_propagate(wmOperatorType *ot) { - static EnumPropertyItem terminate_items[]= { + static EnumPropertyItem terminate_items[] = { {POSE_PROPAGATE_SMART_HOLDS, "WHILE_HELD", 0, "While Held", "Propagate pose to all keyframes after current frame that don't change (Default behavior)"}, {POSE_PROPAGATE_NEXT_KEY, "NEXT_KEY", 0, "To Next Keyframe", "Propagate pose to first keyframe following the current frame only"}, {POSE_PROPAGATE_LAST_KEY, "LAST_KEY", 0, "To Last Keyframe", "Propagate pose to the last keyframe only (i.e. making action cyclic)"}, @@ -1249,7 +1249,7 @@ void POSE_OT_propagate(wmOperatorType *ot) ot->poll = ED_operator_posemode; // XXX: needs selected bones! /* flag */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ // TODO: add "fade out" control for tapering off amount of propagation as time goes by? diff --git a/source/blender/editors/armature/poseUtils.c b/source/blender/editors/armature/poseUtils.c index 3c855ff96e6..4e0398168d3 100644 --- a/source/blender/editors/armature/poseUtils.c +++ b/source/blender/editors/armature/poseUtils.c @@ -79,25 +79,25 @@ /* FCurves <-> PoseChannels Links */ /* helper for poseAnim_mapping_get() -> get the relevant F-Curves per PoseChannel */ -static void fcurves_to_pchan_links_get (ListBase *pfLinks, Object *ob, bAction *act, bPoseChannel *pchan) +static void fcurves_to_pchan_links_get(ListBase *pfLinks, Object *ob, bAction *act, bPoseChannel *pchan) { ListBase curves = {NULL, NULL}; int transFlags = action_get_item_transforms(act, ob, pchan, &curves); - pchan->flag &= ~(POSE_LOC|POSE_ROT|POSE_SIZE); + pchan->flag &= ~(POSE_LOC | POSE_ROT | POSE_SIZE); /* check if any transforms found... */ if (transFlags) { /* make new linkage data */ - tPChanFCurveLink *pfl= MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink"); + tPChanFCurveLink *pfl = MEM_callocN(sizeof(tPChanFCurveLink), "tPChanFCurveLink"); PointerRNA ptr; - pfl->fcurves= curves; - pfl->pchan= pchan; + pfl->fcurves = curves; + pfl->pchan = pchan; /* get the RNA path to this pchan - this needs to be freed! */ RNA_pointer_create((ID *)ob, &RNA_PoseBone, pchan, &ptr); - pfl->pchan_path= RNA_path_from_ID_to_struct(&ptr); + pfl->pchan_path = RNA_path_from_ID_to_struct(&ptr); /* add linkage data to operator data */ BLI_addtail(pfLinks, pfl); @@ -131,7 +131,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a /* for each Pose-Channel which gets affected, get the F-Curves for that channel * and set the relevant transform flags... */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } @@ -141,7 +141,7 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a * i.e. if nothing selected, do whole pose */ if (pfLinks->first == NULL) { - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { fcurves_to_pchan_links_get(pfLinks, ob, act, pchan); } @@ -152,11 +152,11 @@ void poseAnim_mapping_get(bContext *C, ListBase *pfLinks, Object *ob, bAction *a /* free F-Curve <-> PoseChannel links */ void poseAnim_mapping_free(ListBase *pfLinks) { - tPChanFCurveLink *pfl, *pfln=NULL; + tPChanFCurveLink *pfl, *pfln = NULL; /* free the temp pchan links and their data */ - for (pfl= pfLinks->first; pfl; pfl= pfln) { - pfln= pfl->next; + for (pfl = pfLinks->first; pfl; pfl = pfln) { + pfln = pfl->next; /* free custom properties */ if (pfl->oldprops) { @@ -180,19 +180,19 @@ void poseAnim_mapping_free(ListBase *pfLinks) /* helper for apply() / reset() - refresh the data */ void poseAnim_mapping_refresh(bContext *C, Scene *scene, Object *ob) { - bArmature *arm= (bArmature *)ob->data; + bArmature *arm = (bArmature *)ob->data; /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ // FIXME: shouldn't this use the builtin stuff? - if ((arm->flag & ARM_DELAYDEFORM)==0) + if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } /* reset changes made to current pose */ @@ -201,8 +201,8 @@ void poseAnim_mapping_reset(ListBase *pfLinks) tPChanFCurveLink *pfl; /* iterate over each pose-channel affected, restoring all channels to their original values */ - for (pfl= pfLinks->first; pfl; pfl= pfl->next) { - bPoseChannel *pchan= pfl->pchan; + for (pfl = pfLinks->first; pfl; pfl = pfl->next) { + bPoseChannel *pchan = pfl->pchan; /* just copy all the values over regardless of whether they changed or not */ copy_v3_v3(pchan->loc, pfl->oldloc); @@ -231,8 +231,8 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa /* XXX: here we already have the information about what transforms exist, though * it might be easier to just overwrite all using normal mechanisms */ - for (pfl= pfLinks->first; pfl; pfl= pfl->next) { - bPoseChannel *pchan= pfl->pchan; + for (pfl = pfLinks->first; pfl; pfl = pfl->next) { + bPoseChannel *pchan = pfl->pchan; /* add datasource override for the PoseChannel, to be used later */ ANIM_relative_keyingset_add_source(&dsources, &ob->id, &RNA_PoseBone, pchan); @@ -262,14 +262,14 @@ void poseAnim_mapping_autoKeyframe(bContext *C, Scene *scene, Object *ob, ListBa /* find the next F-Curve for a PoseChannel with matching path... * - path is not just the pfl rna_path, since that path doesn't have property info yet */ -LinkData *poseAnim_mapping_getNextFCurve (ListBase *fcuLinks, LinkData *prev, const char *path) +LinkData *poseAnim_mapping_getNextFCurve(ListBase *fcuLinks, LinkData *prev, const char *path) { - LinkData *first= (prev)? prev->next : (fcuLinks)? fcuLinks->first : NULL; + LinkData *first = (prev) ? prev->next : (fcuLinks) ? fcuLinks->first : NULL; LinkData *ld; /* check each link to see if the linked F-Curve has a matching path */ - for (ld= first; ld; ld= ld->next) { - FCurve *fcu= (FCurve *)ld->data; + for (ld = first; ld; ld = ld->next) { + FCurve *fcu = (FCurve *)ld->data; /* check if paths match */ if (strcmp(path, fcu->rna_path) == 0) diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index 8791a345489..36c15c50809 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -89,9 +89,9 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* == POSE-LIBRARY TOOL FOR BLENDER == * * Overview: - * This tool allows animators to store a set of frequently used poses to dump into - * the active action to help in "budget" productions to quickly block out new actions. - * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. + * This tool allows animators to store a set of frequently used poses to dump into + * the active action to help in "budget" productions to quickly block out new actions. + * It acts as a kind of "glorified clipboard for poses", allowing for naming of poses. * * Features: * - PoseLibs are simply normal Actions @@ -108,10 +108,10 @@ static void action_set_activemarker(void *UNUSED(a), void *UNUSED(b), void *UNUS /* gets the first available frame in poselib to store a pose on * - frames start from 1, and a pose should occur on every frame... 0 is error! */ -static int poselib_get_free_index (bAction *act) +static int poselib_get_free_index(bAction *act) { TimeMarker *marker; - int low=0, high=0; + int low = 0, high = 0; short changed = 0; /* sanity checks */ @@ -124,7 +124,7 @@ static int poselib_get_free_index (bAction *act) do { changed = 0; - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { /* only increase low if value is 1 greater than low, to find "gaps" where * poses were removed from the poselib */ @@ -135,7 +135,7 @@ static int poselib_get_free_index (bAction *act) /* value replaces high if it is the highest value encountered yet */ if (marker->frame > high) { - high= marker->frame; + high = marker->frame; changed = 1; } } @@ -151,17 +151,17 @@ static int poselib_get_free_index (bAction *act) } /* returns the active pose for a poselib */ -static TimeMarker *poselib_get_active_pose (bAction *act) +static TimeMarker *poselib_get_active_pose(bAction *act) { if ((act) && (act->active_marker)) - return BLI_findlink(&act->markers, act->active_marker-1); + return BLI_findlink(&act->markers, act->active_marker - 1); else return NULL; } /* Get object that Pose Lib should be found on */ - /* XXX C can be zero */ -static Object *get_poselib_object (bContext *C) +/* XXX C can be zero */ +static Object *get_poselib_object(bContext *C) { ScrArea *sa; @@ -174,11 +174,11 @@ static Object *get_poselib_object (bContext *C) if (sa && (sa->spacetype == SPACE_BUTS)) return ED_object_context(C); else - return object_pose_armature_get(CTX_data_active_object(C)); + return BKE_object_pose_armature_get(CTX_data_active_object(C)); } /* Poll callback for operators that require existing PoseLib data (with poses) to work */ -static int has_poselib_pose_data_poll (bContext *C) +static int has_poselib_pose_data_poll(bContext *C) { Object *ob = get_poselib_object(C); return (ob && ob->poselib); @@ -187,7 +187,7 @@ static int has_poselib_pose_data_poll (bContext *C) /* ----------------------------------- */ /* Initialize a new poselib (whether it is needed or not) */ -static bAction *poselib_init_new (Object *ob) +static bAction *poselib_init_new(Object *ob) { /* sanity checks - only for armatures */ if (ELEM(NULL, ob, ob->pose)) @@ -196,13 +196,13 @@ static bAction *poselib_init_new (Object *ob) /* init object's poselib action (unlink old one if there) */ if (ob->poselib) id_us_min(&ob->poselib->id); - ob->poselib= add_empty_action("PoseLib"); + ob->poselib = add_empty_action("PoseLib"); return ob->poselib; } /* Initialize a new poselib (checks if that needs to happen) */ -static bAction *poselib_validate (Object *ob) +static bAction *poselib_validate(Object *ob) { if (ELEM(NULL, ob, ob->pose)) return NULL; @@ -215,7 +215,7 @@ static bAction *poselib_validate (Object *ob) /* ************************************************************* */ /* Pose Lib UI Operators */ -static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op)) +static int poselib_new_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); @@ -227,7 +227,7 @@ static int poselib_new_exec (bContext *C, wmOperator *UNUSED(op)) poselib_init_new(ob); /* notifier here might evolve? */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } @@ -244,12 +244,12 @@ void POSELIB_OT_new(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------------------------------------ */ -static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op)) +static int poselib_unlink_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = get_poselib_object(C); @@ -262,7 +262,7 @@ static int poselib_unlink_exec (bContext *C, wmOperator *UNUSED(op)) ob->poselib = NULL; /* notifier here might evolve? */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); return OPERATOR_FINISHED; } @@ -279,7 +279,7 @@ void POSELIB_OT_unlink(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************* */ @@ -288,10 +288,10 @@ void POSELIB_OT_unlink(wmOperatorType *ot) /* This tool automagically generates/validates poselib data so that it corresponds to the data * in the action. This is for use in making existing actions usable as poselibs. */ -static int poselib_sanitise_exec (bContext *C, wmOperator *op) +static int poselib_sanitise_exec(bContext *C, wmOperator *op) { Object *ob = get_poselib_object(C); - bAction *act = (ob)? ob->poselib : NULL; + bAction *act = (ob) ? ob->poselib : NULL; DLRBT_Tree keys; ActKeyColumn *ak; TimeMarker *marker, *markern; @@ -304,14 +304,14 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* determine which frames have keys */ BLI_dlrbTree_init(&keys); - action_to_keylist(NULL, act, &keys, NULL); + action_to_keylist(NULL, act, &keys, NULL); BLI_dlrbTree_linkedlist_sync(&keys); /* for each key, make sure there is a corresponding pose */ - for (ak= keys.first; ak; ak= ak->next) { + for (ak = keys.first; ak; ak = ak->next) { /* check if any pose matches this */ // TODO: don't go looking through the list like this every time... - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { if (IS_EQ(marker->frame, (double)ak->cfra)) { marker->flag = -1; break; @@ -321,20 +321,20 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* add new if none found */ if (marker == NULL) { /* add pose to poselib */ - marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); + marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, "Pose", sizeof(marker->name)); - marker->frame= (int)ak->cfra; - marker->flag= -1; + marker->frame = (int)ak->cfra; + marker->flag = -1; BLI_addtail(&act->markers, marker); } } /* remove all untagged poses (unused), and remove all tags */ - for (marker= act->markers.first; marker; marker= markern) { - markern= marker->next; + for (marker = act->markers.first; marker; marker = markern) { + markern = marker->next; if (marker->flag != -1) BLI_freelinkN(&act->markers, marker); @@ -348,7 +348,7 @@ static int poselib_sanitise_exec (bContext *C, wmOperator *op) /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -365,15 +365,15 @@ void POSELIB_OT_action_sanitise(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------------------------------ */ -static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, void *UNUSED(arg)) +static void poselib_add_menu_invoke__replacemenu(bContext *C, uiLayout *layout, void *UNUSED(arg)) { - Object *ob= get_poselib_object(C); - bAction *act= ob->poselib; /* never NULL */ + Object *ob = get_poselib_object(C); + bAction *act = ob->poselib; /* never NULL */ TimeMarker *marker; wmOperatorType *ot = WM_operatortype_find("POSELIB_OT_pose_add", 1); @@ -384,7 +384,7 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add each marker to this menu */ - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { PointerRNA props_ptr; props_ptr = uiItemFullO_ptr(layout, ot, @@ -396,11 +396,11 @@ static void poselib_add_menu_invoke__replacemenu (bContext *C, uiLayout *layout, } } -static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int poselib_add_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Scene *scene= CTX_data_scene(C); - Object *ob= get_poselib_object(C); - bPose *pose= (ob) ? ob->pose : NULL; + Scene *scene = CTX_data_scene(C); + Object *ob = get_poselib_object(C); + bPose *pose = (ob) ? ob->pose : NULL; uiPopupMenu *pup; uiLayout *layout; @@ -409,8 +409,8 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED return OPERATOR_CANCELLED; /* start building */ - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT); /* add new (adds to the first unoccupied frame) */ @@ -432,14 +432,14 @@ static int poselib_add_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } -static int poselib_add_exec (bContext *C, wmOperator *op) +static int poselib_add_exec(bContext *C, wmOperator *op) { - Object *ob= get_poselib_object(C); + Object *ob = get_poselib_object(C); bAction *act = poselib_validate(ob); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; TimeMarker *marker; - KeyingSet *ks= ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ - int frame= RNA_int_get(op->ptr, "frame"); + KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_WHOLE_CHARACTER_ID); /* this includes custom props :)*/ + int frame = RNA_int_get(op->ptr, "frame"); char name[64]; /* sanity check (invoke should have checked this anyway) */ @@ -453,17 +453,17 @@ static int poselib_add_exec (bContext *C, wmOperator *op) * - for the 'replace' option, this should end up finding the appropriate marker, * so no new one will be added */ - for (marker= act->markers.first; marker; marker= marker->next) { + for (marker = act->markers.first; marker; marker = marker->next) { if (marker->frame == frame) { BLI_strncpy(marker->name, name, sizeof(marker->name)); break; } } if (marker == NULL) { - marker= MEM_callocN(sizeof(TimeMarker), "ActionMarker"); + marker = MEM_callocN(sizeof(TimeMarker), "ActionMarker"); BLI_strncpy(marker->name, name, sizeof(marker->name)); - marker->frame= frame; + marker->frame = frame; BLI_addtail(&act->markers, marker); } @@ -477,7 +477,7 @@ static int poselib_add_exec (bContext *C, wmOperator *op) ANIM_apply_keyingset(C, NULL, act, ks, MODIFYKEY_MODE_INSERT, (float)frame); /* store new 'active' pose number */ - act->active_marker= BLI_countlist(&act->markers); + act->active_marker = BLI_countlist(&act->markers); /* done */ return OPERATOR_FINISHED; @@ -496,7 +496,7 @@ void POSELIB_OT_pose_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "frame", 1, 0, INT_MAX, "Frame", "Frame to store pose on", 0, INT_MAX); @@ -511,9 +511,9 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS Object *ob = get_poselib_object(C); bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; - EnumPropertyItem *item= NULL, item_tmp= {0}; - int totitem= 0; - int i= 0; + EnumPropertyItem *item = NULL, item_tmp = {0}; + int totitem = 0; + int i = 0; if (C == NULL) { return DummyRNA_NULL_items; @@ -522,24 +522,24 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *UNUS /* check that the action exists */ if (act) { /* add each marker to the list */ - for (marker=act->markers.first, i=0; marker; marker= marker->next, i++) { - item_tmp.identifier= item_tmp.name= marker->name; - item_tmp.icon= ICON_ARMATURE_DATA; - item_tmp.value= i; + for (marker = act->markers.first, i = 0; marker; marker = marker->next, i++) { + item_tmp.identifier = item_tmp.name = marker->name; + item_tmp.icon = ICON_ARMATURE_DATA; + item_tmp.value = i; RNA_enum_item_add(&item, &totitem, &item_tmp); } } RNA_enum_item_end(&item, &totitem); - *free= 1; + *free = 1; return item; } -static int poselib_remove_exec (bContext *C, wmOperator *op) +static int poselib_remove_exec(bContext *C, wmOperator *op) { - Object *ob= get_poselib_object(C); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; int marker_index; FCurve *fcu; @@ -567,12 +567,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) } /* remove relevant keyframes */ - for (fcu= act->curves.first; fcu; fcu= fcu->next) { + for (fcu = act->curves.first; fcu; fcu = fcu->next) { BezTriple *bezt; unsigned int i; if (fcu->bezt) { - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* check if remove */ if (IS_EQ(bezt->vec[1][0], marker->frame)) { delete_fcurve_key(fcu, i, 1); @@ -586,12 +586,12 @@ static int poselib_remove_exec (bContext *C, wmOperator *op) BLI_freelinkN(&act->markers, marker); /* fix active pose number */ - act->active_marker= 0; + act->active_marker = 0; /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -612,7 +612,7 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ prop = RNA_def_enum(ot->srna, "pose", DummyRNA_NULL_items, 0, "Pose", "The pose to remove"); @@ -620,10 +620,10 @@ void POSELIB_OT_pose_remove(wmOperatorType *ot) ot->prop = prop; } -static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int poselib_rename_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= get_poselib_object(C); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = get_poselib_object(C); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; /* check if valid poselib */ @@ -633,14 +633,14 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, act->active_marker-1); + marker = BLI_findlink(&act->markers, act->active_marker - 1); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; } else { /* use the existing name of the marker as the name, and use the active marker as the one to rename */ - RNA_enum_set(op->ptr, "pose", act->active_marker-1); + RNA_enum_set(op->ptr, "pose", act->active_marker - 1); RNA_string_set(op->ptr, "name", marker->name); } @@ -648,10 +648,10 @@ static int poselib_rename_invoke (bContext *C, wmOperator *op, wmEvent *evt) return WM_operator_props_popup(C, op, evt); } -static int poselib_rename_exec (bContext *C, wmOperator *op) +static int poselib_rename_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bAction *act= (ob) ? ob->poselib : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bAction *act = (ob) ? ob->poselib : NULL; TimeMarker *marker; char newname[64]; @@ -662,7 +662,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) } /* get index (and pointer) of pose to remove */ - marker= BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); + marker = BLI_findlink(&act->markers, RNA_int_get(op->ptr, "pose")); if (marker == NULL) { BKE_report(op->reports, RPT_ERROR, "Invalid index for Pose"); return OPERATOR_CANCELLED; @@ -678,7 +678,7 @@ static int poselib_rename_exec (bContext *C, wmOperator *op) /* send notifiers for this - using keyframe editing notifiers, since action * may be being shown in anim editors as active action */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -702,13 +702,13 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ + /* NOTE: name not pose is the operator's "main" property, so that it will get activated in the popup for easy renaming */ ot->prop = RNA_def_string(ot->srna, "name", "RenamedPose", 64, "New Pose Name", "New name for pose"); - prop= RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); - RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); + prop = RNA_def_enum(ot->srna, "pose", prop_poses_dummy_types, 0, "Pose", "The pose to rename"); + RNA_def_enum_funcs(prop, poselib_stored_pose_itemf); } /* ************************************************************* */ @@ -716,31 +716,31 @@ void POSELIB_OT_pose_rename(wmOperatorType *ot) /* Simple struct for storing settings/data for use during PoseLib preview */ typedef struct tPoseLib_PreviewData { - ListBase backups; /* tPoseLib_Backup structs for restoring poses */ - ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ + ListBase backups; /* tPoseLib_Backup structs for restoring poses */ + ListBase searchp; /* LinkData structs storing list of poses which match the current search-string */ - Scene *scene; /* active scene */ - ScrArea *sa; /* active area */ + Scene *scene; /* active scene */ + ScrArea *sa; /* active area */ - PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ - Object *ob; /* object to work on */ - bArmature *arm; /* object's armature data */ - bPose *pose; /* object's pose */ - bAction *act; /* poselib to use */ - TimeMarker *marker; /* 'active' pose */ + PointerRNA rna_ptr; /* RNA-Pointer to Object 'ob' */ + Object *ob; /* object to work on */ + bArmature *arm; /* object's armature data */ + bPose *pose; /* object's pose */ + bAction *act; /* poselib to use */ + TimeMarker *marker; /* 'active' pose */ + + int selcount; /* number of selected elements to work on */ + int totcount; /* total number of elements to work on */ + + short state; /* state of main loop */ + short redraw; /* redraw/update settings during main loop */ + short flag; /* flags for various settings */ + + short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ + char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ + char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ - int selcount; /* number of selected elements to work on */ - int totcount; /* total number of elements to work on */ - - short state; /* state of main loop */ - short redraw; /* redraw/update settings during main loop */ - short flag; /* flags for various settings */ - - short search_cursor; /* position of cursor in searchstr (cursor occurs before the item at the nominated index) */ - char searchstr[64]; /* (Part of) Name to search for to filter poses that get shown */ - char searchold[64]; /* Previously set searchstr (from last loop run), so that we can detected when to rebuild searchp */ - - char headerstr[200]; /* Info-text to print in header */ + char headerstr[200]; /* Info-text to print in header */ } tPoseLib_PreviewData; /* defines for tPoseLib_PreviewData->state values */ @@ -761,8 +761,8 @@ enum { /* defines for tPoseLib_PreviewData->flag values */ enum { - PL_PREVIEW_FIRSTTIME = (1<<0), - PL_PREVIEW_SHOWORIGINAL = (1<<1) + PL_PREVIEW_FIRSTTIME = (1 << 0), + PL_PREVIEW_SHOWORIGINAL = (1 << 1) }; /* ---------------------------- */ @@ -771,35 +771,35 @@ enum { typedef struct tPoseLib_Backup { struct tPoseLib_Backup *next, *prev; - bPoseChannel *pchan; /* pose channel backups are for */ + bPoseChannel *pchan; /* pose channel backups are for */ - bPoseChannel olddata; /* copy of pose channel's old data (at start) */ - IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ + bPoseChannel olddata; /* copy of pose channel's old data (at start) */ + IDProperty *oldprops; /* copy (needs freeing) of pose channel's properties (at start) */ } tPoseLib_Backup; /* Makes a copy of the current pose for restoration purposes - doesn't do constraints currently */ -static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) +static void poselib_backup_posecopy(tPoseLib_PreviewData *pld) { bActionGroup *agrp; bPoseChannel *pchan; /* for each posechannel that has an actionchannel in */ - for (agrp= pld->act->groups.first; agrp; agrp= agrp->next) { + for (agrp = pld->act->groups.first; agrp; agrp = agrp->next) { /* try to find posechannel */ - pchan= get_pose_channel(pld->pose, agrp->name); + pchan = BKE_pose_channel_find_name(pld->pose, agrp->name); /* backup data if available */ if (pchan) { tPoseLib_Backup *plb; /* store backup */ - plb= MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); + plb = MEM_callocN(sizeof(tPoseLib_Backup), "tPoseLib_Backup"); - plb->pchan= pchan; + plb->pchan = pchan; memcpy(&plb->olddata, plb->pchan, sizeof(bPoseChannel)); if (pchan->prop) - plb->oldprops= IDP_CopyProperty(pchan->prop); + plb->oldprops = IDP_CopyProperty(pchan->prop); BLI_addtail(&pld->backups, plb); @@ -812,11 +812,11 @@ static void poselib_backup_posecopy (tPoseLib_PreviewData *pld) } /* Restores original pose */ -static void poselib_backup_restore (tPoseLib_PreviewData *pld) +static void poselib_backup_restore(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb; - for (plb= pld->backups.first; plb; plb= plb->next) { + for (plb = pld->backups.first; plb; plb = plb->next) { /* copy most of data straight back */ memcpy(plb->pchan, &plb->olddata, sizeof(bPoseChannel)); @@ -829,12 +829,12 @@ static void poselib_backup_restore (tPoseLib_PreviewData *pld) } /* Free list of backups, including any side data it may use */ -static void poselib_backup_free_data (tPoseLib_PreviewData *pld) +static void poselib_backup_free_data(tPoseLib_PreviewData *pld) { tPoseLib_Backup *plb, *plbn; - for (plb= pld->backups.first; plb; plb= plbn) { - plbn= plb->next; + for (plb = pld->backups.first; plb; plb = plbn) { + plbn = plb->next; /* free custom data */ if (plb->oldprops) { @@ -852,48 +852,48 @@ static void poselib_backup_free_data (tPoseLib_PreviewData *pld) /* Applies the appropriate stored pose from the pose-library to the current pose * - assumes that a valid object, with a poselib has been supplied * - gets the string to print in the header - * - this code is based on the code for extract_pose_from_action in blenkernel/action.c + * - this code is based on the code for extract_pose_from_action in blenkernel/action.c */ -static void poselib_apply_pose (tPoseLib_PreviewData *pld) +static void poselib_apply_pose(tPoseLib_PreviewData *pld) { - PointerRNA *ptr= &pld->rna_ptr; - bArmature *arm= pld->arm; - bPose *pose= pld->pose; + PointerRNA *ptr = &pld->rna_ptr; + bArmature *arm = pld->arm; + bPose *pose = pld->pose; bPoseChannel *pchan; - bAction *act= pld->act; + bAction *act = pld->act; bActionGroup *agrp; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc group_ok_cb; - int frame= 1; + int frame = 1; /* get the frame */ if (pld->marker) - frame= pld->marker->frame; + frame = pld->marker->frame; else return; /* init settings for testing groups for keyframes */ - group_ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - ked.f1= ((float)frame) - 0.5f; - ked.f2= ((float)frame) + 0.5f; + group_ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + ked.f1 = ((float)frame) - 0.5f; + ked.f2 = ((float)frame) + 0.5f; /* start applying - only those channels which have a key at this point in time! */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* check if group has any keyframes */ if (ANIM_animchanneldata_keyframes_loop(&ked, NULL, agrp, ALE_GROUP, NULL, group_ok_cb, NULL)) { /* has keyframe on this frame, so try to get a PoseChannel with this name */ - pchan= get_pose_channel(pose, agrp->name); + pchan = BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { - short ok= 0; + short ok = 0; /* check if this bone should get any animation applied */ if (pld->selcount == 0) { /* if no bones are selected, then any bone is ok */ - ok= 1; + ok = 1; } else if (pchan->bone) { /* only ok if bone is visible and selected */ @@ -913,11 +913,11 @@ static void poselib_apply_pose (tPoseLib_PreviewData *pld) } /* Auto-keys/tags bones affected by the pose used from the poselib */ -static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData *pld) +static void poselib_keytag_pose(bContext *C, Scene *scene, tPoseLib_PreviewData *pld) { - bPose *pose= pld->pose; + bPose *pose = pld->pose; bPoseChannel *pchan; - bAction *act= pld->act; + bAction *act = pld->act; bActionGroup *agrp; KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_WHOLE_CHARACTER_ID); @@ -925,9 +925,9 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData short autokey = autokeyframe_cfra_can_key(scene, &pld->ob->id); /* start tagging/keying */ - for (agrp= act->groups.first; agrp; agrp= agrp->next) { + for (agrp = act->groups.first; agrp; agrp = agrp->next) { /* only for selected bones unless there aren't any selected, in which case all are included */ - pchan= get_pose_channel(pose, agrp->name); + pchan = BKE_pose_channel_find_name(pose, agrp->name); if (pchan) { if ( (pld->selcount == 0) || ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) ) { @@ -956,38 +956,38 @@ static void poselib_keytag_pose (bContext *C, Scene *scene, tPoseLib_PreviewData } /* send notifiers for this */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } /* Apply the relevant changes to the pose */ -static void poselib_preview_apply (bContext *C, wmOperator *op) +static void poselib_preview_apply(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; + tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; /* only recalc pose (and its dependencies) if pose has changed */ if (pld->redraw == PL_PREVIEW_REDRAWALL) { /* don't clear pose if firsttime */ - if ((pld->flag & PL_PREVIEW_FIRSTTIME)==0) + if ((pld->flag & PL_PREVIEW_FIRSTTIME) == 0) poselib_backup_restore(pld); else pld->flag &= ~PL_PREVIEW_FIRSTTIME; /* pose should be the right one to draw (unless we're temporarily not showing it) */ - if ((pld->flag & PL_PREVIEW_SHOWORIGINAL)==0) { + if ((pld->flag & PL_PREVIEW_SHOWORIGINAL) == 0) { RNA_int_set(op->ptr, "pose_index", BLI_findindex(&pld->act->markers, pld->marker)); poselib_apply_pose(pld); } else - RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ + RNA_int_set(op->ptr, "pose_index", -2); /* -2 means don't apply any pose */ /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ // FIXME: shouldn't this use the builtin stuff? - if ((pld->arm->flag & ARM_DELAYDEFORM)==0) + if ((pld->arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&pld->ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(pld->scene, pld->ob); + BKE_pose_where_is(pld->scene, pld->ob); } /* do header print - if interactively previewing */ @@ -1004,12 +1004,12 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) short index; /* get search-string */ - index= pld->search_cursor; + index = pld->search_cursor; if (index >= 0 && index <= sizeof(tempstr) - 1) { memcpy(&tempstr[0], &pld->searchstr[0], index); - tempstr[index]= '|'; - memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); + tempstr[index] = '|'; + memcpy(&tempstr[index + 1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index); } else { BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr)); @@ -1035,8 +1035,8 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) } /* request drawing of view + clear redraw flag */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, pld->ob); - pld->redraw= PL_PREVIEW_NOREDRAW; + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, pld->ob); + pld->redraw = PL_PREVIEW_NOREDRAW; } /* ---------------------------- */ @@ -1044,7 +1044,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op) /* This helper function is called during poselib_preview_poses to find the * pose to preview next (after a change event) */ -static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step) +static void poselib_preview_get_next(tPoseLib_PreviewData *pld, int step) { /* stop if not going anywhere, as we assume that there is a direction to move in */ if (step == 0) @@ -1061,91 +1061,91 @@ static void poselib_preview_get_next (tPoseLib_PreviewData *pld, int step) BLI_freelistN(&pld->searchp); /* generate a new list of search matches */ - for (marker= pld->act->markers.first; marker; marker= marker->next) { + for (marker = pld->act->markers.first; marker; marker = marker->next) { /* does the name partially match? - * - don't worry about case, to make it easier for users to quickly input a name (or + * - don't worry about case, to make it easier for users to quickly input a name (or * part of one), which is the whole point of this feature */ if (BLI_strcasestr(marker->name, pld->searchstr)) { /* make link-data to store reference to it */ - ld= MEM_callocN(sizeof(LinkData), "PoseMatch"); - ld->data= marker; + ld = MEM_callocN(sizeof(LinkData), "PoseMatch"); + ld->data = marker; BLI_addtail(&pld->searchp, ld); } } /* set current marker to NULL (so that we start from first) */ - pld->marker= NULL; + pld->marker = NULL; } /* check if any matches */ if (pld->searchp.first == NULL) { - pld->marker= NULL; + pld->marker = NULL; return; } /* find first match */ - for (ldc= pld->searchp.first; ldc; ldc= ldc->next) { + for (ldc = pld->searchp.first; ldc; ldc = ldc->next) { if (ldc->data == pld->marker) break; } if (ldc == NULL) - ldc= pld->searchp.first; + ldc = pld->searchp.first; /* Loop through the matches in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { - for (ld=ldc; ld && step; ld=ldn, step--) - ldn= (ld->next) ? ld->next : pld->searchp.first; + for (ld = ldc; ld && step; ld = ldn, step--) + ldn = (ld->next) ? ld->next : pld->searchp.first; } else { - for (ld=ldc; ld && step; ld=ldn, step++) - ldn= (ld->prev) ? ld->prev : pld->searchp.last; + for (ld = ldc; ld && step; ld = ldn, step++) + ldn = (ld->prev) ? ld->prev : pld->searchp.last; } /* set marker */ if (ld) - pld->marker= ld->data; + pld->marker = ld->data; } else { TimeMarker *marker, *next; /* if no marker, because we just ended searching, then set that to the start of the list */ if (pld->marker == NULL) - pld->marker= pld->act->markers.first; + pld->marker = pld->act->markers.first; /* Loop through the markers in a cyclic fashion, incrementing/decrementing step as appropriate * until step == 0. At this point, marker should be the correct marker. */ if (step > 0) { - for (marker=pld->marker; marker && step; marker=next, step--) - next= (marker->next) ? marker->next : pld->act->markers.first; + for (marker = pld->marker; marker && step; marker = next, step--) + next = (marker->next) ? marker->next : pld->act->markers.first; } else { - for (marker=pld->marker; marker && step; marker=next, step++) - next= (marker->prev) ? marker->prev : pld->act->markers.last; + for (marker = pld->marker; marker && step; marker = next, step++) + next = (marker->prev) ? marker->prev : pld->act->markers.last; } /* it should be fairly impossible for marker to be NULL */ if (marker) - pld->marker= marker; + pld->marker = marker; } } /* specially handle events for searching */ -static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned short event, char ascii) +static void poselib_preview_handle_search(tPoseLib_PreviewData *pld, unsigned short event, char ascii) { /* try doing some form of string manipulation first */ switch (event) { case BACKSPACEKEY: if (pld->searchstr[0] && pld->search_cursor) { - short len= strlen(pld->searchstr); - short index= pld->search_cursor; + short len = strlen(pld->searchstr); + short index = pld->search_cursor; short i; for (i = index; i <= len; i++) - pld->searchstr[i-1] = pld->searchstr[i]; + pld->searchstr[i - 1] = pld->searchstr[i]; pld->search_cursor--; @@ -1157,13 +1157,13 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s case DELKEY: if (pld->searchstr[0] && pld->searchstr[1]) { - short len= strlen(pld->searchstr); - short index= pld->search_cursor; + short len = strlen(pld->searchstr); + short index = pld->search_cursor; int i; if (index < len) { for (i = index; i < len; i++) - pld->searchstr[i] = pld->searchstr[i+1]; + pld->searchstr[i] = pld->searchstr[i + 1]; poselib_preview_get_next(pld, 1); pld->redraw = PL_PREVIEW_REDRAWALL; @@ -1175,18 +1175,18 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s if (ascii) { /* character to add to the string */ - short index= pld->search_cursor; - short len= (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; + short index = pld->search_cursor; + short len = (pld->searchstr[0]) ? strlen(pld->searchstr) : 0; short i; if (len) { for (i = len; i > index; i--) - pld->searchstr[i]= pld->searchstr[i-1]; + pld->searchstr[i] = pld->searchstr[i - 1]; } else - pld->searchstr[1]= 0; + pld->searchstr[1] = 0; - pld->searchstr[index]= ascii; + pld->searchstr[index] = ascii; pld->search_cursor++; poselib_preview_get_next(pld, 1); @@ -1195,9 +1195,9 @@ static void poselib_preview_handle_search (tPoseLib_PreviewData *pld, unsigned s } /* handle events for poselib_preview_poses */ -static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wmEvent *event) +static int poselib_preview_handle_event(bContext *UNUSED(C), wmOperator *op, wmEvent *event) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int ret = OPERATOR_RUNNING_MODAL; /* only accept 'press' event, and ignore 'release', so that we don't get double actions */ @@ -1217,7 +1217,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* exit - cancel */ case ESCKEY: case RIGHTMOUSE: - pld->state= PL_PREVIEW_CANCEL; + pld->state = PL_PREVIEW_CANCEL; break; /* exit - confirm */ @@ -1225,7 +1225,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm case RETKEY: case PADENTER: case SPACEKEY: - pld->state= PL_PREVIEW_CONFIRM; + pld->state = PL_PREVIEW_CONFIRM; break; /* view manipulation */ @@ -1243,7 +1243,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* quicky compare to original */ case TABKEY: pld->flag &= ~PL_PREVIEW_SHOWORIGINAL; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; } @@ -1257,7 +1257,7 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* exit - cancel */ case ESCKEY: case RIGHTMOUSE: - pld->state= PL_PREVIEW_CANCEL; + pld->state = PL_PREVIEW_CANCEL; break; /* exit - confirm */ @@ -1265,39 +1265,39 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm case RETKEY: case PADENTER: case SPACEKEY: - pld->state= PL_PREVIEW_CONFIRM; + pld->state = PL_PREVIEW_CONFIRM; break; /* toggle between original pose and poselib pose*/ case TABKEY: pld->flag |= PL_PREVIEW_SHOWORIGINAL; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to previous pose (cyclic) */ case PAGEUPKEY: case WHEELUPMOUSE: poselib_preview_get_next(pld, -1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to next pose (cyclic) */ case PAGEDOWNKEY: case WHEELDOWNMOUSE: poselib_preview_get_next(pld, 1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* jump 5 poses (cyclic, back) */ case DOWNARROWKEY: poselib_preview_get_next(pld, -5); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* jump 5 poses (cyclic, forward) */ case UPARROWKEY: poselib_preview_get_next(pld, 5); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; break; /* change to next pose or searching cursor control */ @@ -1306,12 +1306,12 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* move text-cursor to the right */ if (pld->search_cursor < strlen(pld->searchstr)) pld->search_cursor++; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to next pose (cyclic) */ poselib_preview_get_next(pld, 1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; @@ -1321,42 +1321,42 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* move text-cursor to the left */ if (pld->search_cursor) pld->search_cursor--; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to previous pose (cyclic) */ poselib_preview_get_next(pld, -1); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; /* change to first pose or start of searching string */ case HOMEKEY: if (pld->searchstr[0]) { - pld->search_cursor= 0; - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->search_cursor = 0; + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to first pose */ - pld->marker= pld->act->markers.first; - pld->act->active_marker= 1; + pld->marker = pld->act->markers.first; + pld->act->active_marker = 1; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; /* change to last pose or start of searching string */ case ENDKEY: if (pld->searchstr[0]) { - pld->search_cursor= strlen(pld->searchstr); - pld->redraw= PL_PREVIEW_REDRAWHEADER; + pld->search_cursor = strlen(pld->searchstr); + pld->redraw = PL_PREVIEW_REDRAWHEADER; } else { /* change to last pose */ - pld->marker= pld->act->markers.last; - pld->act->active_marker= BLI_countlist(&pld->act->markers); + pld->marker = pld->act->markers.last; + pld->act->active_marker = BLI_countlist(&pld->act->markers); - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->redraw = PL_PREVIEW_REDRAWALL; } break; @@ -1396,53 +1396,53 @@ static int poselib_preview_handle_event (bContext *UNUSED(C), wmOperator *op, wm /* ---------------------------- */ /* Init PoseLib Previewing data */ -static void poselib_preview_init_data (bContext *C, wmOperator *op) +static void poselib_preview_init_data(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; - Object *ob= get_poselib_object(C); + Object *ob = get_poselib_object(C); int pose_index = RNA_int_get(op->ptr, "pose_index"); /* set up preview state info */ - op->customdata= pld= MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); + op->customdata = pld = MEM_callocN(sizeof(tPoseLib_PreviewData), "PoseLib Preview Data"); /* get basic data */ - pld->ob= ob; - pld->arm= (ob) ? (ob->data) : NULL; - pld->pose= (ob) ? (ob->pose) : NULL; - pld->act= (ob) ? (ob->poselib) : NULL; + pld->ob = ob; + pld->arm = (ob) ? (ob->data) : NULL; + pld->pose = (ob) ? (ob->pose) : NULL; + pld->act = (ob) ? (ob->poselib) : NULL; - pld->scene= CTX_data_scene(C); - pld->sa= CTX_wm_area(C); + pld->scene = CTX_data_scene(C); + pld->sa = CTX_wm_area(C); /* get starting pose based on RNA-props for this operator */ if (pose_index == -1) - pld->marker= poselib_get_active_pose(pld->act); + pld->marker = poselib_get_active_pose(pld->act); else if (pose_index == -2) pld->flag |= PL_PREVIEW_SHOWORIGINAL; else - pld->marker= (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; + pld->marker = (pld->act) ? BLI_findlink(&pld->act->markers, pose_index) : NULL; /* check if valid poselib */ if (ELEM3(NULL, pld->ob, pld->pose, pld->arm)) { BKE_report(op->reports, RPT_ERROR, "PoseLib is only for Armatures in PoseMode"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } if (pld->act == NULL) { BKE_report(op->reports, RPT_ERROR, "Object doesn't have a valid PoseLib"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } if (pld->marker == NULL) { if (pld->act->markers.first) { /* just use first one then... */ - pld->marker= pld->act->markers.first; + pld->marker = pld->act->markers.first; if (pose_index > -2) BKE_report(op->reports, RPT_WARNING, "PoseLib had no active pose"); } else { BKE_report(op->reports, RPT_ERROR, "PoseLib has no poses to preview/apply"); - pld->state= PL_PREVIEW_ERROR; + pld->state = PL_PREVIEW_ERROR; return; } } @@ -1454,30 +1454,30 @@ static void poselib_preview_init_data (bContext *C, wmOperator *op) poselib_backup_posecopy(pld); /* set flags for running */ - pld->state= PL_PREVIEW_RUNNING; - pld->redraw= PL_PREVIEW_REDRAWALL; + pld->state = PL_PREVIEW_RUNNING; + pld->redraw = PL_PREVIEW_REDRAWALL; pld->flag |= PL_PREVIEW_FIRSTTIME; /* set depsgraph flags */ - /* make sure the lock is set OK, unlock can be accidentally saved? */ + /* make sure the lock is set OK, unlock can be accidentally saved? */ pld->pose->flag |= POSE_LOCKED; pld->pose->flag &= ~POSE_DO_UNLOCK; /* clear strings + search */ - pld->headerstr[0]= pld->searchstr[0]= pld->searchold[0]= '\0'; - pld->search_cursor= 0; + pld->headerstr[0] = pld->searchstr[0] = pld->searchold[0] = '\0'; + pld->search_cursor = 0; } /* After previewing poses */ -static void poselib_preview_cleanup (bContext *C, wmOperator *op) +static void poselib_preview_cleanup(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= (tPoseLib_PreviewData *)op->customdata; - Scene *scene= pld->scene; - Object *ob= pld->ob; - bPose *pose= pld->pose; - bArmature *arm= pld->arm; - bAction *act= pld->act; - TimeMarker *marker= pld->marker; + tPoseLib_PreviewData *pld = (tPoseLib_PreviewData *)op->customdata; + Scene *scene = pld->scene; + Object *ob = pld->ob; + bPose *pose = pld->pose; + bArmature *arm = pld->arm; + bAction *act = pld->act; + TimeMarker *marker = pld->marker; /* redraw the header so that it doesn't show any of our stuff anymore */ ED_area_headerprint(pld->sa, NULL); @@ -1492,10 +1492,10 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) /* old optimize trick... this enforces to bypass the depgraph * - note: code copied from transform_generics.c -> recalcData() */ - if ((arm->flag & ARM_DELAYDEFORM)==0) + if ((arm->flag & ARM_DELAYDEFORM) == 0) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } else if (pld->state == PL_PREVIEW_CONFIRM) { @@ -1503,7 +1503,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) poselib_keytag_pose(C, scene, pld); /* change active pose setting */ - act->active_marker= BLI_findindex(&act->markers, marker) + 1; + act->active_marker = BLI_findindex(&act->markers, marker) + 1; action_set_activemarker(act, marker, NULL); /* Update event for pose and deformation children */ @@ -1514,7 +1514,7 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) //remake_action_ipos(ob->action); } else - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } /* free memory used for backups and searching */ @@ -1523,13 +1523,13 @@ static void poselib_preview_cleanup (bContext *C, wmOperator *op) /* free temp data for operator */ MEM_freeN(pld); - op->customdata= NULL; + op->customdata = NULL; } /* End previewing operation */ -static int poselib_preview_exit (bContext *C, wmOperator *op) +static int poselib_preview_exit(bContext *C, wmOperator *op) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int exit_state = pld->state; /* finish up */ @@ -1542,16 +1542,16 @@ static int poselib_preview_exit (bContext *C, wmOperator *op) } /* Cancel previewing operation (called when exiting Blender) */ -static int poselib_preview_cancel (bContext *C, wmOperator *op) +static int poselib_preview_cancel(bContext *C, wmOperator *op) { poselib_preview_exit(C, op); return OPERATOR_CANCELLED; } /* main modal status check */ -static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event) +static int poselib_preview_modal(bContext *C, wmOperator *op, wmEvent *event) { - tPoseLib_PreviewData *pld= op->customdata; + tPoseLib_PreviewData *pld = op->customdata; int ret; /* 1) check state to see if we're still running */ @@ -1559,7 +1559,7 @@ static int poselib_preview_modal (bContext *C, wmOperator *op, wmEvent *event) return poselib_preview_exit(C, op); /* 2) handle events */ - ret= poselib_preview_handle_event(C, op, event); + ret = poselib_preview_handle_event(C, op, event); /* 3) apply changes and redraw, otherwise, confirming goes wrong */ if (pld->redraw) @@ -1575,7 +1575,7 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); - pld= (tPoseLib_PreviewData *)op->customdata; + pld = (tPoseLib_PreviewData *)op->customdata; if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ @@ -1593,13 +1593,13 @@ static int poselib_preview_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(e } /* Repeat operator */ -static int poselib_preview_exec (bContext *C, wmOperator *op) +static int poselib_preview_exec(bContext *C, wmOperator *op) { tPoseLib_PreviewData *pld; /* check if everything is ok, and init settings for modal operator */ poselib_preview_init_data(C, op); - pld= (tPoseLib_PreviewData *)op->customdata; + pld = (tPoseLib_PreviewData *)op->customdata; if (pld->state == PL_PREVIEW_ERROR) { /* an error occurred, so free temp mem used */ @@ -1637,10 +1637,10 @@ void POSELIB_OT_browse_interactive(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); // XXX: percentage vs factor? @@ -1660,9 +1660,9 @@ void POSELIB_OT_apply_pose(wmOperatorType *ot) ot->poll = has_poselib_pose_data_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - // TODO: make the pose_index into a proper enum instead of a cryptic int... + // TODO: make the pose_index into a proper enum instead of a cryptic int... ot->prop = RNA_def_int(ot->srna, "pose_index", -1, -2, INT_MAX, "Pose", "Index of the pose to apply (-2 for no change to pose, -1 for poselib active pose)", 0, INT_MAX); } diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c index 8a2af14e6f3..e9c960c4080 100644 --- a/source/blender/editors/armature/poseobject.c +++ b/source/blender/editors/armature/poseobject.c @@ -83,8 +83,8 @@ /* This function is used to process the necessary updates for */ void ED_armature_enter_posemode(bContext *C, Base *base) { - ReportList *reports= CTX_wm_reports(C); - Object *ob= base->object; + ReportList *reports = CTX_wm_reports(C); + Object *ob = base->object; if (ob->id.lib) { BKE_report(reports, RPT_WARNING, "Can't pose libdata"); @@ -96,7 +96,7 @@ void ED_armature_enter_posemode(bContext *C, Base *base) ob->restore_mode = ob->mode; ob->mode |= OB_MODE_POSE; - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_POSE, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_POSE, NULL); break; default: @@ -110,12 +110,12 @@ void ED_armature_enter_posemode(bContext *C, Base *base) void ED_armature_exit_posemode(bContext *C, Base *base) { if (base) { - Object *ob= base->object; + Object *ob = base->object; ob->restore_mode = ob->mode; ob->mode &= ~OB_MODE_POSE; - WM_event_add_notifier(C, NC_SCENE|ND_MODE|NS_MODE_OBJECT, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MODE | NS_MODE_OBJECT, NULL); } } @@ -127,13 +127,13 @@ static short pose_has_protected_selected(Object *ob, short warn) /* check protection */ if (ob->proxy) { bPoseChannel *pchan; - bArmature *arm= ob->data; + bArmature *arm = ob->data; - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone && (pchan->bone->layer & arm->layer)) { if (pchan->bone->layer & arm->layer_protected) { if (pchan->bone->flag & BONE_SELECTED) - break; + break; } } } @@ -154,17 +154,17 @@ static int pose_channel_in_IK_chain(Object *ob, bPoseChannel *pchan, int level) /* No need to check if constraint is active (has influence), * since all constraints with CONSTRAINT_IK_AUTO are active */ - for (con= pchan->constraints.first; con; con= con->next) { - if (con->type==CONSTRAINT_TYPE_KINEMATIC) { - bKinematicConstraint *data= con->data; + for (con = pchan->constraints.first; con; con = con->next) { + if (con->type == CONSTRAINT_TYPE_KINEMATIC) { + bKinematicConstraint *data = con->data; if (data->rootbone == 0 || data->rootbone > level) { - if ((data->flag & CONSTRAINT_IK_AUTO)==0) + if ((data->flag & CONSTRAINT_IK_AUTO) == 0) return 1; } } } - for (bone= pchan->bone->childbase.first; bone; bone= bone->next) { - pchan= get_pose_channel(ob->pose, bone->name); + for (bone = pchan->bone->childbase.first; bone; bone = bone->next) { + pchan = BKE_pose_channel_find_name(ob->pose, bone->name); if (pchan && pose_channel_in_IK_chain(ob, pchan, level + 1)) return 1; } @@ -197,10 +197,11 @@ void ED_pose_recalculate_paths(Scene *scene, Object *ob) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -227,8 +228,8 @@ static int pose_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNU */ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); - Scene *scene= CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; @@ -246,7 +247,7 @@ static int pose_calculate_paths_exec(bContext *C, wmOperator *op) } /* set up path data for bones being calculated */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* verify makes sure that the selected bone has a bone with the appropriate settings */ animviz_verify_motionpaths(op->reports, scene, ob, pchan); @@ -276,17 +277,52 @@ void POSE_OT_paths_calculate(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "start_frame", 1, MINAFRAME, MAXFRAME, "Start", - "First frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0); + "First frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0); RNA_def_int(ot->srna, "end_frame", 250, MINAFRAME, MAXFRAME, "End", - "Last frame to calculate bone paths on", MINFRAME, MAXFRAME/2.0); + "Last frame to calculate bone paths on", MINFRAME, MAXFRAME / 2.0); RNA_def_enum(ot->srna, "bake_location", motionpath_bake_location_items, 0, "Bake Location", - "Which point on the bones is used when calculating paths"); + "Which point on the bones is used when calculating paths"); +} + +/* --------- */ + +static int pose_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + + if (ELEM(NULL, ob, scene)) + return OPERATOR_CANCELLED; + + /* calculate the bones that now have motionpaths... */ + // TODO: only make for the selected bones? + ED_pose_recalculate_paths(scene, ob); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); + + return OPERATOR_FINISHED; +} + +void POSE_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Bone Paths"; + ot->idname = "POSE_OT_paths_update"; + ot->description = "Recalculate paths for bones that already have them"; + + /* api callbakcs */ + ot->exec = pose_update_paths_exec; + ot->poll = ED_operator_posemode; /* TODO: this should probably check for active bone and/or existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* --------- */ @@ -301,11 +337,11 @@ static void ED_pose_clear_paths(Object *ob) return; /* free the motionpath blocks, but also take note of whether we skipped some... */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->mpath) { if ((pchan->bone) && (pchan->bone->flag & BONE_SELECTED)) { animviz_free_motionpath(pchan->mpath); - pchan->mpath= NULL; + pchan->mpath = NULL; } else skipped = 1; @@ -318,9 +354,9 @@ static void ED_pose_clear_paths(Object *ob) } /* operator callback for this */ -static int pose_clear_paths_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_clear_paths_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ELEM(NULL, ob, ob->pose)) @@ -347,34 +383,34 @@ void POSE_OT_paths_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************* Select Constraint Target Operator ************* */ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bConstraint *con; - int found= 0; + int found = 0; CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { if (pchan->bone->flag & BONE_SELECTED) { - for (con= pchan->constraints.first; con; con= con->next) { - bConstraintTypeInfo *cti= constraint_get_typeinfo(con); + for (con = pchan->constraints.first; con; con = con->next) { + bConstraintTypeInfo *cti = constraint_get_typeinfo(con); ListBase targets = {NULL, NULL}; bConstraintTarget *ct; if (cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); - for (ct= targets.first; ct; ct= ct->next) { + for (ct = targets.first; ct; ct = ct->next) { if ((ct->tar == ob) && (ct->subtarget[0])) { - bPoseChannel *pchanc= get_pose_channel(ob->pose, ct->subtarget); + bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct->subtarget); if ((pchanc) && !(pchanc->bone->flag & BONE_UNSELECTABLE)) { - pchanc->bone->flag |= BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; - found= 1; + pchanc->bone->flag |= BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; + found = 1; } } } @@ -390,7 +426,7 @@ static int pose_select_constraint_target_exec(bContext *C, wmOperator *UNUSED(op if (!found) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -407,36 +443,36 @@ void POSE_OT_select_constraint_target(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************* select hierarchy operator ************* */ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= ob->data; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = ob->data; Bone *curbone, *pabone, *chbone; int direction = RNA_enum_get(op->ptr, "direction"); int add_to_sel = RNA_boolean_get(op->ptr, "extend"); - int found= 0; + int found = 0; CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - curbone= pchan->bone; + curbone = pchan->bone; - if ((curbone->flag & BONE_UNSELECTABLE)==0) { + if ((curbone->flag & BONE_UNSELECTABLE) == 0) { if (curbone == arm->act_bone) { if (direction == BONE_SELECT_PARENT) { if (pchan->parent == NULL) continue; - else pabone= pchan->parent->bone; + else pabone = pchan->parent->bone; if (PBONE_VISIBLE(arm, pabone)) { if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; pabone->flag |= BONE_SELECTED; - arm->act_bone= pabone; + arm->act_bone = pabone; - found= 1; + found = 1; break; } } @@ -469,9 +505,9 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) if (PBONE_VISIBLE(arm, chbone)) { if (!add_to_sel) curbone->flag &= ~BONE_SELECTED; chbone->flag |= BONE_SELECTED; - arm->act_bone= chbone; + arm->act_bone = chbone; - found= 1; + found = 1; break; } } @@ -483,14 +519,14 @@ static int pose_select_hierarchy_exec(bContext *C, wmOperator *op) if (found == 0) return OPERATOR_CANCELLED; - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } void POSE_OT_select_hierarchy(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { + static EnumPropertyItem direction_items[] = { {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""}, {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""}, {0, NULL, 0, NULL, NULL} @@ -506,7 +542,7 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_enum(ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", ""); @@ -516,39 +552,39 @@ void POSE_OT_select_hierarchy(wmOperatorType *ot) /* ******************* select grouped operator ************* */ -static short pose_select_same_group (bContext *C, Object *ob, short extend) +static short pose_select_same_group(bContext *C, Object *ob, short extend) { - bArmature *arm= (ob)? ob->data : NULL; - bPose *pose= (ob)? ob->pose : NULL; + bArmature *arm = (ob) ? ob->data : NULL; + bPose *pose = (ob) ? ob->pose : NULL; char *group_flags; int numGroups = 0; - short changed=0, tagged=0; + short changed = 0, tagged = 0; /* sanity checks */ if (ELEM3(NULL, ob, pose, arm)) return 0; /* count the number of groups */ - numGroups= BLI_countlist(&pose->agroups); + numGroups = BLI_countlist(&pose->agroups); if (numGroups == 0) return 0; /* alloc a small array to keep track of the groups to use - * - each cell stores on/off state for whether group should be used + * - each cell stores on/off state for whether group should be used * - size is numGroups + 1, since index=0 is used for no-group */ - group_flags= MEM_callocN(numGroups+1, "pose_select_same_group"); + group_flags = MEM_callocN(numGroups + 1, "pose_select_same_group"); CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { /* keep track of group as group to use later? */ if (pchan->bone->flag & BONE_SELECTED) { group_flags[pchan->agrp_index] = 1; - tagged= 1; + tagged = 1; } /* deselect all bones before selecting new ones? */ - if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) + if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -558,11 +594,11 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend) /* only if group matches (and is not selected or current bone) */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { /* check if the group used by this bone is counted */ if (group_flags[pchan->agrp_index]) { pchan->bone->flag |= BONE_SELECTED; - changed= 1; + changed = 1; } } } @@ -575,12 +611,12 @@ static short pose_select_same_group (bContext *C, Object *ob, short extend) return changed; } -static short pose_select_same_layer (bContext *C, Object *ob, short extend) +static short pose_select_same_layer(bContext *C, Object *ob, short extend) { - bPose *pose= (ob)? ob->pose : NULL; - bArmature *arm= (ob)? ob->data : NULL; - short changed= 0; - int layers= 0; + bPose *pose = (ob) ? ob->pose : NULL; + bArmature *arm = (ob) ? ob->data : NULL; + short changed = 0; + int layers = 0; if (ELEM3(NULL, ob, pose, arm)) return 0; @@ -593,7 +629,7 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend) layers |= pchan->bone->layer; /* deselect all bones before selecting new ones? */ - if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) + if ((extend == 0) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -604,9 +640,9 @@ static short pose_select_same_layer (bContext *C, Object *ob, short extend) CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { /* if bone is on a suitable layer, and the bone can have its selection changed, select it */ - if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE)==0) { + if ((layers & pchan->bone->layer) && (pchan->bone->flag & BONE_UNSELECTABLE) == 0) { pchan->bone->flag |= BONE_SELECTED; - changed= 1; + changed = 1; } } CTX_DATA_END; @@ -619,9 +655,9 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) KeyingSet *ks = ANIM_scene_get_active_keyingset(CTX_data_scene(C)); KS_Path *ksp; - bArmature *arm = (ob)? ob->data : NULL; - bPose *pose= (ob)? ob->pose : NULL; - short changed= 0; + bArmature *arm = (ob) ? ob->data : NULL; + bPose *pose = (ob) ? ob->pose : NULL; + short changed = 0; /* sanity checks: validate Keying Set and object */ if ((ks == NULL) || (ANIM_validate_keyingset(C, NULL, ks) != 0)) @@ -634,7 +670,7 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) if (extend == 0) { CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) pchan->bone->flag &= ~BONE_SELECTED; } CTX_DATA_END; @@ -650,12 +686,12 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) char *boneName = BLI_getQuotedStr(ksp->rna_path, "bones["); if (boneName) { - bPoseChannel *pchan = get_pose_channel(pose, boneName); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, boneName); if (pchan) { /* select if bone is visible and can be affected */ if ((PBONE_VISIBLE(arm, pchan->bone)) && - (pchan->bone->flag & BONE_UNSELECTABLE)==0) + (pchan->bone->flag & BONE_UNSELECTABLE) == 0) { pchan->bone->flag |= BONE_SELECTED; changed = 1; @@ -672,10 +708,10 @@ static int pose_select_same_keyingset(bContext *C, Object *ob, short extend) return changed; } -static int pose_select_grouped_exec (bContext *C, wmOperator *op) +static int pose_select_grouped_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - short extend= RNA_boolean_get(op->ptr, "extend"); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + short extend = RNA_boolean_get(op->ptr, "extend"); short changed = 0; /* sanity check */ @@ -687,18 +723,18 @@ static int pose_select_grouped_exec (bContext *C, wmOperator *op) */ switch (RNA_enum_get(op->ptr, "type")) { case 1: /* group */ - changed= pose_select_same_group(C, ob, extend); + changed = pose_select_same_group(C, ob, extend); break; case 2: /* Keying Set */ - changed= pose_select_same_keyingset(C, ob, extend); + changed = pose_select_same_keyingset(C, ob, extend); break; default: /* layer */ - changed= pose_select_same_layer(C, ob, extend); + changed = pose_select_same_layer(C, ob, extend); break; } /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* report done status */ if (changed) @@ -727,7 +763,7 @@ void POSE_OT_select_grouped(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "extend", FALSE, "Extend", "Extend selection instead of deselecting everything first"); @@ -738,25 +774,25 @@ void POSE_OT_select_grouped(wmOperatorType *ot) /* ********************************************** */ /* context active object, or weightpainted object with armature in posemode */ -static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_bone_flip_active_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob_act= CTX_data_active_object(C); - Object *ob= object_pose_armature_get(ob_act); + Object *ob_act = CTX_data_active_object(C); + Object *ob = BKE_object_pose_armature_get(ob_act); if (ob && (ob->mode & OB_MODE_POSE)) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; if (arm->act_bone) { bPoseChannel *pchanf; char name[MAXBONENAME]; flip_side_name(name, arm->act_bone->name, TRUE); - pchanf= get_pose_channel(ob->pose, name); + pchanf = BKE_pose_channel_find_name(ob->pose, name); if (pchanf && pchanf->bone != arm->act_bone) { arm->act_bone->flag &= ~BONE_SELECTED; pchanf->bone->flag |= BONE_SELECTED; - arm->act_bone= pchanf->bone; + arm->act_bone = pchanf->bone; /* in weightpaint we select the associated vertex group too */ if (ob_act->mode & OB_MODE_WEIGHT_PAINT) { @@ -764,7 +800,7 @@ static int pose_bone_flip_active_exec (bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob_act->id, OB_RECALC_DATA); } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_SELECT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, ob); return OPERATOR_FINISHED; } @@ -786,7 +822,7 @@ void POSE_OT_select_flip_active(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -794,49 +830,49 @@ void POSE_OT_select_flip_active(wmOperatorType *ot) #if 0 /* UNUSED 2.5 */ static void pose_copy_menu(Scene *scene) { - Object *obedit= scene->obedit; // XXX context - Object *ob= OBACT; + Object *obedit = scene->obedit; // XXX context + Object *ob = OBACT; bArmature *arm; bPoseChannel *pchan, *pchanact; - short nr=0; - int i=0; + short nr = 0; + int i = 0; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return; - if ((ob==obedit) || (ob->mode & OB_MODE_POSE)==0) return; + if ((ob == obedit) || (ob->mode & OB_MODE_POSE) == 0) return; - pchan= get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); - if (pchan==NULL) return; - pchanact= pchan; - arm= ob->data; + if (pchan == NULL) return; + pchanact = pchan; + arm = ob->data; /* if proxy-protected bones selected, some things (such as locks + displays) shouldn't be changeable, * but for constraints (just add local constraints) */ if (pose_has_protected_selected(ob, 0)) { - i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ + i = BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ if (i < 25) - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5"); else - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4"); } else { - i= BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ + i = BLI_countlist(&(pchanact->constraints)); /* if there are 24 or less, allow for the user to select constraints */ if (i < 25) - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|Constraints...%x5|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); else - nr= pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); + nr = pupmenu("Copy Pose Attributes %t|Local Location%x1|Local Rotation%x2|Local Size%x3|%l|Visual Location %x9|Visual Rotation%x10|Visual Size%x11|%l|Constraints (All)%x4|%l|Transform Locks%x6|IK Limits%x7|Bone Shape%x8"); } if (nr <= 0) return; if (nr != 5) { - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((arm->layer & pchan->bone->layer) && - (pchan->bone->flag & BONE_SELECTED) && - (pchan != pchanact) ) + (pchan->bone->flag & BONE_SELECTED) && + (pchan != pchanact) ) { switch (nr) { case 1: /* Local Location */ @@ -861,7 +897,7 @@ static void pose_copy_menu(Scene *scene) bConstraint *con; /* add proxy-local tags */ - for (con= tmp_constraints.first; con; con= con->next) + for (con = tmp_constraints.first; con; con = con->next) con->flag |= CONSTRAINT_PROXY_LOCAL; } BLI_movelisttolist(&pchan->constraints, &tmp_constraints); @@ -872,7 +908,7 @@ static void pose_copy_menu(Scene *scene) if (ob->pose) ob->pose->flag |= POSE_RECALC; } - break; + break; case 6: /* Transform Locks */ pchan->protectflag = pchanact->protectflag; break; @@ -882,22 +918,22 @@ static void pose_copy_menu(Scene *scene) copy_v3_v3(pchan->limitmin, pchanact->limitmin); copy_v3_v3(pchan->limitmax, pchanact->limitmax); copy_v3_v3(pchan->stiffness, pchanact->stiffness); - pchan->ikstretch= pchanact->ikstretch; - pchan->ikrotweight= pchanact->ikrotweight; - pchan->iklinweight= pchanact->iklinweight; + pchan->ikstretch = pchanact->ikstretch; + pchan->ikrotweight = pchanact->ikrotweight; + pchan->iklinweight = pchanact->iklinweight; } - break; + break; case 8: /* Custom Bone Shape */ pchan->custom = pchanact->custom; break; case 9: /* Visual Location */ - armature_loc_pose_to_bone(pchan, pchanact->pose_mat[3], pchan->loc); + BKE_armature_loc_pose_to_bone(pchan, pchanact->pose_mat[3], pchan->loc); break; case 10: /* Visual Rotation */ { float delta_mat[4][4]; - armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); if (pchan->rotmode == ROT_MODE_AXISANGLE) { float tmp_quat[4]; @@ -911,12 +947,12 @@ static void pose_copy_menu(Scene *scene) else mat4_to_eulO(pchan->eul, pchan->rotmode, delta_mat); } - break; + break; case 11: /* Visual Size */ { float delta_mat[4][4], size[4]; - armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); + BKE_armature_mat_pose_to_bone(pchan, pchanact->pose_mat, delta_mat); mat4_to_size(size, delta_mat); copy_v3_v3(pchan->size, size); } @@ -926,14 +962,14 @@ static void pose_copy_menu(Scene *scene) } else { /* constraints, optional (note: max we can have is 24 constraints) */ bConstraint *con, *con_back; - int const_toggle[24]= {0}; /* XXX, initialize as 0 to quiet errors */ + int const_toggle[24] = {0}; /* XXX, initialize as 0 to quiet errors */ ListBase const_copy = {NULL, NULL}; BLI_duplicatelist(&const_copy, &(pchanact->constraints)); /* build the puplist of constraints */ - for (con = pchanact->constraints.first, i=0; con; con=con->next, i++) { - const_toggle[i]= 1; + for (con = pchanact->constraints.first, i = 0; con; con = con->next, i++) { + const_toggle[i] = 1; // add_numbut(i, TOG|INT, con->name, 0, 0, &(const_toggle[i]), ""); } @@ -943,22 +979,22 @@ static void pose_copy_menu(Scene *scene) // } /* now build a new listbase from the options selected */ - for (i=0, con=const_copy.first; con; i++) { + for (i = 0, con = const_copy.first; con; i++) { /* if not selected, free/remove it from the list */ if (!const_toggle[i]) { - con_back= con->next; + con_back = con->next; BLI_freelinkN(&const_copy, con); - con= con_back; + con = con_back; } else - con= con->next; + con = con->next; } /* Copy the temo listbase to the selected posebones */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if ((arm->layer & pchan->bone->layer) && - (pchan->bone->flag & BONE_SELECTED) && - (pchan!=pchanact) ) + (pchan->bone->flag & BONE_SELECTED) && + (pchan != pchanact) ) { ListBase tmp_constraints = {NULL, NULL}; @@ -968,7 +1004,7 @@ static void pose_copy_menu(Scene *scene) copy_constraints(&tmp_constraints, &const_copy, TRUE); if ((ob->proxy) && (pchan->bone->layer & arm->layer_protected)) { /* add proxy-local tags */ - for (con= tmp_constraints.first; con; con= con->next) + for (con = tmp_constraints.first; con; con = con->next) con->flag |= CONSTRAINT_PROXY_LOCAL; } BLI_movelisttolist(&pchan->constraints, &tmp_constraints); @@ -978,13 +1014,13 @@ static void pose_copy_menu(Scene *scene) } } BLI_freelistN(&const_copy); - update_pose_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ + BKE_pose_update_constraint_flags(ob->pose); /* we could work out the flags but its simpler to do this */ if (ob->pose) ob->pose->flag |= POSE_RECALC; } - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); // and all its relations BIF_undo_push("Copy Pose Attributes"); @@ -1001,7 +1037,7 @@ void free_posebuf(void) if (g_posebuf) { bPoseChannel *pchan; - for (pchan= g_posebuf->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = g_posebuf->chanbase.first; pchan; pchan = pchan->next) { if (pchan->prop) { IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); @@ -1013,20 +1049,20 @@ void free_posebuf(void) MEM_freeN(g_posebuf); } - g_posebuf=NULL; + g_posebuf = NULL; } /* This function is used to indicate that a bone is selected * and needs to be included in copy buffer (used to be for inserting keys) */ -static void set_pose_keys (Object *ob) +static void set_pose_keys(Object *ob) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *chan; if (ob->pose) { - for (chan=ob->pose->chanbase.first; chan; chan=chan->next) { - Bone *bone= chan->bone; + for (chan = ob->pose->chanbase.first; chan; chan = chan->next) { + Bone *bone = chan->bone; if ((bone) && (bone->flag & BONE_SELECTED) && (arm->layer & bone->layer)) chan->flag |= POSE_KEY; else @@ -1043,7 +1079,7 @@ static void set_pose_keys (Object *ob) * * > returns: whether the bone that we pasted to if we succeeded */ -static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short selOnly, short flip) +static bPoseChannel *pose_bone_do_paste(Object *ob, bPoseChannel *chan, short selOnly, short flip) { bPoseChannel *pchan; char name[MAXBONENAME]; @@ -1051,20 +1087,20 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s /* get the name - if flipping, we must flip this first */ if (flip) - flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ + flip_side_name(name, chan->name, 0); /* 0 = don't strip off number extensions */ else BLI_strncpy(name, chan->name, sizeof(name)); /* only copy when: - * 1) channel exists - poses are not meant to add random channels to anymore - * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical + * 1) channel exists - poses are not meant to add random channels to anymore + * 2) if selection-masking is on, channel is selected - only selected bones get pasted on, allowing making both sides symmetrical */ - pchan= get_pose_channel(ob->pose, name); + pchan = BKE_pose_channel_find_name(ob->pose, name); if (selOnly) - paste_ok= ((pchan) && (pchan->bone->flag & BONE_SELECTED)); + paste_ok = ((pchan) && (pchan->bone->flag & BONE_SELECTED)); else - paste_ok= ((pchan != NULL)); + paste_ok = ((pchan != NULL)); /* continue? */ if (paste_ok) { @@ -1073,7 +1109,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s */ copy_v3_v3(pchan->loc, chan->loc); copy_v3_v3(pchan->size, chan->size); - pchan->flag= chan->flag; + pchan->flag = chan->flag; /* check if rotation modes are compatible (i.e. do they need any conversions) */ if (pchan->rotmode == chan->rotmode) { @@ -1113,7 +1149,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s /* paste flipped pose? */ if (flip) { - pchan->loc[0]*= -1; + pchan->loc[0] *= -1; /* has to be done as eulers... */ if (pchan->rotmode > 0) { @@ -1124,8 +1160,8 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s float eul[3]; axis_angle_to_eulO(eul, EULER_ORDER_DEFAULT, pchan->rotAxis, pchan->rotAngle); - eul[1]*= -1; - eul[2]*= -1; + eul[1] *= -1; + eul[2] *= -1; eulO_to_axis_angle(pchan->rotAxis, &pchan->rotAngle, eul, EULER_ORDER_DEFAULT); } else { @@ -1133,8 +1169,8 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s normalize_qt(pchan->quat); quat_to_eul(eul, pchan->quat); - eul[1]*= -1; - eul[2]*= -1; + eul[1] *= -1; + eul[2] *= -1; eul_to_quat(pchan->quat, eul); } } @@ -1150,7 +1186,7 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s } else { /* no existing properties, so assume that we want copies too? */ - pchan->prop= IDP_CopyProperty(chan->prop); + pchan->prop = IDP_CopyProperty(chan->prop); } } } @@ -1161,9 +1197,9 @@ static bPoseChannel *pose_bone_do_paste (Object *ob, bPoseChannel *chan, short s /* ---- */ -static int pose_copy_exec (bContext *C, wmOperator *op) +static int pose_copy_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* sanity checking */ if (ELEM(NULL, ob, ob->pose)) { @@ -1176,7 +1212,7 @@ static int pose_copy_exec (bContext *C, wmOperator *op) /* sets chan->flag to POSE_KEY if bone selected, then copy those bones to the buffer */ set_pose_keys(ob); - copy_pose(&g_posebuf, ob->pose, 0); + BKE_pose_copy_data(&g_posebuf, ob->pose, 0); return OPERATOR_FINISHED; @@ -1199,13 +1235,13 @@ void POSE_OT_copy(wmOperatorType *ot) /* ---- */ -static int pose_paste_exec (bContext *C, wmOperator *op) +static int pose_paste_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - Scene *scene= CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); bPoseChannel *chan; - int flip= RNA_boolean_get(op->ptr, "flipped"); - int selOnly= RNA_boolean_get(op->ptr, "selected_mask"); + int flip = RNA_boolean_get(op->ptr, "flipped"); + int selOnly = RNA_boolean_get(op->ptr, "selected_mask"); /* get KeyingSet to use */ KeyingSet *ks = ANIM_get_keyingset_for_autokeying(scene, ANIM_KS_LOC_ROT_SCALE_ID); @@ -1228,7 +1264,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op) } /* Safely merge all of the channels in the buffer pose into any existing pose */ - for (chan= g_posebuf->chanbase.first; chan; chan=chan->next) { + for (chan = g_posebuf->chanbase.first; chan; chan = chan->next) { if (chan->flag & POSE_KEY) { /* try to perform paste on this bone */ bPoseChannel *pchan = pose_bone_do_paste(ob, chan, selOnly, flip); @@ -1244,7 +1280,7 @@ static int pose_paste_exec (bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1263,7 +1299,7 @@ void POSE_OT_paste(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flag */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ prop = RNA_def_boolean(ot->srna, "flipped", FALSE, "Flipped on X-Axis", "Paste the stored pose flipped on to current pose"); @@ -1275,26 +1311,26 @@ void POSE_OT_paste(wmOperatorType *ot) /* ********************************************** */ /* Bone Groups */ -static int pose_group_add_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_add_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; /* for now, just call the API function for this */ - pose_add_group(ob); + BKE_pose_add_group(ob); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1311,30 +1347,30 @@ void POSE_OT_group_add(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_group_remove_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_remove_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object */ if (ob == NULL) return OPERATOR_CANCELLED; /* for now, just call the API function for this */ - pose_remove_group(ob); + BKE_pose_remove_group(ob); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1351,15 +1387,15 @@ void POSE_OT_group_remove(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------ */ /* invoke callback which presents a list of bone-groups for the user to choose from */ -static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) +static int pose_groups_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; bPose *pose; @@ -1370,20 +1406,20 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - pose= ob->pose; + pose = ob->pose; /* if there's no active group (or active is invalid), create a new menu to find it */ if (pose->active_group <= 0) { /* create a new menu, and start populating it with group names */ - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); /* special entry - allow to create new group, then use that * (not to be used for removing though) @@ -1394,7 +1430,7 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } /* add entries for each group */ - for (grp= pose->agroups.first, i=1; grp; grp=grp->next, i++) + for (grp = pose->agroups.first, i = 1; grp; grp = grp->next, i++) uiItemIntO(layout, grp->name, ICON_NONE, op->idname, "type", i); /* finish building the menu, and process it (should result in calling self again) */ @@ -1410,42 +1446,42 @@ static int pose_groups_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED } /* Assign selected pchans to the bone group that the user selects */ -static int pose_group_assign_exec (bContext *C, wmOperator *op) +static int pose_group_assign_exec(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; bPose *pose; - short done= 0; + short done = 0; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - pose= ob->pose; + pose = ob->pose; /* set the active group number to the one from operator props - * - if 0 after this, make a new group... + * - if 0 after this, make a new group... */ - pose->active_group= RNA_int_get(op->ptr, "type"); + pose->active_group = RNA_int_get(op->ptr, "type"); if (pose->active_group == 0) - pose_add_group(ob); + BKE_pose_add_group(ob); /* add selected bones to group then */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { - pchan->agrp_index= pose->active_group; - done= 1; + pchan->agrp_index = pose->active_group; + done = 1; } CTX_DATA_END; /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* report done status */ if (done) @@ -1467,41 +1503,41 @@ void POSE_OT_group_assign(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "type", 0, 0, 10, "Bone Group Index", "", 0, INT_MAX); } -static int pose_group_unassign_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_unassign_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; - short done= 0; + short done = 0; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; /* find selected bones to remove from all bone groups */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { if (pchan->agrp_index) { - pchan->agrp_index= 0; - done= 1; + pchan->agrp_index = 0; + done = 1; } } CTX_DATA_END; /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* report done status */ if (done) @@ -1522,16 +1558,16 @@ void POSE_OT_group_unassign(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int group_move_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_context(C); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; bActionGroup *grp; - int dir= RNA_enum_get(op->ptr, "direction"); + int dir = RNA_enum_get(op->ptr, "direction"); int grpIndexA, grpIndexB; if (ELEM(NULL, ob, pose)) @@ -1540,7 +1576,7 @@ static int group_move_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get group to move */ - grp= BLI_findlink(&pose->agroups, pose->active_group-1); + grp = BLI_findlink(&pose->agroups, pose->active_group - 1); if (grp == NULL) return OPERATOR_CANCELLED; @@ -1572,15 +1608,15 @@ static int group_move_exec(bContext *C, wmOperator *op) } /* fix changed bone group indices in bones (swap grpIndexA with grpIndexB) */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->agrp_index == grpIndexB) - pchan->agrp_index= grpIndexA; + pchan->agrp_index = grpIndexA; else if (pchan->agrp_index == grpIndexA) - pchan->agrp_index= grpIndexB; + pchan->agrp_index = grpIndexB; } /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1603,7 +1639,7 @@ void POSE_OT_group_move(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "direction", group_slot_move, 0, "Direction", "Direction to move, UP or DOWN"); } @@ -1611,14 +1647,14 @@ void POSE_OT_group_move(wmOperatorType *ot) /* bone group sort element */ typedef struct tSortActionGroup { bActionGroup *agrp; - int index; + int index; } tSortActionGroup; /* compare bone groups by name */ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) { - tSortActionGroup *sgrp_a= (tSortActionGroup *)sgrp_a_ptr; - tSortActionGroup *sgrp_b= (tSortActionGroup *)sgrp_b_ptr; + tSortActionGroup *sgrp_a = (tSortActionGroup *)sgrp_a_ptr; + tSortActionGroup *sgrp_b = (tSortActionGroup *)sgrp_b_ptr; return strcmp(sgrp_a->agrp->name, sgrp_b->agrp->name); } @@ -1626,7 +1662,7 @@ static int compare_agroup(const void *sgrp_a_ptr, const void *sgrp_b_ptr) static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = ED_object_context(C); - bPose *pose= (ob) ? ob->pose : NULL; + bPose *pose = (ob) ? ob->pose : NULL; bPoseChannel *pchan; tSortActionGroup *agrp_array; bActionGroup *agrp; @@ -1641,26 +1677,26 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) /* create temporary array with bone groups and indices */ agrp_count = BLI_countlist(&pose->agroups); agrp_array = MEM_mallocN(sizeof(tSortActionGroup) * agrp_count, "sort bone groups"); - for (agrp= pose->agroups.first, i= 0; agrp; agrp= agrp->next, i++) { + for (agrp = pose->agroups.first, i = 0; agrp; agrp = agrp->next, i++) { BLI_assert(i < agrp_count); agrp_array[i].agrp = agrp; - agrp_array[i].index = i+1; + agrp_array[i].index = i + 1; } /* sort bone groups by name */ qsort(agrp_array, agrp_count, sizeof(tSortActionGroup), compare_agroup); /* create sorted bone group list from sorted array */ - pose->agroups.first= pose->agroups.last= NULL; - for (i= 0; i < agrp_count; i++) { + pose->agroups.first = pose->agroups.last = NULL; + for (i = 0; i < agrp_count; i++) { BLI_addtail(&pose->agroups, agrp_array[i].agrp); } /* fix changed bone group indizes in bones */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next) { - for (i= 0; i < agrp_count; i++) { + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { + for (i = 0; i < agrp_count; i++) { if (pchan->agrp_index == agrp_array[i].index) { - pchan->agrp_index= i+1; + pchan->agrp_index = i + 1; break; } } @@ -1670,7 +1706,7 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) MEM_freeN(agrp_array); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1687,16 +1723,16 @@ void POSE_OT_group_sort(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static void pose_group_select(bContext *C, Object *ob, int select) { - bPose *pose= ob->pose; + bPose *pose = ob->pose; - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, visible_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) { - if ((pchan->bone->flag & BONE_UNSELECTABLE)==0) { + if ((pchan->bone->flag & BONE_UNSELECTABLE) == 0) { if (select) { if (pchan->agrp_index == pose->active_group) pchan->bone->flag |= BONE_SELECTED; @@ -1710,16 +1746,16 @@ static void pose_group_select(bContext *C, Object *ob, int select) CTX_DATA_END; } -static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_select_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1728,7 +1764,7 @@ static int pose_group_select_exec (bContext *C, wmOperator *UNUSED(op)) pose_group_select(C, ob, 1); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1745,19 +1781,19 @@ void POSE_OT_group_select(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_group_deselect_exec(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); Object *ob; /* since this call may also be used from the buttons window, we need to check for where to get the object */ if (sa->spacetype == SPACE_BUTS) - ob= ED_object_context(C); + ob = ED_object_context(C); else - ob= object_pose_armature_get(CTX_data_active_object(C)); + ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only continue if there's an object, and a pose there too */ if (ELEM(NULL, ob, ob->pose)) @@ -1766,7 +1802,7 @@ static int pose_group_deselect_exec (bContext *C, wmOperator *UNUSED(op)) pose_group_select(C, ob, 0); /* notifiers for updates */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1783,23 +1819,23 @@ void POSE_OT_group_deselect(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ -static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_flip_names_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { char newname[MAXBONENAME]; flip_side_name(newname, pchan->name, TRUE); @@ -1811,7 +1847,7 @@ static int pose_flip_names_exec (bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -1828,25 +1864,25 @@ void POSE_OT_flip_names(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------------ */ -static int pose_autoside_names_exec (bContext *C, wmOperator *op) +static int pose_autoside_names_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); bArmature *arm; char newname[MAXBONENAME]; - short axis= RNA_enum_get(op->ptr, "axis"); + short axis = RNA_enum_get(op->ptr, "axis"); /* paranoia checks */ if (ELEM(NULL, ob, ob->pose)) return OPERATOR_CANCELLED; - arm= ob->data; + arm = ob->data; /* loop through selected bones, auto-naming them */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { BLI_strncpy(newname, pchan->name, sizeof(newname)); if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) @@ -1858,18 +1894,19 @@ static int pose_autoside_names_exec (bContext *C, wmOperator *op) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } void POSE_OT_autoside_names(wmOperatorType *ot) { - static EnumPropertyItem axis_items[]= { + static EnumPropertyItem axis_items[] = { {0, "XAXIS", 0, "X-Axis", "Left/Right"}, {1, "YAXIS", 0, "Y-Axis", "Front/Back"}, {2, "ZAXIS", 0, "Z-Axis", "Top/Bottom"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "AutoName by Axis"; @@ -1882,7 +1919,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* settings */ ot->prop = RNA_def_enum(ot->srna, "axis", axis_items, 0, "Axis", "Axis tag names with"); @@ -1890,7 +1927,7 @@ void POSE_OT_autoside_names(wmOperatorType *ot) /* ********************************************** */ -static int pose_bone_rotmode_exec (bContext *C, wmOperator *op) +static int pose_bone_rotmode_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); int mode = RNA_enum_get(op->ptr, "type"); @@ -1904,7 +1941,7 @@ static int pose_bone_rotmode_exec (bContext *C, wmOperator *op) /* notifiers and updates */ DAG_id_tag_update((ID *)ob, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -1922,7 +1959,7 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", posebone_rotmode_items, 0, "Rotation Mode", ""); @@ -1931,18 +1968,18 @@ void POSE_OT_rotation_mode_set(wmOperatorType *ot) /* ********************************************** */ /* Show all armature layers */ -static int pose_armature_layers_showall_poll (bContext *C) +static int pose_armature_layers_showall_poll(bContext *C) { /* this single operator can be used in posemode OR editmode for armatures */ return ED_operator_posemode(C) || ED_operator_editarmature(C); } -static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) +static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm = (ob)? ob->data : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; - int maxLayers = (RNA_boolean_get(op->ptr, "all"))? 32 : 16; + int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16; int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ int i; @@ -1951,7 +1988,7 @@ static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* use RNA to set the layers - * although it would be faster to just set directly using bitflags, we still + * although it would be faster to just set directly using bitflags, we still * need to setup a RNA pointer so that we get the "update" callbacks for free... */ RNA_id_pointer_create(&arm->id, &ptr); @@ -1962,7 +1999,7 @@ static int pose_armature_layers_showall_exec (bContext *C, wmOperator *op) RNA_boolean_set_array(&ptr, "layers", layers); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); /* done */ return OPERATOR_FINISHED; @@ -1980,7 +2017,7 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot) ot->poll = pose_armature_layers_showall_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All Layers", "Enable all layers or just the first 16 (top row)"); @@ -1989,10 +2026,10 @@ void ARMATURE_OT_layers_show_all(wmOperatorType *ot) /* ------------------- */ /* Present a popup to get the layers that should be used */ -static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int pose_armature_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); - bArmature *arm= (ob)? ob->data : NULL; + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2010,9 +2047,9 @@ static int pose_armature_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev } /* Set the visible layers for the active armature (edit and pose modes) */ -static int pose_armature_layers_exec (bContext *C, wmOperator *op) +static int pose_armature_layers_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2028,7 +2065,7 @@ static int pose_armature_layers_exec (bContext *C, wmOperator *op) RNA_boolean_set_array(&ptr, "layers", layers); /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2047,7 +2084,7 @@ void POSE_OT_armature_layers(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible"); @@ -2066,7 +2103,7 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers to make visible"); @@ -2075,9 +2112,9 @@ void ARMATURE_OT_armature_layers(wmOperatorType *ot) /* ------------------- */ /* Present a popup to get the layers that should be used */ -static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int pose_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - int layers[32]= {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get layers that are active already */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -2085,9 +2122,9 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) short bit; /* loop over the bits for this pchan's layers, adding layers where they're needed */ - for (bit= 0; bit < 32; bit++) { - if (pchan->bone->layer & (1<bone->layer & (1 << bit)) + layers[bit] = 1; } } CTX_DATA_END; @@ -2095,18 +2132,18 @@ static int pose_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) /* copy layers to operator */ RNA_boolean_set_array(op->ptr, "layers", layers); - /* part to sync with other similar operators... */ + /* part to sync with other similar operators... */ return WM_operator_props_popup(C, op, evt); } /* Set the visible layers for the active armature (edit and pose modes) */ -static int pose_bone_layers_exec (bContext *C, wmOperator *op) +static int pose_bone_layers_exec(bContext *C, wmOperator *op) { - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ - if (ob==NULL || ob->data==NULL) { + if (ob == NULL || ob->data == NULL) { return OPERATOR_CANCELLED; } @@ -2123,7 +2160,7 @@ static int pose_bone_layers_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2141,7 +2178,7 @@ void POSE_OT_bone_layers(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); @@ -2150,9 +2187,9 @@ void POSE_OT_bone_layers(wmOperatorType *ot) /* ------------------- */ /* Present a popup to get the layers that should be used */ -static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int armature_bone_layers_invoke(bContext *C, wmOperator *op, wmEvent *evt) { - int layers[32]= {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ + int layers[32] = {0}; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ /* get layers that are active already */ CTX_DATA_BEGIN (C, EditBone *, ebone, selected_editable_bones) @@ -2160,9 +2197,9 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev short bit; /* loop over the bits for this pchan's layers, adding layers where they're needed */ - for (bit= 0; bit < 32; bit++) { - if (ebone->layer & (1<layer & (1 << bit)) + layers[bit] = 1; } } CTX_DATA_END; @@ -2170,15 +2207,15 @@ static int armature_bone_layers_invoke (bContext *C, wmOperator *op, wmEvent *ev /* copy layers to operator */ RNA_boolean_set_array(op->ptr, "layers", layers); - /* part to sync with other similar operators... */ + /* part to sync with other similar operators... */ return WM_operator_props_popup(C, op, evt); } /* Set the visible layers for the active armature (edit and pose modes) */ -static int armature_bone_layers_exec (bContext *C, wmOperator *op) +static int armature_bone_layers_exec(bContext *C, wmOperator *op) { - Object *ob= CTX_data_edit_object(C); - bArmature *arm= (ob)? ob->data : NULL; + Object *ob = CTX_data_edit_object(C); + bArmature *arm = (ob) ? ob->data : NULL; PointerRNA ptr; int layers[32]; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ @@ -2195,7 +2232,7 @@ static int armature_bone_layers_exec (bContext *C, wmOperator *op) CTX_DATA_END; /* note, notifier might evolve */ - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); return OPERATOR_FINISHED; } @@ -2213,7 +2250,7 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) ot->poll = ED_operator_editarmature; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean_layer_member(ot->srna, "layers", 32, NULL, "Layer", "Armature layers that bone belongs to"); @@ -2222,14 +2259,14 @@ void ARMATURE_OT_bone_layers(wmOperatorType *ot) /* ********************************************** */ /* Flip Quats */ -static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_flip_quats_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *ob= object_pose_armature_get(CTX_data_active_object(C)); + Scene *scene = CTX_data_scene(C); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); KeyingSet *ks = ANIM_builtin_keyingset_get_named(NULL, ANIM_KS_LOC_ROT_SCALE_ID); /* loop through all selected pchans, flipping and keying (as needed) */ - CTX_DATA_BEGIN (C, bPoseChannel*, pchan, selected_pose_bones) + CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) { /* only if bone is using quaternion rotation */ if (pchan->rotmode == ROT_MODE_QUAT) { @@ -2243,7 +2280,7 @@ static int pose_flip_quats_exec (bContext *C, wmOperator *UNUSED(op)) /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -2260,17 +2297,18 @@ void POSE_OT_quaternions_flip(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ /* Clear User Transforms */ -static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) +static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); float cframe = (float)CFRA; + const short only_select = RNA_boolean_get(op->ptr, "only_selected"); if ((ob->adt) && (ob->adt->action)) { /* XXX: this is just like this to avoid contaminating anything else; @@ -2281,7 +2319,7 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan; /* execute animation step for current frame using a dummy copy of the pose */ - copy_pose(&dummyPose, ob->pose, 0); + BKE_pose_copy_data(&dummyPose, ob->pose, 0); BLI_strncpy(workob.id.name, "OB", sizeof(workob.id.name)); workob.type = OB_ARMATURE; @@ -2293,12 +2331,12 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) /* copy back values, but on selected bones only */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { - pose_bone_do_paste(ob, pchan, 1, 0); + pose_bone_do_paste(ob, pchan, only_select, 0); } /* free temp data - free manually as was copied without constraints */ if (dummyPose) { - for (pchan= dummyPose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->prop) { IDP_FreeProperty(pchan->prop); MEM_freeN(pchan->prop); @@ -2314,12 +2352,12 @@ static int pose_clear_user_transforms_exec (bContext *C, wmOperator *UNUSED(op)) /* no animation, so just reset whole pose to rest pose * (cannot just restore for selected though) */ - rest_pose(ob->pose); + BKE_pose_rest(ob->pose); } /* notifiers and updates */ DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); return OPERATOR_FINISHED; } @@ -2336,6 +2374,9 @@ void POSE_OT_user_transforms_clear(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + /* properties */ + RNA_def_boolean(ot->srna, "only_selected", TRUE, "Only Selected", "Only visible/selected bones"); } diff --git a/source/blender/editors/armature/reeb.c b/source/blender/editors/armature/reeb.c index efcbab78884..2564683ddd2 100644 --- a/source/blender/editors/armature/reeb.c +++ b/source/blender/editors/armature/reeb.c @@ -98,7 +98,7 @@ typedef struct VertexData { typedef struct EdgeIndex { EditEdge **edges; - int *offset; + int *offset; } EdgeIndex; typedef enum { @@ -110,12 +110,12 @@ typedef enum { int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1); void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection direction); int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1); -EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index); +EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index); void mergeArcFaces(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc); void addFacetoArc(ReebArc *arc, EditFace *efa); -void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count); -void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BArc* barc1, BArc* barc2); +void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count); +void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2); void flipArcBuckets(ReebArc *arc); @@ -145,34 +145,34 @@ static VertexData *allocVertexData(EditMesh *em) static int indexData(EditVert *eve) { - return ((VertexData*)eve->tmp.p)->i; + return ((VertexData *)eve->tmp.p)->i; } static float weightData(EditVert *eve) { - return ((VertexData*)eve->tmp.p)->w; + return ((VertexData *)eve->tmp.p)->w; } static void weightSetData(EditVert *eve, float w) { - ((VertexData*)eve->tmp.p)->w = w; + ((VertexData *)eve->tmp.p)->w = w; } -static ReebNode* nodeData(EditVert *eve) +static ReebNode *nodeData(EditVert *eve) { - return ((VertexData*)eve->tmp.p)->n; + return ((VertexData *)eve->tmp.p)->n; } static void nodeSetData(EditVert *eve, ReebNode *n) { - ((VertexData*)eve->tmp.p)->n = n; + ((VertexData *)eve->tmp.p)->n = n; } #endif void REEB_freeArc(BArc *barc) { - ReebArc *arc = (ReebArc*)barc; + ReebArc *arc = (ReebArc *)barc; BLI_freelistN(&arc->edges); if (arc->buckets) @@ -191,7 +191,7 @@ void REEB_freeGraph(ReebGraph *rg) // free nodes for (node = rg->nodes.first; node; node = node->next) { - BLI_freeNode((BGraph*)rg, (BNode*)node); + BLI_freeNode((BGraph *)rg, (BNode *)node); } BLI_freelistN(&rg->nodes); @@ -199,7 +199,7 @@ void REEB_freeGraph(ReebGraph *rg) arc = rg->arcs.first; while (arc) { ReebArc *next = arc->next; - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); arc = next; } @@ -214,7 +214,7 @@ void REEB_freeGraph(ReebGraph *rg) MEM_freeN(rg); } -ReebGraph * newReebGraph(void) +ReebGraph *newReebGraph(void) { ReebGraph *rg; rg = MEM_callocN(sizeof(ReebGraph), "reeb graph"); @@ -233,13 +233,13 @@ ReebGraph * newReebGraph(void) void BIF_flagMultiArcs(ReebGraph *rg, int flag) { - for ( ; rg; rg = rg->link_up) { - BLI_flagArcs((BGraph*)rg, flag); + for (; rg; rg = rg->link_up) { + BLI_flagArcs((BGraph *)rg, flag); } } #if 0 /* UNUSED */ -static ReebNode * addNode(ReebGraph *rg, EditVert *eve) +static ReebNode *addNode(ReebGraph *rg, EditVert *eve) { float weight; ReebNode *node = NULL; @@ -264,7 +264,7 @@ static ReebNode * addNode(ReebGraph *rg, EditVert *eve) return node; } -static ReebNode * copyNode(ReebGraph *rg, ReebNode *node) +static ReebNode *copyNode(ReebGraph *rg, ReebNode *node) { ReebNode *cp_node = NULL; @@ -329,7 +329,7 @@ ReebNode *BIF_lowestLevelNode(ReebNode *node) } #if 0 /* UNUSED */ -static ReebArc * copyArc(ReebGraph *rg, ReebArc *arc) +static ReebArc *copyArc(ReebGraph *rg, ReebArc *arc) { ReebArc *cp_arc; ReebNode *node; @@ -375,7 +375,7 @@ static ReebArc * copyArc(ReebGraph *rg, ReebArc *arc) return cp_arc; } -static ReebGraph * copyReebGraph(ReebGraph *rg, int level) +static ReebGraph *copyReebGraph(ReebGraph *rg, int level) { ReebNode *node; ReebArc *arc; @@ -399,7 +399,7 @@ static ReebGraph * copyReebGraph(ReebGraph *rg, int level) copyArc(cp_rg, arc); } - BLI_buildAdjacencyList((BGraph*)cp_rg); + BLI_buildAdjacencyList((BGraph *)cp_rg); return cp_rg; } @@ -417,7 +417,7 @@ ReebGraph *BIF_graphForMultiNode(ReebGraph *rg, ReebNode *node) } #if 0 /* UNUSED */ -static ReebEdge * copyEdge(ReebEdge *edge) +static ReebEdge *copyEdge(ReebEdge *edge) { ReebEdge *newEdge = NULL; @@ -433,11 +433,11 @@ static ReebEdge * copyEdge(ReebEdge *edge) static void printArc(ReebArc *arc) { ReebEdge *edge; - ReebNode *head = (ReebNode*)arc->head; - ReebNode *tail = (ReebNode*)arc->tail; + ReebNode *head = (ReebNode *)arc->head; + ReebNode *tail = (ReebNode *)arc->tail; printf("arc: (%i) %f -> (%i) %f\n", head->index, head->weight, tail->index, tail->weight); - for (edge = arc->edges.first; edge ; edge = edge->next) + for (edge = arc->edges.first; edge; edge = edge->next) { printf("\tedge (%i, %i)\n", edge->v1->index, edge->v2->index); } @@ -475,8 +475,8 @@ static void NodeDegreeIncrement(ReebGraph *UNUSED(rg), ReebNode *node) } #else -#define NodeDegreeDecrement(rg, node) {node->degree--;} -#define NodeDegreeIncrement(rg, node) {node->degree++;} +#define NodeDegreeDecrement(rg, node) {node->degree--; } +#define NodeDegreeIncrement(rg, node) {node->degree++; } #endif void repositionNodes(ReebGraph *rg) @@ -490,14 +490,14 @@ void repositionNodes(ReebGraph *rg) } for (arc = rg->arcs.first; arc; arc = arc->next) { - if (((ReebArc*)arc)->bcount > 0) { + if (((ReebArc *)arc)->bcount > 0) { float p[3]; - copy_v3_v3(p, ((ReebArc*)arc)->buckets[0].p); + copy_v3_v3(p, ((ReebArc *)arc)->buckets[0].p); mul_v3_fl(p, 1.0f / arc->head->degree); add_v3_v3(arc->head->p, p); - copy_v3_v3(p, ((ReebArc*)arc)->buckets[((ReebArc*)arc)->bcount - 1].p); + copy_v3_v3(p, ((ReebArc *)arc)->buckets[((ReebArc *)arc)->bcount - 1].p); mul_v3_fl(p, 1.0f / arc->tail->degree); add_v3_v3(arc->tail->p, p); } @@ -529,15 +529,15 @@ void verifyNodeDegree(ReebGraph *rg) static void verifyBucketsArc(ReebGraph *UNUSED(rg), ReebArc *arc) { - ReebNode *head = (ReebNode*)arc->head; - ReebNode *tail = (ReebNode*)arc->tail; + ReebNode *head = (ReebNode *)arc->head; + ReebNode *tail = (ReebNode *)arc->tail; if (arc->bcount > 0) { int i; for (i = 0; i < arc->bcount; i++) { if (arc->buckets[i].nv == 0) { printArc(arc); - printf("count error in bucket %i/%i\n", i+1, arc->bcount); + printf("count error in bucket %i/%i\n", i + 1, arc->bcount); } } @@ -653,12 +653,12 @@ static void mergeArcBuckets(ReebArc *aDst, ReebArc *aSrc, float start, float end indexSrc++; } - for ( ; indexDst < aDst->bcount && - indexSrc < aSrc->bcount && - aDst->buckets[indexDst].val <= end && - aSrc->buckets[indexSrc].val <= end + for (; indexDst < aDst->bcount && + indexSrc < aSrc->bcount && + aDst->buckets[indexDst].val <= end && + aSrc->buckets[indexSrc].val <= end - ; indexDst++, indexSrc++) + ; indexDst++, indexSrc++) { mergeBuckets(aDst->buckets + indexDst, aSrc->buckets + indexSrc); } @@ -809,7 +809,7 @@ static void fillArcEmptyBuckets(ReebArc *arc) static void ExtendArcBuckets(ReebArc *arc) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; EmbedBucket *last_bucket, *first_bucket; float *previous = NULL; float average_length = 0, length; @@ -823,10 +823,10 @@ static void ExtendArcBuckets(ReebArc *arc) IT_next(iter); previous = iter->p; - for ( IT_next(iter); - IT_stopped(iter) == 0; - previous = iter->p, IT_next(iter) - ) + for (IT_next(iter); + IT_stopped(iter) == 0; + previous = iter->p, IT_next(iter) + ) { average_length += len_v3v3(previous, iter->p); } @@ -880,7 +880,7 @@ static void extendGraphBuckets(ReebGraph *rg) static void calculateArcLength(ReebArc *arc) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; float *vec0, *vec1; arc->length = 0; @@ -913,9 +913,9 @@ static void calculateGraphLength(ReebGraph *rg) /**************************************** SYMMETRY HANDLING ******************************************/ -void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) +void REEB_RadialSymmetry(BNode *root_node, RadialArc *ring, int count) { - ReebNode *node = (ReebNode*)root_node; + ReebNode *node = (ReebNode *)root_node; float axis[3]; int i; @@ -932,11 +932,11 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) add_v3_v3v3(tangent, ring[i].n, ring[j].n); cross_v3_v3v3(normal, tangent, axis); - node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); - node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); + node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node); + node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node); - arc1 = (ReebArc*)ring[i].arc; - arc2 = (ReebArc*)ring[j].arc; + arc1 = (ReebArc *)ring[i].arc; + arc2 = (ReebArc *)ring[j].arc; /* mirror first node and mix with the second */ BLI_mirrorAlongAxis(node1->p, root_node->p, normal); @@ -947,12 +947,12 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; - BArcIterator *iter1 = (BArcIterator*)&arc_iter1; - BArcIterator *iter2 = (BArcIterator*)&arc_iter2; + BArcIterator *iter1 = (BArcIterator *)&arc_iter1; + BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - initArcIterator(iter1, arc1, (ReebNode*)root_node); - initArcIterator(iter2, arc2, (ReebNode*)root_node); + initArcIterator(iter1, arc1, (ReebNode *)root_node); + initArcIterator(iter2, arc2, (ReebNode *)root_node); bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); @@ -967,7 +967,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) } - for ( ;bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { bucket2->nv += bucket1->nv; /* add counts */ /* mirror on axis */ @@ -989,11 +989,11 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) add_v3_v3v3(tangent, ring[i].n, ring[j].n); cross_v3_v3v3(normal, tangent, axis); - node1 = (ReebNode*)BLI_otherNode(ring[i].arc, root_node); - node2 = (ReebNode*)BLI_otherNode(ring[j].arc, root_node); + node1 = (ReebNode *)BLI_otherNode(ring[i].arc, root_node); + node2 = (ReebNode *)BLI_otherNode(ring[j].arc, root_node); - arc1 = (ReebArc*)ring[i].arc; - arc2 = (ReebArc*)ring[j].arc; + arc1 = (ReebArc *)ring[i].arc; + arc2 = (ReebArc *)ring[j].arc; /* copy first node than mirror */ copy_v3_v3(node2->p, node1->p); @@ -1004,8 +1004,8 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; - BArcIterator *iter1 = (BArcIterator*)&arc_iter1; - BArcIterator *iter2 = (BArcIterator*)&arc_iter2; + BArcIterator *iter1 = (BArcIterator *)&arc_iter1; + BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; initArcIterator(iter1, arc1, node); @@ -1024,7 +1024,7 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) } - for ( ;bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { /* copy and mirror back to bucket2 */ bucket2->nv = bucket1->nv; copy_v3_v3(bucket2->p, bucket1->p); @@ -1034,13 +1034,13 @@ void REEB_RadialSymmetry(BNode* root_node, RadialArc* ring, int count) } } -void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BArc* barc1, BArc* barc2) +void REEB_AxialSymmetry(BNode *root_node, BNode *node1, BNode *node2, struct BArc *barc1, BArc *barc2) { ReebArc *arc1, *arc2; float nor[3], p[3]; - arc1 = (ReebArc*)barc1; - arc2 = (ReebArc*)barc2; + arc1 = (ReebArc *)barc1; + arc2 = (ReebArc *)barc2; copy_v3_v3(nor, root_node->symmetry_axis); @@ -1061,12 +1061,12 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr * */ if (arc1->bcount > 0 && arc2->bcount > 0) { ReebArcIterator arc_iter1, arc_iter2; - BArcIterator *iter1 = (BArcIterator*)&arc_iter1; - BArcIterator *iter2 = (BArcIterator*)&arc_iter2; + BArcIterator *iter1 = (BArcIterator *)&arc_iter1; + BArcIterator *iter2 = (BArcIterator *)&arc_iter2; EmbedBucket *bucket1 = NULL, *bucket2 = NULL; - initArcIterator(iter1, arc1, (ReebNode*)root_node); - initArcIterator(iter2, arc2, (ReebNode*)root_node); + initArcIterator(iter1, arc1, (ReebNode *)root_node); + initArcIterator(iter2, arc2, (ReebNode *)root_node); bucket1 = IT_next(iter1); bucket2 = IT_next(iter2); @@ -1081,7 +1081,7 @@ void REEB_AxialSymmetry(BNode* root_node, BNode* node1, BNode* node2, struct BAr } - for ( ; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { + for (; bucket1 && bucket2; bucket1 = IT_next(iter1), bucket2 = IT_next(iter2)) { bucket1->nv += bucket2->nv; /* add counts */ /* mirror on axis */ @@ -1110,21 +1110,21 @@ void postprocessGraph(ReebGraph *rg, char mode) switch (mode) { - case SKGEN_AVERAGE: - fac1 = fac2 = fac3 = 1.0f / 3.0f; - break; - case SKGEN_SMOOTH: - fac1 = fac3 = 0.25f; - fac2 = 0.5f; - break; - case SKGEN_SHARPEN: - fac1 = fac3 = -0.25f; - fac2 = 1.5f; - break; - default: + case SKGEN_AVERAGE: + fac1 = fac2 = fac3 = 1.0f / 3.0f; + break; + case SKGEN_SMOOTH: + fac1 = fac3 = 0.25f; + fac2 = 0.5f; + break; + case SKGEN_SHARPEN: + fac1 = fac3 = -0.25f; + fac2 = 1.5f; + break; + default: // XXX // error("Unknown post processing mode"); - return; + return; } for (arc = rg->arcs.first; arc; arc = arc->next) @@ -1145,8 +1145,8 @@ void postprocessGraph(ReebGraph *rg, char mode) static int compareNodesWeight(void *vnode1, void *vnode2) { - ReebNode *node1 = (ReebNode*)vnode1; - ReebNode *node2 = (ReebNode*)vnode2; + ReebNode *node1 = (ReebNode *)vnode1; + ReebNode *node2 = (ReebNode *)vnode2; if (node1->weight < node2->weight) { @@ -1156,8 +1156,7 @@ static int compareNodesWeight(void *vnode1, void *vnode2) { return 1; } - else - { + else { return 0; } } @@ -1169,10 +1168,10 @@ void sortNodes(ReebGraph *rg) static int compareArcsWeight(void *varc1, void *varc2) { - ReebArc *arc1 = (ReebArc*)varc1; - ReebArc *arc2 = (ReebArc*)varc2; - ReebNode *node1 = (ReebNode*)arc1->head; - ReebNode *node2 = (ReebNode*)arc2->head; + ReebArc *arc1 = (ReebArc *)varc1; + ReebArc *arc2 = (ReebArc *)varc2; + ReebNode *node1 = (ReebNode *)arc1->head; + ReebNode *node2 = (ReebNode *)arc2->head; if (node1->weight < node2->weight) { @@ -1182,8 +1181,7 @@ static int compareArcsWeight(void *varc1, void *varc2) { return 1; } - else - { + else { return 0; } } @@ -1201,7 +1199,7 @@ static void reweightArc(ReebGraph *rg, ReebArc *arc, ReebNode *start_node, float float end_weight = start_weight + ABS(arc->tail->weight - arc->head->weight); int i; - node = (ReebNode*)BLI_otherNode((BArc*)arc, (BNode*)start_node); + node = (ReebNode *)BLI_otherNode((BArc *)arc, (BNode *)start_node); /* prevent backtracking */ if (node->flag == 1) @@ -1243,7 +1241,7 @@ static void reweightSubgraph(ReebGraph *rg, ReebNode *start_node, float start_we { int i; - BLI_flagNodes((BGraph*)rg, 0); + BLI_flagNodes((BGraph *)rg, 0); for (i = 0; i < start_node->degree; i++) { @@ -1317,15 +1315,15 @@ static int joinSubgraphsEnds(ReebGraph *rg, float threshold, int nb_subgraphs) if (merging) { - BLI_ReflagSubgraph((BGraph*)rg, end_node->flag, subgraph); + BLI_ReflagSubgraph((BGraph *)rg, end_node->flag, subgraph); resizeArcBuckets(start_arc); fillArcEmptyBuckets(start_arc); NodeDegreeIncrement(rg, end_node); - BLI_rebuildAdjacencyListForNode((BGraph*)rg, (BNode*)end_node); + BLI_rebuildAdjacencyListForNode((BGraph *)rg, (BNode *)end_node); - BLI_removeNode((BGraph*)rg, (BNode*)start_node); + BLI_removeNode((BGraph *)rg, (BNode *)start_node); } joined = 1; @@ -1368,10 +1366,9 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) int nb_subgraphs; int joined = 0; - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); - if (BLI_isGraphCyclic((BGraph*)rg)) - { + if (BLI_isGraphCyclic((BGraph *)rg)) { /* don't deal with cyclic graphs YET */ return 0; } @@ -1379,13 +1376,13 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) /* sort nodes before flagging subgraphs to make sure root node is subgraph 0 */ sortNodes(rg); - nb_subgraphs = BLI_FlagSubgraphs((BGraph*)rg); + nb_subgraphs = BLI_FlagSubgraphs((BGraph *)rg); /* Harmonic function can create flipped arcs, take the occasion to fix them */ // XXX // if (G.scene->toolsettings->skgen_options & SKGEN_HARMONIC) // { - fixSubgraphsOrientation(rg, nb_subgraphs); + fixSubgraphsOrientation(rg, nb_subgraphs); // } if (nb_subgraphs > 1) @@ -1395,7 +1392,7 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) if (joined) { removeNormalNodes(rg); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); } } @@ -1407,8 +1404,8 @@ static int joinSubgraphs(ReebGraph *rg, float threshold) static float lengthArc(ReebArc *arc) { #if 0 - ReebNode *head = (ReebNode*)arc->head; - ReebNode *tail = (ReebNode*)arc->tail; + ReebNode *head = (ReebNode *)arc->head; + ReebNode *tail = (ReebNode *)arc->tail; return tail->weight - head->weight; #else @@ -1418,8 +1415,8 @@ static float lengthArc(ReebArc *arc) static int compareArcs(void *varc1, void *varc2) { - ReebArc *arc1 = (ReebArc*)varc1; - ReebArc *arc2 = (ReebArc*)varc2; + ReebArc *arc1 = (ReebArc *)varc1; + ReebArc *arc2 = (ReebArc *)varc2; float len1 = lengthArc(arc1); float len2 = lengthArc(arc2); @@ -1434,7 +1431,7 @@ static int compareArcs(void *varc1, void *varc2) } } -static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc * srcArc, int merging) +static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, ReebArc *srcArc, int merging) { ReebArc *arc = NULL, *nextArc = NULL; @@ -1470,7 +1467,7 @@ static void filterArc(ReebGraph *rg, ReebNode *newNode, ReebNode *removedNode, R // If it's srcArc, it'll be removed later, so keep it for now if (arc != srcArc) { BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); } } else { @@ -1509,8 +1506,8 @@ void filterNullReebGraph(ReebGraph *rg) nextArc = arc->next; // Only collapse arcs too short to have any embed bucket if (arc->bcount == 0) { - ReebNode *newNode = (ReebNode*)arc->head; - ReebNode *removedNode = (ReebNode*)arc->tail; + ReebNode *newNode = (ReebNode *)arc->head; + ReebNode *removedNode = (ReebNode *)arc->tail; float blend; blend = (float)newNode->degree / (float)(newNode->degree + removedNode->degree); // blending factors @@ -1523,9 +1520,9 @@ void filterNullReebGraph(ReebGraph *rg) nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); } arc = nextArc; @@ -1561,9 +1558,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); value = 1; } @@ -1613,9 +1610,9 @@ static int filterInternalExternalReebGraph(ReebGraph *rg, float threshold_intern nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); value = 1; } } @@ -1641,7 +1638,7 @@ static int filterCyclesReebGraph(ReebGraph *rg, float UNUSED(distance_threshold) NodeDegreeDecrement(rg, arc1->tail); BLI_remlink(&rg->arcs, arc2); - REEB_freeArc((BArc*)arc2); + REEB_freeArc((BArc *)arc2); filtered = 1; } @@ -1662,7 +1659,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) #ifdef DEBUG_REEB { EditFace *efa; - for (efa=G.editMesh->faces.first; efa; efa=efa->next) { + for (efa = G.editMesh->faces.first; efa; efa = efa->next) { efa->tmp.fp = -1; } } @@ -1686,14 +1683,14 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) float avg_vec[3] = {0, 0, 0}; for (BLI_ghashIterator_init(&ghi, arc->faces); - !BLI_ghashIterator_isDone(&ghi); - BLI_ghashIterator_step(&ghi)) + !BLI_ghashIterator_isDone(&ghi); + BLI_ghashIterator_step(&ghi)) { EditFace *efa = BLI_ghashIterator_getValue(&ghi); #if 0 ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; EmbedBucket *bucket = NULL; EmbedBucket *previous = NULL; float min_distance = -1; @@ -1716,8 +1713,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) vec0 = arc->head->p; } /* Previous is a valid bucket */ - else - { + else { vec0 = previous->p; } @@ -1805,7 +1801,7 @@ int filterSmartReebGraph(ReebGraph *UNUSED(rg), float UNUSED(threshold)) nextArc = arc->next; BLI_remlink(&rg->arcs, arc); - REEB_freeArc((BArc*)arc); + REEB_freeArc((BArc *)arc); BLI_freelinkN(&rg->nodes, removedNode); value = 1; @@ -1858,7 +1854,7 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method) { int i; - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); sortNodes(rg); @@ -1873,10 +1869,10 @@ static void finalizeGraph(ReebGraph *rg, char passes, char method) /************************************** WEIGHT SPREADING ***********************************************/ -static int compareVerts(const void* a, const void* b) +static int compareVerts(const void *a, const void *b) { - EditVert *va = *(EditVert**)a; - EditVert *vb = *(EditVert**)b; + EditVert *va = *(EditVert **)a; + EditVert *vb = *(EditVert **)b; int value = 0; if (weightData(va) < weightData(vb)) { @@ -1897,7 +1893,7 @@ static void spreadWeight(EditMesh *em) int i; int work_needed = 1; - verts = MEM_callocN(sizeof(EditVert*) * totvert, "verts array"); + verts = MEM_callocN(sizeof(EditVert *) * totvert, "verts array"); for (eve = em->verts.first, i = 0; eve; eve = eve->next, i++) { verts[i] = eve; @@ -1905,7 +1901,7 @@ static void spreadWeight(EditMesh *em) while (work_needed == 1) { work_needed = 0; - qsort(verts, totvert, sizeof(EditVert*), compareVerts); + qsort(verts, totvert, sizeof(EditVert *), compareVerts); for (i = 0; i < totvert; i++) { eve = verts[i]; @@ -1976,7 +1972,7 @@ static void removeZeroNodes(ReebGraph *rg) next_node = node->next; if (node->degree == 0) { - BLI_removeNode((BGraph*)rg, (BNode*)node); + BLI_removeNode((BGraph *)rg, (BNode *)node); } } } @@ -1992,7 +1988,7 @@ void removeNormalNodes(ReebGraph *rg) while (arc->head->degree == 2 || arc->tail->degree == 2) { // merge at v1 if (arc->head->degree == 2) { - ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->head); + ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->head); /* If arcs are one after the other */ if (arc->head == connectedArc->tail) { @@ -2015,7 +2011,7 @@ void removeNormalNodes(ReebGraph *rg) /* merge at v2 */ if (arc->tail->degree == 2) { - ReebArc *connectedArc = (ReebArc*)BLI_findConnectedArc((BGraph*)rg, (BArc*)arc, (BNode*)arc->tail); + ReebArc *connectedArc = (ReebArc *)BLI_findConnectedArc((BGraph *)rg, (BArc *)arc, (BNode *)arc->tail); /* If arcs are one after the other */ if (arc->tail == connectedArc->head) { @@ -2073,8 +2069,8 @@ void mergeArcFaces(ReebGraph *UNUSED(rg), ReebArc *aDst, ReebArc *aSrc) GHashIterator ghi; for (BLI_ghashIterator_init(&ghi, aSrc->faces); - !BLI_ghashIterator_isDone(&ghi); - BLI_ghashIterator_step(&ghi)) + !BLI_ghashIterator_isDone(&ghi); + BLI_ghashIterator_step(&ghi)) { EditFace *efa = BLI_ghashIterator_getValue(&ghi); BLI_ghash_insert(aDst->faces, efa, efa); @@ -2107,11 +2103,11 @@ void mergeArcEdges(ReebGraph *rg, ReebArc *aDst, ReebArc *aSrc, MergeDirection d // if edge was the first in the list, point the edit edge to the new reeb edge instead. if (*p == e) { - *p = (void*)newEdge; + *p = (void *)newEdge; } // otherwise, advance in the list until the predecessor is found then insert it there else { - ReebEdge *previous = (ReebEdge*)*p; + ReebEdge *previous = (ReebEdge *)*p; while (previous->nextEdge != e) { previous = previous->nextEdge; @@ -2155,9 +2151,9 @@ int mergeConnectedArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) // remove a1 from graph BLI_remlink(&rg->arcs, a1); - REEB_freeArc((BArc*)a1); + REEB_freeArc((BArc *)a1); - BLI_removeNode((BGraph*)rg, (BNode*)removedNode); + BLI_removeNode((BGraph *)rg, (BNode *)removedNode); result = 1; return result; @@ -2183,7 +2179,7 @@ int mergeArcs(ReebGraph *rg, ReebArc *a0, ReebArc *a1) // remove a1 from graph BLI_remlink(&rg->arcs, a1); - REEB_freeArc((BArc*)a1); + REEB_freeArc((BArc *)a1); result = 1; } else if (a0->tail->weight > a1->tail->weight) { /* a1->tail->weight is in the middle */ @@ -2266,9 +2262,9 @@ static void glueByMergeSort(ReebGraph *rg, ReebArc *a0, ReebArc *a1, ReebEdge *e else { a1 = nextArcMappedToEdge(a1, e1); } - } } } +} static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2) { @@ -2281,7 +2277,7 @@ static void mergePaths(ReebGraph *rg, ReebEdge *e0, ReebEdge *e1, ReebEdge *e2) glueByMergeSort(rg, a0, a2, e0, e2); } -static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) +static ReebEdge *createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) { ReebEdge *edge; @@ -2359,7 +2355,7 @@ static ReebEdge * createArc(ReebGraph *rg, ReebNode *node1, ReebNode *node2) return edge; } -static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, ReebNode * n3, EditFace *efa) +static void addTriangleToGraph(ReebGraph *rg, ReebNode *n1, ReebNode *n2, ReebNode *n3, EditFace *efa) { ReebEdge *re1, *re2, *re3; ReebEdge *e1, *e2, *e3; @@ -2408,7 +2404,7 @@ static void addTriangleToGraph(ReebGraph *rg, ReebNode * n1, ReebNode * n2, Reeb mergePaths(rg, e1, e2, e3); } -ReebGraph * generateReebGraph(EditMesh *em, int subdivisions) +ReebGraph *generateReebGraph(EditMesh *em, int subdivisions) { ReebGraph *rg; EditVert *eve; @@ -2536,13 +2532,13 @@ static float cotan_weight(float *v1, float *v2, float *v3) if (clen == 0.0f) return 0.0f; - return dot_v3v3(a, b)/clen; + return dot_v3v3(a, b) / clen; } static void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2, int e3) { /* Angle opposite e1 */ - float t1= cotan_weight(v1->co, v2->co, v3->co) / e2; + float t1 = cotan_weight(v1->co, v2->co, v3->co) / e2; /* Angle opposite e2 */ float t2 = cotan_weight(v2->co, v3->co, v1->co) / e3; @@ -2554,9 +2550,9 @@ static void addTriangle(EditVert *v1, EditVert *v2, EditVert *v3, int e1, int e2 int i2 = indexData(v2); int i3 = indexData(v3); - nlMatrixAdd(i1, i1, t2+t3); - nlMatrixAdd(i2, i2, t1+t3); - nlMatrixAdd(i3, i3, t1+t2); + nlMatrixAdd(i1, i1, t2 + t3); + nlMatrixAdd(i2, i2, t1 + t3); + nlMatrixAdd(i3, i3, t1 + t2); nlMatrixAdd(i1, i2, -t3); nlMatrixAdd(i2, i1, -t3); @@ -2688,7 +2684,7 @@ int weightToHarmonic(EditMesh *em, EdgeIndex *indexed_edges) } -EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index) +EditEdge *NextEdgeForVert(EdgeIndex *indexed_edges, int index) { static int offset = -1; @@ -2712,7 +2708,7 @@ EditEdge * NextEdgeForVert(EdgeIndex *indexed_edges, int index) static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeIndex *indexed_edges) { - Heap *edge_heap; + Heap *edge_heap; EditVert *current_eve = NULL; EditEdge *eed = NULL; EditEdge *select_eed = NULL; @@ -2725,7 +2721,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd BLI_heap_insert(edge_heap, FLT_MAX, NULL); /* Initialize edge flag */ - for (eed= em->edges.first; eed; eed= eed->next) { + for (eed = em->edges.first; eed; eed = eed->next) { eed->f1 = 0; } @@ -2744,8 +2740,7 @@ static void shortestPathsFromVert(EditMesh *em, EditVert *starting_vert, EdgeInd } /* Find next shortest edge with unselected verts */ - do - { + do { current_weight = BLI_heap_node_value(BLI_heap_top(edge_heap)); select_eed = BLI_heap_popmin(edge_heap); } while (select_eed != NULL && select_eed->v1->f1 != 0 && select_eed->v2->f1); @@ -2795,7 +2790,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) tot_indexed += totvert; - indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge*), "EdgeIndex edges"); + indexed_edges->edges = MEM_callocN(tot_indexed * sizeof(EditEdge *), "EdgeIndex edges"); /* setting vert offsets */ for (eve = em->verts.first; eve; eve = eve->next) { @@ -2807,7 +2802,7 @@ static void buildIndexedEdges(EditMesh *em, EdgeIndex *indexed_edges) } /* adding edges in array */ - for (eed = em->edges.first; eed; eed= eed->next) { + for (eed = em->edges.first; eed; eed = eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { int i; for (i = indexed_edges->offset[indexData(eed->v1)]; i < tot_indexed; i++) { @@ -2862,7 +2857,7 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) int allDone = 0; /* Calculate edge weight */ - for (eed = em->edges.first; eed; eed= eed->next) { + for (eed = em->edges.first; eed; eed = eed->next) { if (eed->v1->h == 0 && eed->v2->h == 0) { eed->tmp.fp = len_v3v3(eed->v1->co, eed->v2->co); } @@ -2925,12 +2920,12 @@ int weightFromDistance(EditMesh *em, EdgeIndex *indexed_edges) /****************************************** BUCKET ITERATOR **************************************************/ -static void* headNode(void *arg); -static void* tailNode(void *arg); -static void* nextBucket(void *arg); -static void* nextNBucket(void *arg, int n); -static void* peekBucket(void *arg, int n); -static void* previousBucket(void *arg); +static void *headNode(void *arg); +static void *tailNode(void *arg); +static void *nextBucket(void *arg); +static void *nextNBucket(void *arg, int n); +static void *peekBucket(void *arg, int n); +static void *previousBucket(void *arg); static int iteratorStopped(void *arg); static void initIteratorFct(ReebArcIterator *iter) @@ -2959,7 +2954,7 @@ static void setIteratorValues(ReebArcIterator *iter, EmbedBucket *bucket) void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; initIteratorFct(iter); iter->arc = arc; @@ -2982,7 +2977,7 @@ void initArcIterator(BArcIterator *arg, ReebArc *arc, ReebNode *head) void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNode *head, int start) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; initIteratorFct(iter); iter->arc = arc; @@ -3009,7 +3004,7 @@ void initArcIteratorStart(BArcIterator *arg, struct ReebArc *arc, struct ReebNod void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; initIteratorFct(iter); iter->arc = arc; @@ -3029,9 +3024,9 @@ void initArcIterator2(BArcIterator *arg, ReebArc *arc, int start, int end) iter->length = abs(iter->end - iter->start) + 1; } -static void* headNode(void *arg) +static void *headNode(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; ReebNode *node; if (iter->start < iter->end) { @@ -3048,9 +3043,9 @@ static void* headNode(void *arg) return node; } -static void* tailNode(void *arg) +static void *tailNode(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; ReebNode *node; if (iter->start < iter->end) { @@ -3067,9 +3062,9 @@ static void* tailNode(void *arg) return node; } -static void* nextBucket(void *arg) +static void *nextBucket(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; iter->index++; @@ -3082,9 +3077,9 @@ static void* nextBucket(void *arg) return result; } -static void* nextNBucket(void *arg, int n) +static void *nextNBucket(void *arg, int n) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; iter->index += n; @@ -3098,9 +3093,9 @@ static void* nextNBucket(void *arg, int n) return result; } -static void* peekBucket(void *arg, int n) +static void *peekBucket(void *arg, int n) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; int index = iter->index + n; @@ -3113,9 +3108,9 @@ static void* peekBucket(void *arg, int n) return result; } -static void* previousBucket(void *arg) +static void *previousBucket(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; EmbedBucket *result = NULL; if (iter->index > 0) { @@ -3129,7 +3124,7 @@ static void* previousBucket(void *arg) static int iteratorStopped(void *arg) { - ReebArcIterator *iter = (ReebArcIterator*)arg; + ReebArcIterator *iter = (ReebArcIterator *)arg; if (iter->index >= iter->length) { return 1; @@ -3148,7 +3143,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) #if 0 Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); - EditMesh *em = BKE_mesh_get_editmesh(((Mesh*)obedit->data)); + EditMesh *em = BKE_mesh_get_editmesh(((Mesh *)obedit->data)); EdgeIndex indexed_edges; VertexData *data; ReebGraph *rg = NULL; @@ -3193,10 +3188,10 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) joinSubgraphs(rg, 1.0); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); /* calc length before copy, so we have same length on all levels */ - BLI_calcGraphLength((BGraph*)rg); + BLI_calcGraphLength((BGraph *)rg); previous = NULL; for (i = 0; i <= nb_levels; i++) @@ -3214,8 +3209,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) { internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal; } - else - { + else { internal_threshold = rg->length * scene->toolsettings->skgen_threshold_internal * (2 * i / (float)nb_levels); } @@ -3231,7 +3225,7 @@ ReebGraph *BIF_ReebGraphMultiFromEditMesh(bContext *C) finalizeGraph(rgi, scene->toolsettings->skgen_postpro_passes, scene->toolsettings->skgen_postpro); - BLI_markdownSymmetry((BGraph*)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit); + BLI_markdownSymmetry((BGraph *)rgi, rgi->nodes.first, scene->toolsettings->skgen_symmetry_limit); if (previous != NULL) { @@ -3306,10 +3300,10 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) joinSubgraphs(rg, 1.0); - BLI_buildAdjacencyList((BGraph*)rg); + BLI_buildAdjacencyList((BGraph *)rg); /* calc length before copy, so we have same length on all levels */ - BLI_calcGraphLength((BGraph*)rg); + BLI_calcGraphLength((BGraph *)rg); filterGraph(rg, G.scene->toolsettings->skgen_options, G.scene->toolsettings->skgen_threshold_internal, G.scene->toolsettings->skgen_threshold_external); @@ -3323,7 +3317,7 @@ ReebGraph *BIF_ReebGraphFromEditMesh(void) #endif printf("DONE\n"); - printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph*)rg)); + printf("%i subgraphs\n", BLI_FlagSubgraphs((BGraph *)rg)); MEM_freeN(data); @@ -3363,13 +3357,12 @@ void REEB_draw() if (GLOBAL_RG->link_up && G.scene->toolsettings->skgen_options & SKGEN_DISP_ORIG) { - for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up); + for (rg = GLOBAL_RG; rg->link_up; rg = rg->link_up) ; } - else - { + else { i = G.scene->toolsettings->skgen_multi_level; - for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up); + for (rg = GLOBAL_RG; rg->multi_level != i && rg->link_up; rg = rg->link_up) ; } glPointSize(BIF_GetThemeValuef(TH_VERTEX_SIZE)); @@ -3378,7 +3371,7 @@ void REEB_draw() for (arc = rg->arcs.first; arc; arc = arc->next, i++) { ReebArcIterator arc_iter; - BArcIterator *iter = (BArcIterator*)&arc_iter; + BArcIterator *iter = (BArcIterator *)&arc_iter; float vec[3]; char text[128]; char *s = text; @@ -3386,18 +3379,18 @@ void REEB_draw() glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE) + 2); glColor3f(0, 0, 0); glBegin(GL_LINE_STRIP); - glVertex3fv(arc->head->p); + glVertex3fv(arc->head->p); - if (arc->bcount) + if (arc->bcount) + { + initArcIterator(iter, arc, arc->head); + for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter)) { - initArcIterator(iter, arc, arc->head); - for (IT_next(iter); IT_stopped(iter) == 0; IT_next(iter)) - { - glVertex3fv(iter->p); - } + glVertex3fv(iter->p); } + } - glVertex3fv(arc->tail->p); + glVertex3fv(arc->tail->p); glEnd(); glLineWidth(BIF_GetThemeValuef(TH_VERTEX_SIZE)); @@ -3414,13 +3407,33 @@ void REEB_draw() { glColor3f(0.5f, 1, 0); } - else - { + else { glColor3f(1, 1, 0); } glBegin(GL_LINE_STRIP); - glVertex3fv(arc->head->p); + glVertex3fv(arc->head->p); + if (arc->bcount) + { + initArcIterator(iter, arc, arc->head); + for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter)) + { + glVertex3fv(iter->p); + } + } + + glVertex3fv(arc->tail->p); + glEnd(); + + + if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED) + { + glColor3f(1, 1, 1); + glBegin(GL_POINTS); + glVertex3fv(arc->head->p); + glVertex3fv(arc->tail->p); + + glColor3f(0.5f, 0.5f, 1); if (arc->bcount) { initArcIterator(iter, arc, arc->head); @@ -3429,27 +3442,6 @@ void REEB_draw() glVertex3fv(iter->p); } } - - glVertex3fv(arc->tail->p); - glEnd(); - - - if (G.scene->toolsettings->skgen_options & SKGEN_DISP_EMBED) - { - glColor3f(1, 1, 1); - glBegin(GL_POINTS); - glVertex3fv(arc->head->p); - glVertex3fv(arc->tail->p); - - glColor3f(0.5f, 0.5f, 1); - if (arc->bcount) - { - initArcIterator(iter, arc, arc->head); - for (iter->next(iter); IT_stopped(iter) == 0; iter->next(iter)) - { - glVertex3fv(iter->p); - } - } glEnd(); } diff --git a/source/blender/editors/armature/reeb.h b/source/blender/editors/armature/reeb.h index a9b32da4e5b..d71e80ca0ca 100644 --- a/source/blender/editors/armature/reeb.h +++ b/source/blender/editors/armature/reeb.h @@ -41,15 +41,15 @@ struct ReebEdge; struct ReebNode; typedef struct ReebGraph { - ListBase arcs; - ListBase nodes; + ListBase arcs; + ListBase nodes; float length; - FreeArc free_arc; - FreeNode free_node; - RadialSymmetry radial_symmetry; - AxialSymmetry axial_symmetry; + FreeArc free_arc; + FreeNode free_node; + RadialSymmetry radial_symmetry; + AxialSymmetry axial_symmetry; /*********************************/ int resolution; @@ -61,7 +61,7 @@ typedef struct ReebGraph { typedef struct EmbedBucket { float val; - int nv; + int nv; float p[3]; float no[3]; /* if non-null, normal of the bucket */ } EmbedBucket; @@ -85,7 +85,7 @@ typedef struct ReebNode { int index; float weight; - int multi_level; + int multi_level; struct ReebNode *link_down; /* for multi resolution filtering, points to lower levels, if present */ struct ReebNode *link_up; } ReebNode; @@ -120,13 +120,13 @@ typedef struct ReebArc { } ReebArc; typedef struct ReebArcIterator { - HeadFct head; - TailFct tail; - PeekFct peek; - NextFct next; - NextNFct nextN; - PreviousFct previous; - StoppedFct stopped; + HeadFct head; + TailFct tail; + PeekFct peek; + NextFct next; + NextNFct nextN; + PreviousFct previous; + StoppedFct stopped; float *p, *no; float size; @@ -134,7 +134,7 @@ typedef struct ReebArcIterator { int length; int index; /*********************************/ - struct ReebArc *arc; + struct ReebArc *arc; int start; int end; int stride; @@ -151,8 +151,8 @@ void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index); void angleToVCol(struct EditMesh *em, int index); void renormalizeWeight(struct EditMesh *em, float newmax); -ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions); -ReebGraph * newReebGraph(void); +ReebGraph *generateReebGraph(struct EditMesh *me, int subdivisions); +ReebGraph *newReebGraph(void); void initArcIterator(BArcIterator *iter, struct ReebArc *arc, struct ReebNode *head); void initArcIterator2(BArcIterator *iter, struct ReebArc *arc, int start, int end); @@ -178,7 +178,7 @@ void verifyNodeDegree(ReebGraph *rg); /*********************** PUBLIC *********************************/ -#define REEB_MAX_MULTI_LEVEL 10 +#define REEB_MAX_MULTI_LEVEL 10 struct bContext; diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 94ec7c7ce93..dea7ccb161d 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -140,15 +140,15 @@ void ED_operatormacros_curve(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate curve and move"; + ot = WM_operatortype_append_macro("CURVE_OT_duplicate_move", "Add Duplicate", "Duplicate curve and move", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Extrude curve and move result"; + ot = WM_operatortype_append_macro("CURVE_OT_extrude_move", "Extrude Curve and Move", + "Extrude curve and move result", OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CURVE_OT_extrude"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 09c01c2bf8c..be10e3c4c3f 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -29,7 +29,6 @@ * \ingroup edcurve */ - #include #include @@ -108,9 +107,9 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus); /* still need to eradicate a few :( */ -#define callocstructN(x, y, name) (x*)MEM_callocN((y)* sizeof(x), name) +#define callocstructN(x, y, name) (x *)MEM_callocN((y) * sizeof(x), name) -static float nurbcircle[8][2]= { +static float nurbcircle[8][2] = { {0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0, 1.0}, {0.0, 1.0}, { 1.0, 1.0}, { 1.0, 0.0}, { 1.0, -1.0} }; @@ -118,7 +117,7 @@ static float nurbcircle[8][2]= { ListBase *object_editcurve_get(Object *ob) { if (ob && ELEM(ob->type, OB_CURVE, OB_SURF)) { - Curve *cu= ob->data; + Curve *cu = ob->data; return &cu->editnurb->nurbs; } return NULL; @@ -127,39 +126,39 @@ ListBase *object_editcurve_get(Object *ob) /* this replaces the active flag used in uv/face mode */ static void set_actNurb(Object *obedit, Nurb *nu) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; - if (nu==NULL) + if (nu == NULL) cu->actnu = -1; else { - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + ListBase *nurbs = BKE_curve_editNurbs_get(cu); cu->actnu = BLI_findindex(nurbs, nu); } } static Nurb *get_actNurb(Object *obedit) { - Curve *cu= obedit->data; - ListBase *nurbs= BKE_curve_editNurbs_get(cu); + Curve *cu = obedit->data; + ListBase *nurbs = BKE_curve_editNurbs_get(cu); return BLI_findlink(nurbs, cu->actnu); } /* ******************* SELECTION FUNCTIONS ********************* */ -#define HIDDEN 1 -#define VISIBLE 0 +#define HIDDEN 1 +#define VISIBLE 0 -#define FIRST 1 -#define LAST 0 +#define FIRST 1 +#define LAST 0 /* returns 1 in case (de)selection was successful */ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden) { if (bezt) { - if ((bezt->hide==0) || (hidden==1)) { - if (selstatus==1) { /* selects */ + if ((bezt->hide == 0) || (hidden == 1)) { + if (selstatus == 1) { /* selects */ bezt->f1 |= flag; bezt->f2 |= flag; bezt->f3 |= flag; @@ -181,8 +180,8 @@ static short select_beztriple(BezTriple *bezt, short selstatus, short flag, shor static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden) { if (bp) { - if ((bp->hide==0) || (hidden==1)) { - if (selstatus==1) { + if ((bp->hide == 0) || (hidden == 1)) { + if (selstatus == 1) { bp->f1 |= flag; return 1; } @@ -219,18 +218,18 @@ int isNurbsel(Nurb *nu) int a; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1; bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if ( (bp->f1 & SELECT) ) return 1; + if (bp->f1 & SELECT) return 1; bp++; } } @@ -241,19 +240,19 @@ static int isNurbsel_count(Curve *cu, Nurb *nu) { BezTriple *bezt; BPoint *bp; - int a, sel=0; + int a, sel = 0; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) sel++; bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if ( (bp->f1 & SELECT) ) sel++; bp++; @@ -266,19 +265,19 @@ static int isNurbsel_count(Curve *cu, Nurb *nu) void printknots(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; int a, num; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu) && nu->type == CU_NURBS) { if (nu->knotsu) { - num= KNOTSU(nu); - for (a=0;aknotsu[a]); + num = KNOTSU(nu); + for (a = 0; a < num; a++) printf("knotu %d: %f\n", a, nu->knotsu[a]); } if (nu->knotsv) { - num= KNOTSV(nu); - for (a=0;aknotsv[a]); + num = KNOTSV(nu); + for (a = 0; a < num; a++) printf("knotv %d: %f\n", a, nu->knotsv[a]); } } } @@ -290,66 +289,66 @@ static CVKeyIndex *init_cvKeyIndex(void *cv, int key_index, int nu_index, int pt { CVKeyIndex *cvIndex = MEM_callocN(sizeof(CVKeyIndex), "init_cvKeyIndex"); - cvIndex->orig_cv= cv; - cvIndex->key_index= key_index; - cvIndex->nu_index= nu_index; - cvIndex->pt_index= pt_index; - cvIndex->switched= 0; - cvIndex->orig_nu= orig_nu; + cvIndex->orig_cv = cv; + cvIndex->key_index = key_index; + cvIndex->nu_index = nu_index; + cvIndex->pt_index = pt_index; + cvIndex->switched = 0; + cvIndex->orig_nu = orig_nu; return cvIndex; } static void init_editNurb_keyIndex(EditNurb *editnurb, ListBase *origBase) { - Nurb *nu= editnurb->nurbs.first; - Nurb *orignu= origBase->first; + Nurb *nu = editnurb->nurbs.first; + Nurb *orignu = origBase->first; GHash *gh; BezTriple *bezt, *origbezt; BPoint *bp, *origbp; CVKeyIndex *keyIndex; - int a, key_index= 0, nu_index= 0, pt_index= 0; + int a, key_index = 0, nu_index = 0, pt_index = 0; if (editnurb->keyindex) return; - gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex"); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "editNurb keyIndex"); while (orignu) { if (orignu->bezt) { - a= orignu->pntsu; - bezt= nu->bezt; - origbezt= orignu->bezt; - pt_index= 0; + a = orignu->pntsu; + bezt = nu->bezt; + origbezt = orignu->bezt; + pt_index = 0; while (a--) { - keyIndex= init_cvKeyIndex(origbezt, key_index, nu_index, pt_index, orignu); + keyIndex = init_cvKeyIndex(origbezt, key_index, nu_index, pt_index, orignu); BLI_ghash_insert(gh, bezt, keyIndex); - key_index+= 12; + key_index += 12; bezt++; origbezt++; pt_index++; } } else { - a= orignu->pntsu * orignu->pntsv; - bp= nu->bp; - origbp= orignu->bp; - pt_index= 0; + a = orignu->pntsu * orignu->pntsv; + bp = nu->bp; + origbp = orignu->bp; + pt_index = 0; while (a--) { - keyIndex= init_cvKeyIndex(origbp, key_index, nu_index, pt_index, orignu); + keyIndex = init_cvKeyIndex(origbp, key_index, nu_index, pt_index, orignu); BLI_ghash_insert(gh, bp, keyIndex); - key_index+= 4; + key_index += 4; bp++; origbp++; pt_index++; } } - nu= nu->next; - orignu= orignu->next; + nu = nu->next; + orignu = orignu->next; nu_index++; } - editnurb->keyindex= gh; + editnurb->keyindex = gh; } static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, void *cv) @@ -359,29 +358,29 @@ static CVKeyIndex *getCVKeyIndex(EditNurb *editnurb, void *cv) static BezTriple *getKeyIndexOrig_bezt(EditNurb *editnurb, BezTriple *bezt) { - CVKeyIndex *index= getCVKeyIndex(editnurb, bezt); + CVKeyIndex *index = getCVKeyIndex(editnurb, bezt); if (!index) { return NULL; } - return (BezTriple*)index->orig_cv; + return (BezTriple *)index->orig_cv; } static BPoint *getKeyIndexOrig_bp(EditNurb *editnurb, BPoint *bp) { - CVKeyIndex *index= getCVKeyIndex(editnurb, bp); + CVKeyIndex *index = getCVKeyIndex(editnurb, bp); if (!index) { return NULL; } - return (BPoint*)index->orig_cv; + return (BPoint *)index->orig_cv; } static int getKeyIndexOrig_keyIndex(EditNurb *editnurb, void *cv) { - CVKeyIndex *index= getCVKeyIndex(editnurb, cv); + CVKeyIndex *index = getCVKeyIndex(editnurb, cv); if (!index) { return -1; @@ -418,38 +417,38 @@ static void keyIndex_delNurb(EditNurb *editnurb, Nurb *nu) } if (nu->bezt) { - BezTriple *bezt= nu->bezt; - a= nu->pntsu; + BezTriple *bezt = nu->bezt; + a = nu->pntsu; while (a--) { BLI_ghash_remove(editnurb->keyindex, bezt, NULL, (GHashValFreeFP)MEM_freeN); - ++bezt; + bezt++; } } else { - BPoint *bp= nu->bp; - a= nu->pntsu * nu->pntsv; + BPoint *bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { BLI_ghash_remove(editnurb->keyindex, bp, NULL, (GHashValFreeFP)MEM_freeN); - ++bp; + bp++; } } } static void keyIndex_delNurbList(EditNurb *editnurb, ListBase *nubase) { - Nurb *nu= nubase->first; + Nurb *nu = nubase->first; while (nu) { keyIndex_delNurb(editnurb, nu); - nu= nu->next; + nu = nu->next; } } static void keyIndex_updateCV(EditNurb *editnurb, char *cv, - char *newcv, int count, int size) + char *newcv, int count, int size) { int i; CVKeyIndex *index; @@ -460,7 +459,7 @@ static void keyIndex_updateCV(EditNurb *editnurb, char *cv, } for (i = 0; i < count; i++) { - index= getCVKeyIndex(editnurb, cv); + index = getCVKeyIndex(editnurb, cv); BLI_ghash_remove(editnurb->keyindex, cv, NULL, NULL); @@ -474,15 +473,15 @@ static void keyIndex_updateCV(EditNurb *editnurb, char *cv, } static void keyIndex_updateBezt(EditNurb *editnurb, BezTriple *bezt, - BezTriple *newbezt, int count) + BezTriple *newbezt, int count) { - keyIndex_updateCV(editnurb, (char*)bezt, (char*)newbezt, count, sizeof(BezTriple)); + keyIndex_updateCV(editnurb, (char *)bezt, (char *)newbezt, count, sizeof(BezTriple)); } static void keyIndex_updateBP(EditNurb *editnurb, BPoint *bp, - BPoint *newbp, int count) + BPoint *newbp, int count) { - keyIndex_updateCV(editnurb, (char*)bp, (char*)newbp, count, sizeof(BPoint)); + keyIndex_updateCV(editnurb, (char *)bp, (char *)newbp, count, sizeof(BPoint)); } static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu) @@ -497,8 +496,8 @@ static void keyIndex_updateNurb(EditNurb *editnurb, Nurb *nu, Nurb *newnu) static void keyIndex_swap(EditNurb *editnurb, void *a, void *b) { - CVKeyIndex *index1= getCVKeyIndex(editnurb, a); - CVKeyIndex *index2= getCVKeyIndex(editnurb, b); + CVKeyIndex *index1 = getCVKeyIndex(editnurb, a); + CVKeyIndex *index2 = getCVKeyIndex(editnurb, b); BLI_ghash_remove(editnurb->keyindex, a, NULL, NULL); BLI_ghash_remove(editnurb->keyindex, b, NULL, NULL); @@ -515,25 +514,25 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) if (nu->bezt) { BezTriple *bezt1, *bezt2; - a= nu->pntsu; + a = nu->pntsu; - bezt1= nu->bezt; - bezt2= bezt1+(a-1); + bezt1 = nu->bezt; + bezt2 = bezt1 + (a - 1); if (a & 1) ++a; - a/=2; + a /= 2; while (a--) { - index1= getCVKeyIndex(editnurb, bezt1); - index2= getCVKeyIndex(editnurb, bezt2); + index1 = getCVKeyIndex(editnurb, bezt1); + index2 = getCVKeyIndex(editnurb, bezt2); - if (index1) index1->switched= !index1->switched; + if (index1) index1->switched = !index1->switched; if (bezt1 != bezt2) { keyIndex_swap(editnurb, bezt1, bezt2); - if (index2) index2->switched= !index2->switched; + if (index2) index2->switched = !index2->switched; } bezt1++; @@ -544,18 +543,18 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) BPoint *bp1, *bp2; if (nu->pntsv == 1) { - a= nu->pntsu; - bp1= nu->bp; - bp2= bp1+(a-1); - a/= 2; - while (bp1!=bp2 && a>0) { - index1= getCVKeyIndex(editnurb, bp1); - index2= getCVKeyIndex(editnurb, bp2); + a = nu->pntsu; + bp1 = nu->bp; + bp2 = bp1 + (a - 1); + a /= 2; + while (bp1 != bp2 && a > 0) { + index1 = getCVKeyIndex(editnurb, bp1); + index2 = getCVKeyIndex(editnurb, bp2); - if (index1) index1->switched= !index1->switched; + if (index1) index1->switched = !index1->switched; if (bp1 != bp2) { - if (index2) index2->switched= !index2->switched; + if (index2) index2->switched = !index2->switched; keyIndex_swap(editnurb, bp1, bp2); } @@ -568,21 +567,21 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) else { int b; - for (b=0; bpntsv; b++) { + for (b = 0; b < nu->pntsv; b++) { - bp1= nu->bp+b*nu->pntsu; - a= nu->pntsu; - bp2= bp1+(a-1); - a/= 2; + bp1 = &nu->bp[b * nu->pntsu]; + a = nu->pntsu; + bp2 = bp1 + (a - 1); + a /= 2; - while (bp1!=bp2 && a>0) { - index1= getCVKeyIndex(editnurb, bp1); - index2= getCVKeyIndex(editnurb, bp2); + while (bp1 != bp2 && a > 0) { + index1 = getCVKeyIndex(editnurb, bp1); + index2 = getCVKeyIndex(editnurb, bp2); - if (index1) index1->switched= !index1->switched; + if (index1) index1->switched = !index1->switched; if (bp1 != bp2) { - if (index2) index2->switched= !index2->switched; + if (index2) index2->switched = !index2->switched; keyIndex_swap(editnurb, bp1, bp2); } @@ -600,26 +599,26 @@ static void keyIndex_switchDirection(EditNurb *editnurb, Nurb *nu) static void switch_keys_direction(Curve *cu, Nurb *actnu) { KeyBlock *currkey; - EditNurb *editnurb= cu->editnurb; - ListBase *nubase= &editnurb->nurbs; + EditNurb *editnurb = cu->editnurb; + ListBase *nubase = &editnurb->nurbs; Nurb *nu; float *fp; int a; currkey = cu->key->block.first; while (currkey) { - fp= currkey->data; + fp = currkey->data; - nu= nubase->first; + nu = nubase->first; while (nu) { if (nu->bezt) { - BezTriple *bezt= nu->bezt; - a= nu->pntsu; + BezTriple *bezt = nu->bezt; + a = nu->pntsu; if (nu == actnu) { while (a--) { if (getKeyIndexOrig_bezt(editnurb, bezt)) { swap_v3_v3(fp, fp + 6); - *(fp+9) = -*(fp+9); + *(fp + 9) = -*(fp + 9); fp += 12; } bezt++; @@ -628,12 +627,12 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu) else fp += a * 12; } else { - BPoint *bp= nu->bp; - a= nu->pntsu * nu->pntsv; + BPoint *bp = nu->bp; + a = nu->pntsu * nu->pntsv; if (nu == actnu) { while (a--) { if (getKeyIndexOrig_bp(editnurb, bp)) { - *(fp+3) = -*(fp+3); + *(fp + 3) = -*(fp + 3); fp += 4; } bp++; @@ -642,16 +641,16 @@ static void switch_keys_direction(Curve *cu, Nurb *actnu) else fp += a * 4; } - nu= nu->next; + nu = nu->next; } - currkey= currkey->next; + currkey = currkey->next; } } static void keyData_switchDirectionNurb(Curve *cu, Nurb *nu) { - EditNurb *editnurb= cu->editnurb; + EditNurb *editnurb = cu->editnurb; if (!editnurb->keyindex) { /* no shape keys - nothing to do */ @@ -668,11 +667,12 @@ static GHash *dupli_keyIndexHash(GHash *keyindex) GHash *gh; GHashIterator *hashIter; - gh= BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh"); + gh = BLI_ghash_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "dupli_keyIndex gh"); for (hashIter = BLI_ghashIterator_new(keyindex); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter)) { + !BLI_ghashIterator_isDone(hashIter); + BLI_ghashIterator_step(hashIter)) + { void *cv = BLI_ghashIterator_getKey(hashIter); CVKeyIndex *index = BLI_ghashIterator_getValue(hashIter); CVKeyIndex *newIndex = MEM_callocN(sizeof(CVKeyIndex), "dupli_keyIndexHash index"); @@ -691,7 +691,7 @@ static void key_to_bezt(float *key, BezTriple *basebezt, BezTriple *bezt) { memcpy(bezt, basebezt, sizeof(BezTriple)); memcpy(bezt->vec, key, sizeof(float) * 9); - bezt->alfa= key[9]; + bezt->alfa = key[9]; } static void bezt_to_key(BezTriple *bezt, float *key) @@ -704,31 +704,31 @@ static void calc_keyHandles(ListBase *nurb, float *key) { Nurb *nu; int a; - float *fp= key; + float *fp = key; BezTriple *bezt; - nu= nurb->first; + nu = nurb->first; while (nu) { if (nu->bezt) { BezTriple *prevp, *nextp; BezTriple cur, prev, next; float *startfp, *prevfp, *nextfp; - bezt= nu->bezt; - a= nu->pntsu; - startfp= fp; + bezt = nu->bezt; + a = nu->pntsu; + startfp = fp; if (nu->flagu & CU_NURB_CYCLIC) { - prevp= bezt+(a-1); - prevfp= fp+(12 * (a-1)); + prevp = bezt + (a - 1); + prevfp = fp + (12 * (a - 1)); } else { - prevp= NULL; - prevfp= NULL; + prevp = NULL; + prevfp = NULL; } - nextp= bezt + 1; - nextfp= fp + 12; + nextp = bezt + 1; + nextfp = fp + 12; while (a--) { key_to_bezt(fp, bezt, &cur); @@ -739,99 +739,99 @@ static void calc_keyHandles(ListBase *nurb, float *key) BKE_nurb_handle_calc(&cur, prevp ? &prev : NULL, nextp ? &next : NULL, 0); bezt_to_key(&cur, fp); - prevp= bezt; - prevfp= fp; - if (a==1) { + prevp = bezt; + prevfp = fp; + if (a == 1) { if (nu->flagu & CU_NURB_CYCLIC) { - nextp= nu->bezt; - nextfp= startfp; + nextp = nu->bezt; + nextfp = startfp; } else { - nextp= NULL; - nextfp= NULL; + nextp = NULL; + nextfp = NULL; } } else { - ++nextp; + nextp++; nextfp += 12; } - ++bezt; + bezt++; fp += 12; } } else { - a= nu->pntsu * nu->pntsv; + a = nu->pntsu * nu->pntsv; fp += a * 4; } - nu= nu->next; + nu = nu->next; } } static void calc_shapeKeys(Object *obedit) { - Curve *cu= (Curve*)obedit->data; + Curve *cu = (Curve *)obedit->data; /* are there keys? */ if (cu->key) { int a, i; - EditNurb *editnurb= cu->editnurb; + EditNurb *editnurb = cu->editnurb; KeyBlock *currkey; - KeyBlock *actkey= BLI_findlink(&cu->key->block, editnurb->shapenr-1); + KeyBlock *actkey = BLI_findlink(&cu->key->block, editnurb->shapenr - 1); BezTriple *bezt, *oldbezt; BPoint *bp, *oldbp; Nurb *nu; - int totvert= BKE_nurbList_verts_count(&editnurb->nurbs); + int totvert = BKE_nurbList_verts_count(&editnurb->nurbs); float (*ofs)[3] = NULL; float *oldkey, *newkey, *ofp; /* editing the base key should update others */ - if (cu->key->type==KEY_RELATIVE) { + if (cu->key->type == KEY_RELATIVE) { int act_is_basis = 0; /* find if this key is a basis for any others */ - for (currkey = cu->key->block.first; currkey; currkey= currkey->next) { - if (editnurb->shapenr-1 == currkey->relative) { + for (currkey = cu->key->block.first; currkey; currkey = currkey->next) { + if (editnurb->shapenr - 1 == currkey->relative) { act_is_basis = 1; break; } } if (act_is_basis) { /* active key is a base */ - int totvec= 0; + int totvec = 0; /* Calculate needed memory to store offset */ - nu= editnurb->nurbs.first; + nu = editnurb->nurbs.first; while (nu) { if (nu->bezt) { /* Three vects to store handles and one for alfa */ - totvec+= nu->pntsu * 4; + totvec += nu->pntsu * 4; } else { - totvec+= 2 * nu->pntsu * nu->pntsv; + totvec += 2 * nu->pntsu * nu->pntsv; } - nu= nu->next; + nu = nu->next; } - ofs= MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data"); - nu= editnurb->nurbs.first; - i= 0; + ofs = MEM_callocN(sizeof(float) * 3 * totvec, "currkey->data"); + nu = editnurb->nurbs.first; + i = 0; while (nu) { if (nu->bezt) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - oldbezt= getKeyIndexOrig_bezt(editnurb, bezt); + oldbezt = getKeyIndexOrig_bezt(editnurb, bezt); if (oldbezt) { int j; - for (j= 0; j < 3; ++j) { + for (j = 0; j < 3; ++j) { sub_v3_v3v3(ofs[i], bezt->vec[j], oldbezt->vec[j]); i++; } - ofs[i++][0]= bezt->alfa - oldbezt->alfa; + ofs[i++][0] = bezt->alfa - oldbezt->alfa; } else { i += 4; @@ -840,81 +840,81 @@ static void calc_shapeKeys(Object *obedit) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - oldbp= getKeyIndexOrig_bp(editnurb, bp); + oldbp = getKeyIndexOrig_bp(editnurb, bp); if (oldbp) { sub_v3_v3v3(ofs[i], bp->vec, oldbp->vec); - ofs[i+1][0]= bp->alfa - oldbp->alfa; + ofs[i + 1][0] = bp->alfa - oldbp->alfa; } i += 2; - ++bp; + bp++; } } - nu= nu->next; + nu = nu->next; } } } currkey = cu->key->block.first; while (currkey) { - int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr-1 == currkey->relative)); + int apply_offset = (ofs && (currkey != actkey) && (editnurb->shapenr - 1 == currkey->relative)); - float *fp= newkey= MEM_callocN(cu->key->elemsize * totvert, "currkey->data"); - ofp= oldkey = currkey->data; + float *fp = newkey = MEM_callocN(cu->key->elemsize * totvert, "currkey->data"); + ofp = oldkey = currkey->data; - nu= editnurb->nurbs.first; + nu = editnurb->nurbs.first; i = 0; while (nu) { if (currkey == actkey) { - int restore= actkey != cu->key->refkey; + int restore = actkey != cu->key->refkey; if (nu->bezt) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { int j; - oldbezt= getKeyIndexOrig_bezt(editnurb, bezt); + oldbezt = getKeyIndexOrig_bezt(editnurb, bezt); - for (j= 0; j < 3; ++j, ++i) { + for (j = 0; j < 3; ++j, ++i) { copy_v3_v3(fp, bezt->vec[j]); if (restore && oldbezt) { copy_v3_v3(bezt->vec[j], oldbezt->vec[j]); } - fp+= 3; + fp += 3; } - fp[0]= bezt->alfa; + fp[0] = bezt->alfa; if (restore && oldbezt) { - bezt->alfa= oldbezt->alfa; + bezt->alfa = oldbezt->alfa; } - fp+= 3; ++i;/* alphas */ - ++bezt; + fp += 3; ++i; /* alphas */ + bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - oldbp= getKeyIndexOrig_bp(editnurb, bp); + oldbp = getKeyIndexOrig_bp(editnurb, bp); copy_v3_v3(fp, bp->vec); - fp[3]= bp->alfa; + fp[3] = bp->alfa; if (restore && oldbp) { copy_v3_v3(bp->vec, oldbp->vec); - bp->alfa= oldbp->alfa; + bp->alfa = oldbp->alfa; } - fp+= 4; - ++bp; - i+=2; + fp += 4; + bp++; + i += 2; } } } @@ -924,77 +924,77 @@ static void calc_shapeKeys(Object *obedit) if (oldkey) { if (nu->bezt) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - index= getKeyIndexOrig_keyIndex(editnurb, bezt); + index = getKeyIndexOrig_keyIndex(editnurb, bezt); if (index >= 0) { int j; - curofp= ofp + index; + curofp = ofp + index; - for (j= 0; j < 3; ++j, ++i) { + for (j = 0; j < 3; ++j, ++i) { copy_v3_v3(fp, curofp); if (apply_offset) { add_v3_v3(fp, ofs[i]); } - fp+= 3; curofp+= 3; + fp += 3; curofp += 3; } - fp[0]= curofp[0]; + fp[0] = curofp[0]; if (apply_offset) { /* apply alfa offsets */ add_v3_v3(fp, ofs[i]); - ++i; + i++; } - fp+= 3; /* alphas */ + fp += 3; /* alphas */ } else { int j; - for (j= 0; j < 3; ++j, ++i) { + for (j = 0; j < 3; ++j, ++i) { copy_v3_v3(fp, bezt->vec[j]); - fp+= 3; + fp += 3; } - fp[0]= bezt->alfa; + fp[0] = bezt->alfa; - fp+= 3; /* alphas */ + fp += 3; /* alphas */ } - ++bezt; + bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - index= getKeyIndexOrig_keyIndex(editnurb, bp); + index = getKeyIndexOrig_keyIndex(editnurb, bp); if (index >= 0) { - curofp= ofp + index; + curofp = ofp + index; copy_v3_v3(fp, curofp); - fp[3]= curofp[3]; + fp[3] = curofp[3]; if (apply_offset) { add_v3_v3(fp, ofs[i]); - fp[3]+=ofs[i+1][0]; + fp[3] += ofs[i + 1][0]; } } else { copy_v3_v3(fp, bp->vec); - fp[3]= bp->alfa; + fp[3] = bp->alfa; } - fp+= 4; - ++bp; - i+=2; + fp += 4; + bp++; + i += 2; } } } } - nu= nu->next; + nu = nu->next; } if (apply_offset) { @@ -1002,11 +1002,11 @@ static void calc_shapeKeys(Object *obedit) calc_keyHandles(&editnurb->nurbs, newkey); } - currkey->totelem= totvert; + currkey->totelem = totvert; if (currkey->data) MEM_freeN(currkey->data); currkey->data = newkey; - currkey= currkey->next; + currkey = currkey->next; } if (ofs) MEM_freeN(ofs); @@ -1017,7 +1017,7 @@ static void calc_shapeKeys(Object *obedit) static int curve_is_animated(Curve *cu) { - AnimData *ad= BKE_animdata_from_id(&cu->id); + AnimData *ad = BKE_animdata_from_id(&cu->id); return ad && (ad->action || ad->drivers.first); } @@ -1025,16 +1025,16 @@ static int curve_is_animated(Curve *cu) static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path, ListBase *orig_curves, ListBase *curves) { FCurve *fcu, *nfcu, *nextfcu; - int len= strlen(orig_rna_path); + int len = strlen(orig_rna_path); - fcu= orig_curves->first; + fcu = orig_curves->first; while (fcu) { - nextfcu= fcu->next; + nextfcu = fcu->next; if (!strncmp(fcu->rna_path, orig_rna_path, len)) { - char *spath, *suffix= fcu->rna_path + len; - nfcu= copy_fcurve(fcu); - spath= nfcu->rna_path; - nfcu->rna_path= BLI_sprintfN("%s%s", rna_path, suffix); + char *spath, *suffix = fcu->rna_path + len; + nfcu = copy_fcurve(fcu); + spath = nfcu->rna_path; + nfcu->rna_path = BLI_sprintfN("%s%s", rna_path, suffix); BLI_addtail(curves, nfcu); if (fcu->grp) { @@ -1050,13 +1050,13 @@ static void fcurve_path_rename(AnimData *ad, char *orig_rna_path, char *rna_path MEM_freeN(spath); } - fcu= nextfcu; + fcu = nextfcu; } } static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu) { - if (orig_curves==&ad->drivers) BLI_remlink(&ad->drivers, fcu); + if (orig_curves == &ad->drivers) BLI_remlink(&ad->drivers, fcu); else action_groups_remove_channel(ad->action, fcu); free_fcurve(fcu); @@ -1064,23 +1064,23 @@ static void fcurve_remove(AnimData *ad, ListBase *orig_curves, FCurve *fcu) static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) { - int nu_index= 0, a, pt_index; - EditNurb *editnurb= cu->editnurb; - Nurb *nu= editnurb->nurbs.first; + int nu_index = 0, a, pt_index; + EditNurb *editnurb = cu->editnurb; + Nurb *nu = editnurb->nurbs.first; CVKeyIndex *keyIndex; char rna_path[64], orig_rna_path[64]; - AnimData *ad= BKE_animdata_from_id(&cu->id); - ListBase curves= {NULL, NULL}; + AnimData *ad = BKE_animdata_from_id(&cu->id); + ListBase curves = {NULL, NULL}; FCurve *fcu, *next; while (nu) { if (nu->bezt) { - BezTriple *bezt= nu->bezt; - a= nu->pntsu; - pt_index= 0; + BezTriple *bezt = nu->bezt; + a = nu->pntsu; + pt_index = 0; while (a--) { - keyIndex= getCVKeyIndex(editnurb, bezt); + keyIndex = getCVKeyIndex(editnurb, bezt); if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index); @@ -1098,8 +1098,8 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); - keyIndex->nu_index= nu_index; - keyIndex->pt_index= pt_index; + keyIndex->nu_index = nu_index; + keyIndex->pt_index = pt_index; } bezt++; @@ -1107,50 +1107,50 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } } else { - BPoint *bp= nu->bp; - a= nu->pntsu * nu->pntsv; - pt_index= 0; + BPoint *bp = nu->bp; + a = nu->pntsu * nu->pntsv; + pt_index = 0; while (a--) { - keyIndex= getCVKeyIndex(editnurb, bp); + keyIndex = getCVKeyIndex(editnurb, bp); if (keyIndex) { BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index); BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves); - keyIndex->nu_index= nu_index; - keyIndex->pt_index= pt_index; + keyIndex->nu_index = nu_index; + keyIndex->pt_index = pt_index; } bp++; pt_index++; } } - nu= nu->next; + nu = nu->next; nu_index++; } /* remove paths for removed control points * need this to make further step with copying non-cv related curves copying * not touching cv's f-curves */ - for (fcu= orig_curves->first; fcu; fcu= next) { - next= fcu->next; + for (fcu = orig_curves->first; fcu; fcu = next) { + next = fcu->next; if (!strncmp(fcu->rna_path, "splines", 7)) { - char *ch= strchr(fcu->rna_path, '.'); + char *ch = strchr(fcu->rna_path, '.'); if (ch && (!strncmp(ch, ".bezier_points", 14) || !strncmp(ch, ".points", 7))) fcurve_remove(ad, orig_curves, fcu); } } - nu_index= 0; - nu= editnurb->nurbs.first; + nu_index = 0; + nu = editnurb->nurbs.first; while (nu) { - keyIndex= NULL; + keyIndex = NULL; if (nu->pntsu) { - if (nu->bezt) keyIndex= getCVKeyIndex(editnurb, &nu->bezt[0]); - else keyIndex= getCVKeyIndex(editnurb, &nu->bp[0]); + if (nu->bezt) keyIndex = getCVKeyIndex(editnurb, &nu->bezt[0]); + else keyIndex = getCVKeyIndex(editnurb, &nu->bp[0]); } if (keyIndex) { @@ -1160,25 +1160,25 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } nu_index++; - nu= nu->next; + nu = nu->next; } /* the remainders in orig_curves can be copied back (like follow path) */ /* (if it's not path to spline) */ - for (fcu= orig_curves->first; fcu; fcu= next) { - next= fcu->next; + for (fcu = orig_curves->first; fcu; fcu = next) { + next = fcu->next; if (!strncmp(fcu->rna_path, "splines", 7)) fcurve_remove(ad, orig_curves, fcu); else BLI_addtail(&curves, fcu); } - *orig_curves= curves; + *orig_curves = curves; } /* return 0 if animation data wasn't changed, 1 otherwise */ int ED_curve_updateAnimPaths(Curve *cu) { - AnimData *ad= BKE_animdata_from_id(&cu->id); + AnimData *ad = BKE_animdata_from_id(&cu->id); if (!curve_is_animated(cu)) return 0; @@ -1195,19 +1195,19 @@ int ED_curve_updateAnimPaths(Curve *cu) /* load editNurb in object */ void load_editNurb(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); - if (obedit==NULL) return; + if (obedit == NULL) return; set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; Nurb *nu, *newnu; - ListBase newnurb= {NULL, NULL}, oldnurb= cu->nurb; + ListBase newnurb = {NULL, NULL}, oldnurb = cu->nurb; - for (nu= editnurb->first; nu; nu= nu->next) { - newnu= BKE_nurb_duplicate(nu); + for (nu = editnurb->first; nu; nu = nu->next) { + newnu = BKE_nurb_duplicate(nu); BLI_addtail(&newnurb, newnu); if (nu->type == CU_NURBS) { @@ -1215,7 +1215,7 @@ void load_editNurb(Object *obedit) } } - cu->nurb= newnurb; + cu->nurb = newnurb; calc_shapeKeys(obedit); ED_curve_updateAnimPaths(obedit->data); @@ -1229,16 +1229,16 @@ void load_editNurb(Object *obedit) /* make copy in cu->editnurb */ void make_editNurb(Object *obedit) { - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; - Nurb *nu, *newnu, *nu_act= NULL; + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; + Nurb *nu, *newnu, *nu_act = NULL; KeyBlock *actkey; set_actNurb(obedit, NULL); if (ELEM(obedit->type, OB_CURVE, OB_SURF)) { - actkey= ob_get_keyblock(obedit); + actkey = ob_get_keyblock(obedit); if (actkey) { // XXX strcpy(G.editModeTitleExtra, "(Key) "); @@ -1249,31 +1249,31 @@ void make_editNurb(Object *obedit) if (editnurb) { BKE_nurbList_free(&editnurb->nurbs); BKE_curve_editNurb_keyIndex_free(editnurb); - editnurb->keyindex= NULL; + editnurb->keyindex = NULL; } else { - editnurb= MEM_callocN(sizeof(EditNurb), "editnurb"); - cu->editnurb= editnurb; + editnurb = MEM_callocN(sizeof(EditNurb), "editnurb"); + cu->editnurb = editnurb; } - nu= cu->nurb.first; - cu->lastsel= NULL; /* for select row */ + nu = cu->nurb.first; + cu->lastsel = NULL; /* for select row */ while (nu) { - newnu= BKE_nurb_duplicate(nu); - BKE_nurb_test2D(newnu); // after join, or any other creation of curve + newnu = BKE_nurb_duplicate(nu); + BKE_nurb_test2D(newnu); // after join, or any other creation of curve BLI_addtail(&editnurb->nurbs, newnu); if (nu_act == NULL && isNurbsel(nu)) { - nu_act= newnu; + nu_act = newnu; set_actNurb(obedit, newnu); } - nu= nu->next; + nu = nu->next; } if (actkey) - editnurb->shapenr= obedit->shapenr; + editnurb->shapenr = obedit->shapenr; /* animation could be added in editmode even if there was no animdata i * object mode hence we always need CVs index be created */ @@ -1283,14 +1283,14 @@ void make_editNurb(Object *obedit) void free_editNurb(Object *obedit) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; BKE_curve_editNurb_free(cu); } void CU_deselect_all(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); if (editnurb) { selectend_nurb(obedit, FIRST, 0, DESELECT); /* set first control points as unselected */ @@ -1300,7 +1300,7 @@ void CU_deselect_all(Object *obedit) void CU_select_all(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); if (editnurb) { selectend_nurb(obedit, FIRST, 0, SELECT); /* set first control points as unselected */ @@ -1310,25 +1310,25 @@ void CU_select_all(Object *obedit) void CU_select_swap(Object *obedit) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); if (editnurb) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; Nurb *nu; BPoint *bp; BezTriple *bezt; int a; - cu->lastsel= NULL; + cu->lastsel = NULL; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (bezt->hide==0) { + if (bezt->hide == 0) { bezt->f2 ^= SELECT; /* always do the center point */ - if ((cu->drawflag & CU_HIDE_HANDLES)==0) { + if ((cu->drawflag & CU_HIDE_HANDLES) == 0) { bezt->f1 ^= SELECT; bezt->f3 ^= SELECT; } @@ -1337,8 +1337,8 @@ void CU_select_swap(Object *obedit) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { swap_selection_bpoint(bp); bp++; @@ -1352,18 +1352,18 @@ void CU_select_swap(Object *obedit) static int separate_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); Nurb *nu, *nu1; Object *oldob, *newob; Base *oldbase, *newbase; Curve *oldcu, *newcu; EditNurb *oldedit, *newedit; - oldbase= CTX_data_active_base(C); - oldob= oldbase->object; - oldcu= oldob->data; - oldedit= oldcu->editnurb; + oldbase = CTX_data_active_base(C); + oldob = oldbase->object; + oldcu = oldob->data; + oldedit = oldcu->editnurb; if (oldcu->key) { BKE_report(op->reports, RPT_ERROR, "Can't separate a curve with vertex keys"); @@ -1373,23 +1373,23 @@ static int separate_exec(bContext *C, wmOperator *op) WM_cursor_wait(1); /* 1. duplicate the object and data */ - newbase= ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ + newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ ED_base_object_select(newbase, BA_DESELECT); - newob= newbase->object; + newob = newbase->object; - newcu= newob->data= BKE_curve_copy(oldcu); - newcu->editnurb= NULL; + newcu = newob->data = BKE_curve_copy(oldcu); + newcu->editnurb = NULL; oldcu->id.us--; /* because new curve is a copy: reduce user count */ /* 2. put new object in editmode and clear it */ make_editNurb(newob); - newedit= newcu->editnurb; + newedit = newcu->editnurb; BKE_nurbList_free(&newedit->nurbs); BKE_curve_editNurb_keyIndex_free(newedit); /* 3. move over parts from old object */ - for (nu= oldedit->nurbs.first; nu; nu=nu1) { - nu1= nu->next; + for (nu = oldedit->nurbs.first; nu; nu = nu1) { + nu1 = nu->next; if (isNurbsel(nu)) { BLI_remlink(&oldedit->nurbs, nu); @@ -1401,10 +1401,10 @@ static int separate_exec(bContext *C, wmOperator *op) load_editNurb(newob); free_editNurb(newob); - DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ - DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ + DAG_id_tag_update(&oldob->id, OB_RECALC_DATA); /* this is the original one */ + DAG_id_tag_update(&newob->id, OB_RECALC_DATA); /* this is the separated one */ - WM_event_add_notifier(C, NC_GEOM|ND_DATA, oldob->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, oldob->data); WM_cursor_wait(0); @@ -1423,7 +1423,7 @@ void CURVE_OT_separate(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************* FLAGS ********************* */ @@ -1436,36 +1436,36 @@ static short isNurbselUV(Nurb *nu, int *u, int *v, int flag) BPoint *bp; int a, b, sel; - *u= *v= -1; + *u = *v = -1; - bp= nu->bp; - for (b=0; bpntsv; b++) { - sel= 0; - for (a=0; apntsu; a++, bp++) { + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { + sel = 0; + for (a = 0; a < nu->pntsu; a++, bp++) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsu) { - if (*u== -1) *u= b; + if (sel == nu->pntsu) { + if (*u == -1) *u = b; else return 0; } - else if (sel>1) return 0; /* because sel==1 is still ok */ + else if (sel > 1) return 0; /* because sel==1 is still ok */ } - for (a=0; apntsu; a++) { - sel= 0; - bp= nu->bp+a; - for (b=0; bpntsv; b++, bp+=nu->pntsu) { + for (a = 0; a < nu->pntsu; a++) { + sel = 0; + bp = &nu->bp[a]; + for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsv) { - if (*v== -1) *v= a; + if (sel == nu->pntsv) { + if (*v == -1) *v = a; else return 0; } - else if (sel>1) return 0; + else if (sel > 1) return 0; } - if (*u==-1 && *v>-1) return 1; - if (*v==-1 && *u>-1) return 1; + if (*u == -1 && *v > -1) return 1; + if (*v == -1 && *u > -1) return 1; return 0; } @@ -1476,20 +1476,20 @@ static void setflagsNurb(ListBase *editnurb, short flag) BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - bezt->f1= bezt->f2= bezt->f3= flag; + bezt->f1 = bezt->f2 = bezt->f3 = flag; bezt++; } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - bp->f1= flag; + bp->f1 = flag; bp++; } } @@ -1503,10 +1503,10 @@ static void rotateflagNurb(ListBase *editnurb, short flag, float *cent, float ro BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_NURBS) { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->f1 & flag) { @@ -1528,10 +1528,10 @@ static void translateflagNurb(ListBase *editnurb, short flag, const float vec[3] BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { if (bezt->f1 & flag) add_v3_v3(bezt->vec[0], vec); if (bezt->f2 & flag) add_v3_v3(bezt->vec[1], vec); @@ -1540,8 +1540,8 @@ static void translateflagNurb(ListBase *editnurb, short flag, const float vec[3] } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { if (bp->f1 & flag) add_v3_v3(bp->vec, vec); bp++; @@ -1558,14 +1558,14 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w) BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_NURBS) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { if (bp->f1 & flag) { /* a mode used to exist for replace/multiple but is was unused */ - bp->vec[3]*= w; + bp->vec[3] *= w; } bp++; } @@ -1575,102 +1575,100 @@ static void weightflagNurb(ListBase *editnurb, short flag, float w) static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu, *next; BPoint *bp, *bpn, *newbp; int a, b, newu, newv, sel; - if (obedit->type==OB_SURF); + if (obedit->type == OB_SURF) ; else return OPERATOR_CANCELLED; - cu->lastsel= NULL; + cu->lastsel = NULL; - nu= editnurb->first; + nu = editnurb->first; while (nu) { - next= nu->next; + next = nu->next; /* is entire nurb selected */ - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a) { a--; - if (bp->f1 & flag); + if (bp->f1 & flag) ; else break; bp++; } - if (a==0) { + if (a == 0) { BLI_remlink(editnurb, nu); keyIndex_delNurb(cu->editnurb, nu); - BKE_nurb_free(nu); nu=NULL; + BKE_nurb_free(nu); nu = NULL; } else { /* is nurb in U direction selected */ - newv= nu->pntsv; - bp= nu->bp; - for (b=0; bpntsv; b++) { - sel= 0; - for (a=0; apntsu; a++, bp++) { + newv = nu->pntsv; + bp = nu->bp; + for (b = 0; b < nu->pntsv; b++) { + sel = 0; + for (a = 0; a < nu->pntsu; a++, bp++) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsu) { + if (sel == nu->pntsu) { newv--; } - else if (sel>=1) { + else if (sel >= 1) { /* don't delete */ break; } } - if (newv!=nu->pntsv && b==nu->pntsv) { + if (newv != nu->pntsv && b == nu->pntsv) { /* delete */ - bp= nu->bp; - bpn = newbp = - (BPoint*) MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); - for (b=0; bpntsv; b++) { - if ((bp->f1 & flag)==0) { - memcpy(bpn, bp, nu->pntsu*sizeof(BPoint)); + bp = nu->bp; + bpn = newbp = (BPoint *)MEM_mallocN(newv * nu->pntsu * sizeof(BPoint), "deleteNurb"); + for (b = 0; b < nu->pntsv; b++) { + if ((bp->f1 & flag) == 0) { + memcpy(bpn, bp, nu->pntsu * sizeof(BPoint)); keyIndex_updateBP(cu->editnurb, bp, bpn, nu->pntsu); - bpn+= nu->pntsu; + bpn += nu->pntsu; } else { keyIndex_delBP(cu->editnurb, bp); } - bp+= nu->pntsu; + bp += nu->pntsu; } - nu->pntsv= newv; + nu->pntsv = newv; MEM_freeN(nu->bp); - nu->bp= newbp; + nu->bp = newbp; BKE_nurb_order_clamp_v(nu); BKE_nurb_knot_calc_v(nu); } else { /* is the nurb in V direction selected */ - newu= nu->pntsu; - for (a=0; apntsu; a++) { - bp= nu->bp+a; - sel= 0; - for (b=0; bpntsv; b++, bp+=nu->pntsu) { + newu = nu->pntsu; + for (a = 0; a < nu->pntsu; a++) { + bp = &nu->bp[a]; + sel = 0; + for (b = 0; b < nu->pntsv; b++, bp += nu->pntsu) { if (bp->f1 & flag) sel++; } - if (sel==nu->pntsv) { + if (sel == nu->pntsv) { newu--; } - else if (sel>=1) { + else if (sel >= 1) { /* don't delete */ break; } } - if (newu!=nu->pntsu && a==nu->pntsu) { + if (newu != nu->pntsu && a == nu->pntsu) { /* delete */ - bp= nu->bp; - bpn = newbp = - (BPoint*) MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb"); - for (b=0; bpntsv; b++) { - for (a=0; apntsu; a++, bp++) { - if ((bp->f1 & flag)==0) { - *bpn= *bp; + bp = nu->bp; + bpn = newbp = (BPoint *)MEM_mallocN(newu * nu->pntsv * sizeof(BPoint), "deleteNurb"); + for (b = 0; b < nu->pntsv; b++) { + for (a = 0; a < nu->pntsu; a++, bp++) { + if ((bp->f1 & flag) == 0) { + *bpn = *bp; keyIndex_updateBP(cu->editnurb, bp, bpn, 1); bpn++; } @@ -1680,28 +1678,28 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) } } MEM_freeN(nu->bp); - nu->bp= newbp; - if (newu==1 && nu->pntsv>1) { /* make a U spline */ - nu->pntsu= nu->pntsv; - nu->pntsv= 1; + nu->bp = newbp; + if (newu == 1 && nu->pntsv > 1) { /* make a U spline */ + nu->pntsu = nu->pntsv; + nu->pntsv = 1; SWAP(short, nu->orderu, nu->orderv); BKE_nurb_order_clamp_u(nu); if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv= NULL; + nu->knotsv = NULL; } else { - nu->pntsu= newu; + nu->pntsu = newu; BKE_nurb_order_clamp_u(nu); } BKE_nurb_knot_calc_u(nu); } } } - nu= next; + nu = next; } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); return OPERATOR_FINISHED; } @@ -1711,30 +1709,29 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) { Nurb *nu; BPoint *bp, *bpn, *newbp; - int ok= 0, a, u, v, len; + int ok = 0, a, u, v, len; - nu= editnurb->nurbs.first; + nu = editnurb->nurbs.first; while (nu) { - if (nu->pntsv==1) { - bp= nu->bp; - a= nu->pntsu; + if (nu->pntsv == 1) { + bp = nu->bp; + a = nu->pntsu; while (a) { - if (bp->f1 & flag); + if (bp->f1 & flag) ; else break; bp++; a--; } - if (a==0) { - ok= 1; - newbp = - (BPoint*)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1"); + if (a == 0) { + ok = 1; + newbp = (BPoint *)MEM_mallocN(2 * nu->pntsu * sizeof(BPoint), "extrudeNurb1"); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); - bp= newbp+ nu->pntsu; + bp = newbp + nu->pntsu; ED_curve_bpcpy(editnurb, bp, nu->bp, nu->pntsu); MEM_freeN(nu->bp); - nu->bp= newbp; - a= nu->pntsu; + nu->bp = newbp; + a = nu->pntsu; while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); select_bpoint(newbp, DESELECT, flag, HIDDEN); @@ -1742,83 +1739,81 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) newbp++; } - nu->pntsv= 2; - nu->orderv= 2; + nu->pntsv = 2; + nu->orderv = 2; BKE_nurb_knot_calc_v(nu); } } else { /* which row or column is selected */ - if ( isNurbselUV(nu, &u, &v, flag) ) { + if (isNurbselUV(nu, &u, &v, flag) ) { /* deselect all */ - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { select_bpoint(bp, DESELECT, flag, HIDDEN); bp++; } - if (u==0 || u== nu->pntsv-1) { /* row in u-direction selected */ - ok= 1; - newbp = - (BPoint*) MEM_mallocN(nu->pntsu*(nu->pntsv + 1) - * sizeof(BPoint), "extrudeNurb1"); - if (u==0) { - len= nu->pntsv*nu->pntsu; - ED_curve_bpcpy(editnurb, newbp+nu->pntsu, nu->bp, len); + if (u == 0 || u == nu->pntsv - 1) { /* row in u-direction selected */ + ok = 1; + newbp = (BPoint *)MEM_mallocN(nu->pntsu * (nu->pntsv + 1) * + sizeof(BPoint), "extrudeNurb1"); + if (u == 0) { + len = nu->pntsv * nu->pntsu; + ED_curve_bpcpy(editnurb, newbp + nu->pntsu, nu->bp, len); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); - bp= newbp; + bp = newbp; } else { - len= nu->pntsv*nu->pntsu; + len = nu->pntsv * nu->pntsu; ED_curve_bpcpy(editnurb, newbp, nu->bp, len); - ED_curve_bpcpy(editnurb, newbp+len, nu->bp+len-nu->pntsu, nu->pntsu); - bp= newbp+len; + ED_curve_bpcpy(editnurb, newbp + len, &nu->bp[len - nu->pntsu], nu->pntsu); + bp = newbp + len; } - a= nu->pntsu; + a = nu->pntsu; while (a--) { select_bpoint(bp, SELECT, flag, HIDDEN); bp++; } MEM_freeN(nu->bp); - nu->bp= newbp; + nu->bp = newbp; nu->pntsv++; BKE_nurb_knot_calc_v(nu); } - else if (v==0 || v== nu->pntsu-1) { /* column in v-direction selected */ - ok= 1; - bpn = newbp = - (BPoint*) MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1"); - bp= nu->bp; + else if (v == 0 || v == nu->pntsu - 1) { /* column in v-direction selected */ + ok = 1; + bpn = newbp = (BPoint *)MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1"); + bp = nu->bp; - for (a=0; apntsv; a++) { - if (v==0) { - *bpn= *bp; + for (a = 0; a < nu->pntsv; a++) { + if (v == 0) { + *bpn = *bp; bpn->f1 |= flag; bpn++; } ED_curve_bpcpy(editnurb, bpn, bp, nu->pntsu); - bp+= nu->pntsu; - bpn+= nu->pntsu; - if (v== nu->pntsu-1) { - *bpn= *(bp-1); + bp += nu->pntsu; + bpn += nu->pntsu; + if (v == nu->pntsu - 1) { + *bpn = *(bp - 1); bpn->f1 |= flag; bpn++; } } MEM_freeN(nu->bp); - nu->bp= newbp; + nu->bp = newbp; nu->pntsu++; BKE_nurb_knot_calc_u(nu); } } } - nu= nu->next; + nu = nu->next; } return ok; @@ -1826,49 +1821,48 @@ static short extrudeflagNurb(EditNurb *editnurb, int flag) static void adduplicateflagNurb(Object *obedit, short flag) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu, *newnu; BezTriple *bezt, *bezt1; BPoint *bp, *bp1; - Curve *cu= (Curve*)obedit->data; + Curve *cu = (Curve *)obedit->data; int a, b, starta, enda, newu, newv; char *usel; - cu->lastsel= NULL; + cu->lastsel = NULL; - nu= editnurb->last; + nu = editnurb->last; while (nu) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - for (a=0; apntsu; a++) { - enda= -1; - starta= a; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu; a++) { + enda = -1; + starta = a; while ( (bezt->f1 & flag) || (bezt->f2 & flag) || (bezt->f3 & flag) ) { select_beztriple(bezt, DESELECT, flag, HIDDEN); - enda=a; - if (a>=nu->pntsu-1) break; + enda = a; + if (a >= nu->pntsu - 1) break; a++; bezt++; } - if (enda>=starta) { - newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN"); + if (enda >= starta) { + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(editnurb, newnu); set_actNurb(obedit, newnu); - newnu->pntsu= enda-starta+1; - newnu->bezt= - (BezTriple*)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN"); - memcpy(newnu->bezt, nu->bezt+starta, newnu->pntsu*sizeof(BezTriple)); + newnu->pntsu = enda - starta + 1; + newnu->bezt = (BezTriple *)MEM_mallocN((enda - starta + 1) * sizeof(BezTriple), "adduplicateN"); + memcpy(newnu->bezt, &nu->bezt[starta], newnu->pntsu * sizeof(BezTriple)); - b= newnu->pntsu; - bezt1= newnu->bezt; + b = newnu->pntsu; + bezt1 = newnu->bezt; while (b--) { select_beztriple(bezt1, SELECT, flag, HIDDEN); bezt1++; } if (nu->flagu & CU_NURB_CYCLIC) { - if (starta!=0 || enda!=nu->pntsu-1) { + if (starta != 0 || enda != nu->pntsu - 1) { newnu->flagu &= ~CU_NURB_CYCLIC; } } @@ -1876,42 +1870,42 @@ static void adduplicateflagNurb(Object *obedit, short flag) bezt++; } } - else if (nu->pntsv==1) { /* because UV Nurb has a different method for dupli */ - bp= nu->bp; - for (a=0; apntsu; a++) { - enda= -1; - starta= a; + else if (nu->pntsv == 1) { /* because UV Nurb has a different method for dupli */ + bp = nu->bp; + for (a = 0; a < nu->pntsu; a++) { + enda = -1; + starta = a; while (bp->f1 & flag) { select_bpoint(bp, DESELECT, flag, HIDDEN); - enda= a; - if (a>=nu->pntsu-1) break; + enda = a; + if (a >= nu->pntsu - 1) break; a++; bp++; } - if (enda>=starta) { - newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN3"); + if (enda >= starta) { + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN3"); memcpy(newnu, nu, sizeof(Nurb)); set_actNurb(obedit, newnu); BLI_addtail(editnurb, newnu); - newnu->pntsu= enda-starta+1; - newnu->bp = (BPoint*)MEM_mallocN((enda-starta+1) * sizeof(BPoint), "adduplicateN4"); - memcpy(newnu->bp, nu->bp+starta, newnu->pntsu*sizeof(BPoint)); + newnu->pntsu = enda - starta + 1; + newnu->bp = (BPoint *)MEM_mallocN((enda - starta + 1) * sizeof(BPoint), "adduplicateN4"); + memcpy(newnu->bp, &nu->bp[starta], newnu->pntsu * sizeof(BPoint)); - b= newnu->pntsu; - bp1= newnu->bp; + b = newnu->pntsu; + bp1 = newnu->bp; while (b--) { select_bpoint(bp1, SELECT, flag, HIDDEN); bp1++; } if (nu->flagu & CU_NURB_CYCLIC) { - if (starta!=0 || enda!=nu->pntsu-1) { + if (starta != 0 || enda != nu->pntsu - 1) { newnu->flagu &= ~CU_NURB_CYCLIC; } } /* knots */ - newnu->knotsu= NULL; + newnu->knotsu = NULL; BKE_nurb_knot_calc_u(newnu); } bp++; @@ -1920,52 +1914,51 @@ static void adduplicateflagNurb(Object *obedit, short flag) else { /* a rectangular area in nurb has to be selected */ if (isNurbsel(nu)) { - usel= MEM_callocN(nu->pntsu, "adduplicateN4"); - bp= nu->bp; - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++, bp++) { + usel = MEM_callocN(nu->pntsu, "adduplicateN4"); + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++, bp++) { if (bp->f1 & flag) usel[b]++; } } - newu= 0; - newv= 0; - for (a=0; apntsu; a++) { + newu = 0; + newv = 0; + for (a = 0; a < nu->pntsu; a++) { if (usel[a]) { - if (newv==0 || usel[a]==newv) { - newv= usel[a]; + if (newv == 0 || usel[a] == newv) { + newv = usel[a]; newu++; } else { - newv= 0; + newv = 0; break; } } } - if (newu==0 || newv==0) { + if (newu == 0 || newv == 0) { if (G.debug & G_DEBUG) printf("Can't duplicate Nurb\n"); } else { - if (newu==1) SWAP(short, newu, newv); + if (newu == 1) SWAP(short, newu, newv); - newnu = (Nurb*)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "adduplicateN5"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(editnurb, newnu); set_actNurb(obedit, newnu); - newnu->pntsu= newu; - newnu->pntsv= newv; - newnu->bp = - (BPoint*)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6"); + newnu->pntsu = newu; + newnu->pntsv = newv; + newnu->bp = (BPoint *)MEM_mallocN(newu * newv * sizeof(BPoint), "adduplicateN6"); BKE_nurb_order_clamp_u(newnu); BKE_nurb_order_clamp_v(newnu); - newnu->knotsu= newnu->knotsv= NULL; + newnu->knotsu = newnu->knotsv = NULL; - bp= newnu->bp; - bp1= nu->bp; - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++, bp1++) { + bp = newnu->bp; + bp1 = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++, bp1++) { if (bp1->f1 & flag) { memcpy(bp, bp1, sizeof(BPoint)); select_bpoint(bp1, DESELECT, flag, HIDDEN); @@ -1974,16 +1967,16 @@ static void adduplicateflagNurb(Object *obedit, short flag) } } if (BKE_nurb_check_valid_u(newnu)) { - if (nu->pntsu==newnu->pntsu && nu->knotsu) { - newnu->knotsu= MEM_dupallocN(nu->knotsu); + if (nu->pntsu == newnu->pntsu && nu->knotsu) { + newnu->knotsu = MEM_dupallocN(nu->knotsu); } else { BKE_nurb_knot_calc_u(newnu); } } if (BKE_nurb_check_valid_v(newnu)) { - if (nu->pntsv==newnu->pntsv && nu->knotsv) { - newnu->knotsv= MEM_dupallocN(nu->knotsv); + if (nu->pntsv == newnu->pntsv && nu->knotsv) { + newnu->knotsv = MEM_dupallocN(nu->knotsv); } else { BKE_nurb_knot_calc_v(newnu); @@ -1994,7 +1987,7 @@ static void adduplicateflagNurb(Object *obedit, short flag) } } - nu= nu->prev; + nu = nu->prev; } /* actnu changed */ @@ -2004,22 +1997,22 @@ static void adduplicateflagNurb(Object *obedit, short flag) static int switch_direction_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; Nurb *nu; - for (nu= editnurb->nurbs.first; nu; nu= nu->next) + for (nu = editnurb->nurbs.first; nu; nu = nu->next) if (isNurbsel(nu)) { BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -2036,38 +2029,38 @@ void CURVE_OT_switch_direction(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /****************** set weight operator *******************/ static int set_goal_weight_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; - float weight= RNA_float_get(op->ptr, "weight"); + float weight = RNA_float_get(op->ptr, "weight"); int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { + for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { if (bezt->f2 & SELECT) - bezt->weight= weight; + bezt->weight = weight; } } else if (nu->bp) { - for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { + for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) { if (bp->f1 & SELECT) - bp->weight= weight; + bp->weight = weight; } } } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -2085,7 +2078,7 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_factor(ot->srna, "weight", 1.0f, 0.0f, 1.0f, "Weight", "", 0.0f, 1.0f); @@ -2095,30 +2088,30 @@ void CURVE_OT_spline_weight_set(wmOperatorType *ot) static int set_radius_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; - float radius= RNA_float_get(op->ptr, "radius"); + float radius = RNA_float_get(op->ptr, "radius"); int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - for (bezt=nu->bezt, a=0; apntsu; a++, bezt++) { + for (bezt = nu->bezt, a = 0; a < nu->pntsu; a++, bezt++) { if (bezt->f2 & SELECT) - bezt->radius= radius; + bezt->radius = radius; } } else if (nu->bp) { - for (bp=nu->bp, a=0; apntsu*nu->pntsv; a++, bp++) { + for (bp = nu->bp, a = 0; a < nu->pntsu * nu->pntsv; a++, bp++) { if (bp->f1 & SELECT) - bp->radius= radius; + bp->radius = radius; } } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -2137,7 +2130,7 @@ void CURVE_OT_radius_set(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "radius", 1.0f, 0.0f, FLT_MAX, "Radius", "", 0.0001f, 10.0f); @@ -2147,24 +2140,24 @@ void CURVE_OT_radius_set(wmOperatorType *ot) static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt, *beztOrig; BPoint *bp, *bpOrig; float val, newval, offset; int a, i, change = 0; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { change = 0; beztOrig = MEM_dupallocN(nu->bezt); - for (bezt=nu->bezt+1, a=1; apntsu-1; a++, bezt++) { + for (bezt = &nu->bezt[1], a = 1; a < nu->pntsu - 1; a++, bezt++) { if (bezt->f2 & SELECT) { - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { val = bezt->vec[1][i]; - newval = ((beztOrig+(a-1))->vec[1][i] * 0.5f) + ((beztOrig+(a+1))->vec[1][i] * 0.5f); - offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; + newval = ((beztOrig + (a - 1))->vec[1][i] * 0.5f) + ((beztOrig + (a + 1))->vec[1][i] * 0.5f); + offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; /* offset handles */ bezt->vec[1][i] += offset; bezt->vec[0][i] += offset; @@ -2180,12 +2173,12 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) else if (nu->bp) { bpOrig = MEM_dupallocN(nu->bp); /* Same as above, keep these the same! */ - for (bp=nu->bp+1, a=1; apntsu-1; a++, bp++) { + for (bp = &nu->bp[1], a = 1; a < nu->pntsu - 1; a++, bp++) { if (bp->f1 & SELECT) { - for (i=0; i<3; i++) { + for (i = 0; i < 3; i++) { val = bp->vec[i]; - newval = ((bpOrig+(a-1))->vec[i] * 0.5f) + ((bpOrig+(a+1))->vec[i] * 0.5f); - offset = (val*((1.0f/6.0f)*5.0f)) + (newval*(1.0f/6.0f)) - val; + newval = ((bpOrig + (a - 1))->vec[i] * 0.5f) + ((bpOrig + (a + 1))->vec[i] * 0.5f); + offset = (val * ((1.0f / 6.0f) * 5.0f)) + (newval * (1.0f / 6.0f)) - val; bp->vec[i] += offset; } @@ -2195,7 +2188,7 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -2213,7 +2206,7 @@ void CURVE_OT_smooth(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /**************** smooth curve radius operator *************/ @@ -2221,8 +2214,8 @@ void CURVE_OT_smooth(wmOperatorType *ot) /* TODO, make smoothing distance based */ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; @@ -2233,15 +2226,15 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) int start_sel, end_sel; /* selection indices, inclusive */ float start_rad, end_rad, fac, range; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - for (last_sel=0; last_sel < nu->pntsu; last_sel++) { + for (last_sel = 0; last_sel < nu->pntsu; last_sel++) { /* loop over selection segments of a curve, smooth each */ /* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */ start_sel = -1; - for (bezt=nu->bezt+last_sel, a=last_sel; apntsu; a++, bezt++) { + for (bezt = &nu->bezt[last_sel], a = last_sel; a < nu->pntsu; a++, bezt++) { if (bezt->f2 & SELECT) { start_sel = a; break; @@ -2249,8 +2242,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } /* in case there are no other selected verts */ end_sel = start_sel; - for (bezt=nu->bezt+(start_sel+1), a=start_sel+1; apntsu; a++, bezt++) { - if ((bezt->f2 & SELECT)==0) { + for (bezt = &nu->bezt[start_sel + 1], a = start_sel + 1; a < nu->pntsu; a++, bezt++) { + if ((bezt->f2 & SELECT) == 0) { break; } end_sel = a; @@ -2267,35 +2260,35 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel == end_sel) { /* simple, only 1 point selected */ - if (start_sel>0) start_rad = (nu->bezt+start_sel-1)->radius; - if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bezt+start_sel+1)->radius; + if (start_sel > 0) start_rad = nu->bezt[start_sel - 1].radius; + if (end_sel != -1 && end_sel < nu->pntsu) end_rad = nu->bezt[start_sel + 1].radius; - if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bezt+start_sel)->radius = (start_rad + end_rad)/2; - else if (start_rad >= 0.0f) (nu->bezt+start_sel)->radius = start_rad; - else if (end_rad >= 0.0f) (nu->bezt+start_sel)->radius = end_rad; + if (start_rad >= 0.0f && end_rad >= 0.0f) nu->bezt[start_sel].radius = (start_rad + end_rad) / 2.0f; + else if (start_rad >= 0.0f) nu->bezt[start_sel].radius = start_rad; + else if (end_rad >= 0.0f) nu->bezt[start_sel].radius = end_rad; } else { /* if endpoints selected, then use them */ - if (start_sel==0) { - start_rad = (nu->bezt+start_sel)->radius; + if (start_sel == 0) { + start_rad = nu->bezt[start_sel].radius; start_sel++; /* we don't want to edit the selected endpoint */ } else { - start_rad = (nu->bezt+start_sel-1)->radius; + start_rad = nu->bezt[start_sel - 1].radius; } - if (end_sel==nu->pntsu-1) { - end_rad = (nu->bezt+end_sel)->radius; + if (end_sel == nu->pntsu - 1) { + end_rad = nu->bezt[end_sel].radius; end_sel--; /* we don't want to edit the selected endpoint */ } else { - end_rad = (nu->bezt+end_sel+1)->radius; + end_rad = nu->bezt[end_sel + 1].radius; } /* Now Blend between the points */ range = (float)(end_sel - start_sel) + 2.0f; - for (bezt=nu->bezt+start_sel, a=start_sel; a<=end_sel; a++, bezt++) { - fac = (float)(1+a-start_sel) / range; - bezt->radius = start_rad*(1.0f-fac) + end_rad*fac; + for (bezt = &nu->bezt[start_sel], a = start_sel; a <= end_sel; a++, bezt++) { + fac = (float)(1 + a - start_sel) / range; + bezt->radius = start_rad * (1.0f - fac) + end_rad * fac; } } } @@ -2303,12 +2296,12 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } else if (nu->bp) { /* Same as above, keep these the same! */ - for (last_sel=0; last_sel < nu->pntsu; last_sel++) { + for (last_sel = 0; last_sel < nu->pntsu; last_sel++) { /* loop over selection segments of a curve, smooth each */ /* Start BezTriple code, this is duplicated below for points, make sure these functions stay in sync */ start_sel = -1; - for (bp=nu->bp+last_sel, a=last_sel; apntsu; a++, bp++) { + for (bp = &nu->bp[last_sel], a = last_sel; a < nu->pntsu; a++, bp++) { if (bp->f1 & SELECT) { start_sel = a; break; @@ -2316,8 +2309,8 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } /* in case there are no other selected verts */ end_sel = start_sel; - for (bp=nu->bp+(start_sel+1), a=start_sel+1; apntsu; a++, bp++) { - if ((bp->f1 & SELECT)==0) { + for (bp = &nu->bp[start_sel + 1], a = start_sel + 1; a < nu->pntsu; a++, bp++) { + if ((bp->f1 & SELECT) == 0) { break; } end_sel = a; @@ -2334,35 +2327,35 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) if (start_sel == end_sel) { /* simple, only 1 point selected */ - if (start_sel>0) start_rad = (nu->bp+start_sel-1)->radius; - if (end_sel!=-1 && end_sel < nu->pntsu) end_rad = (nu->bp+start_sel+1)->radius; + if (start_sel > 0) start_rad = nu->bp[start_sel - 1].radius; + if (end_sel != -1 && end_sel < nu->pntsu) end_rad = nu->bp[start_sel + 1].radius; - if (start_rad >= 0.0f && end_rad >= 0.0f) (nu->bp+start_sel)->radius = (start_rad + end_rad)/2; - else if (start_rad >= 0.0f) (nu->bp+start_sel)->radius = start_rad; - else if (end_rad >= 0.0f) (nu->bp+start_sel)->radius = end_rad; + if (start_rad >= 0.0f && end_rad >= 0.0f) nu->bp[start_sel].radius = (start_rad + end_rad) / 2; + else if (start_rad >= 0.0f) nu->bp[start_sel].radius = start_rad; + else if (end_rad >= 0.0f) nu->bp[start_sel].radius = end_rad; } else { /* if endpoints selected, then use them */ - if (start_sel==0) { - start_rad = (nu->bp+start_sel)->radius; + if (start_sel == 0) { + start_rad = nu->bp[start_sel].radius; start_sel++; /* we don't want to edit the selected endpoint */ } else { - start_rad = (nu->bp+start_sel-1)->radius; + start_rad = nu->bp[start_sel - 1].radius; } - if (end_sel==nu->pntsu-1) { - end_rad = (nu->bp+end_sel)->radius; + if (end_sel == nu->pntsu - 1) { + end_rad = nu->bp[end_sel].radius; end_sel--; /* we don't want to edit the selected endpoint */ } else { - end_rad = (nu->bp+end_sel+1)->radius; + end_rad = nu->bp[end_sel + 1].radius; } /* Now Blend between the points */ range = (float)(end_sel - start_sel) + 2.0f; - for (bp=nu->bp+start_sel, a=start_sel; a<=end_sel; a++, bp++) { - fac = (float)(1+a-start_sel) / range; - bp->radius = start_rad*(1.0f-fac) + end_rad*fac; + for (bp = &nu->bp[start_sel], a = start_sel; a <= end_sel; a++, bp++) { + fac = (float)(1 + a - start_sel) / range; + bp->radius = start_rad * (1.0f - fac) + end_rad * fac; } } } @@ -2370,7 +2363,7 @@ static int smooth_radius_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -2388,14 +2381,14 @@ void CURVE_OT_smooth_radius(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** selection utility *************************/ -/* next == 1 -> select next */ -/* next == -1 -> select previous */ -/* cont == 1 -> select continuously */ +/* next == 1 -> select next */ +/* next == -1 -> select previous */ +/* cont == 1 -> select continuously */ /* selstatus, inverts behavior */ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus) { @@ -2403,52 +2396,52 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short BezTriple *bezt; BPoint *bp; int a; - short lastsel= 0; + short lastsel = 0; - if (next==0) return; + if (next == 0) return; - for (nu= editnurb->first; nu; nu= nu->next) { - lastsel=0; + for (nu = editnurb->first; nu; nu = nu->next) { + lastsel = 0; if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; - if (next < 0) bezt= (nu->bezt + (a-1)); + a = nu->pntsu; + bezt = nu->bezt; + if (next < 0) bezt = &nu->bezt[a - 1]; while (a--) { - if (a-abs(next) < 0) break; - if ((lastsel==0) && (bezt->hide==0) && ((bezt->f2 & SELECT) || (selstatus==0))) { - bezt+=next; - if (!(bezt->f2 & SELECT) || (selstatus==0)) { - short sel= select_beztriple(bezt, selstatus, 1, VISIBLE); - if ((sel==1) && (cont==0)) lastsel= 1; + if (a - abs(next) < 0) break; + if ((lastsel == 0) && (bezt->hide == 0) && ((bezt->f2 & SELECT) || (selstatus == 0))) { + bezt += next; + if (!(bezt->f2 & SELECT) || (selstatus == 0)) { + short sel = select_beztriple(bezt, selstatus, 1, VISIBLE); + if ((sel == 1) && (cont == 0)) lastsel = 1; } } else { - bezt+=next; - lastsel= 0; + bezt += next; + lastsel = 0; } /* move around in zigzag way so that we go through each */ - bezt-=(next-next/abs(next)); + bezt -= (next - next / abs(next)); } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - if (next < 0) bp= (nu->bp + (a-1)); + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + if (next < 0) bp = &nu->bp[a - 1]; while (a--) { - if (a-abs(next) < 0) break; - if ((lastsel==0) && (bp->hide==0) && ((bp->f1 & SELECT) || (selstatus==0))) { - bp+=next; - if (!(bp->f1 & SELECT) || (selstatus==0)) { - short sel= select_bpoint(bp, selstatus, 1, VISIBLE); - if ((sel==1) && (cont==0)) lastsel= 1; + if (a - abs(next) < 0) break; + if ((lastsel == 0) && (bp->hide == 0) && ((bp->f1 & SELECT) || (selstatus == 0))) { + bp += next; + if (!(bp->f1 & SELECT) || (selstatus == 0)) { + short sel = select_bpoint(bp, selstatus, 1, VISIBLE); + if ((sel == 1) && (cont == 0)) lastsel = 1; } } else { - bp+=next; - lastsel= 0; + bp += next; + lastsel = 0; } /* move around in zigzag way so that we go through each */ - bp-=(next-next/abs(next)); + bp -= (next - next / abs(next)); } } } @@ -2462,56 +2455,56 @@ static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short /* selstatus: selection status in case doswap is false */ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatus) { - ListBase *editnurb= object_editcurve_get(obedit); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; Curve *cu; int a; - if (obedit==NULL) return; + if (obedit == NULL) return; - cu= (Curve*)obedit->data; - cu->lastsel= NULL; + cu = (Curve *)obedit->data; + cu->lastsel = NULL; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; + a = nu->pntsu; /* which point? */ - if (selfirst==0) { /* select last */ - bezt= (nu->bezt + (a-1)); + if (selfirst == 0) { /* select last */ + bezt = &nu->bezt[a - 1]; } else { /* select first */ - bezt= nu->bezt; + bezt = nu->bezt; } while (a--) { short sel; - if (doswap) sel= swap_selection_beztriple(bezt); - else sel= select_beztriple(bezt, selstatus, 1, VISIBLE); + if (doswap) sel = swap_selection_beztriple(bezt); + else sel = select_beztriple(bezt, selstatus, 1, VISIBLE); - if (sel==1) break; + if (sel == 1) break; } } else { - a= nu->pntsu*nu->pntsv; + a = nu->pntsu * nu->pntsv; /* which point? */ - if (selfirst==0) { /* select last */ - bp= (nu->bp + (a-1)); + if (selfirst == 0) { /* select last */ + bp = &nu->bp[a - 1]; } else { /* select first */ - bp= nu->bp; + bp = nu->bp; } while (a--) { if (bp->hide == 0) { short sel; - if (doswap) sel= swap_selection_bpoint(bp); - else sel= select_bpoint(bp, selstatus, 1, VISIBLE); + if (doswap) sel = swap_selection_bpoint(bp); + else sel = select_bpoint(bp, selstatus, 1, VISIBLE); - if (sel==1) break; + if (sel == 1) break; } } } @@ -2520,10 +2513,10 @@ void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatu static int de_select_first_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); selectend_nurb(obedit, FIRST, 1, DESELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2540,15 +2533,15 @@ void CURVE_OT_de_select_first(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int de_select_last_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); selectend_nurb(obedit, LAST, 1, DESELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2565,7 +2558,7 @@ void CURVE_OT_de_select_last(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************* de select all operator ***************/ @@ -2577,12 +2570,12 @@ static short nurb_has_selected_cps(ListBase *editnurb) BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if (bezt->hide==0) { + if (bezt->hide == 0) { if ((bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT)) @@ -2594,10 +2587,10 @@ static short nurb_has_selected_cps(ListBase *editnurb) } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if ((bp->hide==0) && (bp->f1 & SELECT)) return 1; + if ((bp->hide == 0) && (bp->f1 & SELECT)) return 1; bp++; } } @@ -2608,8 +2601,8 @@ static short nurb_has_selected_cps(ListBase *editnurb) static int de_select_all_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); int action = RNA_enum_get(op->ptr, "action"); if (action == SEL_TOGGLE) { @@ -2630,7 +2623,7 @@ static int de_select_all_exec(bContext *C, wmOperator *op) break; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2647,7 +2640,7 @@ void CURVE_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ WM_operator_properties_select_all(ot); @@ -2657,55 +2650,55 @@ void CURVE_OT_select_all(wmOperatorType *ot) static int hide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; - int a, sel, invert= RNA_boolean_get(op->ptr, "unselected"); + int a, sel, invert = RNA_boolean_get(op->ptr, "unselected"); - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; - sel= 0; + bezt = nu->bezt; + a = nu->pntsu; + sel = 0; while (a--) { if (invert == 0 && BEZSELECTED_HIDDENHANDLES(cu, bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); - bezt->hide= 1; + bezt->hide = 1; } else if (invert && !BEZSELECTED_HIDDENHANDLES(cu, bezt)) { select_beztriple(bezt, DESELECT, 1, HIDDEN); - bezt->hide= 1; + bezt->hide = 1; } if (bezt->hide) sel++; bezt++; } - if (sel==nu->pntsu) nu->hide= 1; + if (sel == nu->pntsu) nu->hide = 1; } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; - sel= 0; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; + sel = 0; while (a--) { - if (invert==0 && (bp->f1 & SELECT)) { + if (invert == 0 && (bp->f1 & SELECT)) { select_bpoint(bp, DESELECT, 1, HIDDEN); - bp->hide= 1; + bp->hide = 1; } - else if (invert && (bp->f1 & SELECT)==0) { + else if (invert && (bp->f1 & SELECT) == 0) { select_bpoint(bp, DESELECT, 1, HIDDEN); - bp->hide= 1; + bp->hide = 1; } if (bp->hide) sel++; bp++; } - if (sel==nu->pntsu*nu->pntsv) nu->hide= 1; + if (sel == nu->pntsu * nu->pntsv) nu->hide = 1; } } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2722,7 +2715,7 @@ void CURVE_OT_hide(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -2732,33 +2725,33 @@ void CURVE_OT_hide(wmOperatorType *ot) static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; int a; - for (nu= editnurb->first; nu; nu= nu->next) { - nu->hide= 0; + for (nu = editnurb->first; nu; nu = nu->next) { + nu->hide = 0; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (bezt->hide) { select_beztriple(bezt, SELECT, 1, HIDDEN); - bezt->hide= 0; + bezt->hide = 0; } bezt++; } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (bp->hide) { select_bpoint(bp, SELECT, 1, HIDDEN); - bp->hide= 0; + bp->hide = 0; } bp++; } @@ -2766,7 +2759,7 @@ static int reveal_exec(bContext *C, wmOperator *UNUSED(op)) } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -2783,7 +2776,7 @@ void CURVE_OT_reveal(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** subdivide operator *********************/ @@ -2794,8 +2787,8 @@ void CURVE_OT_reveal(wmOperatorType *ot) */ static void subdividenurb(Object *obedit, int number_cuts) { - Curve *cu= obedit->data; - EditNurb *editnurb= cu->editnurb; + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; Nurb *nu; BezTriple *prevbezt, *bezt, *beztnew, *beztn; BPoint *bp, *prevbp, *bpnew, *bpn; @@ -2805,52 +2798,51 @@ static void subdividenurb(Object *obedit, int number_cuts) // printf("*** subdivideNurb: entering subdivide\n"); - for (nu= editnurb->nurbs.first; nu; nu= nu->next) { - amount= 0; + for (nu = editnurb->nurbs.first; nu; nu = nu->next) { + amount = 0; if (nu->type == CU_BEZIER) { - /* - * Insert a point into a 2D Bezier curve. - * Endpoints are preserved. Otherwise, all selected and inserted points are - * newly created. Old points are discarded. - */ + /* + * Insert a point into a 2D Bezier curve. + * Endpoints are preserved. Otherwise, all selected and inserted points are + * newly created. Old points are discarded. + */ /* count */ if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bezt= nu->bezt; - prevbezt= bezt+(a-1); + a = nu->pntsu; + bezt = nu->bezt; + prevbezt = bezt + (a - 1); } else { - a= nu->pntsu-1; - prevbezt= nu->bezt; - bezt= prevbezt+1; + a = nu->pntsu - 1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; } while (a--) { - if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount+=number_cuts; - prevbezt= bezt; + if (BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) amount += number_cuts; + prevbezt = bezt; bezt++; } if (amount) { /* insert */ - beztnew = - (BezTriple*)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb"); - beztn= beztnew; + beztnew = (BezTriple *)MEM_mallocN((amount + nu->pntsu) * sizeof(BezTriple), "subdivNurb"); + beztn = beztnew; if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bezt= nu->bezt; - prevbezt= bezt+(a-1); + a = nu->pntsu; + bezt = nu->bezt; + prevbezt = bezt + (a - 1); } else { - a= nu->pntsu-1; - prevbezt= nu->bezt; - bezt= prevbezt+1; + a = nu->pntsu - 1; + prevbezt = nu->bezt; + bezt = prevbezt + 1; } while (a--) { memcpy(beztn, prevbezt, sizeof(BezTriple)); keyIndex_updateBezt(editnurb, prevbezt, beztn, 1); beztn++; - if ( BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if (BEZSELECTED_HIDDENHANDLES(cu, prevbezt) && BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { float prevvec[3][3]; memcpy(prevvec, prevbezt->vec, sizeof(float) * 9); @@ -2862,93 +2854,92 @@ static void subdividenurb(Object *obedit, int number_cuts) /* midpoint subdividing */ interp_v3_v3v3(vec, prevvec[1], prevvec[2], factor); - interp_v3_v3v3(vec+3, prevvec[2], bezt->vec[0], factor); - interp_v3_v3v3(vec+6, bezt->vec[0], bezt->vec[1], factor); + interp_v3_v3v3(vec + 3, prevvec[2], bezt->vec[0], factor); + interp_v3_v3v3(vec + 6, bezt->vec[0], bezt->vec[1], factor); - interp_v3_v3v3(vec+9, vec, vec+3, factor); - interp_v3_v3v3(vec+12, vec+3, vec+6, factor); + interp_v3_v3v3(vec + 9, vec, vec + 3, factor); + interp_v3_v3v3(vec + 12, vec + 3, vec + 6, factor); /* change handle of prev beztn */ - copy_v3_v3((beztn-1)->vec[2], vec); + copy_v3_v3((beztn - 1)->vec[2], vec); /* new point */ - copy_v3_v3(beztn->vec[0], vec+9); - interp_v3_v3v3(beztn->vec[1], vec+9, vec+12, factor); - copy_v3_v3(beztn->vec[2], vec+12); + copy_v3_v3(beztn->vec[0], vec + 9); + interp_v3_v3v3(beztn->vec[1], vec + 9, vec + 12, factor); + copy_v3_v3(beztn->vec[2], vec + 12); /* handle of next bezt */ - if (a==0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) {copy_v3_v3(beztnew->vec[0], vec+6);} - else {copy_v3_v3(bezt->vec[0], vec+6);} + if (a == 0 && i == number_cuts - 1 && (nu->flagu & CU_NURB_CYCLIC)) { copy_v3_v3(beztnew->vec[0], vec + 6); } + else { copy_v3_v3(bezt->vec[0], vec + 6); } - beztn->radius = (prevbezt->radius + bezt->radius)/2; - beztn->weight = (prevbezt->weight + bezt->weight)/2; + beztn->radius = (prevbezt->radius + bezt->radius) / 2; + beztn->weight = (prevbezt->weight + bezt->weight) / 2; memcpy(prevvec, beztn->vec, sizeof(float) * 9); beztn++; } } - prevbezt= bezt; + prevbezt = bezt; bezt++; } /* last point */ - if ((nu->flagu & CU_NURB_CYCLIC)==0) { + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { memcpy(beztn, prevbezt, sizeof(BezTriple)); keyIndex_updateBezt(editnurb, prevbezt, beztn, 1); } MEM_freeN(nu->bezt); - nu->bezt= beztnew; - nu->pntsu+= amount; + nu->bezt = beztnew; + nu->pntsu += amount; BKE_nurb_handles_calc(nu); } } /* End of 'if (nu->type == CU_BEZIER)' */ - else if (nu->pntsv==1) { - /* - * All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves - * are handled together with the regular NURB plane division, as it - * should be. I split it off just now, let's see if it is - * stable... nzc 30-5-'00 - */ + else if (nu->pntsv == 1) { + /* + * All flat lines (ie. co-planar), except flat Nurbs. Flat NURB curves + * are handled together with the regular NURB plane division, as it + * should be. I split it off just now, let's see if it is + * stable... nzc 30-5-'00 + */ /* count */ if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bp= nu->bp; - prevbp= bp+(a-1); + a = nu->pntsu; + bp = nu->bp; + prevbp = bp + (a - 1); } else { - a= nu->pntsu-1; - prevbp= nu->bp; - bp= prevbp+1; + a = nu->pntsu - 1; + prevbp = nu->bp; + bp = prevbp + 1; } while (a--) { - if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount+=number_cuts; - prevbp= bp; + if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) amount += number_cuts; + prevbp = bp; bp++; } if (amount) { /* insert */ - bpnew = - (BPoint*)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2"); - bpn= bpnew; + bpnew = (BPoint *)MEM_mallocN((amount + nu->pntsu) * sizeof(BPoint), "subdivNurb2"); + bpn = bpnew; if (nu->flagu & CU_NURB_CYCLIC) { - a= nu->pntsu; - bp= nu->bp; - prevbp= bp+(a-1); + a = nu->pntsu; + bp = nu->bp; + prevbp = bp + (a - 1); } else { - a= nu->pntsu-1; - prevbp= nu->bp; - bp= prevbp+1; + a = nu->pntsu - 1; + prevbp = nu->bp; + bp = prevbp + 1; } while (a--) { memcpy(bpn, prevbp, sizeof(BPoint)); keyIndex_updateBP(editnurb, prevbp, bpn, 1); bpn++; - if ( (bp->f1 & SELECT) && (prevbp->f1 & SELECT) ) { - // printf("*** subdivideNurb: insert 'linear' point\n"); + if ((bp->f1 & SELECT) && (prevbp->f1 & SELECT)) { + // printf("*** subdivideNurb: insert 'linear' point\n"); for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); @@ -2958,17 +2949,17 @@ static void subdividenurb(Object *obedit, int number_cuts) } } - prevbp= bp; + prevbp = bp; bp++; } - if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* last point */ + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* last point */ memcpy(bpn, prevbp, sizeof(BPoint)); keyIndex_updateBP(editnurb, prevbp, bpn, 1); } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsu+= amount; + nu->bp = bpnew; + nu->pntsu += amount; if (nu->type & CU_NURBS) { BKE_nurb_knot_calc_u(nu); @@ -2976,57 +2967,57 @@ static void subdividenurb(Object *obedit, int number_cuts) } } /* End of 'else if (nu->pntsv==1)' */ else if (nu->type == CU_NURBS) { - /* This is a very strange test ... */ - /** - * Subdivide NURB surfaces - nzc 30-5-'00 - - * - * Subdivision of a NURB curve can be effected by adding a - * control point (insertion of a knot), or by raising the - * degree of the functions used to build the NURB. The - * expression - * - * degree = #knots - #controlpoints + 1 (J Walter piece) - * degree = #knots - #controlpoints (Blender - * implementation) - * ( this is confusing.... what is true? Another concern - * is that the JW piece allows the curve to become - * explicitly 1st order derivative discontinuous, while - * this is not what we want here... ) - * - * is an invariant for a single NURB curve. Raising the degree - * of the NURB is done elsewhere; the degree is assumed - * constant during this operation. Degree is a property shared - * by all controlpoints in a curve (even though it is stored - * per control point - this can be misleading). - * Adding a knot is done by searching for the place in the - * knot vector where a certain knot value must be inserted, or - * by picking an appropriate knot value between two existing - * ones. The number of controlpoints that is influenced by the - * insertion depends on the order of the curve. A certain - * minimum number of knots is needed to form high-order - * curves, as can be seen from the equation above. In Blender, - * currently NURBs may be up to 6th order, so we modify at - * most 6 points. One point is added. For an n-degree curve, - * n points are discarded, and n+1 points inserted - * (so effectively, n points are modified). (that holds for - * the JW piece, but it seems not for our NURBs) - * In practice, the knot spacing is copied, but the tail - * (the points following the insertion point) need to be - * offset to keep the knot series ascending. The knot series - * is always a series of monotonically ascending integers in - * Blender. When not enough control points are available to - * fit the order, duplicates of the endpoints are added as - * needed. - */ + /* This is a very strange test ... */ + /** + * Subdivide NURB surfaces - nzc 30-5-'00 - + * + * Subdivision of a NURB curve can be effected by adding a + * control point (insertion of a knot), or by raising the + * degree of the functions used to build the NURB. The + * expression + * + * degree = #knots - #controlpoints + 1 (J Walter piece) + * degree = #knots - #controlpoints (Blender + * implementation) + * ( this is confusing.... what is true? Another concern + * is that the JW piece allows the curve to become + * explicitly 1st order derivative discontinuous, while + * this is not what we want here... ) + * + * is an invariant for a single NURB curve. Raising the degree + * of the NURB is done elsewhere; the degree is assumed + * constant during this operation. Degree is a property shared + * by all controlpoints in a curve (even though it is stored + * per control point - this can be misleading). + * Adding a knot is done by searching for the place in the + * knot vector where a certain knot value must be inserted, or + * by picking an appropriate knot value between two existing + * ones. The number of controlpoints that is influenced by the + * insertion depends on the order of the curve. A certain + * minimum number of knots is needed to form high-order + * curves, as can be seen from the equation above. In Blender, + * currently NURBs may be up to 6th order, so we modify at + * most 6 points. One point is added. For an n-degree curve, + * n points are discarded, and n+1 points inserted + * (so effectively, n points are modified). (that holds for + * the JW piece, but it seems not for our NURBs) + * In practice, the knot spacing is copied, but the tail + * (the points following the insertion point) need to be + * offset to keep the knot series ascending. The knot series + * is always a series of monotonically ascending integers in + * Blender. When not enough control points are available to + * fit the order, duplicates of the endpoints are added as + * needed. + */ /* selection-arrays */ - usel= MEM_callocN(sizeof(int)*nu->pntsu, "subivideNurb3"); - vsel= MEM_callocN(sizeof(int)*nu->pntsv, "subivideNurb3"); - sel= 0; + usel = MEM_callocN(sizeof(int) * nu->pntsu, "subivideNurb3"); + vsel = MEM_callocN(sizeof(int) * nu->pntsv, "subivideNurb3"); + sel = 0; - /* Count the number of selected points. */ - bp= nu->bp; - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++) { + /* Count the number of selected points. */ + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { if (bp->f1 & SELECT) { usel[b]++; vsel[a]++; @@ -3035,48 +3026,48 @@ static void subdividenurb(Object *obedit, int number_cuts) bp++; } } - if ( sel == (nu->pntsu*nu->pntsv) ) { /* subdivide entire nurb */ + if (sel == (nu->pntsu * nu->pntsv) ) { /* subdivide entire nurb */ /* Global subdivision is a special case of partial * subdivision. Strange it is considered separately... */ /* count of nodes (after subdivision) along U axis */ - int countu= nu->pntsu + (nu->pntsu - 1) * number_cuts; + int countu = nu->pntsu + (nu->pntsu - 1) * number_cuts; /* total count of nodes after subdivision */ - int tot= ((number_cuts+1)*nu->pntsu-number_cuts)*((number_cuts+1)*nu->pntsv-number_cuts); + int tot = ((number_cuts + 1) * nu->pntsu - number_cuts) * ((number_cuts + 1) * nu->pntsv - number_cuts); - bpn=bpnew= MEM_mallocN(tot*sizeof(BPoint), "subdivideNurb4"); - bp= nu->bp; + bpn = bpnew = MEM_mallocN(tot * sizeof(BPoint), "subdivideNurb4"); + bp = nu->bp; /* first subdivide rows */ - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++) { - *bpn= *bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { + *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if (bpntsu-1) { - prevbp= bp-1; + if (b < nu->pntsu - 1) { + prevbp = bp - 1; for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - *bpn= *bp; + *bpn = *bp; interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); bpn++; } } } - bpn+= number_cuts * countu; + bpn += number_cuts * countu; } /* now insert new */ - bpn= bpnew+((number_cuts+1)*nu->pntsu - number_cuts); - bp= bpnew+(number_cuts+1)*((number_cuts+1)*nu->pntsu-number_cuts); - prevbp= bpnew; - for (a=1; apntsv; a++) { + bpn = bpnew + ((number_cuts + 1) * nu->pntsu - number_cuts); + bp = bpnew + (number_cuts + 1) * ((number_cuts + 1) * nu->pntsu - number_cuts); + prevbp = bpnew; + for (a = 1; a < nu->pntsv; a++) { - for (b=0; b<(number_cuts+1)*nu->pntsu-number_cuts; b++) { - BPoint *tmp= bpn; + for (b = 0; b < (number_cuts + 1) * nu->pntsu - number_cuts; b++) { + BPoint *tmp = bpn; for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - *tmp= *bp; + *tmp = *bp; interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor); tmp += countu; } @@ -3084,81 +3075,81 @@ static void subdividenurb(Object *obedit, int number_cuts) prevbp++; bpn++; } - bp+= number_cuts * countu; - bpn+= number_cuts * countu; - prevbp+= number_cuts * countu; + bp += number_cuts * countu; + bpn += number_cuts * countu; + prevbp += number_cuts * countu; } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsu= (number_cuts+1)*nu->pntsu-number_cuts; - nu->pntsv= (number_cuts+1)*nu->pntsv-number_cuts; + nu->bp = bpnew; + nu->pntsu = (number_cuts + 1) * nu->pntsu - number_cuts; + nu->pntsv = (number_cuts + 1) * nu->pntsv - number_cuts; BKE_nurb_knot_calc_u(nu); BKE_nurb_knot_calc_v(nu); } /* End of 'if (sel== nu->pntsu*nu->pntsv)' (subdivide entire NURB) */ else { /* subdivide in v direction? */ - sel= 0; - for (a=0; apntsv-1; a++) { - if (vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu) sel+=number_cuts; + sel = 0; + for (a = 0; a < nu->pntsv - 1; a++) { + if (vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) sel += number_cuts; } if (sel) { /* V ! */ - bpn=bpnew= MEM_mallocN((sel+nu->pntsv)*nu->pntsu*sizeof(BPoint), "subdivideNurb4"); - bp= nu->bp; - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++) { - *bpn= *bp; + bpn = bpnew = MEM_mallocN((sel + nu->pntsv) * nu->pntsu * sizeof(BPoint), "subdivideNurb4"); + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { + *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; } - if ( (apntsv-1) && vsel[a]==nu->pntsu && vsel[a+1]==nu->pntsu ) { + if ( (a < nu->pntsv - 1) && vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) { for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - prevbp= bp- nu->pntsu; - for (b=0; bpntsu; b++) { - /* - * This simple bisection must be replaces by a - * subtle resampling of a number of points. Our - * task is made slightly easier because each - * point in our curve is a separate data - * node. (is it?) - */ - *bpn= *prevbp; - interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); - bpn++; + prevbp = bp - nu->pntsu; + for (b = 0; b < nu->pntsu; b++) { + /* + * This simple bisection must be replaces by a + * subtle resampling of a number of points. Our + * task is made slightly easier because each + * point in our curve is a separate data + * node. (is it?) + */ + *bpn = *prevbp; + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); + bpn++; prevbp++; bp++; } - bp-= nu->pntsu; + bp -= nu->pntsu; } } } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsv+= sel; + nu->bp = bpnew; + nu->pntsv += sel; BKE_nurb_knot_calc_v(nu); } else { /* or in u direction? */ - sel= 0; - for (a=0; apntsu-1; a++) { - if (usel[a]==nu->pntsv && usel[a+1]==nu->pntsv) sel+=number_cuts; + sel = 0; + for (a = 0; a < nu->pntsu - 1; a++) { + if (usel[a] == nu->pntsv && usel[a + 1] == nu->pntsv) sel += number_cuts; } - if (sel) { /* U ! */ - /* Inserting U points is sort of 'default' Flat curves only get */ - /* U points inserted in them. */ - bpn=bpnew= MEM_mallocN((sel+nu->pntsu)*nu->pntsv*sizeof(BPoint), "subdivideNurb4"); - bp= nu->bp; - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++) { - *bpn= *bp; + if (sel) { /* U ! */ + /* Inserting U points is sort of 'default' Flat curves only get */ + /* U points inserted in them. */ + bpn = bpnew = MEM_mallocN((sel + nu->pntsu) * nu->pntsv * sizeof(BPoint), "subdivideNurb4"); + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++) { + *bpn = *bp; keyIndex_updateBP(editnurb, bp, bpn, 1); bpn++; bp++; - if ( (bpntsu-1) && usel[b]==nu->pntsv && usel[b+1]==nu->pntsv ) { + if ( (b < nu->pntsu - 1) && usel[b] == nu->pntsv && usel[b + 1] == nu->pntsv) { /* * One thing that bugs me here is that the * orders of things are not the same as in @@ -3168,17 +3159,17 @@ static void subdividenurb(Object *obedit, int number_cuts) */ for (i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); - prevbp= bp- 1; - *bpn= *prevbp; - interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); - bpn++; + prevbp = bp - 1; + *bpn = *prevbp; + interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); + bpn++; } } } } MEM_freeN(nu->bp); - nu->bp= bpnew; - nu->pntsu+= sel; + nu->bp = bpnew; + nu->pntsu += sel; BKE_nurb_knot_calc_u(nu); /* shift knots forward */ } } @@ -3192,15 +3183,15 @@ static void subdividenurb(Object *obedit, int number_cuts) static int subdivide_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - int number_cuts= RNA_int_get(op->ptr, "number_cuts"); + Object *obedit = CTX_data_edit_object(C); + int number_cuts = RNA_int_get(op->ptr, "number_cuts"); subdividenurb(obedit, number_cuts); if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -3220,7 +3211,7 @@ void CURVE_OT_subdivide(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of cuts", "", 1, 10); /* avoid re-using last var because it can cause _very_ high poly meshes and annoy users (or worse crash) */ @@ -3240,10 +3231,10 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, flag = bp->f1; } else { - if (beztindex==0) { + if (beztindex == 0) { flag = bezt->f1; } - else if (beztindex==1) { + else if (beztindex == 1) { flag = bezt->f2; } else { @@ -3251,25 +3242,25 @@ static void findnearestNurbvert__doClosest(void *userData, Nurb *nu, BPoint *bp, } } - temp = abs(data->mval[0]-x) + abs(data->mval[1]-y); - if ((flag&1)==data->select) temp += 5; - if (bezt && beztindex==1) temp += 3; /* middle points get a small disadvantage */ + temp = abs(data->mval[0] - x) + abs(data->mval[1] - y); + if ((flag & 1) == data->select) temp += 5; + if (bezt && beztindex == 1) temp += 3; /* middle points get a small disadvantage */ - if (tempdist) { + if (temp < data->dist) { data->dist = temp; data->bp = bp; data->bezt = bezt; data->nurb = nu; - data->hpoint = bezt?beztindex:0; + data->hpoint = bezt ? beztindex : 0; } } static short findnearestNurbvert(ViewContext *vc, short sel, const int mval[2], Nurb **nurb, BezTriple **bezt, BPoint **bp) { - /* sel==1: selected gets a disadvantage */ - /* in nurb and bezt or bp the nearest is written */ - /* return 0 1 2: handlepunt */ + /* sel==1: selected gets a disadvantage */ + /* in nurb and bezt or bp the nearest is written */ + /* return 0 1 2: handlepunt */ struct { BPoint *bp; BezTriple *bezt; Nurb *nurb; int dist, hpoint, select, mval[2]; } data = {NULL}; data.dist = 100; @@ -3297,51 +3288,51 @@ static void findselectedNurbvert(ListBase *editnurb, Nurb **nu, BezTriple **bezt BPoint *bp1; int a; - *nu= NULL; - *bezt= NULL; - *bp= NULL; - for (nu1= editnurb->first; nu1; nu1= nu1->next) { + *nu = NULL; + *bezt = NULL; + *bp = NULL; + for (nu1 = editnurb->first; nu1; nu1 = nu1->next) { if (nu1->type == CU_BEZIER) { - bezt1= nu1->bezt; - a= nu1->pntsu; + bezt1 = nu1->bezt; + a = nu1->pntsu; while (a--) { if ( (bezt1->f1 & SELECT) || (bezt1->f2 & SELECT) || (bezt1->f3 & SELECT) ) { if (*nu != NULL && *nu != nu1) { - *nu= NULL; - *bp= NULL; - *bezt= NULL; + *nu = NULL; + *bp = NULL; + *bezt = NULL; return; } else if (*bezt || *bp) { - *bp= NULL; - *bezt= NULL; + *bp = NULL; + *bezt = NULL; } else { - *bezt= bezt1; - *nu= nu1; + *bezt = bezt1; + *nu = nu1; } } bezt1++; } } else { - bp1= nu1->bp; - a= nu1->pntsu*nu1->pntsv; + bp1 = nu1->bp; + a = nu1->pntsu * nu1->pntsv; while (a--) { - if ( bp1->f1 & 1 ) { + if (bp1->f1 & SELECT) { if (*nu != NULL && *nu != nu1) { - *bp= NULL; - *bezt= NULL; - *nu= NULL; + *bp = NULL; + *bezt = NULL; + *nu = NULL; return; } else if (*bezt || *bp) { - *bp= NULL; - *bezt= NULL; + *bp = NULL; + *bezt = NULL; } else { - *bp= bp1; - *nu= nu1; + *bp = bp1; + *nu = nu1; } } bp1++; @@ -3359,87 +3350,86 @@ static int convertspline(short type, Nurb *nu) int a, c, nr; if (nu->type == CU_POLY) { - if (type==CU_BEZIER) { /* to Bezier with vecthandles */ - nr= nu->pntsu; - bezt = - (BezTriple*)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); - nu->bezt= bezt; - a= nr; - bp= nu->bp; + if (type == CU_BEZIER) { /* to Bezier with vecthandles */ + nr = nu->pntsu; + bezt = (BezTriple *)MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); + nu->bezt = bezt; + a = nr; + bp = nu->bp; while (a--) { copy_v3_v3(bezt->vec[1], bp->vec); - bezt->f1=bezt->f2=bezt->f3= bp->f1; - bezt->h1= bezt->h2= HD_VECT; - bezt->weight= bp->weight; - bezt->radius= bp->radius; + bezt->f1 = bezt->f2 = bezt->f3 = bp->f1; + bezt->h1 = bezt->h2 = HD_VECT; + bezt->weight = bp->weight; + bezt->radius = bp->radius; bp++; bezt++; } MEM_freeN(nu->bp); - nu->bp= NULL; - nu->pntsu= nr; + nu->bp = NULL; + nu->pntsu = nr; nu->type = CU_BEZIER; BKE_nurb_handles_calc(nu); } - else if (type==CU_NURBS) { + else if (type == CU_NURBS) { nu->type = CU_NURBS; - nu->orderu= 4; + nu->orderu = 4; nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ BKE_nurb_knot_calc_u(nu); - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - bp->vec[3]= 1.0; + bp->vec[3] = 1.0; bp++; } } } - else if (nu->type == CU_BEZIER) { /* Bezier */ - if (type==CU_POLY || type==CU_NURBS) { - nr= 3*nu->pntsu; + else if (nu->type == CU_BEZIER) { /* Bezier */ + if (type == CU_POLY || type == CU_NURBS) { + nr = 3 * nu->pntsu; nu->bp = MEM_callocN(nr * sizeof(BPoint), "setsplinetype"); - a= nu->pntsu; - bezt= nu->bezt; - bp= nu->bp; + a = nu->pntsu; + bezt = nu->bezt; + bp = nu->bp; while (a--) { - if (type==CU_POLY && bezt->h1==HD_VECT && bezt->h2==HD_VECT) { + if (type == CU_POLY && bezt->h1 == HD_VECT && bezt->h2 == HD_VECT) { /* vector handle becomes 1 poly vertice */ copy_v3_v3(bp->vec, bezt->vec[1]); - bp->vec[3]= 1.0; - bp->f1= bezt->f2; - nr-= 2; - bp->radius= bezt->radius; - bp->weight= bezt->weight; + bp->vec[3] = 1.0; + bp->f1 = bezt->f2; + nr -= 2; + bp->radius = bezt->radius; + bp->weight = bezt->weight; bp++; } else { - for (c=0;c<3;c++) { + for (c = 0; c < 3; c++) { copy_v3_v3(bp->vec, bezt->vec[c]); - bp->vec[3]= 1.0; - if (c==0) bp->f1= bezt->f1; - else if (c==1) bp->f1= bezt->f2; - else bp->f1= bezt->f3; - bp->radius= bezt->radius; - bp->weight= bezt->weight; + bp->vec[3] = 1.0; + if (c == 0) bp->f1 = bezt->f1; + else if (c == 1) bp->f1 = bezt->f2; + else bp->f1 = bezt->f3; + bp->radius = bezt->radius; + bp->weight = bezt->weight; bp++; } } bezt++; } MEM_freeN(nu->bezt); - nu->bezt= NULL; - nu->pntsu= nr; - nu->pntsv= 1; - nu->orderu= 4; - nu->orderv= 1; + nu->bezt = NULL; + nu->pntsu = nr; + nu->pntsv = 1; + nu->orderu = 4; + nu->orderv = 1; nu->type = type; -#if 0 /* UNUSED */ - if (nu->flagu & CU_NURB_CYCLIC) c= nu->orderu-1; - else c= 0; +#if 0 /* UNUSED */ + if (nu->flagu & CU_NURB_CYCLIC) c = nu->orderu - 1; + else c = 0; #endif - if (type== CU_NURBS) { + if (type == CU_NURBS) { nu->flagu &= CU_NURB_CYCLIC; /* disable all flags except for cyclic */ nu->flagu |= CU_NURB_BEZIER; BKE_nurb_knot_calc_u(nu); @@ -3447,42 +3437,43 @@ static int convertspline(short type, Nurb *nu) } } else if (nu->type == CU_NURBS) { - if (type==CU_POLY) { + if (type == CU_POLY) { nu->type = CU_POLY; - if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ - nu->knotsu= NULL; + if (nu->knotsu) MEM_freeN(nu->knotsu); /* python created nurbs have a knotsu of zero */ + nu->knotsu = NULL; if (nu->knotsv) MEM_freeN(nu->knotsv); - nu->knotsv= NULL; + nu->knotsv = NULL; } - else if (type==CU_BEZIER) { /* to Bezier */ - nr= nu->pntsu/3; + else if (type == CU_BEZIER) { /* to Bezier */ + nr = nu->pntsu / 3; - if (nr<2) - return 1; /* conversion impossible */ + if (nr < 2) { + return 1; /* conversion impossible */ + } else { bezt = MEM_callocN(nr * sizeof(BezTriple), "setsplinetype2"); - nu->bezt= bezt; - a= nr; - bp= nu->bp; + nu->bezt = bezt; + a = nr; + bp = nu->bp; while (a--) { copy_v3_v3(bezt->vec[0], bp->vec); - bezt->f1= bp->f1; + bezt->f1 = bp->f1; bp++; copy_v3_v3(bezt->vec[1], bp->vec); - bezt->f2= bp->f1; + bezt->f2 = bp->f1; bp++; copy_v3_v3(bezt->vec[2], bp->vec); - bezt->f3= bp->f1; - bezt->radius= bp->radius; - bezt->weight= bp->weight; + bezt->f3 = bp->f1; + bezt->radius = bp->radius; + bezt->weight = bp->weight; bp++; bezt++; } MEM_freeN(nu->bp); - nu->bp= NULL; + nu->bp = NULL; MEM_freeN(nu->knotsu); - nu->knotsu= NULL; - nu->pntsu= nr; + nu->knotsu = NULL; + nu->pntsu = nr; nu->type = CU_BEZIER; } } @@ -3498,31 +3489,31 @@ void ED_nurb_set_spline_type(Nurb *nu, int type) static int set_spline_type_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - int changed=0, type= RNA_enum_get(op->ptr, "type"); + int changed = 0, type = RNA_enum_get(op->ptr, "type"); - if (type==CU_CARDINAL || type==CU_BSPLINE) { + if (type == CU_CARDINAL || type == CU_BSPLINE) { BKE_report(op->reports, RPT_ERROR, "Not implemented yet"); return OPERATOR_CANCELLED; } - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { if (convertspline(type, nu)) BKE_report(op->reports, RPT_ERROR, "No conversion possible"); else - changed= 1; + changed = 1; } } if (changed) { if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -3533,7 +3524,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) void CURVE_OT_spline_type_set(wmOperatorType *ot) { - static EnumPropertyItem type_items[]= { + static EnumPropertyItem type_items[] = { {CU_POLY, "POLY", 0, "Poly", ""}, {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, // {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, @@ -3552,7 +3543,7 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, CU_POLY, "Type", "Spline type"); @@ -3562,12 +3553,12 @@ void CURVE_OT_spline_type_set(wmOperatorType *ot) static int set_handle_type_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); BKE_nurbList_handles_set(editnurb, RNA_enum_get(op->ptr, "type")); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -3576,7 +3567,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) void CURVE_OT_handle_type_set(wmOperatorType *ot) { /* keep in sync with graphkeys_handle_type_items */ - static EnumPropertyItem editcurve_handle_type_items[]= { + static EnumPropertyItem editcurve_handle_type_items[] = { {HD_AUTO, "AUTOMATIC", 0, "Automatic", ""}, {HD_VECT, "VECTOR", 0, "Vector", ""}, {5, "ALIGNED", 0, "Aligned", ""}, @@ -3595,7 +3586,7 @@ void CURVE_OT_handle_type_set(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", editcurve_handle_type_items, 1, "Type", "Spline type"); @@ -3610,36 +3601,36 @@ static void switchdirection_knots(float *base, int tot) float *fp1, *fp2, *tempf; int a; - if (base==NULL || tot==0) return; + if (base == NULL || tot == 0) return; /* reverse knots */ - a= tot; - fp1= base; - fp2= fp1+(a-1); - a/= 2; - while (fp1!=fp2 && a>0) { + a = tot; + fp1 = base; + fp2 = fp1 + (a - 1); + a /= 2; + while (fp1 != fp2 && a > 0) { SWAP(float, *fp1, *fp2); a--; fp1++; fp2--; } /* and make in increasing order again */ - a= tot; - fp1= base; - fp2=tempf= MEM_mallocN(sizeof(float)*a, "switchdirect"); + a = tot; + fp1 = base; + fp2 = tempf = MEM_mallocN(sizeof(float) * a, "switchdirect"); while (a--) { - fp2[0]= fabs(fp1[1]-fp1[0]); + fp2[0] = fabs(fp1[1] - fp1[0]); fp1++; fp2++; } - a= tot-1; - fp1= base; - fp2= tempf; - fp1[0]= 0.0; + a = tot - 1; + fp1 = base; + fp2 = tempf; + fp1[0] = 0.0; fp1++; while (a--) { - fp1[0]= fp1[-1]+fp2[0]; + fp1[0] = fp1[-1] + fp2[0]; fp1++; fp2++; } @@ -3659,12 +3650,12 @@ static void rotate_direction_nurb(Nurb *nu) SWAP(float *, nu->knotsu, nu->knotsv); switchdirection_knots(nu->knotsv, KNOTSV(nu)); - temp= MEM_dupallocN(nu->bp); - bp1= nu->bp; - for (v=0; vpntsv; v++) { - for (u=0; upntsu; u++, bp1++) { - bp2= temp + (nu->pntsu-u-1)*(nu->pntsv) + v; - *bp1= *bp2; + temp = MEM_dupallocN(nu->bp); + bp1 = nu->bp; + for (v = 0; v < nu->pntsv; v++) { + for (u = 0; u < nu->pntsu; u++, bp1++) { + bp2 = temp + (nu->pntsu - u - 1) * (nu->pntsv) + v; + *bp1 = *bp2; } } @@ -3677,8 +3668,8 @@ static int is_u_selected(Nurb *nu, int u) int v; /* what about resolu == 2? */ - bp= nu->bp+u; - for (v=0; vpntsv-1; v++, bp+=nu->pntsu) { + bp = &nu->bp[u]; + for (v = 0; v < nu->pntsv - 1; v++, bp += nu->pntsu) { if (v) if (bp->f1 & SELECT) return 1; } @@ -3691,66 +3682,66 @@ typedef struct NurbSort { float vec[3]; } NurbSort; -static ListBase nsortbase= {NULL, NULL}; +static ListBase nsortbase = {NULL, NULL}; /* static NurbSort *nusmain; */ /* this var seems to go unused... at least in this file */ static void make_selection_list_nurb(ListBase *editnurb) { - ListBase nbase= {NULL, NULL}; + ListBase nbase = {NULL, NULL}; NurbSort *nus, *nustest, *headdo, *taildo; Nurb *nu; BPoint *bp; float dist, headdist, taildist; int a; - for (nu= editnurb->first; nu; nu= nu->next) { - if ( isNurbsel(nu) ) { + for (nu = editnurb->first; nu; nu = nu->next) { + if (isNurbsel(nu)) { - nus = (NurbSort*)MEM_callocN(sizeof(NurbSort), "sort"); + nus = (NurbSort *)MEM_callocN(sizeof(NurbSort), "sort"); BLI_addhead(&nbase, nus); - nus->nu= nu; + nus->nu = nu; - bp= nu->bp; - a= nu->pntsu; + bp = nu->bp; + a = nu->pntsu; while (a--) { add_v3_v3(nus->vec, bp->vec); bp++; } - mul_v3_fl(nus->vec, 1.0f/(float)nu->pntsu); + mul_v3_fl(nus->vec, 1.0f / (float)nu->pntsu); } } /* just add the first one */ - nus= nbase.first; + nus = nbase.first; BLI_remlink(&nbase, nus); BLI_addtail(&nsortbase, nus); /* now add, either at head or tail, the closest one */ while (nbase.first) { - headdist= taildist= 1.0e30; - headdo= taildo= NULL; + headdist = taildist = 1.0e30; + headdo = taildo = NULL; - nustest= nbase.first; + nustest = nbase.first; while (nustest) { - dist= len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); + dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.first)->vec); - if (distvec, ((NurbSort *)nsortbase.last)->vec); + dist = len_v3v3(nustest->vec, ((NurbSort *)nsortbase.last)->vec); - if (distnext; + nustest = nustest->next; } - if (headdistpntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1) ) ; else { /* For 2D curves blender uses orderv=0. It doesn't make any sense mathematically. */ /* but after rotating orderu=0 will be confusing. */ - if (nu1->orderv == 0) nu1->orderv= 1; + if (nu1->orderv == 0) nu1->orderv = 1; rotate_direction_nurb(nu1); - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1)) ; else { rotate_direction_nurb(nu1); - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1)) ; else { rotate_direction_nurb(nu1); - if ( is_u_selected(nu1, nu1->pntsu-1) ); + if (is_u_selected(nu1, nu1->pntsu - 1)) ; else { /* rotate again, now its OK! */ - if (nu1->pntsv!=1) rotate_direction_nurb(nu1); + if (nu1->pntsv != 1) rotate_direction_nurb(nu1); return; } } @@ -3796,28 +3787,28 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu } /* 2nd nurbs: u = 0 selected */ - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0) ) ; else { - if (nu2->orderv == 0) nu2->orderv= 1; + if (nu2->orderv == 0) nu2->orderv = 1; rotate_direction_nurb(nu2); - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0)) ; else { rotate_direction_nurb(nu2); - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0)) ; else { rotate_direction_nurb(nu2); - if ( is_u_selected(nu2, 0) ); + if (is_u_selected(nu2, 0)) ; else { /* rotate again, now its OK! */ - if (nu1->pntsu==1) rotate_direction_nurb(nu1); - if (nu2->pntsv!=1) rotate_direction_nurb(nu2); + if (nu1->pntsu == 1) rotate_direction_nurb(nu1); + if (nu2->pntsv != 1) rotate_direction_nurb(nu2); return; } } } } - if ( nu1->pntsv != nu2->pntsv ) { + if (nu1->pntsv != nu2->pntsv) { BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); return; } @@ -3825,46 +3816,46 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu /* ok, now nu1 has the rightmost column and nu2 the leftmost column selected */ /* maybe we need a 'v' flip of nu2? */ - bp1= nu1->bp+nu1->pntsu-1; - bp2= nu2->bp; - len1= 0.0; + bp1 = &nu1->bp[nu1->pntsu - 1]; + bp2 = nu2->bp; + len1 = 0.0; - for (v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2+=nu2->pntsu) { - len1+= len_v3v3(bp1->vec, bp2->vec); + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 += nu2->pntsu) { + len1 += len_v3v3(bp1->vec, bp2->vec); } - bp1= nu1->bp + nu1->pntsu-1; - bp2= nu2->bp + nu2->pntsu*(nu2->pntsv-1); - len2= 0.0; + bp1 = &nu1->bp[nu1->pntsu - 1]; + bp2 = &nu2->bp[nu2->pntsu * (nu2->pntsv - 1)]; + len2 = 0.0; - for (v=0; vpntsv; v++, bp1+=nu1->pntsu, bp2-=nu2->pntsu) { - len2+= len_v3v3(bp1->vec, bp2->vec); + for (v = 0; v < nu1->pntsv; v++, bp1 += nu1->pntsu, bp2 -= nu2->pntsu) { + len2 += len_v3v3(bp1->vec, bp2->vec); } /* merge */ - origu= nu1->pntsu; - nu1->pntsu+= nu2->pntsu; - if (nu1->orderu<3 && nu1->orderupntsu) nu1->orderu++; - if (nu1->orderv<3 && nu1->ordervpntsv) nu1->orderv++; - temp= nu1->bp; - nu1->bp= MEM_mallocN(nu1->pntsu*nu1->pntsv*sizeof(BPoint), "mergeBP"); + origu = nu1->pntsu; + nu1->pntsu += nu2->pntsu; + if (nu1->orderu < 3 && nu1->orderu < nu1->pntsu) nu1->orderu++; + if (nu1->orderv < 3 && nu1->orderv < nu1->pntsv) nu1->orderv++; + temp = nu1->bp; + nu1->bp = MEM_mallocN(nu1->pntsu * nu1->pntsv * sizeof(BPoint), "mergeBP"); - bp= nu1->bp; - bp1= temp; + bp = nu1->bp; + bp1 = temp; - for (v=0; vpntsv; v++) { + for (v = 0; v < nu1->pntsv; v++) { /* switch direction? */ - if (len1bp + v*nu2->pntsu; - else bp2= nu2->bp + (nu1->pntsv-v-1)*nu2->pntsu; + if (len1 < len2) bp2 = &nu2->bp[v * nu2->pntsu]; + else bp2 = &nu2->bp[(nu1->pntsv - v - 1) * nu2->pntsu]; - for (u=0; upntsu; u++, bp++) { - if (upntsu; u++, bp++) { + if (u < origu) { + *bp = *bp1; bp1++; select_bpoint(bp, SELECT, 1, HIDDEN); } else { - *bp= *bp2; bp2++; + *bp = *bp2; bp2++; } } } @@ -3884,10 +3875,10 @@ static void merge_2_nurb(wmOperator *op, ListBase *editnurb, Nurb *nu1, Nurb *nu static int merge_nurb(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); NurbSort *nus1, *nus2; - int ok= 1; + int ok = 1; make_selection_list_nurb(editnurb); @@ -3897,25 +3888,25 @@ static int merge_nurb(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - nus1= nsortbase.first; - nus2= nus1->next; + nus1 = nsortbase.first; + nus2 = nus1->next; /* resolution match, to avoid uv rotations */ - if (nus1->nu->pntsv==1) { - if (nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsu==nus2->nu->pntsv); - else ok= 0; + if (nus1->nu->pntsv == 1) { + if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) ; + else ok = 0; } - else if (nus2->nu->pntsv==1) { - if (nus2->nu->pntsu==nus1->nu->pntsu || nus2->nu->pntsu==nus1->nu->pntsv); - else ok= 0; + else if (nus2->nu->pntsv == 1) { + if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) ; + else ok = 0; } - else if ( nus1->nu->pntsu==nus2->nu->pntsu || nus1->nu->pntsv==nus2->nu->pntsv); - else if ( nus1->nu->pntsu==nus2->nu->pntsv || nus1->nu->pntsv==nus2->nu->pntsu); + else if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsv == nus2->nu->pntsv) ; + else if (nus1->nu->pntsu == nus2->nu->pntsv || nus1->nu->pntsv == nus2->nu->pntsu) ; else { - ok= 0; + ok = 0; } - if (ok==0) { + if (ok == 0) { BKE_report(op->reports, RPT_ERROR, "Resolution doesn't match"); BLI_freelistN(&nsortbase); return OPERATOR_CANCELLED; @@ -3923,14 +3914,14 @@ static int merge_nurb(bContext *C, wmOperator *op) while (nus2) { merge_2_nurb(op, editnurb, nus1->nu, nus2->nu); - nus2= nus2->next; + nus2 = nus2->next; } BLI_freelistN(&nsortbase); set_actNurb(obedit, NULL); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -3939,91 +3930,91 @@ static int merge_nurb(bContext *C, wmOperator *op) static int make_segment_exec(bContext *C, wmOperator *op) { /* joins 2 curves */ - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *nubase= object_editcurve_get(obedit); - Nurb *nu, *nu1=NULL, *nu2=NULL; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *nubase = object_editcurve_get(obedit); + Nurb *nu, *nu1 = NULL, *nu2 = NULL; BPoint *bp; float *fp, offset; - int a, ok= 0; + int a, ok = 0; /* first decide if this is a surface merge! */ - if (obedit->type==OB_SURF) nu= nubase->first; - else nu= NULL; + if (obedit->type == OB_SURF) nu = nubase->first; + else nu = NULL; while (nu) { - if ( isNurbsel(nu) ) { + if (isNurbsel(nu)) { - if (nu->pntsu>1 && nu->pntsv>1) break; - if (isNurbsel_count(cu, nu)>1) break; - if (isNurbsel_count(cu, nu)==1) { + if (nu->pntsu > 1 && nu->pntsv > 1) break; + if (isNurbsel_count(cu, nu) > 1) break; + if (isNurbsel_count(cu, nu) == 1) { /* only 1 selected, not first or last, a little complex, but intuitive */ - if (nu->pntsv==1) { - if ( (nu->bp->f1 & SELECT) || ((nu->bp+nu->pntsu-1)->f1 & SELECT)); + if (nu->pntsv == 1) { + if ( (nu->bp->f1 & SELECT) || (nu->bp[nu->pntsu - 1].f1 & SELECT)) ; else break; } } } - nu= nu->next; + nu = nu->next; } if (nu) return merge_nurb(C, op); /* find both nurbs and points, nu1 will be put behind nu2 */ - for (nu= nubase->first; nu; nu= nu->next) { + for (nu = nubase->first; nu; nu = nu->next) { if (nu->pntsu == 1) - nu->flagu&= ~CU_NURB_CYCLIC; + nu->flagu &= ~CU_NURB_CYCLIC; - if ((nu->flagu & CU_NURB_CYCLIC)==0) { /* not cyclic */ + if ((nu->flagu & CU_NURB_CYCLIC) == 0) { /* not cyclic */ if (nu->type == CU_BEZIER) { - if (nu1==NULL) { - if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1= nu; + if (nu1 == NULL) { + if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) nu1 = nu; else { - if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { - nu1= nu; + if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1])) ) { + nu1 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } } } - else if (nu2==NULL) { - if ( BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { - nu2= nu; + else if (nu2 == NULL) { + if (BEZSELECTED_HIDDENHANDLES(cu, nu->bezt) ) { + nu2 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } else { - if ( BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu-1])) ) { - nu2= nu; + if (BEZSELECTED_HIDDENHANDLES(cu, &(nu->bezt[nu->pntsu - 1])) ) { + nu2 = nu; } } } else break; } - else if (nu->pntsv==1) { - bp= nu->bp; - if (nu1==NULL) { - if ( bp->f1 & SELECT) nu1= nu; + else if (nu->pntsv == 1) { + bp = nu->bp; + if (nu1 == NULL) { + if (bp->f1 & SELECT) nu1 = nu; else { - bp= bp+(nu->pntsu-1); - if ( bp->f1 & SELECT ) { - nu1= nu; + bp = bp + (nu->pntsu - 1); + if (bp->f1 & SELECT) { + nu1 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } } } - else if (nu2==NULL) { - if ( bp->f1 & SELECT ) { - nu2= nu; + else if (nu2 == NULL) { + if (bp->f1 & SELECT) { + nu2 = nu; BKE_nurb_direction_switch(nu); keyData_switchDirectionNurb(cu, nu); } else { - bp= bp+(nu->pntsu-1); - if ( bp->f1 & SELECT ) { - nu2= nu; + bp = bp + (nu->pntsu - 1); + if (bp->f1 & SELECT) { + nu2 = nu; } } } @@ -4032,75 +4023,74 @@ static int make_segment_exec(bContext *C, wmOperator *op) } } - if ((nu1 && nu2) && (nu1!=nu2)) { - if ( nu1->type==nu2->type) { + if ((nu1 && nu2) && (nu1 != nu2)) { + if (nu1->type == nu2->type) { if (nu1->type == CU_BEZIER) { - BezTriple *bezt = - (BezTriple*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BezTriple), "addsegmentN"); + BezTriple *bezt = (BezTriple *)MEM_mallocN((nu1->pntsu + nu2->pntsu) * sizeof(BezTriple), "addsegmentN"); ED_curve_beztcpy(cu->editnurb, bezt, nu2->bezt, nu2->pntsu); - ED_curve_beztcpy(cu->editnurb, bezt+nu2->pntsu, nu1->bezt, nu1->pntsu); + ED_curve_beztcpy(cu->editnurb, bezt + nu2->pntsu, nu1->bezt, nu1->pntsu); MEM_freeN(nu1->bezt); - nu1->bezt= bezt; - nu1->pntsu+= nu2->pntsu; + nu1->bezt = bezt; + nu1->pntsu += nu2->pntsu; BLI_remlink(nubase, nu2); - BKE_nurb_free(nu2); nu2= NULL; + BKE_nurb_free(nu2); nu2 = NULL; BKE_nurb_handles_calc(nu1); } else { - bp = - (BPoint*)MEM_mallocN((nu1->pntsu+nu2->pntsu) * sizeof(BPoint), "addsegmentN2"); + bp = (BPoint *)MEM_mallocN((nu1->pntsu + nu2->pntsu) * sizeof(BPoint), "addsegmentN2"); ED_curve_bpcpy(cu->editnurb, bp, nu2->bp, nu2->pntsu); - ED_curve_bpcpy(cu->editnurb, bp+nu2->pntsu, nu1->bp, nu1->pntsu); + ED_curve_bpcpy(cu->editnurb, bp + nu2->pntsu, nu1->bp, nu1->pntsu); MEM_freeN(nu1->bp); - nu1->bp= bp; + nu1->bp = bp; - a= nu1->pntsu+nu1->orderu; + a = nu1->pntsu + nu1->orderu; - nu1->pntsu+= nu2->pntsu; + nu1->pntsu += nu2->pntsu; BLI_remlink(nubase, nu2); /* now join the knots */ if (nu1->type == CU_NURBS) { - if (nu1->knotsu==NULL) { + if (nu1->knotsu == NULL) { BKE_nurb_knot_calc_u(nu1); } else { - fp= MEM_mallocN(sizeof(float)*KNOTSU(nu1), "addsegment3"); - memcpy(fp, nu1->knotsu, sizeof(float)*a); + fp = MEM_mallocN(sizeof(float) * KNOTSU(nu1), "addsegment3"); + memcpy(fp, nu1->knotsu, sizeof(float) * a); MEM_freeN(nu1->knotsu); - nu1->knotsu= fp; + nu1->knotsu = fp; - offset= nu1->knotsu[a-1] + 1.0f; - fp= nu1->knotsu+a; - for (a=0; apntsu; a++, fp++) { + offset = nu1->knotsu[a - 1] + 1.0f; + fp = nu1->knotsu + a; + for (a = 0; a < nu2->pntsu; a++, fp++) { if (nu2->knotsu) - *fp= offset+nu2->knotsu[a+1]; + *fp = offset + nu2->knotsu[a + 1]; else *fp = offset; } } } - BKE_nurb_free(nu2); nu2= NULL; + BKE_nurb_free(nu2); nu2 = NULL; } - set_actNurb(obedit, nu1); /* for selected */ - ok= 1; + set_actNurb(obedit, nu1); /* for selected */ + ok = 1; } } else if (nu1 && !nu2) { - if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu>1) { + if (!(nu1->flagu & CU_NURB_CYCLIC) && nu1->pntsu > 1) { if (nu1->type == CU_BEZIER && BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt) && - BEZSELECTED_HIDDENHANDLES(cu, nu1->bezt+(nu1->pntsu-1))) { - nu1->flagu|= CU_NURB_CYCLIC; + BEZSELECTED_HIDDENHANDLES(cu, &nu1->bezt[nu1->pntsu - 1])) + { + nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_handles_calc(nu1); - ok= 1; + ok = 1; } - else if (nu1->type == CU_NURBS && nu1->bp->f1&SELECT && (nu1->bp+(nu1->pntsu-1))->f1&SELECT) { - nu1->flagu|= CU_NURB_CYCLIC; + else if (nu1->type == CU_NURBS && nu1->bp->f1 & SELECT && (nu1->bp[nu1->pntsu - 1].f1 & SELECT)) { + nu1->flagu |= CU_NURB_CYCLIC; BKE_nurb_knot_calc_u(nu1); - ok= 1; + ok = 1; } } } @@ -4111,9 +4101,9 @@ static int make_segment_exec(bContext *C, wmOperator *op) } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4131,67 +4121,67 @@ void CURVE_OT_make_segment(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** pick select from 3d view **********************/ int mouse_nurb(bContext *C, const int mval[2], int extend) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); ViewContext vc; Nurb *nu; - BezTriple *bezt=NULL; - BPoint *bp=NULL; + BezTriple *bezt = NULL; + BPoint *bp = NULL; int location[2]; short hand; view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); - location[0]= mval[0]; - location[1]= mval[1]; - hand= findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); + location[0] = mval[0]; + location[1] = mval[1]; + hand = findnearestNurbvert(&vc, 1, location, &nu, &bezt, &bp); if (bezt || bp) { - if (extend==0) { + if (extend == 0) { setflagsNurb(editnurb, 0); if (bezt) { - if (hand==1) { + if (hand == 1) { select_beztriple(bezt, SELECT, 1, HIDDEN); - cu->lastsel= bezt; + cu->lastsel = bezt; } else { - if (hand==0) bezt->f1|= SELECT; - else bezt->f3|= SELECT; + if (hand == 0) bezt->f1 |= SELECT; + else bezt->f3 |= SELECT; - cu->lastsel= NULL; + cu->lastsel = NULL; } } else { - cu->lastsel= bp; + cu->lastsel = bp; select_bpoint(bp, SELECT, 1, HIDDEN); } } else { if (bezt) { - if (hand==1) { + if (hand == 1) { if (bezt->f2 & SELECT) { select_beztriple(bezt, DESELECT, 1, HIDDEN); if (bezt == cu->lastsel) cu->lastsel = NULL; } else { select_beztriple(bezt, SELECT, 1, HIDDEN); - cu->lastsel= bezt; + cu->lastsel = bezt; } } - else if (hand==0) { + else if (hand == 0) { bezt->f1 ^= SELECT; } else { @@ -4205,16 +4195,16 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) } else { select_bpoint(bp, SELECT, 1, HIDDEN); - cu->lastsel= bp; + cu->lastsel = bp; } } } - if (nu!=get_actNurb(obedit)) + if (nu != get_actNurb(obedit)) set_actNurb(obedit, nu); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return 1; } @@ -4228,13 +4218,13 @@ int mouse_nurb(bContext *C, const int mval[2], int extend) */ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cent) { - Curve *cu= (Curve*)obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Curve *cu = (Curve *)obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; float si, phi, n[3], q[4], cmat[3][3], tmat[3][3], imat[3][3]; float bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3]; float persmat[3][3], persinv[3][3]; - short a, ok, changed= 0; + short a, ok, changed = 0; copy_m3_m4(persmat, viewmat); invert_m3_m3(persinv, persmat); @@ -4244,20 +4234,20 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen invert_m3_m3(imat, bmat); normalize_v3_v3(n, axis); - - phi= M_PI/8.0; - q[0]= cos(phi); - si= sin(phi); - q[1]= n[0]*si; - q[2]= n[1]*si; - q[3]= n[2]*si; + /* TODO - use math func */ + phi = M_PI / 8.0; + q[0] = cos(phi); + si = sin(phi); + q[1] = n[0] * si; + q[2] = n[1] * si; + q[3] = n[2] * si; quat_to_mat3(cmat, q); mul_m3_m3m3(tmat, cmat, bmat); mul_m3_m3m3(rotmat, imat, tmat); unit_m3(scalemat1); - scalemat1[0][0]= M_SQRT2; - scalemat1[1][1]= M_SQRT2; + scalemat1[0][0] = M_SQRT2; + scalemat1[1][1] = M_SQRT2; mul_m3_m3m3(tmat, persmat, bmat); mul_m3_m3m3(cmat, scalemat1, tmat); @@ -4273,32 +4263,32 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen mul_m3_m3m3(tmat, persinv, cmat); mul_m3_m3m3(scalemat2, imat, tmat); - ok= 1; + ok = 1; - for (a=0;a<7;a++) { - ok= extrudeflagNurb(cu->editnurb, 1); + for (a = 0; a < 7; a++) { + ok = extrudeflagNurb(cu->editnurb, 1); - if (ok==0) + if (ok == 0) return changed; - changed= 1; + changed = 1; rotateflagNurb(editnurb, SELECT, cent, rotmat); - if ( (a & SELECT)==0 ) { + if ((a & SELECT) == 0) { rotateflagNurb(editnurb, SELECT, cent, scalemat1); - weightflagNurb(editnurb, SELECT, 0.25*M_SQRT2); + weightflagNurb(editnurb, SELECT, 0.25 * M_SQRT2); } else { rotateflagNurb(editnurb, SELECT, cent, scalemat2); - weightflagNurb(editnurb, SELECT, 4.0/M_SQRT2); + weightflagNurb(editnurb, SELECT, 4.0 / M_SQRT2); } } if (ok) { - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { - nu->orderv= 4; + nu->orderv = 4; nu->flagv |= CU_NURB_CYCLIC; BKE_nurb_knot_calc_v(nu); } @@ -4310,8 +4300,8 @@ static int spin_nurb(float viewmat[][4], Object *obedit, float *axis, float *cen static int spin_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); + Object *obedit = CTX_data_edit_object(C); + RegionView3D *rv3d = ED_view3d_context_rv3d(C); float cent[3], axis[3], viewmat[4][4]; RNA_float_get_array(op->ptr, "center", cent); @@ -4331,9 +4321,9 @@ static int spin_exec(bContext *C, wmOperator *op) } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4343,8 +4333,8 @@ static int spin_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); - float axis[3]= {0.0f, 0.0f, 1.0f}; + RegionView3D *rv3d = ED_view3d_context_rv3d(C); + float axis[3] = {0.0f, 0.0f, 1.0f}; if (rv3d) copy_v3_v3(axis, rv3d->viewinv[2]); @@ -4368,7 +4358,7 @@ void CURVE_OT_spin(wmOperatorType *ot) ot->poll = ED_operator_editsurf; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_float_vector_xyz(ot->srna, "center", 3, NULL, -FLT_MAX, FLT_MAX, "Center", "Center in global view space", -FLT_MAX, FLT_MAX); RNA_def_float_vector(ot->srna, "axis", 3, NULL, -1.0f, 1.0f, "Axis", "Axis in global view space", -FLT_MAX, FLT_MAX); @@ -4378,47 +4368,47 @@ void CURVE_OT_spin(wmOperatorType *ot) static int addvert_Nurb(bContext *C, short mode, float location[3]) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; - Nurb *nu, *newnu= NULL; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; + Nurb *nu, *newnu = NULL; BezTriple *bezt, *newbezt = NULL; BPoint *bp, *newbp = NULL; float imat[4][4], temp[3]; - int ok= 0; + int ok = 0; BezTriple *bezt_recalc[3] = {NULL}; invert_m4_m4(imat, obedit->obmat); findselectedNurbvert(&editnurb->nurbs, &nu, &bezt, &bp); - if ((nu == NULL) || (nu->type==CU_BEZIER && bezt==NULL) || (nu->type!=CU_BEZIER && bp==NULL)) { - if (mode!='e') { + if ((nu == NULL) || (nu->type == CU_BEZIER && bezt == NULL) || (nu->type != CU_BEZIER && bp == NULL)) { + if (mode != 'e') { if (cu->actnu >= 0) - nu= BLI_findlink(&editnurb->nurbs, cu->actnu); + nu = BLI_findlink(&editnurb->nurbs, cu->actnu); - if (!nu || nu->type==CU_BEZIER) { - newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); - newbezt->radius= 1; - newbezt->alfa= 0; + if (!nu || nu->type == CU_BEZIER) { + newbezt = (BezTriple *)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); + newbezt->radius = 1; + newbezt->alfa = 0; BEZ_SEL(newbezt); - newbezt->h2= newbezt->h1= HD_AUTO; + newbezt->h2 = newbezt->h1 = HD_AUTO; - newnu= (Nurb*)MEM_callocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_callocN(sizeof(Nurb), "addvert_Nurb newnu"); if (!nu) { /* no selected segment -- create new one which is BEZIER type * type couldn't be determined from Curve bt could be changed * in the future, so shouldn't make much headache */ - newnu->type= CU_BEZIER; - newnu->resolu= cu->resolu; + newnu->type = CU_BEZIER; + newnu->resolu = cu->resolu; newnu->flag |= CU_SMOOTH; } else memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bezt= newbezt; - newnu->pntsu= 1; + newnu->bezt = newbezt; + newnu->pntsu = 1; temp[0] = 1; temp[1] = 0; @@ -4432,32 +4422,32 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) mul_m4_v3(imat, newbezt->vec[1]); mul_m4_v3(imat, newbezt->vec[2]); - ok= 1; - nu= newnu; + ok = 1; + nu = newnu; } else if (nu->pntsv == 1) { - newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); - newbp->radius= 1; - newbp->alfa= 0; - newbp->f1|= SELECT; - cu->lastsel= newbp; + newbp = (BPoint *)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); + newbp->radius = 1; + newbp->alfa = 0; + newbp->f1 |= SELECT; + cu->lastsel = newbp; - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bp= newbp; - newnu->orderu= 2; - newnu->pntsu= 1; + newnu->bp = newbp; + newnu->orderu = 2; + newnu->pntsu = 1; mul_v3_m4v3(newbp->vec, imat, location); - newbp->vec[3]= 1.0; + newbp->vec[3] = 1.0; - newnu->knotsu= newnu->knotsv= NULL; + newnu->knotsu = newnu->knotsv = NULL; BKE_nurb_knot_calc_u(newnu); - ok= 1; - nu= newnu; + ok = 1; + nu = newnu; } } @@ -4468,73 +4458,71 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) if (!ok && nu->type == CU_BEZIER) { /* which bezpoint? */ - if (bezt== (nu->bezt+nu->pntsu-1)) { /* last */ + if (bezt == &nu->bezt[nu->pntsu - 1]) { /* last */ BEZ_DESEL(bezt); - newbezt = - (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb"); + newbezt = (BezTriple *)MEM_callocN((nu->pntsu + 1) * sizeof(BezTriple), "addvert_Nurb"); ED_curve_beztcpy(editnurb, newbezt, nu->bezt, nu->pntsu); - *(newbezt+nu->pntsu)= *bezt; + newbezt[nu->pntsu] = *bezt; copy_v3_v3(temp, bezt->vec[1]); MEM_freeN(nu->bezt); - nu->bezt= newbezt; - newbezt+= nu->pntsu; + nu->bezt = newbezt; + newbezt += nu->pntsu; BEZ_SEL(newbezt); - cu->lastsel= newbezt; + cu->lastsel = newbezt; newbezt->h1 = newbezt->h2; - bezt= nu->bezt+nu->pntsu-1; - ok= 1; + bezt = &nu->bezt[nu->pntsu - 1]; + ok = 1; if (nu->pntsu > 1) { bezt_recalc[1] = newbezt; bezt_recalc[0] = newbezt - 1; } } - else if (bezt== nu->bezt) { /* first */ + else if (bezt == nu->bezt) { /* first */ BEZ_DESEL(bezt); - newbezt = - (BezTriple*)MEM_callocN((nu->pntsu+1) * sizeof(BezTriple), "addvert_Nurb"); - ED_curve_beztcpy(editnurb, newbezt+1, bezt, nu->pntsu); - *newbezt= *bezt; + newbezt = (BezTriple *)MEM_callocN((nu->pntsu + 1) * sizeof(BezTriple), "addvert_Nurb"); + ED_curve_beztcpy(editnurb, newbezt + 1, bezt, nu->pntsu); + *newbezt = *bezt; BEZ_SEL(newbezt); - cu->lastsel= newbezt; - newbezt->h2= newbezt->h1; + cu->lastsel = newbezt; + newbezt->h2 = newbezt->h1; copy_v3_v3(temp, bezt->vec[1]); MEM_freeN(nu->bezt); - nu->bezt= newbezt; - bezt= newbezt+1; - ok= 1; + nu->bezt = newbezt; + bezt = newbezt + 1; + ok = 1; if (nu->pntsu > 1) { bezt_recalc[1] = newbezt; bezt_recalc[2] = newbezt + 1; } } - else if (mode!='e') { + else if (mode != 'e') { BEZ_DESEL(bezt); - newbezt= (BezTriple*)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); - *newbezt= *bezt; + newbezt = (BezTriple *)MEM_callocN(sizeof(BezTriple), "addvert_Nurb"); + *newbezt = *bezt; BEZ_SEL(newbezt); - newbezt->h2= newbezt->h1; + newbezt->h2 = newbezt->h1; copy_v3_v3(temp, bezt->vec[1]); - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bezt= newbezt; - newnu->pntsu= 1; + newnu->bezt = newbezt; + newnu->pntsu = 1; - cu->lastsel= newbezt; + cu->lastsel = newbezt; - bezt= newbezt; - ok= 1; + bezt = newbezt; + ok = 1; } - else bezt= NULL; + else bezt = NULL; if (bezt) { if (!newnu) nu->pntsu++; - if (mode=='e') { + if (mode == 'e') { copy_v3_v3(newbezt->vec[0], bezt->vec[0]); copy_v3_v3(newbezt->vec[1], bezt->vec[1]); copy_v3_v3(newbezt->vec[2], bezt->vec[2]); @@ -4561,65 +4549,63 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) } } } - else if (!ok && nu->pntsv==1) { + else if (!ok && nu->pntsv == 1) { /* which b-point? */ - if (bp== (nu->bp+nu->pntsu-1)) { /* last */ - bp->f1= 0; - newbp = - (BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb4"); + if (bp == &nu->bp[nu->pntsu - 1]) { /* last */ + bp->f1 = 0; + newbp = (BPoint *)MEM_callocN((nu->pntsu + 1) * sizeof(BPoint), "addvert_Nurb4"); ED_curve_bpcpy(editnurb, newbp, nu->bp, nu->pntsu); - *(newbp+nu->pntsu)= *bp; + newbp[nu->pntsu] = *bp; MEM_freeN(nu->bp); - nu->bp= newbp; - newbp+= nu->pntsu; - newbp->f1|= SELECT; - cu->lastsel= newbp; - bp= newbp - 1; - ok= 1; + nu->bp = newbp; + newbp += nu->pntsu; + newbp->f1 |= SELECT; + cu->lastsel = newbp; + bp = newbp - 1; + ok = 1; } - else if (bp== nu->bp) { /* first */ - bp->f1= 0; - newbp = - (BPoint*)MEM_callocN((nu->pntsu+1) * sizeof(BPoint), "addvert_Nurb3"); - ED_curve_bpcpy(editnurb, newbp+1, bp, nu->pntsu); - *newbp= *bp; - newbp->f1|= SELECT; - cu->lastsel= newbp; + else if (bp == nu->bp) { /* first */ + bp->f1 = 0; + newbp = (BPoint *)MEM_callocN((nu->pntsu + 1) * sizeof(BPoint), "addvert_Nurb3"); + ED_curve_bpcpy(editnurb, newbp + 1, bp, nu->pntsu); + *newbp = *bp; + newbp->f1 |= SELECT; + cu->lastsel = newbp; MEM_freeN(nu->bp); - nu->bp= newbp; - bp= newbp + 1; - ok= 1; + nu->bp = newbp; + bp = newbp + 1; + ok = 1; } - else if (mode!='e') { - bp->f1= 0; - newbp= (BPoint*)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); - *newbp= *bp; - newbp->f1|= SELECT; - cu->lastsel= newbp; + else if (mode != 'e') { + bp->f1 = 0; + newbp = (BPoint *)MEM_callocN(sizeof(BPoint), "addvert_Nurb5"); + *newbp = *bp; + newbp->f1 |= SELECT; + cu->lastsel = newbp; - newnu= (Nurb*)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); + newnu = (Nurb *)MEM_mallocN(sizeof(Nurb), "addvert_Nurb newnu"); memcpy(newnu, nu, sizeof(Nurb)); BLI_addtail(&editnurb->nurbs, newnu); set_actNurb(obedit, newnu); - newnu->bp= newbp; - newnu->orderu= 2; - newnu->pntsu= 1; - newnu->knotsu= newnu->knotsv= NULL; + newnu->bp = newbp; + newnu->orderu = 2; + newnu->pntsu = 1; + newnu->knotsu = newnu->knotsv = NULL; - bp= newbp; - ok= 1; + bp = newbp; + ok = 1; } - else bp= NULL; + else bp = NULL; if (bp) { - if (mode=='e') { + if (mode == 'e') { copy_v3_v3(newbp->vec, bp->vec); } else { mul_v3_m4v3(newbp->vec, imat, location); - newbp->vec[3]= 1.0; + newbp->vec[3] = 1.0; - if (!newnu && nu->orderu<4 && nu->orderu<=nu->pntsu) + if (!newnu && nu->orderu < 4 && nu->orderu <= nu->pntsu) nu->orderu++; } @@ -4635,9 +4621,9 @@ static int addvert_Nurb(bContext *C, short mode, float location[3]) BKE_nurb_test2D(nu); if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4656,7 +4642,7 @@ static int add_vertex_exec(bContext *C, wmOperator *op) static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); if (rv3d && !RNA_struct_property_is_set(op->ptr, "location")) { Curve *cu; @@ -4669,7 +4655,7 @@ static int add_vertex_invoke(bContext *C, wmOperator *op, wmEvent *event) view3d_set_viewcontext(C, &vc); - cu= vc.obedit->data; + cu = vc.obedit->data; findselectedNurbvert(&cu->editnurb->nurbs, &nu, &bezt, &bp); @@ -4703,7 +4689,7 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector_xyz(ot->srna, "location", 3, NULL, -FLT_MAX, FLT_MAX, "Location", "Location to add new vertex at", -1e4, 1e4); @@ -4713,25 +4699,25 @@ void CURVE_OT_vertex_add(wmOperatorType *ot) static int extrude_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditNurb *editnurb= cu->editnurb; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; Nurb *nu; /* first test: curve? */ - for (nu= editnurb->nurbs.first; nu; nu= nu->next) - if (nu->pntsv==1 && isNurbsel_count(cu, nu)==1) + for (nu = editnurb->nurbs.first; nu; nu = nu->next) + if (nu->pntsv == 1 && isNurbsel_count(cu, nu) == 1) break; - if (obedit->type==OB_CURVE || nu) { + if (obedit->type == OB_CURVE || nu) { addvert_Nurb(C, 'e', NULL); } else { if (extrudeflagNurb(editnurb, 1)) { /* '1'= flag */ if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); } } @@ -4751,7 +4737,7 @@ void CURVE_OT_extrude(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -4761,21 +4747,21 @@ void CURVE_OT_extrude(wmOperatorType *ot) static int toggle_cyclic_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; - int a, direction= RNA_enum_get(op->ptr, "direction"); + int a, direction = RNA_enum_get(op->ptr, "direction"); - for (nu= editnurb->first; nu; nu= nu->next) { - if ( nu->pntsu>1 || nu->pntsv>1) { + for (nu = editnurb->first; nu; nu = nu->next) { + if (nu->pntsu > 1 || nu->pntsv > 1) { if (nu->type == CU_POLY) { - a= nu->pntsu; - bp= nu->bp; + a = nu->pntsu; + bp = nu->bp; while (a--) { - if ( bp->f1 & SELECT ) { + if (bp->f1 & SELECT) { nu->flagu ^= CU_NURB_CYCLIC; break; } @@ -4783,10 +4769,10 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } } else if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { nu->flagu ^= CU_NURB_CYCLIC; break; } @@ -4794,31 +4780,31 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } BKE_nurb_handles_calc(nu); } - else if (nu->pntsv==1 && nu->type == CU_NURBS) { + else if (nu->pntsv == 1 && nu->type == CU_NURBS) { if (nu->knotsu) { /* if check_valid_nurb_u fails the knotsu can be NULL */ - a= nu->pntsu; - bp= nu->bp; + a = nu->pntsu; + bp = nu->bp; while (a--) { - if ( bp->f1 & SELECT ) { + if (bp->f1 & SELECT) { nu->flagu ^= CU_NURB_CYCLIC; - BKE_nurb_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ + BKE_nurb_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ break; } bp++; } } } - else if (nu->type==CU_NURBS) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + else if (nu->type == CU_NURBS) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if ( bp->f1 & SELECT) { - if (direction==0 && nu->pntsu>1) { + if (bp->f1 & SELECT) { + if (direction == 0 && nu->pntsu > 1) { nu->flagu ^= CU_NURB_CYCLIC; BKE_nurb_knot_calc_u(nu); /* 1==u type is ignored for cyclic curves */ } - if (direction==1 && nu->pntsv>1) { + if (direction == 1 && nu->pntsv > 1) { nu->flagv ^= CU_NURB_CYCLIC; BKE_nurb_knot_calc_v(nu); /* 2==v type is ignored for cyclic curves */ } @@ -4831,7 +4817,7 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -4839,18 +4825,18 @@ static int toggle_cyclic_exec(bContext *C, wmOperator *op) static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); uiPopupMenu *pup; uiLayout *layout; Nurb *nu; if (obedit->type == OB_SURF) { - for (nu= editnurb->first; nu; nu= nu->next) { - if (nu->pntsu>1 || nu->pntsv>1) { - if (nu->type==CU_NURBS) { - pup= uiPupMenuBegin(C, "Direction", ICON_NONE); - layout= uiPupMenuLayout(pup); + for (nu = editnurb->first; nu; nu = nu->next) { + if (nu->pntsu > 1 || nu->pntsv > 1) { + if (nu->type == CU_NURBS) { + pup = uiPupMenuBegin(C, "Direction", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsEnumO(layout, op->type->idname, "direction"); uiPupMenuEnd(C, pup); return OPERATOR_CANCELLED; @@ -4864,7 +4850,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve void CURVE_OT_cyclic_toggle(wmOperatorType *ot) { - static EnumPropertyItem direction_items[]= { + static EnumPropertyItem direction_items[] = { {0, "CYCLIC_U", 0, "Cyclic U", ""}, {1, "CYCLIC_V", 0, "Cyclic V", ""}, {0, NULL, 0, NULL, NULL}}; @@ -4880,7 +4866,7 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "direction", direction_items, 0, "Direction", "Direction to make surface cyclic in"); @@ -4890,23 +4876,23 @@ void CURVE_OT_cyclic_toggle(wmOperatorType *ot) static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= (Curve*)obedit->data; - EditNurb *editnurb= cu->editnurb; - ListBase *nurbs= &editnurb->nurbs; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = (Curve *)obedit->data; + EditNurb *editnurb = cu->editnurb; + ListBase *nurbs = &editnurb->nurbs; Nurb *nu; BezTriple *bezt; BPoint *bp; int a; - for (nu= nurbs->first; nu; nu= nu->next) { + for (nu = nurbs->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if ( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { select_beztriple(bezt, SELECT, 1, VISIBLE); bezt++; @@ -4917,12 +4903,12 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if ( bp->f1 & 1 ) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + if (bp->f1 & SELECT) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { select_bpoint(bp, SELECT, 1, VISIBLE); bp++; @@ -4934,7 +4920,7 @@ static int select_linked_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -4957,7 +4943,7 @@ void CURVE_OT_select_linked(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ } @@ -4967,14 +4953,14 @@ void CURVE_OT_select_linked(wmOperatorType *ot) static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); ViewContext vc; Nurb *nu; BezTriple *bezt; BPoint *bp; int a, deselect; - deselect= RNA_boolean_get(op->ptr, "deselect"); + deselect = RNA_boolean_get(op->ptr, "deselect"); view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); @@ -4982,8 +4968,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event findnearestNurbvert(&vc, 1, event->mval, &nu, &bezt, &bp); if (bezt) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { if (deselect) select_beztriple(bezt, DESELECT, 1, VISIBLE); else select_beztriple(bezt, SELECT, 1, VISIBLE); @@ -4991,8 +4977,8 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event } } else if (bp) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { if (deselect) select_bpoint(bp, DESELECT, 1, VISIBLE); else select_bpoint(bp, SELECT, 1, VISIBLE); @@ -5000,7 +4986,7 @@ static int select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5017,7 +5003,7 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve_region_view3d; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "Deselect linked control points rather than selecting them"); @@ -5027,28 +5013,28 @@ void CURVE_OT_select_linked_pick(wmOperatorType *ot) static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); - static BPoint *last= NULL; - static int direction=0; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); + static BPoint *last = NULL; + static int direction = 0; Nurb *nu; BPoint *bp; - int u = 0, v = 0, a, b, ok=0; + int u = 0, v = 0, a, b, ok = 0; if (editnurb->first == NULL) return OPERATOR_CANCELLED; - if (cu->lastsel==NULL) + if (cu->lastsel == NULL) return OPERATOR_CANCELLED; /* find the correct nurb and toggle with u of v */ - for (nu= editnurb->first; nu; nu= nu->next) { - bp= nu->bp; - for (v=0; vpntsv; v++) { - for (u=0; upntsu; u++, bp++) { - if (bp==cu->lastsel) { + for (nu = editnurb->first; nu; nu = nu->next) { + bp = nu->bp; + for (v = 0; v < nu->pntsv; v++) { + for (u = 0; u < nu->pntsu; u++, bp++) { + if (bp == cu->lastsel) { if (bp->f1 & SELECT) { - ok= 1; + ok = 1; break; } } @@ -5057,20 +5043,20 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) } if (ok) { - if (last==cu->lastsel) { - direction= 1-direction; + if (last == cu->lastsel) { + direction = 1 - direction; setflagsNurb(editnurb, 0); } - last= cu->lastsel; + last = cu->lastsel; - bp= nu->bp; - for (a=0; apntsv; a++) { - for (b=0; bpntsu; b++, bp++) { + bp = nu->bp; + for (a = 0; a < nu->pntsv; a++) { + for (b = 0; b < nu->pntsu; b++, bp++) { if (direction) { - if (a==v) select_bpoint(bp, SELECT, 1, VISIBLE); + if (a == v) select_bpoint(bp, SELECT, 1, VISIBLE); } else { - if (b==u) select_bpoint(bp, SELECT, 1, VISIBLE); + if (b == u) select_bpoint(bp, SELECT, 1, VISIBLE); } } } @@ -5079,7 +5065,7 @@ static int select_row_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5096,18 +5082,18 @@ void CURVE_OT_select_row(wmOperatorType *ot) ot->poll = ED_operator_editsurf; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** select next operator **********************/ static int select_next_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); select_adjacent_cp(editnurb, 1, 0, SELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5124,18 +5110,18 @@ void CURVE_OT_select_next(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** select previous operator **********************/ static int select_previous_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); select_adjacent_cp(editnurb, -1, 0, SELECT); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5152,58 +5138,58 @@ void CURVE_OT_select_previous(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************** select more operator **********************/ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp, *tempbp; int a; - short sel= 0; + short sel = 0; short *selbpoints; /* note that NURBS surface is a special case because we mimic */ /* the behavior of "select more" of mesh tools. */ /* The algorithm is designed to work in planar cases so it */ /* may not be optimal always (example: end of NURBS sphere) */ - if (obedit->type==OB_SURF) { - for (nu= editnurb->first; nu; nu= nu->next) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - selbpoints= MEM_callocN(sizeof(short)*a-nu->pntsu, "selectlist"); + if (obedit->type == OB_SURF) { + for (nu = editnurb->first; nu; nu = nu->next) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + selbpoints = MEM_callocN(sizeof(short) * a - nu->pntsu, "selectlist"); while (a > 0) { - if ((selbpoints[a]!=1) && (bp->hide==0) && (bp->f1 & SELECT)) { + if ((selbpoints[a] != 1) && (bp->hide == 0) && (bp->f1 & SELECT)) { /* upper control point */ - if (a%nu->pntsu != 0) { - tempbp= bp-1; + if (a % nu->pntsu != 0) { + tempbp = bp - 1; if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); } /* left control point. select only if it is not selected already */ - if (a-nu->pntsu > 0) { - sel= 0; - tempbp= bp+nu->pntsu; - if (!(tempbp->f1 & SELECT)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (a - nu->pntsu > 0) { + sel = 0; + tempbp = bp + nu->pntsu; + if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE); /* make sure selected bpoint is discarded */ - if (sel == 1) selbpoints[a-nu->pntsu]= 1; + if (sel == 1) selbpoints[a - nu->pntsu] = 1; } /* right control point */ - if (a+nu->pntsu < nu->pntsu*nu->pntsv) { - tempbp= bp-nu->pntsu; + if (a + nu->pntsu < nu->pntsu * nu->pntsv) { + tempbp = bp - nu->pntsu; if (!(tempbp->f1 & SELECT)) select_bpoint(tempbp, SELECT, 1, VISIBLE); } /* lower control point. skip next bp in case selection was made */ - if (a%nu->pntsu != 1) { - sel= 0; - tempbp= bp+1; - if (!(tempbp->f1 & 1)) sel= select_bpoint(tempbp, SELECT, 1, VISIBLE); + if (a % nu->pntsu != 1) { + sel = 0; + tempbp = bp + 1; + if (!(tempbp->f1 & SELECT)) sel = select_bpoint(tempbp, SELECT, 1, VISIBLE); if (sel) { bp++; a--; @@ -5223,7 +5209,7 @@ static int select_more_exec(bContext *C, wmOperator *UNUSED(op)) select_adjacent_cp(editnurb, -1, 0, SELECT); } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5233,14 +5219,14 @@ void CURVE_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name = "Select More"; ot->idname = "CURVE_OT_select_more"; - ot->description = "Select control points linked to already selected ones"; + ot->description = "Select control points directly linked to already selected ones"; /* api callbacks */ ot->exec = select_more_exec; ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** select less operator *****************/ @@ -5248,60 +5234,60 @@ void CURVE_OT_select_more(wmOperatorType *ot) /* basic method: deselect if control point doesn't have all neighbors selected */ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BPoint *bp; BezTriple *bezt; int a; - short sel= 0, lastsel= 0; + short sel = 0, lastsel = 0; short *selbpoints; - if (obedit->type==OB_SURF) { - for (nu= editnurb->first; nu; nu= nu->next) { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - selbpoints= MEM_callocN(sizeof(short)*a, "selectlist"); + if (obedit->type == OB_SURF) { + for (nu = editnurb->first; nu; nu = nu->next) { + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + selbpoints = MEM_callocN(sizeof(short) * a, "selectlist"); while (a--) { - if ((bp->hide==0) && (bp->f1 & SELECT)) { - sel= 0; + if ((bp->hide == 0) && (bp->f1 & SELECT)) { + sel = 0; /* check if neighbors have been selected */ /* edges of surface are an exception */ - if ((a+1)%nu->pntsu==0) sel++; + if ((a + 1) % nu->pntsu == 0) sel++; else { bp--; - if ((selbpoints[a+1]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; + if ((selbpoints[a + 1] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; bp++; } - if ((a+1)%nu->pntsu==1) sel++; + if ((a + 1) % nu->pntsu == 1) sel++; else { bp++; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp--; } - if (a+1 > nu->pntsu*nu->pntsv-nu->pntsu) sel++; + if (a + 1 > nu->pntsu * nu->pntsv - nu->pntsu) sel++; else { - bp-=nu->pntsu; - if ((selbpoints[a+nu->pntsu]==1) || ((bp->hide==0) && (bp->f1 & SELECT))) sel++; - bp+=nu->pntsu; + bp -= nu->pntsu; + if ((selbpoints[a + nu->pntsu] == 1) || ((bp->hide == 0) && (bp->f1 & SELECT))) sel++; + bp += nu->pntsu; } if (a < nu->pntsu) sel++; else { - bp+=nu->pntsu; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; - bp-=nu->pntsu; + bp += nu->pntsu; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; + bp -= nu->pntsu; } - if (sel!=4) { + if (sel != 4) { select_bpoint(bp, DESELECT, 1, VISIBLE); - selbpoints[a]= 1; + selbpoints[a] = 1; } } - else lastsel= 0; + else lastsel = 0; bp++; } @@ -5310,74 +5296,74 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } else { - for (nu= editnurb->first; nu; nu= nu->next) { - lastsel=0; + for (nu = editnurb->first; nu; nu = nu->next) { + lastsel = 0; /* check what type of curve/nurb it is */ if (nu->type == CU_BEZIER) { - a= nu->pntsu; - bezt= nu->bezt; + a = nu->pntsu; + bezt = nu->bezt; while (a--) { - if ((bezt->hide==0) && (bezt->f2 & SELECT)) { - if (lastsel==1) sel= 1; - else sel= 0; + if ((bezt->hide == 0) && (bezt->f2 & SELECT)) { + if (lastsel == 1) sel = 1; + else sel = 0; /* check if neighbors have been selected */ /* first and last are exceptions */ - if (a==nu->pntsu-1) sel++; + if (a == nu->pntsu - 1) sel++; else { bezt--; - if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; + if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; bezt++; } - if (a==0) sel++; + if (a == 0) sel++; else { bezt++; - if ((bezt->hide==0) && (bezt->f2 & SELECT)) sel++; + if ((bezt->hide == 0) && (bezt->f2 & SELECT)) sel++; bezt--; } - if (sel!=2) { + if (sel != 2) { select_beztriple(bezt, DESELECT, 1, VISIBLE); - lastsel= 1; + lastsel = 1; } - else lastsel= 0; + else lastsel = 0; } - else lastsel= 0; + else lastsel = 0; bezt++; } } else { - a= nu->pntsu*nu->pntsv; - bp= nu->bp; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; while (a--) { - if ((lastsel==0) && (bp->hide==0) && (bp->f1 & SELECT)) { - if (lastsel!=0) sel= 1; - else sel= 0; + if ((lastsel == 0) && (bp->hide == 0) && (bp->f1 & SELECT)) { + if (lastsel != 0) sel = 1; + else sel = 0; /* first and last are exceptions */ - if (a==nu->pntsu*nu->pntsv-1) sel++; + if (a == nu->pntsu * nu->pntsv - 1) sel++; else { bp--; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp++; } - if (a==0) sel++; + if (a == 0) sel++; else { bp++; - if ((bp->hide==0) && (bp->f1 & SELECT)) sel++; + if ((bp->hide == 0) && (bp->f1 & SELECT)) sel++; bp--; } - if (sel!=2) { + if (sel != 2) { select_bpoint(bp, DESELECT, 1, VISIBLE); - lastsel= 1; + lastsel = 1; } - else lastsel= 0; + else lastsel = 0; } - else lastsel= 0; + else lastsel = 0; bp++; } @@ -5385,7 +5371,7 @@ static int select_less_exec(bContext *C, wmOperator *UNUSED(op)) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5402,7 +5388,7 @@ void CURVE_OT_select_less(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** select random *********************/ @@ -5416,10 +5402,10 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) BLI_srand(BLI_rand()); /* random seed */ - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; while (a--) { if (BLI_frand() < randfac) select_beztriple(bezt, SELECT, 1, VISIBLE); @@ -5427,8 +5413,8 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { if (BLI_frand() < randfac) @@ -5441,15 +5427,15 @@ static void selectrandom_curve(ListBase *editnurb, float randfac) static int select_random_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); if (!RNA_boolean_get(op->ptr, "extend")) CU_deselect_all(obedit); - selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent")/100.0f); + selectrandom_curve(editnurb, RNA_float_get(op->ptr, "percent") / 100.0f); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5466,7 +5452,7 @@ void CURVE_OT_select_random(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f, "Percent", "Percentage of elements to select randomly", 0.f, 100.0f); @@ -5478,19 +5464,19 @@ void CURVE_OT_select_random(wmOperatorType *ot) static int point_on_nurb(Nurb *nu, void *point) { if (nu->bezt) { - BezTriple *bezt= (BezTriple*)point; - return bezt >= nu->bezt && bezt < nu->bezt + nu->pntsu; + BezTriple *bezt = (BezTriple *)point; + return bezt >= nu->bezt && bezt < &nu->bezt[nu->pntsu]; } else { - BPoint *bp= (BPoint*)point; - return bp >= nu->bp && bp < nu->bp + nu->pntsu * nu->pntsv; + BPoint *bp = (BPoint *)point; + return bp >= nu->bp && bp < &nu->bp[nu->pntsu * nu->pntsv]; } } static Nurb *get_lastsel_nurb(Curve *cu) { - ListBase *nubase= BKE_curve_editNurbs_get(cu); - Nurb *nu= nubase->first; + ListBase *nubase = BKE_curve_editNurbs_get(cu); + Nurb *nu = nubase->first; if (!cu->lastsel) return NULL; @@ -5499,7 +5485,7 @@ static Nurb *get_lastsel_nurb(Curve *cu) if (point_on_nurb(nu, cu->lastsel)) return nu; - nu= nu->next; + nu = nu->next; } return NULL; @@ -5509,9 +5495,9 @@ static void select_nth_bezt(Nurb *nu, BezTriple *bezt, int nth) { int a, start; - start= bezt - nu->bezt; - a= nu->pntsu; - bezt= nu->bezt + a - 1; + start = bezt - nu->bezt; + a = nu->pntsu; + bezt = &nu->bezt[a - 1]; while (a--) { if (abs(start - a) % nth) { @@ -5527,23 +5513,23 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth) int a, startrow, startpnt; int dist, row, pnt; - startrow= (bp - nu->bp) / nu->pntsu; - startpnt= (bp - nu->bp) % nu->pntsu; + startrow = (bp - nu->bp) / nu->pntsu; + startpnt = (bp - nu->bp) % nu->pntsu; - a= nu->pntsu * nu->pntsv; - bp= nu->bp + a - 1; + a = nu->pntsu * nu->pntsv; + bp = &nu->bp[a - 1]; row = nu->pntsv - 1; pnt = nu->pntsu - 1; while (a--) { - dist= abs(pnt - startpnt) + abs(row - startrow); + dist = abs(pnt - startpnt) + abs(row - startrow); if (dist % nth) { select_bpoint(bp, DESELECT, 1, HIDDEN); } pnt--; if (pnt < 0) { - pnt= nu->pntsu - 1; + pnt = nu->pntsu - 1; row--; } @@ -5553,10 +5539,10 @@ static void select_nth_bp(Nurb *nu, BPoint *bp, int nth) int CU_select_nth(Object *obedit, int nth) { - Curve *cu= (Curve*)obedit->data; + Curve *cu = (Curve *)obedit->data; Nurb *nu; - nu= get_lastsel_nurb(cu); + nu = get_lastsel_nurb(cu); if (!nu) return 0; @@ -5572,8 +5558,8 @@ int CU_select_nth(Object *obedit, int nth) static int select_nth_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - int nth= RNA_int_get(op->ptr, "nth"); + Object *obedit = CTX_data_edit_object(C); + int nth = RNA_int_get(op->ptr, "nth"); if (!CU_select_nth(obedit, nth)) { if (obedit->type == OB_SURF) { @@ -5586,7 +5572,7 @@ static int select_nth_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5603,7 +5589,7 @@ void CURVE_OT_select_nth(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "nth", 2, 2, 100, "Nth Selection", "", 1, INT_MAX); } @@ -5612,10 +5598,10 @@ void CURVE_OT_select_nth(wmOperatorType *ot) static int duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); adduplicateflagNurb(obedit, 1); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data); return OPERATOR_FINISHED; } @@ -5632,25 +5618,25 @@ void CURVE_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** delete operator *********************/ static int delete_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditNurb *editnurb= cu->editnurb; - ListBase *nubase= &editnurb->nurbs; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditNurb *editnurb = cu->editnurb; + ListBase *nubase = &editnurb->nurbs; Nurb *nu, *nu1; BezTriple *bezt, *bezt1, *bezt2; BPoint *bp, *bp1, *bp2; - int a, cut= 0, type= RNA_enum_get(op->ptr, "type"); - int nuindex= 0; + int a, cut = 0, type = RNA_enum_get(op->ptr, "type"); + int nuindex = 0; - if (obedit->type==OB_SURF) { - if (type==0) { + if (obedit->type == OB_SURF) { + if (type == 0) { deleteflagNurb(C, op, 1); } else { @@ -5658,58 +5644,58 @@ static int delete_exec(bContext *C, wmOperator *op) BKE_nurbList_free(nubase); if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; } - if (type==0) { + if (type == 0) { /* first loop, can we remove entire pieces? */ Nurb *next; - nu= nubase->first; + nu = nubase->first; while (nu) { - next= nu->next; + next = nu->next; if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - a= nu->pntsu; + bezt = nu->bezt; + a = nu->pntsu; if (a) { while (a) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ); + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) ; else break; a--; bezt++; } - if (a==0) { + if (a == 0) { if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); keyIndex_delNurb(editnurb, nu); - BKE_nurb_free(nu); nu= NULL; + BKE_nurb_free(nu); nu = NULL; } } } else { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; if (a) { while (a) { - if (bp->f1 & SELECT); + if (bp->f1 & SELECT) ; else break; a--; bp++; } - if (a==0) { + if (a == 0) { if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); keyIndex_delNurb(editnurb, nu); - BKE_nurb_free(nu); nu= NULL; + BKE_nurb_free(nu); nu = NULL; } } } @@ -5717,55 +5703,54 @@ static int delete_exec(bContext *C, wmOperator *op) /* Never allow the order to exceed the number of points * - note, this is ok but changes unselected nurbs, disable for now */ #if 0 - if ((nu!= NULL) && (nu->type == CU_NURBS)) { + if ((nu != NULL) && (nu->type == CU_NURBS)) { clamp_nurb_order_u(nu); } #endif - nu= next; + nu = next; nuindex++; } /* 2nd loop, delete small pieces: just for curves */ - nu= nubase->first; + nu = nubase->first; while (nu) { - next= nu->next; - type= 0; + next = nu->next; + type = 0; if (nu->type == CU_BEZIER) { - int delta= 0; - bezt= nu->bezt; - for (a=0;apntsu;a++) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { - memmove(bezt, bezt+1, (nu->pntsu-a-1)*sizeof(BezTriple)); + int delta = 0; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu; a++) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + memmove(bezt, bezt + 1, (nu->pntsu - a - 1) * sizeof(BezTriple)); keyIndex_delBezt(editnurb, bezt + delta); - keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu-a-1); + keyIndex_updateBezt(editnurb, bezt + 1, bezt, nu->pntsu - a - 1); nu->pntsu--; a--; - type= 1; + type = 1; delta++; } else bezt++; } if (type) { - bezt1 = - (BezTriple*)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); - memcpy(bezt1, nu->bezt, (nu->pntsu)*sizeof(BezTriple)); + bezt1 = (BezTriple *)MEM_mallocN((nu->pntsu) * sizeof(BezTriple), "delNurb"); + memcpy(bezt1, nu->bezt, (nu->pntsu) * sizeof(BezTriple)); keyIndex_updateBezt(editnurb, nu->bezt, bezt1, nu->pntsu); MEM_freeN(nu->bezt); - nu->bezt= bezt1; + nu->bezt = bezt1; BKE_nurb_handles_calc(nu); } } - else if (nu->pntsv==1) { - int delta= 0; - bp= nu->bp; - - for (a=0;apntsu;a++) { - if ( bp->f1 & SELECT ) { - memmove(bp, bp+1, (nu->pntsu-a-1)*sizeof(BPoint)); + else if (nu->pntsv == 1) { + int delta = 0; + bp = nu->bp; + + for (a = 0; a < nu->pntsu; a++) { + if (bp->f1 & SELECT) { + memmove(bp, bp + 1, (nu->pntsu - a - 1) * sizeof(BPoint)); keyIndex_delBP(editnurb, bp + delta); - keyIndex_updateBP(editnurb, bp+1, bp, nu->pntsu-a-1); + keyIndex_updateBP(editnurb, bp + 1, bp, nu->pntsu - a - 1); nu->pntsu--; a--; - type= 1; + type = 1; delta++; } else { @@ -5773,11 +5758,11 @@ static int delete_exec(bContext *C, wmOperator *op) } } if (type) { - bp1 = (BPoint*)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); - memcpy(bp1, nu->bp, (nu->pntsu)*sizeof(BPoint)); + bp1 = (BPoint *)MEM_mallocN(nu->pntsu * sizeof(BPoint), "delNurb2"); + memcpy(bp1, nu->bp, (nu->pntsu) * sizeof(BPoint)); keyIndex_updateBP(editnurb, nu->bp, bp1, nu->pntsu); MEM_freeN(nu->bp); - nu->bp= bp1; + nu->bp = bp1; /* Never allow the order to exceed the number of points * - note, this is ok but changes unselected nurbs, disable for now */ @@ -5790,68 +5775,68 @@ static int delete_exec(bContext *C, wmOperator *op) BKE_nurb_order_clamp_u(nu); BKE_nurb_knot_calc_u(nu); } - nu= next; + nu = next; } } - else if (type==1) { /* erase segment */ + else if (type == 1) { /* erase segment */ /* find the 2 selected points */ - bezt1= bezt2= NULL; - bp1= bp2= NULL; - nu1= NULL; - nuindex= 0; - for (nu= nubase->first; nu; nu= nu->next) { + bezt1 = bezt2 = NULL; + bp1 = bp2 = NULL; + nu1 = NULL; + nuindex = 0; + for (nu = nubase->first; nu; nu = nu->next) { if (nu->type == CU_BEZIER) { - bezt= nu->bezt; - for (a=0; apntsu-1; a++) { - if ( BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { - bezt1= bezt; - bezt2= bezt+1; + bezt = nu->bezt; + for (a = 0; a < nu->pntsu - 1; a++) { + if (BEZSELECTED_HIDDENHANDLES(cu, bezt) ) { + bezt1 = bezt; + bezt2 = bezt + 1; if ((bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT)) { /* pass */ } - else { /* maybe do not make cyclic */ - if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { - bezt2= bezt+(nu->pntsu-1); + else { /* maybe do not make cyclic */ + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) ) { + bezt2 = bezt + (nu->pntsu - 1); if ( (bezt2->f1 & SELECT) || (bezt2->f2 & SELECT) || (bezt2->f3 & SELECT) ) { nu->flagu &= ~CU_NURB_CYCLIC; BKE_nurb_handles_calc(nu); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); } } return OPERATOR_FINISHED; } - cut= a; - nu1= nu; + cut = a; + nu1 = nu; break; } bezt++; } } - else if (nu->pntsv==1) { - bp= nu->bp; - for (a=0; apntsu-1; a++) { - if ( bp->f1 & SELECT ) { - bp1= bp; - bp2= bp+1; - if (bp2->f1 & 1) { + else if (nu->pntsv == 1) { + bp = nu->bp; + for (a = 0; a < nu->pntsu - 1; a++) { + if (bp->f1 & SELECT) { + bp1 = bp; + bp2 = bp + 1; + if (bp2->f1 & SELECT) { /* pass */ } - else { /* maybe do not make cyclic */ - if (a==0 && (nu->flagu & CU_NURB_CYCLIC) ) { - bp2= bp+(nu->pntsu-1); - if ( bp2->f1 & SELECT ) { + else { /* maybe do not make cyclic */ + if (a == 0 && (nu->flagu & CU_NURB_CYCLIC) ) { + bp2 = bp + (nu->pntsu - 1); + if (bp2->f1 & SELECT) { nu->flagu &= ~CU_NURB_CYCLIC; - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); } } return OPERATOR_FINISHED; } - cut= a; - nu1= nu; + cut = a; + nu1 = nu; break; } bp++; @@ -5862,45 +5847,41 @@ static int delete_exec(bContext *C, wmOperator *op) } if (nu1) { if (bezt1) { - if (nu1->pntsu==2) { /* remove completely */ + if (nu1->pntsu == 2) { /* remove completely */ if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); BKE_nurb_free(nu); nu = NULL; } - else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ - bezt = - (BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb1"); - ED_curve_beztcpy(editnurb, bezt, nu1->bezt, cut+1); - a= nu1->pntsu-cut-1; + else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ + bezt = (BezTriple *)MEM_mallocN((cut + 1) * sizeof(BezTriple), "delNurb1"); + ED_curve_beztcpy(editnurb, bezt, nu1->bezt, cut + 1); + a = nu1->pntsu - cut - 1; ED_curve_beztcpy(editnurb, nu1->bezt, bezt2, a); - ED_curve_beztcpy(editnurb, nu1->bezt+a, bezt, cut+1); + ED_curve_beztcpy(editnurb, &nu1->bezt[a], bezt, cut + 1); nu1->flagu &= ~CU_NURB_CYCLIC; MEM_freeN(bezt); BKE_nurb_handles_calc(nu); } - else { /* add new curve */ + else { /* add new curve */ /* seems to be an error here... but where? (a can become zero) */ - nu = - (Nurb*)MEM_mallocN(sizeof(Nurb), "delNurb2"); + nu = (Nurb *)MEM_mallocN(sizeof(Nurb), "delNurb2"); memcpy(nu, nu1, sizeof(Nurb)); BLI_addtail(nubase, nu); - nu->bezt = - (BezTriple*)MEM_mallocN((cut+1) * sizeof(BezTriple), "delNurb3"); - ED_curve_beztcpy(editnurb, nu->bezt, nu1->bezt, cut+1); - a= nu1->pntsu-cut-1; - - bezt = - (BezTriple*)MEM_mallocN(a * sizeof(BezTriple), "delNurb4"); - ED_curve_beztcpy(editnurb, bezt, nu1->bezt+cut+1, a); + nu->bezt = (BezTriple *)MEM_mallocN((cut + 1) * sizeof(BezTriple), "delNurb3"); + ED_curve_beztcpy(editnurb, nu->bezt, nu1->bezt, cut + 1); + a = nu1->pntsu - cut - 1; + + bezt = (BezTriple *)MEM_mallocN(a * sizeof(BezTriple), "delNurb4"); + ED_curve_beztcpy(editnurb, bezt, &nu1->bezt[cut + 1], a); MEM_freeN(nu1->bezt); - nu1->bezt= bezt; - nu1->pntsu= a; - nu->pntsu= cut+1; + nu1->bezt = bezt; + nu1->pntsu = a; + nu->pntsu = cut + 1; BKE_nurb_handles_calc(nu); @@ -5908,40 +5889,37 @@ static int delete_exec(bContext *C, wmOperator *op) } } else if (bp1) { - if (nu1->pntsu==2) { /* remove completely */ + if (nu1->pntsu == 2) { /* remove completely */ if (cu->actnu == nuindex) - cu->actnu= -1; + cu->actnu = -1; BLI_remlink(nubase, nu); - BKE_nurb_free(nu); nu= NULL; + BKE_nurb_free(nu); nu = NULL; } - else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ - bp = - (BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb5"); - ED_curve_bpcpy(editnurb, bp, nu1->bp, cut+1); - a= nu1->pntsu-cut-1; + else if (nu1->flagu & CU_NURB_CYCLIC) { /* cyclic */ + bp = (BPoint *)MEM_mallocN((cut + 1) * sizeof(BPoint), "delNurb5"); + ED_curve_bpcpy(editnurb, bp, nu1->bp, cut + 1); + a = nu1->pntsu - cut - 1; ED_curve_bpcpy(editnurb, nu1->bp, bp2, a); - ED_curve_bpcpy(editnurb, nu1->bp+a, bp, cut+1); + ED_curve_bpcpy(editnurb, &nu1->bp[a], bp, cut + 1); nu1->flagu &= ~CU_NURB_CYCLIC; MEM_freeN(bp); } - else { /* add new curve */ - nu = (Nurb*)MEM_mallocN(sizeof(Nurb), "delNurb6"); + else { /* add new curve */ + nu = (Nurb *)MEM_mallocN(sizeof(Nurb), "delNurb6"); memcpy(nu, nu1, sizeof(Nurb)); BLI_addtail(nubase, nu); - nu->bp = - (BPoint*)MEM_mallocN((cut+1) * sizeof(BPoint), "delNurb7"); - ED_curve_bpcpy(editnurb, nu->bp, nu1->bp, cut+1); - a= nu1->pntsu-cut-1; - bp = - (BPoint*)MEM_mallocN(a * sizeof(BPoint), "delNurb8"); - ED_curve_bpcpy(editnurb, bp, nu1->bp+cut+1, a); + nu->bp = (BPoint *)MEM_mallocN((cut + 1) * sizeof(BPoint), "delNurb7"); + ED_curve_bpcpy(editnurb, nu->bp, nu1->bp, cut + 1); + a = nu1->pntsu - cut - 1; + bp = (BPoint *)MEM_mallocN(a * sizeof(BPoint), "delNurb8"); + ED_curve_bpcpy(editnurb, bp, &nu1->bp[cut + 1], a); MEM_freeN(nu1->bp); - nu1->bp= bp; - nu1->pntsu= a; - nu1->knotsu= NULL; - nu->pntsu= cut+1; + nu1->bp = bp; + nu1->pntsu = a; + nu1->knotsu = NULL; + nu->pntsu = cut + 1; BKE_nurb_order_clamp_u(nu); BKE_nurb_knot_calc_u(nu); @@ -5952,16 +5930,16 @@ static int delete_exec(bContext *C, wmOperator *op) } } } - else if (type==2) { - cu->actnu= -1; + else if (type == 2) { + cu->actnu = -1; keyIndex_delNurbList(editnurb, nubase); BKE_nurbList_free(nubase); } if (ED_curve_updateAnimPaths(obedit->data)) - WM_event_add_notifier(C, NC_OBJECT|ND_KEYS, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -5969,20 +5947,20 @@ static int delete_exec(bContext *C, wmOperator *op) static int delete_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); uiPopupMenu *pup; uiLayout *layout; - if (obedit->type==OB_SURF) { - pup= uiPupMenuBegin(C, "Delete", ICON_NONE); - layout= uiPupMenuLayout(pup); + if (obedit->type == OB_SURF) { + pup = uiPupMenuBegin(C, "Delete", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 0); uiItemEnumO_ptr(layout, op->type, NULL, 0, "type", 2); uiPupMenuEnd(C, pup); } else { - pup= uiPupMenuBegin(C, "Delete", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Delete", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsEnumO(layout, op->type->idname, "type"); uiPupMenuEnd(C, pup); } @@ -6009,7 +5987,7 @@ void CURVE_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Which elements to delete"); @@ -6019,22 +5997,22 @@ void CURVE_OT_delete(wmOperatorType *ot) static int shade_smooth_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - int clear= (strcmp(op->idname, "CURVE_OT_shade_flat") == 0); + int clear = (strcmp(op->idname, "CURVE_OT_shade_flat") == 0); if (obedit->type != OB_CURVE) return OPERATOR_CANCELLED; - for (nu= editnurb->first; nu; nu= nu->next) { + for (nu = editnurb->first; nu; nu = nu->next) { if (isNurbsel(nu)) { if (!clear) nu->flag |= CU_SMOOTH; else nu->flag &= ~CU_SMOOTH; } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -6052,7 +6030,7 @@ void CURVE_OT_shade_smooth(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void CURVE_OT_shade_flat(wmOperatorType *ot) @@ -6067,16 +6045,16 @@ void CURVE_OT_shade_flat(wmOperatorType *ot) ot->poll = ED_operator_editsurfcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************** join operator, to be used externally? ****************/ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); Curve *cu; Nurb *nu, *newnu; BezTriple *bezt; @@ -6085,33 +6063,33 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) float imat[4][4], cmat[4][4]; int a; - tempbase.first= tempbase.last= NULL; + tempbase.first = tempbase.last = NULL; /* trasnform all selected curves inverse in obact */ invert_m4_m4(imat, ob->obmat); - CTX_DATA_BEGIN (C, Base*, base, selected_editable_bases) + CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - if (base->object->type==ob->type) { + if (base->object->type == ob->type) { if (base->object != ob) { - cu= base->object->data; + cu = base->object->data; if (cu->nurb.first) { /* watch it: switch order here really goes wrong */ mult_m4_m4m4(cmat, imat, base->object->obmat); - nu= cu->nurb.first; + nu = cu->nurb.first; while (nu) { - newnu= BKE_nurb_duplicate(nu); + newnu = BKE_nurb_duplicate(nu); if (ob->totcol) { /* TODO, merge material lists */ - CLAMP(newnu->mat_nr, 0, ob->totcol-1); + CLAMP(newnu->mat_nr, 0, ob->totcol - 1); } - else newnu->mat_nr= 0; + else newnu->mat_nr = 0; BLI_addtail(&tempbase, newnu); - if ( (bezt= newnu->bezt) ) { - a= newnu->pntsu; + if ( (bezt = newnu->bezt) ) { + a = newnu->pntsu; while (a--) { mul_m4_v3(cmat, bezt->vec[0]); mul_m4_v3(cmat, bezt->vec[1]); @@ -6120,14 +6098,14 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) } BKE_nurb_handles_calc(newnu); } - if ( (bp= newnu->bp) ) { - a= newnu->pntsu*nu->pntsv; + if ( (bp = newnu->bp) ) { + a = newnu->pntsu * nu->pntsv; while (a--) { mul_m4_v3(cmat, bp->vec); bp++; } } - nu= nu->next; + nu = nu->next; } } @@ -6137,15 +6115,15 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - cu= ob->data; + cu = ob->data; BLI_movelisttolist(&cu->nurb, &tempbase); - DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! + DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! ED_object_enter_editmode(C, EM_WAITCURSOR); - ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); return OPERATOR_FINISHED; } @@ -6154,9 +6132,9 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) static const char *get_curve_defname(int type) { - int stype= type & CU_PRIMITIVE; + int stype = type & CU_PRIMITIVE; - if ((type & CU_TYPE)==CU_BEZIER) { + if ((type & CU_TYPE) == CU_BEZIER) { switch (stype) { case CU_PRIM_CURVE: return "BezierCurve"; case CU_PRIM_CIRCLE: return "BezierCircle"; @@ -6178,7 +6156,7 @@ static const char *get_curve_defname(int type) static const char *get_surf_defname(int type) { - int stype= type & CU_PRIMITIVE; + int stype = type & CU_PRIMITIVE; switch (stype) { case CU_PRIM_CURVE: return "SurfCurve"; @@ -6194,22 +6172,22 @@ static const char *get_surf_defname(int type) Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) { - static int xzproj= 0; /* this function calls itself... */ - Object *obedit= CTX_data_edit_object(C); - ListBase *editnurb= object_editcurve_get(obedit); - View3D *v3d= CTX_wm_view3d(C); - RegionView3D *rv3d= ED_view3d_context_rv3d(C); + static int xzproj = 0; /* this function calls itself... */ + Object *obedit = CTX_data_edit_object(C); + ListBase *editnurb = object_editcurve_get(obedit); + View3D *v3d = CTX_wm_view3d(C); + RegionView3D *rv3d = ED_view3d_context_rv3d(C); Nurb *nu = NULL; BezTriple *bezt; BPoint *bp; - Curve *cu= (Curve*)obedit->data; - float vec[3], zvec[3]= {0.0f, 0.0f, 1.0f}; - float umat[4][4]= MAT4_UNITY, viewmat[4][4]= MAT4_UNITY; + Curve *cu = (Curve *)obedit->data; + float vec[3], zvec[3] = {0.0f, 0.0f, 1.0f}; + float umat[4][4] = MAT4_UNITY, viewmat[4][4] = MAT4_UNITY; float fac; int a, b; - const float grid= v3d ? v3d->grid : 1.0f; - const int cutype= (type & CU_TYPE); // poly, bezier, nurbs, etc - const int stype= (type & CU_PRIMITIVE); + const float grid = v3d ? v3d->grid : 1.0f; + const int cutype = (type & CU_TYPE); // poly, bezier, nurbs, etc + const int stype = (type & CU_PRIMITIVE); const int force_3d = ((Curve *)obedit->data)->flag & CU_3D; /* could be adding to an existing 3D curve */ if (rv3d) { @@ -6220,328 +6198,325 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) setflagsNurb(editnurb, 0); /* these types call this function to return a Nurb */ - if (stype!=CU_PRIM_TUBE && stype!=CU_PRIM_DONUT) { - nu = (Nurb*)MEM_callocN(sizeof(Nurb), "addNurbprim"); - nu->type= cutype; - nu->resolu= cu->resolu; - nu->resolv= cu->resolv; + if (stype != CU_PRIM_TUBE && stype != CU_PRIM_DONUT) { + nu = (Nurb *)MEM_callocN(sizeof(Nurb), "addNurbprim"); + nu->type = cutype; + nu->resolu = cu->resolu; + nu->resolv = cu->resolv; } switch (stype) { - case CU_PRIM_CURVE: /* curve */ - nu->resolu= cu->resolu; - if (cutype==CU_BEZIER) { - if (!force_3d) nu->flag |= CU_2D; - nu->pntsu= 2; - nu->bezt = - (BezTriple*)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1"); - bezt= nu->bezt; - bezt->h1= bezt->h2= HD_ALIGN; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->radius = 1.0; + case CU_PRIM_CURVE: /* curve */ + nu->resolu = cu->resolu; + if (cutype == CU_BEZIER) { + if (!force_3d) nu->flag |= CU_2D; + nu->pntsu = 2; + nu->bezt = (BezTriple *)MEM_callocN(2 * sizeof(BezTriple), "addNurbprim1"); + bezt = nu->bezt; + bezt->h1 = bezt->h2 = HD_ALIGN; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->radius = 1.0; - bezt->vec[1][0]+= -grid; - bezt->vec[0][0]+= -1.5f*grid; - bezt->vec[0][1]+= -0.5f*grid; - bezt->vec[2][0]+= -0.5f*grid; - bezt->vec[2][1]+= 0.5f*grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->vec[1][0] += -grid; + bezt->vec[0][0] += -1.5f * grid; + bezt->vec[0][1] += -0.5f * grid; + bezt->vec[2][0] += -0.5f * grid; + bezt->vec[2][1] += 0.5f * grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); - bezt++; - bezt->h1= bezt->h2= HD_ALIGN; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->radius = bezt->weight = 1.0; + bezt++; + bezt->h1 = bezt->h2 = HD_ALIGN; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->radius = bezt->weight = 1.0; - bezt->vec[0][0] = 0; - bezt->vec[0][1] = 0; - bezt->vec[1][0] = grid; - bezt->vec[1][1] = 0; - bezt->vec[2][0] = grid*2; - bezt->vec[2][1] = 0; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->vec[0][0] = 0; + bezt->vec[0][1] = 0; + bezt->vec[1][0] = grid; + bezt->vec[1][1] = 0; + bezt->vec[2][0] = grid * 2; + bezt->vec[2][1] = 0; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); - BKE_nurb_handles_calc(nu); - } - else { + BKE_nurb_handles_calc(nu); + } + else { + + nu->pntsu = 4; + nu->pntsv = 1; + nu->orderu = 4; + nu->bp = callocstructN(BPoint, 4, "addNurbprim3"); + + bp = nu->bp; + for (a = 0; a < 4; a++, bp++) { + bp->vec[3] = 1.0; + bp->f1 = SELECT; + bp->radius = bp->weight = 1.0; + } + + bp = nu->bp; + bp->vec[0] += -1.5f * grid; + bp++; + bp->vec[0] += -grid; + bp->vec[1] += grid; + bp++; + bp->vec[0] += grid; + bp->vec[1] += grid; + bp++; + bp->vec[0] += 1.5f * grid; + + bp = nu->bp; + for (a = 0; a < 4; a++, bp++) mul_m4_v3(mat, bp->vec); + + if (cutype == CU_NURBS) { + nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */ + BKE_nurb_knot_calc_u(nu); + } - nu->pntsu= 4; - nu->pntsv= 1; - nu->orderu= 4; - nu->bp= callocstructN(BPoint, 4, "addNurbprim3"); + } + break; + case CU_PRIM_PATH: /* 5 point path */ + nu->pntsu = 5; + nu->pntsv = 1; + nu->orderu = 5; + nu->flagu = CU_NURB_ENDPOINT; /* endpoint */ + nu->resolu = cu->resolu; + nu->bp = callocstructN(BPoint, 5, "addNurbprim3"); - bp= nu->bp; - for (a=0;a<4;a++, bp++) { - bp->vec[3]= 1.0; - bp->f1= SELECT; + bp = nu->bp; + for (a = 0; a < 5; a++, bp++) { + bp->vec[3] = 1.0; + bp->f1 = SELECT; bp->radius = bp->weight = 1.0; } - bp= nu->bp; - bp->vec[0]+= -1.5f*grid; + bp = nu->bp; + bp->vec[0] += -2.0f * grid; bp++; - bp->vec[0]+= -grid; - bp->vec[1]+= grid; + bp->vec[0] += -grid; + bp++; bp++; + bp->vec[0] += grid; bp++; - bp->vec[0]+= grid; - bp->vec[1]+= grid; - bp++; - bp->vec[0]+= 1.5f*grid; + bp->vec[0] += 2.0f * grid; - bp= nu->bp; - for (a=0;a<4;a++, bp++) mul_m4_v3(mat, bp->vec); + bp = nu->bp; + for (a = 0; a < 5; a++, bp++) mul_m4_v3(mat, bp->vec); - if (cutype==CU_NURBS) { - nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */ + if (cutype == CU_NURBS) { + nu->knotsu = NULL; /* nurbs_knot_calc_u allocates */ BKE_nurb_knot_calc_u(nu); } - } - break; - case CU_PRIM_PATH: /* 5 point path */ - nu->pntsu= 5; - nu->pntsv= 1; - nu->orderu= 5; - nu->flagu= CU_NURB_ENDPOINT; /* endpoint */ - nu->resolu= cu->resolu; - nu->bp= callocstructN(BPoint, 5, "addNurbprim3"); - - bp= nu->bp; - for (a=0;a<5;a++, bp++) { - bp->vec[3]= 1.0; - bp->f1= SELECT; - bp->radius = bp->weight = 1.0; - } - - bp= nu->bp; - bp->vec[0]+= -2.0f*grid; - bp++; - bp->vec[0]+= -grid; - bp++; bp++; - bp->vec[0]+= grid; - bp++; - bp->vec[0]+= 2.0f*grid; - - bp= nu->bp; - for (a=0;a<5;a++, bp++) mul_m4_v3(mat, bp->vec); - - if (cutype==CU_NURBS) { - nu->knotsu= NULL; /* nurbs_knot_calc_u allocates */ - BKE_nurb_knot_calc_u(nu); - } - - break; - case CU_PRIM_CIRCLE: /* circle */ - nu->resolu= cu->resolu; - - if (cutype==CU_BEZIER) { - if (!force_3d) nu->flag |= CU_2D; - nu->pntsu= 4; - nu->bezt= callocstructN(BezTriple, 4, "addNurbprim1"); - nu->flagu= CU_NURB_CYCLIC; - bezt= nu->bezt; - - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][0]+= -grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + break; + case CU_PRIM_CIRCLE: /* circle */ + nu->resolu = cu->resolu; - bezt++; - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][1]+= grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + if (cutype == CU_BEZIER) { + if (!force_3d) nu->flag |= CU_2D; + nu->pntsu = 4; + nu->bezt = callocstructN(BezTriple, 4, "addNurbprim1"); + nu->flagu = CU_NURB_CYCLIC; + bezt = nu->bezt; - bezt++; - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][0]+= grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][0] += -grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - bezt++; - bezt->h1= bezt->h2= HD_AUTO; - bezt->f1= bezt->f2= bezt->f3= SELECT; - bezt->vec[1][1]+= -grid; - for (a=0;a<3;a++) mul_m4_v3(mat, bezt->vec[a]); - bezt->radius = bezt->weight = 1.0; + bezt++; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][1] += grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - BKE_nurb_handles_calc(nu); - } - else if ( cutype==CU_NURBS ) { /* nurb */ - nu->pntsu= 8; - nu->pntsv= 1; - nu->orderu= 4; - nu->bp= callocstructN(BPoint, 8, "addNurbprim6"); - nu->flagu= CU_NURB_CYCLIC; - bp= nu->bp; + bezt++; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][0] += grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; - for (a=0; a<8; a++) { - bp->f1= SELECT; - if (xzproj==0) { - bp->vec[0]+= nurbcircle[a][0]*grid; - bp->vec[1]+= nurbcircle[a][1]*grid; + bezt++; + bezt->h1 = bezt->h2 = HD_AUTO; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; + bezt->vec[1][1] += -grid; + for (a = 0; a < 3; a++) mul_m4_v3(mat, bezt->vec[a]); + bezt->radius = bezt->weight = 1.0; + + BKE_nurb_handles_calc(nu); + } + else if (cutype == CU_NURBS) { /* nurb */ + nu->pntsu = 8; + nu->pntsv = 1; + nu->orderu = 4; + nu->bp = callocstructN(BPoint, 8, "addNurbprim6"); + nu->flagu = CU_NURB_CYCLIC; + bp = nu->bp; + + for (a = 0; a < 8; a++) { + bp->f1 = SELECT; + if (xzproj == 0) { + bp->vec[0] += nurbcircle[a][0] * grid; + bp->vec[1] += nurbcircle[a][1] * grid; + } + else { + bp->vec[0] += 0.25f * nurbcircle[a][0] * grid - 0.75f * grid; + bp->vec[2] += 0.25f * nurbcircle[a][1] * grid; + } + if (a & 1) bp->vec[3] = 0.25 * M_SQRT2; + else bp->vec[3] = 1.0; + mul_m4_v3(mat, bp->vec); + bp->radius = bp->weight = 1.0; + + bp++; + } + + BKE_nurb_knot_calc_u(nu); + } + break; + case CU_PRIM_PATCH: /* 4x4 patch */ + if (cutype == CU_NURBS) { /* nurb */ + + nu->pntsu = 4; + nu->pntsv = 4; + nu->orderu = 4; + nu->orderv = 4; + nu->flag = CU_SMOOTH; + nu->bp = callocstructN(BPoint, 4 * 4, "addNurbprim6"); + nu->flagu = 0; + nu->flagv = 0; + bp = nu->bp; + + for (a = 0; a < 4; a++) { + for (b = 0; b < 4; b++) { + bp->f1 = SELECT; + fac = (float)a - 1.5f; + bp->vec[0] += fac * grid; + fac = (float)b - 1.5f; + bp->vec[1] += fac * grid; + if (a == 1 || a == 2) if (b == 1 || b == 2) { + bp->vec[2] += grid; + } + mul_m4_v3(mat, bp->vec); + bp->vec[3] = 1.0; + bp++; + } + } + + BKE_nurb_knot_calc_u(nu); + BKE_nurb_knot_calc_v(nu); + } + break; + case CU_PRIM_TUBE: /* Cylinder */ + if (cutype == CU_NURBS) { + nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ + nu->resolu = cu->resolu; + nu->flag = CU_SMOOTH; + BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ + vec[0] = vec[1] = 0.0; + vec[2] = -grid; + + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { + /* pass */ } else { - bp->vec[0]+= 0.25f*nurbcircle[a][0]*grid-0.75f*grid; - bp->vec[2]+= 0.25f*nurbcircle[a][1]*grid; + mul_mat3_m4_v3(mat, vec); } - if (a & 1) bp->vec[3]= 0.25*M_SQRT2; - else bp->vec[3]= 1.0; - mul_m4_v3(mat, bp->vec); - bp->radius = bp->weight = 1.0; - - bp++; - } - BKE_nurb_knot_calc_u(nu); - } - break; - case CU_PRIM_PATCH: /* 4x4 patch */ - if ( cutype==CU_NURBS ) { /* nurb */ + translateflagNurb(editnurb, 1, vec); + extrudeflagNurb(cu->editnurb, 1); + mul_v3_fl(vec, -2.0f); + translateflagNurb(editnurb, 1, vec); - nu->pntsu= 4; - nu->pntsv= 4; - nu->orderu= 4; - nu->orderv= 4; - nu->flag= CU_SMOOTH; - nu->bp= callocstructN(BPoint, 4*4, "addNurbprim6"); - nu->flagu= 0; - nu->flagv= 0; - bp= nu->bp; + BLI_remlink(editnurb, nu); - for (a=0; a<4; a++) { - for (b=0; b<4; b++) { - bp->f1= SELECT; - fac= (float)a -1.5f; - bp->vec[0]+= fac*grid; - fac= (float)b -1.5f; - bp->vec[1]+= fac*grid; - if (a==1 || a==2) if (b==1 || b==2) { - bp->vec[2]+= grid; - } - mul_m4_v3(mat, bp->vec); - bp->vec[3]= 1.0; + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a-- > 0) { + bp->f1 |= SELECT; bp++; } } + break; + case CU_PRIM_SPHERE: /* sphere */ + if (cutype == CU_NURBS) { + float tmp_cent[3] = {0.f, 0.f, 0.f}; + float tmp_vec[3] = {0.f, 0.f, 1.f}; - BKE_nurb_knot_calc_u(nu); - BKE_nurb_knot_calc_v(nu); - } - break; - case CU_PRIM_TUBE: /* Cylinder */ - if ( cutype==CU_NURBS ) { - nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ - nu->resolu= cu->resolu; - nu->flag= CU_SMOOTH; - BLI_addtail(editnurb, nu); /* temporal for extrude and translate */ - vec[0]=vec[1]= 0.0; - vec[2]= -grid; - - if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) { - /* pass */ + nu->pntsu = 5; + nu->pntsv = 1; + nu->orderu = 3; + nu->resolu = cu->resolu; + nu->resolv = cu->resolv; + nu->flag = CU_SMOOTH; + nu->bp = callocstructN(BPoint, 5, "addNurbprim6"); + nu->flagu = 0; + bp = nu->bp; + + for (a = 0; a < 5; a++) { + bp->f1 = SELECT; + bp->vec[0] += nurbcircle[a][0] * grid; + bp->vec[2] += nurbcircle[a][1] * grid; + if (a & 1) bp->vec[3] = 0.5 * M_SQRT2; + else bp->vec[3] = 1.0; + mul_m4_v3(mat, bp->vec); + bp++; + } + nu->flagu = CU_NURB_BEZIER; + BKE_nurb_knot_calc_u(nu); + + BLI_addtail(editnurb, nu); /* temporal for spin */ + + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); + else spin_nurb(umat, obedit, tmp_vec, mat[3]); + + BKE_nurb_knot_calc_v(nu); + + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a-- > 0) { + bp->f1 |= SELECT; + bp++; + } + BLI_remlink(editnurb, nu); } - else { - mul_mat3_m4_v3(mat, vec); + break; + case CU_PRIM_DONUT: /* torus */ + if (cutype == CU_NURBS) { + float tmp_cent[3] = {0.f, 0.f, 0.f}; + float tmp_vec[3] = {0.f, 0.f, 1.f}; + + xzproj = 1; + nu = add_nurbs_primitive(C, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); /* circle */ + xzproj = 0; + nu->resolu = cu->resolu; + nu->resolv = cu->resolv; + nu->flag = CU_SMOOTH; + BLI_addtail(editnurb, nu); /* temporal for spin */ + + /* same as above */ + if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); + else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); + else spin_nurb(umat, obedit, tmp_vec, mat[3]); + + + BLI_remlink(editnurb, nu); + + a = nu->pntsu * nu->pntsv; + bp = nu->bp; + while (a-- > 0) { + bp->f1 |= SELECT; + bp++; + } + } + break; - translateflagNurb(editnurb, 1, vec); - extrudeflagNurb(cu->editnurb, 1); - vec[0]= -2*vec[0]; - vec[1]= -2*vec[1]; - vec[2]= -2*vec[2]; - translateflagNurb(editnurb, 1, vec); - - BLI_remlink(editnurb, nu); - - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while (a-- >0) { - bp->f1 |= SELECT; - bp++; - } - } - break; - case CU_PRIM_SPHERE: /* sphere */ - if ( cutype==CU_NURBS ) { - float tmp_cent[3] = {0.f, 0.f, 0.f}; - float tmp_vec[3] = {0.f, 0.f, 1.f}; - - nu->pntsu= 5; - nu->pntsv= 1; - nu->orderu= 3; - nu->resolu= cu->resolu; - nu->resolv= cu->resolv; - nu->flag= CU_SMOOTH; - nu->bp= callocstructN(BPoint, 5, "addNurbprim6"); - nu->flagu= 0; - bp= nu->bp; - - for (a=0; a<5; a++) { - bp->f1= SELECT; - bp->vec[0]+= nurbcircle[a][0]*grid; - bp->vec[2]+= nurbcircle[a][1]*grid; - if (a & 1) bp->vec[3]= 0.5*M_SQRT2; - else bp->vec[3]= 1.0; - mul_m4_v3(mat, bp->vec); - bp++; - } - nu->flagu= CU_NURB_BEZIER; - BKE_nurb_knot_calc_u(nu); - - BLI_addtail(editnurb, nu); /* temporal for spin */ - - if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); - else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); - else spin_nurb(umat, obedit, tmp_vec, mat[3]); - - BKE_nurb_knot_calc_v(nu); - - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while (a-- >0) { - bp->f1 |= SELECT; - bp++; - } - BLI_remlink(editnurb, nu); - } - break; - case CU_PRIM_DONUT: /* torus */ - if ( cutype==CU_NURBS ) { - float tmp_cent[3] = {0.f, 0.f, 0.f}; - float tmp_vec[3] = {0.f, 0.f, 1.f}; - - xzproj= 1; - nu= add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_CIRCLE, 0); /* circle */ - xzproj= 0; - nu->resolu= cu->resolu; - nu->resolv= cu->resolv; - nu->flag= CU_SMOOTH; - BLI_addtail(editnurb, nu); /* temporal for spin */ - - /* same as above */ - if (newob && (U.flag & USER_ADD_VIEWALIGNED) == 0) spin_nurb(umat, obedit, tmp_vec, tmp_cent); - else if ((U.flag & USER_ADD_VIEWALIGNED)) spin_nurb(viewmat, obedit, zvec, mat[3]); - else spin_nurb(umat, obedit, tmp_vec, mat[3]); - - - BLI_remlink(editnurb, nu); - - a= nu->pntsu*nu->pntsv; - bp= nu->bp; - while (a-- >0) { - bp->f1 |= SELECT; - bp++; - } - - } - break; - - default: /* should never happen */ - BLI_assert(!"invalid nurbs type"); - return NULL; + default: /* should never happen */ + BLI_assert(!"invalid nurbs type"); + return NULL; } BLI_assert(nu != NULL); @@ -6557,10 +6532,10 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newob) static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); ListBase *editnurb; Nurb *nu; - int newob= 0; + int newob = 0; int enter_editmode, is_aligned; unsigned int layer; float loc[3], rot[3]; @@ -6570,23 +6545,23 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) return OPERATOR_CANCELLED; if (!isSurf) { /* adding curve */ - if (obedit==NULL || obedit->type!=OB_CURVE) { + if (obedit == NULL || obedit->type != OB_CURVE) { Curve *cu; - obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); + obedit = ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); newob = 1; - cu= (Curve*)obedit->data; + cu = (Curve *)obedit->data; cu->flag |= CU_DEFORM_FILL; if (type & CU_PRIM_PATH) - cu->flag |= CU_PATH|CU_3D; + cu->flag |= CU_PATH | CU_3D; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); } else { /* adding surface */ - if (obedit==NULL || obedit->type!=OB_SURF) { - obedit= ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); + if (obedit == NULL || obedit->type != OB_SURF) { + obedit = ED_object_add_type(C, OB_SURF, loc, rot, TRUE, layer); newob = 1; } else DAG_id_tag_update(&obedit->id, OB_RECALC_DATA); @@ -6595,7 +6570,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) /* rename here, the undo stack checks name for valid undo pushes */ if (newob) { - if (obedit->type==OB_CURVE) { + if (obedit->type == OB_CURVE) { rename_id((ID *)obedit, get_curve_defname(type)); rename_id((ID *)obedit->data, get_curve_defname(type)); } @@ -6611,8 +6586,8 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) ED_object_new_primitive_matrix(C, obedit, loc, rot, mat); - nu= add_nurbs_primitive(C, mat, type, newob); - editnurb= object_editcurve_get(obedit); + nu = add_nurbs_primitive(C, mat, type, newob); + editnurb = object_editcurve_get(obedit); BLI_addtail(editnurb, nu); /* userdef */ @@ -6620,7 +6595,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, int type, int isSurf) ED_object_exit_editmode(C, EM_FREEDATA); } - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); return OPERATOR_FINISHED; } @@ -6639,7 +6614,7 @@ static int surf_prim_add(bContext *C, wmOperator *op, int type) static int add_primitive_bezier_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_BEZIER|CU_PRIM_CURVE); + return curve_prim_add(C, op, CU_BEZIER | CU_PRIM_CURVE); } void CURVE_OT_primitive_bezier_curve_add(wmOperatorType *ot) @@ -6655,14 +6630,14 @@ void CURVE_OT_primitive_bezier_curve_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_bezier_circle_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_BEZIER|CU_PRIM_CIRCLE); + return curve_prim_add(C, op, CU_BEZIER | CU_PRIM_CIRCLE); } void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) @@ -6678,14 +6653,14 @@ void CURVE_OT_primitive_bezier_circle_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_curve_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_NURBS|CU_PRIM_CURVE); + return curve_prim_add(C, op, CU_NURBS | CU_PRIM_CURVE); } void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot) @@ -6701,14 +6676,14 @@ void CURVE_OT_primitive_nurbs_curve_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_circle_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_NURBS|CU_PRIM_CIRCLE); + return curve_prim_add(C, op, CU_NURBS | CU_PRIM_CIRCLE); } void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot) @@ -6724,14 +6699,14 @@ void CURVE_OT_primitive_nurbs_circle_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_curve_path_exec(bContext *C, wmOperator *op) { - return curve_prim_add(C, op, CU_NURBS|CU_PRIM_PATH); + return curve_prim_add(C, op, CU_NURBS | CU_PRIM_PATH); } void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) @@ -6747,7 +6722,7 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } @@ -6755,7 +6730,7 @@ void CURVE_OT_primitive_nurbs_path_add(wmOperatorType *ot) /* **************** NURBS surfaces ********************** */ static int add_primitive_nurbs_surface_curve_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_CURVE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_CURVE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) @@ -6771,14 +6746,14 @@ void SURFACE_OT_primitive_nurbs_surface_curve_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_circle_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_CIRCLE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_CIRCLE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) @@ -6794,14 +6769,14 @@ void SURFACE_OT_primitive_nurbs_surface_circle_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_surface_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_PATCH|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_PATCH | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) @@ -6817,14 +6792,14 @@ void SURFACE_OT_primitive_nurbs_surface_surface_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_cylinder_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_TUBE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_TUBE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_cylinder_add(wmOperatorType *ot) @@ -6840,14 +6815,14 @@ void SURFACE_OT_primitive_nurbs_surface_cylinder_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_sphere_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_SPHERE|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_SPHERE | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) @@ -6863,14 +6838,14 @@ void SURFACE_OT_primitive_nurbs_surface_sphere_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } static int add_primitive_nurbs_surface_torus_exec(bContext *C, wmOperator *op) { - return surf_prim_add(C, op, CU_PRIM_DONUT|CU_NURBS); + return surf_prim_add(C, op, CU_PRIM_DONUT | CU_NURBS); } void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) @@ -6886,7 +6861,7 @@ void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ED_object_add_generic_props(ot, TRUE); } @@ -6895,34 +6870,34 @@ void SURFACE_OT_primitive_nurbs_surface_torus_add(wmOperatorType *ot) static int clear_tilt_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - ListBase *editnurb= object_editcurve_get(obedit); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; BezTriple *bezt; BPoint *bp; int a; - for (nu= editnurb->first; nu; nu= nu->next) { - if ( nu->bezt ) { - bezt= nu->bezt; - a= nu->pntsu; + for (nu = editnurb->first; nu; nu = nu->next) { + if (nu->bezt) { + bezt = nu->bezt; + a = nu->pntsu; while (a--) { - if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa= 0.0; + if (BEZSELECTED_HIDDENHANDLES(cu, bezt)) bezt->alfa = 0.0; bezt++; } } else if (nu->bp) { - bp= nu->bp; - a= nu->pntsu*nu->pntsv; + bp = nu->bp; + a = nu->pntsu * nu->pntsv; while (a--) { - if (bp->f1 & SELECT) bp->alfa= 0.0; + if (bp->f1 & SELECT) bp->alfa = 0.0f; bp++; } } } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); DAG_id_tag_update(obedit->data, 0); return OPERATOR_FINISHED; @@ -6940,7 +6915,7 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) ot->poll = ED_operator_editcurve; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /****************** undo for curves ****************/ @@ -6948,15 +6923,15 @@ void CURVE_OT_tilt_clear(wmOperatorType *ot) static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu) { if (nu->bezt) { - BezTriple *lastbezt= (BezTriple*)lastsel; - if (lastbezt >= nu->bezt && lastbezt < nu->bezt + nu->pntsu) { - return newnu->bezt + (lastbezt - nu->bezt); + BezTriple *lastbezt = (BezTriple *)lastsel; + if (lastbezt >= nu->bezt && lastbezt < &nu->bezt[nu->pntsu]) { + return &newnu->bezt[lastbezt - nu->bezt]; } } else { - BPoint *lastbp= (BPoint*)lastsel; - if (lastbp >= nu->bp && lastbp < nu->bp + nu->pntsu*nu->pntsv) { - return newnu->bp + (lastbp - nu->bp); + BPoint *lastbp = (BPoint *)lastsel; + if (lastbp >= nu->bp && lastbp < &nu->bp[nu->pntsu * nu->pntsv]) { + return &newnu->bp[lastbp - nu->bp]; } } @@ -6965,20 +6940,20 @@ static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu) static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) { - Curve *cu= cu_v; - UndoCurve *undoCurve= ucu; - ListBase *undobase= &undoCurve->nubase; - ListBase *editbase= BKE_curve_editNurbs_get(cu); + Curve *cu = cu_v; + UndoCurve *undoCurve = ucu; + ListBase *undobase = &undoCurve->nubase; + ListBase *editbase = BKE_curve_editNurbs_get(cu); Nurb *nu, *newnu; - EditNurb *editnurb= cu->editnurb; - void *lastsel= NULL; - AnimData *ad= BKE_animdata_from_id(&cu->id); + EditNurb *editnurb = cu->editnurb; + void *lastsel = NULL; + AnimData *ad = BKE_animdata_from_id(&cu->id); BKE_nurbList_free(editbase); if (undoCurve->undoIndex) { BLI_ghash_free(editnurb->keyindex, NULL, (GHashValFreeFP)MEM_freeN); - editnurb->keyindex= dupli_keyIndexHash(undoCurve->undoIndex); + editnurb->keyindex = dupli_keyIndexHash(undoCurve->undoIndex); } if (ad) { @@ -6992,11 +6967,11 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) } /* copy */ - for (nu= undobase->first; nu; nu= nu->next) { - newnu= BKE_nurb_duplicate(nu); + for (nu = undobase->first; nu; nu = nu->next) { + newnu = BKE_nurb_duplicate(nu); if (lastsel == NULL) { - lastsel= undo_check_lastsel(undoCurve->lastsel, nu, newnu); + lastsel = undo_check_lastsel(undoCurve->lastsel, nu, newnu); } if (editnurb->keyindex) { @@ -7006,26 +6981,26 @@ static void undoCurve_to_editCurve(void *ucu, void *UNUSED(edata), void *cu_v) BLI_addtail(editbase, newnu); } - cu->lastsel= lastsel; - cu->actnu= undoCurve->actnu; + cu->lastsel = lastsel; + cu->actnu = undoCurve->actnu; ED_curve_updateAnimPaths(cu); } static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) { - Curve *cu= cu_v; - ListBase *nubase= BKE_curve_editNurbs_get(cu); + Curve *cu = cu_v; + ListBase *nubase = BKE_curve_editNurbs_get(cu); UndoCurve *undoCurve; - EditNurb *editnurb= cu->editnurb, tmpEditnurb; + EditNurb *editnurb = cu->editnurb, tmpEditnurb; Nurb *nu, *newnu; - void *lastsel= NULL; - AnimData *ad= BKE_animdata_from_id(&cu->id); + void *lastsel = NULL; + AnimData *ad = BKE_animdata_from_id(&cu->id); - undoCurve= MEM_callocN(sizeof(UndoCurve), "undoCurve"); + undoCurve = MEM_callocN(sizeof(UndoCurve), "undoCurve"); if (editnurb->keyindex) { - undoCurve->undoIndex= dupli_keyIndexHash(editnurb->keyindex); - tmpEditnurb.keyindex= undoCurve->undoIndex; + undoCurve->undoIndex = dupli_keyIndexHash(editnurb->keyindex); + tmpEditnurb.keyindex = undoCurve->undoIndex; } if (ad) { @@ -7036,11 +7011,11 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) } /* copy */ - for (nu= nubase->first; nu; nu= nu->next) { - newnu= BKE_nurb_duplicate(nu); + for (nu = nubase->first; nu; nu = nu->next) { + newnu = BKE_nurb_duplicate(nu); if (lastsel == NULL) { - lastsel= undo_check_lastsel(cu->lastsel, nu, newnu); + lastsel = undo_check_lastsel(cu->lastsel, nu, newnu); } if (undoCurve->undoIndex) { @@ -7050,15 +7025,15 @@ static void *editCurve_to_undoCurve(void *UNUSED(edata), void *cu_v) BLI_addtail(&undoCurve->nubase, newnu); } - undoCurve->lastsel= lastsel; - undoCurve->actnu= cu->actnu; + undoCurve->lastsel = lastsel; + undoCurve->actnu = cu->actnu; return undoCurve; } static void free_undoCurve(void *ucv) { - UndoCurve *undoCurve= ucv; + UndoCurve *undoCurve = ucv; BKE_nurbList_free(&undoCurve->nubase); @@ -7073,7 +7048,7 @@ static void free_undoCurve(void *ucv) static void *get_data(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); return obedit; } @@ -7085,30 +7060,30 @@ void undo_push_curve(bContext *C, const char *name) void ED_curve_beztcpy(EditNurb *editnurb, BezTriple *dst, BezTriple *src, int count) { - memcpy(dst, src, count*sizeof(BezTriple)); + memcpy(dst, src, count * sizeof(BezTriple)); keyIndex_updateBezt(editnurb, src, dst, count); } void ED_curve_bpcpy(EditNurb *editnurb, BPoint *dst, BPoint *src, int count) { - memcpy(dst, src, count*sizeof(BPoint)); + memcpy(dst, src, count * sizeof(BPoint)); keyIndex_updateBP(editnurb, src, dst, count); } int ED_curve_actSelection(Curve *cu, float center[3]) { - Nurb *nu= get_lastsel_nurb(cu); + Nurb *nu = get_lastsel_nurb(cu); if (!nu) return 0; if (nu->bezt) { - BezTriple *bezt= cu->lastsel; + BezTriple *bezt = cu->lastsel; copy_v3_v3(center, bezt->vec[1]); } else { - BPoint *bp= cu->lastsel; + BPoint *bp = cu->lastsel; copy_v3_v3(center, bp->vec); } diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 0a976e6ed6b..83f6b1d1824 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -74,135 +74,135 @@ #include "curve_intern.h" -#define MAXTEXT 32766 +#define MAXTEXT 32766 /************************* utilities ******************************/ static char findaccent(char char1, unsigned int code) { - char new= 0; + char new = 0; - if (char1=='a') { - if (code=='`') new= 224; - else if (code==39) new= 225; - else if (code=='^') new= 226; - else if (code=='~') new= 227; - else if (code=='"') new= 228; - else if (code=='o') new= 229; - else if (code=='e') new= 230; - else if (code=='-') new= 170; + if (char1 == 'a') { + if (code == '`') new = 224; + else if (code == 39) new = 225; + else if (code == '^') new = 226; + else if (code == '~') new = 227; + else if (code == '"') new = 228; + else if (code == 'o') new = 229; + else if (code == 'e') new = 230; + else if (code == '-') new = 170; } - else if (char1=='c') { - if (code==',') new= 231; - if (code=='|') new= 162; + else if (char1 == 'c') { + if (code == ',') new = 231; + if (code == '|') new = 162; } - else if (char1=='e') { - if (code=='`') new= 232; - else if (code==39) new= 233; - else if (code=='^') new= 234; - else if (code=='"') new= 235; + else if (char1 == 'e') { + if (code == '`') new = 232; + else if (code == 39) new = 233; + else if (code == '^') new = 234; + else if (code == '"') new = 235; } - else if (char1=='i') { - if (code=='`') new= 236; - else if (code==39) new= 237; - else if (code=='^') new= 238; - else if (code=='"') new= 239; + else if (char1 == 'i') { + if (code == '`') new = 236; + else if (code == 39) new = 237; + else if (code == '^') new = 238; + else if (code == '"') new = 239; } - else if (char1=='n') { - if (code=='~') new= 241; + else if (char1 == 'n') { + if (code == '~') new = 241; } - else if (char1=='o') { - if (code=='`') new= 242; - else if (code==39) new= 243; - else if (code=='^') new= 244; - else if (code=='~') new= 245; - else if (code=='"') new= 246; - else if (code=='/') new= 248; - else if (code=='-') new= 186; - else if (code=='e') new= 143; + else if (char1 == 'o') { + if (code == '`') new = 242; + else if (code == 39) new = 243; + else if (code == '^') new = 244; + else if (code == '~') new = 245; + else if (code == '"') new = 246; + else if (code == '/') new = 248; + else if (code == '-') new = 186; + else if (code == 'e') new = 143; } - else if (char1=='s') { - if (code=='s') new= 167; + else if (char1 == 's') { + if (code == 's') new = 167; } - else if (char1=='u') { - if (code=='`') new= 249; - else if (code==39) new= 250; - else if (code=='^') new= 251; - else if (code=='"') new= 252; + else if (char1 == 'u') { + if (code == '`') new = 249; + else if (code == 39) new = 250; + else if (code == '^') new = 251; + else if (code == '"') new = 252; } - else if (char1=='y') { - if (code==39) new= 253; - else if (code=='"') new= 255; + else if (char1 == 'y') { + if (code == 39) new = 253; + else if (code == '"') new = 255; } - else if (char1=='A') { - if (code=='`') new= 192; - else if (code==39) new= 193; - else if (code=='^') new= 194; - else if (code=='~') new= 195; - else if (code=='"') new= 196; - else if (code=='o') new= 197; - else if (code=='e') new= 198; + else if (char1 == 'A') { + if (code == '`') new = 192; + else if (code == 39) new = 193; + else if (code == '^') new = 194; + else if (code == '~') new = 195; + else if (code == '"') new = 196; + else if (code == 'o') new = 197; + else if (code == 'e') new = 198; } - else if (char1=='C') { - if (code==',') new= 199; + else if (char1 == 'C') { + if (code == ',') new = 199; } - else if (char1=='E') { - if (code=='`') new= 200; - else if (code==39) new= 201; - else if (code=='^') new= 202; - else if (code=='"') new= 203; + else if (char1 == 'E') { + if (code == '`') new = 200; + else if (code == 39) new = 201; + else if (code == '^') new = 202; + else if (code == '"') new = 203; } - else if (char1=='I') { - if (code=='`') new= 204; - else if (code==39) new= 205; - else if (code=='^') new= 206; - else if (code=='"') new= 207; + else if (char1 == 'I') { + if (code == '`') new = 204; + else if (code == 39) new = 205; + else if (code == '^') new = 206; + else if (code == '"') new = 207; } - else if (char1=='N') { - if (code=='~') new= 209; + else if (char1 == 'N') { + if (code == '~') new = 209; } - else if (char1=='O') { - if (code=='`') new= 210; - else if (code==39) new= 211; - else if (code=='^') new= 212; - else if (code=='~') new= 213; - else if (code=='"') new= 214; - else if (code=='/') new= 216; - else if (code=='e') new= 141; + else if (char1 == 'O') { + if (code == '`') new = 210; + else if (code == 39) new = 211; + else if (code == '^') new = 212; + else if (code == '~') new = 213; + else if (code == '"') new = 214; + else if (code == '/') new = 216; + else if (code == 'e') new = 141; } - else if (char1=='U') { - if (code=='`') new= 217; - else if (code==39) new= 218; - else if (code=='^') new= 219; - else if (code=='"') new= 220; + else if (char1 == 'U') { + if (code == '`') new = 217; + else if (code == 39) new = 218; + else if (code == '^') new = 219; + else if (code == '"') new = 220; } - else if (char1=='Y') { - if (code==39) new= 221; + else if (char1 == 'Y') { + if (code == 39) new = 221; } - else if (char1=='1') { - if (code=='4') new= 188; - if (code=='2') new= 189; + else if (char1 == '1') { + if (code == '4') new = 188; + if (code == '2') new = 189; } - else if (char1=='3') { - if (code=='4') new= 190; + else if (char1 == '3') { + if (code == '4') new = 190; } - else if (char1==':') { - if (code=='-') new= 247; + else if (char1 == ':') { + if (code == '-') new = 247; } - else if (char1=='-') { - if (code==':') new= 247; - if (code=='|') new= 135; - if (code=='+') new= 177; + else if (char1 == '-') { + if (code == ':') new = 247; + if (code == '|') new = 135; + if (code == '+') new = 177; } - else if (char1=='|') { - if (code=='-') new= 135; - if (code=='=') new= 136; + else if (char1 == '|') { + if (code == '-') new = 135; + if (code == '=') new = 136; } - else if (char1=='=') { - if (code=='|') new= 136; + else if (char1 == '=') { + if (code == '|') new = 136; } - else if (char1=='+') { - if (code=='-') new= 177; + else if (char1 == '+') { + if (code == '-') new = 177; } if (new) return new; @@ -212,7 +212,7 @@ static char findaccent(char char1, unsigned int code) static void update_string(Curve *cu) { - EditFont *ef= cu->editfont; + EditFont *ef = cu->editfont; int len; // Free the old curve string @@ -230,22 +230,22 @@ static void update_string(Curve *cu) static int insert_into_textbuf(Object *obedit, uintptr_t c) { - Curve *cu= obedit->data; + Curve *cu = obedit->data; - if (cu->leneditfont; + if (cu->len < MAXTEXT - 1) { + EditFont *ef = cu->editfont; int x; - for (x= cu->len; x>cu->pos; x--) ef->textbuf[x]= ef->textbuf[x-1]; - for (x= cu->len; x>cu->pos; x--) ef->textbufinfo[x]= ef->textbufinfo[x-1]; - ef->textbuf[cu->pos]= c; + for (x = cu->len; x > cu->pos; x--) ef->textbuf[x] = ef->textbuf[x - 1]; + for (x = cu->len; x > cu->pos; x--) ef->textbufinfo[x] = ef->textbufinfo[x - 1]; + ef->textbuf[cu->pos] = c; ef->textbufinfo[cu->pos] = cu->curinfo; ef->textbufinfo[cu->pos].kern = 0; ef->textbufinfo[cu->pos].mat_nr = obedit->actcol; cu->pos++; cu->len++; - ef->textbuf[cu->len]='\0'; + ef->textbuf[cu->len] = '\0'; update_string(cu); @@ -257,63 +257,63 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) static void text_update_edited(bContext *C, Scene *scene, Object *obedit, int recalc, int mode) { - struct Main *bmain= CTX_data_main(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - cu->curinfo = ef->textbufinfo[cu->pos?cu->pos-1:0]; + struct Main *bmain = CTX_data_main(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + cu->curinfo = ef->textbufinfo[cu->pos ? cu->pos - 1 : 0]; if (obedit->totcol > 0) { - obedit->actcol= ef->textbufinfo[cu->pos?cu->pos-1:0].mat_nr; + obedit->actcol = ef->textbufinfo[cu->pos ? cu->pos - 1 : 0].mat_nr; /* since this array is calloc'd, it can be 0 even though we try ensure * (mat_nr > 0) almost everywhere */ if (obedit->actcol < 1) { - obedit->actcol= 1; + obedit->actcol = 1; } } if (mode == FO_EDIT) update_string(cu); - BKE_text_to_curve(bmain, scene, obedit, mode); + BKE_vfont_to_curve(bmain, scene, obedit, mode); if (recalc) DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); } /********************** insert lorem operator *********************/ static int insert_lorem_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); const char *p, *p2; int i; static const char *lastlorem; if (lastlorem) - p= lastlorem; + p = lastlorem; else - p= ED_lorem; + p = ED_lorem; - i= rand()/(RAND_MAX/6)+4; + i = rand() / (RAND_MAX / 6) + 4; - for (p2=p; *p2 && i; p2++) { + for (p2 = p; *p2 && i; p2++) { insert_into_textbuf(obedit, *p2); - if (*p2=='.') + if (*p2 == '.') i--; } - lastlorem = p2+1; - if (strlen(lastlorem)<5) + lastlorem = p2 + 1; + if (strlen(lastlorem) < 5) lastlorem = ED_lorem; insert_into_textbuf(obedit, '\n'); insert_into_textbuf(obedit, '\n'); DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -330,7 +330,7 @@ void FONT_OT_insert_lorem(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************* paste file operator ********************/ @@ -340,15 +340,15 @@ void FONT_OT_insert_lorem(wmOperatorType *ot) static int paste_file(bContext *C, ReportList *reports, const char *filename) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; FILE *fp; int filelen; char *strp; - fp= BLI_fopen(filename, "r"); + fp = BLI_fopen(filename, "r"); if (!fp) { if (reports) @@ -360,22 +360,22 @@ static int paste_file(bContext *C, ReportList *reports, const char *filename) filelen = ftell(fp); fseek(fp, 0L, SEEK_SET); - strp= MEM_callocN(filelen+4, "tempstr"); + strp = MEM_callocN(filelen + 4, "tempstr"); // fread() instead of read(), because windows read() converts text // to DOS \r\n linebreaks, causing double linebreaks in the 3d text filelen = fread(strp, 1, filelen, fp); fclose(fp); - strp[filelen]= 0; + strp[filelen] = 0; - if (cu->len+filelenlen + filelen < MAXTEXT) { int tmplen; - wchar_t *mem = MEM_callocN((sizeof(wchar_t)*filelen)+(4*sizeof(wchar_t)), "temporary"); + wchar_t *mem = MEM_callocN((sizeof(wchar_t) * filelen) + (4 * sizeof(wchar_t)), "temporary"); tmplen = BLI_strncpy_wchar_from_utf8(mem, strp, filelen + 1); wcscat(ef->textbuf, mem); MEM_freeN(mem); cu->len += tmplen; - cu->pos= cu->len; + cu->pos = cu->len; } MEM_freeN(strp); @@ -389,8 +389,8 @@ static int paste_file_exec(bContext *C, wmOperator *op) char *path; int retval; - path= RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); - retval= paste_file(C, op->reports, path); + path = RNA_string_get_alloc(op->ptr, "filepath", NULL, 0); + retval = paste_file(C, op->reports, path); MEM_freeN(path); return retval; @@ -419,17 +419,17 @@ void FONT_OT_file_paste(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | TEXTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); } /******************* text to object operator ********************/ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float offset[3]) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); Curve *cu; Object *obedit; Base *base; @@ -437,60 +437,60 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, float int nchars = 0, a; float rot[3] = {0.f, 0.f, 0.f}; - obedit= add_object(scene, OB_FONT); - base= scene->basact; + obedit = BKE_object_add(scene, OB_FONT); + base = scene->basact; ED_object_base_init_transform(C, base, NULL, rot); /* seems to assume view align ? TODO - look into this, could be an operator option */ - where_is_object(scene, obedit); + BKE_object_where_is_calc(scene, obedit); obedit->loc[0] += offset[0]; obedit->loc[1] += offset[1]; obedit->loc[2] += offset[2]; - cu= obedit->data; - cu->vfont= get_builtin_font(); + cu = obedit->data; + cu->vfont = BKE_vfont_builtin_get(); cu->vfont->id.us++; - for (tmp=firstline, a=0; cu->lennext, a++) + for (tmp = firstline, a = 0; cu->len < MAXTEXT && a < totline; tmp = tmp->next, a++) nchars += strlen(tmp->line) + 1; if (cu->str) MEM_freeN(cu->str); if (cu->strinfo) MEM_freeN(cu->strinfo); - cu->str= MEM_callocN(nchars+4, "str"); - cu->strinfo= MEM_callocN((nchars+4)*sizeof(CharInfo), "strinfo"); + cu->str = MEM_callocN(nchars + 4, "str"); + cu->strinfo = MEM_callocN((nchars + 4) * sizeof(CharInfo), "strinfo"); - cu->str[0]= '\0'; - cu->len= 0; - cu->pos= 0; + cu->str[0] = '\0'; + cu->len = 0; + cu->pos = 0; - for (tmp=firstline, a=0; cu->lennext, a++) { + for (tmp = firstline, a = 0; cu->len < MAXTEXT && a < totline; tmp = tmp->next, a++) { strcat(cu->str, tmp->line); - cu->len+= strlen(tmp->line); + cu->len += strlen(tmp->line); if (tmp->next) { strcat(cu->str, "\n"); cu->len++; } - cu->pos= cu->len; + cu->pos = cu->len; } - WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, obedit); + WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, obedit); } void ED_text_to_object(bContext *C, Text *text, int split_lines) { - RegionView3D *rv3d= CTX_wm_region_view3d(C); + RegionView3D *rv3d = CTX_wm_region_view3d(C); TextLine *line; float offset[3]; - int linenum= 0; + int linenum = 0; if (!text || !text->lines.first) return; if (split_lines) { - for (line=text->lines.first; line; line=line->next) { + for (line = text->lines.first; line; line = line->next) { /* skip lines with no text, but still make space for them */ if (line->line[0] == '\0') { linenum++; @@ -511,9 +511,9 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) } } else { - offset[0]= 0.0f; - offset[1]= 0.0f; - offset[2]= 0.0f; + offset[0] = 0.0f; + offset[1] = 0.0f; + offset[2] = 0.0f; txt_add_object(C, text->lines.first, BLI_countlist(&text->lines), offset); } @@ -523,8 +523,8 @@ void ED_text_to_object(bContext *C, Text *text, int split_lines) static short next_word(Curve *cu) { short s; - for (s=cu->pos; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') && - (cu->str[s] != 1) && (cu->str[s] != '\r')); + for (s = cu->pos; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') && + (cu->str[s] != 1) && (cu->str[s] != '\r')); s++) { /* pass */ @@ -537,7 +537,7 @@ static short prev_word(Curve *cu) { short s; - if (cu->pos==0) return(0); + if (cu->pos == 0) return(0); for (s = cu->pos - 2; ((cu->str[s]) && (cu->str[s] != ' ') && (cu->str[s] != '\n') && (cu->str[s] != 1) && (cu->str[s] != '\r')); s--) @@ -548,29 +548,29 @@ static short prev_word(Curve *cu) return cu->str[s] ? (s + 1) : s; } -static int kill_selection(Object *obedit, int ins) /* 1 == new character */ +static int kill_selection(Object *obedit, int ins) /* 1 == new character */ { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; int selend, selstart, direction; int offset = 0; int getfrom; - direction = BKE_font_getselection(obedit, &selstart, &selend); + direction = BKE_vfont_select_get(obedit, &selstart, &selend); if (direction) { int size; if (ins) offset = 1; - if (cu->pos >= selstart) cu->pos = selstart+offset; + if (cu->pos >= selstart) cu->pos = selstart + offset; if ((direction == -1) && ins) { selstart++; selend++; } - getfrom = selend+offset; - if (ins==0) getfrom++; - size = (cu->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset*sizeof(wchar_t)); - memmove(ef->textbuf+selstart, ef->textbuf+getfrom, size); - memmove(ef->textbufinfo+selstart, ef->textbufinfo+getfrom, ((cu->len-selstart)+offset)*sizeof(CharInfo)); - cu->len -= (selend-selstart)+offset; + getfrom = selend + offset; + if (ins == 0) getfrom++; + size = (cu->len * sizeof(wchar_t)) - (selstart * sizeof(wchar_t)) + (offset * sizeof(wchar_t)); + memmove(ef->textbuf + selstart, ef->textbuf + getfrom, size); + memmove(ef->textbufinfo + selstart, ef->textbufinfo + getfrom, ((cu->len - selstart) + offset) * sizeof(CharInfo)); + cu->len -= (selend - selstart) + offset; cu->selstart = cu->selend = 0; } @@ -579,24 +579,25 @@ static int kill_selection(Object *obedit, int ins) /* 1 == new character */ /******************* set style operator ********************/ -static EnumPropertyItem style_items[]= { +static EnumPropertyItem style_items[] = { {CU_CHINFO_BOLD, "BOLD", 0, "Bold", ""}, {CU_CHINFO_ITALIC, "ITALIC", 0, "Italic", ""}, {CU_CHINFO_UNDERLINE, "UNDERLINE", 0, "Underline", ""}, {CU_CHINFO_SMALLCAPS, "SMALL_CAPS", 0, "Small Caps", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; static int set_style(bContext *C, const int style, const int clear) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; int i, selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - for (i=selstart; i<=selend; i++) { + for (i = selstart; i <= selend; i++) { if (clear) ef->textbufinfo[i].flag &= ~style; else @@ -604,15 +605,15 @@ static int set_style(bContext *C, const int style, const int clear) } DAG_id_tag_update(obedit->data, 0); - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } static int set_style_exec(bContext *C, wmOperator *op) { - const int style= RNA_enum_get(op->ptr, "style"); - const int clear= RNA_boolean_get(op->ptr, "clear"); + const int style = RNA_enum_get(op->ptr, "style"); + const int clear = RNA_boolean_get(op->ptr, "clear"); return set_style(C, style, clear); } @@ -629,7 +630,7 @@ void FONT_OT_style_set(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to"); @@ -640,17 +641,17 @@ void FONT_OT_style_set(wmOperatorType *ot) static int toggle_style_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; int style, clear, selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; - style= RNA_enum_get(op->ptr, "style"); + style = RNA_enum_get(op->ptr, "style"); cu->curinfo.flag ^= style; - clear= (cu->curinfo.flag & style) == 0; + clear = (cu->curinfo.flag & style) == 0; return set_style(C, style, clear); } @@ -667,7 +668,7 @@ void FONT_OT_style_toggle(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "style", style_items, CU_CHINFO_BOLD, "Style", "Style to set selection to"); @@ -679,19 +680,19 @@ static void copy_selection(Object *obedit) { int selstart, selend; - if (BKE_font_getselection(obedit, &selstart, &selend)) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; - memcpy(ef->copybuf, ef->textbuf+selstart, ((selend-selstart)+1)*sizeof(wchar_t)); - ef->copybuf[(selend-selstart)+1]=0; - memcpy(ef->copybufinfo, ef->textbufinfo+selstart, ((selend-selstart)+1)*sizeof(CharInfo)); + memcpy(ef->copybuf, ef->textbuf + selstart, ((selend - selstart) + 1) * sizeof(wchar_t)); + ef->copybuf[(selend - selstart) + 1] = 0; + memcpy(ef->copybufinfo, ef->textbufinfo + selstart, ((selend - selstart) + 1) * sizeof(CharInfo)); } } static int copy_text_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); copy_selection(obedit); @@ -714,11 +715,11 @@ void FONT_OT_text_copy(wmOperatorType *ot) static int cut_text_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); int selstart, selend; - if (!BKE_font_getselection(obedit, &selstart, &selend)) + if (!BKE_vfont_select_get(obedit, &selstart, &selend)) return OPERATOR_CANCELLED; copy_selection(obedit); @@ -741,26 +742,26 @@ void FONT_OT_text_cut(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************* paste text operator ********************/ static int paste_selection(Object *obedit, ReportList *reports) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int len= wcslen(ef->copybuf); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int len = wcslen(ef->copybuf); // Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT if (cu->len + len <= MAXTEXT) { if (len) { - int size = (cu->len * sizeof(wchar_t)) - (cu->pos*sizeof(wchar_t)) + sizeof(wchar_t); - memmove(ef->textbuf+cu->pos+len, ef->textbuf+cu->pos, size); - memcpy(ef->textbuf+cu->pos, ef->copybuf, len * sizeof(wchar_t)); + int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); + memmove(ef->textbuf + cu->pos + len, ef->textbuf + cu->pos, size); + memcpy(ef->textbuf + cu->pos, ef->copybuf, len * sizeof(wchar_t)); - memmove(ef->textbufinfo+cu->pos+len, ef->textbufinfo+cu->pos, (cu->len-cu->pos+1)*sizeof(CharInfo)); - memcpy(ef->textbufinfo+cu->pos, ef->copybufinfo, len*sizeof(CharInfo)); + memmove(ef->textbufinfo + cu->pos + len, ef->textbufinfo + cu->pos, (cu->len - cu->pos + 1) * sizeof(CharInfo)); + memcpy(ef->textbufinfo + cu->pos, ef->copybufinfo, len * sizeof(CharInfo)); cu->len += len; cu->pos += len; @@ -776,8 +777,8 @@ static int paste_selection(Object *obedit, ReportList *reports) static int paste_text_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); if (!paste_selection(obedit, op->reports)) return OPERATOR_CANCELLED; @@ -799,12 +800,12 @@ void FONT_OT_text_paste(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /************************ move operator ************************/ -static EnumPropertyItem move_type_items[]= { +static EnumPropertyItem move_type_items[] = { {LINE_BEGIN, "LINE_BEGIN", 0, "Line Begin", ""}, {LINE_END, "LINE_END", 0, "Line End", ""}, {PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, @@ -819,77 +820,77 @@ static EnumPropertyItem move_type_items[]= { static int move_cursor(bContext *C, int type, int select) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int cursmove= -1; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int cursmove = -1; switch (type) { case LINE_BEGIN: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - while (cu->pos>0) { - if (ef->textbuf[cu->pos-1]=='\n') break; - if (ef->textbufinfo[cu->pos-1].flag & CU_CHINFO_WRAP) break; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + while (cu->pos > 0) { + if (ef->textbuf[cu->pos - 1] == '\n') break; + if (ef->textbufinfo[cu->pos - 1].flag & CU_CHINFO_WRAP) break; cu->pos--; } - cursmove=FO_CURS; + cursmove = FO_CURS; break; case LINE_END: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - while (cu->poslen) { - if (ef->textbuf[cu->pos]==0) break; - if (ef->textbuf[cu->pos]=='\n') break; - if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP ) break; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + while (cu->pos < cu->len) { + if (ef->textbuf[cu->pos] == 0) break; + if (ef->textbuf[cu->pos] == '\n') break; + if (ef->textbufinfo[cu->pos].flag & CU_CHINFO_WRAP) break; cu->pos++; } - cursmove=FO_CURS; + cursmove = FO_CURS; break; case PREV_WORD: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cu->pos= prev_word(cu); - cursmove= FO_CURS; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cu->pos = prev_word(cu); + cursmove = FO_CURS; break; case NEXT_WORD: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cu->pos= next_word(cu); - cursmove= FO_CURS; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cu->pos = next_word(cu); + cursmove = FO_CURS; break; case PREV_CHAR: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; cu->pos--; - cursmove=FO_CURS; + cursmove = FO_CURS; break; case NEXT_CHAR: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; cu->pos++; - cursmove= FO_CURS; + cursmove = FO_CURS; break; case PREV_LINE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove=FO_CURSUP; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_CURSUP; break; case NEXT_LINE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove= FO_CURSDOWN; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_CURSDOWN; break; case PREV_PAGE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove=FO_PAGEUP; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_PAGEUP; break; case NEXT_PAGE: - if ((select) && (cu->selstart==0)) cu->selstart = cu->selend = cu->pos+1; - cursmove=FO_PAGEDOWN; + if ((select) && (cu->selstart == 0)) cu->selstart = cu->selend = cu->pos + 1; + cursmove = FO_PAGEDOWN; break; } @@ -898,16 +899,16 @@ static int move_cursor(bContext *C, int type, int select) if (select == 0) { if (cu->selstart) { - struct Main *bmain= CTX_data_main(C); + struct Main *bmain = CTX_data_main(C); cu->selstart = cu->selend = 0; update_string(cu); - BKE_text_to_curve(bmain, scene, obedit, FO_SELCHANGE); + BKE_vfont_to_curve(bmain, scene, obedit, FO_SELCHANGE); } } - if (cu->pos>cu->len) cu->pos= cu->len; - else if (cu->pos>=MAXTEXT) cu->pos= MAXTEXT; - else if (cu->pos<0) cu->pos= 0; + if (cu->pos > cu->len) cu->pos = cu->len; + else if (cu->pos >= MAXTEXT) cu->pos = MAXTEXT; + else if (cu->pos < 0) cu->pos = 0; text_update_edited(C, scene, obedit, select, cursmove); @@ -919,7 +920,7 @@ static int move_cursor(bContext *C, int type, int select) static int move_exec(bContext *C, wmOperator *op) { - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); return move_cursor(C, type, 0); } @@ -936,7 +937,7 @@ void FONT_OT_move(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to"); @@ -946,7 +947,7 @@ void FONT_OT_move(wmOperatorType *ot) static int move_select_exec(bContext *C, wmOperator *op) { - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); return move_cursor(C, type, 1); } @@ -963,7 +964,7 @@ void FONT_OT_move_select(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", move_type_items, LINE_BEGIN, "Type", "Where to move cursor to, to make a selection"); @@ -973,20 +974,20 @@ void FONT_OT_move_select(wmOperatorType *ot) static int change_spacing_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int kern, delta= RNA_int_get(op->ptr, "delta"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int kern, delta = RNA_int_get(op->ptr, "delta"); - kern = ef->textbufinfo[cu->pos-1].kern; + kern = ef->textbufinfo[cu->pos - 1].kern; kern += delta; CLAMP(kern, -20, 20); - if (ef->textbufinfo[cu->pos-1].kern == kern) + if (ef->textbufinfo[cu->pos - 1].kern == kern) return OPERATOR_CANCELLED; - ef->textbufinfo[cu->pos-1].kern = kern; + ef->textbufinfo[cu->pos - 1].kern = kern; text_update_edited(C, scene, obedit, 1, FO_EDIT); @@ -1005,7 +1006,7 @@ void FONT_OT_change_spacing(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "delta", 1, -20, 20, "Delta", "Amount to decrease or increase character spacing with", -20, 20); @@ -1015,23 +1016,23 @@ void FONT_OT_change_spacing(wmOperatorType *ot) static int change_character_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int character, delta= RNA_int_get(op->ptr, "delta"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int character, delta = RNA_int_get(op->ptr, "delta"); if (cu->pos <= 0) return OPERATOR_CANCELLED; - character= ef->textbuf[cu->pos - 1]; + character = ef->textbuf[cu->pos - 1]; character += delta; CLAMP(character, 0, 255); if (character == ef->textbuf[cu->pos - 1]) return OPERATOR_CANCELLED; - ef->textbuf[cu->pos - 1]= character; + ef->textbuf[cu->pos - 1] = character; text_update_edited(C, scene, obedit, 1, FO_EDIT); @@ -1050,7 +1051,7 @@ void FONT_OT_change_character(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "delta", 1, -255, 255, "Delta", "Number to increase or decrease character code with", -255, 255); @@ -1060,15 +1061,15 @@ void FONT_OT_change_character(wmOperatorType *ot) static int line_break_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - const int ctrl= RNA_boolean_get(op->ptr, "ctrl"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + const int ctrl = RNA_boolean_get(op->ptr, "ctrl"); if (ctrl) { insert_into_textbuf(obedit, 1); - if (ef->textbuf[cu->pos]!='\n') + if (ef->textbuf[cu->pos] != '\n') insert_into_textbuf(obedit, '\n'); } else @@ -1093,7 +1094,7 @@ void FONT_OT_line_break(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "ctrl", 0, "Ctrl", ""); // XXX what is this? @@ -1101,7 +1102,7 @@ void FONT_OT_line_break(wmOperatorType *ot) /******************* delete operator **********************/ -static EnumPropertyItem delete_type_items[]= { +static EnumPropertyItem delete_type_items[] = { {DEL_ALL, "ALL", 0, "All", ""}, {DEL_NEXT_CHAR, "NEXT_CHARACTER", 0, "Next Character", ""}, {DEL_PREV_CHAR, "PREVIOUS_CHARACTER", 0, "Previous Character", ""}, @@ -1112,55 +1113,55 @@ static EnumPropertyItem delete_type_items[]= { static int delete_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; - int x, selstart, selend, type= RNA_enum_get(op->ptr, "type"); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + int x, selstart, selend, type = RNA_enum_get(op->ptr, "type"); if (cu->len == 0) return OPERATOR_CANCELLED; - if (BKE_font_getselection(obedit, &selstart, &selend)) { - if (type == DEL_NEXT_SEL) type= DEL_SELECTION; - else if (type == DEL_PREV_SEL) type= DEL_SELECTION; + if (BKE_vfont_select_get(obedit, &selstart, &selend)) { + if (type == DEL_NEXT_SEL) type = DEL_SELECTION; + else if (type == DEL_PREV_SEL) type = DEL_SELECTION; } else { - if (type == DEL_NEXT_SEL) type= DEL_NEXT_CHAR; - else if (type == DEL_PREV_SEL) type= DEL_PREV_CHAR; + if (type == DEL_NEXT_SEL) type = DEL_NEXT_CHAR; + else if (type == DEL_PREV_SEL) type = DEL_PREV_CHAR; } switch (type) { case DEL_ALL: cu->len = cu->pos = 0; - ef->textbuf[0]= 0; + ef->textbuf[0] = 0; break; case DEL_SELECTION: if (!kill_selection(obedit, 0)) return OPERATOR_CANCELLED; break; case DEL_PREV_CHAR: - if (cu->pos<=0) + if (cu->pos <= 0) return OPERATOR_CANCELLED; - for (x=cu->pos;x<=cu->len;x++) - ef->textbuf[x-1]= ef->textbuf[x]; - for (x=cu->pos;x<=cu->len;x++) - ef->textbufinfo[x-1]= ef->textbufinfo[x]; + for (x = cu->pos; x <= cu->len; x++) + ef->textbuf[x - 1] = ef->textbuf[x]; + for (x = cu->pos; x <= cu->len; x++) + ef->textbufinfo[x - 1] = ef->textbufinfo[x]; cu->pos--; - ef->textbuf[--cu->len]='\0'; + ef->textbuf[--cu->len] = '\0'; break; case DEL_NEXT_CHAR: - if (cu->pos>=cu->len) + if (cu->pos >= cu->len) return OPERATOR_CANCELLED; - for (x=cu->pos;xlen;x++) - ef->textbuf[x]= ef->textbuf[x+1]; - for (x=cu->pos;xlen;x++) - ef->textbufinfo[x]= ef->textbufinfo[x+1]; + for (x = cu->pos; x < cu->len; x++) + ef->textbuf[x] = ef->textbuf[x + 1]; + for (x = cu->pos; x < cu->len; x++) + ef->textbufinfo[x] = ef->textbufinfo[x + 1]; - ef->textbuf[--cu->len]='\0'; + ef->textbuf[--cu->len] = '\0'; break; default: return OPERATOR_CANCELLED; @@ -1183,7 +1184,7 @@ void FONT_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "type", delete_type_items, DEL_ALL, "Type", "Which part of the text to delete"); @@ -1193,8 +1194,8 @@ void FONT_OT_delete(wmOperatorType *ot) static int insert_text_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); char *inserted_utf8; wchar_t *inserted_text; int a, len; @@ -1202,13 +1203,13 @@ static int insert_text_exec(bContext *C, wmOperator *op) if (!RNA_struct_property_is_set(op->ptr, "text")) return OPERATOR_CANCELLED; - inserted_utf8= RNA_string_get_alloc(op->ptr, "text", NULL, 0); - len= BLI_strlen_utf8(inserted_utf8); + inserted_utf8 = RNA_string_get_alloc(op->ptr, "text", NULL, 0); + len = BLI_strlen_utf8(inserted_utf8); - inserted_text= MEM_callocN(sizeof(wchar_t)*(len+1), "FONT_insert_text"); - BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len+1); + inserted_text = MEM_callocN(sizeof(wchar_t) * (len + 1), "FONT_insert_text"); + BLI_strncpy_wchar_from_utf8(inserted_text, inserted_utf8, len + 1); - for (a=0; adata; - EditFont *ef= cu->editfont; - static int accentcode= 0; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; + static int accentcode = 0; uintptr_t ascii = evt->ascii; - int alt= evt->alt, shift= evt->shift, ctrl= evt->ctrl; - int event= evt->type, val= evt->val; - wchar_t inserted_text[2]= {0}; + int alt = evt->alt, shift = evt->shift, ctrl = evt->ctrl; + int event = evt->type, val = evt->val; + wchar_t inserted_text[2] = {0}; if (RNA_struct_property_is_set(op->ptr, "text")) return insert_text_exec(C, op); if (RNA_struct_property_is_set(op->ptr, "accent")) { - if (cu->len!=0 && cu->pos>0) - accentcode= 1; + if (cu->len != 0 && cu->pos > 0) + accentcode = 1; return OPERATOR_FINISHED; } /* tab should exit editmode, but we allow it to be typed using modifier keys */ - if (event==TABKEY) { - if ((alt||ctrl||shift) == 0) + if (event == TABKEY) { + if ((alt || ctrl || shift) == 0) return OPERATOR_PASS_THROUGH; else - ascii= 9; + ascii = 9; } - else if (event==BACKSPACEKEY) - ascii= 0; + else if (event == BACKSPACEKEY) + ascii = 0; if (val && (ascii || evt->utf8_buf[0])) { /* handle case like TAB (== 9) */ if ( (ascii > 31 && ascii < 254 && ascii != 127) || - (ascii==13) || - (ascii==10) || - (ascii==8) || - (evt->utf8_buf[0])) + (ascii == 13) || + (ascii == 10) || + (ascii == 8) || + (evt->utf8_buf[0])) { if (evt->utf8_buf[0]) { BLI_strncpy_wchar_from_utf8(inserted_text, evt->utf8_buf, 1); - ascii= inserted_text[0]; + ascii = inserted_text[0]; insert_into_textbuf(obedit, ascii); - accentcode= 0; + accentcode = 0; } else if (accentcode) { - if (cu->pos>0) { - inserted_text[0]= findaccent(ef->textbuf[cu->pos-1], ascii); - ef->textbuf[cu->pos-1]= inserted_text[0]; + if (cu->pos > 0) { + inserted_text[0] = findaccent(ef->textbuf[cu->pos - 1], ascii); + ef->textbuf[cu->pos - 1] = inserted_text[0]; } - accentcode= 0; + accentcode = 0; } - else if (cu->lenlen < MAXTEXT - 1) { if (alt) { /* might become obsolete, apple has default values for this, other OS's too? */ - if (ascii=='t') ascii= 137; - else if (ascii=='c') ascii= 169; - else if (ascii=='f') ascii= 164; - else if (ascii=='g') ascii= 176; - else if (ascii=='l') ascii= 163; - else if (ascii=='r') ascii= 174; - else if (ascii=='s') ascii= 223; - else if (ascii=='y') ascii= 165; - else if (ascii=='.') ascii= 138; - else if (ascii=='1') ascii= 185; - else if (ascii=='2') ascii= 178; - else if (ascii=='3') ascii= 179; - else if (ascii=='%') ascii= 139; - else if (ascii=='?') ascii= 191; - else if (ascii=='!') ascii= 161; - else if (ascii=='x') ascii= 215; - else if (ascii=='>') ascii= 187; - else if (ascii=='<') ascii= 171; + if (ascii == 't') ascii = 137; + else if (ascii == 'c') ascii = 169; + else if (ascii == 'f') ascii = 164; + else if (ascii == 'g') ascii = 176; + else if (ascii == 'l') ascii = 163; + else if (ascii == 'r') ascii = 174; + else if (ascii == 's') ascii = 223; + else if (ascii == 'y') ascii = 165; + else if (ascii == '.') ascii = 138; + else if (ascii == '1') ascii = 185; + else if (ascii == '2') ascii = 178; + else if (ascii == '3') ascii = 179; + else if (ascii == '%') ascii = 139; + else if (ascii == '?') ascii = 191; + else if (ascii == '!') ascii = 161; + else if (ascii == 'x') ascii = 215; + else if (ascii == '>') ascii = 187; + else if (ascii == '<') ascii = 171; } - inserted_text[0]= ascii; + inserted_text[0] = ascii; insert_into_textbuf(obedit, ascii); } @@ -1304,14 +1305,14 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) text_update_edited(C, scene, obedit, 1, FO_EDIT); } else { - inserted_text[0]= ascii; + inserted_text[0] = ascii; insert_into_textbuf(obedit, ascii); text_update_edited(C, scene, obedit, 1, FO_EDIT); } } else if (val && event == BACKSPACEKEY) { - if (alt && cu->len!=0 && cu->pos>0) - accentcode= 1; + if (alt && cu->len != 0 && cu->pos > 0) + accentcode = 1; return OPERATOR_PASS_THROUGH; } @@ -1327,7 +1328,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, wmEvent *evt) } /* reset property? */ - accentcode= 0; + accentcode = 0; return OPERATOR_FINISHED; } @@ -1345,7 +1346,7 @@ void FONT_OT_text_insert(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "text", "", 0, "Text", "Text to insert at the cursor position"); @@ -1356,18 +1357,18 @@ void FONT_OT_text_insert(wmOperatorType *ot) /*********************** textbox add operator *************************/ static int textbox_add_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_active_object(C); - Curve *cu= obedit->data; + Object *obedit = CTX_data_active_object(C); + Curve *cu = obedit->data; int i; if (cu->totbox < 256) { - for (i = cu->totbox; i>cu->actbox; i--) cu->tb[i]= cu->tb[i-1]; - cu->tb[cu->actbox]= cu->tb[cu->actbox-1]; + for (i = cu->totbox; i > cu->actbox; i--) cu->tb[i] = cu->tb[i - 1]; + cu->tb[cu->actbox] = cu->tb[cu->actbox - 1]; cu->actbox++; cu->totbox++; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -1383,7 +1384,7 @@ void FONT_OT_textbox_add(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable_font; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1396,20 +1397,20 @@ void FONT_OT_textbox_add(wmOperatorType *ot) static int textbox_remove_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_active_object(C); - Curve *cu= obedit->data; + Object *obedit = CTX_data_active_object(C); + Curve *cu = obedit->data; int i; int index = RNA_int_get(op->ptr, "index"); if (cu->totbox > 1) { - for (i = index; i < cu->totbox; i++) cu->tb[i]= cu->tb[i+1]; + for (i = index; i < cu->totbox; i++) cu->tb[i] = cu->tb[i + 1]; cu->totbox--; if (cu->actbox >= index) cu->actbox--; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data); return OPERATOR_FINISHED; } @@ -1426,7 +1427,7 @@ void FONT_OT_textbox_remove(wmOperatorType *ot) ot->poll = ED_operator_object_active_editable_font; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "The current text box", 0, INT_MAX); } @@ -1437,33 +1438,33 @@ void FONT_OT_textbox_remove(wmOperatorType *ot) void make_editText(Object *obedit) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; - if (ef==NULL) { - ef= cu->editfont= MEM_callocN(sizeof(EditFont), "editfont"); + if (ef == NULL) { + ef = cu->editfont = MEM_callocN(sizeof(EditFont), "editfont"); - ef->textbuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditbuf"); - ef->textbufinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "texteditbufinfo"); - ef->copybuf= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "texteditcopybuf"); - ef->copybufinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "texteditcopybufinfo"); - ef->oldstr= MEM_callocN((MAXTEXT+4)*sizeof(wchar_t), "oldstrbuf"); - ef->oldstrinfo= MEM_callocN((MAXTEXT+4)*sizeof(CharInfo), "oldstrbuf"); + ef->textbuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditbuf"); + ef->textbufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditbufinfo"); + ef->copybuf = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "texteditcopybuf"); + ef->copybufinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "texteditcopybufinfo"); + ef->oldstr = MEM_callocN((MAXTEXT + 4) * sizeof(wchar_t), "oldstrbuf"); + ef->oldstrinfo = MEM_callocN((MAXTEXT + 4) * sizeof(CharInfo), "oldstrbuf"); } // Convert the original text to wchar_t - BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT+4); /* length is bogus */ + BLI_strncpy_wchar_from_utf8(ef->textbuf, cu->str, MAXTEXT + 4); /* length is bogus */ wcscpy(ef->oldstr, ef->textbuf); - cu->len= wcslen(ef->textbuf); + cu->len = wcslen(ef->textbuf); - memcpy(ef->textbufinfo, cu->strinfo, (cu->len)*sizeof(CharInfo)); - memcpy(ef->oldstrinfo, cu->strinfo, (cu->len)*sizeof(CharInfo)); + memcpy(ef->textbufinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); + memcpy(ef->oldstrinfo, cu->strinfo, (cu->len) * sizeof(CharInfo)); - if (cu->pos>cu->len) cu->pos= cu->len; + if (cu->pos > cu->len) cu->pos = cu->len; if (cu->pos) - cu->curinfo = ef->textbufinfo[cu->pos-1]; + cu->curinfo = ef->textbufinfo[cu->pos - 1]; else cu->curinfo = ef->textbufinfo[0]; @@ -1473,28 +1474,28 @@ void make_editText(Object *obedit) void load_editText(Object *obedit) { - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; MEM_freeN(ef->oldstr); - ef->oldstr= NULL; + ef->oldstr = NULL; MEM_freeN(ef->oldstrinfo); - ef->oldstrinfo= NULL; + ef->oldstrinfo = NULL; update_string(cu); if (cu->strinfo) MEM_freeN(cu->strinfo); - cu->strinfo= MEM_callocN((cu->len+4)*sizeof(CharInfo), "texteditinfo"); - memcpy(cu->strinfo, ef->textbufinfo, (cu->len)*sizeof(CharInfo)); + cu->strinfo = MEM_callocN((cu->len + 4) * sizeof(CharInfo), "texteditinfo"); + memcpy(cu->strinfo, ef->textbufinfo, (cu->len) * sizeof(CharInfo)); - cu->len= strlen(cu->str); + cu->len = strlen(cu->str); /* this memory system is weak... */ if (cu->selboxes) { MEM_freeN(cu->selboxes); - cu->selboxes= NULL; + cu->selboxes = NULL; } } @@ -1505,35 +1506,35 @@ void free_editText(Object *obedit) /********************** set case operator *********************/ -static EnumPropertyItem case_items[]= { +static EnumPropertyItem case_items[] = { {CASE_LOWER, "LOWER", 0, "Lower", ""}, {CASE_UPPER, "UPPER", 0, "Upper", ""}, {0, NULL, 0, NULL, NULL}}; static int set_case(bContext *C, int ccase) { - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; wchar_t *str; int len; - len= wcslen(ef->textbuf); - str= ef->textbuf; + len = wcslen(ef->textbuf); + str = ef->textbuf; while (len) { - if (*str>='a' && *str<='z') - *str-= 32; + if (*str >= 'a' && *str <= 'z') + *str -= 32; len--; str++; } if (ccase == CASE_LOWER) { - len= wcslen(ef->textbuf); - str= ef->textbuf; + len = wcslen(ef->textbuf); + str = ef->textbuf; while (len) { - if (*str>='A' && *str<='Z') { - *str+= 32; + if (*str >= 'A' && *str <= 'Z') { + *str += 32; } len--; str++; @@ -1562,7 +1563,7 @@ void FONT_OT_case_set(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "case", case_items, CASE_LOWER, "Case", "Lower or upper case"); @@ -1572,17 +1573,17 @@ void FONT_OT_case_set(wmOperatorType *ot) static int toggle_case_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - Curve *cu= obedit->data; - EditFont *ef= cu->editfont; + Object *obedit = CTX_data_edit_object(C); + Curve *cu = obedit->data; + EditFont *ef = cu->editfont; wchar_t *str; - int len, ccase= CASE_UPPER; + int len, ccase = CASE_UPPER; - len= wcslen(ef->textbuf); - str= ef->textbuf; + len = wcslen(ef->textbuf); + str = ef->textbuf; while (len) { - if (*str>='a' && *str<='z') { - ccase= CASE_LOWER; + if (*str >= 'a' && *str <= 'z') { + ccase = CASE_LOWER; break; } @@ -1605,7 +1606,7 @@ void FONT_OT_case_toggle(wmOperatorType *ot) ot->poll = ED_operator_editfont; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************** Open Font ************** */ @@ -1614,27 +1615,27 @@ static void font_ui_template_init(bContext *C, wmOperator *op) { PropertyPointerRNA *pprop; - op->customdata= pprop= MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); + op->customdata = pprop = MEM_callocN(sizeof(PropertyPointerRNA), "OpenPropertyPointerRNA"); uiIDContextProperty(C, &pprop->ptr, &pprop->prop); } static int font_open_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } static int font_open_exec(bContext *C, wmOperator *op) { - struct Main *bmain= CTX_data_main(C); + struct Main *bmain = CTX_data_main(C); VFont *font; PropertyPointerRNA *pprop; PointerRNA idptr; char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - font= load_vfont(bmain, filepath); + font = BKE_vfont_load(bmain, filepath); if (!font) { if (op->customdata) MEM_freeN(op->customdata); @@ -1645,7 +1646,7 @@ static int font_open_exec(bContext *C, wmOperator *op) font_ui_template_init(C, op); /* hook into UI */ - pprop= op->customdata; + pprop = op->customdata; if (pprop->prop) { /* when creating new ID blocks, use is already 1, but RNA @@ -1664,7 +1665,7 @@ static int font_open_exec(bContext *C, wmOperator *op) static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - VFont *font=NULL; + VFont *font = NULL; char *path; PointerRNA idptr; @@ -1673,14 +1674,14 @@ static int open_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) font_ui_template_init(C, op); /* hook into UI */ - pprop= op->customdata; + pprop = op->customdata; if (pprop->prop) { - idptr= RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop); - font= idptr.id.data; + idptr = RNA_property_pointer_get((PointerRNA *)pprop, pprop->prop); + font = idptr.id.data; } - path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0)? font->name: U.fontdir; + path = (font && strcmp(font->name, FO_BUILTIN_NAME) != 0) ? font->name : U.fontdir; if (RNA_struct_property_is_set(op->ptr, "filepath")) return font_open_exec(C, op); @@ -1704,10 +1705,10 @@ void FONT_OT_open(wmOperatorType *ot) ot->cancel = font_open_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | FTFONTFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* delete operator *********************/ @@ -1721,12 +1722,12 @@ static int font_unlink_exec(bContext *C, wmOperator *op) uiIDContextProperty(C, &pprop.ptr, &pprop.prop); - if (pprop.prop==NULL) { + if (pprop.prop == NULL) { BKE_report(op->reports, RPT_ERROR, "Incorrect context for running font unlink"); return OPERATOR_CANCELLED; } - builtin_font = get_builtin_font(); + builtin_font = BKE_vfont_builtin_get(); RNA_id_pointer_create(&builtin_font->id, &idptr); RNA_property_pointer_set(&pprop.ptr, pprop.prop, idptr); @@ -1751,15 +1752,15 @@ void FONT_OT_unlink(wmOperatorType *ot) static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata)) { - Curve *cu= (Curve *)ecu; - EditFont *ef= cu->editfont; - char *str= strv; + Curve *cu = (Curve *)ecu; + EditFont *ef = cu->editfont; + char *str = strv; - cu->pos= *((short *)str); - cu->len= *((short *)(str+2)); + cu->pos = *((short *)str); + cu->len = *((short *)(str + 2)); - memcpy(ef->textbuf, str+4, (cu->len+1)*sizeof(wchar_t)); - memcpy(ef->textbufinfo, str+4 + (cu->len+1)*sizeof(wchar_t), cu->len*sizeof(CharInfo)); + memcpy(ef->textbuf, str + 4, (cu->len + 1) * sizeof(wchar_t)); + memcpy(ef->textbufinfo, str + 4 + (cu->len + 1) * sizeof(wchar_t), cu->len * sizeof(CharInfo)); cu->selstart = cu->selend = 0; @@ -1768,19 +1769,19 @@ static void undoFont_to_editFont(void *strv, void *ecu, void *UNUSED(obdata)) static void *editFont_to_undoFont(void *ecu, void *UNUSED(obdata)) { - Curve *cu= (Curve *)ecu; - EditFont *ef= cu->editfont; + Curve *cu = (Curve *)ecu; + EditFont *ef = cu->editfont; char *str; // The undo buffer includes [MAXTEXT+6]=actual string and [MAXTEXT+4]*sizeof(CharInfo)=charinfo - str= MEM_callocN((MAXTEXT+6)*sizeof(wchar_t) + (MAXTEXT+4)*sizeof(CharInfo), "string undo"); + str = MEM_callocN((MAXTEXT + 6) * sizeof(wchar_t) + (MAXTEXT + 4) * sizeof(CharInfo), "string undo"); // Copy the string and string information - memcpy(str+4, ef->textbuf, (cu->len+1)*sizeof(wchar_t)); - memcpy(str+4 + (cu->len+1)*sizeof(wchar_t), ef->textbufinfo, cu->len*sizeof(CharInfo)); + memcpy(str + 4, ef->textbuf, (cu->len + 1) * sizeof(wchar_t)); + memcpy(str + 4 + (cu->len + 1) * sizeof(wchar_t), ef->textbufinfo, cu->len * sizeof(CharInfo)); - *((short *)str)= cu->pos; - *((short *)(str+2))= cu->len; + *((short *)str) = cu->pos; + *((short *)(str + 2)) = cu->len; return str; } @@ -1792,8 +1793,8 @@ static void free_undoFont(void *strv) static void *get_undoFont(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_FONT) { + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_FONT) { return obedit->data; } return NULL; diff --git a/source/blender/editors/datafiles/CMakeLists.txt b/source/blender/editors/datafiles/CMakeLists.txt index b27901c2667..dc441c41664 100644 --- a/source/blender/editors/datafiles/CMakeLists.txt +++ b/source/blender/editors/datafiles/CMakeLists.txt @@ -64,6 +64,7 @@ if(WITH_BLENDER) inflate.png.c layer.png.c lighten.png.c + mask.png.c mix.png.c multiply.png.c nudge.png.c diff --git a/source/blender/editors/datafiles/mask.png.c b/source/blender/editors/datafiles/mask.png.c new file mode 100644 index 00000000000..78a2e1a0352 --- /dev/null +++ b/source/blender/editors/datafiles/mask.png.c @@ -0,0 +1,400 @@ +/* DataToC output of file */ + +int datatoc_mask_png_size= 12593; +char datatoc_mask_png[]= { +137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, + 0, 0, 96, 0, 0, 0, 96, 8, 2, 0, 0, 0,109,250,224,111, 0, 0, 0, 1,115, 82, 71, 66, 0,174,206, 28,233, 0, 0, 0, + 6, 98, 75, 71, 68, 0,255, 0,255, 0,255,160,189,167,147, 0, 0, 0, 9,112, 72, 89,115, 0, 0, 11, 19, 0, 0, 11, 19, 1, + 0,154,156, 24, 0, 0, 0, 7,116, 73, 77, 69, 7,220, 3, 25, 18, 46, 48,241,229, 90,175, 0, 0, 32, 0, 73, 68, 65, 84,120, +218,237,189, 89,172,101,217,113, 37, 22, 17,123,159,115,231,225, 13,249,114,100,101, 85,102,205, 44, 22,103, 82,148,186, 53,160, +219,114, 55,220,238, 54, 96,160, 1, 15,253, 39,209,128, 13,201, 18,108,195, 48,208,147, 97,255,248,195,250, 51, 12,248,211, 31, +254, 50, 96, 3, 22, 4, 75,178,196,110, 81, 18, 41,137, 44,146, 53,207, 89, 85, 57,231, 27,239,124,206,217, 59, 34,252, 17,123, +159,251,146,173,238, 22, 69,181,236, 6, 58,137,202,122,204,151,239,189,123,227,196,142, 88,177,214,138, 93, 0,255,230,215,191, +249,245,231,254, 69, 0,254, 47,246, 59, 94, 57,216,255,155, 63,247, 83, 63,245,197,207, 58, 71,239,124,240,241,111,125,243,143, +190,243,218,155,255,250, 6,168, 68,196, 31,255,187,116, 59,229,115, 55,174,255,221,127,231,223,250, 15,255,189,191,113,176,191, +171, 12, 77,108,132, 5,145, 8,225,206,131,195, 63,252,238, 15,254,239,223,251,214, 43,175,191, 61, 91, 44,215,155,170, 9,225, + 95,139,232, 56, 4, 5,248,113, 3,244,210,179, 55,255,135,255,230,151,127,250,203,159, 39,162,170,170, 69, 21, 16, 16, 0, 17, + 68, 85, 4, 64, 21, 16, 68,228,240,228,236,225,209,241, 15,222,122,239,221, 15, 63,126,227,189, 91,175,190,253,238, 98,185, 38, + 68, 81,253,255,103,128, 60, 66,212, 31,251,136,125,238,211,207,254,252, 95,249,234,186,170, 81,165, 44, 10, 86, 81, 85, 85, 5, + 0, 79, 32, 4,202,202, 42, 34, 58, 30,244,203,194, 95,218,223,251,185,175,126,113, 85,109,142, 79,231,179,229,242,209,225,113, +217, 41,189, 35, 22, 93, 44, 86, 15, 14,143,155, 16,126,240,214,123, 39,103,179, 15, 62,185, 43, 34,255, 31, 6, 8, 1, 17,244, +199,205,160, 95,251,251,191,250,111,255,204,215, 28,225,160, 55, 24,244, 58,190,240,222, 57, 21,101, 21, 21, 5, 85, 1, 80, 80, +142, 28,133, 67, 19,171,186, 14, 33, 70,230, 58,132, 16, 34,139,212, 77,216,108,170,251,135,135,227,225,176,137, 81,132,189, 47, + 8,177,105,194,163,211,179,183,223,251,240,253,143,238,188,255,241,237,249,114, 85,213, 53,243, 95, 94,200, 10,196,168,250,227, +102,144,130, 30,159,206,155, 80, 75,228, 94,175, 51, 28,244,167,163,209,112, 56,232, 20, 37, 17, 1, 0,168,138, 48, 18, 57, 0, +245,208, 1,116, 46,132, 24,137,200,145,107, 66, 32,194,126,183, 51,157,142,234,186, 9, 33,206,150,203,208,196,154,163, 34, 93, +220,221,185,244,147, 95,250,217,175,125,105,189,169, 30, 30,157,124,248,201,157,143,238,220,127,255,163,219,247, 30, 30,254, 37, + 4, 72, 65,127,220, 26, 84,120,255,255,252,111,255, 51, 33,174,215,235, 38, 4, 21, 65, 66, 36, 44,156,159,142, 71, 7,251,123, +163,193,192, 17, 17, 33, 34, 54,129, 3, 71, 17,101, 97,142, 28, 66, 12, 49,134, 16,152, 37, 8,139,168,136, 48, 51,179,136, 74, + 93, 55,103,139,165,136, 32,145,138,198,200,145,153,133,171,186, 89,173, 54,143,142,143,191,247,230, 59,175,188,246,206,114,189, +254, 87, 91,164,245,207, 21,160,126,175,251,196,149, 75,255,217,223,251,187, 63,255,211, 63, 1, 42,145,229,232,248,100,181, 89, + 51,139,168,130, 10, 32,136,168,170, 14, 7,253,253,221,157,157,201,100,216,239,119,202, 82, 68,154, 16,154,200,194, 18,153,153, + 99,136, 49,178,216, 97, 99, 17, 97, 86, 80, 17,101, 22,102,110, 98, 92,172,214, 42, 28, 35, 43, 40,179,178, 8,139,196, 16, 99, +140,171,205,230,187,175,189,253,135,175,188,122,116,122, 22, 66,252, 87,115,202,126,196, 0,245, 58,157,191,243,243, 63,243,183, +255,250, 79,127,233, 51, 47, 14,135,253,162, 40,188,115,170, 50, 95,172, 14,143,142,207,206,102,117,180,108, 0, 5, 5, 80,102, +142, 28,157,243,163, 65,127,111,103,186,191,179, 51, 29,143, 89, 53, 70,110, 66,104, 66, 96, 22, 97, 14,145, 67, 12, 44, 18, 34, + 3, 64,136, 49,215,122, 21,213, 24, 67, 85, 55, 44, 50, 95, 44, 3, 51,179, 16, 33,139,138,112, 12,188, 90,111,222,185,245,241, +235,111,127,240,254,199,183, 23,171,191,224,132,242, 63,210, 17,251,143,255,206,223,252, 79,254,163,127,255,226,133,221,162,240, +222, 57,231, 92,225,189, 35, 42,138,162, 44,156,170,206, 22,171, 7, 15, 31, 29,159,158,213,117, 19, 56, 10,139,128, 10,139,168, +138,176, 34, 56,162,209, 96,112,237,242,229,131,253, 93, 71,142,133,215,155,166,174,235,200, 28, 35, 71,142,129, 69, 85,153, 57, +198, 40, 98,136, 1, 1, 0, 9, 17, 32, 50, 87,117,243,201,221,251, 31,220,190, 55, 25, 15, 7,189, 94,233, 41, 68,174,235,176, + 92,173, 14,143, 79, 95,125,251,189, 63,121,245, 45,254, 11,237,125,238,207, 82,104,254,234,151, 63,247,191,254,218,127,251, 31, +252,237,191, 49, 28,244, 58,101,217, 43, 59,157,178, 44, 75,239,156, 35, 34, 80, 21, 81, 64, 28,244,187, 23, 47,236, 95,184,176, +215,235,118, 61, 17, 2,168,193, 34, 68, 4, 36, 0, 17, 93, 87,155,251,143, 30, 61, 60, 60,226, 40,157, 78,217,239,118,187,221, +210,130, 34, 42,106, 85, 93, 65, 21,136,208,226,131, 8,133,247,138, 72,136,101, 81, 92,185,120,240,189, 55,222,123,243,131,187, +203,229,154,136,122,221, 78, 81,250,194, 23,253, 94,247,242,193,222, 51, 79,125,234,108,190, 88,174, 55, 34,250,151, 17,160,159, +252,194,203,127,255,151,126,225, 31,252,242, 47,236, 77, 39, 44,210, 41,203, 94,183,219, 41, 11,239,124,225,157,119,228,200, 57, + 34,116,132, 0,204,202, 44,142,220,100, 52,220,223,219,221,157, 76, 7,131,129, 67,140, 81,132, 89, 84, 9,145, 16, 17,176, 9, +225,232,228,244,209,209,241,106,179, 70,194,241,104, 56, 26,244,189,243,160, 26, 89, 84, 5, 16,136, 44, 62, 10, 0, 68,148,122, + 34, 0,139,120, 71,127,252,131,183,215, 13,156, 45, 86, 77, 19,250,101,209,235,117, 11,239,188,247,253,110,231,169,171,151,167, +227,225,166,170,255, 66, 78,220,191, 40, 64,255,248, 87,191,254,223,255, 87,255,233,139,207,222, 96, 22,116,212,237,116,122,157, +162,244,222,121,231,136,156, 35, 76, 15, 25, 17,192,158, 87,219,140,132,197,123, 63, 26, 14, 47,238,239,237,239,239, 2,226,102, +179, 9, 33, 32, 17,145, 35, 0,203,154,229,106,125,116,122,122,120,116,196, 34,211,241,100, 52, 26,140,122, 3, 34,140,204, 25, +147,131,115,132,136,136,132,132,150,100,139,229,250,251,111,190,227,203,126, 8, 50, 91,110,230,171,181, 39, 28, 13,123,190, 40, +156, 67, 95,248,201,104,112,241,194,206,160,223,187,247,232, 72,127, 60,164,238,254,212,113,236,197,103,158,250, 63,255,151,255, +241,223,253,235, 63,163,160, 8,232,189,235,149,101, 89,122,239, 28,165,255, 33, 0, 64,142,140, 77, 20,246, 82, 84, 5, 0, 20, +193, 58,142,136,118,139,242, 96,127,111,127,119, 39,196,184,217,108,212,106, 4, 17,139, 48,115, 8,177,106,234,163,227,211, 7, +135,143, 98,148,178, 44, 38,163,225,100, 60,244, 68,145,197,219,147, 0, 34,239, 64, 84, 85, 64,245,116,190,248,254, 91,239,249, +162, 71,100,199, 54,158, 45,215,132, 48, 25,116,189,243, 68, 72,132,165, 47, 38,195,193,181,203, 23,142, 78,102,235,170,254,243, + 7,232,215,254,225,127,113,253,137,107, 79, 94,187,226, 9,143, 78,206,188,119,255,229,215,255,222,255,244,223,253,215, 87, 46, + 29,196,200, 4,232,156, 43,156, 47, 82,218,144, 35, 71,132, 86,221,109,168, 72,205,198, 42, 17,168, 69, 7, 84, 21, 17, 1, 4, +145, 35,139,106,183,211, 61,216,223,223,155, 78, 17,161, 14, 33,132, 64,136,142, 40,229, 29,115,213, 52, 39,167,167, 71,199, 39, +179,197, 66, 68,119,166,227,221,233,164, 44, 11, 68, 68, 4, 67,230,162, 10, 10, 15,143, 79, 94,123,251,195,178,219,107, 39,129, + 16,101,185,169, 75,143,147, 97,151, 28, 2, 32, 32, 16,162,247,238,234,193,133,194,187,163,211,217,159,111,232, 67,253,232, 59, + 77,136,204, 92,133,112,120, 54,155,205, 22,220,196,253,233,100,127,111,167, 91,250, 38,114,100, 86, 21, 68, 44,138,162,244,222, + 59,135, 4,170, 32, 6,122, 84, 69, 68,196, 94,186,168,130,162,170, 42,138,178, 77,162, 8, 42,160,168,168,160, 8, 4,132,168, + 85, 93, 29, 30, 30,223,185,119,255,108,177, 4, 0, 68, 20, 73,200,200, 57, 71,228,188,247,189,178,188,124,233,226,181, 43,151, +139,162,136,145, 87,171,213,201,124,217, 52, 13, 34,126,227, 91,127,242,141,111,191,218, 29,140, 69, 84, 68,115, 89,135,241,160, +243,194,147, 23, 15,118, 71,145,185,105,194,166,106,150,235,213,114,181,158, 47, 86,199,179,197,239,127,231,213,170,254,145,137, + 4,247,143,255,243, 95, 36, 66,239, 92,233,253,238,120,120,237,224,194,181, 43, 23, 59,157,114,190, 88,204, 87, 27,239,208, 59, +135,136,162,192,145,155, 24, 34, 11, 88,166, 67,206, 29, 59, 94,246,112, 1, 44, 68, 66,136,144, 43, 19, 2,170,253, 63,101,225, +200,140,232,198,227,241,254,222,238,100, 60,138, 49,134, 24, 1,208, 17,121,231, 17, 73, 69, 16, 49,114, 60,155,205, 30, 28, 30, +198, 24,250,189, 94,127,208,159, 14,250, 68, 24, 99,252,245,223,253,102,132, 18,209, 65,198, 41, 10, 10,170,117,224, 16,227,184, +223,233, 90,222,217,184,160, 64,132,158,232,210,133,189,179,197,234, 71, 61,110,238, 31,253,202,215, 49,195, 13,123, 63,162,236, +200,141,134,131, 94,167,136, 44,136,168, 2,136, 72,206, 17,162,136,132, 40,204, 81, 1, 16,208,158,161,106, 62, 93, 0, 32,170, +132, 0,160,162,168, 10, 22,169,246,219,171, 42,128,136,196, 16, 85,180, 44,203,233,100, 50, 26, 14,156,163, 24,153, 69,156, 53, + 44, 4,102, 97,225, 58,132,147,179,217,225,209, 73, 85, 53,174,240, 23,118,119,231,203,213,111,252,147,111,117,186, 35, 5,177, + 16,164,111,141, 8, 10,117, 19, 17, 97, 58,234, 23,158, 0, 65, 85, 81,237,147, 74, 72,211,209,128,153,103,139,213,143, 18,160, + 95,253, 58, 2, 40, 32, 40, 16, 18, 37,150, 8, 69,212, 57, 87, 22, 69, 89,248,162,240, 10,200,145, 53, 63, 22, 80, 96,102, 11, +138,170, 68, 81,102, 86,145, 92, 19, 16, 64, 17, 84, 9, 1,183,121,148, 2,164, 96,167, 81, 88, 89,152, 69,200,185, 94,183, 59, + 25,141, 60,185,170,174, 68,132,136,114,121, 18,142,177, 9, 97, 54,155, 61, 60, 58, 90, 46, 87,223,252,147,239, 31, 45,106, 69, +159,242, 21, 83,169, 64, 64, 4, 16,149, 38, 72,191,231,199,253,126,226,165, 64, 21, 64, 24, 0,212, 17,142, 6, 61, 66, 60,153, + 45,254,204, 71,236, 87,190,174,130,144,135, 3,201,111,144,136, 88, 4, 17, 16, 81, 21,188,195,162,112, 32, 18, 36,218,160,160, +104, 71,199, 90,151, 48, 75, 84, 54,244, 12,170, 8,104,121,100,245, 90, 45, 76,185, 78, 10,231, 83,169, 54,237, 91, 41,131,110, +167, 59, 29,143, 17,145, 99, 20, 21, 0,116,206, 57,231,197,176, 67,228, 15, 62,185,253,221, 55,222,163, 98,160, 10, 10, 98, 49, + 71,235, 25,168,136, 0, 64, 10,136,174, 24,247,138,110,199,111, 19, 95, 5, 80,173, 41,247,186, 69,100,158, 45,254, 76, 40,201, +171,164,145, 21, 17, 65, 21, 53,189,103, 5, 1, 85, 64, 4, 0, 81, 81, 81, 34,232,148,157, 78,217,169, 67, 88,173,214, 85, 85, + 7, 23, 74,239,189, 47, 12,166, 32,163,168,130,168,160, 58,114, 4,132,136,160,160,136,160,106, 72, 32, 85, 5,220, 6, 75,211, + 59, 68, 34,136,172, 10, 56,158, 76,167,147, 73, 93,215,203,213,106,190, 92,104,132, 78,167,195, 28, 79, 78,103,111,127,120, 7, +253, 0, 0, 9, 65,137, 4, 0, 65, 64,132, 0, 21, 64, 64, 17,129, 57, 10,116,119, 46, 92,190,121,101,119, 60, 24,140,199,163, + 77, 85,253,246, 55,255,240,222,195,135,221, 78,135, 89, 68,251, 79, 63,113, 89, 68,239, 60, 56,250,151,103,208, 63,252,229,175, + 35, 42,171, 88,111, 20, 20, 64, 0,123, 71,160,136, 8,136,204, 18, 57,178,218, 35,130,210,251,110,167,116,206,213,117, 8, 28, +153, 25,144,108, 60,179, 20, 68, 36, 1, 5, 67,122, 68,233,123,105,142,142,164,118,151, 32, 66,250, 64, 82, 14,131,138,104, 20, + 1,128,110,183,187, 55,157,122,143,171,213,230,248,116,254,198,251,159,172, 2, 81,209, 71, 32, 53,174,230, 49, 12,135,136,136, +138,136, 80,215,245, 19, 79, 60,245,181,207, 62,255,252,211, 79,142,135,131, 65,183,123,229,226,193,157, 7, 15, 23,203, 37, 33, + 8, 40, 42,244,123, 37, 0,252, 75,243,200,253,163, 95,249, 5, 80,112, 68,169, 25,229, 39,110, 96,198,248,101, 3,124, 4,168, +138, 77,140,222,185, 16,195,173,247,223,186,117,235,221,201,100,119, 83, 55, 77, 19, 12, 79,251,194, 39,248, 75,132, 72,138, 96, +236, 7,110,115,242,241,246,151,161,148,228,194,148,195,136,170, 26, 88, 86,235,245,253,135, 15, 23,155,230, 7,239,126,188,137, +206,151, 67,109,171, 28,218,247, 86, 64, 68, 36,235,150, 96, 79, 52, 70,162,226,230,245, 43,251, 59, 35, 66,138, 49,246,187,221, +213,122, 29, 35,175, 18, 82, 85, 80, 44,189, 99,150,197,186,250, 23,102,208, 47,253, 98, 10,141, 42, 40,160, 34, 42,168,181,132, +116,184,149, 69, 85,149,144,236, 51,143, 30,220,249,157,223,249,141,223,255,131,127,250,250, 59,239,124,239,141,183, 30, 29, 29, +158,204,102, 49, 74,183,215, 85,171,244,132,169, 58,180,228, 28,128, 64, 30, 69, 19, 21,171,118,236, 84, 18,148,201, 88, 1,236, + 3,102, 94,173,215, 15,142, 78,222,189,253,232,253, 59,199, 88, 12,193,119, 53,149,101,235, 76,154, 19, 7,242, 56, 96,179, 15, + 32,185,200,124, 97,239,194,147,151,118, 59,133, 51,114, 10, 17, 15, 79,142, 39,195, 97, 19,226,122,179,177,147,221, 41,125, 19, +194,186,106,254,185, 1,250, 7,191,244,139,144,169, 51, 67, 43,219,188, 85,171,208,202, 34, 8, 64,132,170,240,222, 59,175,255, + 95,191,254,191,223,190,123,103,190,137,117,132, 16,195,201,201,201,189,123,247, 94,121,245, 7,155,170,222,155,238,218,240, 14, +128, 41, 49, 0, 16, 49, 1, 36, 27, 70,164,205,155,116,214, 64, 64, 64, 85, 84, 84, 67,140,155, 77,117,124, 58,191,251,224,240, +131, 59, 15, 62,186,127, 54,223,168,186,142, 0,165, 18,150,184,208,156, 47, 96, 49, 1, 66, 11, 89,250, 19,102, 30, 12, 39, 55, +175,237, 79, 70,125, 80,136,204,206,209,221,251, 15, 68,101, 50,234,139,192,114,181, 68, 84,102,233,150,197,186,170,235, 38,254, +243,142,216, 47,146, 29,102,205, 71,218, 78, 68,234,232,168,168, 42,106,104,230,173,183, 95,253,141,223,248, 63, 22,171,205,217, + 38,134,104,233, 5,145, 35,115,172,155,205, 27,111,189,245,224,240,112, 58, 25,151,101,199,158,171,136, 72,238,249,169,176,137, +138,170,128,178,176,209,105, 54,139,173,214,155,179,249,226,225,209,201,237,251,135, 31,220,126,120,235,222,209,189,227,213,108, + 45, 81,157,228,142,158,128, 58,100,228,131,104, 51, 15, 34, 34, 80,122,197,246, 15,130,136, 32,186,167,175, 95,189,180, 59, 34, +162, 24,153, 16, 31, 29,159,204, 23, 11, 64, 24, 15,135, 72,116,114, 58, 35, 68, 22,233,117,203,249,114, 29,255, 52, 69,192,163, +162,216, 19, 4,104,219, 22,166, 15, 17, 64,129,129, 28, 34,224,107,175,126,231, 55,127,235,215,231,235,106, 89, 9,171, 2,160, + 67, 66,194,200, 12, 0,157,162, 51, 30,234,155,111,191,246,232,232,225,207,124,237,175,124,249, 11, 95,212, 94, 79, 85,137, 80, +156, 71, 66,102,174,234,176,169,170,170,110,154, 38,212, 77,168,154, 80,213,205,166,110, 54, 85,179,174,194,166, 14, 85, 19,155, +168, 81,144,161, 16, 42, 20, 20, 68, 16, 69,137,128, 21, 9, 81, 72, 81, 17, 41,209, 75, 10, 68,168, 32,130,130, 72, 32,224, 64, +144,196,224,237,108,177,184,123, 56,251,204,141, 75,221,110,137,136,206,185,241,104,120,231,129,101,159, 94,187,120,224, 29,189, +243,193,199, 77,136,145,195,213,131,157, 91,119,143,254,217,121,205, 91,134,219,121, 86,177, 49, 43, 33,107,205, 40,149,128,222, +125,247,181,223,249,221,223,156,175,235, 69,165, 34,138,136,228, 8,145, 16,212, 38, 53, 68,236,117,251,136,184,152,159,125,235, + 79,190, 85,150,238,211,207,191,216,233,244, 68,117,185, 62, 59,157, 45,207,150,171,229,186,217,212, 49,176, 6, 22,102,136, 34, + 42,192,150, 83,130,162, 5,171, 87, 50, 81,156, 65, 88, 80, 21, 9,193,224, 24,161, 42,162, 32, 17,169,168,245, 71, 0, 16, 5, + 68, 2, 4, 82, 1, 84, 1, 4, 32, 82, 6, 93,173,151, 15, 79, 22,139, 77,211,237,150,142,136,153,119, 38,227, 68, 49, 33,176, +240,238,100,252,252,205, 39, 95,127,231,195, 16,155,241,160,119,121,111,124,247,104,246,207, 4, 72,117, 59, 37,144, 10, 32,106, +130, 38, 22, 53,116,238,238,157,143,190,241, 79,126,251,116,190,152,109,216,162,131, 8, 42,194,194,228,200,123,175, 98, 24, 27, +250,189, 62, 2,108,214,171, 87,223,120,141, 89,118,247, 14, 78, 23,155,227, 89, 85, 51, 50, 56, 1,175, 90, 88, 30, 39, 60,141, +162,100, 69, 73, 0, 5, 84,129, 5,208, 42, 19, 90, 63, 69, 80,131,171,152,187,148, 69, 68, 82, 15, 17, 16, 1, 36, 18, 1, 66, + 1, 2, 1, 4, 38, 4,142,124,124,182, 60, 91, 86,123,211,129,247,174, 9, 97,103, 50,113,206,133, 16,140,132, 67,196, 97,191, +251,185, 79, 63,253, 71,223,123,189, 14,113,111, 50,156,175,171,197,250,177, 97,141,196, 90,170, 0, 38,188,168,153,202, 0, 69, +112,228,142, 15,239,255,246,111,253,250,221, 7, 15,102,107, 22, 27, 54, 82, 43, 6, 52, 38,203,200, 44, 66, 36,116,206,247,122, + 3,239,203,135,143, 78,222,249,240,246, 91,183, 30,220, 61,174,215,220,139, 52, 84, 26,130,235, 40, 21, 72, 78,193, 41, 32, 0, +129,149,222,196,181, 98,254,225,248,152, 60,149,123, 84,170,201, 96,188, 36,145, 1, 31,227, 51, 17,173,121,230,151,100, 51,142, +156,206, 23,199,243,141,205, 46,136, 56,232,247,247,119,118, 34,139,170,138, 48, 17, 25,193,245,153,231,158,222, 25,143,201,193, +165,189, 81,233,233,113,131, 7,218,147,178,246, 10, 54, 57,128, 2,145, 18,210, 98, 53,251,221,111,252,230,199,119,110, 47, 42, + 97,201,120, 15, 1,200,130,226,136,200, 57,135, 8, 72,142,136, 68,121,179,169,231,171, 64,229,180, 59,249, 20, 23, 83,245, 35, +112, 93, 64,159,200,181, 68,240,181, 40, 72,218, 97, 83,236,243,162, 86,211, 13,221, 67, 26, 35,172,232, 3, 2, 18, 32, 26,150, +160, 54, 26, 54, 68,218,169, 67, 36, 50, 16,143,132,243,249,252,209,201,178, 9,146,120, 91,196, 27,215,159, 16,137, 34,169,232, + 18, 82, 81,184,178,244,207, 92,191, 54, 26, 14, 75,239,119, 70,253,199, 2,148, 49, 33,138,162, 72, 26,203, 5, 84, 20,153,229, +123,223,253,163,247, 63,252, 96,182,225, 38,170,136, 1, 61,123, 31,144,232, 46,251,152,188,170, 10,235,201,233,106,213,224,149, +167, 94,124,250,165,159, 40, 6,123, 64, 29,116, 30, 0,182, 19,125,251, 68, 0,108, 56,202, 29, 95,114,159,202,236, 69, 27, 25, + 72, 37, 40,145, 96,246,108, 16, 16, 93,138, 17, 16,218,168, 66,214,210,210, 41, 36,164,229,106,113,182, 14,243,213,198,178, 6, + 16,246,119,119,203,162,100, 97,251,177,228, 8, 1, 10,231, 58,101,241,252,205,235,101, 89, 78, 6,157,110,185,101,162, 73, 5, +243,120,169,138, 96,152, 13, 81, 29,209,131,251,119, 94,249,222,119,102,171,170, 10,146, 30,188,253,120,178, 17, 34,209,181,162, +138, 8, 49,198,227,211,121,209,155,188,248,217,159,186,246,212,103, 92,103,128,232, 0, 16, 68,129, 82, 76, 53, 5, 55, 13, 97, +154,138, 29,182, 4, 0,160, 98, 14, 25,180,163, 90, 14, 48, 16, 81,154, 73, 91,134,198,114,200,190, 77, 26,233, 18, 96, 65, 4, + 36, 85, 57, 91, 86,103,203,106, 83,109, 66, 12, 10, 64, 8,189,110, 23, 84, 89, 88, 84,237, 75,139,194, 59, 79,157,162,120,225, +230,245, 78,183,115,176, 51, 56, 39,141, 33, 96, 70,247,249,177, 42, 40, 53,161,249,214, 31,126,227,232,228,116, 85,177, 61, 88, +103, 47,133,128,192,164,118,200,209,193,166, 14,103,139,245, 96,122,241,233, 23,190,212, 29,236, 8,230,153,194, 10,172,102,106, + 84,209, 10,112, 62,104,231, 70, 48, 1, 61,231,171,104, 99, 9, 9,186, 42, 25,242, 68, 74, 99,139, 53, 19, 76,104,150, 0, 24, + 17,136, 64, 4,128, 0, 25, 21,136, 32,132,250,116,190,120,112,124, 54,238,193,199,119,238,188,254,198,155,235,170,218,153,238, +150,101,167,170,107,145, 8,228, 16,144, 8, 11,239,188,119,189,110,241,228,213, 75,111,190,255,225,238,176,115,178,172, 83, 23, +203, 61, 69,236,172, 41,128, 3,122,231,173,239,189,253,222, 59,235, 70, 76,195, 68, 74,133, 16,115,102, 3,128,138, 16, 98, 8, + 97,190,170,250,227,131,231, 62,253,149,162, 55, 81, 36, 4, 32, 84,117,100,143,168,213, 21,176, 29, 47,242, 56,140,128,134,162, + 21,100, 11,145, 21, 53,227,202,156,110,152, 38,103,181, 79,167,176,137,161, 53,235,172, 9, 94, 43, 18,102,214, 6, 84,228,244, +228,240,149, 31,156,125,251,247,238,220,250,228,147,186,105, 16,113,119,103,122,227,198,211, 69,225, 66, 35,145,163, 35, 23, 57, + 58,242,142,160,240,126, 50, 26, 60,113,229, 82, 8,119, 23, 85, 19,162,146, 81,202,170, 10,138,204, 42, 34, 8, 48,159, 29,127, +231,187,223,174,234,176,174, 35,171,154,104,151, 11,159,133, 7, 65, 0, 0, 69,120,179,105, 38,187, 23,159,255,204, 87,202,193, + 14, 32, 97,126,234, 9, 63,232,214, 44,145,206,151, 90, 45, 78, 84,127,166,137,180,157,114,236, 11, 19,243, 14,231, 40,183,182, +106, 19,110, 11, 26,108,203, 78, 26,204,206,215, 60,132,179,211,135, 77, 61,103,137,227,241,168, 40, 60,128, 30,159,156,190,247, +222,187, 32,210,233,116, 16,144,133,173, 24, 19,146, 47, 60, 33,236, 78, 70, 87, 46,236, 14,187, 37, 0, 16, 11, 88,241,117,142, + 76,204, 9,129,223,126,231,245, 7, 15, 31, 44,106,177, 49,213, 89,197, 3, 32, 68,231,236,152,171,253,190, 90, 87, 69,111,114, +227,217,207,119,250, 83,176, 46,123,174, 61,195,246,253,106, 30, 51,108,114,149, 31, 98, 59,172, 8,230, 65, 43, 59, 79,172,222, + 65, 59,151,230,225, 52, 75,102, 89,148, 75,177,200, 31,183, 51, 7, 0,128,196, 64, 0, 23,246,247,171,122,227,189,183,220, 63, +155,205,222,122,251, 45,142, 77,175,215, 67, 36,208,164, 77,122, 34,239,136,136, 38,147,225,213,139, 83, 71, 72,153,171,227, 24, + 25,146,152, 55,123,247,157, 55, 23,171,122, 83,179,149, 24,218, 2,142,246,116, 41,168,174, 55,155,168,197,213, 39, 95,232, 12, +246,144, 60, 42,130,149,193,148, 65,210,118, 37, 61, 31, 39,115, 85,101,181, 72, 68, 64,243, 63,170, 91, 60,152,248, 0, 36,200, + 47,193, 10, 78,206, 20, 74,163, 88, 74,151, 54, 78,143,177, 68, 10,136, 16, 66, 64, 87, 76, 70,163,205,122, 9, 32,246,101,171, +245,250,181, 55,222,168, 54,235, 78, 89, 58, 71,128, 88,118, 74, 66,240,206,121,194,194,185, 75,251,211,189,201,128, 68, 88, 85, +140,132,110, 66, 0,132,143, 62,124,239,254,131,251,139, 42,170, 10, 32, 58,139, 13,128,115,206, 25,103,157, 11,243,170,138,151, +175,221,188,112,233, 41, 36,223,102, 76,139, 4,242, 75,180,122, 43,128, 2, 91, 38, 46, 27,245,180, 21, 28, 33,171, 94, 54, 40, +111, 99,164, 91,105, 51,255,249, 54, 85, 8,206,253, 9,230, 67,217,178,226,144, 80,129, 46, 87,155,203,151,175, 93,189,114,181, +174,106, 81,182,191,221, 52,245, 91,239,188,181, 92,206,187,221,174, 61,254,162, 44,157,119, 68,228, 29,129,226,205,107,123,148, +135, 82, 8, 49, 40,226,114,181,124,255,189, 55, 79, 23,171, 16,197,140,194,228, 8, 17, 28,145, 35, 66, 75, 18, 85, 85,157,175, +235,201,238,149,235, 55, 63, 67,190, 67,153,126,222,106, 35,144,186, 49, 32, 42, 40,182, 52,143, 49,134, 40,106,172, 62, 40,160, + 90,182,165,225,194,206, 26, 88, 37,126,252, 36,217, 55, 76,228, 3,225, 99,132, 71, 27, 83,204,173, 47,149, 63, 34, 35,238,181, +110,194,165,203, 87, 94,120,254,185,170,174, 57, 70, 80, 97,142,139,229,226,141, 55,223,184,127,255, 30,106,162,206, 13,153,123, +231,136,192,123, 67,151, 68, 65, 25, 16, 8,240,147,143,222,189,123,255, 94, 21, 68,218,218,156, 74,143, 81,167, 42,160, 72,184, + 88,109,168,232,223,120,238,101,215, 29,166, 44,223, 82, 15, 70,125,146,230,198,101,129,201,186,177, 40,136,242, 86,144, 77,111, + 3, 83, 85, 23, 52, 54, 17, 21, 91,247,139,106,134, 60,233, 41, 24, 32,180, 63, 49,204,152, 19, 24,183,124, 49, 24, 14,232,120, + 34, 66,211, 55,235, 42, 76,199,187,159,123,233, 37, 5,105,154, 42,114,108, 98, 88,174, 22, 31,220,122,255,193,195,251,161,169, + 69, 4, 53,149, 90,231, 28, 1,146,130,134, 24, 81, 1, 17,103,243,179,219,183, 63, 58,157,205,155, 8,162,169, 95, 16,128, 79, +199, 61,113, 45,155,170, 94,172,195,229, 79, 61, 51,154, 94, 74, 13, 85,206, 29, 42, 4,123,159,208,146,100,118,156, 12,167,139, +182,230,168, 45,107,159,186,214, 22, 25,106,202,132,124,220, 0, 64,145,218,115,148, 19, 42,231,145,185,107,218, 47,215, 86,129, + 43, 28,141,122,142,208,100, 38, 21,213,117, 85,119,123,195,231,158,121,166,219,233,198, 24, 29, 0,139,172, 55,155,187,247,239, +158,156, 28, 54,205,198,202,158,185, 73,144,144, 68, 1, 8,152,185, 14,225,225,195,187,247,239,223, 91, 53, 34, 34,154,136, 40, +176,137, 46,177,130,128,194,114,114,182, 30, 78, 15, 46, 63,241, 28,144,183, 34, 35,231,102,204,115,125, 41,199, 67,212,212,197, +196,182,110, 57, 23,221,150,239, 68, 45,131, 97,115, 72,180,180,133,202, 10, 77,150,120,182,236, 94,155, 81,127,138,162,174,170, +128, 56,234, 22,147,190, 7, 5, 81,105, 31, 78,221, 52,131,222,240,169, 39,175,239, 76,198,166, 42,199, 24, 23,203,229,221,251, + 15,142,143,143, 29, 1, 2, 58, 66,231,200, 33,250,200,204,204, 10,202, 49, 62,186,127,247,248,228,180, 9,233, 29, 16,168, 67, +114,137,221, 72, 63,114,185,170, 3,184,235, 55, 62, 93,118, 71,204, 2, 96,102,141,220,162, 50,182,177,174,174,208,198, 70, 90, +193, 48, 71, 49, 79,118,144, 38, 84,216, 10, 21, 63,252,150, 17, 77,219, 7,204,198,243, 45,173,215, 14, 34, 8, 38,181,230, 7, +132,221, 14, 29, 76,138,194, 17, 11,139, 50,108,231, 23,168, 26, 25, 12, 70, 87, 46, 95, 22,145,147,179, 51, 80, 97,209,245,102, + 85, 55, 53,130,150,157, 30,128, 85, 34, 36,243,153,170,232,106,181,120,240,224,238,124, 93,219, 3, 37, 85, 27,153,157, 51,201, + 9, 0,129,163,156, 45, 55, 7, 87,110, 78, 15,158,136, 44, 34,202, 54,200,137,136,114,238,219,233, 48,217, 99,147, 86, 78,133, + 45,239,164, 45, 25,151, 16, 16,180,172, 56,180,157, 27,243, 95,196, 76,205, 3, 2, 40,181,125, 92,173,139,164, 26,165, 0,128, + 98, 18,177,130,150,142, 46, 78,186,227,126,161, 41,119, 44,147,173, 28,138,136,108,170,166,215, 27, 28, 92, 60, 48,235,132, 57, + 71,155,208,220,127,244,104,181, 90, 58, 76,250, 21,153,227, 18,144,238,223,253,228,228,244,100,211, 8,156, 47,204,212, 22, 61, + 69,192,179,229, 26,252,224,218, 83, 47, 40,146,228,159,165,156,206, 15, 75,155, 44,108,137,147, 95,151,108, 43, 67,254, 23,158, + 3,216,208,146,201,122,142, 16,210,164,202, 65,102,207, 18,174,209,243, 98,137,180, 85, 39,155, 37, 68, 85, 61,193,254,164,220, +159,116, 8,204,133, 34, 54, 49,137,176,136,249,105, 69, 68,154, 16,135,253,225,179, 55,111,118,202, 78,182,240,104, 8,225,225, +225,163,249, 98, 1, 18, 8,109,246, 35,136,161, 62,122,112,123, 85, 5, 77, 16, 30,208, 33,102, 25,197,134,167,117, 21,142,103, +155,253, 75,215,203,254, 36,154,143, 87, 88,148, 89,133,133,217,204, 82, 49,114, 50, 51,216,107, 74, 98, 23,106,139,143,255, 84, +211, 63, 0, 8,228,214,127, 78,220, 85, 80, 65, 64, 76,250,175,158,195,232,249, 27,166,239,189, 85,221, 8, 97,103,212,185,188, +211, 43, 29, 90,233, 17,102, 17,142,230,124, 99, 97, 17, 78,175,152,235, 58,118,187,253,103,159,185, 57,232,247, 9, 49,187,121, +100, 54,159,113, 12,189, 14,145, 67, 71, 68, 71,143, 30,156, 45, 22,155,134,205, 33,133, 68,118,190,146, 89, 30, 80, 85, 79,102, + 75,245,189,253,203, 55, 84,192,126,100, 50, 32,112,122, 34, 42, 44,233, 92, 73,155, 63,146,243, 63, 77,168,143,161, 72, 61,247, +111,204,191,101, 63, 70, 43,252,139,158,155, 90,245,220, 25,109, 37,114, 67,230, 2, 42, 8,186, 51, 44,174,237, 14,122,165, 75, + 73,156, 82, 72,149, 37, 55,208, 54,251, 69, 65,234, 16,189, 47,175, 93,185, 82,148,133, 21, 52,123, 3,171,205, 38, 52, 53,173, +215,107, 66,124,244,232,193, 39,247, 30,174,234, 16, 35, 3,180,240, 62, 81,128,136, 80,213,113,190,110,118, 15, 62,213, 31,237, +112,202, 84,145,200, 34, 81,211, 83,145,200,194,194,105,250, 21,205,239, 44, 87,210, 54, 3,126, 40, 68,104,178,129, 34,230,118, +118,254,244,181, 26, 90, 30,199,180, 21,128, 65, 19,181,151,148, 89, 17,145,241,176,247,196,197,201,120,216, 69, 34, 48, 79,186, +136,136,176, 50,171,178, 50,107, 84, 21, 81,182,210,100,131, 78,100,118, 69,121,229,210,165,178,240,109,150,199, 24,151,235,141, +171,170,249, 27,239,188,247,234,155,111, 30,157,205,153, 53,187,235,208, 81,242,199,217,139, 62, 91,172,151, 1,158,121,225,203, +157,238, 32,137,161, 34, 2, 57, 87,204,154,170,201, 44,148,251,217, 99,188,114,219,228, 17,160,253,164, 10,180,189,199,254, 14, +226, 57, 0,144,254, 76, 16,219,113, 85,179, 43, 42,185,213, 69,185,197, 90, 59,211,233,151, 95,122,230, 11, 47,222,232,117, 59, +243,197,122,211, 52, 77, 29,146,165,180, 69, 97,230,161,148,172,116,131, 40, 40,139,198,192,162,226,157,159, 47, 87,185,105,171, + 2,248,143, 62,186,245,250, 91,111,151,158, 58,101, 57,238,119,198,195,158,115, 70,232,144, 34,130, 10, 0,178,200, 98, 93,239, + 29, 60, 49, 28,237, 49, 51,104,130,112,105, 40, 79,125, 74,218, 78,189, 69, 35,109,254,180,188,252,182, 88,107,219,119, 53, 55, +184, 52,199,164,218,171,173,225,209,136,159,115, 25,245, 67,230, 72, 70,160,103,110, 62,247,179, 63,241,185, 23,159, 24, 21, 78, + 99,228,221,157,157,111,252,254,183,231,235,181, 71,195, 6,231,127, 4,234,150, 32,215,212, 90, 16, 68,128,156,247, 69, 55,134, +141,167, 20, 67,119,243,218,133,178,240,206, 57, 81,219, 4,208,174,243,100,253, 43,179,172,213, 38, 44, 42,121,242,185, 47,116, +186, 3, 59,216,121,176,218, 30,105,248,161, 42, 1,184,237,197,150, 54,169,149,107,219,229,181, 13, 43,232,185,221, 26, 60, 55, +195,234,227, 4,108, 59,224,178,213, 29, 91,239,240,190,120,249,229, 47,252,244,151, 62,243,242,205, 93, 2,102, 17, 79,238, 96, +111,103,103, 58,125,229,181, 55,207,230,115,181,249, 14, 19, 74,205,179,158, 81, 81,162,106, 37, 53,181, 26, 80, 88,174, 27, 36, +112,164, 0,224,110, 94,187,128,105,190,113, 10, 26, 3, 40,112,225, 8, 50, 65, 6, 0,243,229,166, 51,218,187,112,229,102,130, +168, 34,208,186, 55,173,103,229, 14,159, 94,128,149, 31,132,140, 74,210,251,222, 10, 70,143,141,250, 45, 66,122,220,247,145,186, +126,251, 5,250,195,104, 84, 69, 65,119,119,246,191,242,229,175,252,228, 75, 55, 94,120, 98,236,137, 61,145, 3,231,157,115,142, + 46, 31,236,221,188,254,196, 31,127,239,213,163,211, 83, 97,241,142,172,244, 43, 0,110,171,117, 66,252,204,202,137,167, 22, 81, +174, 54,209, 17, 16,161,187,118, 48, 53,193, 0, 49, 53,144,192,162, 34, 14, 83, 27,139, 33,174,170,184,123,233, 70,111,184,155, + 72, 47,200,137, 41, 86,119,210,252,189, 53,196,101,207,133,197, 4, 91, 35, 92,203,108,108, 81,245,150,157,182,118,221, 82,214, +104,159,183,211,161, 91,130,205,190,148, 37,146,163,167,111, 62,243,179, 95,251,210, 87, 95,184,122,237, 66,215,161, 24,215,208, + 50,179,160,184, 55,157,124,234,242,165,219,247,238,223,123,240,176,105, 66,225, 61, 57,196,109, 43,205, 22, 55,211,201, 68, 36, + 74,148,168, 10, 49, 4,102, 44, 28,120,116,190, 9,145, 80,188, 39,163,212, 89, 96,190, 86, 17,157, 18, 34, 64, 19,162,146, 31, +141,247, 84, 20,128,211, 97, 70,176, 9, 3,178, 55, 35,243, 51,106, 40, 10,204,190,169, 91,151,138,129, 57,220,106, 26,153,156, +199,124,154, 32,255, 46,134,189,116, 11,193, 83, 97,106, 31, 77,220,223,221,255,234, 23, 62,251,185,231,174, 95,154,118, 29, 70, + 51,245, 37, 71,177, 17, 23,154,252,109,215,174, 92,190,121,253,202,209,209,163,217,124,121,124,122,182,183, 51,237, 20,222,200, +218,182,155,180,182, 8,160, 52,129,250,210,111,214,117,100,244, 23, 47,236,110,214,155,117, 85,109,170,198, 17, 16, 57, 17,102, + 66,168, 21,136,118,134, 20, 34,247,250, 83, 87,116, 68,248,156,146,177,109, 38,237,243, 64, 36, 16, 52,239, 37, 2,129,181,159, + 92, 94,209,242,179,141, 4,110, 53,111,205,154, 88, 22,198, 18, 63,155,198,180,115,135, 1, 17,134,131,222, 75,207, 63,247,181, +207,191,240,228,149,105,137,218,212,213,150,181, 4,101,102,211, 88,205,201, 93, 55,245, 59, 31,188,127,114,122,178,183, 51,142, + 33,108,234,230,228,236,108,111, 58, 41,202, 2, 77,224, 63,103,225,202,112,196,100, 18,244, 30,234,168,126,111, 58,137,195, 97, +136,177,170, 67, 85,215, 33,132,186,169, 99,100, 22, 88, 85,193, 19, 21,222,239,236, 95,142, 12,201,118,171,186,173, 13,233,205, + 97, 70,183, 2, 64,170, 2, 64, 0, 2,232, 18, 99,145,109, 52,217,149,219,170,143,146, 42, 64,130, 76,219,153, 36,157,182, 92, +201,153, 89, 85,166,227,241,115, 55,159,250,202,103,159,191,113,237, 66,191, 68, 14,161,137,161,237, 3, 22, 90,231,140, 1,165, +245,102,115,235,147,143,127,240,198,235, 31,124,116, 75, 84, 71,131, 97,220,229, 71,135, 71, 77,148,163,211,179,157,201,184,219, +241,231,220,239, 89, 95,104,203, 1,161,115,142, 37,250,201,104,104,242,164, 2,196,200, 85, 19, 86,155,106,179,217, 84,213,198, +182,184,202, 78,191,211, 29,137,176,125,117, 58, 13,231,138, 74, 82,102, 17,173, 46,171, 38,119, 90,170,215,152,181,177, 45,175, +209,110, 49,164,179,149, 89,145, 54, 60,210, 54, 97, 27, 89, 70,163,225,231, 94,120,254,243, 47,222,120,242,202,126,191, 67,220, + 84, 77,197,230,235,104,201, 19,123, 23, 70, 31,190,253,193,251,255,244, 15,254,224,228,236, 84, 84,201,249,166,106,152,155,126, +191, 55, 26, 15,103,243,133,178,158,158,158, 77, 39,163,178, 83,166, 12, 18,209,196,125, 66,162,105, 1,136,200, 59,240,189,110, +199, 57, 95,250,194, 57, 2, 34, 21,169, 3,111,170, 42, 52,141,115, 84,173, 22,141,150, 12,148,156,226,153,248,200, 50, 84,110, +191, 8, 10, 98, 49, 50, 35, 88, 98,182, 84, 53, 57,105, 52, 89,140,207,131,152,243, 92, 90, 42,206,169,206,216,134, 1, 17,237, +142,198, 47, 60,247,244, 87, 62,243,252,245, 75,147,110, 65, 28,234,102, 19,146,200,137,100,101, 77,179, 19,174,110,234,135, 71, +135,223,249,254,247,223,253,240, 3, 68,138, 44, 57,133, 85, 20, 28, 97,191,223, 19,142,203,213, 58, 4, 57, 60, 57,155,140, 70, +189,110,153, 43,169, 36,101,101,219,102,136,200,123,239,124, 81, 20,101, 89,122,239,189,115, 68,168, 2,145,135,129, 99,225, 60, +208,149, 59, 15,231,203,192,232, 57, 65, 27,139,120,203,224, 65,106,126,152,172, 25,106,123, 97,170, 0,192, 86,185,165,181, 21, + 38,240, 43,217,182, 96, 15,143, 85, 36,103,146,253,226,126,127,112,245,210,193,179, 79,125,234,165,231,158,186,186, 63, 46, 29, +112,108,234, 77,180,124,105, 55,148,236, 95, 68,168,170, 31,221,190,253,221, 87,127,240,209,237,219, 77,104, 0, 72, 53,198,200, + 42,172, 0,102,130, 12, 77, 84,133,178,211, 25, 33, 45,151,203,186,110,206,102,179, 38,244, 6,189,142, 35, 58,223, 80, 91, 27, +155,115,206,147,115,222, 57,135,228,189,243,206,118, 85,200,164, 34,239,105,185,105, 66, 76,104,122,235,164, 3, 0,101,104,137, +180,246, 37, 39, 1,192,170, 95, 18, 25,182, 88, 89,183,240, 79,179, 81, 51,129,255, 84, 67, 4, 65, 15, 46,236,189,248,244,141, +231,111, 94,251,212,197,221,241,168, 71,192, 92,215, 77,224, 31, 10, 77,171, 74, 34,226,124,185,252,254,235,175,191,250,198, 91, +179,229, 92, 68, 89,162,216, 80, 8,140,130,198, 80,165,164, 20, 16,129,210,187,209,104, 4,184,168,170,122,185, 90,133,166, 25, + 12,250,222,187,180,202,133,217,183,143, 2,136,190,244,190, 40,138,162, 40,188, 43,188, 39,239,189, 39,219, 72,117,206,185,158, +151, 72,166, 0, 0, 16,165, 73, 68, 65, 84,213, 38, 68, 85, 17, 32,180,113,241,220,242, 28,170,249,166,140,207, 18, 85, 52,127, +154,149,106,155,119,240,156, 7, 97,187, 77,150,200, 34,201,151, 15,148,158,134,253,254,213, 75,123, 95,252,244,243, 55,158,184, + 60, 25,117,137, 72, 56,114,181,110,132, 91,185, 71,219,202, 37, 10, 0,204,188,174,214, 31,220,250,248,143,190,255,202,201,233, +220,134,229,200, 44,108,251,174,166,165,107, 59,234, 8, 72,238,171, 84,120, 26, 13,134,136,180, 92, 46,171,166,142,204,131, 65, +183,116,222,176, 4, 38,211, 62, 34,160,159, 76,166,133,109,131, 57,231, 8, 41,101,147,119,142, 20, 40,176, 4,123, 8, 40, 9, + 6,106,134,163, 98,246, 9,200,200,140, 82,109,202,114,130,154, 89, 3,207, 19,101, 70,209, 26, 10,103, 2,217,157, 12,111, 92, +187,244,220,141,107, 79, 92, 61, 56,184,176, 79, 30, 32,114,108,234, 24, 66, 46,156,233, 88, 99,162,111, 69, 84,154,166, 57, 58, + 57,190,117,251,206,237,123,247,110,223,189,107, 43,251, 45,213,147, 64, 77,122, 90,168, 32,182, 11, 41, 0, 42,140, 42,138,137, +234,239,245,122,132, 48,155,175, 66,140,203,197,186,219, 45,189,247, 89,220, 4, 82, 66, 82, 63,157,238, 56, 34,114, 73, 69, 49, + 10,209,116, 76, 22, 89, 87,117,140,162, 36, 40, 64,136, 98, 2, 79, 59, 75,129,152, 21, 14, 21, 8, 84, 17, 69,149,160, 45,220, +231,135,213,116, 22, 69, 68, 69,202,194, 93,189,122,241, 43,159,121,246,153,235, 23,167,147,161,239,148,168,194, 77, 21,214,193, + 22, 55,178,119, 21, 84, 85,152, 99,228,192,177,137,113,185, 92,221,121,112,255,214, 71, 31, 61, 60, 62,218, 84, 85,228, 24,109, + 95,154,163,173,197, 38, 14, 13, 16,148,179,113, 55,137, 6,168,102, 27, 20, 4, 16, 84, 17, 64,229,178, 83, 14, 6, 50,155, 45, +213,137, 86,224, 92,116,158,146, 88,137, 0,138,190, 44, 10,115,250,180,171, 39,136,102, 52, 65,102,222,212,129, 85, 65,192,172, +166,164, 98, 62, 74,204, 99,118,234, 34,132,121, 32, 5, 54,241, 89, 64,208, 12,153,201, 35,170,170,206,209,116, 60,186,241,196, +213, 47,190,116,243,230,213,253,110,215, 1,162,196, 24,151,115,137, 81,183,251, 4,160, 2, 81,184, 9, 77, 85, 55,155,170, 90, +111,214,143, 14, 15, 63,190,115,247,209,241,225,114,181, 50, 50,211,102,192, 40,204, 49,166, 81, 16,196,214,104,210,189, 36, 72, + 12, 2, 2, 34, 10, 32,137, 25, 22, 64,100, 2, 66,132, 40,132, 32,221,110,209, 52,101,211,132, 24,131,170, 99,110,117, 1, 4, +167, 62,109,159,152,235, 11, 19,242,135,220,106, 91,203, 25, 33, 90,156, 80, 85, 73,200,172,255,154, 11, 83, 2,234,105,107, 75, + 50,209, 46, 25,248,216,138,229,167,159,189,241,242,179, 79, 92,191, 56,237,149, 40,194, 97, 83, 75,140,246,183,179, 13, 10, 69, +164,106,154,229,114,121, 54, 95,156,206,102,199,167, 39,199, 39, 39,167,179,179,197,106, 21, 99, 72, 83,183, 38, 26,147,141, 11, + 59, 55,118, 34, 42, 8, 42,136,113, 53,104,102,225,116, 52, 19, 34, 4, 54, 73, 73, 33,211, 87,253,126, 7, 17, 67,224,200, 33, +165, 65,110, 50, 94, 68,204,120,156,153,243,115,194, 93,218,116, 18, 37, 1, 48,229, 5,237,102, 32, 33, 32,164,243, 64,173, 53, + 27,108, 71, 44,149,214, 28,244,244,147,215,126,246, 43, 47, 63,125,109,175, 32,209,184,217,172,132,146,173, 7,144,176, 61,125, + 71,199, 39, 31,223,187,247,232,240,240,108,190, 88, 85,155,205,102, 93, 85, 85,176,219, 28,192,110,246, 96, 53,115, 88, 76,146, + 74,110,131,201,167, 0,146,132, 35, 67, 96, 98,127,153,165, 5,180, 9,242,183,241, 82,230, 40,190, 40,134, 3, 90,174, 43, 12, + 16, 66,216,106,186,136,158, 85, 29, 0,176, 10, 34,210,121,155, 73,166, 53, 68, 68,197,184, 15, 77, 46, 56, 32, 86,113, 66, 64, +233,248,144,102,237,217,146, 42, 45,212, 9, 96,167,240, 47,191,240,204, 95,251,234, 75,151,119,251,177,174, 56, 68, 1, 32, 68, + 51,123, 91, 92,234,166,249,228,238,253,119, 63,252,240,225,209,113, 85,175, 99,100,230, 24,154, 38,112,228, 92,116, 19,241,173, +194, 28,173, 7,202, 57,187,131,182, 32, 29,197,252, 87,132,160,154,181, 4, 81, 49, 25,174, 93,186, 72, 40, 86, 44, 79,204, 6, +219,237,148, 27,173, 1,124,140, 17, 24,148,128, 20,188,205, 66,212, 46, 81,226,227, 6,220, 68, 41,169, 40, 32, 41,146,130, 16, + 17, 9, 10, 9, 9, 10, 33,165, 83, 15,170, 9,212,106,203,140, 77, 71,195,159,251,137,207,127,249,165, 27,131, 18,234,205, 42, +117,122,209, 8, 54,107, 67,136,241,195, 79,110,191,253,254,135,143,142,143, 66, 8, 33, 52, 33, 6,102, 14, 33,164, 64, 36,243, +155, 88, 96,140,175,177,192,100,161,176,221,180,198,214,238,103,112, 63,154,124,145,165,204, 45,142, 7, 68, 73,116,191, 57,126, +152,217, 78,119, 89,250, 0, 0,160, 17, 80, 68, 20,213,139, 8, 32,130,160,105, 96,250,184, 64,110,170, 54, 67, 36, 34, 18,155, +211, 5, 69,145,156, 36, 15,149, 32, 56, 64,123, 24,138,173, 61, 6,116,119, 60,252, 91, 63,247,165,207,191,120,131,148,171,213, + 74, 85, 9, 33,154,229, 92, 69,145, 78,230,243, 87, 94,123,227,238,253, 7, 85, 83, 53, 77,211,132, 38, 70, 86,230,192,193, 78, + 69,203,137, 70, 97,230,216,170,182,219,133,129, 45, 67,135,121, 47, 19, 64,213, 54,242, 37, 45, 54,110, 49,124,139, 88, 69, 21, + 12, 17,112,218,216, 70, 68, 81, 33,197, 78, 89,136,136,247, 24,130,128,130, 23, 81, 36, 67,154,217,250,180,101,199, 5, 1,197, +150,125, 84,128,148, 4,193, 81, 36, 36, 1, 66,167,170,202,102,191, 53,143, 37, 42,171, 81,145, 59,227,193, 79,190,124,243,233, +107,251,205,122, 37,161, 49, 35, 22, 3,196, 24, 89,216,145,187,243,224,193,171,111,190,125, 54,155, 53,193, 54, 55, 66,150,214, + 82,135,202,116, 51,199, 92,137, 33,141,149,233, 29, 99,106,121, 8,173,163, 15,147,204, 99,223,234, 49, 3,146,205,209, 25,182, + 26,189,202,170,104, 80, 21,128, 0,109, 74, 18,150,210,251, 16, 99, 68, 20, 81, 47,170,168, 64, 10, 64, 34, 91,115, 77, 42,241, + 73, 36,210, 8,226, 84, 65,157, 35, 22, 84, 18, 18, 32, 32,177,205, 98,225,196, 52, 37, 82,124, 52, 40, 95,184,190, 63, 40,225, +155,223,254,227,170,170, 46,238,237,140,135,253,157,233,216,121, 31,154,112, 58, 95,220,189,255,224,240,228,100,179,217,212, 77, +101,137,195,182,244,154, 77,122, 73,238,203, 21,228,156,187, 81,211,146,121,182, 39,158, 95, 77, 79,154,147, 69,231,113,246,178, +221, 60,177, 80, 70,110,251, 90,235,130,204,243, 15, 58, 91, 35,143,142,154, 24,188,136,152,129,221, 44,169,231, 23,173, 85,149, + 16,193,180,101, 2, 34, 2,142, 74, 68,170, 36, 78, 84,192, 1, 2, 34, 19,162, 8, 37, 11, 83,175,244, 79, 92, 24, 13, 10,248, +248,238,189, 59,247,238,127,239,181,215,231,139,179, 43, 7, 23, 62,253,220,211,207,220,120,170,105,194,195,227, 19, 83, 22, 66, + 12, 33, 90,161,201,206,139, 76,145,217,166,148, 36, 87,158, 49,225,153,137,176,199,141, 0,128,172,220,234, 6,169,237,171, 72, +171, 32,156, 59, 91,152,104, 57, 81,212,104,144, 27, 36, 89,187,140, 0, 76, 70,113,178,251, 83, 68,217, 59,116, 68, 94,132, 17, + 72, 81, 5,145, 30, 91,166, 51,175, 20,168, 70, 97,187,107, 33,109, 29,130,170,146, 18, 58, 80, 69,103,203, 90, 8,130,138,232, +157, 59,152,116,247,198,157,200, 97,189, 94, 45, 55,107, 34,220,108,170,247,110,221,186,115,239,238,239,252,222, 31,244,251,189, + 39, 63,245,169,157,157, 73,167,236, 24,250,223, 58, 97, 13, 64,164, 3,149, 81, 49,180,117, 55, 23, 0, 74,181, 39,165, 64,146, +116,165,229,220, 91, 25, 73, 91,238,106,235,188, 1, 97,181,107,249,172,117,183, 70, 1,132,164,201,165,171, 34, 20, 16,160, 83, +160, 55,143, 62,153,204,131,136,143,153,118,149,192, 54, 14, 89, 1, 5,217,129,221,219, 66,182, 33, 10,228,136, 65,137,129, 8, +129, 16,116,212,239, 94,217, 27,150,158,236, 36,247,202, 98,111,103,167,110,170,217,236,172,106, 26,144,122,185, 94,205, 23,203, +107, 87, 46, 93,190,120,177,219,235,166,185, 53, 87,147,150,193, 69, 68,231, 72,240, 60,177, 38, 91,135, 95, 66,126, 41,154, 86, +183, 84, 88, 91, 86, 55,147, 85,104,149,197,156, 56,220,222, 49,194,231,242, 74,207,217,134, 45,130, 98,215, 23,169, 48, 34,185, +191,245,215,254,234,246, 22, 23, 67, 22,154, 87,147, 5, 54, 85,117,239,240,172, 10,143, 57,158,243, 74, 98,114,129, 97,134,134, +165,119,215, 47,142, 15,118, 7,201,182, 76,128, 0, 33, 4, 5, 17,145,208, 68,219, 44, 11, 33,206,230,243,197,114,229, 8,243, +221, 37, 54, 9,170,137, 83, 96,196,127, 91,130,177,181,163,109,213, 66, 43, 33,173, 79,195,138, 78,166,245, 83,233, 49,216,159, + 40, 93, 22,101,213,243, 78,227, 22,218, 42,230,123, 52,242, 5, 26,109,170,168,248, 24, 35, 56,167,128, 36, 32, 6,135,218,149, + 89,181,165, 42, 85, 97, 1, 82,178, 60, 37, 85, 80,167,206,168, 91, 2, 48, 7, 53,105,191,235,247, 70,221, 84, 49, 0, 28,185, + 97,191,191, 59, 29,213,245, 38, 6,174,155, 48,155, 55,168,201, 29,112, 58,155,213, 77,115,241,194,254,254,222, 78,175,219,119, +132, 42, 91,106, 24, 20,137, 64, 5, 36,205, 64,152, 24,108,209, 86,129,203,228, 90,178,255,192, 57, 75,127,162,162, 36,159, 44, + 78,146,136,110,151, 93, 33,149,251,188,129,145,132, 56,123, 30,108,118, 13, 96, 85, 31,153, 85,213, 41, 18, 18, 26,246, 79,171, + 0, 22, 72, 69, 0,150,136,224, 73, 17, 72,149,212, 73, 58,182,100,127,201,129, 10,120,132, 73,191,236,118,252, 22,113, 0,122, +239,135,131,193,116, 60, 78,151,148, 49,159,205,102, 0,226,201,145, 66,181,169,238, 63,124, 52, 95, 44,167,147,241,100, 60, 44, +203, 82,207,175, 59,230,214,181,245,185,234,150, 25, 48, 66,236,252, 50, 96,170, 89,152, 27,141,108,239,137,107, 63,108, 13,104, +105,139, 60, 91, 63, 91, 23, 23, 36, 59, 59, 64,150, 16,124, 72,144,193,145, 83,218,174, 88,167, 51, 73, 72,142,144, 69, 73, 25, +136, 64,137, 84,196, 89, 73, 6, 5, 5, 2,100, 85,212,178,112,163, 65, 73, 68,137,181,151,228,128, 42,203,114, 48,232, 87,117, +197, 34, 14,177,240,197,201,217, 89, 29,106, 34, 50, 13, 59,196, 88, 85,245, 98,185,220,153, 76,198,163, 1,218, 54,106,230, 99, +211,131, 70,243,190, 38,195,175,164,103,189, 69,140,173, 89,130, 82,227,207, 89,198, 91,230,251, 28,229,166,231,214,139,210,138, + 74, 27, 30, 75, 10, 84, 49,157,202, 51, 51, 16, 1, 40, 9, 58,243, 20, 35, 32, 80,246, 97, 67,233,201, 86,136, 21, 4, 8, 84, + 72,129,129, 40,213,111, 16, 66, 34,148,194,209,160, 83,164,113, 72,160,165, 98,189, 47, 6,189,126, 61,168,155, 38,196,126,216, +211,177,247,110,182, 88,172, 55, 27,187,156,200, 59, 39, 44, 33,132,170,105, 54,117, 53, 25, 14,124,225,179,144,111,175, 71, 25, + 4, 34,146,195,220,193, 53,235, 15,153,154, 72,173, 20,219, 3, 8, 57, 58,143,221,172,185,157, 57,208, 12, 87,218,114, 27,219, + 41, 9,192, 74, 33, 0,160,250,116,181,136,154,227, 85, 40,237, 90, 11,106,178,214, 22,133, 19, 21, 80, 34, 0, 6, 33, 2, 84, +226,116,219,148,146,217, 0,200,117, 10,234,148,190,245,176,182,207,159, 16,139,178, 24, 14,134, 33,196, 24, 66, 44,227,168,223, +117, 4,221,178, 88,215, 85, 93, 55, 77,140, 70, 6, 6,230,186, 14,203,229,102, 50, 25, 78,134, 3,231,201,142,191, 71, 7,136, +224, 84,132, 20, 37, 13,238,182, 38,212,198, 8,225,188,156,156,101, 36,105,243,203,238, 63, 75,165,138, 20, 24,179,143,182,109, + 80, 8,237, 56,171,105,155,157, 0,188,180, 59, 37,105, 81,140, 76, 54, 37, 68, 96, 0, 0,239, 93,162,116,149,200, 54,200, 1, +137, 32,155, 88,211,162, 84,183,227, 11,243, 67,156, 99,230,243,149, 7,212,233,148,227,241, 48,114,140, 9,170,128,119,174, 83, + 20, 43, 95,173, 55, 85,211, 52, 28, 27, 95, 8, 51, 55, 77,179, 92,175,231,195,254,206,100,210,235,149, 8, 26, 57, 66,186, 61, + 69, 91, 79, 98,222, 88, 0, 72,251,122,182, 43,223,230,142,232, 57,123,141,149, 47,201, 78, 18,100, 84,201,148, 16,108, 73,144, + 12,107,210, 13,131, 86,251,188,205, 19,108,201,102, 67, 39,217, 99, 65,163,124, 58,222, 35,164,251,201,140,125, 22, 16, 80, 27, + 52,136,145, 69,137,156,235, 21, 5, 18,164,135,214, 10, 21,185,233, 32, 82, 81,148,163,225, 48,166, 91,181, 4,146, 57,194, 57, +231,214, 27,170,154, 38,132, 32, 34,196, 92, 55,205, 98,181,186,123,255,112, 58, 30, 94,185,180,223,239,117,243, 77, 14,208,218, +181,179,213, 21,133,132,192,229,169, 65,193, 48, 81, 59,117,181, 87, 13,102, 5,193,116,123,160,115, 90,106,206, 30, 68,108,103, +189, 68,137, 40,250, 45, 91,156, 82, 87, 89,208, 17, 0, 40, 10, 42, 81,217,241, 68,164, 81,237, 62, 50,180, 73,140, 18, 33, 71, +152,210,190, 83, 58, 56,223,108,181,181,184,165, 95, 8, 88, 22,197,168,223, 87, 22, 64, 34,221, 4, 80, 66, 37,215, 45, 28, 20, + 27, 87,213,117, 8, 77, 20, 99,116, 49, 70,126,116,116,122, 58, 95, 94,188,176,123,113,127, 90, 22, 37, 36, 77, 24,193,185,244, +152, 17, 32, 2, 3, 27,115, 40, 42,102,240, 1, 60,151, 59, 9,216,100, 43,146,213, 94,187, 86, 45, 15, 14, 89,128, 84, 99,170, +183,200, 17,213, 99,186,132, 13,208, 80, 6, 2, 81,226,250,204, 30,209, 45, 59,101,225, 54,117, 0, 17, 33, 68, 65, 64, 37, 16, + 86, 34, 66, 69, 35,218,168, 44, 40,111, 58,109, 85, 83,201,179, 99,146, 28, 0,188, 43, 6,253, 65,250, 97,154,252,252,132,228, +188, 47,189,219,212, 84, 53,129, 89, 16,212, 19, 70,213,166,105,238,220,125,120,122, 54,191,122,249,194,116, 52,116,132,228, 60, +144,237, 78,137, 68, 17, 20, 36,148,104, 70,100,109,133,166,188,234,130, 34,130,130, 66,146, 47, 50,210,243,152, 55, 91,225, 48, +185,185, 18,179,142,104,131, 7, 98,186, 79, 26, 5,212,105,242,100,107,187, 1, 4,170,216,235,150,131,110, 57, 91,134, 52,141, + 1,176, 93,226, 70, 2,233,146, 1,114, 14, 11, 71,153, 97,200,138,233,185, 8,113,154, 8,172,202, 97,183,236,240,128, 5, 84, +171, 13, 40, 20, 5, 56,236,120, 36,239,169, 40,154, 77, 85, 55, 49, 34,131,163,180,215,184,169,234, 91,159,220, 59,216,223,189, +176, 59,233,118, 74, 2, 71,164, 42, 32, 36, 16,179, 97, 76, 4, 72,137, 73, 41,221,185, 7,237,204, 65,219,237,141,212,240,183, + 34, 67, 91, 54, 5, 84,242, 5, 68,146, 45,172,232,147,202,165,166, 16,163,160,221,113,165,153,214,149,210,251,157, 81,239,254, +241, 42,219,157, 16, 77,177, 16, 96, 51,225, 32,148,158,188, 67,179, 47,202, 54, 66,146, 39,201,116,143,116,180, 88,169, 32, 82, + 89,118,250,172,160, 90,105,165,141, 32, 33,148,158, 72,237,218,198,186,105,234, 38,132, 24, 85,129, 85,148,129,153,239, 61, 56, + 92, 46,215, 23,246,167,211,241,208,123,167,233, 70, 6, 72,218,169,105,224, 78,172,183,156,219,238, 76, 3, 84,158,240,179, 87, + 39,195,234,188,165,165,148,175,217, 49,178,192, 68, 12,159,177,125, 86, 5, 8, 5,157, 57,214,109, 9, 1,137,166,227,126, 89, +224,186, 86, 67,133,206,248, 94, 2, 4, 96, 69, 34, 45, 29, 34,130, 93, 96,166,219,246,149,102, 43, 21,149, 68, 49,100,171,187, + 42, 34, 22,133,239,105,207,212,154,134, 3, 41, 0,185, 78, 73,222, 81,167, 40, 67, 39,212, 77, 88,215, 85,213,196,100,139, 17, +153,205, 23,139,213,106,208,239, 29,236,239, 76,199, 3, 66, 50,147, 96,222, 23, 82, 66, 84, 7,105, 79, 56, 45,112,180,150,189, + 92,152, 90, 53,113,219,114,165,149, 44,204, 70,101, 53, 7, 17,253, 57,163,133,169, 2, 32, 32,230,176, 79, 89,136, 58, 26,244, + 70,189,114, 83, 87,102, 14,138,130,136, 72,108,115,170, 32, 18, 57, 84,149, 40, 81, 90, 47, 82,114,145, 39,151,112, 76,150,119, + 43, 70,246,161, 0, 18, 57,234,116,186,170,160,149,134,168,130,138,170,206, 57, 34,245, 5, 21,133, 47, 59,126,189,105, 54, 85, + 29, 56,253, 7, 5, 36,242,108,190, 90, 44,214,163,209,224,194,238,104,208,233,166, 94, 96, 34,138, 49,120,102, 18,182,228, 17, + 77,172,106,203,153,217,118,190,245,197,212,157, 41,183, 71, 56,191,198, 7, 8, 94,183,130, 26,160, 2,181,215, 58, 17,129, 0, + 16,144, 72,183, 44,118,198,189,195,179, 74,210,162, 91, 54,196,153, 53, 51,203,151, 12,231,230,159, 20, 31,219,218, 72,106,150, + 93, 10, 44, 45, 75, 33,138,128, 68, 84, 20, 5,100, 27,149,180, 67, 19,162,115,212,193,130, 16, 11, 79,235, 77, 93, 55, 33,138, +182,166,189,217,108, 62, 95,172, 6,189,206,116, 52,232,117, 93,186,167, 96, 91,121, 64, 32,211,139,146,111, 6, 75,109, 13, 91, +247, 81,126, 3, 89, 56, 34,108,123,159, 29, 51,223,132,144, 61,147, 10, 0,146,168,230,188,232,167,168, 68,136,176, 59, 30,148, +229,217,122,147, 38, 21,204,214, 94, 69,171, 73,204,202, 42,152,140, 44,105, 93, 35, 45,178,180, 84, 95,203,135,110, 57, 10, 51, +117, 16, 58,239, 59,170, 0,208, 64, 45,145, 53,111,141, 33,162,119,142, 58,232,136, 10,239,214,117, 19, 35, 39,149, 5, 80, 68, +230,171,205,186,218, 76,134,131,241,160, 99, 23,184,217, 45,135,246, 92, 98,140,178, 93,122,197,180, 26,154,111, 8,201, 55,121, +231,141,189, 45, 26,202,252, 49,170,175,155,166, 5, 83,182,141, 40, 14, 29, 57, 99,209, 0, 72, 20, 28,194,100,212,155,244, 59, +235,205, 90, 5,243,253,118,173, 8,162,145, 69, 34, 43, 98,123,193,171,230, 45, 58, 57, 15,135,140, 53, 78,240,145, 83,134,137, +128, 8, 0,146,163,162,112,170, 37,104, 19, 99, 20,144,150, 6, 2, 4,239,169,171,158, 8, 54, 85,186, 0,223, 84,118, 80,136, + 17,142,103,203,245,166, 30, 13, 58,221,210, 59, 71,166,136, 69,142, 44,146,198, 57, 0, 32,115,123,156,187, 6,156, 32,223, 84, +144, 45, 24, 9,128,102,230, 27,209,125,233,229, 23,146, 83,223,238,210,148,173, 28, 0,237,242,132,130,119, 20, 66, 56,154,173, + 34, 75,134, 87, 6,251, 5, 1,166,163,238,254,164,111,216,134, 69, 52, 49,124,146, 9,188,214,103,203,109,107, 19, 86,201,174, +228,156, 74,249, 78, 6,108, 23,207, 31,139,112,123,143,155,141, 67,152, 61,108, 10,160,138, 33,114, 19, 34, 0, 18,161,154,217, +197,240,117,118,232,192,118,155, 38, 45,163,160,182,123,140,152, 87,168, 83,245, 33, 77, 30, 33,247,185,231,159,177, 87,202, 38, +184, 36, 57, 36,187, 1, 32,253,151, 67, 0,176,112,116,182, 88, 47, 54,141, 42, 60,118,193,159,234,176, 87,236, 79,250,105, 12, + 78,215,143, 51, 39,202,207, 8,245,237,209,226,150, 11,212,148, 70,146,229,207,124, 7, 68,234,169, 9, 28,199,196,232,216,237, +248,198,246,184,124, 61, 78,126, 79,182,210, 39,117, 19,171, 38, 42,128, 67, 32,135,137, 24, 58,199,111,152,216,151,210, 37, 25, + 54, 48,211,221,237,182,121,187,193,135,255, 47,141, 49,219,167,190,145,191,220, 0, 0, 0, 0, 73, 69, 78, 68,174, 66, 96,130, + 0}; + diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 12a54658f90..8d771f0dc58 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -74,23 +74,23 @@ /* flags for sflag */ typedef enum eDrawStrokeFlags { - GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */ - GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */ - GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ - GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */ - GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ - GP_DRAWDATA_NO_XRAY = (1<<5), /* don't draw xray in 3D view (which is default) */ + GP_DRAWDATA_NOSTATUS = (1 << 0), /* don't draw status info */ + GP_DRAWDATA_ONLY3D = (1 << 1), /* only draw 3d-strokes */ + GP_DRAWDATA_ONLYV2D = (1 << 2), /* only draw 'canvas' strokes */ + GP_DRAWDATA_ONLYI2D = (1 << 3), /* only draw 'image' strokes */ + GP_DRAWDATA_IEDITHACK = (1 << 4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ + GP_DRAWDATA_NO_XRAY = (1 << 5), /* don't draw xray in 3D view (which is default) */ } eDrawStrokeFlags; /* thickness above which we should use special drawing */ -#define GP_DRAWTHICKNESS_SPECIAL 3 +#define GP_DRAWTHICKNESS_SPECIAL 3 /* ----- Tool Buffer Drawing ------ */ /* draw stroke defined in buffer (simple ogl lines/points for now, as dotted lines) */ -static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) +static void gp_draw_stroke_buffer(tGPspoint *points, int totpoints, short thickness, short dflag, short sflag) { tGPspoint *pt; int i; @@ -100,14 +100,14 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick return; /* check if buffer can be drawn */ - if (dflag & (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_ONLYV2D)) + if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D)) return; /* if drawing a single point, draw it larger */ if (totpoints == 1) { /* draw point */ glBegin(GL_POINTS); - glVertex2iv(&points->x); + glVertex2iv(&points->x); glEnd(); } else if (sflag & GP_STROKE_ERASER) { @@ -122,7 +122,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick glLineWidth(oldpressure * thickness); glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ @@ -154,12 +154,12 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick /* ----- Existing Strokes Drawing (3D and Point) ------ */ /* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) { /* draw point */ if (sflag & GP_STROKE_3DSPACE) { glBegin(GL_POINTS); - glVertex3fv(&points->x); + glVertex3fv(&points->x); glEnd(); } else { @@ -167,26 +167,26 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl /* get coordinates of point */ if (sflag & GP_STROKE_2DSPACE) { - co[0]= points->x; - co[1]= points->y; + co[0] = points->x; + co[1] = points->y; } else if (sflag & GP_STROKE_2DIMAGE) { - co[0]= (points->x * winx) + offsx; - co[1]= (points->y * winy) + offsy; + co[0] = (points->x * winx) + offsx; + co[1] = (points->y * winy) + offsy; } else { - co[0]= (points->x / 100 * winx) + offsx; - co[1]= (points->y / 100 * winy) + offsy; + co[0] = (points->x / 100 * winx) + offsx; + co[1] = (points->y / 100 * winy) + offsy; } /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok - * - also mandatory in if Image Editor 'image-based' dot + * - also mandatory in if Image Editor 'image-based' dot */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) + ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) { glBegin(GL_POINTS); - glVertex2fv(co); + glVertex2fv(co); glEnd(); } else { @@ -206,7 +206,7 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dfl } /* draw a given stroke in 3d (i.e. in 3d-space), using simple ogl lines */ -static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thickness, short debug) +static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug) { bGPDspoint *pt; float oldpressure = 0.0f; @@ -214,7 +214,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw stroke curve */ glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { /* if there was a significant pressure change, stop the curve, change the thickness of the stroke, * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP) */ @@ -240,7 +240,7 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw debug points of curve on top? */ if (debug) { glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) glVertex3fv(&pt->x); glEnd(); } @@ -249,35 +249,35 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* ----- Fancy 2D-Stroke Drawing ------ */ /* draw a given stroke in 2d */ -static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, - short debug, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke(bGPDspoint *points, int totpoints, short thickness_s, short dflag, short sflag, + short debug, int offsx, int offsy, int winx, int winy) { /* otherwise thickness is twice that of the 3D view */ - float thickness= (float)thickness_s * 0.5f; + float thickness = (float)thickness_s * 0.5f; /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better - * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke + * - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke */ if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) + ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) ) { bGPDspoint *pt; int i; glBegin(GL_LINE_STRIP); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2f(pt->x, pt->y); } else if (sflag & GP_STROKE_2DIMAGE) { - const float x= (pt->x * winx) + offsx; - const float y= (pt->y * winy) + offsy; + const float x = (pt->x * winx) + offsx; + const float y = (pt->y * winy) + offsy; glVertex2f(x, y); } else { - const float x= (pt->x / 100 * winx) + offsx; - const float y= (pt->y / 100 * winy) + offsy; + const float x = (pt->x / 100 * winx) + offsx; + const float y = (pt->y / 100 * winy) + offsy; glVertex2f(x, y); } @@ -296,67 +296,67 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s glShadeModel(GL_FLAT); glBegin(GL_QUADS); - for (i=0, pt1=points, pt2=points+1; i < (totpoints-1); i++, pt1++, pt2++) { - float s0[2], s1[2]; /* segment 'center' points */ - float t0[2], t1[2]; /* tessellated coordinates */ - float m1[2], m2[2]; /* gradient and normal */ - float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ - float pthick; /* thickness at segment point */ + for (i = 0, pt1 = points, pt2 = points + 1; i < (totpoints - 1); i++, pt1++, pt2++) { + float s0[2], s1[2]; /* segment 'center' points */ + float t0[2], t1[2]; /* tessellated coordinates */ + float m1[2], m2[2]; /* gradient and normal */ + float mt[2], sc[2]; /* gradient for thickness, point for end-cap */ + float pthick; /* thickness at segment point */ /* get x and y coordinates from points */ if (sflag & GP_STROKE_2DSPACE) { - s0[0]= pt1->x; s0[1]= pt1->y; - s1[0]= pt2->x; s1[1]= pt2->y; + s0[0] = pt1->x; s0[1] = pt1->y; + s1[0] = pt2->x; s1[1] = pt2->y; } else if (sflag & GP_STROKE_2DIMAGE) { - s0[0]= (pt1->x * winx) + offsx; - s0[1]= (pt1->y * winy) + offsy; - s1[0]= (pt2->x * winx) + offsx; - s1[1]= (pt2->y * winy) + offsy; + s0[0] = (pt1->x * winx) + offsx; + s0[1] = (pt1->y * winy) + offsy; + s1[0] = (pt2->x * winx) + offsx; + s1[1] = (pt2->y * winy) + offsy; } else { - s0[0]= (pt1->x / 100 * winx) + offsx; - s0[1]= (pt1->y / 100 * winy) + offsy; - s1[0]= (pt2->x / 100 * winx) + offsx; - s1[1]= (pt2->y / 100 * winy) + offsy; + s0[0] = (pt1->x / 100 * winx) + offsx; + s0[1] = (pt1->y / 100 * winy) + offsy; + s1[0] = (pt2->x / 100 * winx) + offsx; + s1[1] = (pt2->y / 100 * winy) + offsy; } /* calculate gradient and normal - 'angle'=(ny/nx) */ - m1[1]= s1[1] - s0[1]; - m1[0]= s1[0] - s0[0]; + m1[1] = s1[1] - s0[1]; + m1[0] = s1[0] - s0[0]; normalize_v2(m1); - m2[1]= -m1[0]; - m2[0]= m1[1]; + m2[1] = -m1[0]; + m2[0] = m1[1]; /* always use pressure from first point here */ - pthick= (pt1->pressure * thickness); + pthick = (pt1->pressure * thickness); /* if the first segment, start of segment is segment's normal */ if (i == 0) { /* draw start cap first * - make points slightly closer to center (about halfway across) */ - mt[0]= m2[0] * pthick * 0.5f; - mt[1]= m2[1] * pthick * 0.5f; - sc[0]= s0[0] - (m1[0] * pthick * 0.75f); - sc[1]= s0[1] - (m1[1] * pthick * 0.75f); - - t0[0]= sc[0] - mt[0]; - t0[1]= sc[1] - mt[1]; - t1[0]= sc[0] + mt[0]; - t1[1]= sc[1] + mt[1]; + mt[0] = m2[0] * pthick * 0.5f; + mt[1] = m2[1] * pthick * 0.5f; + sc[0] = s0[0] - (m1[0] * pthick * 0.75f); + sc[1] = s0[1] - (m1[1] * pthick * 0.75f); + + t0[0] = sc[0] - mt[0]; + t0[1] = sc[1] - mt[1]; + t1[0] = sc[0] + mt[0]; + t1[1] = sc[1] + mt[1]; glVertex2fv(t0); glVertex2fv(t1); /* calculate points for start of segment */ - mt[0]= m2[0] * pthick; - mt[1]= m2[1] * pthick; + mt[0] = m2[0] * pthick; + mt[1] = m2[1] * pthick; - t0[0]= s0[0] - mt[0]; - t0[1]= s0[1] - mt[1]; - t1[0]= s0[0] + mt[0]; - t1[1]= s0[1] + mt[1]; + t0[0] = s0[0] - mt[0]; + t0[1] = s0[1] - mt[1]; + t1[0] = s0[0] + mt[0]; + t1[1] = s0[1] + mt[1]; /* draw this line twice (first to finish off start cap, then for stroke) */ glVertex2fv(t1); @@ -366,33 +366,33 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s } /* if not the first segment, use bisector of angle between segments */ else { - float mb[2]; /* bisector normal */ - float athick, dfac; /* actual thickness, difference between thicknesses */ + float mb[2]; /* bisector normal */ + float athick, dfac; /* actual thickness, difference between thicknesses */ /* calculate gradient of bisector (as average of normals) */ - mb[0]= (pm[0] + m2[0]) / 2; - mb[1]= (pm[1] + m2[1]) / 2; + mb[0] = (pm[0] + m2[0]) / 2; + mb[1] = (pm[1] + m2[1]) / 2; normalize_v2(mb); /* calculate gradient to apply - * - as basis, use just pthick * bisector gradient + * - as basis, use just pthick * bisector gradient * - if cross-section not as thick as it should be, add extra padding to fix it */ - mt[0]= mb[0] * pthick; - mt[1]= mb[1] * pthick; - athick= len_v2(mt); - dfac= pthick - (athick * 2); + mt[0] = mb[0] * pthick; + mt[1] = mb[1] * pthick; + athick = len_v2(mt); + dfac = pthick - (athick * 2); - if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick)==0)) { + if (((athick * 2.0f) < pthick) && (IS_EQF(athick, pthick) == 0)) { mt[0] += (mb[0] * dfac); mt[1] += (mb[1] * dfac); } /* calculate points for start of segment */ - t0[0]= s0[0] - mt[0]; - t0[1]= s0[1] - mt[1]; - t1[0]= s0[0] + mt[0]; - t1[1]= s0[1] + mt[1]; + t0[0] = s0[0] - mt[0]; + t0[1] = s0[1] - mt[1]; + t1[0] = s0[0] + mt[0]; + t1[1] = s0[1] + mt[1]; /* draw this line twice (once for end of current segment, and once for start of next) */ glVertex2fv(t1); @@ -402,18 +402,18 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s } /* if last segment, also draw end of segment (defined as segment's normal) */ - if (i == totpoints-2) { + if (i == totpoints - 2) { /* for once, we use second point's pressure (otherwise it won't be drawn) */ - pthick= (pt2->pressure * thickness); + pthick = (pt2->pressure * thickness); /* calculate points for end of segment */ - mt[0]= m2[0] * pthick; - mt[1]= m2[1] * pthick; + mt[0] = m2[0] * pthick; + mt[1] = m2[1] * pthick; - t0[0]= s1[0] - mt[0]; - t0[1]= s1[1] - mt[1]; - t1[0]= s1[0] + mt[0]; - t1[1]= s1[1] + mt[1]; + t0[0] = s1[0] - mt[0]; + t0[1] = s1[1] - mt[1]; + t1[0] = s1[0] + mt[0]; + t1[1] = s1[1] + mt[1]; /* draw this line twice (once for end of stroke, and once for endcap)*/ glVertex2fv(t1); @@ -425,15 +425,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s /* draw end cap as last step * - make points slightly closer to center (about halfway across) */ - mt[0]= m2[0] * pthick * 0.5f; - mt[1]= m2[1] * pthick * 0.5f; - sc[0]= s1[0] + (m1[0] * pthick * 0.75f); - sc[1]= s1[1] + (m1[1] * pthick * 0.75f); - - t0[0]= sc[0] - mt[0]; - t0[1]= sc[1] - mt[1]; - t1[0]= sc[0] + mt[0]; - t1[1]= sc[1] + mt[1]; + mt[0] = m2[0] * pthick * 0.5f; + mt[1] = m2[1] * pthick * 0.5f; + sc[0] = s1[0] + (m1[0] * pthick * 0.75f); + sc[1] = s1[1] + (m1[1] * pthick * 0.75f); + + t0[0] = sc[0] - mt[0]; + t0[1] = sc[1] - mt[1]; + t1[0] = sc[0] + mt[0]; + t1[1] = sc[1] + mt[1]; glVertex2fv(t1); glVertex2fv(t0); @@ -452,19 +452,19 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s int i; glBegin(GL_POINTS); - for (i=0, pt=points; i < totpoints && pt; i++, pt++) { + for (i = 0, pt = points; i < totpoints && pt; i++, pt++) { if (sflag & GP_STROKE_2DSPACE) { glVertex2fv(&pt->x); } else if (sflag & GP_STROKE_2DIMAGE) { - const float x= (float)((pt->x * winx) + offsx); - const float y= (float)((pt->y * winy) + offsy); + const float x = (float)((pt->x * winx) + offsx); + const float y = (float)((pt->y * winy) + offsy); glVertex2f(x, y); } else { - const float x= (float)(pt->x / 100 * winx) + offsx; - const float y= (float)(pt->y / 100 * winy) + offsy; + const float x = (float)(pt->x / 100 * winx) + offsx; + const float y = (float)(pt->y / 100 * winy) + offsy; glVertex2f(x, y); } @@ -476,15 +476,15 @@ static void gp_draw_stroke (bGPDspoint *points, int totpoints, short thickness_s /* ----- General Drawing ------ */ /* draw a set of strokes */ -static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag, - short debug, short lthick, float color[4]) +static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int winy, int dflag, + short debug, short lthick, float color[4]) { bGPDstroke *gps; /* set color first (may need to reset it again later too) */ glColor4fv(color); - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps = gpf->strokes.first; gps; gps = gps->next) { /* check if stroke can be drawn - checks here generally fall into pairs */ if ((dflag & GP_DRAWDATA_ONLY3D) && !(gps->flag & GP_STROKE_3DSPACE)) continue; @@ -505,7 +505,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int if (gps->totpoints == 1) gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy); else if (dflag & GP_DRAWDATA_ONLY3D) { - const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY); + const int no_xray = (dflag & GP_DRAWDATA_NO_XRAY); int mask_orig = 0; if (no_xray) { @@ -540,7 +540,7 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int } /* draw grease-pencil datablock */ -static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) +static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) { bGPDlayer *gpl; @@ -555,11 +555,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy glEnable(GL_BLEND); /* loop over layers, drawing them */ - for (gpl= gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = gpd->layers.first; gpl; gpl = gpl->next) { bGPDframe *gpf; short debug = (gpl->flag & GP_LAYER_DRAWDEBUG) ? 1 : 0; - short lthick= gpl->thickness; + short lthick = gpl->thickness; float color[4], tcolor[4]; /* don't draw layer if hidden */ @@ -567,7 +567,7 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy continue; /* get frame to draw */ - gpf= gpencil_layer_getframe(gpl, cfra, 0); + gpf = gpencil_layer_getframe(gpl, cfra, 0); if (gpf == NULL) continue; @@ -579,8 +579,8 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy glPointSize((float)(gpl->thickness + 2)); /* apply xray layer setting */ - if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; - else dflag &= ~GP_DRAWDATA_NO_XRAY; + if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; + else dflag &= ~GP_DRAWDATA_NO_XRAY; /* draw 'onionskins' (frame left + right) */ if (gpl->flag & GP_LAYER_ONIONSKIN) { @@ -590,11 +590,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy float fac; /* draw previous frames first */ - for (gf=gpf->prev; gf; gf=gf->prev) { + for (gf = gpf->prev; gf; gf = gf->prev) { /* check if frame is drawable */ if ((gpf->framenum - gf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - fac= 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); + fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1)); tcolor[3] = color[3] * fac * 0.66f; gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); } @@ -603,11 +603,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy } /* now draw next frames */ - for (gf= gpf->next; gf; gf=gf->next) { + for (gf = gpf->next; gf; gf = gf->next) { /* check if frame is drawable */ if ((gf->framenum - gpf->framenum) <= gpl->gstep) { /* alpha decreases with distance from curframe index */ - fac= 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1)); + fac = 1.0f - ((float)(gf->framenum - gpf->framenum) / (float)(gpl->gstep + 1)); tcolor[3] = color[3] * fac * 0.66f; gp_draw_strokes(gf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); } @@ -636,14 +636,14 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy } /* draw the strokes already in active frame */ - tcolor[3]= color[3]; + tcolor[3] = color[3]; gp_draw_strokes(gpf, offsx, offsy, winx, winy, dflag, debug, lthick, tcolor); /* Check if may need to draw the active stroke cache, only if this layer is the active layer * that is being edited. (Stroke buffer is currently stored in gp-data) */ if (ED_gpencil_session_active() && (gpl->flag & GP_LAYER_ACTIVE) && - (gpf->flag & GP_FRAME_PAINT)) + (gpf->flag & GP_FRAME_PAINT)) { /* Buffer stroke needs to be drawn with a different linestyle to help differentiate them from normal strokes. */ gp_draw_stroke_buffer(gpd->sbuffer, gpd->sbuffer_size, lthick, dflag, gpd->sbuffer_sflag); @@ -671,16 +671,16 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy /* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); bGPdata *gpd; int offsx, offsy, sizex, sizey; int dflag = GP_DRAWDATA_NOSTATUS; /* check that we have grease-pencil stuff to draw */ if (ELEM(NULL, sa, ibuf)) return; - gpd= gpencil_data_get_active(C); // XXX + gpd = gpencil_data_get_active(C); // XXX if (gpd == NULL) return; /* calculate rect */ @@ -691,24 +691,24 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) /* just draw using standard scaling (settings here are currently ignored anyways) */ // FIXME: the opengl poly-strokes don't draw at right thickness when done this way, so disabled - offsx= 0; - offsy= 0; - sizex= ar->winx; - sizey= ar->winy; + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax); - dflag |= GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_IEDITHACK; + dflag |= GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_IEDITHACK; } - break; -#if 0 /* removed since 2.5x, needs to be added back */ + break; +#if 0 /* removed since 2.5x, needs to be added back */ case SPACE_SEQ: /* sequence */ { - SpaceSeq *sseq= (SpaceSeq *)sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)sa->spacedata.first; float zoom, zoomx, zoomy; /* calculate accessory values */ - zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom)); + zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { /* XXX sequencer zoom should store it? */ zoomx = zoom; // * (G.scene->r.xasp / G.scene->r.yasp); @@ -718,20 +718,20 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) zoomx = zoomy = zoom; /* calculate transforms (Note: we use ibuf here, as we have it) */ - sizex= (int)(zoomx * ibuf->x); - sizey= (int)(zoomy * ibuf->y); - offsx= (int)( (ar->winx-sizex)/2 + sseq->xof ); - offsy= (int)( (ar->winy-sizey)/2 + sseq->yof ); + sizex = (int)(zoomx * ibuf->x); + sizey = (int)(zoomy * ibuf->y); + offsx = (int)( (ar->winx - sizex) / 2 + sseq->xof); + offsy = (int)( (ar->winy - sizey) / 2 + sseq->yof); dflag |= GP_DRAWDATA_ONLYI2D; } - break; + break; #endif default: /* for spacetype not yet handled */ - offsx= 0; - offsy= 0; - sizex= ar->winx; - sizey= ar->winy; + offsx = 0; + offsy = 0; + sizex = ar->winx; + sizey = ar->winy; dflag |= GP_DRAWDATA_ONLYI2D; break; @@ -747,15 +747,15 @@ void draw_gpencil_2dimage(bContext *C, ImBuf *ibuf) */ void draw_gpencil_view2d(bContext *C, short onlyv2d) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); bGPdata *gpd; int dflag = 0; /* check that we have grease-pencil stuff to draw */ if (sa == NULL) return; - gpd= gpencil_data_get_active(C); // XXX + gpd = gpencil_data_get_active(C); // XXX if (gpd == NULL) return; /* special hack for Image Editor */ @@ -764,7 +764,7 @@ void draw_gpencil_view2d(bContext *C, short onlyv2d) dflag |= GP_DRAWDATA_IEDITHACK; /* draw it! */ - if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D|GP_DRAWDATA_NOSTATUS); + if (onlyv2d) dflag |= (GP_DRAWDATA_ONLYV2D | GP_DRAWDATA_NOSTATUS); gp_draw_data(gpd, 0, 0, ar->winx, ar->winy, CFRA, dflag); } @@ -777,10 +777,10 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) bGPdata *gpd; int dflag = 0; rcti rect; - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* check that we have grease-pencil stuff to draw */ - gpd= gpencil_data_get_active_v3d(scene); // XXX + gpd = gpencil_data_get_active_v3d(scene); // XXX if (gpd == NULL) return; /* when rendering to the offscreen buffer we don't want to @@ -798,7 +798,7 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, short only3d) } /* draw it! */ - if (only3d) dflag |= (GP_DRAWDATA_ONLY3D|GP_DRAWDATA_NOSTATUS); + if (only3d) dflag |= (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_NOSTATUS); gp_draw_data(gpd, rect.xmin, rect.ymin, rect.xmax, rect.ymax, CFRA, dflag); } diff --git a/source/blender/editors/gpencil/editaction_gpencil.c b/source/blender/editors/gpencil/editaction_gpencil.c index b79516ed25e..9cc738b016e 100644 --- a/source/blender/editors/gpencil/editaction_gpencil.c +++ b/source/blender/editors/gpencil/editaction_gpencil.c @@ -54,9 +54,9 @@ /* ***************************************** */ /* NOTE ABOUT THIS FILE: - * This file contains code for editing Grease Pencil data in the Action Editor - * as a 'keyframes', so that a user can adjust the timing of Grease Pencil drawings. - * Therefore, this file mostly contains functions for selecting Grease-Pencil frames. + * This file contains code for editing Grease Pencil data in the Action Editor + * as a 'keyframes', so that a user can adjust the timing of Grease Pencil drawings. + * Therefore, this file mostly contains functions for selecting Grease-Pencil frames. */ /* ***************************************** */ /* Generics - Loopers */ @@ -71,7 +71,7 @@ short gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDfr return 0; /* do loop */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* execute callback */ if (gpf_cb(gpf, scene)) return 1; @@ -95,12 +95,12 @@ void gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, short onlysel) return; /* loop through gp-frames, adding */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if ((onlysel == 0) || (gpf->flag & GP_FRAME_SELECT)) { - ce= MEM_callocN(sizeof(CfraElem), "CfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "CfraElem"); - ce->cfra= (float)gpf->framenum; - ce->sel= (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; + ce->cfra = (float)gpf->framenum; + ce->sel = (gpf->flag & GP_FRAME_SELECT) ? 1 : 0; BLI_addtail(elems, ce); } @@ -120,7 +120,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl) return 0; /* stop at the first one found */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (gpf->flag & GP_FRAME_SELECT) return 1; } @@ -130,7 +130,7 @@ short is_gplayer_frame_selected(bGPDlayer *gpl) } /* helper function - select gp-frame based on SELECT_* mode */ -static void gpframe_select (bGPDframe *gpf, short select_mode) +static void gpframe_select(bGPDframe *gpf, short select_mode) { if (gpf == NULL) return; @@ -158,7 +158,7 @@ void select_gpencil_frames(bGPDlayer *gpl, short select_mode) return; /* handle according to mode */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { gpframe_select(gpf, select_mode); } } @@ -183,7 +183,7 @@ void select_gpencil_frame(bGPDlayer *gpl, int selx, short select_mode) return; /* search through frames for a match */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { /* there should only be one frame with this frame-number */ if (gpf->framenum == selx) { gpframe_select(gpf, select_mode); @@ -201,7 +201,7 @@ void borderselect_gplayer_frames(bGPDlayer *gpl, float min, float max, short sel return; /* only select those frames which are in bounds */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { if (IN_RANGE(gpf->framenum, min, max)) gpframe_select(gpf, select_mode); } @@ -220,8 +220,8 @@ void delete_gplayer_frames(bGPDlayer *gpl) return; /* check for frames to delete */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; if (gpf->flag & GP_FRAME_SELECT) gpencil_layer_delframe(gpl, gpf); @@ -238,15 +238,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl) return; /* duplicate selected frames */ - for (gpf= gpl->frames.first; gpf; gpf= gpfn) { - gpfn= gpf->next; + for (gpf = gpl->frames.first; gpf; gpf = gpfn) { + gpfn = gpf->next; /* duplicate this frame */ if (gpf->flag & GP_FRAME_SELECT) { bGPDframe *gpfd; /* duplicate frame, and deselect self */ - gpfd= gpencil_frame_duplicate(gpf); + gpfd = gpencil_frame_duplicate(gpf); gpf->flag &= ~GP_FRAME_SELECT; BLI_insertlinkafter(&gpl->frames, gpf, gpfd); @@ -267,15 +267,15 @@ void duplicate_gplayer_frames(bGPDlayer *gpl) /* globals for copy/paste data (like for other copy/paste buffers) */ ListBase gpcopybuf = {NULL, NULL}; -static int gpcopy_firstframe= 999999999; +static int gpcopy_firstframe = 999999999; /* This function frees any MEM_calloc'ed copy/paste buffer data */ void free_gpcopybuf() { free_gpencil_layers(&gpcopybuf); - gpcopybuf.first= gpcopybuf.last= NULL; - gpcopy_firstframe= 999999999; + gpcopybuf.first = gpcopybuf.last = NULL; + gpcopy_firstframe = 999999999; } /* This function adds data to the copy/paste buffer, freeing existing data first @@ -293,39 +293,39 @@ void copy_gpdata() free_gpcopybuf(); /* get data */ - data= get_action_context(&datatype); + data = get_action_context(&datatype); if (data == NULL) return; if (datatype != ACTCONT_GPENCIL) return; /* filter data */ - filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL); + filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL); actdata_filter(&act_data, filter, data, datatype); /* assume that each of these is an ipo-block */ - for (ale= act_data.first; ale; ale= ale->next) { + for (ale = act_data.first; ale; ale = ale->next) { bGPDlayer *gpls, *gpln; bGPDframe *gpf, *gpfn; /* get new layer to put into buffer */ - gpls= (bGPDlayer *)ale->data; - gpln= MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); + gpls = (bGPDlayer *)ale->data; + gpln = MEM_callocN(sizeof(bGPDlayer), "GPCopyPasteLayer"); - gpln->frames.first= gpln->frames.last= NULL; + gpln->frames.first = gpln->frames.last = NULL; BLI_strncpy(gpln->info, gpls->info, sizeof(gpln->info)); BLI_addtail(&gpcopybuf, gpln); /* loop over frames, and copy only selected frames */ - for (gpf= gpls->frames.first; gpf; gpf= gpf->next) { + for (gpf = gpls->frames.first; gpf; gpf = gpf->next) { /* if frame is selected, make duplicate it and its strokes */ if (gpf->flag & GP_FRAME_SELECT) { /* add frame to buffer */ - gpfn= gpencil_frame_duplicate(gpf); + gpfn = gpencil_frame_duplicate(gpf); BLI_addtail(&gpln->frames, gpfn); /* check if this is the earliest frame encountered so far */ if (gpf->framenum < gpcopy_firstframe) - gpcopy_firstframe= gpf->framenum; + gpcopy_firstframe = gpf->framenum; } } } @@ -347,7 +347,7 @@ void paste_gpdata(Scene *scene) short datatype; const int offset = (CFRA - gpcopy_firstframe); - short no_name= 0; + short no_name = 0; /* check if buffer is empty */ if (ELEM(NULL, gpcopybuf.first, gpcopybuf.last)) { @@ -356,27 +356,27 @@ void paste_gpdata(Scene *scene) } /* check if single channel in buffer (disregard names if so) */ if (gpcopybuf.first == gpcopybuf.last) - no_name= 1; + no_name = 1; /* get data */ - data= get_action_context(&datatype); + data = get_action_context(&datatype); if (data == NULL) return; if (datatype != ACTCONT_GPENCIL) return; /* filter data */ - filter= (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT); + filter = (ACTFILTER_VISIBLE | ACTFILTER_SEL | ACTFILTER_FOREDIT); actdata_filter(&act_data, filter, data, datatype); /* from selected channels */ - for (ale= act_data.first; ale; ale= ale->next) { - bGPDlayer *gpld= (bGPDlayer *)ale->data; - bGPDlayer *gpls= NULL; + for (ale = act_data.first; ale; ale = ale->next) { + bGPDlayer *gpld = (bGPDlayer *)ale->data; + bGPDlayer *gpls = NULL; bGPDframe *gpfs, *gpf; /* find suitable layer from buffer to use to paste from */ - for (gpls= gpcopybuf.first; gpls; gpls= gpls->next) { + for (gpls = gpcopybuf.first; gpls; gpls = gpls->next) { /* check if layer name matches */ - if ((no_name) || (strcmp(gpls->info, gpld->info)==0)) + if ((no_name) || (strcmp(gpls->info, gpld->info) == 0)) break; } @@ -385,12 +385,12 @@ void paste_gpdata(Scene *scene) continue; /* add frames from buffer */ - for (gpfs= gpls->frames.first; gpfs; gpfs= gpfs->next) { + for (gpfs = gpls->frames.first; gpfs; gpfs = gpfs->next) { /* temporarily apply offset to buffer-frame while copying */ gpfs->framenum += offset; /* get frame to copy data into (if no frame returned, then just ignore) */ - gpf= gpencil_layer_getframe(gpld, gpfs->framenum, 1); + gpf = gpencil_layer_getframe(gpld, gpfs->framenum, 1); if (gpf) { bGPDstroke *gps, *gpsn; ScrArea *sa; @@ -404,12 +404,12 @@ void paste_gpdata(Scene *scene) * - we cannot just add a duplicate frame, as that would cause errors * - need to check for compatible types to minimise memory usage (copying 'junk' over) */ - for (gps= gpfs->strokes.first; gps; gps= gps->next) { + for (gps = gpfs->strokes.first; gps; gps = gps->next) { short stroke_ok; /* if there's an area, check that it supports this type of stroke */ if (sa) { - stroke_ok= 0; + stroke_ok = 0; /* check if spacetype supports this type of stroke * - NOTE: must sync this with gp_paint_initstroke() in gpencil.c @@ -417,30 +417,30 @@ void paste_gpdata(Scene *scene) switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View: either screen-aligned or 3d-space */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_3DSPACE)) - stroke_ok= 1; + stroke_ok = 1; break; case SPACE_NODE: /* Nodes Editor: either screen-aligned or view-aligned */ case SPACE_IMAGE: /* Image Editor: either screen-aligned or view\image-aligned */ case SPACE_CLIP: /* Image Editor: either screen-aligned or view\image-aligned */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DSPACE)) - stroke_ok= 1; + stroke_ok = 1; break; case SPACE_SEQ: /* Sequence Editor: either screen-aligned or view-aligned */ if ((gps->flag == 0) || (gps->flag & GP_STROKE_2DIMAGE)) - stroke_ok= 1; + stroke_ok = 1; break; } } else - stroke_ok= 1; + stroke_ok = 1; /* if stroke is ok, we make a copy of this stroke and add to frame */ if (stroke_ok) { /* make a copy of stroke, then of its points array */ - gpsn= MEM_dupallocN(gps); - gpsn->points= MEM_dupallocN(gps->points); + gpsn = MEM_dupallocN(gps); + gpsn->points = MEM_dupallocN(gps->points); /* append stroke to frame */ BLI_addtail(&gpf->strokes, gpsn); @@ -467,32 +467,32 @@ void paste_gpdata(Scene *scene) /* -------------------------------------- */ /* Snap Tools */ -static short snap_gpf_nearest (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearest(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)(floor(gpf->framenum+0.5)); + gpf->framenum = (int)(floor(gpf->framenum + 0.5)); return 0; } -static short snap_gpf_nearestsec (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearestsec(bGPDframe *gpf, Scene *scene) { float secf = (float)FPS; if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)(floor(gpf->framenum/secf + 0.5f) * secf); + gpf->framenum = (int)(floor(gpf->framenum / secf + 0.5f) * secf); return 0; } -static short snap_gpf_cframe (bGPDframe *gpf, Scene *scene) +static short snap_gpf_cframe(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)CFRA; + gpf->framenum = (int)CFRA; return 0; } -static short snap_gpf_nearmarker (bGPDframe *gpf, Scene *scene) +static short snap_gpf_nearmarker(bGPDframe *gpf, Scene *scene) { if (gpf->flag & GP_FRAME_SELECT) - gpf->framenum= (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum); + gpf->framenum = (int)find_nearest_marker_time(&scene->markers, (float)gpf->framenum); return 0; } @@ -522,43 +522,43 @@ void snap_gplayer_frames(bGPDlayer *gpl, Scene *scene, short mode) /* -------------------------------------- */ /* Mirror Tools */ -static short mirror_gpf_cframe (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_cframe(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= CFRA - gpf->framenum; - gpf->framenum= CFRA; + diff = CFRA - gpf->framenum; + gpf->framenum = CFRA; } return 0; } -static short mirror_gpf_yaxis (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_yaxis(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= -gpf->framenum; - gpf->framenum= diff; + diff = -gpf->framenum; + gpf->framenum = diff; } return 0; } -static short mirror_gpf_xaxis (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_xaxis(bGPDframe *gpf, Scene *scene) { int diff; if (gpf->flag & GP_FRAME_SELECT) { - diff= -gpf->framenum; - gpf->framenum= diff; + diff = -gpf->framenum; + gpf->framenum = diff; } return 0; } -static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) +static short mirror_gpf_marker(bGPDframe *gpf, Scene *scene) { static TimeMarker *marker; static short initialized = 0; @@ -575,8 +575,8 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) if (gpf) { /* mirroring time */ if ((gpf->flag & GP_FRAME_SELECT) && (marker)) { - diff= (marker->frame - gpf->framenum); - gpf->framenum= (marker->frame + diff); + diff = (marker->frame - gpf->framenum); + gpf->framenum = (marker->frame + diff); } } else { @@ -588,9 +588,9 @@ static short mirror_gpf_marker (bGPDframe *gpf, Scene *scene) } else { /* try to find a marker */ - marker= ED_markers_get_first_selected(&scene->markers); + marker = ED_markers_get_first_selected(&scene->markers); if (marker) { - initialized= 1; + initialized = 1; } } } diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index 263c842ed08..3a7e806c2ed 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -74,7 +74,7 @@ static void gp_ui_activelayer_cb(bContext *C, void *gpd, void *gpl) /* make sure the layer we want to remove is the active one */ gpencil_layer_setactive(gpd, gpl); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ } /* delete 'active' layer */ @@ -84,7 +84,7 @@ static void gp_ui_dellayer_cb(bContext *C, void *gpd, void *gpl) gpencil_layer_setactive(gpd, gpl); gpencil_layer_delactive(gpd); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ } @@ -133,7 +133,7 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons uiItemR(sub, &ptr, "lock", 0, "", icon); /* when layer is locked or hidden, only draw header */ - if (gpl->flag & (GP_LAYER_LOCKED|GP_LAYER_HIDE)) { + if (gpl->flag & (GP_LAYER_LOCKED | GP_LAYER_HIDE)) { char name[256]; /* gpl->info is 128, but we need space for 'locked/hidden' as well */ /* visibility button (only if hidden but not locked!) */ @@ -197,8 +197,8 @@ static void gp_drawui_layer(uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, cons /* color */ sub = uiLayoutColumn(col, 1); - uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); - uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); + uiItemR(sub, &ptr, "color", 0, "", ICON_NONE); + uiItemR(sub, &ptr, "alpha", UI_ITEM_R_SLIDER, NULL, ICON_NONE); /* stroke thickness */ uiItemR(col, &ptr, "line_width", UI_ITEM_R_SLIDER, NULL, ICON_NONE); @@ -251,8 +251,8 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* add new layer button - can be used even when no data, since it can add a new block too */ uiItemO(col, IFACE_("New Layer"), ICON_NONE, "GPENCIL_OT_layer_add"); row = uiLayoutRow(col, 1); - uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); - uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); + uiItemO(row, IFACE_("Delete Frame"), ICON_NONE, "GPENCIL_OT_active_frame_delete"); + uiItemO(row, IFACE_("Convert"), ICON_NONE, "GPENCIL_OT_convert"); /* sanity checks... */ if (gpd == NULL) @@ -266,29 +266,29 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin /* draw gpd drawing settings first ------------------------------------- */ col = uiLayoutColumn(layout, 1); - /* label */ - uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); + /* label */ + uiItemL(col, IFACE_("Drawing Settings:"), ICON_NONE); - /* check whether advanced 3D-View drawing space options can be used */ - if (is_v3d) { - if (gpd->flag & (GP_DATA_DEPTH_STROKE|GP_DATA_DEPTH_VIEW)) - v3d_stroke_opts = STROKE_OPTS_V3D_ON; - else - v3d_stroke_opts = STROKE_OPTS_V3D_OFF; - } + /* check whether advanced 3D-View drawing space options can be used */ + if (is_v3d) { + if (gpd->flag & (GP_DATA_DEPTH_STROKE | GP_DATA_DEPTH_VIEW)) + v3d_stroke_opts = STROKE_OPTS_V3D_ON; + else + v3d_stroke_opts = STROKE_OPTS_V3D_OFF; + } - /* drawing space options */ - row= uiLayoutRow(col, 1); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); - row= uiLayoutRow(col, 1); - uiLayoutSetActive(row, v3d_stroke_opts); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); - uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); - - row= uiLayoutRow(col, 0); - uiLayoutSetActive(row, v3d_stroke_opts==STROKE_OPTS_V3D_ON); - uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); + /* drawing space options */ + row = uiLayoutRow(col, 1); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "VIEW", NULL, ICON_NONE); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "CURSOR", NULL, ICON_NONE); + row = uiLayoutRow(col, 1); + uiLayoutSetActive(row, v3d_stroke_opts); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "SURFACE", NULL, ICON_NONE); + uiItemEnumR_string(row, &gpd_ptr, "draw_mode", "STROKE", NULL, ICON_NONE); + + row = uiLayoutRow(col, 0); + uiLayoutSetActive(row, v3d_stroke_opts == STROKE_OPTS_V3D_ON); + uiItemR(row, &gpd_ptr, "use_stroke_endpoints", 0, NULL, ICON_NONE); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 34a95cd89bf..9250d48a20c 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -77,10 +77,10 @@ /* Context Wrangling... */ /* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */ -bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) +bGPdata **gpencil_data_get_pointers(bContext *C, PointerRNA *ptr) { - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); /* if there's an active area, check if the particular editor may * have defined any special Grease Pencil context for editing... @@ -89,7 +89,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) switch (sa->spacetype) { case SPACE_VIEW3D: /* 3D-View */ { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); // TODO: we can include other data-types such as bones later if need be... @@ -100,11 +100,11 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return &ob->gpd; } } - break; + break; case SPACE_NODE: /* Nodes Editor */ { - SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C); + SpaceNode *snode = (SpaceNode *)CTX_wm_space_data(C); /* return the GP data for the active node block/node */ if (snode && snode->nodetree) { @@ -117,7 +117,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return NULL; } } - break; + break; case SPACE_SEQ: /* Sequencer */ { @@ -125,23 +125,23 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) /* return the GP data for the active strips/image/etc. */ } - break; + break; case SPACE_IMAGE: /* Image/UV Editor */ { - SpaceImage *sima= (SpaceImage *)CTX_wm_space_data(C); + SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C); /* for now, Grease Pencil data is associated with the space... */ // XXX our convention for everything else is to link to data though... if (ptr) RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_SpaceImageEditor, sima, ptr); return &sima->gpd; } - break; + break; case SPACE_CLIP: /* Nodes Editor */ { - SpaceClip *sc= (SpaceClip *)CTX_wm_space_data(C); - MovieClip *clip= ED_space_clip(sc); + SpaceClip *sc = (SpaceClip *)CTX_wm_space_data(C); + MovieClip *clip = ED_space_clip(sc); if (clip) { /* for now, as long as there's a clip, default to using that in Clip Editor */ @@ -149,7 +149,7 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) return &clip->gpd; } } - break; + break; default: /* unsupported space */ return NULL; @@ -162,16 +162,16 @@ bGPdata **gpencil_data_get_pointers (bContext *C, PointerRNA *ptr) } /* Get the active Grease Pencil datablock */ -bGPdata *gpencil_data_get_active (bContext *C) +bGPdata *gpencil_data_get_active(bContext *C) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); return (gpd_ptr) ? *(gpd_ptr) : NULL; } /* needed for offscreen rendering */ -bGPdata *gpencil_data_get_active_v3d (Scene *scene) +bGPdata *gpencil_data_get_active_v3d(Scene *scene) { - bGPdata *gpd= scene->basact ? scene->basact->object->gpd : NULL; + bGPdata *gpd = scene->basact ? scene->basact->object->gpd : NULL; return gpd ? gpd : scene->gpd; } @@ -179,7 +179,7 @@ bGPdata *gpencil_data_get_active_v3d (Scene *scene) /* Panel Operators */ /* poll callback for adding data/layers - special */ -static int gp_add_poll (bContext *C) +static int gp_add_poll(bContext *C) { /* the base line we have is that we have somewhere to add Grease Pencil data */ return gpencil_data_get_pointers(C, NULL) != NULL; @@ -188,9 +188,9 @@ static int gp_add_poll (bContext *C) /* ******************* Add New Data ************************ */ /* add new datablock - wrapper around API */ -static int gp_data_add_exec (bContext *C, wmOperator *op) +static int gp_data_add_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); @@ -198,14 +198,14 @@ static int gp_data_add_exec (bContext *C, wmOperator *op) } else { /* decrement user count and add new datablock */ - bGPdata *gpd= (*gpd_ptr); + bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr= gpencil_data_addnew("GPencil"); + *gpd_ptr = gpencil_data_addnew("GPencil"); } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work return OPERATOR_FINISHED; } @@ -216,7 +216,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) ot->name = "Grease Pencil Add New"; ot->idname = "GPENCIL_OT_data_add"; ot->description = "Add new Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_data_add_exec; @@ -226,9 +226,9 @@ void GPENCIL_OT_data_add(wmOperatorType *ot) /* ******************* Unlink Data ************************ */ /* poll callback for adding data/layers - special */ -static int gp_data_unlink_poll (bContext *C) +static int gp_data_unlink_poll(bContext *C) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); /* if we have access to some active data, make sure there's a datablock before enabling this */ return (gpd_ptr && *gpd_ptr); @@ -236,9 +236,9 @@ static int gp_data_unlink_poll (bContext *C) /* unlink datablock - wrapper around API */ -static int gp_data_unlink_exec (bContext *C, wmOperator *op) +static int gp_data_unlink_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); if (gpd_ptr == NULL) { BKE_report(op->reports, RPT_ERROR, "Nowhere for Grease Pencil data to go"); @@ -246,14 +246,14 @@ static int gp_data_unlink_exec (bContext *C, wmOperator *op) } else { /* just unlink datablock now, decreasing its user count */ - bGPdata *gpd= (*gpd_ptr); + bGPdata *gpd = (*gpd_ptr); id_us_min(&gpd->id); - *gpd_ptr= NULL; + *gpd_ptr = NULL; } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work return OPERATOR_FINISHED; } @@ -264,7 +264,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) ot->name = "Grease Pencil Unlink"; ot->idname = "GPENCIL_OT_data_unlink"; ot->description = "Unlink active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_data_unlink_exec; @@ -274,9 +274,9 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot) /* ******************* Add New Layer ************************ */ /* add new layer - wrapper around API */ -static int gp_layer_add_exec (bContext *C, wmOperator *op) +static int gp_layer_add_exec(bContext *C, wmOperator *op) { - bGPdata **gpd_ptr= gpencil_data_get_pointers(C, NULL); + bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL); /* if there's no existing Grease-Pencil data there, add some */ if (gpd_ptr == NULL) { @@ -284,13 +284,13 @@ static int gp_layer_add_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } if (*gpd_ptr == NULL) - *gpd_ptr= gpencil_data_addnew("GPencil"); + *gpd_ptr = gpencil_data_addnew("GPencil"); /* add new layer now */ gpencil_layer_addnew(*gpd_ptr); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! return OPERATOR_FINISHED; } @@ -301,7 +301,7 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) ot->name = "Add New Layer"; ot->idname = "GPENCIL_OT_layer_add"; ot->description = "Add new Grease Pencil layer for the active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_layer_add_exec; @@ -310,22 +310,22 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot) /* ******************* Delete Active Frame ************************ */ -static int gp_actframe_delete_poll (bContext *C) +static int gp_actframe_delete_poll(bContext *C) { - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); /* only if there's an active layer with an active frame */ return (gpl && gpl->actframe); } /* delete active frame - wrapper around API calls */ -static int gp_actframe_delete_exec (bContext *C, wmOperator *op) +static int gp_actframe_delete_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); - bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + Scene *scene = CTX_data_scene(C); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); /* if there's no existing Grease-Pencil data there, add some */ if (gpd == NULL) { @@ -341,7 +341,7 @@ static int gp_actframe_delete_exec (bContext *C, wmOperator *op) gpencil_layer_delframe(gpl, gpf); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! return OPERATOR_FINISHED; } @@ -352,7 +352,7 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot) ot->name = "Delete Active Frame"; ot->idname = "GPENCIL_OT_active_frame_delete"; ot->description = "Delete the active frame for the active Grease Pencil datablock"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->exec = gp_actframe_delete_exec; @@ -380,35 +380,35 @@ static EnumPropertyItem prop_gpencil_convertmodes[] = { /* convert the coordinates from the given stroke point into 3d-coordinates * - assumes that the active space is the 3D-View */ -static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect) +static void gp_strokepoint_convertcoords(bContext *C, bGPDstroke *gps, bGPDspoint *pt, float p3d[3], rctf *subrect) { - Scene *scene= CTX_data_scene(C); - View3D *v3d= CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); if (gps->flag & GP_STROKE_3DSPACE) { /* directly use 3d-coordinates */ copy_v3_v3(p3d, &pt->x); } else { - float *fp= give_cursor(scene, v3d); + float *fp = give_cursor(scene, v3d); float mvalf[2]; /* get screen coordinate */ if (gps->flag & GP_STROKE_2DSPACE) { int mvali[2]; - View2D *v2d= &ar->v2d; - UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali+1); + View2D *v2d = &ar->v2d; + UI_view2d_view_to_region(v2d, pt->x, pt->y, mvali, mvali + 1); VECCOPY2D(mvalf, mvali); } else { if (subrect) { - mvalf[0]= (((float)pt->x/100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; - mvalf[1]= (((float)pt->y/100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; + mvalf[0] = (((float)pt->x / 100.0f) * (subrect->xmax - subrect->xmin)) + subrect->xmin; + mvalf[1] = (((float)pt->y / 100.0f) * (subrect->ymax - subrect->ymin)) + subrect->ymin; } else { - mvalf[0]= (float)pt->x / 100.0f * ar->winx; - mvalf[1]= (float)pt->y / 100.0f * ar->winy; + mvalf[0] = (float)pt->x / 100.0f * ar->winx; + mvalf[1] = (float)pt->y / 100.0f * ar->winy; } } @@ -422,7 +422,7 @@ static void gp_strokepoint_convertcoords (bContext *C, bGPDstroke *gps, bGPDspoi /* --- */ /* convert stroke to 3d path */ -static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) +static void gp_stroke_to_path(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) { bGPDspoint *pt; Nurb *nu; @@ -432,16 +432,16 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_path(nurb)"); - nu->pntsu= gps->totpoints; - nu->pntsv= 1; - nu->orderu= gps->totpoints; - nu->flagu= CU_NURB_ENDPOINT; - nu->resolu= 32; + nu->pntsu = gps->totpoints; + nu->pntsv = 1; + nu->orderu = gps->totpoints; + nu->flagu = CU_NURB_ENDPOINT; + nu->resolu = 32; - nu->bp= (BPoint *)MEM_callocN(sizeof(BPoint)*gps->totpoints, "bpoints"); + nu->bp = (BPoint *)MEM_callocN(sizeof(BPoint) * gps->totpoints, "bpoints"); /* add points */ - for (i=0, pt=gps->points, bp=nu->bp; i < gps->totpoints; i++, pt++, bp++) { + for (i = 0, pt = gps->points, bp = nu->bp; i < gps->totpoints; i++, pt++, bp++) { float p3d[3]; /* get coordinates to add at */ @@ -449,7 +449,7 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur copy_v3_v3(bp->vec, p3d); /* set settings */ - bp->f1= SELECT; + bp->f1 = SELECT; bp->radius = bp->weight = pt->pressure * gpl->thickness; } @@ -459,15 +459,15 @@ static void gp_stroke_to_path (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Cur static int gp_camera_view_subrect(bContext *C, rctf *subrect) { - View3D *v3d= CTX_wm_view3d(C); - ARegion *ar= CTX_wm_region(C); + View3D *v3d = CTX_wm_view3d(C); + ARegion *ar = CTX_wm_region(C); if (v3d) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ED_view3d_calc_camera_border(scene, ar, v3d, rv3d, subrect, TRUE); /* no shift */ return 1; } @@ -477,7 +477,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) } /* convert stroke to 3d bezier */ -static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) +static void gp_stroke_to_bezier(bContext *C, bGPDlayer *gpl, bGPDstroke *gps, Curve *cu, rctf *subrect) { bGPDspoint *pt; Nurb *nu; @@ -488,31 +488,31 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C /* create new 'nurb' within the curve */ nu = (Nurb *)MEM_callocN(sizeof(Nurb), "gpstroke_to_bezier(nurb)"); - nu->pntsu= gps->totpoints; - nu->resolu= 12; - nu->resolv= 12; - nu->type= CU_BEZIER; - nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints*sizeof(BezTriple), "bezts"); + nu->pntsu = gps->totpoints; + nu->resolu = 12; + nu->resolv = 12; + nu->type = CU_BEZIER; + nu->bezt = (BezTriple *)MEM_callocN(gps->totpoints * sizeof(BezTriple), "bezts"); - tot= gps->totpoints; + tot = gps->totpoints; /* get initial coordinates */ - pt=gps->points; + pt = gps->points; if (tot) { gp_strokepoint_convertcoords(C, gps, pt, p3d_cur, subrect); if (tot > 1) { - gp_strokepoint_convertcoords(C, gps, pt+1, p3d_next, subrect); + gp_strokepoint_convertcoords(C, gps, pt + 1, p3d_next, subrect); } } /* add points */ - for (i=0, bezt=nu->bezt; i < tot; i++, pt++, bezt++) { + for (i = 0, bezt = nu->bezt; i < tot; i++, pt++, bezt++) { float h1[3], h2[3]; if (i) interp_v3_v3v3(h1, p3d_cur, p3d_prev, 0.3); else interp_v3_v3v3(h1, p3d_cur, p3d_next, -0.3); - if (i < tot-1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); + if (i < tot - 1) interp_v3_v3v3(h2, p3d_cur, p3d_next, 0.3); else interp_v3_v3v3(h2, p3d_cur, p3d_prev, -0.3); copy_v3_v3(bezt->vec[0], h1); @@ -520,8 +520,8 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C copy_v3_v3(bezt->vec[2], h2); /* set settings */ - bezt->h1= bezt->h2= HD_FREE; - bezt->f1= bezt->f2= bezt->f3= SELECT; + bezt->h1 = bezt->h2 = HD_FREE; + bezt->f1 = bezt->f2 = bezt->f3 = SELECT; bezt->radius = bezt->weight = pt->pressure * gpl->thickness * 0.1f; /* shift coord vects */ @@ -541,16 +541,16 @@ static void gp_stroke_to_bezier (bContext *C, bGPDlayer *gpl, bGPDstroke *gps, C } /* convert a given grease-pencil layer to a 3d-curve representation (using current view if appropriate) */ -static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode) +static void gp_layer_to_curve(bContext *C, bGPdata *gpd, bGPDlayer *gpl, short mode) { - Scene *scene= CTX_data_scene(C); - bGPDframe *gpf= gpencil_layer_getframe(gpl, CFRA, 0); + Scene *scene = CTX_data_scene(C); + bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0); bGPDstroke *gps; Object *ob; Curve *cu; /* camera framing */ - rctf subrect, *subrect_ptr= NULL; + rctf subrect, *subrect_ptr = NULL; /* error checking */ if (ELEM3(NULL, gpd, gpl, gpf)) @@ -562,16 +562,16 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* initialize camera framing */ if (gp_camera_view_subrect(C, &subrect)) { - subrect_ptr= &subrect; + subrect_ptr = &subrect; } /* init the curve object (remove rotation and get curve data from it) * - must clear transforms set on object, as those skew our results */ - ob= add_object(scene, OB_CURVE); + ob = BKE_object_add(scene, OB_CURVE); zero_v3(ob->loc); zero_v3(ob->rot); - cu= ob->data; + cu = ob->data; cu->flag |= CU_3D; /* rename object and curve to layer name */ @@ -579,7 +579,7 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short rename_id((ID *)cu, gpl->info); /* add points to curve */ - for (gps= gpf->strokes.first; gps; gps= gps->next) { + for (gps = gpf->strokes.first; gps; gps = gps->next) { switch (mode) { case GP_STROKECONVERT_PATH: gp_stroke_to_path(C, gpl, gps, cu, subrect_ptr); @@ -596,22 +596,22 @@ static void gp_layer_to_curve (bContext *C, bGPdata *gpd, bGPDlayer *gpl, short /* --- */ -static int gp_convert_poll (bContext *C) +static int gp_convert_poll(bContext *C) { - bGPdata *gpd= gpencil_data_get_active(C); - ScrArea *sa= CTX_wm_area(C); - Scene *scene= CTX_data_scene(C); + bGPdata *gpd = gpencil_data_get_active(C); + ScrArea *sa = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); /* only if there's valid data, and the current view is 3D View */ return ((sa && sa->spacetype == SPACE_VIEW3D) && gpencil_layer_getactive(gpd) && (scene->obedit == NULL)); } -static int gp_convert_layer_exec (bContext *C, wmOperator *op) +static int gp_convert_layer_exec(bContext *C, wmOperator *op) { - bGPdata *gpd= gpencil_data_get_active(C); - bGPDlayer *gpl= gpencil_layer_getactive(gpd); - Scene *scene= CTX_data_scene(C); - int mode= RNA_enum_get(op->ptr, "type"); + bGPdata *gpd = gpencil_data_get_active(C); + bGPDlayer *gpl = gpencil_layer_getactive(gpd); + Scene *scene = CTX_data_scene(C); + int mode = RNA_enum_get(op->ptr, "type"); /* check if there's data to work with */ if (gpd == NULL) { @@ -622,8 +622,8 @@ static int gp_convert_layer_exec (bContext *C, wmOperator *op) gp_layer_to_curve(C, gpd, gpl, mode); /* notifiers */ - WM_event_add_notifier(C, NC_OBJECT|NA_ADDED, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + WM_event_add_notifier(C, NC_OBJECT | NA_ADDED, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); /* done */ return OPERATOR_FINISHED; @@ -635,7 +635,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) ot->name = "Convert Grease Pencil"; ot->idname = "GPENCIL_OT_convert"; ot->description = "Convert the active Grease Pencil layer to a new Object"; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* callbacks */ ot->invoke = WM_menu_invoke; @@ -643,7 +643,7 @@ void GPENCIL_OT_convert(wmOperatorType *ot) ot->poll = gp_convert_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_gpencil_convertmodes, 0, "Type", ""); diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index b88723d8a3c..28eb1355caf 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -77,18 +77,18 @@ void gpencil_undo_finish(void); typedef struct bActListElem { struct bActListElem *next, *prev; - void *data; /* source data this elem represents */ - int type; /* one of the ACTTYPE_* values */ - int flag; /* copy of elem's flags for quick access */ - int index; /* copy of adrcode where applicable */ + void *data; /* source data this elem represents */ + int type; /* one of the ACTTYPE_* values */ + int flag; /* copy of elem's flags for quick access */ + int index; /* copy of adrcode where applicable */ - void *key_data; /* motion data - ipo or ipo-curve */ - short datatype; /* type of motion data to expect */ + void *key_data; /* motion data - ipo or ipo-curve */ + short datatype; /* type of motion data to expect */ - struct bActionGroup *grp; /* action group that owns the channel */ + struct bActionGroup *grp; /* action group that owns the channel */ - void *owner; /* will either be an action channel or fake ipo-channel (for keys) */ - short ownertype; /* type of owner */ + void *owner; /* will either be an action channel or fake ipo-channel (for keys) */ + short ownertype; /* type of owner */ } bActListElem; /******************************************************* */ @@ -96,14 +96,14 @@ typedef struct bActListElem { /* filtering flags - under what circumstances should a channel be added */ typedef enum ACTFILTER_FLAGS { - ACTFILTER_VISIBLE = (1<<0), /* should channels be visible */ - ACTFILTER_SEL = (1<<1), /* should channels be selected */ - ACTFILTER_FOREDIT = (1<<2), /* does editable status matter */ - ACTFILTER_CHANNELS = (1<<3), /* do we only care that it is a channel */ - ACTFILTER_IPOKEYS = (1<<4), /* only channels referencing ipo's */ - ACTFILTER_ONLYICU = (1<<5), /* only reference ipo-curves */ - ACTFILTER_FORDRAWING = (1<<6), /* make list for interface drawing */ - ACTFILTER_ACTGROUPED = (1<<7) /* belongs to the active group */ + ACTFILTER_VISIBLE = (1 << 0), /* should channels be visible */ + ACTFILTER_SEL = (1 << 1), /* should channels be selected */ + ACTFILTER_FOREDIT = (1 << 2), /* does editable status matter */ + ACTFILTER_CHANNELS = (1 << 3), /* do we only care that it is a channel */ + ACTFILTER_IPOKEYS = (1 << 4), /* only channels referencing ipo's */ + ACTFILTER_ONLYICU = (1 << 5), /* only reference ipo-curves */ + ACTFILTER_FORDRAWING = (1 << 6), /* make list for interface drawing */ + ACTFILTER_ACTGROUPED = (1 << 7) /* belongs to the active group */ } ACTFILTER_FLAGS; /* Action Editor - Main Data types */ diff --git a/source/blender/editors/gpencil/gpencil_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index baa6999f552..7055eb3ee1b 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -54,18 +54,22 @@ void ED_keymap_gpencil(wmKeyConfig *keyconf) wmKeyMapItem *kmi; /* Draw */ - /* draw */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); - /* draw - straight lines */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); - /* draw - poly lines */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); - /* erase */ - kmi=WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); - RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); + + /* draw */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, 0, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW); + + /* draw - straight lines */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, KM_PRESS, KM_CTRL, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_STRAIGHT); + + /* draw - poly lines */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, KM_CTRL, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY); + + /* erase */ + kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", RIGHTMOUSE, KM_PRESS, 0, DKEY); + RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER); } /* ****************************************** */ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 9f9d941f523..b79c510efce 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -71,38 +71,38 @@ typedef struct tGPsdata { Scene *scene; /* current scene from context */ - wmWindow *win; /* window where painting originated */ - ScrArea *sa; /* area where painting originated */ + wmWindow *win; /* window where painting originated */ + ScrArea *sa; /* area where painting originated */ ARegion *ar; /* region where painting originated */ - View2D *v2d; /* needed for GP_STROKE_2DSPACE */ - rctf *subrect; /* for using the camera rect within the 3d view */ + View2D *v2d; /* needed for GP_STROKE_2DSPACE */ + rctf *subrect; /* for using the camera rect within the 3d view */ rctf subrect_data; #if 0 // XXX review this 2d image stuff... - ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ + ImBuf *ibuf; /* needed for GP_STROKE_2DIMAGE */ struct IBufViewSettings { - int offsx, offsy; /* offsets */ - int sizex, sizey; /* dimensions to use as scale-factor */ - } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ + int offsx, offsy; /* offsets */ + int sizex, sizey; /* dimensions to use as scale-factor */ + } im2d_settings; /* needed for GP_STROKE_2DIMAGE */ #endif - PointerRNA ownerPtr;/* pointer to owner of gp-datablock */ - bGPdata *gpd; /* gp-datablock layer comes from */ - bGPDlayer *gpl; /* layer we're working on */ - bGPDframe *gpf; /* frame we're working on */ + PointerRNA ownerPtr; /* pointer to owner of gp-datablock */ + bGPdata *gpd; /* gp-datablock layer comes from */ + bGPDlayer *gpl; /* layer we're working on */ + bGPDframe *gpf; /* frame we're working on */ + + short status; /* current status of painting */ + short paintmode; /* mode for painting */ - short status; /* current status of painting */ - short paintmode; /* mode for painting */ + int mval[2]; /* current mouse-position */ + int mvalo[2]; /* previous recorded mouse-position */ - int mval[2]; /* current mouse-position */ - int mvalo[2]; /* previous recorded mouse-position */ + float pressure; /* current stylus pressure */ + float opressure; /* previous stylus pressure */ - float pressure; /* current stylus pressure */ - float opressure; /* previous stylus pressure */ - - short radius; /* radius of influence for eraser */ - short flags; /* flags that can get set during runtime */ + short radius; /* radius of influence for eraser */ + short flags; /* flags that can get set during runtime */ float imat[4][4]; /* inverted transformation matrix applying when converting coords from screen-space * to region space */ @@ -112,36 +112,36 @@ typedef struct tGPsdata { /* values for tGPsdata->status */ enum { - GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ - GP_STATUS_PAINTING, /* a stroke is in progress */ - GP_STATUS_ERROR, /* something wasn't correctly set up */ - GP_STATUS_DONE /* painting done */ + GP_STATUS_IDLING = 0, /* stroke isn't in progress yet */ + GP_STATUS_PAINTING, /* a stroke is in progress */ + GP_STATUS_ERROR, /* something wasn't correctly set up */ + GP_STATUS_DONE /* painting done */ }; /* Return flags for adding points to stroke buffer */ enum { - GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ - GP_STROKEADD_OVERFLOW = -1, /* error occurred - cannot fit any more points */ - GP_STROKEADD_NORMAL, /* point was successfully added */ - GP_STROKEADD_FULL /* cannot add any more points to buffer */ + GP_STROKEADD_INVALID = -2, /* error occurred - insufficient info to do so */ + GP_STROKEADD_OVERFLOW = -1, /* error occurred - cannot fit any more points */ + GP_STROKEADD_NORMAL, /* point was successfully added */ + GP_STROKEADD_FULL /* cannot add any more points to buffer */ }; /* Runtime flags */ enum { - GP_PAINTFLAG_FIRSTRUN = (1<<0), /* operator just started */ - GP_PAINTFLAG_STROKEADDED = (1<<1) /* stroke was already added during draw session */ + GP_PAINTFLAG_FIRSTRUN = (1 << 0), /* operator just started */ + GP_PAINTFLAG_STROKEADDED = (1 << 1) /* stroke was already added during draw session */ }; /* ------ */ /* maximum sizes of gp-session buffer */ -#define GP_STROKE_BUFFER_MAX 5000 +#define GP_STROKE_BUFFER_MAX 5000 /* Macros for accessing sensitivity thresholds... */ - /* minimum number of pixels mouse should move before new point created */ -#define MIN_MANHATTEN_PX (U.gp_manhattendist) - /* minimum length of new segment before new point can be added */ -#define MIN_EUCLIDEAN_PX (U.gp_euclideandist) +/* minimum number of pixels mouse should move before new point created */ +#define MIN_MANHATTEN_PX (U.gp_manhattendist) +/* minimum length of new segment before new point can be added */ +#define MIN_EUCLIDEAN_PX (U.gp_euclideandist) /* ------ */ /* Forward defines for some functions... */ @@ -152,7 +152,7 @@ static void gp_session_validatebuffer(tGPsdata *p); /* Context Wrangling... */ /* check if context is suitable for drawing */ -static int gpencil_draw_poll (bContext *C) +static int gpencil_draw_poll(bContext *C) { if (ED_operator_regionactive(C)) { /* check if current context can support GPencil data */ @@ -175,9 +175,9 @@ static int gpencil_draw_poll (bContext *C) } /* check if projecting strokes into 3d-geometry in the 3D-View */ -static int gpencil_project_check (tGPsdata *p) +static int gpencil_project_check(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; return ((gpd->sbuffer_sflag & GP_STROKE_3DSPACE) && (p->gpd->flag & (GP_DATA_DEPTH_VIEW | GP_DATA_DEPTH_STROKE))); } @@ -187,18 +187,18 @@ static int gpencil_project_check (tGPsdata *p) /* Utilities --------------------------------- */ /* get the reference point for stroke-point conversions */ -static void gp_get_3d_reference (tGPsdata *p, float vec[3]) +static void gp_get_3d_reference(tGPsdata *p, float vec[3]) { - View3D *v3d= p->sa->spacedata.first; - float *fp= give_cursor(p->scene, v3d); + View3D *v3d = p->sa->spacedata.first; + float *fp = give_cursor(p->scene, v3d); /* the reference point used depends on the owner... */ #if 0 // XXX: disabled for now, since we can't draw relative to the owner yet if (p->ownerPtr.type == &RNA_Object) { - Object *ob= (Object *)p->ownerPtr.data; + Object *ob = (Object *)p->ownerPtr.data; /* active Object - * - use relative distance of 3D-cursor from object center + * - use relative distance of 3D-cursor from object center */ sub_v3_v3v3(vec, fp, ob->loc); } @@ -213,10 +213,10 @@ static void gp_get_3d_reference (tGPsdata *p, float vec[3]) /* Stroke Editing ---------------------------- */ /* check if the current mouse position is suitable for adding a new point */ -static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) +static short gp_stroke_filtermval(tGPsdata *p, const int mval[2], int pmval[2]) { - int dx= abs(mval[0] - pmval[0]); - int dy= abs(mval[1] - pmval[1]); + int dx = abs(mval[0] - pmval[0]); + int dy = abs(mval[1] - pmval[1]); /* if buffer is empty, just let this go through (i.e. so that dots will work) */ if (p->gpd->sbuffer_size == 0) @@ -232,7 +232,7 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) * - prevents points being added too densely * - distance here doesn't use sqrt to prevent slowness... we should still be safe from overflows though */ - else if ((dx*dx + dy*dy) > MIN_EUCLIDEAN_PX*MIN_EUCLIDEAN_PX) + else if ((dx * dx + dy * dy) > MIN_EUCLIDEAN_PX * MIN_EUCLIDEAN_PX) return 1; /* mouse 'didn't move' */ @@ -242,9 +242,9 @@ static short gp_stroke_filtermval (tGPsdata *p, const int mval[2], int pmval[2]) /* convert screen-coordinates to buffer-coordinates */ // XXX this method needs a total overhaul! -static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3], float *depth) +static void gp_stroke_convertcoords(tGPsdata *p, const int mval[2], float out[3], float *depth) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; /* in 3d-space - pt->x/y/z are 3 side-by-side floats */ if (gpd->sbuffer_sflag & GP_STROKE_3DSPACE) { @@ -292,14 +292,14 @@ static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3 /* get stored settings * - assume that these have been set already (there are checks that set sane 'defaults' just in case) */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - out[0]= (float)(mval[0] - offsx) / (float)sizex; - out[1]= (float)(mval[1] - offsy) / (float)sizey; + out[0] = (float)(mval[0] - offsx) / (float)sizex; + out[1] = (float)(mval[1] - offsy) / (float)sizey; } #endif @@ -310,16 +310,16 @@ static void gp_stroke_convertcoords (tGPsdata *p, const int mval[2], float out[3 out[1] = (float)(mval[1]) / (float)(p->ar->winy) * 100; } else { /* camera view, use subrect */ - out[0]= ((mval[0] - p->subrect->xmin) / ((p->subrect->xmax - p->subrect->xmin))) * 100; - out[1]= ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; + out[0] = ((mval[0] - p->subrect->xmin) / ((p->subrect->xmax - p->subrect->xmin))) * 100; + out[1] = ((mval[1] - p->subrect->ymin) / ((p->subrect->ymax - p->subrect->ymin))) * 100; } } } /* add current stroke-point to buffer (returns whether point was successfully added) */ -static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) +static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; tGPspoint *pt; /* check painting mode */ @@ -327,11 +327,11 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) /* straight lines only - i.e. only store start and end point in buffer */ if (gpd->sbuffer_size == 0) { /* first point in buffer (start point) */ - pt= (tGPspoint *)(gpd->sbuffer); + pt = (tGPspoint *)(gpd->sbuffer); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* increment buffer size */ gpd->sbuffer_size++; @@ -340,18 +340,18 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) /* normally, we just reset the endpoint to the latest value * - assume that pointers for this are always valid... */ - pt= ((tGPspoint *)(gpd->sbuffer) + 1); + pt = ((tGPspoint *)(gpd->sbuffer) + 1); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* if this is just the second point we've added, increment the buffer size * so that it will be drawn properly... * otherwise, just leave it alone, otherwise we get problems */ if (gpd->sbuffer_size != 2) - gpd->sbuffer_size= 2; + gpd->sbuffer_size = 2; } /* can keep carrying on this way :) */ @@ -363,11 +363,11 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) return GP_STROKEADD_OVERFLOW; /* get pointer to destination point */ - pt= ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); + pt = ((tGPspoint *)(gpd->sbuffer) + gpd->sbuffer_size); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* increment counters */ gpd->sbuffer_size++; @@ -380,43 +380,43 @@ static short gp_stroke_addpoint (tGPsdata *p, const int mval[2], float pressure) } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* get pointer to destination point */ - pt= (tGPspoint *)(gpd->sbuffer); + pt = (tGPspoint *)(gpd->sbuffer); /* store settings */ copy_v2_v2_int(&pt->x, mval); - pt->pressure= pressure; + pt->pressure = pressure; /* if there's stroke for this poly line session add (or replace last) point * to stroke. This allows to draw lines more interactively (see new segment * during mouse slide, i.e.) */ if (p->flags & GP_PAINTFLAG_STROKEADDED) { - bGPDstroke *gps= p->gpf->strokes.last; + bGPDstroke *gps = p->gpf->strokes.last; bGPDspoint *pts; /* first time point is adding to temporary buffer -- need to allocate new point in stroke */ if (gpd->sbuffer_size == 0) { - gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint)*(gps->totpoints+1)); + gps->points = MEM_reallocN(gps->points, sizeof(bGPDspoint) * (gps->totpoints + 1)); gps->totpoints++; } - pts = &gps->points[gps->totpoints-1]; + pts = &gps->points[gps->totpoints - 1]; /* special case for poly lines: normally, depth is needed only when creating new stroke from buffer, * but poly lines are converting to stroke instantly, so initialize depth buffer before converting coordinates */ if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; + View3D *v3d = p->sa->spacedata.first; view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &pt->x, &pts->x, NULL); /* copy pressure */ - pts->pressure= pt->pressure; + pts->pressure = pt->pressure; } /* increment counters */ @@ -438,11 +438,11 @@ typedef struct tGpSmoothCo { } tGpSmoothCo; /* smooth a stroke (in buffer) before storing it */ -static void gp_stroke_smooth (tGPsdata *p) +static void gp_stroke_smooth(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; tGpSmoothCo *smoothArray, *spc; - int i=0, cmx=gpd->sbuffer_size; + int i = 0, cmx = gpd->sbuffer_size; /* only smooth if smoothing is enabled, and we're not doing a straight line */ if (!(U.gp_settings & GP_PAINT_DOSMOOTH) || ELEM(p->paintmode, GP_PAINTMODE_DRAW_STRAIGHT, GP_PAINTMODE_DRAW_POLY)) @@ -453,23 +453,23 @@ static void gp_stroke_smooth (tGPsdata *p) return; /* create a temporary smoothing coordinates buffer, use to store calculated values to prevent sequential error */ - smoothArray = MEM_callocN(sizeof(tGpSmoothCo)*cmx, "gp_stroke_smooth smoothArray"); + smoothArray = MEM_callocN(sizeof(tGpSmoothCo) * cmx, "gp_stroke_smooth smoothArray"); /* first pass: calculate smoothing coordinates using weighted-averages */ - for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { - const tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); - const tGPspoint *pb= (i-1 > 0)?(pc-1):(pc); - const tGPspoint *pa= (i-2 > 0)?(pc-2):(pb); - const tGPspoint *pd= (i+1 < cmx)?(pc+1):(pc); - const tGPspoint *pe= (i+2 < cmx)?(pc+2):(pd); + for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { + const tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); + const tGPspoint *pb = (i - 1 > 0) ? (pc - 1) : (pc); + const tGPspoint *pa = (i - 2 > 0) ? (pc - 2) : (pb); + const tGPspoint *pd = (i + 1 < cmx) ? (pc + 1) : (pc); + const tGPspoint *pe = (i + 2 < cmx) ? (pc + 2) : (pd); - spc->x= (int)(0.1*pa->x + 0.2*pb->x + 0.4*pc->x + 0.2*pd->x + 0.1*pe->x); - spc->y= (int)(0.1*pa->y + 0.2*pb->y + 0.4*pc->y + 0.2*pd->y + 0.1*pe->y); + spc->x = (int)(0.1 * pa->x + 0.2 * pb->x + 0.4 * pc->x + 0.2 * pd->x + 0.1 * pe->x); + spc->y = (int)(0.1 * pa->y + 0.2 * pb->y + 0.4 * pc->y + 0.2 * pd->y + 0.1 * pe->y); } /* second pass: apply smoothed coordinates */ - for (i=0, spc=smoothArray; i < gpd->sbuffer_size; i++, spc++) { - tGPspoint *pc= (((tGPspoint *)gpd->sbuffer) + i); + for (i = 0, spc = smoothArray; i < gpd->sbuffer_size; i++, spc++) { + tGPspoint *pc = (((tGPspoint *)gpd->sbuffer) + i); copy_v2_v2_int(&pc->x, &spc->x); } @@ -482,12 +482,12 @@ static void gp_stroke_smooth (tGPsdata *p) * - applies a reverse Chaikin filter * - code adapted from etch-a-ton branch (editarmature_sketch.c) */ -static void gp_stroke_simplify (tGPsdata *p) +static void gp_stroke_simplify(tGPsdata *p) { - bGPdata *gpd= p->gpd; - tGPspoint *old_points= (tGPspoint *)gpd->sbuffer; - short num_points= gpd->sbuffer_size; - short flag= gpd->sbuffer_sflag; + bGPdata *gpd = p->gpd; + tGPspoint *old_points = (tGPspoint *)gpd->sbuffer; + short num_points = gpd->sbuffer_size; + short flag = gpd->sbuffer_sflag; short i, j; /* only simplify if simplification is enabled, and we're not doing a straight line */ @@ -502,7 +502,7 @@ static void gp_stroke_simplify (tGPsdata *p) * - firstly set sbuffer to NULL, so a new one is allocated * - secondly, reset flag after, as it gets cleared auto */ - gpd->sbuffer= NULL; + gpd->sbuffer = NULL; gp_session_validatebuffer(p); gpd->sbuffer_sflag = flag; @@ -522,19 +522,19 @@ static void gp_stroke_simplify (tGPsdata *p) int mco[2]; /* initialize values */ - co[0]= 0; - co[1]= 0; + co[0] = 0; + co[1] = 0; pressure = 0; /* using macro, calculate new point */ GP_SIMPLIFY_AVPOINT(j, -0.25f); - GP_SIMPLIFY_AVPOINT(j+1, 0.75f); - GP_SIMPLIFY_AVPOINT(j+2, 0.75f); - GP_SIMPLIFY_AVPOINT(j+3, -0.25f); + GP_SIMPLIFY_AVPOINT(j + 1, 0.75f); + GP_SIMPLIFY_AVPOINT(j + 2, 0.75f); + GP_SIMPLIFY_AVPOINT(j + 3, -0.25f); /* set values for adding */ - mco[0]= (int)co[0]; - mco[1]= (int)co[1]; + mco[0] = (int)co[0]; + mco[1] = (int)co[1]; /* ignore return values on this... assume to be ok for now */ gp_stroke_addpoint(p, mco, pressure); @@ -549,9 +549,9 @@ static void gp_stroke_simplify (tGPsdata *p) /* make a new stroke from the buffer data */ -static void gp_stroke_newfrombuffer (tGPsdata *p) +static void gp_stroke_newfrombuffer(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; bGPDstroke *gps; bGPDspoint *pt; tGPspoint *ptc; @@ -563,7 +563,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) * - drawing straight-lines only requires the endpoints */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) - totelem = (gpd->sbuffer_size >= 2) ? 2: gpd->sbuffer_size; + totelem = (gpd->sbuffer_size >= 2) ? 2 : gpd->sbuffer_size; else totelem = gpd->sbuffer_size; @@ -583,77 +583,77 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } /* allocate memory for a new stroke */ - gps= MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); + gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke"); /* copy appropriate settings for stroke */ - gps->totpoints= totelem; - gps->thickness= p->gpl->thickness; - gps->flag= gpd->sbuffer_sflag; + gps->totpoints = totelem; + gps->thickness = p->gpl->thickness; + gps->flag = gpd->sbuffer_sflag; /* allocate enough memory for a continuous array for storage points */ - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); /* set pointer to first non-initialized point */ - pt= gps->points + (gps->totpoints - totelem); + pt = gps->points + (gps->totpoints - totelem); /* copy points from the buffer to the stroke */ if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) { /* straight lines only -> only endpoints */ { /* first point */ - ptc= gpd->sbuffer; + ptc = gpd->sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; pt++; } if (totelem == 2) { /* last point if applicable */ - ptc= ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); + ptc = ((tGPspoint *)gpd->sbuffer) + (gpd->sbuffer_size - 1); /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } } else if (p->paintmode == GP_PAINTMODE_DRAW_POLY) { /* first point */ - ptc= gpd->sbuffer; + ptc = gpd->sbuffer; /* convert screen-coordinates to appropriate coordinates (and store them) */ gp_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } else { - float *depth_arr= NULL; + float *depth_arr = NULL; /* get an array of depths, far depths are blended */ if (gpencil_project_check(p)) { - int mval[2], mval_prev[2]= {0}; + int mval[2], mval_prev[2] = {0}; int interp_depth = 0; int found_depth = 0; - depth_arr= MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); + depth_arr = MEM_mallocN(sizeof(float) * gpd->sbuffer_size, "depth_points"); - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size; i++, ptc++, pt++) { copy_v2_v2_int(mval, &ptc->x); - if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr+i) == 0) && - (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr+i) == 0)) - ) { - interp_depth= TRUE; + if ((ED_view3d_autodist_depth(p->ar, mval, depth_margin, depth_arr + i) == 0) && + (i && (ED_view3d_autodist_depth_seg(p->ar, mval, mval_prev, depth_margin + 1, depth_arr + i) == 0))) + { + interp_depth = TRUE; } else { - found_depth= TRUE; + found_depth = TRUE; } copy_v2_v2_int(mval_prev, mval); @@ -661,7 +661,7 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) if (found_depth == FALSE) { /* eeh... not much we can do.. :/, ignore depth in this case, use the 3D cursor */ - for (i=gpd->sbuffer_size-1; i >= 0; i--) + for (i = gpd->sbuffer_size - 1; i >= 0; i--) depth_arr[i] = 0.9999f; } else { @@ -670,23 +670,23 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) int first_valid = 0; int last_valid = 0; - for (i=0; i < gpd->sbuffer_size; i++) { + for (i = 0; i < gpd->sbuffer_size; i++) { if (depth_arr[i] != FLT_MAX) break; } - first_valid= i; + first_valid = i; - for (i=gpd->sbuffer_size-1; i >= 0; i--) { + for (i = gpd->sbuffer_size - 1; i >= 0; i--) { if (depth_arr[i] != FLT_MAX) break; } - last_valid= i; + last_valid = i; /* invalidate non-endpoints, so only blend between first and last */ - for (i=first_valid+1; i < last_valid; i++) - depth_arr[i]= FLT_MAX; + for (i = first_valid + 1; i < last_valid; i++) + depth_arr[i] = FLT_MAX; - interp_depth= TRUE; + interp_depth = TRUE; } if (interp_depth) { @@ -696,15 +696,15 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) } - pt= gps->points; + pt = gps->points; /* convert all points (normal behavior) */ - for (i=0, ptc=gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { + for (i = 0, ptc = gpd->sbuffer; i < gpd->sbuffer_size && ptc; i++, ptc++, pt++) { /* convert screen-coordinates to appropriate coordinates (and store them) */ - gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr+i:NULL); + gp_stroke_convertcoords(p, &ptc->x, &pt->x, depth_arr ? depth_arr + i : NULL); /* copy pressure */ - pt->pressure= ptc->pressure; + pt->pressure = ptc->pressure; } if (depth_arr) @@ -720,9 +720,9 @@ static void gp_stroke_newfrombuffer (tGPsdata *p) /* --- 'Eraser' for 'Paint' Tool ------ */ /* eraser tool - remove segment from stroke/split stroke (after lasso inside) */ -static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) +static short gp_stroke_eraser_splitdel(bGPDframe *gpf, bGPDstroke *gps, int i) { - bGPDspoint *pt_tmp= gps->points; + bGPDspoint *pt_tmp = gps->points; bGPDstroke *gsn = NULL; /* if stroke only had two points, get rid of stroke */ @@ -739,8 +739,8 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) else if (i == gps->totpoints - 2) { /* allocate new points array, and assign most of the old stroke there */ gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*gps->totpoints); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint) * gps->totpoints); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -753,8 +753,8 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) else if (i == 0) { /* allocate new points array, and assign most of the old stroke there */ gps->totpoints--; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint)*gps->totpoints); + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp + 1, sizeof(bGPDspoint) * gps->totpoints); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -766,18 +766,18 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) /* segment occurs in 'middle' of stroke, so split */ else { /* duplicate stroke, and assign 'later' data to that stroke */ - gsn= MEM_dupallocN(gps); - gsn->prev= gsn->next= NULL; + gsn = MEM_dupallocN(gps); + gsn->prev = gsn->next = NULL; BLI_insertlinkafter(&gpf->strokes, gps, gsn); - gsn->totpoints= gps->totpoints - i; - gsn->points= MEM_callocN(sizeof(bGPDspoint)*gsn->totpoints, "gp_stroke_points"); - memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint)*gsn->totpoints); + gsn->totpoints = gps->totpoints - i; + gsn->points = MEM_callocN(sizeof(bGPDspoint) * gsn->totpoints, "gp_stroke_points"); + memcpy(gsn->points, pt_tmp + i, sizeof(bGPDspoint) * gsn->totpoints); /* adjust existing stroke */ - gps->totpoints= i; - gps->points= MEM_callocN(sizeof(bGPDspoint)*gps->totpoints, "gp_stroke_points"); - memcpy(gps->points, pt_tmp, sizeof(bGPDspoint)*i); + gps->totpoints = i; + gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points"); + memcpy(gps->points, pt_tmp, sizeof(bGPDspoint) * i); /* free temp buffer */ MEM_freeN(pt_tmp); @@ -788,7 +788,7 @@ static short gp_stroke_eraser_splitdel (bGPDframe *gpf, bGPDstroke *gps, int i) } /* eraser tool - check if part of stroke occurs within last segment drawn by eraser */ -static short gp_stroke_eraser_strokeinside (int mval[], int UNUSED(mvalo[]), short rad, short x0, short y0, short x1, short y1) +static short gp_stroke_eraser_strokeinside(int mval[], int UNUSED(mvalo[]), short rad, short x0, short y0, short x1, short y1) { /* simple within-radius check for now */ if (edge_inside_circle(mval[0], mval[1], rad, x0, y0, x1, y1)) @@ -800,10 +800,10 @@ static short gp_stroke_eraser_strokeinside (int mval[], int UNUSED(mvalo[]), sho /* eraser tool - evaluation per stroke */ // TODO: this could really do with some optimization (KD-Tree/BVH?) -static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], short rad, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) +static void gp_stroke_eraser_dostroke(tGPsdata *p, int mval[], int mvalo[], short rad, rcti *rect, bGPDframe *gpf, bGPDstroke *gps) { bGPDspoint *pt1, *pt2; - int x0=0, y0=0, x1=0, y1=0; + int x0 = 0, y0 = 0, x1 = 0, y1 = 0; int xyval[2]; int i; @@ -817,8 +817,8 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { project_int(p->ar, &gps->points->x, xyval); - x0= xyval[0]; - y0= xyval[1]; + x0 = xyval[0]; + y0 = xyval[1]; } else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, gps->points->x, gps->points->y, &x0, &y0); @@ -828,31 +828,31 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho int offsx, offsy, sizex, sizey; /* get stored settings */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - x0= (int)((gps->points->x * sizex) + offsx); - y0= (int)((gps->points->y * sizey) + offsy); + x0 = (int)((gps->points->x * sizex) + offsx); + y0 = (int)((gps->points->y * sizey) + offsy); } #endif else { if (p->subrect == NULL) { /* normal 3D view */ - x0= (int)(gps->points->x / 100 * p->ar->winx); - y0= (int)(gps->points->y / 100 * p->ar->winy); + x0 = (int)(gps->points->x / 100 * p->ar->winx); + y0 = (int)(gps->points->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0= (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0= (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x0 = (int)((gps->points->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y0 = (int)((gps->points->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; } } /* do boundbox check first */ if (BLI_in_rcti(rect, x0, y0)) { /* only check if point is inside */ - if ( ((x0-mval[0])*(x0-mval[0]) + (y0-mval[1])*(y0-mval[1])) <= rad*rad ) { + if ( ((x0 - mval[0]) * (x0 - mval[0]) + (y0 - mval[1]) * (y0 - mval[1])) <= rad * rad) { /* free stroke */ MEM_freeN(gps->points); BLI_freelinkN(&gpf->strokes, gps); @@ -861,22 +861,22 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } else { /* loop over the points in the stroke, checking for intersections - * - an intersection will require the stroke to be split + * - an intersection will require the stroke to be split */ - for (i=0; (i+1) < gps->totpoints; i++) { + for (i = 0; (i + 1) < gps->totpoints; i++) { /* get points to work with */ - pt1= gps->points + i; - pt2= gps->points + i + 1; + pt1 = gps->points + i; + pt2 = gps->points + i + 1; /* get coordinates */ if (gps->flag & GP_STROKE_3DSPACE) { project_int(p->ar, &pt1->x, xyval); - x0= xyval[0]; - y0= xyval[1]; + x0 = xyval[0]; + y0 = xyval[1]; project_int(p->ar, &pt2->x, xyval); - x1= xyval[0]; - y1= xyval[1]; + x1 = xyval[0]; + y1 = xyval[1]; } else if (gps->flag & GP_STROKE_2DSPACE) { UI_view2d_view_to_region(p->v2d, pt1->x, pt1->y, &x0, &y0); @@ -888,31 +888,31 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho int offsx, offsy, sizex, sizey; /* get stored settings */ - sizex= p->im2d_settings.sizex; - sizey= p->im2d_settings.sizey; - offsx= p->im2d_settings.offsx; - offsy= p->im2d_settings.offsy; + sizex = p->im2d_settings.sizex; + sizey = p->im2d_settings.sizey; + offsx = p->im2d_settings.offsx; + offsy = p->im2d_settings.offsy; /* calculate new points */ - x0= (int)((pt1->x * sizex) + offsx); - y0= (int)((pt1->y * sizey) + offsy); + x0 = (int)((pt1->x * sizex) + offsx); + y0 = (int)((pt1->y * sizey) + offsy); - x1= (int)((pt2->x * sizex) + offsx); - y1= (int)((pt2->y * sizey) + offsy); + x1 = (int)((pt2->x * sizex) + offsx); + y1 = (int)((pt2->y * sizey) + offsy); } #endif else { if (p->subrect == NULL) { /* normal 3D view */ - x0= (int)(pt1->x / 100 * p->ar->winx); - y0= (int)(pt1->y / 100 * p->ar->winy); - x1= (int)(pt2->x / 100 * p->ar->winx); - y1= (int)(pt2->y / 100 * p->ar->winy); + x0 = (int)(pt1->x / 100 * p->ar->winx); + y0 = (int)(pt1->y / 100 * p->ar->winy); + x1 = (int)(pt2->x / 100 * p->ar->winx); + y1 = (int)(pt2->y / 100 * p->ar->winy); } else { /* camera view, use subrect */ - x0= (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y0= (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; - x1= (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; - y1= (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x0 = (int)((pt1->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y0 = (int)((pt1->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; + x1 = (int)((pt2->x / 100) * (p->subrect->xmax - p->subrect->xmin)) + p->subrect->xmin; + y1 = (int)((pt2->y / 100) * (p->subrect->ymax - p->subrect->ymin)) + p->subrect->ymin; } } @@ -920,7 +920,7 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho if (BLI_in_rcti(rect, x0, y0) || BLI_in_rcti(rect, x1, y1)) { /* check if point segment of stroke had anything to do with * eraser region (either within stroke painted, or on its lines) - * - this assumes that linewidth is irrelevant + * - this assumes that linewidth is irrelevant */ if (gp_stroke_eraser_strokeinside(mval, mvalo, rad, x0, y0, x1, y1)) { /* if function returns true, break this loop (as no more point to check) */ @@ -933,9 +933,9 @@ static void gp_stroke_eraser_dostroke (tGPsdata *p, int mval[], int mvalo[], sho } /* erase strokes which fall under the eraser strokes */ -static void gp_stroke_doeraser (tGPsdata *p) +static void gp_stroke_doeraser(tGPsdata *p) { - bGPDframe *gpf= p->gpf; + bGPDframe *gpf = p->gpf; bGPDstroke *gps, *gpn; rcti rect; @@ -946,8 +946,8 @@ static void gp_stroke_doeraser (tGPsdata *p) rect.ymax = p->mval[1] + p->radius; /* loop over strokes, checking segments for intersections */ - for (gps= gpf->strokes.first; gps; gps= gpn) { - gpn= gps->next; + for (gps = gpf->strokes.first; gps; gps = gpn) { + gpn = gps->next; gp_stroke_eraser_dostroke(p, p->mval, p->mvalo, p->radius, &rect, gpf, gps); } } @@ -956,45 +956,45 @@ static void gp_stroke_doeraser (tGPsdata *p) /* Sketching Operator */ /* clear the session buffers (call this before AND after a paint operation) */ -static void gp_session_validatebuffer (tGPsdata *p) +static void gp_session_validatebuffer(tGPsdata *p) { - bGPdata *gpd= p->gpd; + bGPdata *gpd = p->gpd; /* clear memory of buffer (or allocate it if starting a new session) */ if (gpd->sbuffer) { //printf("\t\tGP - reset sbuffer\n"); - memset(gpd->sbuffer, 0, sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX); + memset(gpd->sbuffer, 0, sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX); } else { //printf("\t\tGP - allocate sbuffer\n"); - gpd->sbuffer= MEM_callocN(sizeof(tGPspoint)*GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); + gpd->sbuffer = MEM_callocN(sizeof(tGPspoint) * GP_STROKE_BUFFER_MAX, "gp_session_strokebuffer"); } /* reset indices */ gpd->sbuffer_size = 0; /* reset flags */ - gpd->sbuffer_sflag= 0; + gpd->sbuffer_sflag = 0; } /* (re)init new painting data */ -static int gp_session_initdata (bContext *C, tGPsdata *p) +static int gp_session_initdata(bContext *C, tGPsdata *p) { bGPdata **gpd_ptr = NULL; - ScrArea *curarea= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + ScrArea *curarea = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); /* make sure the active view (at the starting time) is a 3d-view */ if (curarea == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: No active view for painting\n"); return 0; } /* pass on current scene and window */ - p->scene= CTX_data_scene(C); - p->win= CTX_wm_window(C); + p->scene = CTX_data_scene(C); + p->win = CTX_wm_window(C); unit_m4(p->imat); @@ -1008,11 +1008,11 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) /* set current area * - must verify that region data is 3D-view (and not something else) */ - p->sa= curarea; - p->ar= ar; + p->sa = curarea; + p->ar = ar; if (ar->regiondata == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: 3D-View active region doesn't have any region data, so cannot be drawable\n"); return 0; @@ -1020,118 +1020,118 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ - if ((v3d->flag2 & V3D_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((v3d->flag2 & V3D_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; case SPACE_NODE: { //SpaceNode *snode= curarea->spacedata.first; /* set current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; #if 0 // XXX will this sort of antiquated stuff be restored? /* check that gpencil data is allowed to be drawn */ - if ((snode->flag & SNODE_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((snode->flag & SNODE_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; #if 0 // XXX these other spaces will come over time... case SPACE_SEQ: { - SpaceSeq *sseq= curarea->spacedata.first; + SpaceSeq *sseq = curarea->spacedata.first; /* set current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; /* check that gpencil data is allowed to be drawn */ if (sseq->mainb == SEQ_DRAW_SEQUENCE) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view (sequencer), active mode doesn't support Grease Pencil\n"); return 0; } - if ((sseq->flag & SEQ_DRAW_GPENCIL)==0) { - p->status= GP_STATUS_ERROR; + if ((sseq->flag & SEQ_DRAW_GPENCIL) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } } - break; + break; #endif case SPACE_IMAGE: { //SpaceImage *sima= curarea->spacedata.first; /* set the current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); #if 0 // XXX disabled for now /* check that gpencil data is allowed to be drawn */ - if ((sima->flag & SI_DISPGP)==0) { - p->status= GP_STATUS_ERROR; + if ((sima->flag & SI_DISPGP) == 0) { + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: In active view, Grease Pencil not shown\n"); return 0; } #endif } - break; + break; case SPACE_CLIP: { - SpaceClip *sc= curarea->spacedata.first; + SpaceClip *sc = curarea->spacedata.first; /* set the current area */ - p->sa= curarea; - p->ar= ar; - p->v2d= &ar->v2d; + p->sa = curarea; + p->ar = ar; + p->v2d = &ar->v2d; //p->ibuf= BKE_image_get_ibuf(sima->image, &sima->iuser); invert_m4_m4(p->imat, sc->unistabmat); /* custom color for new layer */ - p->custom_color[0]= 1.0f; - p->custom_color[1]= 0.0f; - p->custom_color[2]= 0.5f; - p->custom_color[3]= 0.9f; + p->custom_color[0] = 1.0f; + p->custom_color[1] = 0.0f; + p->custom_color[2] = 0.5f; + p->custom_color[3] = 0.9f; } - break; + break; /* unsupported views */ default: { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Active view not appropriate for Grease Pencil drawing\n"); return 0; } - break; + break; } /* get gp-data */ - gpd_ptr= gpencil_data_get_pointers(C, &p->ownerPtr); + gpd_ptr = gpencil_data_get_pointers(C, &p->ownerPtr); if (gpd_ptr == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Current context doesn't allow for any Grease Pencil data\n"); return 0; @@ -1139,11 +1139,11 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) else { /* if no existing GPencil block exists, add one */ if (*gpd_ptr == NULL) - *gpd_ptr= gpencil_data_addnew("GPencil"); - p->gpd= *gpd_ptr; + *gpd_ptr = gpencil_data_addnew("GPencil"); + p->gpd = *gpd_ptr; } - if (ED_gpencil_session_active()==0) { + if (ED_gpencil_session_active() == 0) { /* initialize undo stack, * also, existing undo stack would make buffer drawn */ gpencil_undo_init(p->gpd); @@ -1154,20 +1154,20 @@ static int gp_session_initdata (bContext *C, tGPsdata *p) #if 0 /* set 'default' im2d_settings just in case something that uses this doesn't set it */ - p->im2d_settings.sizex= 1; - p->im2d_settings.sizey= 1; + p->im2d_settings.sizex = 1; + p->im2d_settings.sizey = 1; #endif return 1; } /* init new painting session */ -static tGPsdata *gp_session_initpaint (bContext *C) +static tGPsdata *gp_session_initpaint(bContext *C) { tGPsdata *p = NULL; /* create new context data */ - p= MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); + p = MEM_callocN(sizeof(tGPsdata), "GPencil Drawing Data"); gp_session_initdata(C, p); @@ -1176,9 +1176,9 @@ static tGPsdata *gp_session_initpaint (bContext *C) } /* cleanup after a painting session */ -static void gp_session_cleanup (tGPsdata *p) +static void gp_session_cleanup(tGPsdata *p) { - bGPdata *gpd= (p) ? p->gpd : NULL; + bGPdata *gpd = (p) ? p->gpd : NULL; /* error checking */ if (gpd == NULL) @@ -1188,36 +1188,36 @@ static void gp_session_cleanup (tGPsdata *p) if (gpd->sbuffer) { //printf("\t\tGP - free sbuffer\n"); MEM_freeN(gpd->sbuffer); - gpd->sbuffer= NULL; + gpd->sbuffer = NULL; } /* clear flags */ - gpd->sbuffer_size= 0; - gpd->sbuffer_sflag= 0; + gpd->sbuffer_size = 0; + gpd->sbuffer_sflag = 0; } /* init new stroke */ -static void gp_paint_initstroke (tGPsdata *p, short paintmode) +static void gp_paint_initstroke(tGPsdata *p, short paintmode) { /* get active layer (or add a new one if non-existent) */ - p->gpl= gpencil_layer_getactive(p->gpd); + p->gpl = gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { - p->gpl= gpencil_layer_addnew(p->gpd); + p->gpl = gpencil_layer_addnew(p->gpd); if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); } if (p->gpl->flag & GP_LAYER_LOCKED) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: Cannot paint on locked layer\n"); return; } /* get active frame (add a new one if not matching frame) */ - p->gpf= gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1); + p->gpf = gpencil_layer_getframe(p->gpl, p->scene->r.cfra, 1); if (p->gpf == NULL) { - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; if (G.debug & G_DEBUG) printf("Error: No frame created (gpencil_paint_init)\n"); return; @@ -1226,7 +1226,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpf->flag |= GP_FRAME_PAINT; /* set 'eraser' for this stroke if using eraser */ - p->paintmode= paintmode; + p->paintmode = paintmode; if (p->paintmode == GP_PAINTMODE_ERASER) p->gpd->sbuffer_sflag |= GP_STROKE_ERASER; @@ -1237,13 +1237,13 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) /* when drawing in the camera view, in 2D space, set the subrect */ if (!(p->gpd->flag & GP_DATA_VIEWALIGN)) { if (p->sa->spacetype == SPACE_VIEW3D) { - View3D *v3d= p->sa->spacedata.first; - RegionView3D *rv3d= p->ar->regiondata; + View3D *v3d = p->sa->spacedata.first; + RegionView3D *rv3d = p->ar->regiondata; /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { ED_view3d_calc_camera_border(p->scene, p->ar, v3d, rv3d, &p->subrect_data, TRUE); /* no shift */ - p->subrect= &p->subrect_data; + p->subrect = &p->subrect_data; } } } @@ -1253,7 +1253,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) switch (p->sa->spacetype) { case SPACE_VIEW3D: { - RegionView3D *rv3d= p->ar->regiondata; + RegionView3D *rv3d = p->ar->regiondata; float rvec[3]; /* get reference point for 3d space placement */ @@ -1262,17 +1262,17 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_3DSPACE; } - break; + break; case SPACE_NODE: { p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; #if 0 // XXX other spacetypes to be restored in due course case SPACE_SEQ: { - SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first; + SpaceSeq *sseq = (SpaceSeq *)p->sa->spacedata.first; int rectx, recty; float zoom, zoomx, zoomy; @@ -1280,7 +1280,7 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE; /* calculate zoom factor */ - zoom= (float)(SEQ_ZOOM_FAC(sseq->zoom)); + zoom = (float)(SEQ_ZOOM_FAC(sseq->zoom)); if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) { zoomx = zoom * (p->scene->r.xasp / p->scene->r.yasp); zoomy = zoom; @@ -1293,20 +1293,20 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) * as it is too messy getting the ibuf (and could be too slow). This should be * a reasonable for most cases anyway. */ - rectx= (p->scene->r.size * p->scene->r.xsch) / 100; - recty= (p->scene->r.size * p->scene->r.ysch) / 100; + rectx = (p->scene->r.size * p->scene->r.xsch) / 100; + recty = (p->scene->r.size * p->scene->r.ysch) / 100; /* set offset and scale values for opertations to use */ - p->im2d_settings.sizex= (int)(zoomx * rectx); - p->im2d_settings.sizey= (int)(zoomy * recty); - p->im2d_settings.offsx= (int)((p->sa->winx-p->im2d_settings.sizex)/2 + sseq->xof); - p->im2d_settings.offsy= (int)((p->sa->winy-p->im2d_settings.sizey)/2 + sseq->yof); + p->im2d_settings.sizex = (int)(zoomx * rectx); + p->im2d_settings.sizey = (int)(zoomy * recty); + p->im2d_settings.offsx = (int)((p->sa->winx - p->im2d_settings.sizex) / 2 + sseq->xof); + p->im2d_settings.offsy = (int)((p->sa->winy - p->im2d_settings.sizey) / 2 + sseq->yof); } - break; + break; #endif case SPACE_IMAGE: { - SpaceImage *sima= (SpaceImage *)p->sa->spacedata.first; + SpaceImage *sima = (SpaceImage *)p->sa->spacedata.first; /* only set these flags if the image editor doesn't have an image active, * otherwise user will be confused by strokes not appearing after they're drawn @@ -1321,29 +1321,29 @@ static void gp_paint_initstroke (tGPsdata *p, short paintmode) else p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; case SPACE_CLIP: { p->gpd->sbuffer_sflag |= GP_STROKE_2DSPACE; } - break; + break; } } } /* finish off a stroke (clears buffer, but doesn't finish the paint operation) */ -static void gp_paint_strokeend (tGPsdata *p) +static void gp_paint_strokeend(tGPsdata *p) { /* for surface sketching, need to set the right OpenGL context stuff so that * the conversions will project the values correctly... */ if (gpencil_project_check(p)) { - View3D *v3d= p->sa->spacedata.first; + View3D *v3d = p->sa->spacedata.first; /* need to restore the original projection settings before packing up */ view3d_region_operator_needs_opengl(p->win, p->ar); - ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1:0); + ED_view3d_autodist_init(p->scene, p->ar, v3d, (p->gpd->flag & GP_DATA_DEPTH_STROKE) ? 1 : 0); } /* check if doing eraser or not */ @@ -1363,7 +1363,7 @@ static void gp_paint_strokeend (tGPsdata *p) } /* finish off stroke painting operation */ -static void gp_paint_cleanup (tGPsdata *p) +static void gp_paint_cleanup(tGPsdata *p) { /* p->gpd==NULL happens when stroke failed to initialize, * for example. when GP is hidden in current space (sergey) */ @@ -1379,9 +1379,9 @@ static void gp_paint_cleanup (tGPsdata *p) /* ------------------------------- */ -static void gpencil_draw_exit (bContext *C, wmOperator *op) +static void gpencil_draw_exit(bContext *C, wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; /* clear undo stack */ gpencil_undo_finish(); @@ -1405,10 +1405,10 @@ static void gpencil_draw_exit (bContext *C, wmOperator *op) MEM_freeN(p); } - op->customdata= NULL; + op->customdata = NULL; } -static int gpencil_draw_cancel (bContext *C, wmOperator *op) +static int gpencil_draw_cancel(bContext *C, wmOperator *op) { /* this is just a wrapper around exit() */ gpencil_draw_exit(C, op); @@ -1418,13 +1418,13 @@ static int gpencil_draw_cancel (bContext *C, wmOperator *op) /* ------------------------------- */ -static int gpencil_draw_init (bContext *C, wmOperator *op) +static int gpencil_draw_init(bContext *C, wmOperator *op) { tGPsdata *p; - int paintmode= RNA_enum_get(op->ptr, "mode"); + int paintmode = RNA_enum_get(op->ptr, "mode"); /* check context */ - p= op->customdata= gp_session_initpaint(C); + p = op->customdata = gp_session_initpaint(C); if ((p == NULL) || (p->status == GP_STATUS_ERROR)) { /* something wasn't set correctly in context */ gpencil_draw_exit(C, op); @@ -1439,7 +1439,7 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) } /* radius for eraser circle is defined in userprefs now */ - p->radius= U.gp_eraser; + p->radius = U.gp_eraser; /* everything is now setup ok */ return 1; @@ -1448,7 +1448,7 @@ static int gpencil_draw_init (bContext *C, wmOperator *op) /* ------------------------------- */ /* update UI indicators of status, including cursor and header prints */ -static void gpencil_draw_status_indicators (tGPsdata *p) +static void gpencil_draw_status_indicators(tGPsdata *p) { /* header prints */ switch (p->status) { @@ -1488,7 +1488,7 @@ static void gpencil_draw_status_indicators (tGPsdata *p) /* ------------------------------- */ /* create a new stroke point at the point indicated by the painting context */ -static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) +static void gpencil_draw_apply(wmOperator *op, tGPsdata *p) { /* handle drawing/erasing -> test for erasing first */ if (p->paintmode == GP_PAINTMODE_ERASER) { @@ -1496,14 +1496,14 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) gp_stroke_doeraser(p); /* store used values */ - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } /* only add current point to buffer if mouse moved (even though we got an event, it might be just noise) */ else if (gp_stroke_filtermval(p, p->mval, p->mvalo)) { /* try to add point */ - short ok= gp_stroke_addpoint(p, p->mval, p->pressure); + short ok = gp_stroke_addpoint(p, p->mval, p->pressure); /* handle errors while adding point */ if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { @@ -1525,43 +1525,43 @@ static void gpencil_draw_apply (wmOperator *op, tGPsdata *p) } /* store used values */ - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } } /* handle draw event */ -static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) +static void gpencil_draw_apply_event(wmOperator *op, wmEvent *event) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; PointerRNA itemptr; float mousef[2]; - int tablet=0; + int tablet = 0; /* convert from window-space to area-space mouse coordintes */ // NOTE: float to ints conversions, +1 factor is probably used to ensure a bit more accurate rounding... - p->mval[0]= event->mval[0] + 1; - p->mval[1]= event->mval[1] + 1; + p->mval[0] = event->mval[0] + 1; + p->mval[1] = event->mval[1] + 1; /* handle pressure sensitivity (which is supplied by tablets) */ if (event->custom == EVT_DATA_TABLET) { - wmTabletData *wmtab= event->customdata; + wmTabletData *wmtab = event->customdata; - tablet= (wmtab->Active != EVT_TABLET_NONE); - p->pressure= wmtab->Pressure; + tablet = (wmtab->Active != EVT_TABLET_NONE); + p->pressure = wmtab->Pressure; //if (wmtab->Active == EVT_TABLET_ERASER) - // TODO... this should get caught by the keymaps which call drawing in the first place + // TODO... this should get caught by the keymaps which call drawing in the first place } else - p->pressure= 1.0f; + p->pressure = 1.0f; /* fill in stroke data (not actually used directly by gpencil_draw_apply) */ RNA_collection_add(op->ptr, "stroke", &itemptr); - mousef[0]= p->mval[0]; - mousef[1]= p->mval[1]; + mousef[0] = p->mval[0]; + mousef[1] = p->mval[1]; RNA_float_set_array(&itemptr, "mouse", mousef); RNA_float_set(&itemptr, "pressure", p->pressure); RNA_boolean_set(&itemptr, "is_start", (p->flags & GP_PAINTFLAG_FIRSTRUN)); @@ -1570,9 +1570,9 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; /* special exception here for too high pressure values on first touch in * windows for some tablets, then we just skip first touch .. @@ -1591,7 +1591,7 @@ static void gpencil_draw_apply_event (wmOperator *op, wmEvent *event) /* ------------------------------- */ /* operator 'redo' (i.e. after changing some properties, but also for repeat last) */ -static int gpencil_draw_exec (bContext *C, wmOperator *op) +static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; @@ -1604,14 +1604,14 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } else - p= op->customdata; + p = op->customdata; //printf("\tGP - Start redrawing stroke\n"); /* loop over the stroke RNA elements recorded (i.e. progress of mouse movement), * setting the relevant values in context at each step, then applying */ - RNA_BEGIN (op->ptr, itemptr, "stroke") + RNA_BEGIN(op->ptr, itemptr, "stroke") { float mousef[2]; @@ -1621,7 +1621,7 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) RNA_float_get_array(&itemptr, "mouse", mousef); p->mval[0] = (int)mousef[0]; p->mval[1] = (int)mousef[1]; - p->pressure= RNA_float_get(&itemptr, "pressure"); + p->pressure = RNA_float_get(&itemptr, "pressure"); if (RNA_boolean_get(&itemptr, "is_start")) { /* if first-run flag isn't set already (i.e. not true first stroke), @@ -1638,9 +1638,9 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) if (p->flags & GP_PAINTFLAG_FIRSTRUN) { p->flags &= ~GP_PAINTFLAG_FIRSTRUN; - p->mvalo[0]= p->mval[0]; - p->mvalo[1]= p->mval[1]; - p->opressure= p->pressure; + p->mvalo[0] = p->mval[0]; + p->mvalo[1] = p->mval[1]; + p->opressure = p->pressure; } /* apply this data as necessary now (as per usual) */ @@ -1654,7 +1654,7 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) gpencil_draw_exit(C, op); /* refreshes */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work /* done */ return OPERATOR_FINISHED; @@ -1663,10 +1663,10 @@ static int gpencil_draw_exec (bContext *C, wmOperator *op) /* ------------------------------- */ /* start of interactive drawing part of operator */ -static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) { tGPsdata *p = NULL; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); if (G.debug & G_DEBUG) printf("GPencil - Starting Drawing\n"); @@ -1680,7 +1680,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else - p= op->customdata; + p = op->customdata; // TODO: set any additional settings that we can take from the events? // TODO? if tablet is erasing, force eraser to be on? @@ -1694,7 +1694,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) /* set cursor */ if (p->paintmode == GP_PAINTMODE_ERASER) - WM_cursor_modal(win, BC_CROSSCURSOR); // XXX need a better cursor + WM_cursor_modal(win, BC_CROSSCURSOR); // XXX need a better cursor else WM_cursor_modal(win, BC_PAINTBRUSHCURSOR); @@ -1705,7 +1705,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) if (event->type) { /* hotkey invoked - start drawing */ //printf("\tGP - set first spot\n"); - p->status= GP_STATUS_PAINTING; + p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ gpencil_draw_apply_event(op, event); @@ -1715,7 +1715,7 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) //printf("\tGP - hotkey invoked... waiting for click-drag\n"); } - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -1724,11 +1724,11 @@ static int gpencil_draw_invoke (bContext *C, wmOperator *op, wmEvent *event) /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ static int gpencil_area_exists(bContext *C, ScrArea *satest) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); ScrArea *sa; - for (sa= sc->areabase.first; sa; sa= sa->next) { - if (sa==satest) + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (sa == satest) return 1; } @@ -1737,14 +1737,14 @@ static int gpencil_area_exists(bContext *C, ScrArea *satest) static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; /* we must check that we're still within the area that we're set up to work from * otherwise we could crash (see bug #20586) */ if (CTX_wm_area(C) != p->sa) { printf("\t\t\tGP - wrong area execution abort!\n"); - p->status= GP_STATUS_ERROR; + p->status = GP_STATUS_ERROR; } //printf("\t\tGP - start stroke\n"); @@ -1757,14 +1757,14 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) gp_paint_initstroke(p, p->paintmode); if (p->status != GP_STATUS_ERROR) - p->status= GP_STATUS_PAINTING; + p->status = GP_STATUS_PAINTING; return op->customdata; } static void gpencil_stroke_end(wmOperator *op) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; gp_paint_cleanup(p); @@ -1772,17 +1772,17 @@ static void gpencil_stroke_end(wmOperator *op) gp_session_cleanup(p); - p->status= GP_STATUS_IDLING; + p->status = GP_STATUS_IDLING; - p->gpd= NULL; - p->gpl= NULL; - p->gpf= NULL; + p->gpd = NULL; + p->gpl = NULL; + p->gpf = NULL; } /* events handling during interactive drawing part of operator */ -static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) +static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) { - tGPsdata *p= op->customdata; + tGPsdata *p = op->customdata; int estate = OPERATOR_PASS_THROUGH; /* default exit state - not handled, so let others have a share of the pie */ // if (event->type == NDOF_MOTION) @@ -1803,7 +1803,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) { /* exit() ends the current stroke before cleaning up */ //printf("\t\tGP - end of paint op + end of stroke\n"); - p->status= GP_STATUS_DONE; + p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } @@ -1811,7 +1811,7 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE)) { /* if painting, end stroke */ if (p->status == GP_STATUS_PAINTING) { - int sketch= 0; + int sketch = 0; /* basically, this should be mouse-button up = end stroke * BUT what happens next depends on whether we 'painting sessions' is enabled */ @@ -1828,17 +1828,17 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) estate = OPERATOR_RUNNING_MODAL; /* stroke could be smoothed, send notifier to refresh screen */ - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); } else { //printf("\t\tGP - end of stroke + op\n"); - p->status= GP_STATUS_DONE; + p->status = GP_STATUS_DONE; estate = OPERATOR_FINISHED; } } else if (event->val == KM_PRESS) { /* not painting, so start stroke (this should be mouse-button down) */ - p= gpencil_stroke_begin(C, op); + p = gpencil_stroke_begin(C, op); if (p->status == GP_STATUS_ERROR) { estate = OPERATOR_CANCELLED; @@ -1878,8 +1878,8 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) } /* gpencil modal operator stores area, which can be removed while using it (like fullscreen) */ - if (0==gpencil_area_exists(C, p->sa)) - estate= OPERATOR_CANCELLED; + if (0 == gpencil_area_exists(C, p->sa)) + estate = OPERATOR_CANCELLED; else /* update status indicators - cursor, header, etc. */ gpencil_draw_status_indicators(p); @@ -1889,14 +1889,14 @@ static int gpencil_draw_modal (bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_FINISHED: /* one last flush before we're done */ gpencil_draw_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work break; case OPERATOR_CANCELLED: gpencil_draw_exit(C, op); break; - case OPERATOR_RUNNING_MODAL|OPERATOR_PASS_THROUGH: + case OPERATOR_RUNNING_MODAL | OPERATOR_PASS_THROUGH: /* event doesn't need to be handled */ //printf("unhandled event -> %d (mmb? = %d | mmv? = %d)\n", event->type, event->type == MIDDLEMOUSE, event->type==MOUSEMOVE); break; @@ -1931,7 +1931,7 @@ void GPENCIL_OT_draw(wmOperatorType *ot) ot->poll = gpencil_draw_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* settings for drawing */ RNA_def_enum(ot->srna, "mode", prop_gpencil_drawmodes, 0, "Mode", "Way to interpret mouse movements"); diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index 36624b88a9f..61f7e1bb86f 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -46,7 +46,7 @@ #include "gpencil_intern.h" -#define MAXUNDONAME 64 +#define MAXUNDONAME 64 typedef struct bGPundonode { struct bGPundonode *next, *prev; @@ -65,25 +65,25 @@ int ED_gpencil_session_active(void) int ED_undo_gpencil_step(bContext *C, int step, const char *name) { - bGPdata **gpd_ptr= NULL, *new_gpd= NULL; + bGPdata **gpd_ptr = NULL, *new_gpd = NULL; - gpd_ptr= gpencil_data_get_pointers(C, NULL); + gpd_ptr = gpencil_data_get_pointers(C, NULL); - if (step==1) { /* undo */ + if (step == 1) { /* undo */ //printf("\t\tGP - undo step\n"); if (cur_node->prev) { if (!name || strcmp(cur_node->name, name) == 0) { - cur_node= cur_node->prev; - new_gpd= cur_node->gpd; + cur_node = cur_node->prev; + new_gpd = cur_node->gpd; } } } - else if (step==-1) { + else if (step == -1) { //printf("\t\tGP - redo step\n"); if (cur_node->next) { if (!name || strcmp(cur_node->name, name) == 0) { - cur_node= cur_node->next; - new_gpd= cur_node->gpd; + cur_node = cur_node->next; + new_gpd = cur_node->gpd; } } } @@ -91,24 +91,24 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) if (new_gpd) { if (gpd_ptr) { if (*gpd_ptr) { - bGPdata *gpd= *gpd_ptr; + bGPdata *gpd = *gpd_ptr; bGPDlayer *gpl, *gpld; free_gpencil_layers(&gpd->layers); /* copy layers */ - gpd->layers.first= gpd->layers.last= NULL; + gpd->layers.first = gpd->layers.last = NULL; - for (gpl= new_gpd->layers.first; gpl; gpl= gpl->next) { + for (gpl = new_gpd->layers.first; gpl; gpl = gpl->next) { /* make a copy of source layer and its data */ - gpld= gpencil_layer_duplicate(gpl); + gpld = gpencil_layer_duplicate(gpl); BLI_addtail(&gpd->layers, gpld); } } } } - WM_event_add_notifier(C, NC_SCREEN|ND_GPENCIL|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -126,41 +126,41 @@ void gpencil_undo_push(bGPdata *gpd) if (cur_node) { /* remove all un-done nodes from stack */ - undo_node= cur_node->next; + undo_node = cur_node->next; while (undo_node) { - bGPundonode *next_node= undo_node->next; + bGPundonode *next_node = undo_node->next; - free_gpencil_data(undo_node->gpd); + BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); BLI_freelinkN(&undo_nodes, undo_node); - undo_node= next_node; + undo_node = next_node; } } /* create new undo node */ - undo_node= MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); - undo_node->gpd= gpencil_data_duplicate(gpd); + undo_node = MEM_callocN(sizeof(bGPundonode), "gpencil undo node"); + undo_node->gpd = gpencil_data_duplicate(gpd); - cur_node= undo_node; + cur_node = undo_node; BLI_addtail(&undo_nodes, undo_node); } void gpencil_undo_finish(void) { - bGPundonode *undo_node= undo_nodes.first; + bGPundonode *undo_node = undo_nodes.first; while (undo_node) { - free_gpencil_data(undo_node->gpd); + BKE_gpencil_free(undo_node->gpd); MEM_freeN(undo_node->gpd); - undo_node= undo_node->next; + undo_node = undo_node->next; } BLI_freelistN(&undo_nodes); - cur_node= NULL; + cur_node = NULL; } diff --git a/source/blender/editors/include/ED_datafiles.h b/source/blender/editors/include/ED_datafiles.h index 9b20553e0cc..64b57f6858b 100644 --- a/source/blender/editors/include/ED_datafiles.h +++ b/source/blender/editors/include/ED_datafiles.h @@ -102,6 +102,9 @@ extern char datatoc_layer_png[]; extern int datatoc_lighten_png_size; extern char datatoc_lighten_png[]; +extern int datatoc_mask_png_size; +extern char datatoc_mask_png[]; + extern int datatoc_mix_png_size; extern char datatoc_mix_png[]; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index afb14191797..490a8830d3a 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -190,7 +190,7 @@ int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, const char name[]); /* Find KeyingSet type info given a name */ -KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]); +KeyingSetInfo *ANIM_keyingset_info_find_name(const char name[]); /* for RNA type registrations... */ void ANIM_keyingset_info_register(KeyingSetInfo *ksi); @@ -292,7 +292,7 @@ short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter); * Checks whether a keyframe exists for the given ID-block one the given frame. * - It is recommended to call this method over the other keyframe-checkers directly, * in case some detail of the implementation changes... - * - frame: the value of this is quite often result of BKE_curframe() + * - frame: the value of this is quite often result of BKE_scene_frame_get() */ short id_frame_has_keyframe(struct ID *id, float frame, short filter); diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index 2df699255be..e8593e9b60d 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -32,6 +32,7 @@ struct ARegion; struct bContext; +struct MultiresModifierData; struct Object; struct RegionView3D; struct wmKeyConfig; @@ -44,14 +45,16 @@ void sculpt_get_redraw_planes(float planes[4][4], struct ARegion *ar, void ED_sculpt_force_update(struct bContext *C); float *ED_sculpt_get_last_stroke(struct Object *ob); int ED_sculpt_minmax(struct bContext *C, float *min, float *max); +void ED_sculpt_mask_layers_ensure(struct Object *ob, + struct MultiresModifierData *mmd); /* paint_ops.c */ void ED_operatortypes_paint(void); void ED_keymap_paint(struct wmKeyConfig *keyconf); /* paint_undo.c */ -#define UNDO_PAINT_IMAGE 0 -#define UNDO_PAINT_MESH 1 +#define UNDO_PAINT_IMAGE 0 +#define UNDO_PAINT_MESH 1 int ED_undo_paint_step(struct bContext *C, int type, int step, const char *name); void ED_undo_paint_free(void); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 4b614085f8e..e3759ef5fde 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -304,6 +304,8 @@ void ED_view3d_camera_lock_init(struct View3D *v3d, struct RegionView3D *rv3d); /* copy the view to the camera, return TRUE if */ int ED_view3d_camera_lock_sync(struct View3D *v3d, struct RegionView3D *rv3d); +void ED_view3D_lock_clear(struct View3D *v3d); + struct BGpic *ED_view3D_background_image_new(struct View3D *v3d); void ED_view3D_background_image_remove(struct View3D *v3d, struct BGpic *bgpic); void ED_view3D_background_image_clear(struct View3D *v3d); diff --git a/source/blender/editors/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index c1fa45a10a1..cdc4c492d56 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -974,6 +974,7 @@ DEF_ICON(BRUSH_GRAB) DEF_ICON(BRUSH_INFLATE) DEF_ICON(BRUSH_LAYER) DEF_ICON(BRUSH_LIGHTEN) +DEF_ICON(BRUSH_MASK) DEF_ICON(BRUSH_MIX) DEF_ICON(BRUSH_MULTIPLY) DEF_ICON(BRUSH_NUDGE) diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index c7fb523dcba..0c13b5de02e 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -509,9 +509,9 @@ static void ui_draw_linkline(uiLinkLine *line, int hilightActiveLines) rect.xmax = (line->to->x1 + line->to->x2) / 2.0f; rect.ymax = (line->to->y1 + line->to->y2) / 2.0f; - if(line->flag & UI_SELECT) - glColor3ub(100,100,100); - else if(hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) + if (line->flag & UI_SELECT) + glColor3ub(100, 100, 100); + else if (hilightActiveLines && ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE))) UI_ThemeColor(TH_TEXT_HI); else glColor3ub(0, 0, 0); @@ -528,9 +528,9 @@ static void ui_draw_links(uiBlock *block) // As we go, remember if we see any active or selected lines. int foundselectline = 0; int foundactiveline = 0; - for (but=block->buttons.first; but; but=but->next) { - if(but->type==LINK && but->link) { - for (line=but->link->lines.first; line; line=line->next) { + for (but = block->buttons.first; but; but = but->next) { + if (but->type == LINK && but->link) { + for (line = but->link->lines.first; line; line = line->next) { if (!(line->from->flag & UI_ACTIVE) && !(line->to->flag & UI_ACTIVE)) ui_draw_linkline(line, 0); else @@ -545,9 +545,9 @@ static void ui_draw_links(uiBlock *block) // Draw any active lines (lines with either button being hovered over). // Do this last so they appear on top of inactive lines. if (foundactiveline) { - for (but=block->buttons.first; but; but=but->next) { - if(but->type==LINK && but->link) { - for (line=but->link->lines.first; line; line=line->next) { + for (but = block->buttons.first; but; but = but->next) { + if (but->type == LINK && but->link) { + for (line = but->link->lines.first; line; line = line->next) { if ((line->from->flag & UI_ACTIVE) || (line->to->flag & UI_ACTIVE)) ui_draw_linkline(line, !foundselectline); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4cc478aa7c4..94ebdb7c0b9 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4557,7 +4557,7 @@ static int ui_but_menu(bContext *C, uiBut *but) WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); RNA_string_set(&ptr_props, "doc_id", buf); - uiItemFullO(layout, "WM_OT_doc_view", "View Docs", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); + uiItemFullO(layout, "WM_OT_doc_view", "Python Documentation", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); /* XXX inactive option, not for public! */ #if 0 @@ -4573,7 +4573,7 @@ static int ui_but_menu(bContext *C, uiBut *but) WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); RNA_string_set(&ptr_props, "doc_id", buf); - uiItemFullO(layout, "WM_OT_doc_view", "View Docs", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); + uiItemFullO(layout, "WM_OT_doc_view", "Python Documentation", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); WM_operator_properties_create(&ptr_props, "WM_OT_doc_edit"); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index e20b60cd77e..e9186aff666 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -491,6 +491,7 @@ static void init_brush_icons(void) INIT_BRUSH_ICON(ICON_BRUSH_INFLATE, inflate); INIT_BRUSH_ICON(ICON_BRUSH_LAYER, layer); INIT_BRUSH_ICON(ICON_BRUSH_LIGHTEN, lighten); + INIT_BRUSH_ICON(ICON_BRUSH_MASK, mask); INIT_BRUSH_ICON(ICON_BRUSH_MIX, mix); INIT_BRUSH_ICON(ICON_BRUSH_MULTIPLY, multiply); INIT_BRUSH_ICON(ICON_BRUSH_NUDGE, nudge); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index a0935e7abdd..9e073055fc3 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -99,48 +99,48 @@ typedef enum { } uiWidgetTypeEnum; /* panel limits */ -#define UI_PANEL_MINX 100 -#define UI_PANEL_MINY 70 +#define UI_PANEL_MINX 100 +#define UI_PANEL_MINY 70 /* uiBut->flag */ -#define UI_SELECT 1 /* use when the button is pressed */ -#define UI_SCROLLED 2 /* temp hidden, scrolled away */ -#define UI_ACTIVE 4 -#define UI_HAS_ICON 8 -#define UI_TEXTINPUT 16 -#define UI_HIDDEN 32 +#define UI_SELECT 1 /* use when the button is pressed */ +#define UI_SCROLLED 2 /* temp hidden, scrolled away */ +#define UI_ACTIVE 4 +#define UI_HAS_ICON 8 +#define UI_TEXTINPUT 16 +#define UI_HIDDEN 32 /* warn: rest of uiBut->flag in UI_interface.h */ /* internal panel drawing defines */ -#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ -#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ +#define PNL_GRID (UI_UNIT_Y / 5) /* 4 default */ +#define PNL_HEADER (UI_UNIT_Y + 4) /* 24 default */ /* panel->flag */ -#define PNL_SELECT 1 -#define PNL_CLOSEDX 2 -#define PNL_CLOSEDY 4 -#define PNL_CLOSED 6 +#define PNL_SELECT 1 +#define PNL_CLOSEDX 2 +#define PNL_CLOSEDY 4 +#define PNL_CLOSED 6 /*#define PNL_TABBED 8*/ /*UNUSED*/ -#define PNL_OVERLAP 16 +#define PNL_OVERLAP 16 /* Button text selection: * extension direction, selextend, inside ui_do_but_TEX */ -#define EXTEND_LEFT 1 -#define EXTEND_RIGHT 2 +#define EXTEND_LEFT 1 +#define EXTEND_RIGHT 2 /* for scope resize zone */ -#define SCOPE_RESIZE_PAD 9 +#define SCOPE_RESIZE_PAD 9 -typedef struct uiLinkLine { /* only for draw/edit */ +typedef struct uiLinkLine { /* only for draw/edit */ struct uiLinkLine *next, *prev; struct uiBut *from, *to; short flag, pad; } uiLinkLine; typedef struct { - void **poin; /* pointer to original pointer */ - void ***ppoin; /* pointer to original pointer-array */ - short *totlink; /* if pointer-array, here is the total */ + void **poin; /* pointer to original pointer */ + void ***ppoin; /* pointer to original pointer-array */ + short *totlink; /* if pointer-array, here is the total */ short maxlink, pad; short fromcode, tocode; @@ -178,8 +178,8 @@ struct uiBut { /* not ysed yet, was used in 2.4x for ui_draw_pulldown_round & friends */ #if 0 - void (*embossfunc)(int , int , float, float, float, float, float, int); - void (*sliderfunc)(int , float, float, float, float, float, float, int); + void (*embossfunc)(int, int, float, float, float, float, float, int); + void (*sliderfunc)(int, float, float, float, float, float, float, int); #endif uiButCompleteFunc autocomplete_func; @@ -245,7 +245,7 @@ struct uiBut { void *editcoba; void *editcumap; - /* pointer back */ + /* pointer back */ uiBlock *block; }; @@ -268,7 +268,7 @@ struct uiBlock { float minx, miny, maxx, maxy; float aspect; - int puphash; // popup menu hash for memory + int puphash; /* popup menu hash for memory */ uiButHandleFunc func; void *func_arg1; @@ -303,27 +303,27 @@ struct uiBlock { const char *lockstr; char lock; - char active; // to keep blocks while drawing and free them afterwards - char tooltipdisabled; // to avoid tooltip after click - char endblock; // uiEndBlock done? + char active; // to keep blocks while drawing and free them afterwards + char tooltipdisabled; // to avoid tooltip after click + char endblock; // uiEndBlock done? - float xofs, yofs; // offset to parent button - int dobounds, mx, my; // for doing delayed - int bounds, minbounds; // for doing delayed + float xofs, yofs; // offset to parent button + int dobounds, mx, my; // for doing delayed + int bounds, minbounds; // for doing delayed - rctf safety; // pulldowns, to detect outside, can differ per case how it is created - ListBase saferct; // uiSafetyRct list + rctf safety; // pulldowns, to detect outside, can differ per case how it is created + ListBase saferct; // uiSafetyRct list - uiPopupBlockHandle *handle; // handle + uiPopupBlockHandle *handle; // handle - struct wmOperator *ui_operator;// use so presets can find the operator, - // across menus and from nested popups which fail for operator context. + struct wmOperator *ui_operator; // use so presets can find the operator, + // across menus and from nested popups which fail for operator context. - void *evil_C; // XXX hack for dynamic operator enums + void *evil_C; // XXX hack for dynamic operator enums - struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. - float _hsv[3]; // XXX, only access via ui_block_hsv_get() - char color_profile; // color profile for correcting linear colors for display + struct UnitSettings *unit; // unit system, used a lot for numeric buttons so include here rather then fetching through the scene every time. + float _hsv[3]; // XXX, only access via ui_block_hsv_get() + char color_profile; // color profile for correcting linear colors for display }; typedef struct uiSafetyRct { @@ -425,12 +425,12 @@ void ui_searchbox_apply(uiBut *but, struct ARegion *ar); void ui_searchbox_free(struct bContext *C, struct ARegion *ar); void ui_but_search_test(uiBut *but); -typedef uiBlock* (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); +typedef uiBlock * (*uiBlockHandleCreateFunc)(struct bContext *C, struct uiPopupBlockHandle *handle, void *arg1); uiPopupBlockHandle *ui_popup_block_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); + uiBlockCreateFunc create_func, uiBlockHandleCreateFunc handle_create_func, void *arg); uiPopupBlockHandle *ui_popup_menu_create(struct bContext *C, struct ARegion *butregion, uiBut *but, - uiMenuCreateFunc create_func, void *arg, char *str); + uiMenuCreateFunc create_func, void *arg, char *str); void ui_popup_block_free(struct bContext *C, uiPopupBlockHandle *handle); @@ -466,14 +466,14 @@ extern int ui_button_is_active(struct ARegion *ar); void ui_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y3); void ui_draw_anti_roundbox(int mode, float minx, float miny, float maxx, float maxy, float rad); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); -uiWidgetColors* ui_tooltip_get_theme(void); -void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock *block, rcti *rect); +uiWidgetColors *ui_tooltip_get_theme(void); +void ui_draw_tooltip_background(uiStyle *UNUSED(style), uiBlock * block, rcti * rect); void ui_draw_search_back(struct uiStyle *style, uiBlock *block, rcti *rect); -int ui_link_bezier_points(rcti *rect, float coord_array[][2], int resol); +int ui_link_bezier_points(rcti * rect, float coord_array[][2], int resol); void ui_draw_link_bezier(rcti *rect); extern void ui_draw_but(const struct bContext *C, ARegion *ar, struct uiStyle *style, uiBut *but, rcti *rect); - /* theme color init */ +/* theme color init */ struct ThemeUI; void ui_widget_color_init(struct ThemeUI *tui); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 3c913b26dec..958ee9f5420 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -857,7 +857,7 @@ void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char PointerRNA ptr; PropertyRNA *prop; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); @@ -888,7 +888,7 @@ void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char EnumPropertyItem *item; int value, free; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); @@ -926,7 +926,7 @@ void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *op wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_boolean_set(&ptr, propname, value); @@ -939,7 +939,7 @@ void uiItemIntO(uiLayout *layout, const char *name, int icon, const char *opname wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_int_set(&ptr, propname, value); @@ -952,7 +952,7 @@ void uiItemFloatO(uiLayout *layout, const char *name, int icon, const char *opna wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_float_set(&ptr, propname, value); @@ -965,7 +965,7 @@ void uiItemStringO(uiLayout *layout, const char *name, int icon, const char *opn wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ PointerRNA ptr; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); WM_operator_properties_create_ptr(&ptr, ot); RNA_string_set(&ptr, propname, value); @@ -1611,7 +1611,7 @@ void uiItemMenuEnumO(uiLayout *layout, const char *opname, const char *propname, wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */ MenuItemLevel *lvl; - UI_OPERATOR_ERROR_RET(ot, opname, return); + UI_OPERATOR_ERROR_RET(ot, opname, return ); if (!ot->srna) { ui_item_disabled(layout, opname); @@ -1776,12 +1776,12 @@ static void ui_litem_layout_row(uiLayout *litem) /* align right/center */ offset = 0; if (litem->alignment == UI_LAYOUT_ALIGN_RIGHT) { - if (freew > 0 && freew < w - fixedw) - offset = (w - fixedw) - freew; + if (freew + fixedw > 0 && freew + fixedw < w) + offset = w - (fixedw + freew); } else if (litem->alignment == UI_LAYOUT_ALIGN_CENTER) { - if (freew > 0 && freew < w - fixedw) - offset = ((w - fixedw) - freew) / 2; + if (freew + fixedw > 0 && freew + fixedw < w) + offset = (w - (fixedw + freew)) / 2; } /* position item */ @@ -2726,8 +2726,8 @@ void uiLayoutSetContextPointer(uiLayout *layout, const char *name, PointerRNA *p void uiLayoutContextCopy(uiLayout *layout, bContextStore *context) { - uiBlock *block= layout->root->block; - layout->context= CTX_store_add_all(&block->contexts, context); + uiBlock *block = layout->root->block; + layout->context = CTX_store_add_all(&block->contexts, context); } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 93546d74c1b..6d2ac388374 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -234,12 +234,32 @@ static void UI_OT_reset_default_theme(wmOperatorType *ot) /* Copy Data Path Operator ------------------------ */ +static int copy_data_path_button_poll(bContext *C) +{ + PointerRNA ptr; + PropertyRNA *prop; + char *path; + int index; + + uiContextActiveProperty(C, &ptr, &prop, &index); + + if (ptr.id.data && ptr.data && prop) { + path = RNA_path_from_ID_to_property(&ptr, prop); + + if (path) { + MEM_freeN(path); + return 1; + } + } + + return 0; +} + static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr; PropertyRNA *prop; char *path; - int success = 0; int index; /* try to create driver using property retrieved from UI */ @@ -251,11 +271,11 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op)) if (path) { WM_clipboard_text_set(path, FALSE); MEM_freeN(path); + return OPERATOR_FINISHED; } } - /* since we're just copying, we don't really need to do anything else...*/ - return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; } static void UI_OT_copy_data_path_button(wmOperatorType *ot) @@ -267,7 +287,7 @@ static void UI_OT_copy_data_path_button(wmOperatorType *ot) /* callbacks */ ot->exec = copy_data_path_button_exec; - //op->poll= ??? // TODO: need to have some valid property before this can be done + ot->poll = copy_data_path_button_poll; /* flags */ ot->flag = OPTYPE_REGISTER; @@ -507,7 +527,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) char *str; /* create new text-block to write to */ - txt = add_empty_text("Recent Reports"); + txt = BKE_text_add("Recent Reports"); /* convert entire list to a display string, and add this to the text-block * - if commandline debug option enabled, show debug reports too @@ -516,7 +536,7 @@ static int reports_to_text_exec(bContext *C, wmOperator *UNUSED(op)) str = BKE_reports_string(reports, (G.debug & G_DEBUG) ? RPT_DEBUG : RPT_INFO); if (str) { - write_text(txt, str); + BKE_text_write(txt, str); MEM_freeN(str); return OPERATOR_FINISHED; @@ -652,7 +672,7 @@ static int editsource_text_edit(bContext *C, wmOperator *op, } if (text == NULL) { - text = add_text(filepath, bmain->name); + text = BKE_text_load(filepath, bmain->name); } if (text == NULL) { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 36e8dedee97..e4ea8bf08c5 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -836,7 +836,7 @@ static uiLayout *draw_modifier(uiLayout *layout, Scene *scene, Object *ob, if (!ELEM(md->type, eModifierType_Collision, eModifierType_Surface)) { /* only here obdata, the rest of modifiers is ob level */ - uiBlockSetButLock(block, object_data_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + uiBlockSetButLock(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if (md->type == eModifierType_ParticleSystem) { ParticleSystem *psys = ((ParticleSystemModifierData *)md)->psys; @@ -954,7 +954,7 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) // if there are problems because of this, then rna needs changed update functions. // // object_test_constraints(ob); - // if (ob->pose) update_pose_constraint_flags(ob->pose); + // if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); if (ob->type == OB_ARMATURE) DAG_id_tag_update(&ob->id, OB_RECALC_DATA | OB_RECALC_OB); else DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -970,7 +970,7 @@ static void constraint_active_func(bContext *UNUSED(C), void *ob_v, void *con_v) /* draw panel showing settings for a constraint */ static uiLayout *draw_constraint(uiLayout *layout, Object *ob, bConstraint *con) { - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraintTypeInfo *cti; uiBlock *block; uiLayout *result = NULL, *col, *box, *row; @@ -2151,7 +2151,7 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe uiItemL(sub, name, icon); ma = give_current_material(ob, index + 1); - if (ma && !scene_use_new_shading_nodes(scene)) { + if (ma && !BKE_scene_use_new_shading_nodes(scene)) { manode = give_node_material(ma); if (manode) { char str[MAX_ID_NAME + 12]; diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index cfc9e11879e..5f6384d6b24 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -67,7 +67,7 @@ * use in object mode when selecting faces (while painting) */ void paintface_flush_flags(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MPoly *polys, *mp_orig; MFace *faces; @@ -166,7 +166,7 @@ void paintface_hide(Object *ob, const int unselected) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; mpoly = me->mpoly; @@ -195,7 +195,7 @@ void paintface_reveal(Object *ob) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; mpoly = me->mpoly; @@ -325,7 +325,7 @@ void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2] Mesh *me; unsigned int index = 0; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; if (mode == 0 || mode == 1) { @@ -347,7 +347,7 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags) MPoly *mpoly; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (action == SEL_INVERT) { @@ -410,7 +410,7 @@ int paintface_minmax(Object *ob, float r_min[3], float r_max[3]) int a, b, ok = FALSE; float vec[3], bmat[3][3]; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!me || !me->mtpoly) return ok; copy_m3_m4(bmat, ob->obmat); @@ -459,7 +459,7 @@ void seam_mark_clear_tface(Scene *scene, short mode) MEdge *med; int a, b; - me = get_mesh(OBACT); + me = BKE_mesh_from_object(OBACT); if (me == 0 || me->totpoly == 0) return; if (mode == 0) @@ -516,7 +516,7 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in unsigned int a, index; /* Get the face under the cursor */ - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!facesel_face_pick(C, me, ob, mval, &index, 1)) return 0; @@ -567,7 +567,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) int sx = rect->xmax - rect->xmin + 1; int sy = rect->ymax - rect->ymin + 1; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0 || sx * sy <= 0) return OPERATOR_CANCELLED; @@ -629,7 +629,7 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend) * use in object mode when selecting vertices (while painting) */ void paintvert_flush_flags(Object *ob) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); DerivedMesh *dm = ob->derivedFinal; MVert *dm_mvert, *dm_mv; int *index_array = NULL; @@ -668,7 +668,7 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags) MVert *mvert; int a; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (action == SEL_INVERT) { diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 57d7869d3db..5a99ddb9332 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2785,7 +2785,7 @@ static int knifetool_init(bContext *C, wmOperator *op, int UNUSED(do_cut)) DerivedMesh *cage, *final; SmallHash shash; void *data[3]; - const short only_select = RNA_boolean_get(op->ptr, "only_select"); + const short only_select = RNA_boolean_get(op->ptr, "only_selected"); /* alloc new customdata */ kcd = op->customdata = MEM_callocN(sizeof(KnifeTool_OpData), "knifetool Modal Op Data"); @@ -3086,5 +3086,5 @@ void MESH_OT_knife_tool(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; RNA_def_boolean(ot->srna, "use_occlude_geometry", TRUE, "Occlude Geometry", "Only cut the front most geometry"); - RNA_def_boolean(ot->srna, "only_select", FALSE, "Only Selected", "Only cut selected geometry"); + RNA_def_boolean(ot->srna, "only_selected", FALSE, "Only Selected", "Only cut selected geometry"); } diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 0b65cce20d7..7298153791e 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -492,7 +492,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->val == KM_RELEASE) break; - cuts = MAX2(cuts - 1, 1); + cuts = MAX2(cuts - 1, 0); RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); show_cuts = TRUE; @@ -519,12 +519,15 @@ static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event) /* using the keyboard to input the number of cuts */ if (event->val == KM_PRESS) { - float value; + /* init as zero so backspace clears */ + float value = 0.0f; if (handleNumInput(&lcd->num, event)) { applyNumInput(&lcd->num, &value); - cuts = CLAMPIS(value, 1, 130); + /* allow zero so you can backspace and type in a value + * otherwise 1 as minimum would make more sense */ + cuts = CLAMPIS(value, 0, 130); RNA_int_set(op->ptr, "number_cuts", cuts); ringsel_find_edge(lcd, cuts); diff --git a/source/blender/editors/mesh/editmesh_select.c b/source/blender/editors/mesh/editmesh_select.c index 7e89025d528..538087b8e46 100644 --- a/source/blender/editors/mesh/editmesh_select.c +++ b/source/blender/editors/mesh/editmesh_select.c @@ -150,7 +150,7 @@ static void draw_triangulated(int mcords[][2], short tot) } /* do the fill */ - filldisplist(&lb, &lb, 0); + BKE_displist_fill(&lb, &lb, 0); /* do the draw */ dl = lb.first; /* filldisplist adds in head of list */ @@ -170,7 +170,7 @@ static void draw_triangulated(int mcords[][2], short tot) glEnd(); } - freedisplist(&lb); + BKE_displist_free(&lb); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 533b2ca12de..645b2d9cb68 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -66,6 +66,8 @@ #include "RE_render_ext.h" +#include "UI_interface.h" + #include "mesh_intern.h" /* allow accumulated normals to form a new direction but don't @@ -485,7 +487,7 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe * automatically building this data if invalid. Or something. */ // DAG_object_flush_update(scene, obedit, OB_RECALC_DATA); - object_handle_update(scene, obedit); + BKE_object_handle_update(scene, obedit); /* individual faces? */ // BIF_TransformSetUndo("Extrude"); @@ -614,7 +616,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op) edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor); - WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit); + EDBM_update_generic(C, em, TRUE); return OPERATOR_FINISHED; } @@ -1251,6 +1253,7 @@ void MESH_OT_edge_split(wmOperatorType *ot) /* identifiers */ ot->name = "Edge Split"; ot->idname = "MESH_OT_edge_split"; + ot->description = "Split selected edges so that each neighbor face gets its own copy"; /* api callbacks */ ot->exec = edbm_edge_split_exec; @@ -3060,6 +3063,7 @@ void MESH_OT_beautify_fill(wmOperatorType *ot) /* identifiers */ ot->name = "Beautify Fill"; ot->idname = "MESH_OT_beautify_fill"; + ot->description = "Rearrange some faces to try to get less degenerated geometry"; /* api callbacks */ ot->exec = edbm_beautify_fill_exec; @@ -3657,393 +3661,577 @@ void MESH_OT_select_mirror(wmOperatorType *ot) RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection"); } -/* qsort routines. not sure how to make these - * work, since we aren't using linked lists for - * geometry anymore. might need a sort of "swap" - * function for bmesh elements. */ +/****************************************************************************** + * qsort routines. + * Now unified, for vertices/edges/faces. */ -/* TODO All this section could probably use a refresh... - * face code works in object mode, does everything in one op, while vert uses several... - */ +enum { + SRT_VIEW_ZAXIS = 1, /* Use view Z (deep) axis. */ + SRT_VIEW_XAXIS, /* Use view X (left to right) axis. */ + SRT_CURSOR_DISTANCE, /* Use distance from element to 3D cursor. */ + SRT_MATERIAL, /* Face only: use mat number. */ + SRT_SELECTED, /* Move selected elements in first, without modifying + * relative order of selected and unselected elements. */ + SRT_RANDOMIZE, /* Randomize selected elements. */ + SRT_REVERSE, /* Reverse current order of selected elements. */ +}; -typedef struct xvertsort { - int x; /* X screen-coordinate */ - int org_idx; /* Original index of this vertex _in the mempool_ */ -} xvertsort; +typedef struct bmelemsort { + float srt; /* Sort factor */ + int org_idx; /* Original index of this element _in its mempool_ */ +} bmelemsort; - -static int vergxco(const void *v1, const void *v2) +static int bmelemsort_comp(const void *v1, const void *v2) { - const xvertsort *x1 = v1, *x2 = v2; + const bmelemsort *x1 = v1, *x2 = v2; - /* We move unchanged vertices (org_idx < 0) at the begining of the sorted list. */ - if (x1->org_idx >= 0 && x2->org_idx >= 0) - return (x1->x > x2->x) - (x1->x < x2->x); - return (x2->org_idx < 0) - (x1->org_idx < 0); + return (x1->srt > x2->srt) - (x1->srt < x2->srt); } -static void xsortvert_flag__doSetX(void *userData, BMVert *UNUSED(eve), int x, int UNUSED(y), int index) -{ - xvertsort *sortblock = userData; - - sortblock[index].x = x; -} - -/* all verts with (flag & 'flag') are sorted */ -static void xsortvert_flag(bContext *C, int flag) +/* Reorders vertices/edges/faces using a given methods. Loops are not supported. */ +static void sort_bmelem_flag(bContext *C, const int types, const int flag, const int action, + const int reverse, const unsigned int seed) { + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_edit_object(C); ViewContext vc; BMEditMesh *em; BMVert *ve; + BMEdge *ed; + BMFace *fa; BMIter iter; - xvertsort *sortblock; - int *unchangedblock, *vmap; - int totvert, sorted = 0, unchanged = 0, i; + + /* In all five elements below, 0 = vertices, 1 = edges, 2 = faces. */ + /* Just to mark protected elements. */ + char *pblock[3] = {NULL, NULL, NULL}, *pb; + bmelemsort *sblock[3] = {NULL, NULL, NULL}, *sb; + int *map[3] = {NULL, NULL, NULL}, *mp; + int totelem[3] = {0, 0, 0}, tot; + int affected[3] = {0, 0, 0}, aff; + int i, j; + + if (!(types && flag && action)) + return; em_setup_viewcontext(C, &vc); em = vc.em; - totvert = em->bm->totvert; + if (types & BM_VERT) + totelem[0] = em->bm->totvert; + if (types & BM_EDGE) + totelem[1] = em->bm->totedge; + if (types & BM_FACE) + totelem[2] = em->bm->totface; - sortblock = MEM_callocN(sizeof(xvertsort) * totvert, "xsort sorted"); - /* Stores unchanged verts, will be reused as final old2new vert mapping... */ - unchangedblock = MEM_callocN(sizeof(int) * totvert, "xsort unchanged"); - BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(ve, flag)) { - sortblock[i].org_idx = i; - sorted++; + if (ELEM(action, SRT_VIEW_ZAXIS, SRT_VIEW_XAXIS)) { + RegionView3D *rv3d = ED_view3d_context_rv3d(C); + float mat[4][4]; + float fact = reverse ? -1.0 : 1.0; + int coidx = (action == SRT_VIEW_ZAXIS) ? 2 : 0; + + mult_m4_m4m4(mat, rv3d->viewmat, ob->obmat); /* Apply the view matrix to the object matrix. */ + + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + float co[3]; + mul_v3_m4v3(co, mat, ve->co); + + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } } - else { - unchangedblock[unchanged++] = i; - sortblock[i].org_idx = -1; + + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + float co[3]; + mid_v3_v3v3(co, ed->v1->co, ed->v2->co); + mul_m4_v3(mat, co); + + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + float co[3]; + BM_face_calc_center_mean(fa, co); + mul_m4_v3(mat, co); + + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = co[coidx] * fact; + } + else { + pb[i] = TRUE; + } + } } } -/* printf("%d verts: %d to be sorted, %d unchanged…\n", totvert, sorted, unchanged);*/ - if (sorted == 0) { - MEM_freeN(sortblock); - MEM_freeN(unchangedblock); + + else if (action == SRT_CURSOR_DISTANCE) { + View3D *v3d = CTX_wm_view3d(C); + float cur[3]; + float mat[4][4]; + float fact = reverse ? -1.0 : 1.0; + + if (v3d && v3d->localvd) + copy_v3_v3(cur, v3d->cursor); + else + copy_v3_v3(cur, scene->cursor); + invert_m4_m4(mat, ob->obmat); + mul_m4_v3(mat, cur); + + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = len_squared_v3v3(cur, ve->co) * fact; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + float co[3]; + mid_v3_v3v3(co, ed->v1->co, ed->v2->co); + + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = len_squared_v3v3(cur, co) * fact; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + float co[3]; + BM_face_calc_center_mean(fa, co); + + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = len_squared_v3v3(cur, co) * fact; + } + else { + pb[i] = TRUE; + } + } + } + } + + /* Faces only! */ + else if (action == SRT_MATERIAL && totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + /* Reverse materials' order, not order of faces inside each mat! */ + /* Note: cannot use totcol, as mat_nr may sometimes be greater... */ + float srt = reverse ? (float)(MAXMAT - fa->mat_nr) : (float)fa->mat_nr; + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + /* Multiplying with totface and adding i ensures us we keep current order for all faces of same mat. */ + sb[affected[2]++].srt = srt * ((float)totelem[2]) + ((float)i); +/* printf("e: %d; srt: %f; final: %f\n", i, srt, srt * ((float)totface) + ((float)i));*/ + } + else { + pb[i] = TRUE; + } + } + } + + else if (action == SRT_SELECTED) { + int *tbuf[3] = {NULL, NULL, NULL}, *tb; + + if (totelem[0]) { + tb = tbuf[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert tbuf"); + mp = map[0] = MEM_callocN(sizeof(int) * totelem[0], "sort_bmelem vert map"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + mp[affected[0]++] = i; + } + else { + *tb = i; + tb++; + } + } + } + + if (totelem[1]) { + tb = tbuf[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge tbuf"); + mp = map[1] = MEM_callocN(sizeof(int) * totelem[1], "sort_bmelem edge map"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + mp[affected[1]++] = i; + } + else { + *tb = i; + tb++; + } + } + } + + if (totelem[2]) { + tb = tbuf[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face tbuf"); + mp = map[2] = MEM_callocN(sizeof(int) * totelem[2], "sort_bmelem face map"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + mp[affected[2]++] = i; + } + else { + *tb = i; + tb++; + } + } + } + + for (j = 3; j--;) { + int tot = totelem[j]; + int aff = affected[j]; + tb = tbuf[j]; + mp = map[j]; + if (!(tb && mp)) + continue; + if (ELEM(aff, 0, tot)) { + MEM_freeN(tb); + MEM_freeN(mp); + map[j] = NULL; + continue; + } + if (reverse) { + memcpy(tb + (tot - aff), mp, aff * sizeof(int)); + } + else { + memcpy(mp + aff, tb, (tot - aff) * sizeof(int)); + tb = mp; + mp = map[j] = tbuf[j]; + tbuf[j] = tb; + } + + /* Reverse mapping, we want an org2new one! */ + for (i = tot, tb = tbuf[j] + tot - 1; i--; tb--) { + mp[*tb] = i; + } + MEM_freeN(tbuf[j]); + } + } + + else if (action == SRT_RANDOMIZE) { + if (totelem[0]) { + /* Re-init random generator for each element type, to get consistant random when + * enabling/disabling an element type. */ + BLI_srandom(seed); + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[1]) { + BLI_srandom(seed); + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + BLI_srandom(seed); + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = BLI_frand(); + } + else { + pb[i] = TRUE; + } + } + } + } + + else if (action == SRT_REVERSE) { + if (totelem[0]) { + pb = pblock[0] = MEM_callocN(sizeof(char) * totelem[0], "sort_bmelem vert pblock"); + sb = sblock[0] = MEM_callocN(sizeof(bmelemsort) * totelem[0], "sort_bmelem vert sblock"); + + BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { + if (BM_elem_flag_test(ve, flag)) { + pb[i] = FALSE; + sb[affected[0]].org_idx = i; + sb[affected[0]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[1]) { + pb = pblock[1] = MEM_callocN(sizeof(char) * totelem[1], "sort_bmelem edge pblock"); + sb = sblock[1] = MEM_callocN(sizeof(bmelemsort) * totelem[1], "sort_bmelem edge sblock"); + + BM_ITER_MESH_INDEX (ed, &iter, em->bm, BM_EDGES_OF_MESH, i) { + if (BM_elem_flag_test(ed, flag)) { + pb[i] = FALSE; + sb[affected[1]].org_idx = i; + sb[affected[1]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + + if (totelem[2]) { + pb = pblock[2] = MEM_callocN(sizeof(char) * totelem[2], "sort_bmelem face pblock"); + sb = sblock[2] = MEM_callocN(sizeof(bmelemsort) * totelem[2], "sort_bmelem face sblock"); + + BM_ITER_MESH_INDEX (fa, &iter, em->bm, BM_FACES_OF_MESH, i) { + if (BM_elem_flag_test(fa, flag)) { + pb[i] = FALSE; + sb[affected[2]].org_idx = i; + sb[affected[2]++].srt = (float)-i; + } + else { + pb[i] = TRUE; + } + } + } + } + +/* printf("%d vertices: %d to be affected…\n", totelem[0], affected[0]);*/ +/* printf("%d edges: %d to be affected…\n", totelem[1], affected[1]);*/ +/* printf("%d faces: %d to be affected…\n", totelem[2], affected[2]);*/ + if (affected[0] == 0 && affected[1] == 0 && affected[2] == 0) { + for (j = 3; j--;) { + if (pblock[j]) + MEM_freeN(pblock[j]); + if (sblock[j]) + MEM_freeN(sblock[j]); + if (map[j]) + MEM_freeN(map[j]); + } return; } - ED_view3d_init_mats_rv3d(vc.obedit, vc.rv3d); - mesh_foreachScreenVert(&vc, xsortvert_flag__doSetX, sortblock, V3D_CLIP_TEST_OFF); + /* Sort affected elements, and populate mapping arrays, if needed. */ + for (j = 3; j--;) { + pb = pblock[j]; + sb = sblock[j]; + if (pb && sb && !map[j]) { + char *p_blk; + bmelemsort *s_blk; + tot = totelem[j]; + aff = affected[j]; - qsort(sortblock, totvert, sizeof(xvertsort), vergxco); + qsort(sb, aff, sizeof(bmelemsort), bmelemsort_comp); - /* Convert sortblock into an array mapping old idx to new. */ - vmap = unchangedblock; - unchangedblock = NULL; - if (unchanged) { - unchangedblock = MEM_mallocN(sizeof(int) * unchanged, "xsort unchanged"); - memcpy(unchangedblock, vmap, unchanged * sizeof(int)); - } - for (i = totvert; i--; ) { - if (i < unchanged) - vmap[unchangedblock[i]] = i; - else - vmap[sortblock[i].org_idx] = i; - } - - MEM_freeN(sortblock); - if (unchangedblock) - MEM_freeN(unchangedblock); - - BM_mesh_remap(em->bm, vmap, NULL, NULL); - - MEM_freeN(vmap); -} - -static int edbm_vertices_sort_exec(bContext *C, wmOperator *UNUSED(op)) -{ - xsortvert_flag(C, BM_ELEM_SELECT); - return OPERATOR_FINISHED; -} - -void MESH_OT_vertices_sort(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Vertex Sort"; - ot->description = "Sort vertex order"; - ot->idname = "MESH_OT_vertices_sort"; - - /* api callbacks */ - ot->exec = edbm_vertices_sort_exec; - - ot->poll = EM_view3d_poll; /* uses view relative X axis to sort verts */ - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; -} - -/* ********************** SORT FACES ******************* */ - -static void permutate(void *list, int num, int size, int *index) -{ - void *buf; - int len; - int i; - - len = num * size; - - buf = MEM_mallocN(len, "permutate"); - memcpy(buf, list, len); - - for (i = 0; i < num; i++) { - memcpy((char *)list + (i * size), (char *)buf + (index[i] * size), size); - } - MEM_freeN(buf); -} - -/* sort faces on view axis */ -static float *face_sort_floats; -static int float_sort(const void *v1, const void *v2) -{ - float x1, x2; - - x1 = face_sort_floats[((int *) v1)[0]]; - x2 = face_sort_floats[((int *) v2)[0]]; - - if (x1 > x2) return 1; - else if (x1 < x2) return -1; - return 0; -} - -static int edbm_sort_faces_exec(bContext *C, wmOperator *op) -{ - RegionView3D *rv3d = ED_view3d_context_rv3d(C); - View3D *v3d = CTX_wm_view3d(C); - Object *ob = CTX_data_edit_object(C); - Scene *scene = CTX_data_scene(C); - Mesh *me; - CustomDataLayer *layer; - int i, j, *index; - int event; - float reverse = 1; - // XXX int ctrl = 0; - - if (!v3d) return OPERATOR_CANCELLED; - - /* This operator work in Object Mode, not in edit mode. - * After talk with Campbell we agree that there is no point to port this to EditMesh right now. - * so for now, we just exit_editmode and enter_editmode at the end of this function. - */ - ED_object_exit_editmode(C, EM_FREEDATA); - - me = ob->data; - if (me->totpoly == 0) { - ED_object_enter_editmode(C, 0); - return OPERATOR_FINISHED; - } - - event = RNA_enum_get(op->ptr, "type"); - - // XXX - //if (ctrl) - // reverse = -1; - - /* create index list */ - index = (int *)MEM_mallocN(sizeof(int) * me->totpoly, "sort faces"); - for (i = 0; i < me->totpoly; i++) { - index[i] = i; - } - - face_sort_floats = (float *) MEM_mallocN(sizeof(float) * me->totpoly, "sort faces float"); - - /* sort index list instead of faces itself - * and apply this permutation to all face layers - */ - if (event == 5) { - /* Random */ - for (i = 0; i < me->totpoly; i++) { - face_sort_floats[i] = BLI_frand(); + mp = map[j] = MEM_mallocN(sizeof(int) * tot, "sort_bmelem map"); + p_blk = pb + tot - 1; + s_blk = sb + aff - 1; + for (i = tot; i--; p_blk--) { + if (*p_blk) { /* Protected! */ + mp[i] = i; + } + else { + mp[s_blk->org_idx] = i; + s_blk--; + } + } } - qsort(index, me->totpoly, sizeof(int), float_sort); + if (pb) + MEM_freeN(pb); + if (sb) + MEM_freeN(sb); + } + + BM_mesh_remap(em->bm, map[0], map[1], map[2]); +/* DAG_id_tag_update(ob->data, 0);*/ + + for (j = 3; j--;) { + if (map[j]) + MEM_freeN(map[j]); + } +} + +static int edbm_sort_elements_exec(bContext *C, wmOperator *op) +{ + int action = RNA_enum_get(op->ptr, "type"); + PropertyRNA *prop_elem_types = RNA_struct_find_property(op->ptr, "elements"); + int elem_types = 0; + int reverse = RNA_boolean_get(op->ptr, "reverse"); + unsigned int seed = RNA_int_get(op->ptr, "seed"); + + /* If no elem_types set, use current selection mode to set it! */ + if (RNA_property_is_set(op->ptr, prop_elem_types)) { + elem_types = RNA_property_enum_get(op->ptr, prop_elem_types); } else { - MPoly *mp; - MLoop *ml; - MVert *mv; - float vec[3]; - float mat[4][4]; - float cur[3]; - - if (event == 1) - mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */ - else if (event == 2) { /* sort from cursor */ - if (v3d && v3d->localvd) { - copy_v3_v3(cur, v3d->cursor); - } - else { - copy_v3_v3(cur, scene->cursor); - } - invert_m4_m4(mat, OBACT->obmat); - mul_m4_v3(mat, cur); - } - - mp = me->mpoly; - - for (i = 0; i < me->totpoly; i++, mp++) { - if (event == 3) { - face_sort_floats[i] = ((float)mp->mat_nr) * reverse; - } - else if (event == 4) { - /* selected first */ - if (mp->flag & ME_FACE_SEL) - face_sort_floats[i] = 0.0; - else - face_sort_floats[i] = reverse; - } - else { - /* find the face's center */ - ml = me->mloop + mp->loopstart; - zero_v3(vec); - for (j = 0; j < mp->totloop; j++, ml++) { - mv = me->mvert + ml->v; - add_v3_v3(vec, mv->co); - } - mul_v3_fl(vec, 1.0f / (float)mp->totloop); - - if (event == 1) { /* sort on view axis */ - mul_m4_v3(mat, vec); - face_sort_floats[i] = vec[2] * reverse; - } - else if (event == 2) { /* distance from cursor */ - face_sort_floats[i] = len_v3v3(cur, vec) * reverse; /* back to front */ - } - } - } - qsort(index, me->totpoly, sizeof(int), float_sort); - } - - MEM_freeN(face_sort_floats); - for (i = 0; i < me->pdata.totlayer; i++) { - layer = &me->pdata.layers[i]; - permutate(layer->data, me->totpoly, CustomData_sizeof(layer->type), index); + BMEditMesh *em = BMEdit_FromObject(CTX_data_edit_object(C)); + if (em->selectmode & SCE_SELECT_VERTEX) + elem_types |= BM_VERT; + if (em->selectmode & SCE_SELECT_EDGE) + elem_types |= BM_EDGE; + if (em->selectmode & SCE_SELECT_FACE) + elem_types |= BM_FACE; + RNA_enum_set(op->ptr, "elements", elem_types); } - MEM_freeN(index); - DAG_id_tag_update(ob->data, 0); - - /* Return to editmode. */ - ED_object_enter_editmode(C, 0); - + sort_bmelem_flag(C, elem_types, BM_ELEM_SELECT, action, reverse, seed); return OPERATOR_FINISHED; } -void MESH_OT_sort_faces(wmOperatorType *ot) +static int edbm_sort_elements_draw_check_prop(PointerRNA *ptr, PropertyRNA *prop) +{ + const char *prop_id = RNA_property_identifier(prop); + int action = RNA_enum_get(ptr, "type"); + + /* Only show seed for randomize action! */ + if (strcmp(prop_id, "seed") == 0) { + if (action == SRT_RANDOMIZE) + return TRUE; + else + return FALSE; + } + + /* Hide seed for reverse and randomize actions! */ + if (strcmp(prop_id, "reverse") == 0) { + if (ELEM(action, SRT_RANDOMIZE, SRT_REVERSE)) + return FALSE; + else + return TRUE; + } + + return TRUE; +} + +static void edbm_sort_elements_ui(bContext *C, wmOperator *op) +{ + uiLayout *layout = op->layout; + wmWindowManager *wm = CTX_wm_manager(C); + PointerRNA ptr; + + RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); + + /* Main auto-draw call. */ + uiDefAutoButsRNA(layout, &ptr, edbm_sort_elements_draw_check_prop, '\0'); +} + +void MESH_OT_sort_elements(wmOperatorType *ot) { static EnumPropertyItem type_items[] = { - { 1, "VIEW_AXIS", 0, "View Axis", "" }, - { 2, "CURSOR_DISTANCE", 0, "Cursor Distance", "" }, - { 3, "MATERIAL", 0, "Material", "" }, - { 4, "SELECTED", 0, "Selected", "" }, - { 5, "RANDOMIZE", 0, "Randomize", "" }, - { 0, NULL, 0, NULL, NULL }}; + {SRT_VIEW_ZAXIS, "VIEW_ZAXIS", 0, "View Z Axis", + "Sort selected elements from farest to nearest one in current view"}, + {SRT_VIEW_XAXIS, "VIEW_XAXIS", 0, "View X Axis", + "Sort selected elements from left to right one in current view"}, + {SRT_CURSOR_DISTANCE, "CURSOR_DISTANCE", 0, "Cursor Distance", + "Sort selected elements from nearest to farest from 3D cursor"}, + {SRT_MATERIAL, "MATERIAL", 0, "Material", + "Sort selected elements from smallest to greatest material index (faces only!)"}, + {SRT_SELECTED, "SELECTED", 0, "Selected", + "Move all selected elements in first places, preserving their relative order " + "(WARNING: this will affect unselected elements' indices as well!)"}, + {SRT_RANDOMIZE, "RANDOMIZE", 0, "Randomize", "Randomize order of selected elements"}, + {SRT_REVERSE, "REVERSE", 0, "Reverse", "Reverse current order of selected elements"}, + {0, NULL, 0, NULL, NULL}, + }; + + static EnumPropertyItem elem_items[] = { + {BM_VERT, "VERT", 0, "Vertices", ""}, + {BM_EDGE, "EDGE", 0, "Edges", ""}, + {BM_FACE, "FACE", 0, "Faces", ""}, + {0, NULL, 0, NULL, NULL}, + }; /* identifiers */ - ot->name = "Sort Faces"; // XXX (Ctrl to reverse)%t| - ot->description = "The faces of the active Mesh Object are sorted, based on the current view"; - ot->idname = "MESH_OT_sort_faces"; + ot->name = "Sort Mesh Elements"; + ot->description = "The order of selected vertices/edges/faces is modified, based on a given method"; + ot->idname = "MESH_OT_sort_elements"; /* api callbacks */ ot->invoke = WM_menu_invoke; - ot->exec = edbm_sort_faces_exec; + ot->exec = edbm_sort_elements_exec; ot->poll = ED_operator_editmesh; + ot->ui = edbm_sort_elements_ui; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); + ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "Type of re-ordering operation to apply"); + RNA_def_enum_flag(ot->srna, "elements", elem_items, 0, "Elements", + "Which elements to affect (vertices, edges and/or faces)"); + RNA_def_boolean(ot->srna, "reverse", FALSE, "Reverse", "Reverse the sorting effect"); + RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for random-based operations", 0, 255); } -/* ******************************* Randomize verts ************************* */ -static void hashvert_flag(BMEditMesh *em, int flag, unsigned int seed) -{ - BMVert *ve; - BMIter iter; - char *block /* Just to mark protected vertices */, *t_blk; - int *randblock, *vmap, *t_idx, *r_idx; - int totvert, randomized = 0, /*protected = 0, */ i; - - totvert = em->bm->totvert; - - block = MEM_callocN(sizeof(char) * totvert, "randvert block"); - randblock = MEM_callocN(sizeof(int) * totvert, "randvert randblock"); - BM_ITER_MESH_INDEX (ve, &iter, em->bm, BM_VERTS_OF_MESH, i) { - if (BM_elem_flag_test(ve, flag)) { - block[i] = FALSE; - randblock[randomized++] = i; - } - else { - block[i] = TRUE; - } - } -/* protected = totvert - randomized;*/ -/* printf("%d verts: %d to be randomized, %d protected…\n", totvert, randomized, protected);*/ - if (randomized == 0) { - MEM_freeN(block); - MEM_freeN(randblock); - return; - } - - - /* Randomize non-protected vertices indices, and create an array mapping old idx to new - * from both blocks, keeping protected vertices at the same indices. */ - vmap = randblock; - randblock = MEM_mallocN(sizeof(int) * randomized, "randvert randblock"); - memcpy(randblock, vmap, randomized * sizeof(int)); - BLI_array_randomize((void *)randblock, sizeof(int), randomized, seed); - t_blk = block + totvert - 1; - t_idx = vmap + totvert - 1; - r_idx = randblock + randomized - 1; - for (i = totvert; i--; t_blk--, t_idx--) { - if (*t_blk) /* Protected! */ - *t_idx = i; - else - *t_idx = *r_idx--; - } - - MEM_freeN(randblock); - MEM_freeN(block); - - BM_mesh_remap(em->bm, vmap, NULL, NULL); - - MEM_freeN(vmap); -} - -static int edbm_vertices_randomize_exec(bContext *C, wmOperator *op) -{ - Object *obedit = CTX_data_edit_object(C); - BMEditMesh *em = BMEdit_FromObject(obedit); - unsigned int seed = RNA_int_get(op->ptr, "seed"); - - hashvert_flag(em, BM_ELEM_SELECT, seed); - - return OPERATOR_FINISHED; -} - -void MESH_OT_vertices_randomize(wmOperatorType *ot) -{ - /* identifiers */ - ot->name = "Vertex Randomize"; - ot->description = "Randomize vertex order"; - ot->idname = "MESH_OT_vertices_randomize"; - - /* api callbacks */ - ot->exec = edbm_vertices_randomize_exec; - - ot->poll = ED_operator_editmesh; - - /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; - - /* Properties */ - ot->prop = RNA_def_int(ot->srna, "seed", 0, 0, INT_MAX, "Seed", "Seed for the random generator", 0, 255); -} - -/******end of qsort stuff ****/ - +/****** end of qsort stuff ****/ static int edbm_noise_exec(bContext *C, wmOperator *op) { diff --git a/source/blender/editors/mesh/editmesh_utils.c b/source/blender/editors/mesh/editmesh_utils.c index a17f335091b..533ead1ff29 100644 --- a/source/blender/editors/mesh/editmesh_utils.c +++ b/source/blender/editors/mesh/editmesh_utils.c @@ -545,11 +545,11 @@ static void free_undo(void *me_v) { Mesh *me = me_v; if (me->key) { - free_key(me->key); + BKE_key_free(me->key); MEM_freeN(me->key); } - free_mesh(me, FALSE); + BKE_mesh_free(me, FALSE); MEM_freeN(me); } @@ -611,7 +611,7 @@ UvVertMap *EDBM_uv_vert_map_create(BMEditMesh *em, int selected, int do_face_idx buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { - free_uv_vert_map(vmap); + BKE_mesh_uv_vert_map_free(vmap); if (do_face_idx_array) EDBM_index_arrays_free(em); return NULL; diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index f611a985797..bc11a627be6 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -556,11 +556,11 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event) char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } if (!ima) { @@ -808,16 +808,16 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface) * contain the normal of the poly the face was tessellated from. */ face_nors = CustomData_add_layer(&mesh->fdata, CD_NORMAL, CD_CALLOC, NULL, mesh->totface); - mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, - mesh->totloop, mesh->totpoly, - NULL /* polyNors_r */, - mesh->mface, mesh->totface, - polyindex, face_nors, FALSE); + BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, + mesh->totloop, mesh->totpoly, + NULL /* polyNors_r */, + mesh->mface, mesh->totface, + polyindex, face_nors, FALSE); #else - mesh_calc_normals(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL); + BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL); (void)polyindex; (void)face_nors; #endif @@ -1138,13 +1138,13 @@ void ED_mesh_polys_add(Mesh *mesh, ReportList *reports, int count) void ED_mesh_calc_normals(Mesh *mesh) { #ifdef USE_BMESH_MPOLY_NORMALS - mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL, NULL, 0, NULL, NULL, FALSE); + BKE_mesh_calc_normals_mapping_ex(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL, NULL, 0, NULL, NULL, FALSE); #else - mesh_calc_normals(mesh->mvert, mesh->totvert, - mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, - NULL); + BKE_mesh_calc_normals(mesh->mvert, mesh->totvert, + mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, + NULL); #endif } diff --git a/source/blender/editors/mesh/mesh_intern.h b/source/blender/editors/mesh/mesh_intern.h index a5eb39c7da4..ee74cea48af 100644 --- a/source/blender/editors/mesh/mesh_intern.h +++ b/source/blender/editors/mesh/mesh_intern.h @@ -148,8 +148,6 @@ extern struct EnumPropertyItem *corner_type_items; void MESH_OT_merge(struct wmOperatorType *ot); void MESH_OT_subdivide(struct wmOperatorType *ot); void MESH_OT_remove_doubles(struct wmOperatorType *ot); -void MESH_OT_vertices_randomize(struct wmOperatorType *ot); -void MESH_OT_vertices_sort(struct wmOperatorType *ot); void MESH_OT_spin(struct wmOperatorType *ot); void MESH_OT_screw(struct wmOperatorType *ot); @@ -184,7 +182,7 @@ void MESH_OT_rip(struct wmOperatorType *ot); void MESH_OT_shape_propagate_to_all(struct wmOperatorType *ot); void MESH_OT_blend_from_shape(struct wmOperatorType *ot); -void MESH_OT_sort_faces(struct wmOperatorType *ot); +void MESH_OT_sort_elements(struct wmOperatorType *ot); void MESH_OT_mark_freestyle_face(struct wmOperatorType *ot); /* ******************* mesh_data.c */ diff --git a/source/blender/editors/mesh/mesh_navmesh.c b/source/blender/editors/mesh/mesh_navmesh.c index cc640e38fc2..14d20d68455 100644 --- a/source/blender/editors/mesh/mesh_navmesh.c +++ b/source/blender/editors/mesh/mesh_navmesh.c @@ -316,8 +316,8 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh, } else { obedit = base->object; - scene_deselect_all(scene); - scene_select_base(scene, base); + BKE_scene_base_deselect_all(scene); + BKE_scene_base_select(scene, base); copy_v3_v3(obedit->loc, co); copy_v3_v3(obedit->rot, rot); } diff --git a/source/blender/editors/mesh/mesh_ops.c b/source/blender/editors/mesh/mesh_ops.c index 37ae5b4a967..dc0d576d701 100644 --- a/source/blender/editors/mesh/mesh_ops.c +++ b/source/blender/editors/mesh/mesh_ops.c @@ -87,8 +87,6 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_primitive_ico_sphere_add); WM_operatortype_append(MESH_OT_duplicate); WM_operatortype_append(MESH_OT_remove_doubles); - WM_operatortype_append(MESH_OT_vertices_sort); - WM_operatortype_append(MESH_OT_vertices_randomize); WM_operatortype_append(MESH_OT_spin); WM_operatortype_append(MESH_OT_screw); @@ -118,7 +116,7 @@ void ED_operatortypes_mesh(void) WM_operatortype_append(MESH_OT_dissolve_limited); WM_operatortype_append(MESH_OT_faces_shade_smooth); WM_operatortype_append(MESH_OT_faces_shade_flat); - WM_operatortype_append(MESH_OT_sort_faces); + WM_operatortype_append(MESH_OT_sort_elements); WM_operatortype_append(MESH_OT_mark_freestyle_face); WM_operatortype_append(MESH_OT_delete); @@ -199,49 +197,49 @@ void ED_operatormacros_mesh(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Cut mesh loop and slide it"; + ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", "Cut mesh loop and slide it", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_loopcut"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide"); RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); - ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Duplicate mesh and move"; + ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", "Duplicate mesh and move", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Rip polygons and move the result"; + ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", "Rip polygons and move the result", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "MESH_OT_rip"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude region and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", + "Extrude region and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude faces and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", + "Extrude faces and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude edges and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", + "Extrude edges and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); RNA_boolean_set(otmacro->ptr, "mirror", FALSE); - ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO | OPTYPE_REGISTER); - ot->description = "Extrude vertices and move result"; + ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", + "Extrude vertices and move result", OPTYPE_UNDO | OPTYPE_REGISTER); otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", 0); @@ -355,11 +353,11 @@ void ED_keymap_mesh(wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", TRUE); - RNA_boolean_set(kmi->ptr, "only_select", FALSE); + RNA_boolean_set(kmi->ptr, "only_selected", FALSE); kmi = WM_keymap_add_item(keymap, "MESH_OT_knife_tool", KKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "use_occlude_geometry", FALSE); - RNA_boolean_set(kmi->ptr, "only_select", TRUE); + RNA_boolean_set(kmi->ptr, "only_selected", TRUE); WM_keymap_add_item(keymap, "OBJECT_OT_vertex_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index e41807787f1..aa89eaa0c6d 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -182,7 +182,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) */ if (key) { /* make a duplicate copy that will only be used here... (must remember to free it!) */ - nkey = copy_key(key); + nkey = BKE_key_copy(key); /* for all keys in old block, clear data-arrays */ for (kb = key->block.first; kb; kb = kb->next) { @@ -524,13 +524,13 @@ int join_mesh_exec(bContext *C, wmOperator *op) #if 0 /* free it's ipo too - both are not actually freed from memory yet as ID-blocks */ if (nkey->ipo) { - free_ipo(nkey->ipo); + BKE_ipo_free(nkey->ipo); BLI_remlink(&bmain->ipo, nkey->ipo); MEM_freeN(nkey->ipo); } #endif - free_key(nkey); + BKE_key_free(nkey); BLI_remlink(&bmain->key, nkey); MEM_freeN(nkey); } diff --git a/source/blender/editors/metaball/mball_edit.c b/source/blender/editors/metaball/mball_edit.c index fd842ce4f7c..ed51f53eb03 100644 --- a/source/blender/editors/metaball/mball_edit.c +++ b/source/blender/editors/metaball/mball_edit.c @@ -67,24 +67,24 @@ /* This function is used to free all MetaElems from MetaBall */ void free_editMball(Object *obedit) { - MetaBall *mb = (MetaBall*)obedit->data; + MetaBall *mb = (MetaBall *)obedit->data; - mb->editelems= NULL; - mb->lastelem= NULL; + mb->editelems = NULL; + mb->lastelem = NULL; } /* This function is called, when MetaBall Object is * switched from object mode to edit mode */ void make_editMball(Object *obedit) { - MetaBall *mb = (MetaBall*)obedit->data; - MetaElem *ml;/*, *newml;*/ + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml; /*, *newml;*/ - ml= mb->elems.first; + ml = mb->elems.first; while (ml) { if (ml->flag & SELECT) mb->lastelem = ml; - ml= ml->next; + ml = ml->next; } mb->editelems = &mb->elems; @@ -100,22 +100,22 @@ void load_editMball(Object *UNUSED(obedit)) /* Add metaelem primitive to metaball object (which is in edit mode) */ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNUSED(newname)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mball = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mball = (MetaBall *)obedit->data; MetaElem *ml; /* Deselect all existing metaelems */ - ml= mball->editelems->first; + ml = mball->editelems->first; while (ml) { ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } - ml= BKE_metaball_element_add(mball, type); + ml = BKE_mball_element_add(mball, type); copy_v3_v3(&ml->x, mat[3]); ml->flag |= SELECT; - mball->lastelem= ml; + mball->lastelem = ml; return ml; } @@ -125,12 +125,12 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int UNU static int mball_select_all_exec(bContext *C, wmOperator *op) { //Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; int action = RNA_enum_get(op->ptr, "action"); - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { if (action == SEL_TOGGLE) { action = SEL_SELECT; @@ -139,26 +139,26 @@ static int mball_select_all_exec(bContext *C, wmOperator *op) action = SEL_DESELECT; break; } - ml= ml->next; + ml = ml->next; } } - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { switch (action) { - case SEL_SELECT: - ml->flag |= SELECT; - break; - case SEL_DESELECT: - ml->flag &= ~SELECT; - break; - case SEL_INVERT: - ml->flag ^= SELECT; - break; + case SEL_SELECT: + ml->flag |= SELECT; + break; + case SEL_DESELECT: + ml->flag &= ~SELECT; + break; + case SEL_INVERT: + ml->flag ^= SELECT; + break; } - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); } return OPERATOR_FINISHED; @@ -176,7 +176,7 @@ void MBALL_OT_select_all(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -186,16 +186,16 @@ void MBALL_OT_select_all(wmOperatorType *ot) /* Random metaball selection */ static int select_random_metaelems_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - float percent= RNA_float_get(op->ptr, "percent"); + float percent = RNA_float_get(op->ptr, "percent"); if (percent == 0.0f) return OPERATOR_CANCELLED; - ml= mb->editelems->first; - BLI_srand(BLI_rand()); /* Random seed */ + ml = mb->editelems->first; + BLI_srand(BLI_rand()); /* Random seed */ /* Stupid version of random selection. Should be improved. */ while (ml) { @@ -203,10 +203,10 @@ static int select_random_metaelems_exec(bContext *C, wmOperator *op) ml->flag |= SELECT; else ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return OPERATOR_FINISHED; } @@ -225,7 +225,7 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_percentage(ot->srna, "percent", 0.5f, 0.0f, 1.0f, "Percent", "Percentage of metaelems to select randomly", 0.0001f, 1.0f); @@ -236,22 +236,22 @@ void MBALL_OT_select_random_metaelems(struct wmOperatorType *ot) /* Duplicate selected MetaElements */ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb = (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *newml; - ml= mb->editelems->last; + ml = mb->editelems->last; if (ml) { while (ml) { if (ml->flag & SELECT) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(mb->editelems, newml); - mb->lastelem= newml; + mb->lastelem = newml; ml->flag &= ~SELECT; } - ml= ml->prev; + ml = ml->prev; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -260,7 +260,7 @@ static int duplicate_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) static int duplicate_metaelems_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - int retv= duplicate_metaelems_exec(C, op); + int retv = duplicate_metaelems_exec(C, op); if (retv == OPERATOR_FINISHED) { RNA_enum_set(op->ptr, "mode", TFM_TRANSLATION); @@ -284,7 +284,7 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -295,22 +295,22 @@ void MBALL_OT_duplicate_metaelems(wmOperatorType *ot) /* Delete all selected MetaElems (not MetaBall) */ static int delete_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml, *next; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { - next= ml->next; + next = ml->next; if (ml->flag & SELECT) { - if (mb->lastelem==ml) mb->lastelem= NULL; + if (mb->lastelem == ml) mb->lastelem = NULL; BLI_remlink(mb->editelems, ml); MEM_freeN(ml); } - ml= next; + ml = next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -329,7 +329,7 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /***************************** Hide operator *****************************/ @@ -337,20 +337,20 @@ void MBALL_OT_delete_metaelems(wmOperatorType *ot) /* Hide selected MetaElems */ static int hide_metaelems_exec(bContext *C, wmOperator *op) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - const int invert= RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; + const int invert = RNA_boolean_get(op->ptr, "unselected") ? SELECT : 0; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { if ((ml->flag & SELECT) != invert) ml->flag |= MB_HIDE; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -369,7 +369,7 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected"); @@ -380,18 +380,18 @@ void MBALL_OT_hide_metaelems(wmOperatorType *ot) /* Unhide all edited MetaElems */ static int reveal_metaelems_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *obedit= CTX_data_edit_object(C); - MetaBall *mb= (MetaBall*)obedit->data; + Object *obedit = CTX_data_edit_object(C); + MetaBall *mb = (MetaBall *)obedit->data; MetaElem *ml; - ml= mb->editelems->first; + ml = mb->editelems->first; if (ml) { while (ml) { ml->flag &= ~MB_HIDE; - ml= ml->next; + ml = ml->next; } - WM_event_add_notifier(C, NC_GEOM|ND_DATA, mb); + WM_event_add_notifier(C, NC_GEOM | ND_DATA, mb); DAG_id_tag_update(obedit->data, 0); } @@ -410,69 +410,69 @@ void MBALL_OT_reveal_metaelems(wmOperatorType *ot) ot->poll = ED_operator_editmball; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Select MetaElement with mouse click (user can select radius circle or * stiffness circle) */ int mouse_mball(bContext *C, const int mval[2], int extend) { - static MetaElem *startelem=NULL; - Object *obedit= CTX_data_edit_object(C); + static MetaElem *startelem = NULL; + Object *obedit = CTX_data_edit_object(C); ViewContext vc; - MetaBall *mb = (MetaBall*)obedit->data; - MetaElem *ml, *act=NULL; + MetaBall *mb = (MetaBall *)obedit->data; + MetaElem *ml, *act = NULL; int a, hits; - unsigned int buffer[4*MAXPICKBUF]; + unsigned int buffer[4 * MAXPICKBUF]; rcti rect; view3d_set_viewcontext(C, &vc); - rect.xmin = mval[0]-12; - rect.xmax = mval[0]+12; - rect.ymin = mval[1]-12; - rect.ymax = mval[1]+12; + rect.xmin = mval[0] - 12; + rect.xmax = mval[0] + 12; + rect.ymin = mval[1] - 12; + rect.ymax = mval[1] + 12; - hits= view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); + hits = view3d_opengl_select(&vc, buffer, MAXPICKBUF, &rect); /* does startelem exist? */ - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { - if (ml==startelem) break; - ml= ml->next; + if (ml == startelem) break; + ml = ml->next; } - if (ml==NULL) startelem= mb->editelems->first; + if (ml == NULL) startelem = mb->editelems->first; - if (hits>0) { - ml= startelem; + if (hits > 0) { + ml = startelem; while (ml) { - for (a=0; aselcol1==buffer[ 4 * a + 3 ]) { + if (ml->selcol1 == buffer[4 * a + 3]) { ml->flag |= MB_SCALE_RAD; - act= ml; + act = ml; } - if (ml->selcol2==buffer[ 4 * a + 3 ]) { + if (ml->selcol2 == buffer[4 * a + 3]) { ml->flag &= ~MB_SCALE_RAD; - act= ml; + act = ml; } } if (act) break; - ml= ml->next; - if (ml==NULL) ml= mb->editelems->first; - if (ml==startelem) break; + ml = ml->next; + if (ml == NULL) ml = mb->editelems->first; + if (ml == startelem) break; } /* When some metaelem was found, then it is necessary to select or * deselect it. */ if (act) { - if (extend==0) { + if (extend == 0) { /* Deselect all existing metaelems */ - ml= mb->editelems->first; + ml = mb->editelems->first; while (ml) { ml->flag &= ~SELECT; - ml= ml->next; + ml = ml->next; } /* Select only metaelem clicked on */ act->flag |= SELECT; @@ -483,9 +483,9 @@ int mouse_mball(bContext *C, const int mval[2], int extend) else act->flag |= SELECT; } - mb->lastelem= act; + mb->lastelem = act; - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, mb); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, mb); return 1; } @@ -502,54 +502,54 @@ static void freeMetaElemlist(ListBase *lb) { MetaElem *ml, *next; - if (lb==NULL) return; + if (lb == NULL) return; - ml= lb->first; + ml = lb->first; while (ml) { - next= ml->next; + next = ml->next; BLI_remlink(lb, ml); MEM_freeN(ml); - ml= next; + ml = next; } - lb->first= lb->last= NULL; + lb->first = lb->last = NULL; } static void undoMball_to_editMball(void *lbu, void *lbe, void *UNUSED(obe)) { - ListBase *lb= lbu; - ListBase *editelems= lbe; + ListBase *lb = lbu; + ListBase *editelems = lbe; MetaElem *ml, *newml; freeMetaElemlist(editelems); /* copy 'undo' MetaElems to 'edit' MetaElems */ - ml= lb->first; + ml = lb->first; while (ml) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(editelems, newml); - ml= ml->next; + ml = ml->next; } } static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) { - ListBase *editelems= lbe; + ListBase *editelems = lbe; ListBase *lb; MetaElem *ml, *newml; /* allocate memory for undo ListBase */ - lb= MEM_callocN(sizeof(ListBase), "listbase undo"); - lb->first= lb->last= NULL; + lb = MEM_callocN(sizeof(ListBase), "listbase undo"); + lb->first = lb->last = NULL; /* copy contents of current ListBase to the undo ListBase */ - ml= editelems->first; + ml = editelems->first; while (ml) { - newml= MEM_dupallocN(ml); + newml = MEM_dupallocN(ml); BLI_addtail(lb, newml); - ml= ml->next; + ml = ml->next; } return lb; @@ -558,7 +558,7 @@ static void *editMball_to_undoMball(void *lbe, void *UNUSED(obe)) /* free undo ListBase of MetaElems */ static void free_undoMball(void *lbv) { - ListBase *lb= lbv; + ListBase *lb = lbv; freeMetaElemlist(lb); MEM_freeN(lb); @@ -566,8 +566,8 @@ static void free_undoMball(void *lbv) static ListBase *metaball_get_editelems(Object *ob) { - if (ob && ob->type==OB_MBALL) { - struct MetaBall *mb= (struct MetaBall*)ob->data; + if (ob && ob->type == OB_MBALL) { + struct MetaBall *mb = (struct MetaBall *)ob->data; return mb->editelems; } return NULL; @@ -576,7 +576,7 @@ static ListBase *metaball_get_editelems(Object *ob) static void *get_data(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); return metaball_get_editelems(obedit); } diff --git a/source/blender/editors/metaball/mball_ops.c b/source/blender/editors/metaball/mball_ops.c index 5d019cc49d9..1c77eba2019 100644 --- a/source/blender/editors/metaball/mball_ops.c +++ b/source/blender/editors/metaball/mball_ops.c @@ -75,9 +75,9 @@ void ED_keymap_metaball(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MBALL_OT_duplicate_metaelems", DKEY, KM_PRESS, KM_SHIFT, 0); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", AKEY, KM_PRESS, 0, 0); - RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); + RNA_enum_set(kmi->ptr, "action", SEL_TOGGLE); kmi = WM_keymap_add_item(keymap, "MBALL_OT_select_all", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_enum_set(kmi->ptr, "action", SEL_INVERT); + RNA_enum_set(kmi->ptr, "action", SEL_INVERT); ED_object_generic_keymap(keyconf, keymap, 3); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index d030e61952e..466338a736f 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -147,7 +147,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *r if (rot) copy_v3_v3(ob->rot, rot); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); } /* uses context to figure out transform for primitive */ @@ -325,7 +325,7 @@ Object *ED_object_add_type(bContext *C, int type, float *loc, float *rot, ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); /* freedata, and undo */ /* deselects all, sets scene->basact */ - ob = add_object(scene, type); + ob = BKE_object_add(scene, type); BASACT->lay = ob->lay = layer; /* editor level activate, notifiers */ ED_base_object_activate(C, BASACT); @@ -733,7 +733,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) rename_id(&ob->id, get_lamp_defname(type)); rename_id(&la->id, get_lamp_defname(type)); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &la->id); la->use_nodes = 1; } @@ -891,7 +891,7 @@ void ED_base_object_free_and_unlink(Main *bmain, Scene *scene, Base *base) { DAG_id_type_tag(bmain, ID_OB); BLI_remlink(&scene->base, base); - free_libblock_us(&bmain->object, base->object); + BKE_libblock_free_us(&bmain->object, base->object); if (scene->basact == base) scene->basact = NULL; MEM_freeN(base); } @@ -923,7 +923,7 @@ static int object_delete_exec(bContext *C, wmOperator *op) for (scene_iter = bmain->scene.first; scene_iter; scene_iter = scene_iter->id.next) { if (scene_iter != scene && !(scene_iter->id.lib)) { - base_other = object_in_scene(base->object, scene_iter); + base_other = BKE_scene_base_find(scene_iter, base->object); if (base_other) { ED_base_object_free_and_unlink(bmain, scene_iter, base_other); } @@ -975,7 +975,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) /* XXX check object pointers */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - object_relink(ob); + BKE_object_relink(ob); } CTX_DATA_END; @@ -993,7 +993,7 @@ static void copy_object_set_idnew(bContext *C, int dupflag) id = (ID *)ma->mtex[a]->tex; if (id) { ID_NEW_US(ma->mtex[a]->tex) - else ma->mtex[a]->tex = copy_texture(ma->mtex[a]->tex); + else ma->mtex[a]->tex = BKE_texture_copy(ma->mtex[a]->tex); id->us--; } } @@ -1073,7 +1073,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, for (dob = lb->first; dob; dob = dob->next) { Base *basen; - Object *ob = copy_object(dob->ob); + Object *ob = BKE_object_copy(dob->ob); /* font duplis can have a totcol without material, we get them from parent * should be implemented better... */ @@ -1097,7 +1097,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, ob->lay = base->lay; copy_m4_m4(ob->obmat, dob->mat); - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); if (dupli_gh) BLI_ghash_insert(dupli_gh, dob, ob); @@ -1143,7 +1143,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* note, this may be the parent of other objects, but it should * still work out ok */ - object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + BKE_object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); /* to set ob_dst->orig and in case theres any other discrepicies */ DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); @@ -1162,7 +1162,7 @@ static void make_object_duplilist_real(bContext *C, Scene *scene, Base *base, /* similer to the code above, see comments */ invert_m4_m4(ob_dst->parentinv, dob->mat); - object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); + BKE_object_apply_mat4(ob_dst, dob->mat, FALSE, TRUE); DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB); @@ -1239,12 +1239,12 @@ static EnumPropertyItem convert_target_items[] = { static void curvetomesh(Scene *scene, Object *ob) { if (ob->disp.first == NULL) - makeDispListCurveTypes(scene, ob, 0); /* force creation */ + BKE_displist_make_curveTypes(scene, ob, 0); /* force creation */ - nurbs_to_mesh(ob); /* also does users */ + BKE_mesh_from_nurbs(ob); /* also does users */ if (ob->type == OB_MESH) - object_free_modifiers(ob); + BKE_object_free_modifiers(ob); } static int convert_poll(bContext *C) @@ -1265,7 +1265,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) ob = base->object; } - obn = copy_object(ob); + obn = BKE_object_copy(ob); obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; basen = MEM_mallocN(sizeof(Base), "duplibase"); @@ -1325,7 +1325,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* When 2 objects with linked data are selected, converting both * would keep modifiers on all but the converted object [#26003] */ if (ob->type == OB_MESH) { - object_free_modifiers(ob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(ob); /* after derivedmesh calls! */ } } } @@ -1341,16 +1341,16 @@ static int convert_exec(bContext *C, wmOperator *op) me->id.us--; /* make a new copy of the mesh */ - newob->data = copy_mesh(me); + newob->data = BKE_mesh_copy(me); } else { newob = ob; } - mesh_to_curve(scene, newob); + BKE_mesh_from_curve(scene, newob); if (newob->type == OB_CURVE) - object_free_modifiers(newob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_MESH && ob->modifiers.first) { /* converting a mesh with no modifiers causes a segfault */ ob->flag |= OB_DONE; @@ -1364,7 +1364,7 @@ static int convert_exec(bContext *C, wmOperator *op) me->id.us--; /* make a new copy of the mesh */ - newob->data = copy_mesh(me); + newob->data = BKE_mesh_copy(me); } else { newob = ob; @@ -1383,7 +1383,7 @@ static int convert_exec(bContext *C, wmOperator *op) /* re-tessellation is called by DM_to_mesh */ dm->release(dm); - object_free_modifiers(newob); /* after derivedmesh calls! */ + BKE_object_free_modifiers(newob); /* after derivedmesh calls! */ } else if (ob->type == OB_FONT) { ob->flag |= OB_DONE; @@ -1405,7 +1405,7 @@ static int convert_exec(bContext *C, wmOperator *op) cu = newob->data; if (!newob->disp.first) - makeDispListCurveTypes(scene, newob, 0); + BKE_displist_make_curveTypes(scene, newob, 0); newob->type = OB_CURVE; cu->type = OB_CURVE; @@ -1446,7 +1446,7 @@ static int convert_exec(bContext *C, wmOperator *op) curvetomesh(scene, newob); /* meshes doesn't use displist */ - freedisplist(&newob->disp); + BKE_displist_free(&newob->disp); } } else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { @@ -1467,7 +1467,7 @@ static int convert_exec(bContext *C, wmOperator *op) newob = ob; /* meshes doesn't use displist */ - freedisplist(&newob->disp); + BKE_displist_free(&newob->disp); } curvetomesh(scene, newob); @@ -1479,7 +1479,7 @@ static int convert_exec(bContext *C, wmOperator *op) base->flag &= ~SELECT; ob->flag &= ~SELECT; - baseob = BKE_metaball_basis_find(scene, ob); + baseob = BKE_mball_basis_find(scene, ob); if (ob != baseob) { /* if motherball is converting it would be marked as done later */ @@ -1487,7 +1487,7 @@ static int convert_exec(bContext *C, wmOperator *op) } if (!baseob->disp.first) { - makeDispListMBall(scene, baseob); + BKE_displist_make_mball(scene, baseob); } if (!(baseob->flag & OB_DONE)) { @@ -1499,7 +1499,7 @@ static int convert_exec(bContext *C, wmOperator *op) mb = newob->data; mb->id.us--; - newob->data = add_mesh("Mesh"); + newob->data = BKE_mesh_add("Mesh"); newob->type = OB_MESH; me = newob->data; @@ -1509,7 +1509,7 @@ static int convert_exec(bContext *C, wmOperator *op) for (a = 0; a < newob->totcol; a++) id_us_plus((ID *)me->mat[a]); } - mball_to_mesh(&baseob->disp, newob->data); + BKE_mesh_from_metaball(&baseob->disp, newob->data); if (obact->type == OB_MBALL) { basact = basen; @@ -1631,7 +1631,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base ; /* nothing? */ } else { - obn = copy_object(ob); + obn = BKE_object_copy(ob); obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; basen = MEM_mallocN(sizeof(Base), "duplibase"); @@ -1657,7 +1657,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *)obn->mat[a]; if (id) { ID_NEW_US(obn->mat[a]) - else obn->mat[a] = copy_material(obn->mat[a]); + else obn->mat[a] = BKE_material_copy(obn->mat[a]); id->us--; if (dupflag & USER_DUP_ACT) { @@ -1672,7 +1672,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *) psys->part; if (id) { ID_NEW_US(psys->part) - else psys->part = psys_copy_settings(psys->part); + else psys->part = BKE_particlesettings_copy(psys->part); if (dupflag & USER_DUP_ACT) { BKE_copy_animdata_id_action(&psys->part->id); @@ -1691,7 +1691,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_MESH) { ID_NEW_US2(obn->data) else { - obn->data = copy_mesh(obn->data); + obn->data = BKE_mesh_copy(obn->data); if (obn->fluidsimSettings) { obn->fluidsimSettings->orgMesh = (Mesh *)obn->data; @@ -1736,7 +1736,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_MBALL) { ID_NEW_US2(obn->data) else { - obn->data = BKE_metaball_copy(obn->data); + obn->data = BKE_mball_copy(obn->data); didit = 1; } id->us--; @@ -1746,7 +1746,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_LAMP) { ID_NEW_US2(obn->data) else { - obn->data = copy_lamp(obn->data); + obn->data = BKE_lamp_copy(obn->data); didit = 1; } id->us--; @@ -1760,8 +1760,8 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag & USER_DUP_ARM) { ID_NEW_US2(obn->data) else { - obn->data = copy_armature(obn->data); - armature_rebuild_pose(obn, obn->data); + obn->data = BKE_armature_copy(obn->data); + BKE_pose_rebuild(obn, obn->data); didit = 1; } id->us--; @@ -1773,7 +1773,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_lattice(obn->data); + obn->data = BKE_lattice_copy(obn->data); didit = 1; } id->us--; @@ -1793,7 +1793,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base if (dupflag != 0) { ID_NEW_US2(obn->data) else { - obn->data = copy_speaker(obn->data); + obn->data = BKE_speaker_copy(obn->data); didit = 1; } id->us--; @@ -1832,7 +1832,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base id = (ID *)(*matarar)[a]; if (id) { ID_NEW_US((*matarar)[a]) - else (*matarar)[a] = copy_material((*matarar)[a]); + else (*matarar)[a] = BKE_material_copy((*matarar)[a]); id->us--; } @@ -1863,7 +1863,7 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag ob = basen->object; /* link own references to the newly duplicated data [#26816] */ - object_relink(ob); + BKE_object_relink(ob); set_sca_new_poins_ob(ob); DAG_scene_sort(bmain, scene); @@ -1954,7 +1954,7 @@ static int add_named_exec(bContext *C, wmOperator *op) /* find object, create fake base */ RNA_string_get(op->ptr, "name", name); - ob = (Object *)find_id("OB", name); + ob = (Object *)BKE_libblock_find_name(ID_OB, name); if (ob == NULL) return OPERATOR_CANCELLED; @@ -2033,7 +2033,7 @@ static int join_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if (object_data_is_libdata(ob)) { + else if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } @@ -2086,7 +2086,7 @@ static int join_shapes_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_ERROR, "This data does not support joining in editmode"); return OPERATOR_CANCELLED; } - else if (object_data_is_libdata(ob)) { + else if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 593a5b6f1fe..cea9a0aae6b 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -49,6 +49,7 @@ #include "BLI_math_geom.h" #include "BKE_blender.h" +#include "BKE_ccg.h" #include "BKE_screen.h" #include "BKE_context.h" #include "BKE_global.h" @@ -475,32 +476,32 @@ static void interp_barycentric_tri_data(float data[3][3], float u, float v, floa /* mode = 0: interpolate normals, * mode = 1: interpolate coord */ -static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, float crn_y, int mode, float res[3]) +static void interp_bilinear_grid(CCGKey *key, CCGElem *grid, float crn_x, float crn_y, int mode, float res[3]) { int x0, x1, y0, y1; float u, v; float data[4][3]; x0 = (int) crn_x; - x1 = x0 >= (grid_size - 1) ? (grid_size - 1) : (x0 + 1); + x1 = x0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (x0 + 1); y0 = (int) crn_y; - y1 = y0 >= (grid_size - 1) ? (grid_size - 1) : (y0 + 1); + y1 = y0 >= (key->grid_size - 1) ? (key->grid_size - 1) : (y0 + 1); u = crn_x - x0; v = crn_y - y0; if (mode == 0) { - copy_v3_v3(data[0], grid[y0 * grid_size + x0].no); - copy_v3_v3(data[1], grid[y0 * grid_size + x1].no); - copy_v3_v3(data[2], grid[y1 * grid_size + x1].no); - copy_v3_v3(data[3], grid[y1 * grid_size + x0].no); + copy_v3_v3(data[0], CCG_grid_elem_no(key, grid, x0, y0)); + copy_v3_v3(data[1], CCG_grid_elem_no(key, grid, x1, y0)); + copy_v3_v3(data[2], CCG_grid_elem_no(key, grid, x1, y1)); + copy_v3_v3(data[3], CCG_grid_elem_no(key, grid, x0, y1)); } else { - copy_v3_v3(data[0], grid[y0 * grid_size + x0].co); - copy_v3_v3(data[1], grid[y0 * grid_size + x1].co); - copy_v3_v3(data[2], grid[y1 * grid_size + x1].co); - copy_v3_v3(data[3], grid[y1 * grid_size + x0].co); + copy_v3_v3(data[0], CCG_grid_elem_co(key, grid, x0, y0)); + copy_v3_v3(data[1], CCG_grid_elem_co(key, grid, x1, y0)); + copy_v3_v3(data[2], CCG_grid_elem_co(key, grid, x1, y1)); + copy_v3_v3(data[3], CCG_grid_elem_co(key, grid, x0, y1)); } interp_bilinear_quad_data(data, u, v, res); @@ -509,7 +510,8 @@ static void interp_bilinear_grid(DMGridData *grid, int grid_size, float crn_x, f static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *origindex, const int lvl, const int face_index, const float u, const float v, float co[3], float n[3]) { MFace mface; - DMGridData **grid_data; + CCGElem **grid_data; + CCGKey key; float crn_x, crn_y; int grid_size, S, face_side; int *grid_offset, g_index; @@ -519,6 +521,7 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig grid_size = hidm->getGridSize(hidm); grid_data = hidm->getGridData(hidm); grid_offset = hidm->getGridOffset(hidm); + hidm->getGridKey(hidm, &key); face_side = (grid_size << 1) - 1; @@ -546,10 +549,10 @@ static void get_ccgdm_data(DerivedMesh *lodm, DerivedMesh *hidm, const int *orig CLAMP(crn_y, 0.0f, grid_size); if (n != NULL) - interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 0, n); + interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 0, n); if (co != NULL) - interp_bilinear_grid(grid_data[g_index + S], grid_size, crn_x, crn_y, 1, co); + interp_bilinear_grid(&key, grid_data[g_index + S], crn_x, crn_y, 1, co); } /* mode = 0: interpolate normals, @@ -619,7 +622,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima) if (bkr->simple) smd.subdivType = ME_SIMPLE_SUBSURF; - height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0); + height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0); } height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX); @@ -1020,7 +1023,8 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = *lvl; tmp_mmd.sculptlvl = *lvl; - dm = multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, + MULTIRES_USE_LOCAL_MMD); cddm->release(cddm); } @@ -1040,7 +1044,8 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; - dm = multires_dm_create_from_derived(&tmp_mmd, 1, cddm, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, + MULTIRES_USE_LOCAL_MMD); cddm->release(cddm); return dm; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index e63e0e34934..d73b53deecc 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -89,7 +89,7 @@ ListBase *get_active_constraints(Object *ob) if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (pchan) return &pchan->constraints; } @@ -309,23 +309,23 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) * the constraint is deemed invalid */ /* default IK check ... */ - if (exist_object(data->tar) == 0) { + if (BKE_object_exists_check(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { - if (!get_named_bone(get_armature(owner), data->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->subtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } if (data->poletar) { - if (exist_object(data->poletar) == 0) { + if (BKE_object_exists_check(data->poletar) == 0) { data->poletar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (data->poletar == owner) { - if (!get_named_bone(get_armature(owner), data->polesubtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->polesubtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -339,12 +339,12 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) bPivotConstraint *data = curcon->data; /* target doesn't have to exist, but if it is non-null, it must exist! */ - if (data->tar && exist_object(data->tar) == 0) { + if (data->tar && BKE_object_exists_check(data->tar) == 0) { data->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (data->tar == owner) { - if (!get_named_bone(get_armature(owner), data->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), data->subtarget)) { curcon->flag |= CONSTRAINT_DISABLE; } } @@ -446,14 +446,14 @@ static void test_constraints(Object *owner, bPoseChannel *pchan) /* disable and clear constraints targets that are incorrect */ for (ct = targets.first; ct; ct = ct->next) { /* general validity checks (for those constraints that need this) */ - if (exist_object(ct->tar) == 0) { + if (BKE_object_exists_check(ct->tar) == 0) { /* object doesn't exist, but constraint requires target */ ct->tar = NULL; curcon->flag |= CONSTRAINT_DISABLE; } else if (ct->tar == owner) { if (type == CONSTRAINT_OBTYPE_BONE) { - if (!get_named_bone(get_armature(owner), ct->subtarget)) { + if (!BKE_armature_find_bone_name(BKE_armature_from_object(owner), ct->subtarget)) { /* bone must exist in armature... */ // TODO: clear subtarget? curcon->flag |= CONSTRAINT_DISABLE; @@ -585,7 +585,7 @@ static bConstraint *edit_constraint_property_get(wmOperator *op, Object *ob, int list = &ob->constraints; } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - bPoseChannel *pchan = get_active_posechannel(ob); + bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) list = &pchan->constraints; else { @@ -713,7 +713,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, /* try to find a pose channel - assume that this is the constraint owner */ // TODO: get from context instead? if (ob && ob->pose) - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); /* calculate/set inverse matrix: * We just calculate all transform-stack eval up to but not including this constraint. @@ -729,7 +729,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, * to use as baseline ("pmat") to derive delta from. This extra calc saves users * from having pressing "Clear Inverse" first */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); copy_m4_m4(pmat, pchan->pose_mat); /* 2. knock out constraints starting from this one */ @@ -746,7 +746,7 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, } /* 3. solve pose without disabled constraints */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); /* 4. determine effect of constraint by removing the newly calculated * pchan->pose_mat from the original pchan->pose_mat, thus determining @@ -769,13 +769,13 @@ static void child_get_inverse_matrix(Scene *scene, Object *ob, bConstraint *con, } /* 6. recalculate pose with new inv-mat applied */ - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); } else if (ob) { Object workob; - /* use what_does_parent to find inverse - just like for normal parenting */ - what_does_parent(scene, ob, &workob); + /* use BKE_object_workob_calc_parent to find inverse - just like for normal parenting */ + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(invmat, workob.obmat); } } @@ -977,7 +977,7 @@ void ED_object_constraint_set_active(Object *ob, bConstraint *con) void ED_object_constraint_update(Object *ob) { - if (ob->pose) update_pose_constraint_flags(ob->pose); + if (ob->pose) BKE_pose_update_constraint_flags(ob->pose); object_test_constraints(ob); @@ -1147,7 +1147,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* free constraints for all selected bones */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) @@ -1253,7 +1253,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) void POSE_OT_constraints_copy(wmOperatorType *ot) { /* identifiers */ - ot->name = "Copy Constraints to Selected"; + ot->name = "Copy Constraints to Selected Bones"; ot->idname = "POSE_OT_constraints_copy"; ot->description = "Copy constraints to other selected bones"; @@ -1294,7 +1294,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) void OBJECT_OT_constraints_copy(wmOperatorType *ot) { /* identifiers */ - ot->name = "Copy Constraints to Selected"; + ot->name = "Copy Constraints to Selected Objects"; ot->idname = "OBJECT_OT_constraints_copy"; ot->description = "Copy constraints to other selected objects"; @@ -1312,7 +1312,7 @@ void OBJECT_OT_constraints_copy(wmOperatorType *ot) static short get_new_constraint_target(bContext *C, int con_type, Object **tar_ob, bPoseChannel **tar_pchan, short add) { Object *obact = ED_object_active_context(C); - bPoseChannel *pchanact = get_active_posechannel(obact); + bPoseChannel *pchanact = BKE_pose_channel_active(obact); short only_curve = 0, only_mesh = 0, only_ob = 0; short found = 0; @@ -1413,7 +1413,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o Object *obt; /* add new target object */ - obt = add_object(scene, OB_EMPTY); + obt = BKE_object_add(scene, OB_EMPTY); /* set layers OK */ newbase = BASACT; @@ -1434,7 +1434,7 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o copy_v3_v3(obt->loc, obact->obmat[3]); } - /* restore, add_object sets active */ + /* restore, BKE_object_add sets active */ BASACT = base; base->flag |= SELECT; @@ -1459,7 +1459,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase pchan = NULL; } else { - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); /* ensure not to confuse object/pose adding */ if (pchan == NULL) { @@ -1541,7 +1541,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase object_test_constraints(ob); if (pchan) - update_pose_constraint_flags(ob->pose); + BKE_pose_update_constraint_flags(ob->pose); /* force depsgraph to get recalculated since new relationships added */ @@ -1586,7 +1586,7 @@ static int object_constraint_add_exec(bContext *C, wmOperator *op) /* dummy operator callback */ static int pose_constraint_add_exec(bContext *C, wmOperator *op) { - Object *ob = object_pose_armature_get(ED_object_active_context(C)); + Object *ob = BKE_object_pose_armature_get(ED_object_active_context(C)); int type = RNA_enum_get(op->ptr, "type"); short with_targets = 0; @@ -1689,8 +1689,8 @@ void POSE_OT_constraint_add_with_targets(wmOperatorType *ot) /* present menu with options + validation for targets to use */ static int pose_ik_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(evt)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); - bPoseChannel *pchan = get_active_posechannel(ob); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); + bPoseChannel *pchan = BKE_pose_channel_active(ob); bConstraint *con = NULL; uiPopupMenu *pup; @@ -1773,7 +1773,7 @@ void POSE_OT_ik_add(wmOperatorType *ot) /* remove IK constraints from selected bones */ static int pose_ik_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Object *ob = object_pose_armature_get(CTX_data_active_object(C)); + Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* only remove IK Constraints */ CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index c669bbfe3b2..c97ad9c62f9 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -427,7 +427,7 @@ void ED_object_enter_editmode(bContext *C, int flag) ob = base->object; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { error_libdata(); return; } @@ -465,11 +465,11 @@ void ED_object_enter_editmode(bContext *C, int flag) bArmature *arm = base->object->data; if (!arm) return; /* - * The function object_data_is_libdata make a problem here, the + * The function BKE_object_obdata_is_libdata make a problem here, the * check for ob->proxy return 0 and let blender enter to edit mode * this causes a crash when you try leave the edit mode. * The problem is that i can't remove the ob->proxy check from - * object_data_is_libdata that prevent the bugfix #6614, so + * BKE_object_obdata_is_libdata that prevent the bugfix #6614, so * i add this little hack here. */ if (arm->id.lib) { @@ -749,10 +749,10 @@ static void copy_texture_space(Object *to, Object *ob) /* pass */ } else if (to->type == OB_MBALL) { - BKE_metaball_tex_space_calc(to); + BKE_mball_texspace_calc(to); } else { - BKE_curve_tex_space_calc(to->data); + BKE_curve_texspace_calc(to->data); } } @@ -783,7 +783,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) return; } else if (event == 24) { - /* moved to object_link_modifiers */ + /* moved to BKE_object_link_modifiers */ /* copymenu_modifiers(bmain, scene, v3d, ob); */ return; } @@ -885,7 +885,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->vfontbi = cu->vfontbi; id_us_plus((ID *)cu1->vfontbi); - BKE_text_to_curve(bmain, scene, base->object, 0); /* needed? */ + BKE_vfont_to_curve(bmain, scene, base->object, 0); /* needed? */ BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); @@ -1125,6 +1125,7 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene) BLI_freelistN(&targets); } + /* show popup to determine settings */ static int object_calculate_paths_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { @@ -1200,6 +1201,39 @@ void OBJECT_OT_paths_calculate(wmOperatorType *ot) /* --------- */ +static int object_update_paths_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + + if (scene == NULL) + return OPERATOR_CANCELLED; + + /* calculate the paths for objects that have them (and are tagged to get refreshed) */ + ED_objects_recalculate_paths(C, scene); + + /* notifiers for updates */ + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_paths_update(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Update Object Paths"; + ot->idname = "OBJECT_OT_paths_update"; + ot->description = "Recalculate paths for selected objects"; + + /* api callbakcs */ + ot->exec = object_update_paths_exec; + ot->poll = ED_operator_object_active_editable; /* TODO: this should probably check for existing paths */ + + /* flags */ + ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; +} + +/* --------- */ + /* Clear motion paths for selected objects only */ void ED_objects_clear_paths(bContext *C) { @@ -1256,7 +1290,7 @@ static int shade_smooth_exec(bContext *C, wmOperator *op) { if (ob->type == OB_MESH) { - mesh_set_smooth_flag(ob, !clear); + BKE_mesh_smooth_flag_set(ob, !clear); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -1350,7 +1384,7 @@ static void UNUSED_FUNCTION(image_aspect) (Scene * scene, View3D * v3d) space = 1.0; if (ob->type == OB_MESH) { float size[3]; - mesh_get_texspace(ob->data, NULL, NULL, size); + BKE_mesh_texspace_get(ob->data, NULL, NULL, size); space = size[0] / size[1]; } else if (ELEM3(ob->type, OB_CURVE, OB_FONT, OB_SURF)) { @@ -1402,7 +1436,7 @@ static EnumPropertyItem *object_mode_set_itemsf(bContext *C, PointerRNA *UNUSED( { RNA_enum_item_add(&item, &totitem, input); } - ++input; + input++; } RNA_enum_item_end(&item, &totitem); @@ -1703,6 +1737,7 @@ void OBJECT_OT_game_property_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Game Property"; ot->idname = "OBJECT_OT_game_property_copy"; + ot->description = "Copy/merge/replace a game property from active object to all selected objects"; /* api callbacks */ ot->exec = game_property_copy_exec; @@ -1733,6 +1768,7 @@ void OBJECT_OT_game_property_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Game Property"; ot->idname = "OBJECT_OT_game_property_clear"; + ot->description = "Remove all game properties from all selected objects"; /* api callbacks */ ot->exec = game_property_clear_exec; diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index dd6c08a2247..b47591dddee 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -327,6 +327,7 @@ void OBJECT_OT_group_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Group"; ot->idname = "OBJECT_OT_group_remove"; + ot->description = "Remove the active object from this group"; /* api callbacks */ ot->exec = group_remove_exec; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 2cfefa61a18..e9341d90e86 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -417,13 +417,13 @@ static Object *add_hook_object_new(Scene *scene, Object *obedit) Base *base, *basedit; Object *ob; - ob = add_object(scene, OB_EMPTY); + ob = BKE_object_add(scene, OB_EMPTY); - basedit = object_in_scene(obedit, scene); - base = object_in_scene(ob, scene); + basedit = BKE_scene_base_find(scene, obedit); + base = BKE_scene_base_find(scene, ob); base->lay = ob->lay = obedit->lay; - /* icky, add_object sets new base as active. + /* icky, BKE_object_add sets new base as active. * so set it back to the original edit object */ scene->basact = basedit; @@ -469,7 +469,7 @@ static void add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *o /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m4_m4(ob->imat, ob->obmat); /* apparently this call goes from right to left... */ @@ -648,7 +648,7 @@ static int object_hook_reset_exec(bContext *C, wmOperator *op) /* reset functionality */ if (hmd->object) { - bPoseChannel *pchan = get_pose_channel(hmd->object->pose, hmd->subtarget); + bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); if (hmd->subtarget[0] && pchan) { float imat[4][4], mat[4][4]; diff --git a/source/blender/editors/object/object_intern.h b/source/blender/editors/object/object_intern.h index ee9d776ea3b..e834c93b0d8 100644 --- a/source/blender/editors/object/object_intern.h +++ b/source/blender/editors/object/object_intern.h @@ -84,6 +84,7 @@ void OBJECT_OT_proxy_make(struct wmOperatorType *ot); void OBJECT_OT_shade_smooth(struct wmOperatorType *ot); void OBJECT_OT_shade_flat(struct wmOperatorType *ot); void OBJECT_OT_paths_calculate(struct wmOperatorType *ot); +void OBJECT_OT_paths_update(struct wmOperatorType *ot); void OBJECT_OT_paths_clear(struct wmOperatorType *ot); void OBJECT_OT_forcefield_toggle(struct wmOperatorType *ot); diff --git a/source/blender/editors/object/object_lattice.c b/source/blender/editors/object/object_lattice.c index 648f530881a..7b37ca8ab95 100644 --- a/source/blender/editors/object/object_lattice.c +++ b/source/blender/editors/object/object_lattice.c @@ -271,12 +271,12 @@ static int make_regular_exec(bContext *C, wmOperator *UNUSED(op)) if (ob) { lt = ob->data; - resizelattice(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt->editlatt->latt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } else { ob = CTX_data_active_object(C); lt = ob->data; - resizelattice(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); + BKE_lattice_resize(lt, lt->pntsu, lt->pntsv, lt->pntsw, NULL); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 281ca7e59b6..191677989b9 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -76,6 +76,7 @@ #include "ED_armature.h" #include "ED_object.h" #include "ED_screen.h" +#include "ED_sculpt.h" #include "ED_mesh.h" #include "WM_api.h" @@ -147,9 +148,13 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc } else if (type == eModifierType_Surface) DAG_scene_sort(bmain, scene); - else if (type == eModifierType_Multires) + else if (type == eModifierType_Multires) { /* set totlvl from existing MDISPS layer if object already had it */ multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); + + /* ensure that grid paint mask layer is created */ + ED_sculpt_mask_layers_ensure(ob, (MultiresModifierData *)new_md); + } } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -368,7 +373,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * if (totvert == 0) return 0; /* add new mesh */ - obn = add_object(scene, OB_MESH); + obn = BKE_object_add(scene, OB_MESH); me = obn->data; me->totvert = totvert; @@ -545,7 +550,7 @@ static int modifier_apply_obdata(ReportList *reports, Scene *scene, Object *ob, BKE_report(reports, RPT_INFO, "Applied modifier only changed CV points, not tessellated/bevel vertices"); vertexCos = BKE_curve_vertexCos_get(cu, &cu->nurb, &numVerts); - mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); + mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0); BK_curve_vertexCos_apply(cu, &cu->nurb, vertexCos); MEM_freeN(vertexCos); @@ -610,6 +615,9 @@ int ED_object_modifier_apply(ReportList *reports, Scene *scene, Object *ob, Modi BLI_remlink(&ob->modifiers, md); modifier_free(md); + /* ensure mesh paint mask layer remains after applying */ + ED_sculpt_mask_layers_ensure(ob, NULL); + return 1; } @@ -661,7 +669,7 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *UNUSED(ptr) if (mti->flags & eModifierTypeFlag_NoUserAdd) continue; - if (!object_support_modifier_type(ob, md_item->value)) + if (!BKE_object_support_modifier_type_check(ob, md_item->value)) continue; } else { @@ -918,7 +926,8 @@ static int modifier_apply_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev static EnumPropertyItem modifier_apply_as_items[] = { {MODIFIER_APPLY_DATA, "DATA", 0, "Object Data", "Apply modifier to the object's data"}, {MODIFIER_APPLY_SHAPE, "SHAPE", 0, "New Shape", "Apply deform-only modifier to a new shape on this object"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; void OBJECT_OT_modifier_apply(wmOperatorType *ot) { @@ -1369,13 +1378,13 @@ static int meshdeform_bind_exec(bContext *C, wmOperator *op) dm->release(dm); } else if (ob->type == OB_LATTICE) { - lattice_calc_modifiers(scene, ob); + BKE_lattice_modifiers_calc(scene, ob); } else if (ob->type == OB_MBALL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { - makeDispListCurveTypes(scene, ob, 0); + BKE_displist_make_curveTypes(scene, ob, 0); } mmd->bindfunc = NULL; diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index 4cd18d91249..b7dc3fd7bea 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -77,6 +77,7 @@ void ED_operatortypes_object(void) WM_operatortype_append(OBJECT_OT_shade_smooth); WM_operatortype_append(OBJECT_OT_shade_flat); WM_operatortype_append(OBJECT_OT_paths_calculate); + WM_operatortype_append(OBJECT_OT_paths_update); WM_operatortype_append(OBJECT_OT_paths_clear); WM_operatortype_append(OBJECT_OT_forcefield_toggle); @@ -222,18 +223,18 @@ void ED_operatormacros_object(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move", "Duplicate Objects", + "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Duplicate selected objects and move them"; WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_enum_set(otmacro->ptr, "proportional", PROP_EDIT_OFF); } /* grr, should be able to pass options on... */ - ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_duplicate_move_linked", "Duplicate Linked", + "Duplicate selected objects and move them", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Duplicate selected objects and move them"; otmacro = WM_operatortype_macro_define(ot, "OBJECT_OT_duplicate"); RNA_boolean_set(otmacro->ptr, "linked", TRUE); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); @@ -241,9 +242,9 @@ void ED_operatormacros_object(void) } /* XXX */ - ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("OBJECT_OT_add_named_cursor", "Add Named At Cursor", + "Add named object at cursor", OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Add named object at cursor"; RNA_def_string(ot->srna, "name", "Cube", MAX_ID_NAME - 2, "Name", "Object name to add"); WM_operatortype_macro_define(ot, "VIEW3D_OT_cursor3d"); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 4678416e1c9..b3e16c8d4eb 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -235,7 +235,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) ob->par3 = v3 - 1; /* inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { @@ -243,7 +243,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) ob->par1 = v1 - 1; /* inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } } @@ -335,24 +335,24 @@ static int make_proxy_exec(bContext *C, wmOperator *op) char name[MAX_ID_NAME + 4]; /* Add new object for the proxy */ - newob = add_object(scene, OB_EMPTY); + newob = BKE_object_add(scene, OB_EMPTY); BLI_snprintf(name, sizeof(name), "%s_proxy", ((ID *)(gob ? gob : ob))->name + 2); rename_id(&newob->id, name); /* set layers OK */ - newbase = BASACT; /* add_object sets active... */ + newbase = BASACT; /* BKE_object_add sets active... */ newbase->lay = oldbase->lay; newob->lay = newbase->lay; - /* remove base, leave user count of object, it gets linked in object_make_proxy */ + /* remove base, leave user count of object, it gets linked in BKE_object_make_proxy */ if (gob == NULL) { BLI_remlink(&scene->base, oldbase); MEM_freeN(oldbase); } - object_make_proxy(newob, ob, gob); + BKE_object_make_proxy(newob, ob, gob); /* depsgraph flushes are needed for the new data */ DAG_scene_sort(bmain, scene); @@ -439,7 +439,7 @@ void ED_object_parent_clear(bContext *C, int type) } else if (type == 1) { ob->parent = NULL; - object_apply_mat4(ob, ob->obmat, TRUE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, FALSE); } else if (type == 2) unit_m4(ob->parentinv); @@ -533,7 +533,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object if ((cu->flag & CU_PATH) == 0) { cu->flag |= CU_PATH | CU_FOLLOW; - makeDispListCurveTypes(scene, par, 0); /* force creation of path data */ + BKE_displist_make_curveTypes(scene, par, 0); /* force creation of path data */ } else cu->flag |= CU_FOLLOW; @@ -554,7 +554,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } } else if (partype == PAR_BONE) { - pchan = get_active_posechannel(par); + pchan = BKE_pose_channel_active(par); if (pchan == NULL) { BKE_report(reports, RPT_ERROR, "No active Bone"); @@ -571,7 +571,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object Object workob; /* apply transformation of previous parenting */ - /* object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ + /* BKE_object_apply_mat4(ob, ob->obmat); */ /* removed because of bug [#23577] */ /* set the parent (except for follow-path constraint option) */ if (partype != PAR_PATH_CONST) { @@ -650,13 +650,13 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object } /* get corrected inverse */ ob->partype = PAROBJECT; - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } else { /* calculate inverse parent matrix */ - what_does_parent(scene, ob, &workob); + BKE_object_workob_calc_parent(scene, ob, &workob); invert_m4_m4(ob->parentinv, workob.obmat); } @@ -814,7 +814,7 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->parent) { if (ob->partype & PARSLOW) { ob->partype -= PARSLOW; - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); ob->partype |= PARSLOW; ob->recalc |= OB_RECALC_OB; } @@ -920,7 +920,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } if (type == 1) - object_apply_mat4(ob, ob->obmat, TRUE, TRUE); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, TRUE); } CTX_DATA_END; @@ -1217,7 +1217,7 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Base *, base, selected_bases) { - if (!object_in_scene(base->object, scene_to)) { + if (!BKE_scene_base_find(scene_to, base->object)) { Base *nbase = MEM_mallocN(sizeof(Base), "newbase"); *nbase = *base; BLI_addhead(&(scene_to->base), nbase); @@ -1313,7 +1313,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - object_link_modifiers(obt, ob); + BKE_object_link_modifiers(obt, ob); obt->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; break; } @@ -1401,7 +1401,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) if ( (base->flag & flag) == flag) { if (ob->id.lib == NULL && ob->id.us > 1) { /* base gets copy of object */ - obn = copy_object(ob); + obn = BKE_object_copy(ob); base->object = obn; ob->id.us--; } @@ -1413,7 +1413,7 @@ static void single_object_users(Scene *scene, View3D *v3d, int flag) /* object pointers */ for (base = FIRSTBASE; base; base = base->next) { - object_relink(base->object); + BKE_object_relink(base->object); } set_sca_new_poins(); @@ -1447,7 +1447,7 @@ static void new_id_matar(Material **matar, int totcol) id->us--; } else if (id->us > 1) { - matar[a] = copy_material(matar[a]); + matar[a] = BKE_material_copy(matar[a]); id->us--; id->newid = (ID *)matar[a]; } @@ -1478,7 +1478,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) switch (ob->type) { case OB_LAMP: - ob->data = la = copy_lamp(ob->data); + ob->data = la = BKE_lamp_copy(ob->data); for (a = 0; a < MAX_MTEX; a++) { if (la->mtex[a]) { ID_NEW(la->mtex[a]->object); @@ -1489,13 +1489,13 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ob->data = BKE_camera_copy(ob->data); break; case OB_MESH: - ob->data = copy_mesh(ob->data); + ob->data = BKE_mesh_copy(ob->data); //me= ob->data; //if (me && me->key) // ipo_idnew(me->key->ipo); /* drivers */ break; case OB_MBALL: - ob->data = BKE_metaball_copy(ob->data); + ob->data = BKE_mball_copy(ob->data); break; case OB_CURVE: case OB_SURF: @@ -1505,15 +1505,15 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ID_NEW(cu->taperobj); break; case OB_LATTICE: - ob->data = copy_lattice(ob->data); + ob->data = BKE_lattice_copy(ob->data); break; case OB_ARMATURE: ob->recalc |= OB_RECALC_DATA; - ob->data = copy_armature(ob->data); - armature_rebuild_pose(ob, ob->data); + ob->data = BKE_armature_copy(ob->data); + BKE_pose_rebuild(ob, ob->data); break; case OB_SPEAKER: - ob->data = copy_speaker(ob->data); + ob->data = BKE_speaker_copy(ob->data); break; default: if (G.debug & G_DEBUG) @@ -1568,7 +1568,7 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) /* do not test for LIB_NEW: this functions guaranteed delivers single_users! */ if (ma->id.us > 1) { - man = copy_material(ma); + man = BKE_material_copy(ma); BKE_copy_animdata_id_action(&man->id); man->id.us = 0; @@ -1579,7 +1579,7 @@ static void single_mat_users(Scene *scene, int flag, int do_textures) if (ma->mtex[b] && (tex = ma->mtex[b]->tex)) { if (tex->id.us > 1) { tex->id.us--; - tex = copy_texture(tex); + tex = BKE_texture_copy(tex); BKE_copy_animdata_id_action(&tex->id); man->mtex[b]->tex = tex; } @@ -1606,7 +1606,7 @@ static void do_single_tex_user(Tex **from) tex->id.us--; } else if (tex->id.us > 1) { - texn = copy_texture(tex); + texn = BKE_texture_copy(tex); BKE_copy_animdata_id_action(&texn->id); tex->id.newid = (ID *)texn; tex->id.us--; @@ -1911,7 +1911,7 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even char name[MAX_ID_NAME - 2]; RNA_string_get(op->ptr, "name", name); - ma = (Material *)find_id("MA", name); + ma = (Material *)BKE_libblock_find_name(ID_MA, name); if (base == NULL || ma == NULL) return OPERATOR_CANCELLED; diff --git a/source/blender/editors/object/object_select.c b/source/blender/editors/object/object_select.c index ed53e4a9b91..86823be09a4 100644 --- a/source/blender/editors/object/object_select.c +++ b/source/blender/editors/object/object_select.c @@ -416,7 +416,7 @@ static short select_grouped_parent(bContext *C) /* Makes parent active and de-se if (!basact || !(basact->object->parent)) return 0; /* we know OBACT is valid */ - baspar = object_in_scene(basact->object->parent, scene); + baspar = BKE_scene_base_find(scene, basact->object->parent); /* can be NULL if parent in other scene */ if (baspar && BASE_SELECTABLE(v3d, baspar)) { @@ -487,7 +487,7 @@ static short select_grouped_object_hooks(bContext *C, Object *ob) if (md->type == eModifierType_Hook) { hmd = (HookModifierData *) md; if (hmd->object && !(hmd->object->flag & SELECT)) { - base = object_in_scene(hmd->object, scene); + base = BKE_scene_base_find(scene, hmd->object); if (base && (BASE_SELECTABLE(v3d, base))) { ED_base_object_select(base, BA_SELECT); changed = 1; @@ -884,9 +884,9 @@ static int object_select_mirror_exec(bContext *C, wmOperator *op) flip_side_name(tmpname, primbase->object->id.name + 2, TRUE); if (strcmp(tmpname, primbase->object->id.name + 2) != 0) { /* names differ */ - Object *ob = (Object *)find_id("OB", tmpname); + Object *ob = (Object *)BKE_libblock_find_name(ID_OB, tmpname); if (ob) { - Base *secbase = object_in_scene(ob, scene); + Base *secbase = BKE_scene_base_find(scene, ob); if (secbase) { ED_base_object_select(secbase, BA_SELECT); diff --git a/source/blender/editors/object/object_shapekey.c b/source/blender/editors/object/object_shapekey.c index 5d31bfff99a..19864ed58cf 100644 --- a/source/blender/editors/object/object_shapekey.c +++ b/source/blender/editors/object/object_shapekey.c @@ -77,7 +77,7 @@ static void ED_object_shape_key_add(bContext *C, Scene *scene, Object *ob, int from_mix) { KeyBlock *kb; - if ((kb = object_insert_shape_key(scene, ob, NULL, from_mix))) { + if ((kb = BKE_object_insert_shape_key(scene, ob, NULL, from_mix))) { Key *key = ob_get_key(ob); /* for absolute shape keys, new keys may not be added last */ ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -141,7 +141,7 @@ static int ED_object_shape_key_remove(bContext *C, Object *ob) else if (GS(key->from->name) == ID_CU) ((Curve *)key->from)->key = NULL; else if (GS(key->from->name) == ID_LT) ((Lattice *)key->from)->key = NULL; - free_libblock_us(&(bmain->key), key); + BKE_libblock_free_us(&(bmain->key), key); } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); @@ -403,6 +403,7 @@ void OBJECT_OT_shape_key_mirror(wmOperatorType *ot) /* identifiers */ ot->name = "Mirror Shape Key"; ot->idname = "OBJECT_OT_shape_key_mirror"; + ot->description = "Mirror the current shape key along the local X axis"; /* api callbacks */ ot->poll = shape_key_mode_poll; @@ -474,6 +475,7 @@ void OBJECT_OT_shape_key_move(wmOperatorType *ot) /* identifiers */ ot->name = "Move Shape Key"; ot->idname = "OBJECT_OT_shape_key_move"; + ot->description = "Move the active shape key up/down in the list"; /* api callbacks */ ot->poll = shape_key_mode_poll; diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index b8a7ce999f1..34395163ad3 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -370,8 +370,8 @@ static void ignore_parent_tx(Main *bmain, Scene *scene, Object *ob) /* a change was made, adjust the children to compensate */ for (ob_child = bmain->object.first; ob_child; ob_child = ob_child->id.next) { if (ob_child->parent == ob) { - object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); - what_does_parent(scene, ob_child, &workob); + BKE_object_apply_mat4(ob_child, ob_child->obmat, TRUE, FALSE); + BKE_object_workob_calc_parent(scene, ob_child, &workob); invert_m4_m4(ob_child->parentinv, workob.obmat); } } @@ -434,17 +434,17 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo /* calculate rotation/scale matrix */ if (apply_scale && apply_rot) - object_to_mat3(ob, rsmat); + BKE_object_to_mat3(ob, rsmat); else if (apply_scale) - object_scale_to_mat3(ob, rsmat); + BKE_object_scale_to_mat3(ob, rsmat); else if (apply_rot) { float tmat[3][3], timat[3][3]; /* simple rotation matrix */ - object_rot_to_mat3(ob, rsmat); + BKE_object_rot_to_mat3(ob, rsmat); /* correct for scale, note mul_m3_m3m3 has swapped args! */ - object_scale_to_mat3(ob, tmat); + BKE_object_scale_to_mat3(ob, tmat); invert_m3_m3(timat, tmat); mul_m3_m3m3(rsmat, timat, rsmat); mul_m3_m3m3(rsmat, rsmat, tmat); @@ -460,7 +460,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo if (!(apply_scale && apply_rot)) { /* correct for scale and rotation that is still applied */ - object_to_mat3(ob, obmat); + BKE_object_to_mat3(ob, obmat); invert_m3_m3(iobmat, obmat); mul_m3_m3m3(tmat, rsmat, iobmat); mul_m3_v3(tmat, mat[3]); @@ -491,7 +491,7 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo } /* update normals */ - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); } else if (ob->type == OB_ARMATURE) { ED_armature_apply_transform(ob, mat); @@ -546,9 +546,9 @@ static int apply_objects_internal(bContext *C, ReportList *reports, int apply_lo unit_axis_angle(ob->rotAxis, &ob->rotAngle); } - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); @@ -573,9 +573,9 @@ static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { - where_is_object(scene, ob); - object_apply_mat4(ob, ob->obmat, TRUE, TRUE); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); + BKE_object_apply_mat4(ob, ob->obmat, TRUE, TRUE); + BKE_object_where_is_calc(scene, ob); /* update for any children that may get moved */ DAG_id_tag_update(&ob->id, OB_RECALC_OB); @@ -750,7 +750,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) else { /* only bounds support */ INIT_MINMAX(min, max); - minmax_object_duplis(scene, ob, min, max); + BKE_object_minmax_dupli(scene, ob, min, max); mid_v3_v3v3(cent, min, max); invert_m4_m4(ob->imat, ob->obmat); mul_m4_v3(ob->imat, cent); @@ -772,11 +772,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_CENTROID) { mesh_center_median(me, cent); } - else { mesh_center_bounds(me, cent); } + else if (around == V3D_CENTROID) { BKE_mesh_center_median(me, cent); } + else { BKE_mesh_center_bounds(me, cent); } negate_v3_v3(cent_neg, cent); - mesh_translate(me, cent_neg, 1); + BKE_mesh_translate(me, cent_neg, 1); tot_change++; me->id.flag |= LIB_DOIT; @@ -854,8 +854,8 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) arm->id.flag |= LIB_DOIT; /* do_inverse_offset= TRUE; */ /* docenter_armature() handles this */ - where_is_object(scene, ob); - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_object_where_is_calc(scene, ob); + BKE_pose_where_is(scene, ob); /* needed for bone parents */ ignore_parent_tx(bmain, scene, ob); @@ -867,11 +867,11 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) MetaBall *mb = ob->data; if (centermode == ORIGIN_TO_CURSOR) { /* done */ } - else if (around == V3D_CENTROID) { BKE_metaball_center_median(mb, cent); } - else { BKE_metaball_center_bounds(mb, cent); } + else if (around == V3D_CENTROID) { BKE_mball_center_median(mb, cent); } + else { BKE_mball_center_bounds(mb, cent); } negate_v3_v3(cent_neg, cent); - BKE_metaball_translate(mb, cent_neg); + BKE_mball_translate(mb, cent_neg); tot_change++; mb->id.flag |= LIB_DOIT; @@ -893,9 +893,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_mat3_m4_v3(ob->obmat, centn); /* ommit translation part */ add_v3_v3(ob->loc, centn); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); if (ob->type == OB_ARMATURE) { - where_is_pose(scene, ob); /* needed for bone parents */ + BKE_pose_where_is(scene, ob); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob); @@ -915,9 +915,9 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) mul_mat3_m4_v3(ob_other->obmat, centn); /* ommit translation part */ add_v3_v3(ob_other->loc, centn); - where_is_object(scene, ob_other); + BKE_object_where_is_calc(scene, ob_other); if (ob_other->type == OB_ARMATURE) { - where_is_pose(scene, ob_other); /* needed for bone parents */ + BKE_pose_where_is(scene, ob_other); /* needed for bone parents */ } ignore_parent_tx(bmain, scene, ob_other); } diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index acafe62150f..0c0611d3d33 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -2122,6 +2122,7 @@ void OBJECT_OT_vertex_group_add(wmOperatorType *ot) /* identifiers */ ot->name = "Add Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_add"; + ot->description = "Add a new vertex group to the active object"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2152,6 +2153,7 @@ void OBJECT_OT_vertex_group_remove(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove"; + ot->description = "Delete the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2187,6 +2189,7 @@ void OBJECT_OT_vertex_group_assign(wmOperatorType *ot) /* identifiers */ ot->name = "Assign Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_assign"; + ot->description = "Assign the selected vertices to the current (or a new) vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2229,6 +2232,7 @@ void OBJECT_OT_vertex_group_remove_from(wmOperatorType *ot) /* identifiers */ ot->name = "Remove from Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_remove_from"; + ot->description = "Remove the selected vertices from the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2262,6 +2266,7 @@ void OBJECT_OT_vertex_group_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_select"; + ot->description = "Select all the vertices assigned to the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2286,6 +2291,7 @@ void OBJECT_OT_vertex_group_deselect(wmOperatorType *ot) /* identifiers */ ot->name = "Deselect Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_deselect"; + ot->description = "Deselect all selected vertices assigned to the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll_edit_or_wpaint_vert_select; @@ -2312,6 +2318,7 @@ void OBJECT_OT_vertex_group_copy(wmOperatorType *ot) /* identifiers */ ot->name = "Copy Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_copy"; + ot->description = "Make a copy of the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2342,6 +2349,7 @@ void OBJECT_OT_vertex_group_levels(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Group Levels"; ot->idname = "OBJECT_OT_vertex_group_levels"; + ot->description = "Add some offset and multiply with some gain the weights of the active vertex group"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2372,6 +2380,7 @@ void OBJECT_OT_vertex_group_normalize(wmOperatorType *ot) /* identifiers */ ot->name = "Normalize Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_normalize"; + ot->description = "Normalize weights of the active vertex group, so that the highest ones are now 1.0"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2400,6 +2409,8 @@ void OBJECT_OT_vertex_group_normalize_all(wmOperatorType *ot) /* identifiers */ ot->name = "Normalize All Vertex Groups"; ot->idname = "OBJECT_OT_vertex_group_normalize_all"; + ot->description = "Normalize all weights of all vertex groups, " + "so that for each vertex, the sum of all weights is 1.0"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2480,6 +2491,7 @@ void OBJECT_OT_vertex_group_lock(wmOperatorType *ot) /* identifiers */ ot->name = "Change the Lock On Vertex Groups"; ot->idname = "OBJECT_OT_vertex_group_lock"; + ot->description = "Change the lock state of all vertex groups of active object"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2510,6 +2522,7 @@ void OBJECT_OT_vertex_group_invert(wmOperatorType *ot) /* identifiers */ ot->name = "Invert Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_invert"; + ot->description = "Invert active vertex group's weights"; /* api callbacks */ ot->poll = vertex_group_poll; @@ -2996,6 +3009,7 @@ void OBJECT_OT_vertex_group_move(wmOperatorType *ot) /* identifiers */ ot->name = "Move Vertex Group"; ot->idname = "OBJECT_OT_vertex_group_move"; + ot->description = "Move the active vertex group up/down in the list"; /* api callbacks */ ot->poll = vertex_group_poll; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7fb5352979d..64f4ffe4881 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -1367,6 +1367,7 @@ void PARTICLE_OT_select_all(wmOperatorType *ot) /* identifiers */ ot->name = "(De)select All"; ot->idname = "PARTICLE_OT_select_all"; + ot->description = "(De)select all particles' keys"; /* api callbacks */ ot->exec = pe_select_all_exec; @@ -1441,6 +1442,7 @@ void PARTICLE_OT_select_roots(wmOperatorType *ot) /* identifiers */ ot->name = "Select Roots"; ot->idname = "PARTICLE_OT_select_roots"; + ot->description = "Select roots of all visible particles"; /* api callbacks */ ot->exec = select_roots_exec; @@ -1481,7 +1483,8 @@ void PARTICLE_OT_select_tips(wmOperatorType *ot) /* identifiers */ ot->name = "Select Tips"; ot->idname = "PARTICLE_OT_select_tips"; - + ot->description = "Select tips of all visible particles"; + /* api callbacks */ ot->exec = select_tips_exec; ot->poll = PE_poll; @@ -1525,6 +1528,7 @@ void PARTICLE_OT_select_linked(wmOperatorType *ot) /* identifiers */ ot->name = "Select Linked"; ot->idname = "PARTICLE_OT_select_linked"; + ot->description = "Select nearest particle from mouse pointer"; /* api callbacks */ ot->exec = select_linked_exec; @@ -1717,6 +1721,7 @@ void PARTICLE_OT_hide(wmOperatorType *ot) /* identifiers */ ot->name = "Hide Selected"; ot->idname = "PARTICLE_OT_hide"; + ot->description = "Hide selected particles"; /* api callbacks */ ot->exec = hide_exec; @@ -1759,6 +1764,7 @@ void PARTICLE_OT_reveal(wmOperatorType *ot) /* identifiers */ ot->name = "Reveal"; ot->idname = "PARTICLE_OT_reveal"; + ot->description = "Show hidden particles"; /* api callbacks */ ot->exec = reveal_exec; @@ -1817,6 +1823,7 @@ void PARTICLE_OT_select_less(wmOperatorType *ot) /* identifiers */ ot->name = "Select Less"; ot->idname = "PARTICLE_OT_select_less"; + ot->description = "Deselect boundary selected keys of each particle"; /* api callbacks */ ot->exec = select_less_exec; @@ -1878,6 +1885,7 @@ void PARTICLE_OT_select_more(wmOperatorType *ot) /* identifiers */ ot->name = "Select More"; ot->idname = "PARTICLE_OT_select_more"; + ot->description = "Select keys linked to boundary selected keys of each particle"; /* api callbacks */ ot->exec = select_more_exec; @@ -1974,6 +1982,7 @@ void PARTICLE_OT_rekey(wmOperatorType *ot) /* identifiers */ ot->name = "Rekey"; ot->idname = "PARTICLE_OT_rekey"; + ot->description = "Change the number of keys of selected particles (root and tip keys included)"; /* api callbacks */ ot->exec = rekey_exec; @@ -2304,6 +2313,7 @@ void PARTICLE_OT_subdivide(wmOperatorType *ot) /* identifiers */ ot->name = "Subdivide"; ot->idname = "PARTICLE_OT_subdivide"; + ot->description = "Subdivide selected particles segments (adds keys)"; /* api callbacks */ ot->exec = subdivide_exec; @@ -2392,6 +2402,7 @@ void PARTICLE_OT_remove_doubles(wmOperatorType *ot) /* identifiers */ ot->name = "Remove Doubles"; ot->idname = "PARTICLE_OT_remove_doubles"; + ot->description = "Remove selected particles close enough of others"; /* api callbacks */ ot->exec = remove_doubles_exec; @@ -2442,6 +2453,7 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Set"; ot->idname = "PARTICLE_OT_weight_set"; + ot->description = "Set the weight of selected keys"; /* api callbacks */ ot->exec = weight_set_exec; @@ -2450,7 +2462,8 @@ void PARTICLE_OT_weight_set(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", "", 0, 1); + RNA_def_float(ot->srna, "factor", 1, 0, 1, "Factor", + "Interpolation factor between current brush weight, and keys' weights", 0, 1); } /************************ cursor drawing *******************************/ @@ -2545,6 +2558,7 @@ void PARTICLE_OT_delete(wmOperatorType *ot) /* identifiers */ ot->name = "Delete"; ot->idname = "PARTICLE_OT_delete"; + ot->description = "Delete selected particles or keys"; /* api callbacks */ ot->exec = delete_exec; @@ -2710,6 +2724,7 @@ void PARTICLE_OT_mirror(wmOperatorType *ot) /* identifiers */ ot->name = "Mirror"; ot->idname = "PARTICLE_OT_mirror"; + ot->description = "Duplicate and mirror the selected particles along the local X axis"; /* api callbacks */ ot->exec = mirror_exec; @@ -3739,6 +3754,7 @@ void PARTICLE_OT_brush_edit(wmOperatorType *ot) /* identifiers */ ot->name = "Brush Edit"; ot->idname = "PARTICLE_OT_brush_edit"; + ot->description = "Apply a stroke of brush to the particles"; /* api callbacks */ ot->exec = brush_edit_exec; @@ -4068,7 +4084,7 @@ int PE_minmax(Scene *scene, float min[3], float max[3]) } if (!ok) { - minmax_object(ob, min, max); + BKE_object_minmax(ob, min, max); ok= 1; } @@ -4229,6 +4245,7 @@ void PARTICLE_OT_particle_edit_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Particle Edit Toggle"; ot->idname = "PARTICLE_OT_particle_edit_toggle"; + ot->description = "Toggle particle edit mode"; /* api callbacks */ ot->exec = particle_edit_toggle_exec; @@ -4278,6 +4295,7 @@ void PARTICLE_OT_edited_clear(wmOperatorType *ot) /* identifiers */ ot->name = "Clear Edited"; ot->idname = "PARTICLE_OT_edited_clear"; + ot->description = "Undo all edition performed on the particle system"; /* api callbacks */ ot->exec = clear_edited_exec; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 13e407040c3..b57500df719 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -158,7 +158,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy particle setting */ if (psys->part) - part= psys_copy_settings(psys->part); + part= BKE_particlesettings_copy(psys->part); else part= psys_new_settings("ParticleSettings", bmain); diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 068e93e7a5a..5a56672f766 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -126,7 +126,7 @@ static float get_fluid_size_m(Scene *scene, Object *domainob, FluidsimSettings * float dim[3]; float longest_axis; - object_get_dimensions(domainob, dim); + BKE_object_dimensions_get(domainob, dim); longest_axis = MAX3(dim[0], dim[1], dim[2]); return longest_axis * scene->unit.scale_length; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index 6573647aaee..c935cb7da82 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -173,6 +173,7 @@ void PTCACHE_OT_free_bake_all(wmOperatorType *ot) /* identifiers */ ot->name = "Free All Physics Bakes"; ot->idname = "PTCACHE_OT_free_bake_all"; + ot->description = "Free all baked caches of all objects in the current scene"; /* api callbacks */ ot->exec = ptcache_free_bake_all_exec; diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 1a2e42d691a..595b51d22c4 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -170,7 +170,7 @@ static void screen_render_scene_layer_set(wmOperator *op, Main *mainp, Scene **s if (scn) { /* camera switch wont have updated */ scn->r.cfra = (*scene)->r.cfra; - scene_camera_switch_update(scn); + BKE_scene_camera_switch_update(scn); *scene = scn; } diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 9f611b52669..de3d2d4e871 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -271,7 +271,7 @@ static void screen_opengl_render_apply(OGLRender *oglrender) } BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, FALSE); - ok = BKE_write_ibuf_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ + ok = BKE_imbuf_write_as(ibuf, name, &scene->r.im_format, TRUE); /* no need to stamp here */ if (ok) printf("OpenGL Render written to '%s'\n", name); else printf("OpenGL Render failed to write '%s'\n", name); } @@ -413,7 +413,7 @@ static void screen_opengl_render_end(bContext *C, OGLRender *oglrender) if (oglrender->timer) { /* exec will not have a timer */ scene->r.cfra = oglrender->cfrao; - scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), oglrender->timer); } @@ -451,7 +451,7 @@ static int screen_opengl_render_anim_initialize(bContext *C, wmOperator *op) scene = oglrender->scene; oglrender->reports = op->reports; - oglrender->mh = BKE_get_movie_handle(scene->r.im_format.imtype); + oglrender->mh = BKE_movie_handle_get(scene->r.im_format.imtype); if (BKE_imtype_is_movie(scene->r.im_format.imtype)) { if (!oglrender->mh->start_movie(scene, &scene->r, oglrender->sizex, oglrender->sizey, oglrender->reports)) { screen_opengl_render_end(C, oglrender); @@ -478,7 +478,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) Object *camera = NULL; /* update animated image textures for gpu, etc, - * call before scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, scene->r.cfra); /* go to next frame */ @@ -488,17 +488,17 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) if (lay & 0xFF000000) lay &= 0xFF000000; - scene_update_for_newframe(bmain, scene, lay); + BKE_scene_update_for_newframe(bmain, scene, lay); CFRA++; } - scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); + BKE_scene_update_for_newframe(bmain, scene, screen_opengl_layers(oglrender)); if (view_context) { if (oglrender->rv3d->persp == RV3D_CAMOB && oglrender->v3d->camera && oglrender->v3d->scenelock) { - /* since scene_update_for_newframe() is used rather + /* since BKE_scene_update_for_newframe() is used rather * then ED_update_for_newframe() the camera needs to be set */ - if (scene_camera_switch_update(scene)) { + if (BKE_scene_camera_switch_update(scene)) { oglrender->v3d->camera = scene->camera; } @@ -506,7 +506,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } } else { - scene_camera_switch_update(scene); + BKE_scene_camera_switch_update(scene); camera = scene->camera; } @@ -546,7 +546,7 @@ static int screen_opengl_render_anim_step(bContext *C, wmOperator *op) } else { BKE_makepicstring(name, scene->r.pic, oglrender->bmain->name, scene->r.cfra, scene->r.im_format.imtype, scene->r.scemode & R_EXTENSION, TRUE); - ok = BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); + ok = BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); if (ok == 0) { printf("Write error: cannot save %s\n", name); diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index 32ed74097e1..f7024444e86 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -754,13 +754,13 @@ static void shader_preview_free(void *customdata) /* get rid of copied material */ BLI_remlink(&pr_main->mat, sp->matcopy); - /* free_material decrements texture, prevent this. hack alert! */ + /* BKE_material_free decrements texture, prevent this. hack alert! */ for (a = 0; a < MAX_MTEX; a++) { MTex *mtex = sp->matcopy->mtex[a]; if (mtex && mtex->tex) mtex->tex = NULL; } - free_material(sp->matcopy); + BKE_material_free(sp->matcopy); properties = IDP_GetProperties((ID *)sp->matcopy, FALSE); if (properties) { @@ -776,7 +776,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied texture */ BLI_remlink(&pr_main->tex, sp->texcopy); - free_texture(sp->texcopy); + BKE_texture_free(sp->texcopy); properties = IDP_GetProperties((ID *)sp->texcopy, FALSE); if (properties) { @@ -792,7 +792,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied world */ BLI_remlink(&pr_main->world, sp->worldcopy); - free_world(sp->worldcopy); + BKE_world_free(sp->worldcopy); properties = IDP_GetProperties((ID *)sp->worldcopy, FALSE); if (properties) { @@ -808,7 +808,7 @@ static void shader_preview_free(void *customdata) /* get rid of copied lamp */ BLI_remlink(&pr_main->lamp, sp->lampcopy); - free_lamp(sp->lampcopy); + BKE_lamp_free(sp->lampcopy); properties = IDP_GetProperties((ID *)sp->lampcopy, FALSE); if (properties) { diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index 6231970ae40..fed336e8e45 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -194,7 +194,7 @@ static int material_slot_assign_exec(bContext *C, wmOperator *UNUSED(op)) EditFont *ef = ((Curve *)ob->data)->editfont; int i, selstart, selend; - if (ef && BKE_font_getselection(ob, &selstart, &selend)) { + if (ef && BKE_vfont_select_get(ob, &selstart, &selend)) { for (i = selstart; i <= selend; i++) ef->textbufinfo[i].mat_nr = ob->actcol; } @@ -212,7 +212,7 @@ void OBJECT_OT_material_slot_assign(wmOperatorType *ot) /* identifiers */ ot->name = "Assign Material Slot"; ot->idname = "OBJECT_OT_material_slot_assign"; - ot->description = "Assign the material in the selected material slot to the selected vertices"; + ot->description = "Assign active material slot to selection"; /* api callbacks */ ot->exec = material_slot_assign_exec; @@ -296,7 +296,7 @@ void OBJECT_OT_material_slot_select(wmOperatorType *ot) /* identifiers */ ot->name = "Select Material Slot"; ot->idname = "OBJECT_OT_material_slot_select"; - ot->description = "Select vertices assigned to the selected material slot"; + ot->description = "Select by active material slot"; /* api callbacks */ ot->exec = material_slot_select_exec; @@ -315,7 +315,7 @@ void OBJECT_OT_material_slot_deselect(wmOperatorType *ot) /* identifiers */ ot->name = "Deselect Material Slot"; ot->idname = "OBJECT_OT_material_slot_deselect"; - ot->description = "Deselect vertices assigned to the selected material slot"; + ot->description = "Deselect by active material slot"; /* api callbacks */ ot->exec = material_slot_deselect_exec; @@ -376,12 +376,12 @@ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy material */ if (ma) { - ma = copy_material(ma); + ma = BKE_material_copy(ma); } else { - ma = add_material("Material"); + ma = BKE_material_add("Material"); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &ma->id); ma->use_nodes = 1; } @@ -429,7 +429,7 @@ static int new_texture_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy texture */ if (tex) - tex = copy_texture(tex); + tex = BKE_texture_copy(tex); else tex = add_texture("Texture"); @@ -476,12 +476,12 @@ static int new_world_exec(bContext *C, wmOperator *UNUSED(op)) /* add or copy world */ if (wo) { - wo = copy_world(wo); + wo = BKE_world_copy(wo); } else { wo = add_world("World"); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { ED_node_shader_default(scene, &wo->id); wo->use_nodes = 1; } @@ -525,7 +525,7 @@ static int render_layer_add_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - scene_add_render_layer(scene, NULL); + BKE_scene_add_render_layer(scene, NULL); scene->r.actlay = BLI_countlist(&scene->r.layers) - 1; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); @@ -552,7 +552,7 @@ static int render_layer_remove_exec(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); SceneRenderLayer *rl = BLI_findlink(&scene->r.layers, scene->r.actlay); - if (!scene_remove_render_layer(CTX_data_main(C), scene, rl)) + if (!BKE_scene_remove_render_layer(CTX_data_main(C), scene, rl)) return OPERATOR_CANCELLED; WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 2fa1e759e21..0f286d91613 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -104,10 +104,10 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct) void ED_region_pixelspace(ARegion *ar) { - int width= ar->winrct.xmax-ar->winrct.xmin+1; - int height= ar->winrct.ymax-ar->winrct.ymin+1; + int width = ar->winrct.xmax - ar->winrct.xmin + 1; + int height = ar->winrct.ymax - ar->winrct.ymin + 1; - wmOrtho2(-0.375f, (float)width-0.375f, -0.375f, (float)height-0.375f); + wmOrtho2(-0.375f, (float)width - 0.375f, -0.375f, (float)height - 0.375f); glLoadIdentity(); } @@ -117,7 +117,7 @@ void ED_region_do_listen(ARegion *ar, wmNotifier *note) /* generic notes first */ switch (note->category) { case NC_WM: - if (note->data==ND_FILEREAD) + if (note->data == ND_FILEREAD) ED_region_tag_redraw(ar); break; case NC_WINDOW: @@ -145,7 +145,7 @@ void ED_area_do_refresh(bContext *C, ScrArea *sa) if (sa->type && sa->type->refresh) { sa->type->refresh(C, sa); } - sa->do_refresh= 0; + sa->do_refresh = 0; } /* based on screen region draw tags, set draw tags in azones, and future region tabs etc */ @@ -154,15 +154,15 @@ void ED_area_overdraw_flush(ScrArea *sa, ARegion *ar) { AZone *az; - for (az= sa->actionzones.first; az; az= az->next) { + for (az = sa->actionzones.first; az; az = az->next) { int xs, ys; - xs= (az->x1+az->x2)/2; - ys= (az->y1+az->y2)/2; + xs = (az->x1 + az->x2) / 2; + ys = (az->y1 + az->y2) / 2; /* test if inside */ if (BLI_in_rcti(&ar->winrct, xs, ys)) { - az->do_draw= 1; + az->do_draw = 1; } } } @@ -181,16 +181,16 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) glColor4ub(255, 255, 255, 180); fdrawline(x1, y2, x2, y1); glColor4ub(255, 255, 255, 130); - fdrawline(x1, y2-dy, x2-dx, y1); + fdrawline(x1, y2 - dy, x2 - dx, y1); glColor4ub(255, 255, 255, 80); - fdrawline(x1, y2-2*dy, x2-2*dx, y1); + fdrawline(x1, y2 - 2 * dy, x2 - 2 * dx, y1); glColor4ub(0, 0, 0, 210); - fdrawline(x1, y2+1, x2+1, y1); + fdrawline(x1, y2 + 1, x2 + 1, y1); glColor4ub(0, 0, 0, 180); - fdrawline(x1, y2-dy+1, x2-dx+1, y1); + fdrawline(x1, y2 - dy + 1, x2 - dx + 1, y1); glColor4ub(0, 0, 0, 150); - fdrawline(x1, y2-2*dy+1, x2-2*dx+1, y1); + fdrawline(x1, y2 - 2 * dy + 1, x2 - 2 * dx + 1, y1); glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); @@ -199,8 +199,8 @@ static void area_draw_azone(short x1, short y1, short x2, short y2) static void region_draw_azone_icon(AZone *az) { GLUquadricObj *qobj = NULL; - short midx = az->x1 + (az->x2 - az->x1)/2; - short midy = az->y1 + (az->y2 - az->y1)/2; + short midx = az->x1 + (az->x2 - az->x1) / 2; + short midy = az->y1 + (az->y2 - az->y1) / 2; qobj = gluNewQuadric(); @@ -226,8 +226,8 @@ static void region_draw_azone_icon(AZone *az) gluDeleteQuadric(qobj); /* + */ - sdrawline(midx, midy-2, midx, midy+3); - sdrawline(midx-2, midy, midx+3, midy); + sdrawline(midx, midy - 2, midx, midy + 3); + sdrawline(midx - 2, midy, midx + 3, midy); } static void draw_azone_plus(float x1, float y1, float x2, float y2) @@ -235,9 +235,9 @@ static void draw_azone_plus(float x1, float y1, float x2, float y2) float width = 2.0f; float pad = 4.0f; - glRectf((x1 + x2 - width)*0.5f, y1 + pad, (x1 + x2 + width)*0.5f, y2 - pad); - glRectf(x1 + pad, (y1 + y2 - width)*0.5f, (x1 + x2 - width)*0.5f, (y1 + y2 + width)*0.5f); - glRectf((x1 + x2 + width)*0.5f, (y1 + y2 - width)*0.5f, x2 - pad, (y1 + y2 + width)*0.5f); + glRectf((x1 + x2 - width) * 0.5f, y1 + pad, (x1 + x2 + width) * 0.5f, y2 - pad); + glRectf(x1 + pad, (y1 + y2 - width) * 0.5f, (x1 + x2 - width) * 0.5f, (y1 + y2 + width) * 0.5f); + glRectf((x1 + x2 + width) * 0.5f, (y1 + y2 - width) * 0.5f, x2 - pad, (y1 + y2 + width) * 0.5f); } static void region_draw_azone_tab_plus(AZone *az) @@ -288,14 +288,14 @@ static void region_draw_azone_tab(AZone *az) uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f); + uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_BOTTOM_TO_TOPLEFT: uiSetRoundBox(UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); uiDrawBoxShade(GL_POLYGON, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, -0.3f, 0.05f); glColor4ub(0, 0, 0, 255); - uiRoundRect((float)az->x1, 0.3f+(float)az->y1, (float)az->x2, 0.3f+(float)az->y2, 4.0f); + uiRoundRect((float)az->x1, 0.3f + (float)az->y1, (float)az->x2, 0.3f + (float)az->y2, 4.0f); break; case AE_LEFT_TO_TOPRIGHT: uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT | UI_RB_ALPHA); @@ -327,19 +327,19 @@ static void region_draw_azone_tria(AZone *az) /* add code to draw region hidden as 'too small' */ switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1+az->x2)/2, (float)az->y2); + ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x2, (float)az->y1, (float)(az->x1 + az->x2) / 2, (float)az->y2); break; case AE_BOTTOM_TO_TOPLEFT: - ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1+az->x2)/2, (float)az->y1); + ui_draw_anti_tria((float)az->x1, (float)az->y2, (float)az->x2, (float)az->y2, (float)(az->x1 + az->x2) / 2, (float)az->y1); break; case AE_LEFT_TO_TOPRIGHT: - ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1+az->y2)/2); + ui_draw_anti_tria((float)az->x2, (float)az->y1, (float)az->x2, (float)az->y2, (float)az->x1, (float)(az->y1 + az->y2) / 2); break; case AE_RIGHT_TO_TOPLEFT: - ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1+az->y2)/2); + ui_draw_anti_tria((float)az->x1, (float)az->y1, (float)az->x1, (float)az->y2, (float)az->x2, (float)(az->y1 + az->y2) / 2); break; } @@ -350,8 +350,8 @@ static void region_draw_azone_tria(AZone *az) /* only exported for WM */ void ED_area_overdraw(bContext *C) { - wmWindow *win= CTX_wm_window(C); - bScreen *screen= CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); ScrArea *sa; /* Draw AZones, in screenspace */ @@ -360,23 +360,23 @@ void ED_area_overdraw(bContext *C) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { AZone *az; - for (az= sa->actionzones.first; az; az= az->next) { + for (az = sa->actionzones.first; az; az = az->next) { if (az->do_draw) { - if (az->type==AZONE_AREA) { + if (az->type == AZONE_AREA) { area_draw_azone(az->x1, az->y1, az->x2, az->y2); } - else if (az->type==AZONE_REGION) { + else if (az->type == AZONE_REGION) { if (az->ar) { /* only display tab or icons when the region is hidden */ - if (az->ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if (G.rt==3) + if (az->ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + if (G.rt == 3) region_draw_azone_icon(az); - else if (G.rt==2) + else if (G.rt == 2) region_draw_azone_tria(az); - else if (G.rt==1) + else if (G.rt == 1) region_draw_azone_tab(az); else region_draw_azone_tab_plus(az); @@ -384,7 +384,7 @@ void ED_area_overdraw(bContext *C) } } - az->do_draw= 0; + az->do_draw = 0; } } } @@ -395,21 +395,21 @@ void ED_area_overdraw(bContext *C) /* get scissor rect, checking overlapping regions */ void region_scissor_winrct(ARegion *ar, rcti *winrct) { - *winrct= ar->winrct; + *winrct = ar->winrct; if (ELEM(ar->alignment, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) return; while (ar->prev) { - ar= ar->prev; + ar = ar->prev; if (BLI_isect_rcti(winrct, &ar->winrct, NULL)) { - if (ar->flag & RGN_FLAG_HIDDEN); - else if (ar->alignment & RGN_SPLIT_PREV); - else if (ar->alignment==RGN_OVERLAP_LEFT) { + if (ar->flag & RGN_FLAG_HIDDEN) ; + else if (ar->alignment & RGN_SPLIT_PREV) ; + else if (ar->alignment == RGN_OVERLAP_LEFT) { winrct->xmin = ar->winrct.xmax + 1; } - else if (ar->alignment==RGN_OVERLAP_RIGHT) { + else if (ar->alignment == RGN_OVERLAP_RIGHT) { winrct->xmax = ar->winrct.xmin - 1; } else break; @@ -421,19 +421,19 @@ void region_scissor_winrct(ARegion *ar, rcti *winrct) /* makes region ready for drawing, sets pixelspace */ void ED_region_set(const bContext *C, ARegion *ar) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); rcti winrct; /* checks other overlapping regions */ region_scissor_winrct(ar, &winrct); - ar->drawrct= winrct; + ar->drawrct = winrct; /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); - UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); + UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0); ED_region_pixelspace(ar); } @@ -442,9 +442,9 @@ void ED_region_set(const bContext *C, ARegion *ar) /* only exported for WM */ void ED_region_do_draw(bContext *C, ARegion *ar) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); - ARegionType *at= ar->type; + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); + ARegionType *at = ar->type; rcti winrct; /* see BKE_spacedata_draw_locks() */ @@ -456,7 +456,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* if no partial draw rect set, full rect */ if (ar->drawrct.xmin == ar->drawrct.xmax) - ar->drawrct= winrct; + ar->drawrct = winrct; else { /* extra clip for safety */ ar->drawrct.xmin = MAX2(winrct.xmin, ar->drawrct.xmin); @@ -468,7 +468,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) /* note; this sets state, so we can use wmOrtho and friends */ wmSubWindowScissorSet(win, ar->swinid, &ar->drawrct); - UI_SetTheme(sa?sa->spacetype:0, ar->type?ar->type->regionid:0); + UI_SetTheme(sa ? sa->spacetype : 0, ar->type ? ar->type->regionid : 0); /* optional header info instead? */ if (ar->headerstr) { @@ -487,7 +487,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar) ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL); - ar->do_draw= 0; + ar->do_draw = 0; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); uiFreeInactiveBlocks(C, &ar->uiblocks); @@ -505,7 +505,7 @@ void ED_region_tag_redraw(ARegion *ar) { if (ar) { /* zero region means full region redraw */ - ar->do_draw= RGN_DRAW; + ar->do_draw = RGN_DRAW; memset(&ar->drawrct, 0, sizeof(ar->drawrct)); } } @@ -513,7 +513,7 @@ void ED_region_tag_redraw(ARegion *ar) void ED_region_tag_redraw_overlay(ARegion *ar) { if (ar) - ar->do_draw_overlay= RGN_DRAW; + ar->do_draw_overlay = RGN_DRAW; } void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) @@ -521,8 +521,8 @@ void ED_region_tag_redraw_partial(ARegion *ar, rcti *rct) if (ar) { if (!ar->do_draw) { /* no redraw set yet, set partial region */ - ar->do_draw= RGN_DRAW_PARTIAL; - ar->drawrct= *rct; + ar->do_draw = RGN_DRAW_PARTIAL; + ar->drawrct = *rct; } else if (ar->drawrct.xmin != ar->drawrct.xmax) { /* partial redraw already set, expand region */ @@ -539,7 +539,7 @@ void ED_area_tag_redraw(ScrArea *sa) ARegion *ar; if (sa) - for (ar= sa->regionbase.first; ar; ar= ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_tag_redraw(ar); } @@ -548,7 +548,7 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) ARegion *ar; if (sa) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == regiontype) { ED_region_tag_redraw(ar); } @@ -559,7 +559,7 @@ void ED_area_tag_redraw_regiontype(ScrArea *sa, int regiontype) void ED_area_tag_refresh(ScrArea *sa) { if (sa) - sa->do_refresh= 1; + sa->do_refresh = 1; } /* *************************************************************** */ @@ -573,16 +573,16 @@ void ED_area_headerprint(ScrArea *sa, const char *str) if (sa == NULL) return; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_HEADER) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_HEADER) { if (str) { - if (ar->headerstr==NULL) - ar->headerstr= MEM_mallocN(256, "headerprint"); + if (ar->headerstr == NULL) + ar->headerstr = MEM_mallocN(256, "headerprint"); BLI_strncpy(ar->headerstr, str, 256); } else if (ar->headerstr) { MEM_freeN(ar->headerstr); - ar->headerstr= NULL; + ar->headerstr = NULL; } ED_region_tag_redraw(ar); } @@ -600,53 +600,53 @@ static void area_azone_initialize(ScrArea *sa) BLI_freelistN(&sa->actionzones); /* set area action zones */ - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_AREA; - az->x1= sa->totrct.xmin - 1; - az->y1= sa->totrct.ymin - 1; - az->x2= sa->totrct.xmin + (AZONESPOT-1); - az->y2= sa->totrct.ymin + (AZONESPOT-1); + az->type = AZONE_AREA; + az->x1 = sa->totrct.xmin - 1; + az->y1 = sa->totrct.ymin - 1; + az->x2 = sa->totrct.xmin + (AZONESPOT - 1); + az->y2 = sa->totrct.ymin + (AZONESPOT - 1); BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_AREA; - az->x1= sa->totrct.xmax + 1; - az->y1= sa->totrct.ymax + 1; - az->x2= sa->totrct.xmax - (AZONESPOT-1); - az->y2= sa->totrct.ymax - (AZONESPOT-1); + az->type = AZONE_AREA; + az->x1 = sa->totrct.xmax + 1; + az->y1 = sa->totrct.ymax + 1; + az->x2 = sa->totrct.xmax - (AZONESPOT - 1); + az->y2 = sa->totrct.ymax - (AZONESPOT - 1); BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } -#define AZONEPAD_EDGE 4 -#define AZONEPAD_ICON 9 +#define AZONEPAD_EDGE 4 +#define AZONEPAD_ICON 9 static void region_azone_edge(AZone *az, ARegion *ar) { switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymax - AZONEPAD_EDGE; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymax; + az->x1 = ar->winrct.xmin; + az->y1 = ar->winrct.ymax - AZONEPAD_EDGE; + az->x2 = ar->winrct.xmax; + az->y2 = ar->winrct.ymax; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymin + AZONEPAD_EDGE; - az->x2= ar->winrct.xmax; - az->y2= ar->winrct.ymin; + az->x1 = ar->winrct.xmin; + az->y1 = ar->winrct.ymin + AZONEPAD_EDGE; + az->x2 = ar->winrct.xmax; + az->y2 = ar->winrct.ymin; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmin + AZONEPAD_EDGE; - az->y2= ar->winrct.ymax; + az->x1 = ar->winrct.xmin; + az->y1 = ar->winrct.ymin; + az->x2 = ar->winrct.xmin + AZONEPAD_EDGE; + az->y2 = ar->winrct.ymax; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax; - az->y1= ar->winrct.ymin; - az->x2= ar->winrct.xmax - AZONEPAD_EDGE; - az->y2= ar->winrct.ymax; + az->x1 = ar->winrct.xmax; + az->y1 = ar->winrct.ymin; + az->x2 = ar->winrct.xmax - AZONEPAD_EDGE; + az->y2 = ar->winrct.ymax; break; } @@ -656,55 +656,55 @@ static void region_azone_edge(AZone *az, ARegion *ar) static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot=0; + int tot = 0; /* count how many actionzones with along same edge are available. * This allows for adding more action zones in the future without * having to worry about correct offset */ - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - az->x1= ar->winrct.xmax - tot*2*AZONEPAD_ICON; - az->y1= ar->winrct.ymax + AZONEPAD_ICON; - az->x2= ar->winrct.xmax - tot*AZONEPAD_ICON; - az->y2= ar->winrct.ymax + 2*AZONEPAD_ICON; + az->x1 = ar->winrct.xmax - tot * 2 * AZONEPAD_ICON; + az->y1 = ar->winrct.ymax + AZONEPAD_ICON; + az->x2 = ar->winrct.xmax - tot * AZONEPAD_ICON; + az->y2 = ar->winrct.ymax + 2 * AZONEPAD_ICON; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin + AZONEPAD_ICON; - az->y1= ar->winrct.ymin - 2*AZONEPAD_ICON; - az->x2= ar->winrct.xmin + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymin - AZONEPAD_ICON; + az->x1 = ar->winrct.xmin + AZONEPAD_ICON; + az->y1 = ar->winrct.ymin - 2 * AZONEPAD_ICON; + az->x2 = ar->winrct.xmin + 2 * AZONEPAD_ICON; + az->y2 = ar->winrct.ymin - AZONEPAD_ICON; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin - 2*AZONEPAD_ICON; - az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; - az->x2= ar->winrct.xmin - AZONEPAD_ICON; - az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + az->x1 = ar->winrct.xmin - 2 * AZONEPAD_ICON; + az->y1 = ar->winrct.ymax - tot * 2 * AZONEPAD_ICON; + az->x2 = ar->winrct.xmin - AZONEPAD_ICON; + az->y2 = ar->winrct.ymax - tot * AZONEPAD_ICON; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax + AZONEPAD_ICON; - az->y1= ar->winrct.ymax - tot*2*AZONEPAD_ICON; - az->x2= ar->winrct.xmax + 2*AZONEPAD_ICON; - az->y2= ar->winrct.ymax - tot*AZONEPAD_ICON; + az->x1 = ar->winrct.xmax + AZONEPAD_ICON; + az->y1 = ar->winrct.ymax - tot * 2 * AZONEPAD_ICON; + az->x2 = ar->winrct.xmax + 2 * AZONEPAD_ICON; + az->y2 = ar->winrct.ymax - tot * AZONEPAD_ICON; break; } BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); /* if more azones on 1 spot, set offset */ - for (azt= sa->actionzones.first; azt; azt= azt->next) { - if (az!=azt) { - if ( ABS(az->x1-azt->x1) < 2 && ABS(az->y1-azt->y1) < 2) { - if (az->edge==AE_TOP_TO_BOTTOMRIGHT || az->edge==AE_BOTTOM_TO_TOPLEFT) { - az->x1+= AZONESPOT; - az->x2+= AZONESPOT; + for (azt = sa->actionzones.first; azt; azt = azt->next) { + if (az != azt) { + if (ABS(az->x1 - azt->x1) < 2 && ABS(az->y1 - azt->y1) < 2) { + if (az->edge == AE_TOP_TO_BOTTOMRIGHT || az->edge == AE_BOTTOM_TO_TOPLEFT) { + az->x1 += AZONESPOT; + az->x2 += AZONESPOT; } else { - az->y1-= AZONESPOT; - az->y2-= AZONESPOT; + az->y1 -= AZONESPOT; + az->y2 -= AZONESPOT; } BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } @@ -712,44 +712,44 @@ static void region_azone_icon(ScrArea *sa, AZone *az, ARegion *ar) } } -#define AZONEPAD_TAB_PLUSW 14 -#define AZONEPAD_TAB_PLUSH 14 +#define AZONEPAD_TAB_PLUSW 14 +#define AZONEPAD_TAB_PLUSH 14 /* region already made zero sized, in shape of edge */ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot= 0, add; + int tot = 0, add; - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; - az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; - az->y1= ar->winrct.ymax - add; - az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; - az->y2= ar->winrct.ymax - add + AZONEPAD_TAB_PLUSH; + if (ar->winrct.ymax == sa->totrct.ymin) add = 1; else add = 0; + az->x1 = ar->winrct.xmax - 2.5 * AZONEPAD_TAB_PLUSW; + az->y1 = ar->winrct.ymax - add; + az->x2 = ar->winrct.xmax - 1.5 * AZONEPAD_TAB_PLUSW; + az->y2 = ar->winrct.ymax - add + AZONEPAD_TAB_PLUSH; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 2.5*AZONEPAD_TAB_PLUSW; - az->y1= ar->winrct.ymin - AZONEPAD_TAB_PLUSH; - az->x2= ar->winrct.xmax - 1.5*AZONEPAD_TAB_PLUSW; - az->y2= ar->winrct.ymin; + az->x1 = ar->winrct.xmax - 2.5 * AZONEPAD_TAB_PLUSW; + az->y1 = ar->winrct.ymin - AZONEPAD_TAB_PLUSH; + az->x2 = ar->winrct.xmax - 1.5 * AZONEPAD_TAB_PLUSW; + az->y2 = ar->winrct.ymin; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin - AZONEPAD_TAB_PLUSH; - az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW; - az->x2= ar->winrct.xmin; - az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW; + az->x1 = ar->winrct.xmin - AZONEPAD_TAB_PLUSH; + az->y1 = ar->winrct.ymax - 2.5 * AZONEPAD_TAB_PLUSW; + az->x2 = ar->winrct.xmin; + az->y2 = ar->winrct.ymax - 1.5 * AZONEPAD_TAB_PLUSW; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 1; - az->y1= ar->winrct.ymax - 2.5*AZONEPAD_TAB_PLUSW; - az->x2= ar->winrct.xmax - 1 + AZONEPAD_TAB_PLUSH; - az->y2= ar->winrct.ymax - 1.5*AZONEPAD_TAB_PLUSW; + az->x1 = ar->winrct.xmax - 1; + az->y1 = ar->winrct.ymax - 2.5 * AZONEPAD_TAB_PLUSW; + az->x2 = ar->winrct.xmax - 1 + AZONEPAD_TAB_PLUSH; + az->y2 = ar->winrct.ymax - 1.5 * AZONEPAD_TAB_PLUSW; break; } /* rect needed for mouse pointer test */ @@ -757,89 +757,89 @@ static void region_azone_tab_plus(ScrArea *sa, AZone *az, ARegion *ar) } -#define AZONEPAD_TABW 18 -#define AZONEPAD_TABH 7 +#define AZONEPAD_TABW 18 +#define AZONEPAD_TABH 7 /* region already made zero sized, in shape of edge */ static void region_azone_tab(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot= 0, add; + int tot = 0, add; - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; - az->x1= ar->winrct.xmax - 2*AZONEPAD_TABW; - az->y1= ar->winrct.ymax - add; - az->x2= ar->winrct.xmax - AZONEPAD_TABW; - az->y2= ar->winrct.ymax - add + AZONEPAD_TABH; + if (ar->winrct.ymax == sa->totrct.ymin) add = 1; else add = 0; + az->x1 = ar->winrct.xmax - 2 * AZONEPAD_TABW; + az->y1 = ar->winrct.ymax - add; + az->x2 = ar->winrct.xmax - AZONEPAD_TABW; + az->y2 = ar->winrct.ymax - add + AZONEPAD_TABH; break; case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin + AZONEPAD_TABW; - az->y1= ar->winrct.ymin - AZONEPAD_TABH; - az->x2= ar->winrct.xmin + 2*AZONEPAD_TABW; - az->y2= ar->winrct.ymin; + az->x1 = ar->winrct.xmin + AZONEPAD_TABW; + az->y1 = ar->winrct.ymin - AZONEPAD_TABH; + az->x2 = ar->winrct.xmin + 2 * AZONEPAD_TABW; + az->y2 = ar->winrct.ymin; break; case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin + 1 - AZONEPAD_TABH; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW; - az->x2= ar->winrct.xmin + 1; - az->y2= ar->winrct.ymax - AZONEPAD_TABW; + az->x1 = ar->winrct.xmin + 1 - AZONEPAD_TABH; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TABW; + az->x2 = ar->winrct.xmin + 1; + az->y2 = ar->winrct.ymax - AZONEPAD_TABW; break; case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 1; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TABW; - az->x2= ar->winrct.xmax - 1 + AZONEPAD_TABH; - az->y2= ar->winrct.ymax - AZONEPAD_TABW; + az->x1 = ar->winrct.xmax - 1; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TABW; + az->x2 = ar->winrct.xmax - 1 + AZONEPAD_TABH; + az->y2 = ar->winrct.ymax - AZONEPAD_TABW; break; } /* rect needed for mouse pointer test */ BLI_init_rcti(&az->rect, az->x1, az->x2, az->y1, az->y2); } -#define AZONEPAD_TRIAW 16 -#define AZONEPAD_TRIAH 9 +#define AZONEPAD_TRIAW 16 +#define AZONEPAD_TRIAH 9 /* region already made zero sized, in shape of edge */ static void region_azone_tria(ScrArea *sa, AZone *az, ARegion *ar) { AZone *azt; - int tot= 0, add; + int tot = 0, add; - for (azt= sa->actionzones.first; azt; azt= azt->next) { + for (azt = sa->actionzones.first; azt; azt = azt->next) { if (azt->edge == az->edge) tot++; } switch (az->edge) { case AE_TOP_TO_BOTTOMRIGHT: - if (ar->winrct.ymax == sa->totrct.ymin) add= 1; else add= 0; - az->x1= ar->winrct.xmax - 2*AZONEPAD_TRIAW; - az->y1= ar->winrct.ymax - add; - az->x2= ar->winrct.xmax - AZONEPAD_TRIAW; - az->y2= ar->winrct.ymax - add + AZONEPAD_TRIAH; + if (ar->winrct.ymax == sa->totrct.ymin) add = 1; else add = 0; + az->x1 = ar->winrct.xmax - 2 * AZONEPAD_TRIAW; + az->y1 = ar->winrct.ymax - add; + az->x2 = ar->winrct.xmax - AZONEPAD_TRIAW; + az->y2 = ar->winrct.ymax - add + AZONEPAD_TRIAH; break; - case AE_BOTTOM_TO_TOPLEFT: - az->x1= ar->winrct.xmin + AZONEPAD_TRIAW; - az->y1= ar->winrct.ymin - AZONEPAD_TRIAH; - az->x2= ar->winrct.xmin + 2*AZONEPAD_TRIAW; - az->y2= ar->winrct.ymin; + case AE_BOTTOM_TO_TOPLEFT: + az->x1 = ar->winrct.xmin + AZONEPAD_TRIAW; + az->y1 = ar->winrct.ymin - AZONEPAD_TRIAH; + az->x2 = ar->winrct.xmin + 2 * AZONEPAD_TRIAW; + az->y2 = ar->winrct.ymin; break; - case AE_LEFT_TO_TOPRIGHT: - az->x1= ar->winrct.xmin + 1 - AZONEPAD_TRIAH; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW; - az->x2= ar->winrct.xmin + 1; - az->y2= ar->winrct.ymax - AZONEPAD_TRIAW; + case AE_LEFT_TO_TOPRIGHT: + az->x1 = ar->winrct.xmin + 1 - AZONEPAD_TRIAH; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TRIAW; + az->x2 = ar->winrct.xmin + 1; + az->y2 = ar->winrct.ymax - AZONEPAD_TRIAW; break; - case AE_RIGHT_TO_TOPLEFT: - az->x1= ar->winrct.xmax - 1; - az->y1= ar->winrct.ymax - 2*AZONEPAD_TRIAW; - az->x2= ar->winrct.xmax - 1 + AZONEPAD_TRIAH; - az->y2= ar->winrct.ymax - AZONEPAD_TRIAW; + case AE_RIGHT_TO_TOPLEFT: + az->x1 = ar->winrct.xmax - 1; + az->y1 = ar->winrct.ymax - 2 * AZONEPAD_TRIAW; + az->x2 = ar->winrct.xmax - 1 + AZONEPAD_TRIAH; + az->y2 = ar->winrct.ymax - AZONEPAD_TRIAW; break; } /* rect needed for mouse pointer test */ @@ -851,18 +851,18 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) { AZone *az; - az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); + az = (AZone *)MEM_callocN(sizeof(AZone), "actionzone"); BLI_addtail(&(sa->actionzones), az); - az->type= AZONE_REGION; - az->ar= ar; - az->edge= edge; + az->type = AZONE_REGION; + az->ar = ar; + az->edge = edge; - if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - if (G.rt==3) + if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + if (G.rt == 3) region_azone_icon(sa, az, ar); - else if (G.rt==2) + else if (G.rt == 2) region_azone_tria(sa, az, ar); - else if (G.rt==1) + else if (G.rt == 1) region_azone_tab(sa, az, ar); else region_azone_tab_plus(sa, az, ar); @@ -878,11 +878,11 @@ static void region_azone_initialize(ScrArea *sa, ARegion *ar, AZEdge edge) static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) { - /* edge code (t b l r) is along which area edge azone will be drawn */ + /* edge code (t b l r) is along which area edge azone will be drawn */ - if (alignment==RGN_ALIGN_TOP) + if (alignment == RGN_ALIGN_TOP) region_azone_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT); - else if (alignment==RGN_ALIGN_BOTTOM) + else if (alignment == RGN_ALIGN_BOTTOM) region_azone_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT); else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) region_azone_initialize(sa, ar, AE_LEFT_TO_TOPRIGHT); @@ -893,21 +893,21 @@ static void region_azone_add(ScrArea *sa, ARegion *ar, int alignment) /* dir is direction to check, not the splitting edge direction! */ static int rct_fits(rcti *rect, char dir, int size) { - if (dir=='h') { - return rect->xmax-rect->xmin - size; + if (dir == 'h') { + return rect->xmax - rect->xmin - size; } else { // 'v' - return rect->ymax-rect->ymin - size; + return rect->ymax - rect->ymin - size; } } static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int quad) { - rcti *remainder_prev= remainder; + rcti *remainder_prev = remainder; int prefsizex, prefsizey; int alignment; - if (ar==NULL) + if (ar == NULL) return; /* no returns in function, winrct gets set in the end again */ @@ -916,53 +916,53 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int /* for test; allow split of previously defined region */ if (ar->alignment & RGN_SPLIT_PREV) if (ar->prev) - remainder= &ar->prev->winrct; + remainder = &ar->prev->winrct; alignment = ar->alignment & ~RGN_SPLIT_PREV; /* clear state flags first */ ar->flag &= ~RGN_FLAG_TOO_SMALL; /* user errors */ - if (ar->next==NULL && alignment!=RGN_ALIGN_QSPLIT) - alignment= RGN_ALIGN_NONE; + if (ar->next == NULL && alignment != RGN_ALIGN_QSPLIT) + alignment = RGN_ALIGN_NONE; /* prefsize, for header we stick to exception */ - prefsizex= ar->sizex?ar->sizex:ar->type->prefsizex; - if (ar->regiontype==RGN_TYPE_HEADER) - prefsizey= ar->type->prefsizey; - else if (ar->regiontype==RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { - prefsizey= UI_UNIT_Y * 2 + (UI_UNIT_Y/2); + prefsizex = ar->sizex ? ar->sizex : ar->type->prefsizex; + if (ar->regiontype == RGN_TYPE_HEADER) + prefsizey = ar->type->prefsizey; + else if (ar->regiontype == RGN_TYPE_UI && sa->spacetype == SPACE_FILE) { + prefsizey = UI_UNIT_Y * 2 + (UI_UNIT_Y / 2); } else - prefsizey= ar->sizey?ar->sizey:ar->type->prefsizey; + prefsizey = ar->sizey ? ar->sizey : ar->type->prefsizey; /* hidden is user flag */ - if (ar->flag & RGN_FLAG_HIDDEN); + if (ar->flag & RGN_FLAG_HIDDEN) ; /* XXX floating area region, not handled yet here */ - else if (alignment == RGN_ALIGN_FLOAT); + else if (alignment == RGN_ALIGN_FLOAT) ; /* remainder is too small for any usage */ - else if ( rct_fits(remainder, 'v', 1)<0 || rct_fits(remainder, 'h', 1) < 0 ) { + else if (rct_fits(remainder, 'v', 1) < 0 || rct_fits(remainder, 'h', 1) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } - else if (alignment==RGN_ALIGN_NONE) { + else if (alignment == RGN_ALIGN_NONE) { /* typically last region */ - ar->winrct= *remainder; + ar->winrct = *remainder; BLI_init_rcti(remainder, 0, 0, 0, 0); } - else if (alignment==RGN_ALIGN_TOP || alignment==RGN_ALIGN_BOTTOM) { + else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) { - if ( rct_fits(remainder, 'v', prefsizey) < 0 ) { + if (rct_fits(remainder, 'v', prefsizey) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { - int fac= rct_fits(remainder, 'v', prefsizey); + int fac = rct_fits(remainder, 'v', prefsizey); - if (fac < 0 ) + if (fac < 0) prefsizey += fac; - ar->winrct= *remainder; + ar->winrct = *remainder; - if (alignment==RGN_ALIGN_TOP) { + if (alignment == RGN_ALIGN_TOP) { ar->winrct.ymin = ar->winrct.ymax - prefsizey + 1; remainder->ymax = ar->winrct.ymin - 1; } @@ -972,92 +972,92 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } } } - else if ( ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) { + else if (ELEM4(alignment, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT, RGN_OVERLAP_LEFT, RGN_OVERLAP_RIGHT)) { - if ( rct_fits(remainder, 'h', prefsizex) < 0 ) { + if (rct_fits(remainder, 'h', prefsizex) < 0) { ar->flag |= RGN_FLAG_TOO_SMALL; } else { - int fac= rct_fits(remainder, 'h', prefsizex); + int fac = rct_fits(remainder, 'h', prefsizex); - if (fac < 0 ) + if (fac < 0) prefsizex += fac; - ar->winrct= *remainder; + ar->winrct = *remainder; if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) { ar->winrct.xmin = ar->winrct.xmax - prefsizex + 1; - if (alignment==RGN_ALIGN_RIGHT) + if (alignment == RGN_ALIGN_RIGHT) remainder->xmax = ar->winrct.xmin - 1; } else { ar->winrct.xmax = ar->winrct.xmin + prefsizex - 1; - if (alignment==RGN_ALIGN_LEFT) + if (alignment == RGN_ALIGN_LEFT) remainder->xmin = ar->winrct.xmax + 1; } } } - else if (alignment==RGN_ALIGN_VSPLIT || alignment==RGN_ALIGN_HSPLIT) { + else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) { /* percentage subdiv*/ - ar->winrct= *remainder; + ar->winrct = *remainder; - if (alignment==RGN_ALIGN_HSPLIT) { - if ( rct_fits(remainder, 'h', prefsizex) > 4) { - ar->winrct.xmax = (remainder->xmin+remainder->xmax)/2; - remainder->xmin = ar->winrct.xmax+1; + if (alignment == RGN_ALIGN_HSPLIT) { + if (rct_fits(remainder, 'h', prefsizex) > 4) { + ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + remainder->xmin = ar->winrct.xmax + 1; } else { BLI_init_rcti(remainder, 0, 0, 0, 0); } } else { - if ( rct_fits(remainder, 'v', prefsizey) > 4) { - ar->winrct.ymax = (remainder->ymin+remainder->ymax)/2; - remainder->ymin = ar->winrct.ymax+1; + if (rct_fits(remainder, 'v', prefsizey) > 4) { + ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; + remainder->ymin = ar->winrct.ymax + 1; } else { BLI_init_rcti(remainder, 0, 0, 0, 0); } } } - else if (alignment==RGN_ALIGN_QSPLIT) { - ar->winrct= *remainder; + else if (alignment == RGN_ALIGN_QSPLIT) { + ar->winrct = *remainder; /* test if there's still 4 regions left */ - if (quad==0) { - ARegion *artest= ar->next; - int count= 1; + if (quad == 0) { + ARegion *artest = ar->next; + int count = 1; while (artest) { - artest->alignment= RGN_ALIGN_QSPLIT; - artest= artest->next; + artest->alignment = RGN_ALIGN_QSPLIT; + artest = artest->next; count++; } - if (count!=4) { + if (count != 4) { /* let's stop adding regions */ BLI_init_rcti(remainder, 0, 0, 0, 0); if (G.debug & G_DEBUG) printf("region quadsplit failed\n"); } - else quad= 1; + else quad = 1; } if (quad) { - if (quad==1) { /* left bottom */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; + if (quad == 1) { /* left bottom */ + ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; } - else if (quad==2) { /* left top */ - ar->winrct.xmax = (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; + else if (quad == 2) { /* left top */ + ar->winrct.xmax = (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; } - else if (quad==3) { /* right bottom */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymax = (remainder->ymin + remainder->ymax)/2; + else if (quad == 3) { /* right bottom */ + ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymax = (remainder->ymin + remainder->ymax) / 2; } - else { /* right top */ - ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax)/2; - ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax)/2; + else { /* right top */ + ar->winrct.xmin = 1 + (remainder->xmin + remainder->xmax) / 2; + ar->winrct.ymin = 1 + (remainder->ymin + remainder->ymax) / 2; BLI_init_rcti(remainder, 0, 0, 0, 0); } @@ -1066,16 +1066,16 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int } /* for speedup */ - ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1; - ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; + ar->winx = ar->winrct.xmax - ar->winrct.xmin + 1; + ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; /* set winrect for azones */ - if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { - ar->winrct= *remainder; + if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { + ar->winrct = *remainder; - if (alignment==RGN_ALIGN_TOP) + if (alignment == RGN_ALIGN_TOP) ar->winrct.ymin = ar->winrct.ymax; - else if (alignment==RGN_ALIGN_BOTTOM) + else if (alignment == RGN_ALIGN_BOTTOM) ar->winrct.ymax = ar->winrct.ymin; else if (ELEM(alignment, RGN_ALIGN_RIGHT, RGN_OVERLAP_RIGHT)) ar->winrct.xmin = ar->winrct.xmax; @@ -1088,9 +1088,9 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int /* restore prev-split exception */ if (ar->alignment & RGN_SPLIT_PREV) { if (ar->prev) { - remainder= remainder_prev; - ar->prev->winx= ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; - ar->prev->winy= ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; + remainder = remainder_prev; + ar->prev->winx = ar->prev->winrct.xmax - ar->prev->winrct.xmin + 1; + ar->prev->winy = ar->prev->winrct.ymax - ar->prev->winrct.ymin + 1; } } @@ -1113,34 +1113,34 @@ static void region_rect_recursive(ScrArea *sa, ARegion *ar, rcti *remainder, int static void area_calc_totrct(ScrArea *sa, int sizex, int sizey) { - short rt= 0; // CLAMPIS(G.rt, 0, 16); + short rt = 0; // CLAMPIS(G.rt, 0, 16); - if (sa->v1->vec.x>0) sa->totrct.xmin = sa->v1->vec.x+1+rt; + if (sa->v1->vec.x > 0) sa->totrct.xmin = sa->v1->vec.x + 1 + rt; else sa->totrct.xmin = sa->v1->vec.x; - if (sa->v4->vec.xtotrct.xmax = sa->v4->vec.x-1-rt; + if (sa->v4->vec.x < sizex - 1) sa->totrct.xmax = sa->v4->vec.x - 1 - rt; else sa->totrct.xmax = sa->v4->vec.x; - if (sa->v1->vec.y>0) sa->totrct.ymin = sa->v1->vec.y+1+rt; + if (sa->v1->vec.y > 0) sa->totrct.ymin = sa->v1->vec.y + 1 + rt; else sa->totrct.ymin = sa->v1->vec.y; - if (sa->v2->vec.ytotrct.ymax = sa->v2->vec.y-1-rt; + if (sa->v2->vec.y < sizey - 1) sa->totrct.ymax = sa->v2->vec.y - 1 - rt; else sa->totrct.ymax = sa->v2->vec.y; /* for speedup */ - sa->winx= sa->totrct.xmax-sa->totrct.xmin+1; - sa->winy= sa->totrct.ymax-sa->totrct.ymin+1; + sa->winx = sa->totrct.xmax - sa->totrct.xmin + 1; + sa->winy = sa->totrct.ymax - sa->totrct.ymin + 1; } /* used for area initialize below */ static void region_subwindow(wmWindow *win, ARegion *ar) { - if (ar->flag & (RGN_FLAG_HIDDEN|RGN_FLAG_TOO_SMALL)) { + if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { if (ar->swinid) wm_subwindow_close(win, ar->swinid); - ar->swinid= 0; + ar->swinid = 0; } - else if (ar->swinid==0) - ar->swinid= wm_subwindow_open(win, &ar->winrct); + else if (ar->swinid == 0) + ar->swinid = wm_subwindow_open(win, &ar->winrct); else wm_subwindow_position(win, ar->swinid, &ar->winrct); } @@ -1164,10 +1164,10 @@ static void ed_default_handlers(wmWindowManager *wm, ScrArea *sa, ListBase *hand wmKeyMap *keymap = WM_keymap_find(wm->defaultconf, "Markers", 0, 0); /* time space only has this keymap, the others get a boundbox restricted map */ - if (sa->spacetype!=SPACE_TIME) { + if (sa->spacetype != SPACE_TIME) { ARegion *ar; - static rcti rect= {0, 10000, 0, 30}; /* same local check for all areas */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + static rcti rect = {0, 10000, 0, 30}; /* same local check for all areas */ + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { WM_event_add_keymap_handler_bb(handlers, keymap, &rect, &ar->winrct); } @@ -1205,15 +1205,15 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) rcti rect; /* set typedefinitions */ - sa->type= BKE_spacetype_from_id(sa->spacetype); + sa->type = BKE_spacetype_from_id(sa->spacetype); - if (sa->type==NULL) { - sa->butspacetype= sa->spacetype= SPACE_VIEW3D; - sa->type= BKE_spacetype_from_id(sa->spacetype); + if (sa->type == NULL) { + sa->butspacetype = sa->spacetype = SPACE_VIEW3D; + sa->type = BKE_spacetype_from_id(sa->spacetype); } - for (ar= sa->regionbase.first; ar; ar= ar->next) - ar->type= BKE_regiontype_from_id(sa->type, ar->regiontype); + for (ar = sa->regionbase.first; ar; ar = ar->next) + ar->type = BKE_regiontype_from_id(sa->type, ar->regiontype); /* area sizes */ area_calc_totrct(sa, win->sizex, win->sizey); @@ -1222,7 +1222,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) area_azone_initialize(sa); /* region rect sizes */ - rect= sa->totrct; + rect = sa->totrct; region_rect_recursive(sa, sa->regionbase.first, &rect, 0); /* default area handlers */ @@ -1232,7 +1232,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) sa->type->init(wm, sa); /* region windows, default and own handlers */ - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { region_subwindow(win, ar); if (ar->swinid) { @@ -1248,7 +1248,7 @@ void ED_area_initialize(wmWindowManager *wm, wmWindow *win, ScrArea *sa) } /* rechecks 2d matrix for header on dpi changing, do not do for other regions, it resets view && blocks view2d operator polls (ton) */ - if (ar->regiontype==RGN_TYPE_HEADER) + if (ar->regiontype == RGN_TYPE_HEADER) ar->v2d.flag &= ~V2D_IS_INITIALISED; } } @@ -1261,17 +1261,17 @@ void ED_region_init(bContext *C, ARegion *ar) /* refresh can be called before window opened */ region_subwindow(CTX_wm_window(C), ar); - ar->winx= ar->winrct.xmax - ar->winrct.xmin + 1; - ar->winy= ar->winrct.ymax - ar->winrct.ymin + 1; + ar->winx = ar->winrct.xmax - ar->winrct.xmin + 1; + ar->winy = ar->winrct.ymax - ar->winrct.ymin + 1; /* UI convention */ - wmOrtho2(-0.01f, ar->winx-0.01f, -0.01f, ar->winy-0.01f); + wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f); glLoadIdentity(); } void ED_region_toggle_hidden(bContext *C, ARegion *ar) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); ar->flag ^= RGN_FLAG_HIDDEN; @@ -1288,11 +1288,11 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) { SpaceType *st; ARegion *ar; - int spacetype= sa1->spacetype; + int spacetype = sa1->spacetype; - sa1->headertype= sa2->headertype; - sa1->spacetype= sa2->spacetype; - sa1->butspacetype= sa2->butspacetype; + sa1->headertype = sa2->headertype; + sa1->spacetype = sa2->spacetype; + sa1->butspacetype = sa2->butspacetype; if (swap_space == 1) { SWAP(ListBase, sa1->spacedata, sa2->spacedata); @@ -1315,16 +1315,16 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) SWAP(ListBase, sa1->regionbase, sa2->regionbase); } else { - if (swap_space<2) { - st= BKE_spacetype_from_id(spacetype); - for (ar= sa1->regionbase.first; ar; ar= ar->next) + if (swap_space < 2) { + st = BKE_spacetype_from_id(spacetype); + for (ar = sa1->regionbase.first; ar; ar = ar->next) BKE_area_region_free(st, ar); BLI_freelistN(&sa1->regionbase); } - st= BKE_spacetype_from_id(sa2->spacetype); - for (ar= sa2->regionbase.first; ar; ar= ar->next) { - ARegion *newar= BKE_area_region_copy(st, ar); + st = BKE_spacetype_from_id(sa2->spacetype); + for (ar = sa2->regionbase.first; ar; ar = ar->next) { + ARegion *newar = BKE_area_region_copy(st, ar); BLI_addtail(&sa1->regionbase, newar); } } @@ -1334,7 +1334,7 @@ void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space) void ED_area_swapspace(bContext *C, ScrArea *sa1, ScrArea *sa2) { - ScrArea *tmp= MEM_callocN(sizeof(ScrArea), "addscrarea"); + ScrArea *tmp = MEM_callocN(sizeof(ScrArea), "addscrarea"); ED_area_exit(C, sa1); ED_area_exit(C, sa2); @@ -1366,34 +1366,34 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) ED_area_exit(C, sa); - st= BKE_spacetype_from_id(type); - slold= sa->spacedata.first; + st = BKE_spacetype_from_id(type); + slold = sa->spacedata.first; - sa->spacetype= type; - sa->butspacetype= type; - sa->type= st; + sa->spacetype = type; + sa->butspacetype = type; + sa->type = st; /* check previously stored space */ - for (sl= sa->spacedata.first; sl; sl= sl->next) - if (sl->spacetype==type) + for (sl = sa->spacedata.first; sl; sl = sl->next) + if (sl->spacetype == type) break; /* old spacedata... happened during work on 2.50, remove */ - if (sl && sl->regionbase.first==NULL) { + if (sl && sl->regionbase.first == NULL) { st->free(sl); BLI_freelinkN(&sa->spacedata, sl); if (slold == sl) { - slold= NULL; + slold = NULL; } - sl= NULL; + sl = NULL; } if (sl) { /* swap regions */ - slold->regionbase= sa->regionbase; - sa->regionbase= sl->regionbase; - sl->regionbase.first= sl->regionbase.last= NULL; + slold->regionbase = sa->regionbase; + sa->regionbase = sl->regionbase; + sl->regionbase.first = sl->regionbase.last = NULL; /* put in front of list */ BLI_remlink(&sa->spacedata, sl); @@ -1402,14 +1402,14 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) else { /* new space */ if (st) { - sl= st->new(C); + sl = st->new(C); BLI_addhead(&sa->spacedata, sl); /* swap regions */ if (slold) - slold->regionbase= sa->regionbase; - sa->regionbase= sl->regionbase; - sl->regionbase.first= sl->regionbase.last= NULL; + slold->regionbase = sa->regionbase; + sa->regionbase = sl->regionbase; + sl->regionbase.first = sl->regionbase.last = NULL; } } @@ -1419,7 +1419,7 @@ void ED_area_newspace(bContext *C, ScrArea *sa, int type) WM_event_add_mousemove(C); /*send space change notifier*/ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); ED_area_tag_refresh(sa); } @@ -1446,47 +1446,47 @@ void ED_area_prevspace(bContext *C, ScrArea *sa) ED_area_tag_redraw(sa); /*send space change notifier*/ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, sa); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, sa); } static const char *editortype_pup(void) { - const char *types= N_( - "Editor type:%t" - "|3D View %x1" + const char *types = N_( + "Editor type:%t" + "|3D View %x1" - "|%l" + "|%l" - "|Timeline %x15" - "|Graph Editor %x2" - "|DopeSheet %x12" - "|NLA Editor %x13" + "|Timeline %x15" + "|Graph Editor %x2" + "|DopeSheet %x12" + "|NLA Editor %x13" - "|%l" + "|%l" - "|UV/Image Editor %x6" + "|UV/Image Editor %x6" - "|Video Sequence Editor %x8" - "|Movie Clip Editor %x20" - "|Text Editor %x9" - "|Node Editor %x16" - "|Logic Editor %x17" + "|Video Sequence Editor %x8" + "|Movie Clip Editor %x20" + "|Text Editor %x9" + "|Node Editor %x16" + "|Logic Editor %x17" - "|%l" + "|%l" - "|Properties %x4" - "|Outliner %x3" - "|User Preferences %x19" - "|Info%x7" + "|Properties %x4" + "|Outliner %x3" + "|User Preferences %x19" + "|Info%x7" - "|%l" + "|%l" - "|File Browser %x5" + "|File Browser %x5" - "|%l" + "|%l" - "|Python Console %x18" - ); + "|Python Console %x18" + ); return IFACE_(types); } @@ -1497,20 +1497,20 @@ static void spacefunc(struct bContext *C, void *UNUSED(arg1), void *UNUSED(arg2) ED_area_tag_redraw(CTX_wm_area(C)); /*send space change notifier*/ - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CHANGED, CTX_wm_area(C)); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CHANGED, CTX_wm_area(C)); } /* returns offset for next button in header */ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); uiBut *but; - int xco= 8; + int xco = 8; but = uiDefIconTextButC(block, ICONTEXTROW, 0, ICON_VIEW3D, - editortype_pup(), xco, yco, UI_UNIT_X+10, UI_UNIT_Y, - &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, - TIP_("Displays current editor type. Click for menu of available types")); + editortype_pup(), xco, yco, UI_UNIT_X + 10, UI_UNIT_Y, + &(sa->butspacetype), 1.0, SPACEICONMAX, 0, 0, + TIP_("Displays current editor type. Click for menu of available types")); uiButSetFunc(but, spacefunc, NULL, NULL); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ @@ -1519,12 +1519,12 @@ int ED_area_header_switchbutton(const bContext *C, uiBlock *block, int yco) int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) { - ScrArea *sa= CTX_wm_area(C); - int xco= 8; + ScrArea *sa = CTX_wm_area(C); + int xco = 8; uiBut *but; if (!sa->full) - xco= ED_area_header_switchbutton(C, block, yco); + xco = ED_area_header_switchbutton(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSSN); @@ -1554,25 +1554,25 @@ int ED_area_header_standardbuttons(const bContext *C, uiBlock *block, int yco) void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char *context, int contextnr) { - ScrArea *sa= CTX_wm_area(C); - uiStyle *style= UI_GetStyle(); + ScrArea *sa = CTX_wm_area(C); + uiStyle *style = UI_GetStyle(); uiBlock *block; PanelType *pt; Panel *panel; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; - int x, y, xco, yco, w, em, triangle, open, newcontext= 0; + int x, y, xco, yco, w, em, triangle, open, newcontext = 0; if (contextnr >= 0) - newcontext= UI_view2d_tab_set(v2d, contextnr); + newcontext = UI_view2d_tab_set(v2d, contextnr); if (vertical) { - w= v2d->cur.xmax - v2d->cur.xmin; - em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; + w = v2d->cur.xmax - v2d->cur.xmin; + em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; } else { - w= UI_PANEL_WIDTH; - em= (ar->type->prefsizex)? UI_UNIT_Y/2: UI_UNIT_Y; + w = UI_PANEL_WIDTH; + em = (ar->type->prefsizex) ? UI_UNIT_Y / 2 : UI_UNIT_Y; } /* create panels */ @@ -1581,7 +1581,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(v2d); - for (pt= ar->type->paneltypes.first; pt; pt= pt->next) { + for (pt = ar->type->paneltypes.first; pt; pt = pt->next) { /* verify context */ if (context) if (pt->context[0] && strcmp(context, pt->context) != 0) @@ -1589,25 +1589,25 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* draw panel */ if (pt->draw && (!pt->poll || pt->poll(C, pt))) { - block= uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); - panel= uiBeginPanel(sa, ar, block, pt, &open); + block = uiBeginBlock(C, ar, pt->idname, UI_EMBOSS); + panel = uiBeginPanel(sa, ar, block, pt, &open); /* bad fixed values */ - triangle= (int)(UI_UNIT_Y * 1.1f); + triangle = (int)(UI_UNIT_Y * 1.1f); if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) { /* for enabled buttons */ - panel->layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, - triangle, UI_UNIT_Y+style->panelspace+2, UI_UNIT_Y, 1, style); + panel->layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, + triangle, UI_UNIT_Y + style->panelspace + 2, UI_UNIT_Y, 1, style); pt->draw_header(C, panel); uiBlockLayoutResolve(block, &xco, &yco); - panel->labelofs= xco - triangle; - panel->layout= NULL; + panel->labelofs = xco - triangle; + panel->layout = NULL; } else { - panel->labelofs= 0; + panel->labelofs = 0; } if (open) { @@ -1615,23 +1615,23 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * /* panel context can either be toolbar region or normal panels region */ if (ar->regiontype == RGN_TYPE_TOOLS) - panelContext= UI_LAYOUT_TOOLBAR; + panelContext = UI_LAYOUT_TOOLBAR; else - panelContext= UI_LAYOUT_PANEL; + panelContext = UI_LAYOUT_PANEL; - panel->layout= uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, - style->panelspace, 0, w-2*style->panelspace, em, style); + panel->layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, panelContext, + style->panelspace, 0, w - 2 * style->panelspace, em, style); pt->draw(C, panel); uiBlockLayoutResolve(block, &xco, &yco); - panel->layout= NULL; + panel->layout = NULL; - yco -= 2*style->panelspace; + yco -= 2 * style->panelspace; uiEndPanel(block, w, -yco); } else { - yco= 0; + yco = 0; uiEndPanel(block, w, 0); } @@ -1643,28 +1643,28 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * uiEndPanels(C, ar, &x, &y); /* clear */ - UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW)?TH_PREVIEW_BACK:TH_BACK); + UI_ThemeClearColor((ar->type->regionid == RGN_TYPE_PREVIEW) ? TH_PREVIEW_BACK : TH_BACK); glClear(GL_COLOR_BUFFER_BIT); /* before setting the view */ if (vertical) { /* only allow scrolling in vertical direction */ - v2d->keepofs |= V2D_LOCKOFS_X|V2D_KEEPOFS_Y; - v2d->keepofs &= ~(V2D_LOCKOFS_Y|V2D_KEEPOFS_X); + v2d->keepofs |= V2D_LOCKOFS_X | V2D_KEEPOFS_Y; + v2d->keepofs &= ~(V2D_LOCKOFS_Y | V2D_KEEPOFS_X); v2d->scroll |= V2D_SCROLL_HORIZONTAL_HIDE; v2d->scroll &= ~V2D_SCROLL_VERTICAL_HIDE; // don't jump back when panels close or hide if (!newcontext) - y= MAX2(-y, -v2d->cur.ymin); + y = MAX2(-y, -v2d->cur.ymin); else - y= -y; + y = -y; } else { /* for now, allow scrolling in both directions (since layouts are optimized for vertical, * they often don't fit in horizontal layout) */ - v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_LOCKOFS_Y|V2D_KEEPOFS_X|V2D_KEEPOFS_Y); + v2d->keepofs &= ~(V2D_LOCKOFS_X | V2D_LOCKOFS_Y | V2D_KEEPOFS_X | V2D_KEEPOFS_Y); //v2d->keepofs |= V2D_LOCKOFS_Y|V2D_KEEPOFS_X; //v2d->keepofs &= ~(V2D_LOCKOFS_X|V2D_KEEPOFS_Y); v2d->scroll |= V2D_SCROLL_VERTICAL_HIDE; @@ -1672,12 +1672,12 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * // don't jump back when panels close or hide if (!newcontext) - x= MAX2(x, v2d->cur.xmax); - y= -y; + x = MAX2(x, v2d->cur.xmax); + y = -y; } // +V2D_SCROLL_HEIGHT is workaround to set the actual height - UI_view2d_totRect_set(v2d, x+V2D_SCROLL_WIDTH, y+V2D_SCROLL_HEIGHT); + UI_view2d_totRect_set(v2d, x + V2D_SCROLL_WIDTH, y + V2D_SCROLL_HEIGHT); /* set the view */ UI_view2d_view_ortho(v2d); @@ -1689,7 +1689,7 @@ void ED_region_panels(const bContext *C, ARegion *ar, int vertical, const char * UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -1699,13 +1699,13 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) wmKeyMap *keymap; // XXX quick hacks for files saved with 2.5 already (i.e. the builtin defaults file) - // scrollbars for button regions - ar->v2d.scroll |= (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + // scrollbars for button regions + ar->v2d.scroll |= (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); ar->v2d.scroll |= V2D_SCROLL_HORIZONTAL_HIDE; ar->v2d.scroll &= ~V2D_SCROLL_VERTICAL_HIDE; ar->v2d.keepzoom |= V2D_KEEPZOOM; - // correctly initialized User-Prefs? + // correctly initialized User-Prefs? if (!(ar->v2d.align & V2D_ALIGN_NO_POS_Y)) ar->v2d.flag &= ~V2D_IS_INITIALISED; @@ -1717,52 +1717,52 @@ void ED_region_panels_init(wmWindowManager *wm, ARegion *ar) void ED_region_header(const bContext *C, ARegion *ar) { - uiStyle *style= UI_GetStyle(); + uiStyle *style = UI_GetStyle(); uiBlock *block; uiLayout *layout; HeaderType *ht; Header header = {NULL}; int maxco, xco, yco; - int headery= ED_area_headersize(); + int headery = ED_area_headersize(); /* clear */ - UI_ThemeClearColor((ED_screen_area_active(C))?TH_HEADER:TH_HEADERDESEL); + UI_ThemeClearColor((ED_screen_area_active(C)) ? TH_HEADER : TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(&ar->v2d); - xco= maxco= 8; - yco= headery-4; + xco = maxco = 8; + yco = headery - 4; /* draw all headers types */ - for (ht= ar->type->headertypes.first; ht; ht= ht->next) { - block= uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); - layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style); + for (ht = ar->type->headertypes.first; ht; ht = ht->next) { + block = uiBeginBlock(C, ar, ht->idname, UI_EMBOSS); + layout = uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style); if (ht->draw) { - header.type= ht; - header.layout= layout; + header.type = ht; + header.layout = layout; ht->draw(C, &header); /* for view2d */ - xco= uiLayoutGetWidth(layout); + xco = uiLayoutGetWidth(layout); if (xco > maxco) - maxco= xco; + maxco = xco; } uiBlockLayoutResolve(block, &xco, &yco); /* for view2d */ if (xco > maxco) - maxco= xco; + maxco = xco; uiEndBlock(C, block); uiDrawBlock(C, block); } /* always as last */ - UI_view2d_totRect_set(&ar->v2d, maxco+UI_UNIT_X+80, ar->v2d.tot.ymax-ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, maxco + UI_UNIT_X + 80, ar->v2d.tot.ymax - ar->v2d.tot.ymin); /* restore view matrix? */ UI_view2d_view_restore(C); @@ -1776,20 +1776,20 @@ void ED_region_header_init(ARegion *ar) /* UI_UNIT_Y is defined as U variable now, depending dpi */ int ED_area_headersize(void) { - return UI_UNIT_Y+6; + return UI_UNIT_Y + 6; } void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) { const int header_height = 18; - uiStyle *style= UI_GetStyle(); - int fontid= style->widget.uifont_id; + uiStyle *style = UI_GetStyle(); + int fontid = style->widget.uifont_id; rcti rect; BLF_size(fontid, 11.0f, 72); /* background box */ - rect= ar->winrct; + rect = ar->winrct; rect.xmin = 0; rect.ymin = ar->winrct.ymax - ar->winrct.ymin - header_height; @@ -1805,7 +1805,7 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha) glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.0f, 0.0f, 0.0f, alpha); - glRecti(rect.xmin, rect.ymin, rect.xmax+1, rect.ymax+1); + glRecti(rect.xmin, rect.ymin, rect.xmax + 1, rect.ymax + 1); glDisable(GL_BLEND); /* text */ diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 69db65fda1c..0f1ffb856e7 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -92,7 +92,7 @@ GLubyte stipple_quarttone[128] = { GLubyte stipple_diag_stripes_pos[128] = { - 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, + 0x00, 0xff, 0x00, 0xff, 0x01, 0xfe, 0x01, 0xfe, 0x03, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x07, 0xf8, 0x0f, 0xf0, 0x0f, 0xf0, 0x1f, 0xe0, 0x1f, 0xe0, 0x3f, 0xc0, 0x3f, 0xc0, 0x7f, 0x80, 0x7f, 0x80, @@ -111,7 +111,7 @@ GLubyte stipple_diag_stripes_pos[128] = { GLubyte stipple_diag_stripes_neg[128] = { - 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, + 0xff, 0x00, 0xff, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfc, 0x03, 0xfc, 0x03, 0xf8, 0x07, 0xf8, 0x07, 0xf0, 0x0f, 0xf0, 0x0f, 0xe0, 0x1f, 0xe0, 0x1f, 0xc0, 0x3f, 0xc0, 0x3f, 0x80, 0x7f, 0x80, 0x7f, @@ -134,16 +134,16 @@ void fdrawbezier(float vec[4][3]) float dist; float curve_res = 24, spline_step = 0.0f; - dist= 0.5f*ABS(vec[0][0] - vec[3][0]); + dist = 0.5f * ABS(vec[0][0] - vec[3][0]); /* check direction later, for top sockets */ - vec[1][0]= vec[0][0]+dist; - vec[1][1]= vec[0][1]; + vec[1][0] = vec[0][0] + dist; + vec[1][1] = vec[0][1]; - vec[2][0]= vec[3][0]-dist; - vec[2][1]= vec[3][1]; + vec[2][0] = vec[3][0] - dist; + vec[2][1] = vec[3][1]; /* we can reuse the dist variable here to increment the GL curve eval amount*/ - dist = 1.0f/curve_res; + dist = 1.0f / curve_res; cpack(0x0); glMap1f(GL_MAP1_VERTEX_3, 0.0, 1.0, 3, 4, vec[0]); @@ -193,7 +193,7 @@ void fdrawbox(float x1, float y1, float x2, float y2) void fdrawcheckerboard(float x1, float y1, float x2, float y2) { - unsigned char col1[4]= {40, 40, 40}, col2[4]= {50, 50, 50}; + unsigned char col1[4] = {40, 40, 40}, col2[4] = {50, 50, 50}; GLubyte checker_stipple[32 * 32 / 8] = { 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, 255, 0, @@ -238,11 +238,11 @@ void sdrawline(short x1, short y1, short x2, short y2) static void sdrawtripoints(short x1, short y1, short x2, short y2) { short v[2]; - v[0]= x1; v[1]= y1; + v[0] = x1; v[1] = y1; glVertex2sv(v); - v[0]= x1; v[1]= y2; + v[0] = x1; v[1] = y2; glVertex2sv(v); - v[0]= x2; v[1]= y1; + v[0] = x2; v[1] = y1; glVertex2sv(v); } @@ -285,7 +285,7 @@ void sdrawbox(short x1, short y1, short x2, short y2) void setlinestyle(int nr) { - if (nr==0) { + if (nr == 0) { glDisable(GL_LINE_STIPPLE); } else { @@ -295,20 +295,20 @@ void setlinestyle(int nr) } } - /* Invert line handling */ +/* Invert line handling */ -#define gl_toggle(mode, onoff) (((onoff)?glEnable:glDisable)(mode)) +#define gl_toggle(mode, onoff) (((onoff) ? glEnable : glDisable)(mode)) void set_inverted_drawing(int enable) { - glLogicOp(enable?GL_INVERT:GL_COPY); + glLogicOp(enable ? GL_INVERT : GL_COPY); gl_toggle(GL_COLOR_LOGIC_OP, enable); gl_toggle(GL_DITHER, !enable); } void sdrawXORline(int x0, int y0, int x1, int y1) { - if (x0==x1 && y0==y1) return; + if (x0 == x1 && y0 == y1) return; set_inverted_drawing(1); @@ -323,35 +323,35 @@ void sdrawXORline(int x0, int y0, int x1, int y1) void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) { static short old[4][2][2]; - static char flags[4]= {0, 0, 0, 0}; + static char flags[4] = {0, 0, 0, 0}; - /* with builtin memory, max 4 lines */ + /* with builtin memory, max 4 lines */ set_inverted_drawing(1); glBegin(GL_LINES); - if (nr== -1) { /* flush */ - for (nr=0; nr<4; nr++) { + if (nr == -1) { /* flush */ + for (nr = 0; nr < 4; nr++) { if (flags[nr]) { glVertex2sv(old[nr][0]); glVertex2sv(old[nr][1]); - flags[nr]= 0; + flags[nr] = 0; } } } else { - if (nr>=0 && nr<4) { + if (nr >= 0 && nr < 4) { if (flags[nr]) { glVertex2sv(old[nr][0]); glVertex2sv(old[nr][1]); } - old[nr][0][0]= x0; - old[nr][0][1]= y0; - old[nr][1][0]= x1; - old[nr][1][1]= y1; + old[nr][0][0] = x0; + old[nr][0][1] = y0; + old[nr][1][0] = x1; + old[nr][1][1] = y1; - flags[nr]= 1; + flags[nr] = 1; } glVertex2i(x0, y0); @@ -364,14 +364,14 @@ void sdrawXORline4(int nr, int x0, int y0, int x1, int y1) void fdrawXORellipse(float xofs, float yofs, float hw, float hh) { - if (hw==0) return; + if (hw == 0) return; set_inverted_drawing(1); glPushMatrix(); glTranslatef(xofs, yofs, 0.0f); glScalef(1.0f, hh / hw, 1.0f); - glutil_draw_lined_arc(0.0, M_PI*2.0, hw, 20); + glutil_draw_lined_arc(0.0, M_PI * 2.0, hw, 20); glPopMatrix(); set_inverted_drawing(0); @@ -382,7 +382,7 @@ void fdrawXORcirc(float xofs, float yofs, float rad) glPushMatrix(); glTranslatef(xofs, yofs, 0.0); - glutil_draw_lined_arc(0.0, M_PI*2.0, rad, 20); + glutil_draw_lined_arc(0.0, M_PI * 2.0, rad, 20); glPopMatrix(); set_inverted_drawing(0); @@ -394,11 +394,11 @@ void glutil_draw_filled_arc(float start, float angle, float radius, int nsegment glBegin(GL_TRIANGLE_FAN); glVertex2f(0.0, 0.0); - for (i=0; i2 && tex_h>2)? 2: 0; + seamless = ((tex_w < img_w || tex_h < img_h) && tex_w > 2 && tex_h > 2) ? 2 : 0; - offset_x= tex_w - seamless; - offset_y= tex_h - seamless; + offset_x = tex_w - seamless; + offset_y = tex_h - seamless; - nsubparts_x= (img_w + (offset_x - 1))/(offset_x); - nsubparts_y= (img_h + (offset_y - 1))/(offset_y); + nsubparts_x = (img_w + (offset_x - 1)) / (offset_x); + nsubparts_y = (img_h + (offset_y - 1)) / (offset_y); - for (subpart_y=0; subpart_ytex_w)? 1: 0; - int offset_top= (seamless && remainder_y>tex_h)? 1: 0; - float rast_x= x+subpart_x*offset_x*xzoom; - float rast_y= y+subpart_y*offset_y*yzoom; + for (subpart_y = 0; subpart_y < nsubparts_y; subpart_y++) { + for (subpart_x = 0; subpart_x < nsubparts_x; subpart_x++) { + int remainder_x = img_w - subpart_x * offset_x; + int remainder_y = img_h - subpart_y * offset_y; + int subpart_w = (remainder_x < tex_w) ? remainder_x : tex_w; + int subpart_h = (remainder_y < tex_h) ? remainder_y : tex_h; + int offset_left = (seamless && subpart_x != 0) ? 1 : 0; + int offset_bot = (seamless && subpart_y != 0) ? 1 : 0; + int offset_right = (seamless && remainder_x > tex_w) ? 1 : 0; + int offset_top = (seamless && remainder_y > tex_h) ? 1 : 0; + float rast_x = x + subpart_x * offset_x * xzoom; + float rast_y = y + subpart_y * offset_y * yzoom; /* check if we already got these because we always get 2 more when doing seamless*/ - if (subpart_w<=seamless || subpart_h<=seamless) + if (subpart_w <= seamless || subpart_h <= seamless) continue; - if (format==GL_FLOAT) { - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y*offset_y*img_w*4 + subpart_x*offset_x*4]); + if (format == GL_FLOAT) { + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, subpart_w, subpart_h, GL_RGBA, GL_FLOAT, &f_rect[subpart_y * offset_y * img_w * 4 + subpart_x * offset_x * 4]); /* add an extra border of pixels so linear looks ok at edges of full image. */ - if (subpart_w0 && draw_h>0) { + if (draw_w > 0 && draw_h > 0) { int old_row_length = glaGetOneInteger(GL_UNPACK_ROW_LENGTH); - /* Don't use safe RasterPos (slower) if we can avoid it. */ - if (rast_x>=0 && rast_y>=0) { + /* Don't use safe RasterPos (slower) if we can avoid it. */ + if (rast_x >= 0 && rast_y >= 0) { glRasterPos2f(rast_x, rast_y); } else { @@ -639,24 +639,24 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo } glPixelStorei(GL_UNPACK_ROW_LENGTH, row_w); - if (format==GL_LUMINANCE || format==GL_RED) { - if (type==GL_FLOAT) { - float *f_rect= (float *)rect; - glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)); + if (format == GL_LUMINANCE || format == GL_RED) { + if (type == GL_FLOAT) { + float *f_rect = (float *)rect; + glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y * row_w + off_x)); } - else if (type==GL_INT || type==GL_UNSIGNED_INT) { - int *i_rect= (int *)rect; - glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y*row_w + off_x)); + else if (type == GL_INT || type == GL_UNSIGNED_INT) { + int *i_rect = (int *)rect; + glDrawPixels(draw_w, draw_h, format, type, i_rect + (off_y * row_w + off_x)); } } else { /* RGBA */ - if (type==GL_FLOAT) { - float *f_rect= (float *)rect; - glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y*row_w + off_x)*4); + if (type == GL_FLOAT) { + float *f_rect = (float *)rect; + glDrawPixels(draw_w, draw_h, format, type, f_rect + (off_y * row_w + off_x) * 4); } - else if (type==GL_UNSIGNED_BYTE) { - unsigned char *uc_rect= (unsigned char *) rect; - glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y*row_w + off_x)*4); + else if (type == GL_UNSIGNED_BYTE) { + unsigned char *uc_rect = (unsigned char *) rect; + glDrawPixels(draw_w, draw_h, format, type, uc_rect + (off_y * row_w + off_x) * 4); } } @@ -668,17 +668,17 @@ void glaDrawPixelsSafe(float x, float y, int img_w, int img_h, int row_w, int fo void glaDefine2DArea(rcti *screen_rect) { - int sc_w= screen_rect->xmax - screen_rect->xmin + 1; - int sc_h= screen_rect->ymax - screen_rect->ymin + 1; + int sc_w = screen_rect->xmax - screen_rect->xmin + 1; + int sc_h = screen_rect->ymax - screen_rect->ymin + 1; glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); - /* The 0.375 magic number is to shift the matrix so that - * both raster and vertex integer coordinates fall at pixel - * centers properly. For a longer discussion see the OpenGL - * Programming Guide, Appendix H, Correctness Tips. - */ + /* The 0.375 magic number is to shift the matrix so that + * both raster and vertex integer coordinates fall at pixel + * centers properly. For a longer discussion see the OpenGL + * Programming Guide, Appendix H, Correctness Tips. + */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -703,7 +703,7 @@ struct gla2DDrawInfo { void gla2DGetMap(gla2DDrawInfo *di, rctf *rect) { - *rect= di->world_rect; + *rect = di->world_rect; } void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) @@ -711,20 +711,20 @@ void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) int sc_w, sc_h; float wo_w, wo_h; - di->world_rect= *rect; + di->world_rect = *rect; - sc_w= (di->screen_rect.xmax-di->screen_rect.xmin); - sc_h= (di->screen_rect.ymax-di->screen_rect.ymin); - wo_w= (di->world_rect.xmax-di->world_rect.xmin); - wo_h= (di->world_rect.ymax-di->world_rect.ymin); + sc_w = (di->screen_rect.xmax - di->screen_rect.xmin); + sc_h = (di->screen_rect.ymax - di->screen_rect.ymin); + wo_w = (di->world_rect.xmax - di->world_rect.xmin); + wo_h = (di->world_rect.ymax - di->world_rect.ymin); - di->wo_to_sc[0]= sc_w/wo_w; - di->wo_to_sc[1]= sc_h/wo_h; + di->wo_to_sc[0] = sc_w / wo_w; + di->wo_to_sc[1] = sc_h / wo_h; } gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) { - gla2DDrawInfo *di= MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); + gla2DDrawInfo *di = MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); int sc_w, sc_h; float wo_w, wo_h; @@ -733,9 +733,9 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) glGetFloatv(GL_PROJECTION_MATRIX, (GLfloat *)di->orig_projmat); glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat *)di->orig_viewmat); - di->screen_rect= *screen_rect; + di->screen_rect = *screen_rect; if (world_rect) { - di->world_rect= *world_rect; + di->world_rect = *world_rect; } else { di->world_rect.xmin = di->screen_rect.xmin; @@ -744,13 +744,13 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) di->world_rect.ymax = di->screen_rect.ymax; } - sc_w= (di->screen_rect.xmax-di->screen_rect.xmin); - sc_h= (di->screen_rect.ymax-di->screen_rect.ymin); - wo_w= (di->world_rect.xmax-di->world_rect.xmin); - wo_h= (di->world_rect.ymax-di->world_rect.ymin); + sc_w = (di->screen_rect.xmax - di->screen_rect.xmin); + sc_h = (di->screen_rect.ymax - di->screen_rect.ymin); + wo_w = (di->world_rect.xmax - di->world_rect.xmin); + wo_h = (di->world_rect.ymax - di->world_rect.ymin); - di->wo_to_sc[0]= sc_w/wo_w; - di->wo_to_sc[1]= sc_h/wo_h; + di->wo_to_sc[0] = sc_w / wo_w; + di->wo_to_sc[1] = sc_h / wo_h; glaDefine2DArea(&di->screen_rect); @@ -759,13 +759,13 @@ gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *sc_x_r, int *sc_y_r) { - *sc_x_r= (wo_x - di->world_rect.xmin)*di->wo_to_sc[0]; - *sc_y_r= (wo_y - di->world_rect.ymin)*di->wo_to_sc[1]; + *sc_x_r = (wo_x - di->world_rect.xmin) * di->wo_to_sc[0]; + *sc_y_r = (wo_y - di->world_rect.ymin) * di->wo_to_sc[1]; } void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int screen_r[2]) { - screen_r[0]= (world[0] - di->world_rect.xmin)*di->wo_to_sc[0]; - screen_r[1]= (world[1] - di->world_rect.ymin)*di->wo_to_sc[1]; + screen_r[0] = (world[0] - di->world_rect.xmin) * di->wo_to_sc[0]; + screen_r[1] = (world[1] - di->world_rect.ymin) * di->wo_to_sc[1]; } void glaEnd2DDraw(gla2DDrawInfo *di) @@ -783,8 +783,8 @@ void glaEnd2DDraw(gla2DDrawInfo *di) /* **************** GL_POINT hack ************************ */ -static int curmode=0; -static int pointhack=0; +static int curmode = 0; +static int pointhack = 0; static GLubyte Squaredot[16] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, @@ -792,15 +792,15 @@ static GLubyte Squaredot[16] = {0xff, 0xff, 0xff, 0xff, void bglBegin(int mode) { - curmode= mode; + curmode = mode; - if (mode==GL_POINTS) { + if (mode == GL_POINTS) { float value[4]; glGetFloatv(GL_POINT_SIZE_RANGE, value); if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); - pointhack= floor(value[0] + 0.5f); - if (pointhack>4) pointhack= 4; + pointhack = floor(value[0] + 0.5f); + if (pointhack > 4) pointhack = 4; } else glBegin(mode); } @@ -814,8 +814,8 @@ int bglPointHack(void) glGetFloatv(GL_POINT_SIZE_RANGE, value); if (value[1] < 2.0f) { glGetFloatv(GL_POINT_SIZE, value); - pointhack_px= floorf(value[0]+0.5f); - if (pointhack_px>4) pointhack_px= 4; + pointhack_px = floorf(value[0] + 0.5f); + if (pointhack_px > 4) pointhack_px = 4; return pointhack_px; } return 0; @@ -825,46 +825,46 @@ int bglPointHack(void) void bglVertex3fv(const float vec[3]) { switch (curmode) { - case GL_POINTS: - if (pointhack) { - glRasterPos3fv(vec); - glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); - } - else glVertex3fv(vec); - break; + case GL_POINTS: + if (pointhack) { + glRasterPos3fv(vec); + glBitmap(pointhack, pointhack, (float)pointhack / 2.0f, (float)pointhack / 2.0f, 0.0, 0.0, Squaredot); + } + else glVertex3fv(vec); + break; } } void bglVertex3f(float x, float y, float z) { switch (curmode) { - case GL_POINTS: - if (pointhack) { - glRasterPos3f(x, y, z); - glBitmap(pointhack, pointhack, (float)pointhack/2.0f, (float)pointhack/2.0f, 0.0, 0.0, Squaredot); - } - else glVertex3f(x, y, z); - break; + case GL_POINTS: + if (pointhack) { + glRasterPos3f(x, y, z); + glBitmap(pointhack, pointhack, (float)pointhack / 2.0f, (float)pointhack / 2.0f, 0.0, 0.0, Squaredot); + } + else glVertex3f(x, y, z); + break; } } void bglVertex2fv(const float vec[2]) { switch (curmode) { - case GL_POINTS: - if (pointhack) { - glRasterPos2fv(vec); - glBitmap(pointhack, pointhack, (float)pointhack/2, pointhack/2, 0.0, 0.0, Squaredot); - } - else glVertex2fv(vec); - break; + case GL_POINTS: + if (pointhack) { + glRasterPos2fv(vec); + glBitmap(pointhack, pointhack, (float)pointhack / 2, pointhack / 2, 0.0, 0.0, Squaredot); + } + else glVertex2fv(vec); + break; } } void bglEnd(void) { - if (pointhack) pointhack= 0; + if (pointhack) pointhack = 0; else glEnd(); } @@ -872,7 +872,7 @@ void bglEnd(void) /* Uses current OpenGL state to get view matrices for gluProject/gluUnProject */ void bgl_get_mats(bglMats *mats) { - const double badvalue= 1.0e-6; + const double badvalue = 1.0e-6; glGetDoublev(GL_MODELVIEW_MATRIX, mats->modelview); glGetDoublev(GL_PROJECTION_MATRIX, mats->projection); @@ -901,7 +901,7 @@ void bgl_get_mats(bglMats *mats) /* dist is only for ortho now... */ void bglPolygonOffset(float viewdist, float dist) { - static float winmat[16], offset=0.0; + static float winmat[16], offset = 0.0; if (dist != 0.0f) { float offs; @@ -915,11 +915,11 @@ void bglPolygonOffset(float viewdist, float dist) /* dist is from camera to center point */ - if (winmat[15]>0.5f) offs= 0.00001f*dist*viewdist; // ortho tweaking - else offs= 0.0005f*dist; // should be clipping value or so... + if (winmat[15] > 0.5f) offs = 0.00001f * dist * viewdist; // ortho tweaking + else offs = 0.0005f * dist; // should be clipping value or so... - winmat[14]-= offs; - offset+= offs; + winmat[14] -= offs; + offset += offs; glLoadMatrixf(winmat); glMatrixMode(GL_MODELVIEW); @@ -927,8 +927,8 @@ void bglPolygonOffset(float viewdist, float dist) else { glMatrixMode(GL_PROJECTION); - winmat[14]+= offset; - offset= 0.0; + winmat[14] += offset; + offset = 0.0; glLoadMatrixf(winmat); glMatrixMode(GL_MODELVIEW); } diff --git a/source/blender/editors/screen/screen_context.c b/source/blender/editors/screen/screen_context.c index 9e044068468..352039c5a61 100644 --- a/source/blender/editors/screen/screen_context.c +++ b/source/blender/editors/screen/screen_context.c @@ -72,19 +72,19 @@ const char *screen_context_dir[] = { int ed_screen_context(const bContext *C, const char *member, bContextDataResult *result) { - bScreen *sc= CTX_wm_screen(C); - Scene *scene= sc->scene; + bScreen *sc = CTX_wm_screen(C); + Scene *scene = sc->scene; Base *base; unsigned int lay = scene->lay; -#if 0 /* Using the context breaks adding objects in the UI. Need to find out why - campbell */ - Object *obact= CTX_data_active_object(C); - Object *obedit= CTX_data_edit_object(C); - base= CTX_data_active_base(C); +#if 0 /* Using the context breaks adding objects in the UI. Need to find out why - campbell */ + Object *obact = CTX_data_active_object(C); + Object *obedit = CTX_data_edit_object(C); + base = CTX_data_active_base(C); #else - Object *obedit= scene->obedit; - Object *obact= OBACT; - base= BASACT; + Object *obedit = scene->obedit; + Object *obact = OBACT; + base = BASACT; #endif if (CTX_data_dir(member)) { @@ -96,9 +96,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "visible_objects") || CTX_data_equals(member, "visible_bases")) { - int visible_objects= CTX_data_equals(member, "visible_objects"); + int visible_objects = CTX_data_equals(member, "visible_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) && (base->lay & scene->lay)) { if (visible_objects) CTX_data_id_list_add(result, &base->object->id); @@ -110,11 +110,11 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selectable_objects") || CTX_data_equals(member, "selectable_bases")) { - int selectable_objects= CTX_data_equals(member, "selectable_objects"); + int selectable_objects = CTX_data_equals(member, "selectable_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & lay) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0 && (base->object->restrictflag & OB_RESTRICT_SELECT)==0) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0 && (base->object->restrictflag & OB_RESTRICT_SELECT) == 0) { if (selectable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -126,9 +126,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selected_objects") || CTX_data_equals(member, "selected_bases")) { - int selected_objects= CTX_data_equals(member, "selected_objects"); + int selected_objects = CTX_data_equals(member, "selected_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & scene->lay)) { if (selected_objects) CTX_data_id_list_add(result, &base->object->id); @@ -140,12 +140,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "selected_editable_objects") || CTX_data_equals(member, "selected_editable_bases")) { - int selected_editable_objects= CTX_data_equals(member, "selected_editable_objects"); + int selected_editable_objects = CTX_data_equals(member, "selected_editable_objects"); - for (base=scene->base.first; base; base=base->next) { + for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & scene->lay)) { - if ((base->object->restrictflag & OB_RESTRICT_VIEW)==0) { - if (0==object_is_libdata(base->object)) { + if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { + if (0 == BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else @@ -158,13 +158,13 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "visible_bones") || CTX_data_equals(member, "editable_bones")) { - bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; - EditBone *ebone, *flipbone=NULL; - int editable_bones= CTX_data_equals(member, "editable_bones"); + bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; + EditBone *ebone, *flipbone = NULL; + int editable_bones = CTX_data_equals(member, "editable_bones"); if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled @@ -190,7 +190,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult /* only include bones if visible */ CTX_data_list_add(result, &arm->id, &RNA_EditBone, ebone); - if ((flipbone) && EBONE_VISIBLE(arm, flipbone)==0) + if ((flipbone) && EBONE_VISIBLE(arm, flipbone) == 0) CTX_data_list_add(result, &arm->id, &RNA_EditBone, flipbone); } } @@ -200,13 +200,13 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_bones") || CTX_data_equals(member, "selected_editable_bones")) { - bArmature *arm= (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; - EditBone *ebone, *flipbone=NULL; - int selected_editable_bones= CTX_data_equals(member, "selected_editable_bones"); + bArmature *arm = (obedit && obedit->type == OB_ARMATURE) ? obedit->data : NULL; + EditBone *ebone, *flipbone = NULL; + int selected_editable_bones = CTX_data_equals(member, "selected_editable_bones"); if (arm && arm->edbo) { /* Attention: X-Axis Mirroring is also handled here... */ - for (ebone= arm->edbo->first; ebone; ebone= ebone->next) { + for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { /* first and foremost, bone must be visible and selected */ if (EBONE_VISIBLE(arm, ebone) && (ebone->flag & BONE_SELECTED)) { /* Get 'x-axis mirror equivalent' bone if the X-Axis Mirroring option is enabled @@ -242,12 +242,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "visible_pose_bones")) { - Object *obpose= object_pose_armature_get(obact); - bArmature *arm= (obpose) ? obpose->data : NULL; + Object *obpose = BKE_object_pose_armature_get(obact); + bArmature *arm = (obpose) ? obpose->data : NULL; bPoseChannel *pchan; if (obpose && obpose->pose && arm) { - for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if (PBONE_VISIBLE(arm, pchan->bone)) { CTX_data_list_add(result, &obpose->id, &RNA_PoseBone, pchan); @@ -258,12 +258,12 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_pose_bones")) { - Object *obpose= object_pose_armature_get(obact); - bArmature *arm= (obpose) ? obpose->data : NULL; + Object *obpose = BKE_object_pose_armature_get(obact); + bArmature *arm = (obpose) ? obpose->data : NULL; bPoseChannel *pchan; if (obpose && obpose->pose && arm) { - for (pchan= obpose->pose->chanbase.first; pchan; pchan= pchan->next) { + for (pchan = obpose->pose->chanbase.first; pchan; pchan = pchan->next) { /* ensure that PoseChannel is on visible layer and is not hidden in PoseMode */ if (PBONE_VISIBLE(arm, pchan->bone)) { if (pchan->bone->flag & BONE_SELECTED) @@ -276,7 +276,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "active_bone")) { if (obact && obact->type == OB_ARMATURE) { - bArmature *arm= obact->data; + bArmature *arm = obact->data; if (arm->edbo) { if (arm->act_edbone) { CTX_data_pointer_set(result, &arm->id, &RNA_EditBone, arm->act_edbone); @@ -293,9 +293,9 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } else if (CTX_data_equals(member, "active_pose_bone")) { bPoseChannel *pchan; - Object *obpose= object_pose_armature_get(obact); + Object *obpose = BKE_object_pose_armature_get(obact); - pchan= get_active_posechannel(obpose); + pchan = BKE_pose_channel_active(obpose); if (pchan) { CTX_data_pointer_set(result, &obpose->id, &RNA_PoseBone, pchan); return 1; @@ -357,10 +357,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult return 1; } else if (CTX_data_equals(member, "sequences")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { Sequence *seq; - for (seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq = ed->seqbasep->first; seq; seq = seq->next) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } CTX_data_type_set(result, CTX_DATA_TYPE_COLLECTION); @@ -368,10 +368,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_sequences")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { Sequence *seq; - for (seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } @@ -381,10 +381,10 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "selected_editable_sequences")) { - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { Sequence *seq; - for (seq= ed->seqbasep->first; seq; seq= seq->next) { + for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT && !(seq->flag & SEQ_LOCK)) { CTX_data_list_add(result, &scene->id, &RNA_Sequence, seq); } @@ -394,19 +394,19 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult } } else if (CTX_data_equals(member, "active_operator")) { - wmOperator *op= NULL; + wmOperator *op = NULL; - SpaceFile *sfile= CTX_wm_space_file(C); + SpaceFile *sfile = CTX_wm_space_file(C); if (sfile) { - op= sfile->op; + op = sfile->op; } - else if ((op= uiContextActiveOperator(C))) { + else if ((op = uiContextActiveOperator(C))) { /* do nothign */ } else { /* note, this checks poll, could be a problem, but this also * happens for the toolbar */ - op= WM_operator_last_redo(C); + op = WM_operator_last_redo(C); } /* TODO, get the operator from popup's */ diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 512cd404273..d714f82b58b 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -66,16 +66,16 @@ /* XXX actually should be not here... solve later */ #include "wm_subwindow.h" -#include "screen_intern.h" /* own module include */ +#include "screen_intern.h" /* own module include */ /* ******************* screen vert, edge, area managing *********************** */ static ScrVert *screen_addvert(bScreen *sc, short x, short y) { - ScrVert *sv= MEM_callocN(sizeof(ScrVert), "addscrvert"); - sv->vec.x= x; - sv->vec.y= y; + ScrVert *sv = MEM_callocN(sizeof(ScrVert), "addscrvert"); + sv->vec.x = x; + sv->vec.y = y; BLI_addtail(&sc->vertbase, sv); return sv; @@ -86,19 +86,19 @@ static void sortscrvert(ScrVert **v1, ScrVert **v2) ScrVert *tmp; if (*v1 > *v2) { - tmp= *v1; - *v1= *v2; - *v2= tmp; + tmp = *v1; + *v1 = *v2; + *v2 = tmp; } } static ScrEdge *screen_addedge(bScreen *sc, ScrVert *v1, ScrVert *v2) { - ScrEdge *se= MEM_callocN(sizeof(ScrEdge), "addscredge"); + ScrEdge *se = MEM_callocN(sizeof(ScrEdge), "addscredge"); sortscrvert(&v1, &v2); - se->v1= v1; - se->v2= v2; + se->v1 = v1; + se->v2 = v2; BLI_addtail(&sc->edgebase, se); return se; @@ -110,8 +110,8 @@ ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2) ScrEdge *se; sortscrvert(&v1, &v2); - for (se= sc->edgebase.first; se; se= se->next) - if (se->v1==v1 && se->v2==v2) + for (se = sc->edgebase.first; se; se = se->next) + if (se->v1 == v1 && se->v2 == v2) return se; return NULL; @@ -123,50 +123,50 @@ void removedouble_scrverts(bScreen *sc) ScrEdge *se; ScrArea *sa; - verg= sc->vertbase.first; + verg = sc->vertbase.first; while (verg) { - if (verg->newv==NULL) { /* !!! */ - v1= verg->next; + if (verg->newv == NULL) { /* !!! */ + v1 = verg->next; while (v1) { - if (v1->newv==NULL) { /* !?! */ - if (v1->vec.x==verg->vec.x && v1->vec.y==verg->vec.y) { + if (v1->newv == NULL) { /* !?! */ + if (v1->vec.x == verg->vec.x && v1->vec.y == verg->vec.y) { /* printf("doublevert\n"); */ - v1->newv= verg; + v1->newv = verg; } } - v1= v1->next; + v1 = v1->next; } } - verg= verg->next; + verg = verg->next; } /* replace pointers in edges and faces */ - se= sc->edgebase.first; + se = sc->edgebase.first; while (se) { - if (se->v1->newv) se->v1= se->v1->newv; - if (se->v2->newv) se->v2= se->v2->newv; + if (se->v1->newv) se->v1 = se->v1->newv; + if (se->v2->newv) se->v2 = se->v2->newv; /* edges changed: so.... */ sortscrvert(&(se->v1), &(se->v2)); - se= se->next; + se = se->next; } - sa= sc->areabase.first; + sa = sc->areabase.first; while (sa) { - if (sa->v1->newv) sa->v1= sa->v1->newv; - if (sa->v2->newv) sa->v2= sa->v2->newv; - if (sa->v3->newv) sa->v3= sa->v3->newv; - if (sa->v4->newv) sa->v4= sa->v4->newv; - sa= sa->next; + if (sa->v1->newv) sa->v1 = sa->v1->newv; + if (sa->v2->newv) sa->v2 = sa->v2->newv; + if (sa->v3->newv) sa->v3 = sa->v3->newv; + if (sa->v4->newv) sa->v4 = sa->v4->newv; + sa = sa->next; } /* remove */ - verg= sc->vertbase.first; + verg = sc->vertbase.first; while (verg) { - v1= verg->next; + v1 = verg->next; if (verg->newv) { BLI_remlink(&sc->vertbase, verg); MEM_freeN(verg); } - verg= v1; + verg = v1; } } @@ -178,22 +178,22 @@ void removenotused_scrverts(bScreen *sc) /* we assume edges are ok */ - se= sc->edgebase.first; + se = sc->edgebase.first; while (se) { - se->v1->flag= 1; - se->v2->flag= 1; - se= se->next; + se->v1->flag = 1; + se->v2->flag = 1; + se = se->next; } - sv= sc->vertbase.first; + sv = sc->vertbase.first; while (sv) { - svn= sv->next; - if (sv->flag==0) { + svn = sv->next; + if (sv->flag == 0) { BLI_remlink(&sc->vertbase, sv); MEM_freeN(sv); } - else sv->flag= 0; - sv= svn; + else sv->flag = 0; + sv = svn; } } @@ -202,18 +202,18 @@ void removedouble_scredges(bScreen *sc) ScrEdge *verg, *se, *sn; /* compare */ - verg= sc->edgebase.first; + verg = sc->edgebase.first; while (verg) { - se= verg->next; + se = verg->next; while (se) { - sn= se->next; - if (verg->v1==se->v1 && verg->v2==se->v2) { + sn = se->next; + if (verg->v1 == se->v1 && verg->v2 == se->v2) { BLI_remlink(&sc->edgebase, se); MEM_freeN(se); } - se= sn; + se = sn; } - verg= verg->next; + verg = verg->next; } } @@ -221,35 +221,35 @@ void removenotused_scredges(bScreen *sc) { ScrEdge *se, *sen; ScrArea *sa; - int a=0; + int a = 0; /* sets flags when edge is used in area */ - sa= sc->areabase.first; + sa = sc->areabase.first; while (sa) { - se= screen_findedge(sc, sa->v1, sa->v2); - if (se==NULL) printf("error: area %d edge 1 doesn't exist\n", a); - else se->flag= 1; - se= screen_findedge(sc, sa->v2, sa->v3); - if (se==NULL) printf("error: area %d edge 2 doesn't exist\n", a); - else se->flag= 1; - se= screen_findedge(sc, sa->v3, sa->v4); - if (se==NULL) printf("error: area %d edge 3 doesn't exist\n", a); - else se->flag= 1; - se= screen_findedge(sc, sa->v4, sa->v1); - if (se==NULL) printf("error: area %d edge 4 doesn't exist\n", a); - else se->flag= 1; - sa= sa->next; + se = screen_findedge(sc, sa->v1, sa->v2); + if (se == NULL) printf("error: area %d edge 1 doesn't exist\n", a); + else se->flag = 1; + se = screen_findedge(sc, sa->v2, sa->v3); + if (se == NULL) printf("error: area %d edge 2 doesn't exist\n", a); + else se->flag = 1; + se = screen_findedge(sc, sa->v3, sa->v4); + if (se == NULL) printf("error: area %d edge 3 doesn't exist\n", a); + else se->flag = 1; + se = screen_findedge(sc, sa->v4, sa->v1); + if (se == NULL) printf("error: area %d edge 4 doesn't exist\n", a); + else se->flag = 1; + sa = sa->next; a++; } - se= sc->edgebase.first; + se = sc->edgebase.first; while (se) { - sen= se->next; - if (se->flag==0) { + sen = se->next; + if (se->flag == 0) { BLI_remlink(&sc->edgebase, se); MEM_freeN(se); } - else se->flag= 0; - se= sen; + else se->flag = 0; + se = sen; } } @@ -262,21 +262,21 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my) { ScrEdge *se; - for (se= sc->edgebase.first; se; se= se->next) { + for (se = sc->edgebase.first; se; se = se->next) { if (scredge_is_horizontal(se)) { short min, max; - min= MIN2(se->v1->vec.x, se->v2->vec.x); - max= MAX2(se->v1->vec.x, se->v2->vec.x); + min = MIN2(se->v1->vec.x, se->v2->vec.x); + max = MAX2(se->v1->vec.x, se->v2->vec.x); - if (abs(my-se->v1->vec.y)<=2 && mx>=min && mx<=max) + if (abs(my - se->v1->vec.y) <= 2 && mx >= min && mx <= max) return se; } else { short min, max; - min= MIN2(se->v1->vec.y, se->v2->vec.y); - max= MAX2(se->v1->vec.y, se->v2->vec.y); + min = MIN2(se->v1->vec.y, se->v2->vec.y); + max = MAX2(se->v1->vec.y, se->v2->vec.y); - if (abs(mx-se->v1->vec.x)<=2 && my>=min && my<=max) + if (abs(mx - se->v1->vec.x) <= 2 && my >= min && my <= max) return se; } } @@ -289,13 +289,13 @@ ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my) /* adds no space data */ static ScrArea *screen_addarea(bScreen *sc, ScrVert *v1, ScrVert *v2, ScrVert *v3, ScrVert *v4, short headertype, short spacetype) { - ScrArea *sa= MEM_callocN(sizeof(ScrArea), "addscrarea"); - sa->v1= v1; - sa->v2= v2; - sa->v3= v3; - sa->v4= v4; - sa->headertype= headertype; - sa->spacetype= sa->butspacetype= spacetype; + ScrArea *sa = MEM_callocN(sizeof(ScrArea), "addscrarea"); + sa->v1 = v1; + sa->v2 = v2; + sa->v3 = v3; + sa->v4 = v4; + sa->headertype = headertype; + sa->spacetype = sa->butspacetype = spacetype; BLI_addtail(&sc->areabase, sa); @@ -320,31 +320,31 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) short x, y; // area big enough? - if (dir=='v' && (sa->v4->vec.x- sa->v1->vec.x <= 2*AREAMINX)) return 0; - if (dir=='h' && (sa->v2->vec.y- sa->v1->vec.y <= 2*AREAMINY)) return 0; + if (dir == 'v' && (sa->v4->vec.x - sa->v1->vec.x <= 2 * AREAMINX)) return 0; + if (dir == 'h' && (sa->v2->vec.y - sa->v1->vec.y <= 2 * AREAMINY)) return 0; // to be sure CLAMP(fac, 0.0f, 1.0f); - if (dir=='h') { - y= sa->v1->vec.y+ fac*(sa->v2->vec.y- sa->v1->vec.y); + if (dir == 'h') { + y = sa->v1->vec.y + fac * (sa->v2->vec.y - sa->v1->vec.y); - if (y- sa->v1->vec.y < AREAMINY) - y= sa->v1->vec.y+ AREAMINY; - else if (sa->v2->vec.y- y < AREAMINY) - y= sa->v2->vec.y- AREAMINY; - else y-= (y % AREAGRID); + if (y - sa->v1->vec.y < AREAMINY) + y = sa->v1->vec.y + AREAMINY; + else if (sa->v2->vec.y - y < AREAMINY) + y = sa->v2->vec.y - AREAMINY; + else y -= (y % AREAGRID); return y; } else { - x= sa->v1->vec.x+ fac*(sa->v4->vec.x- sa->v1->vec.x); + x = sa->v1->vec.x + fac * (sa->v4->vec.x - sa->v1->vec.x); - if (x- sa->v1->vec.x < AREAMINX) - x= sa->v1->vec.x+ AREAMINX; - else if (sa->v4->vec.x- x < AREAMINX) - x= sa->v4->vec.x- AREAMINX; - else x-= (x % AREAGRID); + if (x - sa->v1->vec.x < AREAMINX) + x = sa->v1->vec.x + AREAMINX; + else if (sa->v4->vec.x - x < AREAMINX) + x = sa->v4->vec.x - AREAMINX; + else x -= (x % AREAGRID); return x; } @@ -352,19 +352,19 @@ static short testsplitpoint(ScrArea *sa, char dir, float fac) ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) { - ScrArea *newa=NULL; + ScrArea *newa = NULL; ScrVert *sv1, *sv2; short split; - if (sa==NULL) return NULL; + if (sa == NULL) return NULL; - split= testsplitpoint(sa, dir, fac); - if (split==0) return NULL; + split = testsplitpoint(sa, dir, fac); + if (split == 0) return NULL; - if (dir=='h') { + if (dir == 'h') { /* new vertices */ - sv1= screen_addvert(sc, sa->v1->vec.x, split); - sv2= screen_addvert(sc, sa->v4->vec.x, split); + sv1 = screen_addvert(sc, sa->v1->vec.x, split); + sv2 = screen_addvert(sc, sa->v4->vec.x, split); /* new edges */ screen_addedge(sc, sa->v1, sv1); @@ -374,18 +374,18 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) screen_addedge(sc, sv1, sv2); /* new areas: top */ - newa= screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype); + newa = screen_addarea(sc, sv1, sa->v2, sa->v3, sv2, sa->headertype, sa->spacetype); area_copy_data(newa, sa, 0); /* area below */ - sa->v2= sv1; - sa->v3= sv2; + sa->v2 = sv1; + sa->v3 = sv2; } else { /* new vertices */ - sv1= screen_addvert(sc, split, sa->v1->vec.y); - sv2= screen_addvert(sc, split, sa->v2->vec.y); + sv1 = screen_addvert(sc, split, sa->v1->vec.y); + sv2 = screen_addvert(sc, split, sa->v2->vec.y); /* new edges */ screen_addedge(sc, sa->v1, sv1); @@ -395,12 +395,12 @@ ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge) screen_addedge(sc, sv1, sv2); /* new areas: left */ - newa= screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype); + newa = screen_addarea(sc, sa->v1, sa->v2, sv2, sv1, sa->headertype, sa->spacetype); area_copy_data(newa, sa, 0); /* area right */ - sa->v1= sv1; - sa->v2= sv2; + sa->v1 = sv1; + sa->v2 = sv2; } /* remove double vertices en edges */ @@ -419,16 +419,16 @@ bScreen *ED_screen_add(wmWindow *win, Scene *scene, const char *name) bScreen *sc; ScrVert *sv1, *sv2, *sv3, *sv4; - sc= alloc_libblock(&G.main->screen, ID_SCR, name); - sc->scene= scene; - sc->do_refresh= 1; - sc->redraws_flag= TIME_ALL_3D_WIN|TIME_ALL_ANIM_WIN; - sc->winid= win->winid; - - sv1= screen_addvert(sc, 0, 0); - sv2= screen_addvert(sc, 0, win->sizey-1); - sv3= screen_addvert(sc, win->sizex-1, win->sizey-1); - sv4= screen_addvert(sc, win->sizex-1, 0); + sc = BKE_libblock_alloc(&G.main->screen, ID_SCR, name); + sc->scene = scene; + sc->do_refresh = 1; + sc->redraws_flag = TIME_ALL_3D_WIN | TIME_ALL_ANIM_WIN; + sc->winid = win->winid; + + sv1 = screen_addvert(sc, 0, 0); + sv2 = screen_addvert(sc, 0, win->sizey - 1); + sv3 = screen_addvert(sc, win->sizex - 1, win->sizey - 1); + sv4 = screen_addvert(sc, win->sizex - 1, 0); screen_addedge(sc, sv1, sv2); screen_addedge(sc, sv2, sv3); @@ -448,42 +448,42 @@ static void screen_copy(bScreen *to, bScreen *from) ScrArea *sa, *saf; /* free contents of 'to', is from blenkernel screen.c */ - free_screen(to); + BKE_screen_free(to); BLI_duplicatelist(&to->vertbase, &from->vertbase); BLI_duplicatelist(&to->edgebase, &from->edgebase); BLI_duplicatelist(&to->areabase, &from->areabase); - to->regionbase.first= to->regionbase.last= NULL; + to->regionbase.first = to->regionbase.last = NULL; - s2= to->vertbase.first; - for (s1= from->vertbase.first; s1; s1= s1->next, s2= s2->next) { - s1->newv= s2; + s2 = to->vertbase.first; + for (s1 = from->vertbase.first; s1; s1 = s1->next, s2 = s2->next) { + s1->newv = s2; } - for (se= to->edgebase.first; se; se= se->next) { - se->v1= se->v1->newv; - se->v2= se->v2->newv; + for (se = to->edgebase.first; se; se = se->next) { + se->v1 = se->v1->newv; + se->v2 = se->v2->newv; sortscrvert(&(se->v1), &(se->v2)); } - saf= from->areabase.first; - for (sa= to->areabase.first; sa; sa= sa->next, saf= saf->next) { - sa->v1= sa->v1->newv; - sa->v2= sa->v2->newv; - sa->v3= sa->v3->newv; - sa->v4= sa->v4->newv; - - sa->spacedata.first= sa->spacedata.last= NULL; - sa->regionbase.first= sa->regionbase.last= NULL; - sa->actionzones.first= sa->actionzones.last= NULL; - sa->handlers.first= sa->handlers.last= NULL; + saf = from->areabase.first; + for (sa = to->areabase.first; sa; sa = sa->next, saf = saf->next) { + sa->v1 = sa->v1->newv; + sa->v2 = sa->v2->newv; + sa->v3 = sa->v3->newv; + sa->v4 = sa->v4->newv; + + sa->spacedata.first = sa->spacedata.last = NULL; + sa->regionbase.first = sa->regionbase.last = NULL; + sa->actionzones.first = sa->actionzones.last = NULL; + sa->handlers.first = sa->handlers.last = NULL; area_copy_data(sa, saf, 0); } /* put at zero (needed?) */ - for (s1= from->vertbase.first; s1; s1= s1->next) - s1->newv= NULL; + for (s1 = from->vertbase.first; s1; s1 = s1->next) + s1->newv = NULL; } @@ -496,27 +496,27 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) ScrVert *sav1, *sav2, *sav3, *sav4; ScrVert *sbv1, *sbv2, *sbv3, *sbv4; - if (sa==NULL || sb==NULL) return -1; + if (sa == NULL || sb == NULL) return -1; - sav1= sa->v1; - sav2= sa->v2; - sav3= sa->v3; - sav4= sa->v4; - sbv1= sb->v1; - sbv2= sb->v2; - sbv3= sb->v3; - sbv4= sb->v4; + sav1 = sa->v1; + sav2 = sa->v2; + sav3 = sa->v3; + sav4 = sa->v4; + sbv1 = sb->v1; + sbv2 = sb->v2; + sbv3 = sb->v3; + sbv4 = sb->v4; - if (sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ + if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ return 0; } - else if (sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ + else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */ return 1; } - else if (sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ + else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */ return 2; } - else if (sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ + else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ return 3; } @@ -524,9 +524,9 @@ int area_getorientation(ScrArea *sa, ScrArea *sb) } /* Helper function to join 2 areas, it has a return value, 0=failed 1=success - * used by the split, join operators + * used by the split, join operators */ -int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2) +int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2) { int dir; @@ -534,32 +534,32 @@ int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2) /*printf("dir is : %i\n", dir);*/ if (dir < 0) { - if (sa1 ) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; - if (sa2 ) sa2->flag &= ~AREA_FLAG_DRAWJOINTO; + if (sa1) sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; + if (sa2) sa2->flag &= ~AREA_FLAG_DRAWJOINTO; return 0; } if (dir == 0) { - sa1->v1= sa2->v1; - sa1->v2= sa2->v2; + sa1->v1 = sa2->v1; + sa1->v2 = sa2->v2; screen_addedge(scr, sa1->v2, sa1->v3); screen_addedge(scr, sa1->v1, sa1->v4); } else if (dir == 1) { - sa1->v2= sa2->v2; - sa1->v3= sa2->v3; + sa1->v2 = sa2->v2; + sa1->v3 = sa2->v3; screen_addedge(scr, sa1->v1, sa1->v2); screen_addedge(scr, sa1->v3, sa1->v4); } else if (dir == 2) { - sa1->v3= sa2->v3; - sa1->v4= sa2->v4; + sa1->v3 = sa2->v3; + sa1->v4 = sa2->v4; screen_addedge(scr, sa1->v2, sa1->v3); screen_addedge(scr, sa1->v1, sa1->v4); } else if (dir == 3) { - sa1->v1= sa2->v1; - sa1->v4= sa2->v4; + sa1->v1 = sa2->v1; + sa1->v4 = sa2->v4; screen_addedge(scr, sa1->v1, sa1->v2); screen_addedge(scr, sa1->v3, sa1->v4); } @@ -581,34 +581,38 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) /* select connected, only in the right direction */ /* 'dir' is the direction of EDGE */ - if (edge->v1->vec.x==edge->v2->vec.x) dir= 'v'; - else dir= 'h'; + if (edge->v1->vec.x == edge->v2->vec.x) dir = 'v'; + else dir = 'h'; - sv= sc->vertbase.first; + sv = sc->vertbase.first; while (sv) { sv->flag = 0; - sv= sv->next; + sv = sv->next; } - edge->v1->flag= 1; - edge->v2->flag= 1; + edge->v1->flag = 1; + edge->v2->flag = 1; - oneselected= 1; + oneselected = 1; while (oneselected) { - se= sc->edgebase.first; - oneselected= 0; + se = sc->edgebase.first; + oneselected = 0; while (se) { - if (se->v1->flag + se->v2->flag==1) { - if (dir=='h') if (se->v1->vec.y==se->v2->vec.y) { - se->v1->flag= se->v2->flag= 1; - oneselected= 1; - } - if (dir=='v') if (se->v1->vec.x==se->v2->vec.x) { - se->v1->flag= se->v2->flag= 1; - oneselected= 1; + if (se->v1->flag + se->v2->flag == 1) { + if (dir == 'h') { + if (se->v1->vec.y == se->v2->vec.y) { + se->v1->flag = se->v2->flag = 1; + oneselected = 1; } + } + if (dir == 'v') { + if (se->v1->vec.x == se->v2->vec.x) { + se->v1->flag = se->v2->flag = 1; + oneselected = 1; + } + } } - se= se->next; + se = se->next; } } } @@ -616,52 +620,52 @@ void select_connected_scredge(bScreen *sc, ScrEdge *edge) /* test if screen vertices should be scaled */ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) { - ScrVert *sv=NULL; + ScrVert *sv = NULL; ScrArea *sa; int sizex, sizey; float facx, facy, tempf, min[2], max[2]; /* calculate size */ - min[0]= min[1]= 10000.0f; - max[0]= max[1]= 0.0f; + min[0] = min[1] = 10000.0f; + max[0] = max[1] = 0.0f; - for (sv= sc->vertbase.first; sv; sv= sv->next) { - min[0]= MIN2(min[0], sv->vec.x); - min[1]= MIN2(min[1], sv->vec.y); - max[0]= MAX2(max[0], sv->vec.x); - max[1]= MAX2(max[1], sv->vec.y); + for (sv = sc->vertbase.first; sv; sv = sv->next) { + min[0] = MIN2(min[0], sv->vec.x); + min[1] = MIN2(min[1], sv->vec.y); + max[0] = MAX2(max[0], sv->vec.x); + max[1] = MAX2(max[1], sv->vec.y); } /* always make 0.0 left under */ - for (sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv = sc->vertbase.first; sv; sv = sv->next) { sv->vec.x -= min[0]; sv->vec.y -= min[1]; } - sizex= max[0]-min[0]; - sizey= max[1]-min[1]; + sizex = max[0] - min[0]; + sizey = max[1] - min[1]; - if (sizex!= winsizex || sizey!= winsizey) { - facx= winsizex; - facx/= (float)sizex; - facy= winsizey; - facy/= (float)sizey; + if (sizex != winsizex || sizey != winsizey) { + facx = winsizex; + facx /= (float)sizex; + facy = winsizey; + facy /= (float)sizey; /* make sure it fits! */ - for (sv= sc->vertbase.first; sv; sv= sv->next) { + for (sv = sc->vertbase.first; sv; sv = sv->next) { /* FIXME, this re-sizing logic is no good when re-sizing the window + redrawing [#24428] * need some way to store these as floats internally and re-apply from there. */ - tempf= ((float)sv->vec.x)*facx; - sv->vec.x= (short)(tempf+0.5f); - sv->vec.x+= AREAGRID-1; - sv->vec.x-= (sv->vec.x % AREAGRID); + tempf = ((float)sv->vec.x) * facx; + sv->vec.x = (short)(tempf + 0.5f); + sv->vec.x += AREAGRID - 1; + sv->vec.x -= (sv->vec.x % AREAGRID); CLAMP(sv->vec.x, 0, winsizex); - tempf= ((float)sv->vec.y)*facy; - sv->vec.y= (short)(tempf+0.5f); - sv->vec.y+= AREAGRID-1; - sv->vec.y-= (sv->vec.y % AREAGRID); + tempf = ((float)sv->vec.y) * facy; + sv->vec.y = (short)(tempf + 0.5f); + sv->vec.y += AREAGRID - 1; + sv->vec.y -= (sv->vec.y % AREAGRID); CLAMP(sv->vec.y, 0, winsizey); } @@ -671,26 +675,26 @@ static void screen_test_scale(bScreen *sc, int winsizex, int winsizey) /* ton: removed option now, it needs Context... */ /* make each window at least ED_area_headersize() high */ - for (sa= sc->areabase.first; sa; sa= sa->next) { - int headery= ED_area_headersize()+1; + for (sa = sc->areabase.first; sa; sa = sa->next) { + int headery = ED_area_headersize() + 1; - if (sa->v1->vec.y+headery > sa->v2->vec.y) { + if (sa->v1->vec.y + headery > sa->v2->vec.y) { /* lower edge */ - ScrEdge *se= screen_findedge(sc, sa->v4, sa->v1); - if (se && sa->v1!=sa->v2 ) { + ScrEdge *se = screen_findedge(sc, sa->v4, sa->v1); + if (se && sa->v1 != sa->v2) { int yval; select_connected_scredge(sc, se); /* all selected vertices get the right offset */ - yval= sa->v2->vec.y-headery; - sv= sc->vertbase.first; + yval = sa->v2->vec.y - headery; + sv = sc->vertbase.first; while (sv) { /* if is a collapsed area */ - if (sv!=sa->v2 && sv!=sa->v3) { - if (sv->flag) sv->vec.y= yval; + if (sv != sa->v2 && sv != sa->v3) { + if (sv->flag) sv->vec.y = yval; } - sv= sv->next; + sv = sv->next; } } } @@ -714,17 +718,17 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; - if (heightv1->vec.x; - points[0].y = sa->v1->vec.y + height/2; + points[0].y = sa->v1->vec.y + height / 2; points[1].x = sa->v1->vec.x; points[1].y = sa->v1->vec.y; @@ -733,13 +737,13 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) points[2].y = sa->v4->vec.y; points[3].x = sa->v4->vec.x - w; - points[3].y = sa->v4->vec.y + height/2 - 2*h; + points[3].y = sa->v4->vec.y + height / 2 - 2 * h; - points[4].x = sa->v4->vec.x - 2*w; - points[4].y = sa->v4->vec.y + height/2; + points[4].x = sa->v4->vec.x - 2 * w; + points[4].y = sa->v4->vec.y + height / 2; points[5].x = sa->v4->vec.x - w; - points[5].y = sa->v4->vec.y + height/2 + 2*h; + points[5].y = sa->v4->vec.y + height / 2 + 2 * h; points[6].x = sa->v3->vec.x - w; points[6].y = sa->v3->vec.y; @@ -748,15 +752,15 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) points[7].y = sa->v2->vec.y; points[8].x = sa->v4->vec.x; - points[8].y = sa->v4->vec.y + height/2 - h; + points[8].y = sa->v4->vec.y + height / 2 - h; points[9].x = sa->v4->vec.x; - points[9].y = sa->v4->vec.y + height/2 + h; + points[9].y = sa->v4->vec.y + height / 2 + h; - if (dir=='l') { + if (dir == 'l') { /* when direction is left, then we flip direction of arrow */ float cx = sa->v1->vec.x + width; - for (i=0;i<10;i++) { + for (i = 0; i < 10; i++) { points[i].x -= cx; points[i].x = -points[i].x; points[i].x += sa->v1->vec.x; @@ -764,11 +768,11 @@ static void draw_horizontal_join_shape(ScrArea *sa, char dir) } glBegin(GL_POLYGON); - for (i=0;i<5;i++) + for (i = 0; i < 5; i++) glVertex2f(points[i].x, points[i].y); glEnd(); glBegin(GL_POLYGON); - for (i=4;i<8;i++) + for (i = 4; i < 8; i++) glVertex2f(points[i].x, points[i].y); glVertex2f(points[0].x, points[0].y); glEnd(); @@ -786,16 +790,16 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) float width = sa->v3->vec.x - sa->v1->vec.x; float height = sa->v3->vec.y - sa->v1->vec.y; - if (heightv1->vec.x + width/2; + points[0].x = sa->v1->vec.x + width / 2; points[0].y = sa->v3->vec.y; points[1].x = sa->v2->vec.x; @@ -804,13 +808,13 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) points[2].x = sa->v1->vec.x; points[2].y = sa->v1->vec.y + h; - points[3].x = sa->v1->vec.x + width/2 - 2*w; + points[3].x = sa->v1->vec.x + width / 2 - 2 * w; points[3].y = sa->v1->vec.y + h; - points[4].x = sa->v1->vec.x + width/2; - points[4].y = sa->v1->vec.y + 2*h; + points[4].x = sa->v1->vec.x + width / 2; + points[4].y = sa->v1->vec.y + 2 * h; - points[5].x = sa->v1->vec.x + width/2 + 2*w; + points[5].x = sa->v1->vec.x + width / 2 + 2 * w; points[5].y = sa->v1->vec.y + h; points[6].x = sa->v4->vec.x; @@ -819,16 +823,16 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) points[7].x = sa->v3->vec.x; points[7].y = sa->v3->vec.y; - points[8].x = sa->v1->vec.x + width/2 - w; + points[8].x = sa->v1->vec.x + width / 2 - w; points[8].y = sa->v1->vec.y; - points[9].x = sa->v1->vec.x + width/2 + w; + points[9].x = sa->v1->vec.x + width / 2 + w; points[9].y = sa->v1->vec.y; - if (dir=='u') { + if (dir == 'u') { /* when direction is up, then we flip direction of arrow */ float cy = sa->v1->vec.y + height; - for (i=0;i<10;i++) { + for (i = 0; i < 10; i++) { points[i].y -= cy; points[i].y = -points[i].y; points[i].y += sa->v1->vec.y; @@ -836,11 +840,11 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) } glBegin(GL_POLYGON); - for (i=0;i<5;i++) + for (i = 0; i < 5; i++) glVertex2f(points[i].x, points[i].y); glEnd(); glBegin(GL_POLYGON); - for (i=4;i<8;i++) + for (i = 4; i < 8; i++) glVertex2f(points[i].x, points[i].y); glVertex2f(points[0].x, points[0].y); glEnd(); @@ -852,7 +856,7 @@ static void draw_vertical_join_shape(ScrArea *sa, char dir) /* draw join shape due to direction of joining */ static void draw_join_shape(ScrArea *sa, char dir) { - if (dir=='u' || dir=='d') + if (dir == 'u' || dir == 'd') draw_vertical_join_shape(sa, dir); else draw_horizontal_join_shape(sa, dir); @@ -883,38 +887,38 @@ static void scrarea_draw_shape_light(ScrArea *sa, char UNUSED(dir)) static void drawscredge_area_draw(int sizex, int sizey, short x1, short y1, short x2, short y2, short a) { /* right border area */ - if (x20) /* otherwise it draws the emboss of window over */ - sdrawline(x1+a, y1, x1+a, y2); + if (x1 > 0) /* otherwise it draws the emboss of window over */ + sdrawline(x1 + a, y1, x1 + a, y2); /* top border area */ - if (y20) - sdrawline(x1, y1+a, x2, y1+a); + if (y1 > 0) + sdrawline(x1, y1 + a, x2, y1 + a); } /** screen edges drawing **/ static void drawscredge_area(ScrArea *sa, int sizex, int sizey, int center) { - short x1= sa->v1->vec.x; - short y1= sa->v1->vec.y; - short x2= sa->v3->vec.x; - short y2= sa->v3->vec.y; + short x1 = sa->v1->vec.x; + short y1 = sa->v1->vec.y; + short x2 = sa->v3->vec.x; + short y2 = sa->v3->vec.y; short a, rt; - rt= 0; // CLAMPIS(G.rt, 0, 16); + rt = 0; // CLAMPIS(G.rt, 0, 16); - if (center==0) { + if (center == 0) { cpack(0x505050); - for (a=-rt; a<=rt; a++) - if (a!=0) + for (a = -rt; a <= rt; a++) + if (a != 0) drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, a); } else { @@ -929,10 +933,10 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) { bScreen *newsc; - if (sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ + if (sc->full != SCREENNORMAL) return NULL; /* XXX handle this case! */ /* make new empty screen: */ - newsc= ED_screen_add(win, sc->scene, sc->id.name+2); + newsc = ED_screen_add(win, sc->scene, sc->id.name + 2); /* copy all data */ screen_copy(newsc, sc); @@ -942,11 +946,11 @@ bScreen *ED_screen_duplicate(wmWindow *win, bScreen *sc) /* screen sets cursor based on swinid */ static void region_cursor_set(wmWindow *win, int swinid) { - ScrArea *sa= win->screen->areabase.first; + ScrArea *sa = win->screen->areabase.first; - for (;sa; sa= sa->next) { - ARegion *ar= sa->regionbase.first; - for (;ar; ar= ar->next) { + for (; sa; sa = sa->next) { + ARegion *ar = sa->regionbase.first; + for (; ar; ar = ar->next) { if (ar->swinid == swinid) { if (ar->type && ar->type->cursor) ar->type->cursor(win, sa, ar); @@ -960,25 +964,25 @@ static void region_cursor_set(wmWindow *win, int swinid) void ED_screen_do_listen(bContext *C, wmNotifier *note) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); /* generic notes */ switch (note->category) { case NC_WM: - if (note->data==ND_FILEREAD) - win->screen->do_draw= 1; + if (note->data == ND_FILEREAD) + win->screen->do_draw = 1; break; case NC_WINDOW: - win->screen->do_draw= 1; + win->screen->do_draw = 1; break; case NC_SCREEN: - if (note->data==ND_SUBWINACTIVE) + if (note->data == ND_SUBWINACTIVE) uiFreeActiveButtons(C, win->screen); - if (note->action==NA_EDITED) - win->screen->do_draw= win->screen->do_refresh= 1; + if (note->action == NA_EDITED) + win->screen->do_draw = win->screen->do_refresh = 1; break; case NC_SCENE: - if (note->data==ND_MODE) + if (note->data == ND_MODE) region_cursor_set(win, note->swinid); break; } @@ -988,21 +992,21 @@ void ED_screen_do_listen(bContext *C, wmNotifier *note) void ED_screen_draw(wmWindow *win) { ScrArea *sa; - ScrArea *sa1= NULL; - ScrArea *sa2= NULL; - ScrArea *sa3= NULL; + ScrArea *sa1 = NULL; + ScrArea *sa2 = NULL; + ScrArea *sa3 = NULL; int dir = -1; int dira = -1; wmSubWindowSet(win, win->screen->mainwin); - for (sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa = win->screen->areabase.first; sa; sa = sa->next) { if (sa->flag & AREA_FLAG_DRAWJOINFROM) sa1 = sa; if (sa->flag & AREA_FLAG_DRAWJOINTO) sa2 = sa; - if (sa->flag & (AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V)) sa3 = sa; + if (sa->flag & (AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V)) sa3 = sa; drawscredge_area(sa, win->sizex, win->sizey, 0); } - for (sa= win->screen->areabase.first; sa; sa= sa->next) + for (sa = win->screen->areabase.first; sa; sa = sa->next) drawscredge_area(sa, win->sizex, win->sizey, 1); /* blended join arrow */ @@ -1040,29 +1044,29 @@ void ED_screen_draw(wmWindow *win) if (sa3->flag & AREA_FLAG_DRAWSPLIT_H) { sdrawline(sa3->totrct.xmin, win->eventstate->y, sa3->totrct.xmax, win->eventstate->y); glColor4ub(0, 0, 0, 100); - sdrawline(sa3->totrct.xmin, win->eventstate->y+1, sa3->totrct.xmax, win->eventstate->y+1); + sdrawline(sa3->totrct.xmin, win->eventstate->y + 1, sa3->totrct.xmax, win->eventstate->y + 1); } else { sdrawline(win->eventstate->x, sa3->totrct.ymin, win->eventstate->x, sa3->totrct.ymax); glColor4ub(0, 0, 0, 100); - sdrawline(win->eventstate->x+1, sa3->totrct.ymin, win->eventstate->x+1, sa3->totrct.ymax); + sdrawline(win->eventstate->x + 1, sa3->totrct.ymin, win->eventstate->x + 1, sa3->totrct.ymax); } glDisable(GL_BLEND); } - win->screen->do_draw= 0; + win->screen->do_draw = 0; } /* helper call for below, dpi changes headers */ static void screen_refresh_headersizes(void) { - const ListBase *lb= BKE_spacetypes_list(); + const ListBase *lb = BKE_spacetypes_list(); SpaceType *st; - for (st= lb->first; st; st= st->next) { - ARegionType *art= BKE_regiontype_from_id(st, RGN_TYPE_HEADER); - if (art) art->prefsizey= ED_area_headersize(); + for (st = lb->first; st; st = st->next) { + ARegionType *art = BKE_regiontype_from_id(st, RGN_TYPE_HEADER); + if (art) art->prefsizey = ED_area_headersize(); } } @@ -1076,21 +1080,21 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) rcti winrct; winrct.xmin = 0; - winrct.xmax = win->sizex-1; + winrct.xmax = win->sizex - 1; winrct.ymin = 0; - winrct.ymax = win->sizey-1; + winrct.ymax = win->sizey - 1; screen_test_scale(win->screen, win->sizex, win->sizey); - if (win->screen->mainwin==0) - win->screen->mainwin= wm_subwindow_open(win, &winrct); + if (win->screen->mainwin == 0) + win->screen->mainwin = wm_subwindow_open(win, &winrct); else wm_subwindow_position(win, win->screen->mainwin, &winrct); /* header size depends on DPI, let's verify */ screen_refresh_headersizes(); - for (sa= win->screen->areabase.first; sa; sa= sa->next) { + for (sa = win->screen->areabase.first; sa; sa = sa->next) { /* set spacetype and region callbacks, calls init() */ /* sets subwindows for regions, adds handlers */ ED_area_initialize(wm, win, sa); @@ -1104,9 +1108,9 @@ void ED_screen_refresh(wmWindowManager *wm, wmWindow *win) if (G.debug & G_DEBUG_EVENTS) { printf("%s: set screen\n", __func__); } - win->screen->do_refresh= 0; + win->screen->do_refresh = 0; - win->screen->context= ed_screen_context; + win->screen->context = ed_screen_context; } /* file read, set all screens, ... */ @@ -1114,10 +1118,10 @@ void ED_screens_initialize(wmWindowManager *wm) { wmWindow *win; - for (win= wm->windows.first; win; win= win->next) { + for (win = wm->windows.first; win; win = win->next) { - if (win->screen==NULL) - win->screen= G.main->screen.first; + if (win->screen == NULL) + win->screen = G.main->screen.first; ED_screen_refresh(wm, win); } @@ -1128,28 +1132,28 @@ void ED_screens_initialize(wmWindowManager *wm) void ED_region_exit(bContext *C, ARegion *ar) { - ARegion *prevar= CTX_wm_region(C); + ARegion *prevar = CTX_wm_region(C); CTX_wm_region_set(C, ar); WM_event_remove_handlers(C, &ar->handlers); if (ar->swinid) wm_subwindow_close(CTX_wm_window(C), ar->swinid); - ar->swinid= 0; + ar->swinid = 0; if (ar->headerstr) MEM_freeN(ar->headerstr); - ar->headerstr= NULL; + ar->headerstr = NULL; CTX_wm_region_set(C, prevar); } void ED_area_exit(bContext *C, ScrArea *sa) { - ScrArea *prevsa= CTX_wm_area(C); + ScrArea *prevsa = CTX_wm_area(C); ARegion *ar; if (sa->spacetype == SPACE_FILE) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; if (sl && sl->spacetype == SPACE_FILE) { ED_fileselect_exit(C, (SpaceFile *)sl); } @@ -1159,7 +1163,7 @@ void ED_area_exit(bContext *C, ScrArea *sa) } CTX_wm_area_set(C, sa); - for (ar= sa->regionbase.first; ar; ar= ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) ED_region_exit(C, ar); WM_event_remove_handlers(C, &sa->handlers); @@ -1168,8 +1172,8 @@ void ED_area_exit(bContext *C, ScrArea *sa) void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *prevwin= CTX_wm_window(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *prevwin = CTX_wm_window(C); ScrArea *sa; ARegion *ar; @@ -1177,21 +1181,21 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) if (screen->animtimer) WM_event_remove_timer(wm, window, screen->animtimer); - screen->animtimer= NULL; + screen->animtimer = NULL; if (screen->mainwin) wm_subwindow_close(window, screen->mainwin); - screen->mainwin= 0; - screen->subwinactive= 0; + screen->mainwin = 0; + screen->subwinactive = 0; - for (ar= screen->regionbase.first; ar; ar= ar->next) + for (ar = screen->regionbase.first; ar; ar = ar->next) ED_region_exit(C, ar); - for (sa= screen->areabase.first; sa; sa= sa->next) + for (sa = screen->areabase.first; sa; sa = sa->next) ED_area_exit(C, sa); /* mark it available for use for other windows */ - screen->winid= 0; + screen->winid = 0; if (prevwin->screen->temp == 0) { /* use previous window if possible */ @@ -1209,17 +1213,17 @@ void ED_screen_exit(bContext *C, wmWindow *window, bScreen *screen) /* case when on area-edge or in azones, or outside window */ static void screen_cursor_set(wmWindow *win, wmEvent *event) { - AZone *az= NULL; + AZone *az = NULL; ScrArea *sa; - for (sa= win->screen->areabase.first; sa; sa= sa->next) - if ((az=is_in_area_actionzone(sa, event->x, event->y))) + for (sa = win->screen->areabase.first; sa; sa = sa->next) + if ((az = is_in_area_actionzone(sa, event->x, event->y))) break; if (sa) { - if (az->type==AZONE_AREA) + if (az->type == AZONE_AREA) WM_cursor_set(win, CURSOR_EDIT); - else if (az->type==AZONE_REGION) { + else if (az->type == AZONE_REGION) { if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) WM_cursor_set(win, CURSOR_X_MOVE); else @@ -1227,7 +1231,7 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) } } else { - ScrEdge *actedge= screen_find_active_scredge(win->screen, event->x, event->y); + ScrEdge *actedge = screen_find_active_scredge(win->screen, event->x, event->y); if (actedge) { if (scredge_is_horizontal(actedge)) @@ -1245,72 +1249,72 @@ static void screen_cursor_set(wmWindow *win, wmEvent *event) /* event type is mouse move */ void ED_screen_set_subwinactive(bContext *C, wmEvent *event) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); if (win->screen) { - bScreen *scr= win->screen; + bScreen *scr = win->screen; ScrArea *sa; ARegion *ar; - int oldswin= scr->subwinactive; + int oldswin = scr->subwinactive; - for (sa= scr->areabase.first; sa; sa= sa->next) { + for (sa = scr->areabase.first; sa; sa = sa->next) { if (event->x > sa->totrct.xmin && event->x < sa->totrct.xmax) if (event->y > sa->totrct.ymin && event->y < sa->totrct.ymax) - if (NULL==is_in_area_actionzone(sa, event->x, event->y)) + if (NULL == is_in_area_actionzone(sa, event->x, event->y)) break; } if (sa) { - for (ar= sa->regionbase.first; ar; ar= ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (BLI_in_rcti(&ar->winrct, event->x, event->y)) - scr->subwinactive= ar->swinid; + scr->subwinactive = ar->swinid; } } else - scr->subwinactive= scr->mainwin; + scr->subwinactive = scr->mainwin; /* check for redraw headers */ - if (oldswin!=scr->subwinactive) { + if (oldswin != scr->subwinactive) { - for (sa= scr->areabase.first; sa; sa= sa->next) { - int do_draw= 0; + for (sa = scr->areabase.first; sa; sa = sa->next) { + int do_draw = 0; - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->swinid==oldswin || ar->swinid==scr->subwinactive) - do_draw= 1; + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->swinid == oldswin || ar->swinid == scr->subwinactive) + do_draw = 1; if (do_draw) { - for (ar= sa->regionbase.first; ar; ar= ar->next) - if (ar->regiontype==RGN_TYPE_HEADER) + for (ar = sa->regionbase.first; ar; ar = ar->next) + if (ar->regiontype == RGN_TYPE_HEADER) ED_region_tag_redraw(ar); } } } /* cursors, for time being set always on edges, otherwise aregion doesnt switch */ - if (scr->subwinactive==scr->mainwin) { + if (scr->subwinactive == scr->mainwin) { screen_cursor_set(win, event); } - else if (oldswin!=scr->subwinactive) { + else if (oldswin != scr->subwinactive) { region_cursor_set(win, scr->subwinactive); - WM_event_add_notifier(C, NC_SCREEN|ND_SUBWINACTIVE, scr); + WM_event_add_notifier(C, NC_SCREEN | ND_SUBWINACTIVE, scr); } } } int ED_screen_area_active(const bContext *C) { - wmWindow *win= CTX_wm_window(C); - bScreen *sc= CTX_wm_screen(C); - ScrArea *sa= CTX_wm_area(C); + wmWindow *win = CTX_wm_window(C); + bScreen *sc = CTX_wm_screen(C); + ScrArea *sa = CTX_wm_area(C); if (win && sc && sa) { - AZone *az= is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); + AZone *az = is_in_area_actionzone(sa, win->eventstate->x, win->eventstate->y); ARegion *ar; if (az && az->type == AZONE_REGION) return 1; - for (ar= sa->regionbase.first; ar; ar= ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) if (ar->swinid == sc->subwinactive) return 1; } @@ -1321,35 +1325,35 @@ int ED_screen_area_active(const bContext *C) /* Do NOT call in area/region queues! */ void ED_screen_set(bContext *C, bScreen *sc) { - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); - bScreen *oldscreen= CTX_wm_screen(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + bScreen *oldscreen = CTX_wm_screen(C); ID *id; /* validate screen, it's called with notifier reference */ - for (id= CTX_data_main(C)->screen.first; id; id= id->next) + for (id = CTX_data_main(C)->screen.first; id; id = id->next) if (sc == (bScreen *)id) break; - if (id==NULL) + if (id == NULL) return; /* check for valid winid */ - if (sc->winid!=0 && sc->winid!=win->winid) + if (sc->winid != 0 && sc->winid != win->winid) return; - if (sc->full) { /* find associated full */ + if (sc->full) { /* find associated full */ bScreen *sc1; - for (sc1= CTX_data_main(C)->screen.first; sc1; sc1= sc1->id.next) { - ScrArea *sa= sc1->areabase.first; - if (sa->full==sc) { - sc= sc1; + for (sc1 = CTX_data_main(C)->screen.first; sc1; sc1 = sc1->id.next) { + ScrArea *sa = sc1->areabase.first; + if (sa->full == sc) { + sc = sc1; break; } } } if (oldscreen != sc) { - wmTimer *wt= oldscreen->animtimer; + wmTimer *wt = oldscreen->animtimer; ScrArea *sa; /* remove handlers referencing areas in old screen */ @@ -1358,22 +1362,22 @@ void ED_screen_set(bContext *C, bScreen *sc) } /* we put timer to sleep, so screen_exit has to think there's no timer */ - oldscreen->animtimer= NULL; + oldscreen->animtimer = NULL; if (wt) WM_event_timer_sleep(wm, win, wt, 1); ED_screen_exit(C, win, oldscreen); - oldscreen->animtimer= wt; + oldscreen->animtimer = wt; - win->screen= sc; - CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf + win->screen = sc; + CTX_wm_window_set(C, win); // stores C->wm.screen... hrmf /* prevent multiwin errors */ - sc->winid= win->winid; + sc->winid = win->winid; ED_screen_refresh(CTX_wm_manager(C), CTX_wm_window(C)); WM_event_add_notifier(C, NC_WINDOW, NULL); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENSET, sc); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENSET, sc); /* makes button hilites work */ WM_event_add_mousemove(C); @@ -1384,7 +1388,7 @@ static int ed_screen_used(wmWindowManager *wm, bScreen *sc) { wmWindow *win; - for (win=wm->windows.first; win; win=win->next) + for (win = wm->windows.first; win; win = win->next) if (win->screen == sc) return 1; @@ -1394,11 +1398,11 @@ static int ed_screen_used(wmWindowManager *wm, bScreen *sc) /* only call outside of area/region loops */ void ED_screen_delete(bContext *C, bScreen *sc) { - Main *bmain= CTX_data_main(C); - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); + Main *bmain = CTX_data_main(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); bScreen *newsc; - int delete= 1; + int delete = 1; /* don't allow deleting temp fullscreens for now */ if (sc->full == SCREENFULL) { @@ -1410,12 +1414,12 @@ void ED_screen_delete(bContext *C, bScreen *sc) * long as we are able to find a screen that is unused, we * can safely assume ours is not in use anywhere an delete it */ - for (newsc= sc->id.prev; newsc; newsc=newsc->id.prev) + for (newsc = sc->id.prev; newsc; newsc = newsc->id.prev) if (!ed_screen_used(wm, newsc)) break; if (!newsc) { - for (newsc= sc->id.next; newsc; newsc=newsc->id.next) + for (newsc = sc->id.next; newsc; newsc = newsc->id.next) if (!ed_screen_used(wm, newsc)) break; } @@ -1426,32 +1430,32 @@ void ED_screen_delete(bContext *C, bScreen *sc) ED_screen_set(C, newsc); if (delete && win->screen != sc) - free_libblock(&bmain->screen, sc); + BKE_libblock_free(&bmain->screen, sc); } /* only call outside of area/region loops */ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); bScreen *sc; if (screen == NULL) return; if (ed_screen_used(CTX_wm_manager(C), screen)) - ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_DO_UNDO); - for (sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { - if ((U.flag & USER_SCENEGLOBAL) || sc==screen) { + for (sc = CTX_data_main(C)->screen.first; sc; sc = sc->id.next) { + if ((U.flag & USER_SCENEGLOBAL) || sc == screen) { if (scene != sc->scene) { /* all areas endlocalview */ - // XXX ScrArea *sa= sc->areabase.first; - // while (sa) { - // endlocalview(sa); - // sa= sa->next; - // } - sc->scene= scene; + // XXX ScrArea *sa= sc->areabase.first; + // while (sa) { + // endlocalview(sa); + // sa= sa->next; + // } + sc->scene = scene; } } @@ -1460,42 +1464,42 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) // copy_view3d_lock(0); /* space.c */ /* are there cameras in the views that are not in the scene? */ - for (sc= CTX_data_main(C)->screen.first; sc; sc= sc->id.next) { - if ( (U.flag & USER_SCENEGLOBAL) || sc==screen) { - ScrArea *sa= sc->areabase.first; + for (sc = CTX_data_main(C)->screen.first; sc; sc = sc->id.next) { + if ( (U.flag & USER_SCENEGLOBAL) || sc == screen) { + ScrArea *sa = sc->areabase.first; while (sa) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; while (sl) { - if (sl->spacetype==SPACE_VIEW3D) { - View3D *v3d= (View3D*) sl; + if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *) sl; BKE_screen_view3d_sync(v3d, scene); - if (!v3d->camera || !object_in_scene(v3d->camera, scene)) { - v3d->camera= scene_find_camera(sc->scene); + if (!v3d->camera || !BKE_scene_base_find(scene, v3d->camera)) { + v3d->camera = BKE_scene_camera_find(sc->scene); // XXX if (sc==curscreen) handle_view3d_lock(); if (!v3d->camera) { ARegion *ar; - for (ar=v3d->regionbase.first; ar; ar= ar->next) { + for (ar = v3d->regionbase.first; ar; ar = ar->next) { if (ar->regiontype == RGN_TYPE_WINDOW) { - RegionView3D *rv3d= ar->regiondata; + RegionView3D *rv3d = ar->regiondata; - if (rv3d->persp==RV3D_CAMOB) - rv3d->persp= RV3D_PERSP; + if (rv3d->persp == RV3D_CAMOB) + rv3d->persp = RV3D_PERSP; } } } } } - sl= sl->next; + sl = sl->next; } - sa= sa->next; + sa = sa->next; } } } CTX_data_scene_set(C, scene); - set_scene_bg(bmain, scene); + BKE_scene_set_background(bmain, scene); ED_render_engine_changed(bmain); ED_update_for_newframe(bmain, scene, screen, 1); @@ -1508,29 +1512,29 @@ void ED_screen_set_scene(bContext *C, bScreen *screen, Scene *scene) /* only call outside of area/region loops */ void ED_screen_delete_scene(bContext *C, Scene *scene) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); Scene *newscene; if (scene->id.prev) - newscene= scene->id.prev; + newscene = scene->id.prev; else if (scene->id.next) - newscene= scene->id.next; + newscene = scene->id.next; else return; ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - unlink_scene(bmain, scene, newscene); + BKE_scene_unlink(bmain, scene, newscene); } ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) { - wmWindow *win= CTX_wm_window(C); - bScreen *screen= CTX_wm_screen(C); - ScrArea *newsa= NULL; + wmWindow *win = CTX_wm_window(C); + bScreen *screen = CTX_wm_screen(C); + ScrArea *newsa = NULL; - if (!sa || sa->full==NULL) { - newsa= ED_screen_full_toggle(C, win, sa); + if (!sa || sa->full == NULL) { + newsa = ED_screen_full_toggle(C, win, sa); } if (!newsa) { @@ -1538,7 +1542,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) /* if this has been called from the temporary info header generated in * temp fullscreen layouts, find the correct fullscreen area to change * to create a new space inside */ - for (newsa = screen->areabase.first; newsa; newsa=newsa->next) { + for (newsa = screen->areabase.first; newsa; newsa = newsa->next) { if (!(sa->flag & AREA_TEMP_INFO)) break; } @@ -1555,7 +1559,7 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) void ED_screen_full_prevspace(bContext *C, ScrArea *sa) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); ED_area_prevspace(C, sa); @@ -1566,7 +1570,7 @@ void ED_screen_full_prevspace(bContext *C, ScrArea *sa) /* restore a screen / area back to default operation, after temp fullscreen modes */ void ED_screen_full_restore(bContext *C, ScrArea *sa) { - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); SpaceLink *sl = sa->spacedata.first; /* if fullscreen area has a secondary space (such as a file browser or fullscreen render @@ -1579,13 +1583,13 @@ void ED_screen_full_restore(bContext *C, ScrArea *sa) /* Special check added for non-render image window (back from fullscreen through "Back to Previous" button) */ if (sl->spacetype == SPACE_IMAGE) { - SpaceImage *sima= sa->spacedata.first; + SpaceImage *sima = sa->spacedata.first; if (!(sima->flag & SI_PREVSPACE) && !(sima->flag & SI_FULLWINDOW)) sima_restore = 1; } if (sl->spacetype == SPACE_IMAGE && !sima_restore) { - SpaceImage *sima= sa->spacedata.first; + SpaceImage *sima = sa->spacedata.first; if (sima->flag & SI_PREVSPACE) sima->flag &= ~SI_PREVSPACE; if (sima->flag & SI_FULLWINDOW) { @@ -1616,7 +1620,7 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* ensure we don't have a button active anymore, can crash when * switching screens with tooltip open because region and tooltip * are no longer in the same screen */ - for (ar=sa->regionbase.first; ar; ar=ar->next) + for (ar = sa->regionbase.first; ar; ar = ar->next) uiFreeBlocks(C, &ar->uiblocks); /* prevent hanging header prints */ @@ -1627,76 +1631,76 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) ScrArea *old; /*short fulltype;*/ /*UNUSED*/ - sc= sa->full; /* the old screen to restore */ - oldscreen= win->screen; /* the one disappearing */ + sc = sa->full; /* the old screen to restore */ + oldscreen = win->screen; /* the one disappearing */ /*fulltype = sc->full;*/ - sc->full= 0; + sc->full = 0; /* removed: SCREENAUTOPLAY exception here */ /* find old area */ - for (old= sc->areabase.first; old; old= old->next) + for (old = sc->areabase.first; old; old = old->next) if (old->full) break; - if (old==NULL) { + if (old == NULL) { if (G.debug & G_DEBUG) printf("%s: something wrong in areafullscreen\n", __func__); return NULL; } - area_copy_data(old, sa, 1); /* 1 = swap spacelist */ + area_copy_data(old, sa, 1); /* 1 = swap spacelist */ if (sa->flag & AREA_TEMP_INFO) sa->flag &= ~AREA_TEMP_INFO; - old->full= NULL; + old->full = NULL; /* animtimer back */ - sc->animtimer= oldscreen->animtimer; - oldscreen->animtimer= NULL; + sc->animtimer = oldscreen->animtimer; + oldscreen->animtimer = NULL; ED_screen_set(C, sc); - free_screen(oldscreen); - free_libblock(&CTX_data_main(C)->screen, oldscreen); + BKE_screen_free(oldscreen); + BKE_libblock_free(&CTX_data_main(C)->screen, oldscreen); } else { ScrArea *newa; - char newname[MAX_ID_NAME-2]; + char newname[MAX_ID_NAME - 2]; - oldscreen= win->screen; + oldscreen = win->screen; /* nothing wrong with having only 1 area, as far as I can see... * is there only 1 area? */ #if 0 - if (oldscreen->areabase.first==oldscreen->areabase.last) + if (oldscreen->areabase.first == oldscreen->areabase.last) return NULL; #endif oldscreen->full = SCREENFULL; - BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name+2, "full"); - sc= ED_screen_add(win, oldscreen->scene, newname); + BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "full"); + sc = ED_screen_add(win, oldscreen->scene, newname); sc->full = SCREENFULL; // XXX /* timer */ - sc->animtimer= oldscreen->animtimer; - oldscreen->animtimer= NULL; + sc->animtimer = oldscreen->animtimer; + oldscreen->animtimer = NULL; /* returns the top small area */ - newa= area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1); + newa = area_split(sc, (ScrArea *)sc->areabase.first, 'h', 0.99f, 1); ED_area_newspace(C, newa, SPACE_INFO); /* use random area when we have no active one, e.g. when the * mouse is outside of the window and we open a file browser */ if (!sa) - sa= oldscreen->areabase.first; + sa = oldscreen->areabase.first; /* copy area */ - newa= newa->prev; - area_copy_data(newa, sa, 1); /* 1 = swap spacelist */ + newa = newa->prev; + area_copy_data(newa, sa, 1); /* 1 = swap spacelist */ sa->flag |= AREA_TEMP_INFO; - sa->full= oldscreen; - newa->full= oldscreen; - newa->next->full= oldscreen; // XXX + sa->full = oldscreen; + newa->full = oldscreen; + newa->next->full = oldscreen; // XXX ED_screen_set(C, sc); } @@ -1710,26 +1714,26 @@ ScrArea *ED_screen_full_toggle(bContext *C, wmWindow *win, ScrArea *sa) /* update frame rate info for viewport drawing */ void ED_refresh_viewport_fps(bContext *C) { - wmTimer *animtimer= CTX_wm_screen(C)->animtimer; - Scene *scene= CTX_data_scene(C); + wmTimer *animtimer = CTX_wm_screen(C)->animtimer; + Scene *scene = CTX_data_scene(C); /* is anim playback running? */ if (animtimer && (U.uiflag & USER_SHOW_FPS)) { - ScreenFrameRateInfo *fpsi= scene->fps_info; + ScreenFrameRateInfo *fpsi = scene->fps_info; /* if there isn't any info, init it first */ if (fpsi == NULL) - fpsi= scene->fps_info= MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info"); + fpsi = scene->fps_info = MEM_callocN(sizeof(ScreenFrameRateInfo), "refresh_viewport_fps fps_info"); /* update the values */ - fpsi->redrawtime= fpsi->lredrawtime; - fpsi->lredrawtime= animtimer->ltime; + fpsi->redrawtime = fpsi->lredrawtime; + fpsi->lredrawtime = animtimer->ltime; } else { /* playback stopped or shouldn't be running */ if (scene->fps_info) MEM_freeN(scene->fps_info); - scene->fps_info= NULL; + scene->fps_info = NULL; } } @@ -1738,56 +1742,56 @@ void ED_refresh_viewport_fps(bContext *C) */ void ED_screen_animation_timer(bContext *C, int redraws, int refresh, int sync, int enable) { - bScreen *screen= CTX_wm_screen(C); - wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *win= CTX_wm_window(C); - Scene *scene= CTX_data_scene(C); + bScreen *screen = CTX_wm_screen(C); + wmWindowManager *wm = CTX_wm_manager(C); + wmWindow *win = CTX_wm_window(C); + Scene *scene = CTX_data_scene(C); if (screen->animtimer) WM_event_remove_timer(wm, win, screen->animtimer); - screen->animtimer= NULL; + screen->animtimer = NULL; if (enable) { - ScreenAnimData *sad= MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); + ScreenAnimData *sad = MEM_callocN(sizeof(ScreenAnimData), "ScreenAnimData"); - screen->animtimer= WM_event_add_timer(wm, win, TIMER0, (1.0/FPS)); + screen->animtimer = WM_event_add_timer(wm, win, TIMER0, (1.0 / FPS)); - sad->ar= CTX_wm_region(C); + sad->ar = CTX_wm_region(C); /* if startframe is larger than current frame, we put currentframe on startframe. * note: first frame then is not drawn! (ton) */ if (scene->r.sfra > scene->r.cfra) { - sad->sfra= scene->r.cfra; - scene->r.cfra= scene->r.sfra; + sad->sfra = scene->r.cfra; + scene->r.cfra = scene->r.sfra; } else sad->sfra = scene->r.cfra; - sad->redraws= redraws; - sad->refresh= refresh; - sad->flag |= (enable < 0)? ANIMPLAY_FLAG_REVERSE: 0; - sad->flag |= (sync == 0)? ANIMPLAY_FLAG_NO_SYNC: (sync == 1)? ANIMPLAY_FLAG_SYNC: 0; + sad->redraws = redraws; + sad->refresh = refresh; + sad->flag |= (enable < 0) ? ANIMPLAY_FLAG_REVERSE : 0; + sad->flag |= (sync == 0) ? ANIMPLAY_FLAG_NO_SYNC : (sync == 1) ? ANIMPLAY_FLAG_SYNC : 0; - screen->animtimer->customdata= sad; + screen->animtimer->customdata = sad; } /* notifier catched by top header, for button */ - WM_event_add_notifier(C, NC_SCREEN|ND_ANIMPLAY, screen); + WM_event_add_notifier(C, NC_SCREEN | ND_ANIMPLAY, screen); } /* helper for screen_animation_play() - only to be used for TimeLine */ static ARegion *time_top_left_3dwindow(bScreen *screen) { - ARegion *aret= NULL; + ARegion *aret = NULL; ScrArea *sa; - int min= 10000; + int min = 10000; - for (sa= screen->areabase.first; sa; sa= sa->next) { - if (sa->spacetype==SPACE_VIEW3D) { + for (sa = screen->areabase.first; sa; sa = sa->next) { + if (sa->spacetype == SPACE_VIEW3D) { ARegion *ar; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { if (ar->winrct.xmin - ar->winrct.ymin < min) { - aret= ar; - min= ar->winrct.xmin - ar->winrct.ymin; + aret = ar; + min = ar->winrct.xmin - ar->winrct.ymin; } } } @@ -1800,14 +1804,14 @@ static ARegion *time_top_left_3dwindow(bScreen *screen) void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) { if (screen && screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; + wmTimer *wt = screen->animtimer; + ScreenAnimData *sad = wt->customdata; - sad->redraws= redraws; - sad->refresh= refresh; - sad->ar= NULL; + sad->redraws = redraws; + sad->refresh = refresh; + sad->ar = NULL; if (redraws & TIME_REGION) - sad->ar= time_top_left_3dwindow(screen); + sad->ar = time_top_left_3dwindow(screen); } } @@ -1816,12 +1820,12 @@ void ED_screen_animation_timer_update(bScreen *screen, int redraws, int refresh) void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUSED(mute)) { #ifdef DURIAN_CAMERA_SWITCH - void *camera= scene_camera_switch_find(scene); + void *camera = BKE_scene_camera_switch_find(scene); if (camera && scene->camera != camera) { bScreen *sc; - scene->camera= camera; + scene->camera = camera; /* are there cameras in the views that are not in the scene? */ - for (sc= bmain->screen.first; sc; sc= sc->id.next) { + for (sc = bmain->screen.first; sc; sc = sc->id.next) { BKE_screen_view3d_scene_sync(sc); } } @@ -1830,14 +1834,14 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS //extern void audiostream_scrub(unsigned int frame); /* seqaudio.c */ /* update animated image textures for gpu, etc, - * call before scene_update_for_newframe so modifiers with textures don't lag 1 frame */ + * call before BKE_scene_update_for_newframe so modifiers with textures don't lag 1 frame */ ED_image_update_frame(bmain, scene->r.cfra); ED_clip_update_frame(bmain, scene->r.cfra); /* this function applies the changes too */ /* XXX future: do all windows */ - scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ + BKE_scene_update_for_newframe(bmain, scene, BKE_screen_visible_layers(screen, scene)); /* BKE_scene.h */ //if ( (CFRA>1) && (!mute) && (scene->r.audio.flag & AUDIO_SCRUB)) // audiostream_scrub( CFRA ); @@ -1855,7 +1859,7 @@ void ED_update_for_newframe(Main *bmain, Scene *scene, bScreen *screen, int UNUS /* update animated texture nodes */ { Tex *tex; - for (tex= bmain->tex.first; tex; tex= tex->id.next) + for (tex = bmain->tex.first; tex; tex = tex->id.next) if (tex->use_nodes && tex->nodetree) { ntreeTexTagAnimated(tex->nodetree); } diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 90533fd3a12..aa11c3eecdd 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -35,24 +35,24 @@ struct wmWindow; struct Scene; -#define AZONESPOT 12 +#define AZONESPOT 12 /* area.c */ -void area_copy_data (ScrArea *sa1, ScrArea *sa2, int swap_space); +void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space); /* screen_edit.c */ -ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2); -ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge); -int screen_area_join(bContext *C, bScreen* scr, ScrArea *sa1, ScrArea *sa2); -int area_getorientation(ScrArea *sa, ScrArea *sb); -void select_connected_scredge(bScreen *sc, ScrEdge *edge); +ScrEdge *screen_findedge(bScreen *sc, ScrVert *v1, ScrVert *v2); +ScrArea *area_split(bScreen *sc, ScrArea *sa, char dir, float fac, int merge); +int screen_area_join(bContext *C, bScreen *scr, ScrArea *sa1, ScrArea *sa2); +int area_getorientation(ScrArea *sa, ScrArea *sb); +void select_connected_scredge(bScreen *sc, ScrEdge *edge); -void removenotused_scrverts(bScreen *sc); -void removedouble_scrverts(bScreen *sc); -void removedouble_scredges(bScreen *sc); -void removenotused_scredges(bScreen *sc); -int scredge_is_horizontal(ScrEdge *se); -ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); +void removenotused_scrverts(bScreen *sc); +void removedouble_scrverts(bScreen *sc); +void removedouble_scredges(bScreen *sc); +void removenotused_scredges(bScreen *sc); +int scredge_is_horizontal(ScrEdge *se); +ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my); struct AZone *is_in_area_actionzone(ScrArea *sa, int x, int y); @@ -66,7 +66,3 @@ void SCREEN_OT_screenshot(struct wmOperatorType *ot); void SCREEN_OT_screencast(struct wmOperatorType *ot); #endif /* __SCREEN_INTERN_H__ */ - - - - diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 49672b77d43..52e1f90606f 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -78,35 +78,35 @@ #include "wm_window.h" -#include "screen_intern.h" /* own module include */ +#include "screen_intern.h" /* own module include */ -#define KM_MODAL_CANCEL 1 -#define KM_MODAL_APPLY 2 -#define KM_MODAL_STEP10 3 -#define KM_MODAL_STEP10_OFF 4 +#define KM_MODAL_CANCEL 1 +#define KM_MODAL_APPLY 2 +#define KM_MODAL_STEP10 3 +#define KM_MODAL_STEP10_OFF 4 /* ************** Exported Poll tests ********************** */ int ED_operator_regionactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_region(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_region(C) == NULL) return 0; return 1; } int ED_operator_areaactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_area(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_area(C) == NULL) return 0; return 1; } int ED_operator_screenactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; return 1; } @@ -114,8 +114,8 @@ int ED_operator_screenactive(bContext *C) static int ED_operator_screenactive_norender(bContext *C) { if (G.rendering) return 0; - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; return 1; } @@ -134,28 +134,28 @@ static int screen_active_editable(bContext *C) /* when mouse is over area-edge */ int ED_operator_screen_mainwinactive(bContext *C) { - if (CTX_wm_window(C)==NULL) return 0; - if (CTX_wm_screen(C)==NULL) return 0; - if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0; + if (CTX_wm_window(C) == NULL) return 0; + if (CTX_wm_screen(C) == NULL) return 0; + if (CTX_wm_screen(C)->subwinactive != CTX_wm_screen(C)->mainwin) return 0; return 1; } int ED_operator_scene_editable(bContext *C) { - Scene *scene= CTX_data_scene(C); - if (scene && scene->id.lib==NULL) + Scene *scene = CTX_data_scene(C); + if (scene && scene->id.lib == NULL) return 1; return 0; } int ED_operator_objectmode(bContext *C) { - Scene *scene= CTX_data_scene(C); - Object *obact= CTX_data_active_object(C); + Scene *scene = CTX_data_scene(C); + Object *obact = CTX_data_active_object(C); - if (scene==NULL || scene->id.lib) + if (scene == NULL || scene->id.lib) return 0; - if ( CTX_data_edit_object(C) ) + if (CTX_data_edit_object(C) ) return 0; /* add a check for ob->mode too? */ @@ -169,7 +169,7 @@ int ED_operator_objectmode(bContext *C) static int ed_spacetype_test(bContext *C, int type) { if (ED_operator_areaactive(C)) { - SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); + SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C); return sl && (sl->spacetype == type); } return 0; @@ -193,7 +193,7 @@ int ED_operator_region_view3d_active(bContext *C) int ED_operator_animview_active(bContext *C) { if (ED_operator_areaactive(C)) { - SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C); + SpaceLink *sl = (SpaceLink *)CTX_wm_space_data(C); if (sl && (ELEM5(sl->spacetype, SPACE_SEQ, SPACE_ACTION, SPACE_NLA, SPACE_IPO, SPACE_TIME))) return TRUE; } @@ -216,7 +216,7 @@ int ED_operator_outliner_active_no_editobject(bContext *C) { if (ed_spacetype_test(C, SPACE_OUTLINER)) { Object *ob = ED_object_active_context(C); - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (ob && ob == obedit) return 0; else @@ -242,7 +242,7 @@ int ED_operator_buttons_active(bContext *C) int ED_operator_node_active(bContext *C) { - SpaceNode *snode= CTX_wm_space_node(C); + SpaceNode *snode = CTX_wm_space_node(C); if (snode && snode->edittree) return 1; @@ -313,8 +313,8 @@ int ED_operator_object_active_editable_font(bContext *C) int ED_operator_editmesh(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_MESH) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_MESH) return NULL != BMEdit_FromObject(obedit); return 0; } @@ -335,19 +335,19 @@ int ED_operator_editmesh_region_view3d(bContext *C) int ED_operator_editarmature(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_ARMATURE) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_ARMATURE) return NULL != ((bArmature *)obedit->data)->edbo; return 0; } int ED_operator_posemode(bContext *C) { - Object *obact= CTX_data_active_object(C); + Object *obact = CTX_data_active_object(C); if (obact && !(obact->mode & OB_MODE_EDIT)) { Object *obpose; - if ((obpose= object_pose_armature_get(obact))) { + if ((obpose = BKE_object_pose_armature_get(obact))) { if ((obact == obpose) || (obact->mode & OB_MODE_WEIGHT_PAINT)) { return 1; } @@ -360,8 +360,8 @@ int ED_operator_posemode(bContext *C) /* wrapper for ED_space_image_show_uvedit */ int ED_operator_uvedit(bContext *C) { - SpaceImage *sima= CTX_wm_space_image(C); - Object *obedit= CTX_data_edit_object(C); + SpaceImage *sima = CTX_wm_space_image(C); + Object *obedit = CTX_data_edit_object(C); return ED_space_image_show_uvedit(sima, obedit); } @@ -383,7 +383,7 @@ int ED_operator_uvmap(bContext *C) int ED_operator_editsurfcurve(bContext *C) { - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit && ELEM(obedit->type, OB_CURVE, OB_SURF)) return NULL != ((Curve *)obedit->data)->editnurb; return 0; @@ -400,51 +400,51 @@ int ED_operator_editsurfcurve_region_view3d(bContext *C) int ED_operator_editcurve(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_CURVE) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_CURVE) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } int ED_operator_editcurve_3d(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_CURVE) { - Curve *cu= (Curve *)obedit->data; + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_CURVE) { + Curve *cu = (Curve *)obedit->data; - return (cu->flag&CU_3D) && (NULL != cu->editnurb); + return (cu->flag & CU_3D) && (NULL != cu->editnurb); } return 0; } int ED_operator_editsurf(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_SURF) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_SURF) return NULL != ((Curve *)obedit->data)->editnurb; return 0; } int ED_operator_editfont(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_FONT) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_FONT) return NULL != ((Curve *)obedit->data)->editfont; return 0; } int ED_operator_editlattice(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_LATTICE) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_LATTICE) return NULL != ((Lattice *)obedit->data)->editlatt; return 0; } int ED_operator_editmball(bContext *C) { - Object *obedit= CTX_data_edit_object(C); - if (obedit && obedit->type==OB_MBALL) + Object *obedit = CTX_data_edit_object(C); + if (obedit && obedit->type == OB_MBALL) return NULL != ((MetaBall *)obedit->data)->editelems; return 0; } @@ -482,11 +482,11 @@ typedef struct sActionzoneData { /* used by other operators too */ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) { - ScrArea *sa= NULL; - sa= scr->areabase.first; + ScrArea *sa = NULL; + sa = scr->areabase.first; while (sa) { if (BLI_in_rcti(&sa->totrct, x, y)) break; - sa= sa->next; + sa = sa->next; } return sa; @@ -495,15 +495,15 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y) /* quick poll to save operators to be created and handled */ static int actionzone_area_poll(bContext *C) { - wmWindow *win= CTX_wm_window(C); - ScrArea *sa= CTX_wm_area(C); + wmWindow *win = CTX_wm_window(C); + ScrArea *sa = CTX_wm_area(C); if (sa && win) { AZone *az; - int x= win->eventstate->x; - int y= win->eventstate->y; + int x = win->eventstate->x; + int y = win->eventstate->y; - for (az= sa->actionzones.first; az; az= az->next) + for (az = sa->actionzones.first; az; az = az->next) if (BLI_in_rcti(&az->rect, x, y)) return 1; } @@ -512,15 +512,15 @@ static int actionzone_area_poll(bContext *C) AZone *is_in_area_actionzone(ScrArea *sa, int x, int y) { - AZone *az= NULL; + AZone *az = NULL; - for (az= sa->actionzones.first; az; az= az->next) { + for (az = sa->actionzones.first; az; az = az->next) { if (BLI_in_rcti(&az->rect, x, y)) { if (az->type == AZONE_AREA) { /* no triangle intersect but a hotspot circle based on corner */ - int radius= (x-az->x1)*(x-az->x1) + (y-az->y1)*(y-az->y1); + int radius = (x - az->x1) * (x - az->x1) + (y - az->y1) * (y - az->y1); - if (radius <= AZONESPOT*AZONESPOT) + if (radius <= AZONESPOT * AZONESPOT) break; } else if (az->type == AZONE_REGION) { @@ -537,47 +537,47 @@ static void actionzone_exit(wmOperator *op) { if (op->customdata) MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } /* send EVT_ACTIONZONE event */ static void actionzone_apply(bContext *C, wmOperator *op, int type) { wmEvent event; - wmWindow *win= CTX_wm_window(C); - sActionzoneData *sad= op->customdata; + wmWindow *win = CTX_wm_window(C); + sActionzoneData *sad = op->customdata; - sad->modifier= RNA_int_get(op->ptr, "modifier"); + sad->modifier = RNA_int_get(op->ptr, "modifier"); - event= *(win->eventstate); /* XXX huh huh? make api call */ - if (type==AZONE_AREA) - event.type= EVT_ACTIONZONE_AREA; + event = *(win->eventstate); /* XXX huh huh? make api call */ + if (type == AZONE_AREA) + event.type = EVT_ACTIONZONE_AREA; else - event.type= EVT_ACTIONZONE_REGION; - event.customdata= op->customdata; - event.customdatafree= TRUE; - op->customdata= NULL; + event.type = EVT_ACTIONZONE_REGION; + event.customdata = op->customdata; + event.customdatafree = TRUE; + op->customdata = NULL; wm_event_add(win, &event); } static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) { - AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); + AZone *az = is_in_area_actionzone(CTX_wm_area(C), event->x, event->y); sActionzoneData *sad; /* quick escape */ - if (az==NULL) + if (az == NULL) return OPERATOR_PASS_THROUGH; /* ok we do the actionzone */ - sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); - sad->sa1= CTX_wm_area(C); - sad->az= az; - sad->x= event->x; sad->y= event->y; + sad = op->customdata = MEM_callocN(sizeof(sActionzoneData), "sActionzoneData"); + sad->sa1 = CTX_wm_area(C); + sad->az = az; + sad->x = event->x; sad->y = event->y; /* region azone directly reacts on mouse clicks */ - if (sad->az->type==AZONE_REGION) { + if (sad->az->type == AZONE_REGION) { actionzone_apply(C, op, AZONE_REGION); actionzone_exit(op); return OPERATOR_FINISHED; @@ -593,30 +593,30 @@ static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event) static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event) { - sActionzoneData *sad= op->customdata; + sActionzoneData *sad = op->customdata; int deltax, deltay; - int mindelta= sad->az->type==AZONE_REGION?1:12; + int mindelta = sad->az->type == AZONE_REGION ? 1 : 12; switch (event->type) { case MOUSEMOVE: /* calculate gesture direction */ - deltax= (event->x - sad->x); - deltay= (event->y - sad->y); + deltax = (event->x - sad->x); + deltay = (event->y - sad->y); if (deltay > ABS(deltax)) - sad->gesture_dir= 'n'; + sad->gesture_dir = 'n'; else if (deltax > ABS(deltay)) - sad->gesture_dir= 'e'; + sad->gesture_dir = 'e'; else if (deltay < -ABS(deltax)) - sad->gesture_dir= 's'; + sad->gesture_dir = 's'; else - sad->gesture_dir= 'w'; + sad->gesture_dir = 'w'; /* gesture is large enough? */ if (ABS(deltax) > mindelta || ABS(deltay) > mindelta) { /* second area, for join */ - sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); + sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* apply sends event */ actionzone_apply(C, op, sad->az->type); actionzone_exit(op); @@ -688,16 +688,16 @@ typedef struct sAreaSwapData { static int area_swap_init(wmOperator *op, wmEvent *event) { - sAreaSwapData *sd= NULL; - sActionzoneData *sad= event->customdata; + sAreaSwapData *sd = NULL; + sActionzoneData *sad = event->customdata; - if (sad==NULL || sad->sa1==NULL) + if (sad == NULL || sad->sa1 == NULL) return 0; - sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); - sd->sa1= sad->sa1; - sd->sa2= sad->sa2; - op->customdata= sd; + sd = MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData"); + sd->sa1 = sad->sa1; + sd->sa2 = sad->sa2; + op->customdata = sd; return 1; } @@ -708,7 +708,7 @@ static void area_swap_exit(bContext *C, wmOperator *op) WM_cursor_restore(CTX_wm_window(C)); if (op->customdata) MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static int area_swap_cancel(bContext *C, wmOperator *op) @@ -733,15 +733,15 @@ static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event) static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) { - sActionzoneData *sad= op->customdata; + sActionzoneData *sad = op->customdata; switch (event->type) { case MOUSEMOVE: /* second area, for join */ - sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); + sad->sa2 = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); break; case LEFTMOUSE: /* release LMB */ - if (event->val==KM_RELEASE) { + if (event->val == KM_RELEASE) { if (!sad->sa2 || sad->sa1 == sad->sa2) { return area_swap_cancel(C, op); @@ -754,7 +754,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) area_swap_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -790,35 +790,35 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa; rcti rect; - win= CTX_wm_window(C); - sc= CTX_wm_screen(C); - sa= CTX_wm_area(C); + win = CTX_wm_window(C); + sc = CTX_wm_screen(C); + sa = CTX_wm_area(C); /* XXX hrmf! */ - if (event->type==EVT_ACTIONZONE_AREA) { - sActionzoneData *sad= event->customdata; + if (event->type == EVT_ACTIONZONE_AREA) { + sActionzoneData *sad = event->customdata; - if (sad==NULL) + if (sad == NULL) return OPERATOR_PASS_THROUGH; - sa= sad->sa1; + sa = sad->sa1; } /* poll() checks area context, but we don't accept full-area windows */ if (sc->full != SCREENNORMAL) { - if (event->type==EVT_ACTIONZONE_AREA) + if (event->type == EVT_ACTIONZONE_AREA) actionzone_exit(op); return OPERATOR_CANCELLED; } /* adds window to WM */ - rect= sa->totrct; + rect = sa->totrct; BLI_translate_rcti(&rect, win->posx, win->posy); - newwin= WM_window_open(C, &rect); + newwin = WM_window_open(C, &rect); /* allocs new screen and adds to newly created window, using window size */ - newsc= ED_screen_add(newwin, CTX_data_scene(C), sc->id.name+2); - newwin->screen= newsc; + newsc = ED_screen_add(newwin, CTX_data_scene(C), sc->id.name + 2); + newwin->screen = newsc; /* copy area to new screen */ area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); @@ -826,9 +826,9 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) ED_area_tag_redraw((ScrArea *)newsc->areabase.first); /* screen, areas init */ - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); - if (event->type==EVT_ACTIONZONE_AREA) + if (event->type == EVT_ACTIONZONE_AREA) actionzone_exit(op); return OPERATOR_FINISHED; @@ -848,7 +848,7 @@ static void SCREEN_OT_area_dupli(wmOperatorType *ot) /* ************** move area edge operator *********************************** */ /* operator state vars used: - * x, y mouse coord near edge + * x, y mouse coord near edge * delta movement of edge * * functions: @@ -884,56 +884,56 @@ typedef struct sAreaMoveData { static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller) { ScrArea *sa; - int areaminy= ED_area_headersize()+1; + int areaminy = ED_area_headersize() + 1; /* we check all areas and test for free space with MINSIZE */ - *bigger= *smaller= 100000; + *bigger = *smaller = 100000; - for (sa= sc->areabase.first; sa; sa= sa->next) { - if (dir=='h') { - int y1= sa->v2->vec.y - sa->v1->vec.y-areaminy; + for (sa = sc->areabase.first; sa; sa = sa->next) { + if (dir == 'h') { + int y1 = sa->v2->vec.y - sa->v1->vec.y - areaminy; /* if top or down edge selected, test height */ if (sa->v1->flag && sa->v4->flag) - *bigger= MIN2(*bigger, y1); + *bigger = MIN2(*bigger, y1); else if (sa->v2->flag && sa->v3->flag) - *smaller= MIN2(*smaller, y1); + *smaller = MIN2(*smaller, y1); } else { - int x1= sa->v4->vec.x - sa->v1->vec.x-AREAMINX; + int x1 = sa->v4->vec.x - sa->v1->vec.x - AREAMINX; /* if left or right edge selected, test width */ if (sa->v1->flag && sa->v2->flag) - *bigger= MIN2(*bigger, x1); + *bigger = MIN2(*bigger, x1); else if (sa->v3->flag && sa->v4->flag) - *smaller= MIN2(*smaller, x1); + *smaller = MIN2(*smaller, x1); } } } /* validate selection inside screen, set variables OK */ /* return 0: init failed */ -static int area_move_init (bContext *C, wmOperator *op) +static int area_move_init(bContext *C, wmOperator *op) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); ScrEdge *actedge; sAreaMoveData *md; int x, y; /* required properties */ - x= RNA_int_get(op->ptr, "x"); - y= RNA_int_get(op->ptr, "y"); + x = RNA_int_get(op->ptr, "x"); + y = RNA_int_get(op->ptr, "y"); /* setup */ - actedge= screen_find_active_scredge(sc, x, y); - if (actedge==NULL) return 0; + actedge = screen_find_active_scredge(sc, x, y); + if (actedge == NULL) return 0; - md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); - op->customdata= md; + md = MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData"); + op->customdata = md; - md->dir= scredge_is_horizontal(actedge)?'h':'v'; - if (md->dir=='h') md->origval= actedge->v1->vec.y; - else md->origval= actedge->v1->vec.x; + md->dir = scredge_is_horizontal(actedge) ? 'h' : 'v'; + if (md->dir == 'h') md->origval = actedge->v1->vec.y; + else md->origval = actedge->v1->vec.x; select_connected_scredge(sc, actedge); /* now all vertices with 'flag==1' are the ones that can be moved. */ @@ -946,48 +946,48 @@ static int area_move_init (bContext *C, wmOperator *op) /* moves selected screen edge amount of delta, used by split & move */ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller) { - wmWindow *win= CTX_wm_window(C); - bScreen *sc= CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + bScreen *sc = CTX_wm_screen(C); ScrVert *v1; ScrArea *sa; - int areaminy= ED_area_headersize()+1; + int areaminy = ED_area_headersize() + 1; - delta= CLAMPIS(delta, -smaller, bigger); + delta = CLAMPIS(delta, -smaller, bigger); - for (v1= sc->vertbase.first; v1; v1= v1->next) { + for (v1 = sc->vertbase.first; v1; v1 = v1->next) { if (v1->flag) { /* that way a nice AREAGRID */ - if ((dir=='v') && v1->vec.x>0 && v1->vec.xsizex-1) { - v1->vec.x= origval + delta; - if (delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID); + if ((dir == 'v') && v1->vec.x > 0 && v1->vec.x < win->sizex - 1) { + v1->vec.x = origval + delta; + if (delta != bigger && delta != -smaller) v1->vec.x -= (v1->vec.x % AREAGRID); } - if ((dir=='h') && v1->vec.y>0 && v1->vec.ysizey-1) { - v1->vec.y= origval + delta; + if ((dir == 'h') && v1->vec.y > 0 && v1->vec.y < win->sizey - 1) { + v1->vec.y = origval + delta; - v1->vec.y+= AREAGRID-1; - v1->vec.y-= (v1->vec.y % AREAGRID); + v1->vec.y += AREAGRID - 1; + v1->vec.y -= (v1->vec.y % AREAGRID); /* prevent too small top header */ - if (v1->vec.y > win->sizey-areaminy) - v1->vec.y= win->sizey-areaminy; + if (v1->vec.y > win->sizey - areaminy) + v1->vec.y = win->sizey - areaminy; } } } - for (sa= sc->areabase.first; sa; sa= sa->next) { + for (sa = sc->areabase.first; sa; sa = sa->next) { if (sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) ED_area_tag_redraw(sa); } - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); /* redraw everything */ + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* redraw everything */ } static void area_move_apply(bContext *C, wmOperator *op) { - sAreaMoveData *md= op->customdata; + sAreaMoveData *md = op->customdata; int delta; - delta= RNA_int_get(op->ptr, "delta"); + delta = RNA_int_get(op->ptr, "delta"); area_move_apply_do(C, md->origval, delta, md->dir, md->bigger, md->smaller); } @@ -995,7 +995,7 @@ static void area_move_exit(bContext *C, wmOperator *op) { if (op->customdata) MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); @@ -1041,18 +1041,18 @@ static int area_move_cancel(bContext *C, wmOperator *op) /* modal callback for while moving edges */ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) { - sAreaMoveData *md= op->customdata; + sAreaMoveData *md = op->customdata; int delta, x, y; /* execute the events */ switch (event->type) { case MOUSEMOVE: - x= RNA_int_get(op->ptr, "x"); - y= RNA_int_get(op->ptr, "y"); + x = RNA_int_get(op->ptr, "x"); + y = RNA_int_get(op->ptr, "y"); - delta= (md->dir == 'v')? event->x - x: event->y - y; - if (md->step) delta= delta - (delta % md->step); + delta = (md->dir == 'v') ? event->x - x : event->y - y; + if (md->step) delta = delta - (delta % md->step); RNA_int_set(op->ptr, "delta", delta); area_move_apply(C, op); @@ -1069,10 +1069,10 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event) return area_move_cancel(C, op); case KM_MODAL_STEP10: - md->step= 10; + md->step = 10; break; case KM_MODAL_STEP10_OFF: - md->step= 0; + md->step = 0; break; } } @@ -1109,7 +1109,7 @@ static void SCREEN_OT_area_move(wmOperatorType *ot) * dir direction 'v' or 'h' * * operator customdata: - * area pointer to (active) area + * area pointer to (active) area * x, y last used mouse pos * (more, see below) * @@ -1137,21 +1137,21 @@ static void SCREEN_OT_area_move(wmOperatorType *ot) * call exit() or cancel() and remove handler */ -#define SPLIT_STARTED 1 -#define SPLIT_PROGRESS 2 +#define SPLIT_STARTED 1 +#define SPLIT_PROGRESS 2 typedef struct sAreaSplitData { - int x, y; /* last used mouse position */ + int x, y; /* last used mouse position */ - int origval; /* for move areas */ - int bigger, smaller; /* constraints for moving new edge */ - int delta; /* delta move edge */ - int origmin, origsize; /* to calculate fac, for property storage */ - int previewmode; /* draw previewline, then split */ - - ScrEdge *nedge; /* new edge */ - ScrArea *sarea; /* start area */ - ScrArea *narea; /* new area */ + int origval; /* for move areas */ + int bigger, smaller; /* constraints for moving new edge */ + int delta; /* delta move edge */ + int origmin, origsize; /* to calculate fac, for property storage */ + int previewmode; /* draw previewline, then split */ + + ScrEdge *nedge; /* new edge */ + ScrArea *sarea; /* start area */ + ScrArea *narea; /* new area */ } sAreaSplitData; @@ -1161,15 +1161,15 @@ static int area_split_menu_init(bContext *C, wmOperator *op) sAreaSplitData *sd; /* custom data */ - sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); - op->customdata= sd; + sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + op->customdata = sd; - sd->sarea= CTX_wm_area(C); + sd->sarea = CTX_wm_area(C); if (sd->sarea) { - int dir= RNA_enum_get(op->ptr, "direction"); + int dir = RNA_enum_get(op->ptr, "direction"); - if (dir=='h') + if (dir == 'h') sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; else sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V; @@ -1180,28 +1180,28 @@ static int area_split_menu_init(bContext *C, wmOperator *op) /* generic init, no UI stuff here, assumes active area */ static int area_split_init(bContext *C, wmOperator *op) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); sAreaSplitData *sd; - int areaminy= ED_area_headersize()+1; + int areaminy = ED_area_headersize() + 1; int dir; /* required context */ - if (sa==NULL) return 0; + if (sa == NULL) return 0; /* required properties */ - dir= RNA_enum_get(op->ptr, "direction"); + dir = RNA_enum_get(op->ptr, "direction"); /* minimal size */ - if (dir=='v' && sa->winx < 2*AREAMINX) return 0; - if (dir=='h' && sa->winy < 2*areaminy) return 0; + if (dir == 'v' && sa->winx < 2 * AREAMINX) return 0; + if (dir == 'h' && sa->winy < 2 * areaminy) return 0; /* custom data */ - sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); - op->customdata= sd; + sd = (sAreaSplitData *)MEM_callocN(sizeof (sAreaSplitData), "op_area_split"); + op->customdata = sd; - sd->sarea= sa; - sd->origsize= dir=='v' ? sa->winx:sa->winy; - sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin; + sd->sarea = sa; + sd->origsize = dir == 'v' ? sa->winx : sa->winy; + sd->origmin = dir == 'v' ? sa->totrct.xmin : sa->totrct.ymin; return 1; } @@ -1210,25 +1210,25 @@ static int area_split_init(bContext *C, wmOperator *op) /* used with split operator */ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) { - ScrVert *sav1= sa->v1; - ScrVert *sav2= sa->v2; - ScrVert *sav3= sa->v3; - ScrVert *sav4= sa->v4; - ScrVert *sbv1= sb->v1; - ScrVert *sbv2= sb->v2; - ScrVert *sbv3= sb->v3; - ScrVert *sbv4= sb->v4; + ScrVert *sav1 = sa->v1; + ScrVert *sav2 = sa->v2; + ScrVert *sav3 = sa->v3; + ScrVert *sav4 = sa->v4; + ScrVert *sbv1 = sb->v1; + ScrVert *sbv2 = sb->v2; + ScrVert *sbv3 = sb->v3; + ScrVert *sbv4 = sb->v4; - if (sav1==sbv4 && sav2==sbv3) { /* sa to right of sb = W */ + if (sav1 == sbv4 && sav2 == sbv3) { /* sa to right of sb = W */ return screen_findedge(screen, sav1, sav2); } - else if (sav2==sbv1 && sav3==sbv4) { /* sa to bottom of sb = N */ + else if (sav2 == sbv1 && sav3 == sbv4) { /* sa to bottom of sb = N */ return screen_findedge(screen, sav2, sav3); } - else if (sav3==sbv2 && sav4==sbv1) { /* sa to left of sb = E */ + else if (sav3 == sbv2 && sav4 == sbv1) { /* sa to left of sb = E */ return screen_findedge(screen, sav3, sav4); } - else if (sav1==sbv2 && sav4==sbv3) { /* sa on top of sb = S*/ + else if (sav1 == sbv2 && sav4 == sbv3) { /* sa on top of sb = S*/ return screen_findedge(screen, sav1, sav4); } @@ -1239,35 +1239,35 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb) /* do the split, return success */ static int area_split_apply(bContext *C, wmOperator *op) { - bScreen *sc= CTX_wm_screen(C); - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + bScreen *sc = CTX_wm_screen(C); + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; int dir; - fac= RNA_float_get(op->ptr, "factor"); - dir= RNA_enum_get(op->ptr, "direction"); + fac = RNA_float_get(op->ptr, "factor"); + dir = RNA_enum_get(op->ptr, "direction"); - sd->narea= area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ + sd->narea = area_split(sc, sd->sarea, dir, fac, 0); /* 0 = no merge */ if (sd->narea) { ScrVert *sv; - sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea); + sd->nedge = area_findsharededge(sc, sd->sarea, sd->narea); /* select newly created edge, prepare for moving edge */ - for (sv= sc->vertbase.first; sv; sv= sv->next) + for (sv = sc->vertbase.first; sv; sv = sv->next) sv->flag = 0; - sd->nedge->v1->flag= 1; - sd->nedge->v2->flag= 1; + sd->nedge->v1->flag = 1; + sd->nedge->v2->flag = 1; - if (dir=='h') sd->origval= sd->nedge->v1->vec.y; - else sd->origval= sd->nedge->v1->vec.x; + if (dir == 'h') sd->origval = sd->nedge->v1->vec.y; + else sd->origval = sd->nedge->v1->vec.x; ED_area_tag_redraw(sd->sarea); ED_area_tag_redraw(sd->narea); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return 1; } @@ -1278,19 +1278,19 @@ static int area_split_apply(bContext *C, wmOperator *op) static void area_split_exit(bContext *C, wmOperator *op) { if (op->customdata) { - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; if (sd->sarea) ED_area_tag_redraw(sd->sarea); if (sd->narea) ED_area_tag_redraw(sd->narea); if (sd->sarea) - sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); + sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); MEM_freeN(op->customdata); op->customdata = NULL; } WM_cursor_restore(CTX_wm_window(C)); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); /* this makes sure aligned edges will result in aligned grabbing */ removedouble_scrverts(CTX_wm_screen(C)); @@ -1308,28 +1308,28 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) if (CTX_wm_screen(C)->full != SCREENNORMAL) return OPERATOR_CANCELLED; - if (event->type==EVT_ACTIONZONE_AREA) { - sActionzoneData *sad= event->customdata; + if (event->type == EVT_ACTIONZONE_AREA) { + sActionzoneData *sad = event->customdata; - if (sad->modifier>0) { + if (sad->modifier > 0) { return OPERATOR_PASS_THROUGH; } /* verify *sad itself */ - if (sad==NULL || sad->sa1==NULL || sad->az==NULL) + if (sad == NULL || sad->sa1 == NULL || sad->az == NULL) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas not equal it should be passed on */ - if (CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2) + if (CTX_wm_area(C) != sad->sa1 || sad->sa1 != sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ - if (sad->gesture_dir=='n' || sad->gesture_dir=='s') { - dir= 'h'; + if (sad->gesture_dir == 'n' || sad->gesture_dir == 's') { + dir = 'h'; RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx); } else { - dir= 'v'; + dir = 'v'; RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy); } RNA_enum_set(op->ptr, "direction", dir); @@ -1345,20 +1345,20 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) /* retrieve initial mouse coord, so we can find the active edge */ if (RNA_struct_property_is_set(op->ptr, "mouse_x")) - x= RNA_int_get(op->ptr, "mouse_x"); + x = RNA_int_get(op->ptr, "mouse_x"); else - x= event->x; + x = event->x; if (RNA_struct_property_is_set(op->ptr, "mouse_y")) - y= RNA_int_get(op->ptr, "mouse_y"); + y = RNA_int_get(op->ptr, "mouse_y"); else - y= event->x; + y = event->x; - actedge= screen_find_active_scredge(CTX_wm_screen(C), x, y); - if (actedge==NULL) + actedge = screen_find_active_scredge(CTX_wm_screen(C), x, y); + if (actedge == NULL) return OPERATOR_CANCELLED; - dir= scredge_is_horizontal(actedge)?'v':'h'; + dir = scredge_is_horizontal(actedge) ? 'v' : 'h'; RNA_enum_set(op->ptr, "direction", dir); @@ -1368,12 +1368,12 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) } - sd= (sAreaSplitData *)op->customdata; + sd = (sAreaSplitData *)op->customdata; - sd->x= event->x; - sd->y= event->y; + sd->x = event->x; + sd->y = event->y; - if (event->type==EVT_ACTIONZONE_AREA) { + if (event->type == EVT_ACTIONZONE_AREA) { /* do the split */ if (area_split_apply(C, op)) { @@ -1386,7 +1386,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event) } } else { - sd->previewmode= 1; + sd->previewmode = 1; /* add temp handler for edge move or cancel */ WM_event_add_modal_handler(C, op); @@ -1413,7 +1413,7 @@ static int area_split_exec(bContext *C, wmOperator *op) static int area_split_cancel(bContext *C, wmOperator *op) { - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; if (sd->previewmode) { } @@ -1433,44 +1433,44 @@ static int area_split_cancel(bContext *C, wmOperator *op) static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) { - sAreaSplitData *sd= (sAreaSplitData *)op->customdata; + sAreaSplitData *sd = (sAreaSplitData *)op->customdata; float fac; int dir; /* execute the events */ switch (event->type) { case MOUSEMOVE: - dir= RNA_enum_get(op->ptr, "direction"); + dir = RNA_enum_get(op->ptr, "direction"); - sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval; - if (sd->previewmode==0) + sd->delta = (dir == 'v') ? event->x - sd->origval : event->y - sd->origval; + if (sd->previewmode == 0) area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller); else { if (sd->sarea) { - sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); + sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); ED_area_tag_redraw(sd->sarea); } - sd->sarea= screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* area context not set */ + sd->sarea = screen_areahascursor(CTX_wm_screen(C), event->x, event->y); /* area context not set */ if (sd->sarea) { ED_area_tag_redraw(sd->sarea); - if (dir=='v') { - sd->origsize= sd->sarea->winx; - sd->origmin= sd->sarea->totrct.xmin; + if (dir == 'v') { + sd->origsize = sd->sarea->winx; + sd->origmin = sd->sarea->totrct.xmin; sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_V; } else { - sd->origsize= sd->sarea->winy; - sd->origmin= sd->sarea->totrct.ymin; + sd->origsize = sd->sarea->winy; + sd->origmin = sd->sarea->totrct.ymin; sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; } } - CTX_wm_window(C)->screen->do_draw= 1; + CTX_wm_window(C)->screen->do_draw = 1; } - fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin; + fac = (dir == 'v') ? event->x - sd->origmin : event->y - sd->origmin; RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize); break; @@ -1482,7 +1482,7 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_FINISHED; } else { - if (event->val==KM_RELEASE) { /* mouse up */ + if (event->val == KM_RELEASE) { /* mouse up */ area_split_exit(C, op); return OPERATOR_FINISHED; } @@ -1491,17 +1491,17 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) case MIDDLEMOUSE: case TABKEY: - if (sd->previewmode==0) { + if (sd->previewmode == 0) { } else { dir = RNA_enum_get(op->ptr, "direction"); - if (event->val==KM_PRESS) { + if (event->val == KM_PRESS) { if (sd->sarea) { - sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H|AREA_FLAG_DRAWSPLIT_V); + sd->sarea->flag &= ~(AREA_FLAG_DRAWSPLIT_H | AREA_FLAG_DRAWSPLIT_V); ED_area_tag_redraw(sd->sarea); - if (dir=='v') { + if (dir == 'v') { RNA_enum_set(op->ptr, "direction", 'h'); sd->sarea->flag |= AREA_FLAG_DRAWSPLIT_H; @@ -1528,9 +1528,10 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event) } static EnumPropertyItem prop_direction_items[] = { -{'h', "HORIZONTAL", 0, "Horizontal", ""}, -{'v', "VERTICAL", 0, "Vertical", ""}, -{0, NULL, 0, NULL, NULL}}; + {'h', "HORIZONTAL", 0, "Horizontal", ""}, + {'v', "VERTICAL", 0, "Vertical", ""}, + {0, NULL, 0, NULL, NULL} +}; static void SCREEN_OT_area_split(wmOperatorType *ot) { @@ -1574,16 +1575,16 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) ARegion *ar; int dist; - if (edge==AE_RIGHT_TO_TOPLEFT || edge==AE_LEFT_TO_TOPRIGHT) { + if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { dist = sa->totrct.xmax - sa->totrct.xmin; } - else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ + else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ dist = sa->totrct.ymax - sa->totrct.ymin; } /* subtractwidth of regions on opposite side * prevents dragging regions into other opposite regions */ - for (ar=sa->regionbase.first; ar; ar=ar->next) { + for (ar = sa->regionbase.first; ar; ar = ar->next) { if (ar == scalear) continue; @@ -1609,10 +1610,10 @@ static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) { - sActionzoneData *sad= event->customdata; + sActionzoneData *sad = event->customdata; AZone *az; - if (event->type!=EVT_ACTIONZONE_REGION) { + if (event->type != EVT_ACTIONZONE_REGION) { BKE_report(op->reports, RPT_ERROR, "Can only scale region size from an action zone"); return OPERATOR_CANCELLED; } @@ -1620,31 +1621,31 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) az = sad->az; if (az->ar) { - RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); + RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); int maxsize; - op->customdata= rmd; + op->customdata = rmd; rmd->az = az; - rmd->ar= az->ar; + rmd->ar = az->ar; rmd->sa = sad->sa1; - rmd->edge= az->edge; - rmd->origx= event->x; - rmd->origy= event->y; + rmd->edge = az->edge; + rmd->origx = event->x; + rmd->origy = event->y; rmd->maxsize = area_max_regionsize(rmd->sa, rmd->ar, rmd->edge); /* if not set we do now, otherwise it uses type */ - if (rmd->ar->sizex==0) - rmd->ar->sizex= rmd->ar->type->prefsizex; - if (rmd->ar->sizey==0) - rmd->ar->sizey= rmd->ar->type->prefsizey; + if (rmd->ar->sizex == 0) + rmd->ar->sizex = rmd->ar->type->prefsizex; + if (rmd->ar->sizey == 0) + rmd->ar->sizey = rmd->ar->type->prefsizey; /* now copy to regionmovedata */ - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { - rmd->origval= rmd->ar->sizex; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + rmd->origval = rmd->ar->sizex; } else { - rmd->origval= rmd->ar->sizey; + rmd->origval = rmd->ar->sizey; } /* limit headers to standard height for now */ @@ -1666,16 +1667,16 @@ static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event) static int region_scale_get_maxsize(RegionMoveData *rmd) { - int maxsize= 0; + int maxsize = 0; - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { return rmd->sa->winx - UI_UNIT_X; } if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { /* this calculation seems overly verbose * can someone explain why this method is necessary? - campbell */ - maxsize = rmd->maxsize - ((rmd->sa->headertype==HEADERTOP)?UI_UNIT_Y*2:UI_UNIT_Y) - (UI_UNIT_Y/4); + maxsize = rmd->maxsize - ((rmd->sa->headertype == HEADERTOP) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4); } return maxsize; @@ -1683,19 +1684,19 @@ static int region_scale_get_maxsize(RegionMoveData *rmd) static void region_scale_validate_size(RegionMoveData *rmd) { - if ((rmd->ar->flag & RGN_FLAG_HIDDEN)==0) { - short *size, maxsize= -1; + if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) { + short *size, maxsize = -1; - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) - size= &rmd->ar->sizex; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) + size = &rmd->ar->sizex; else - size= &rmd->ar->sizey; + size = &rmd->ar->sizey; - maxsize= region_scale_get_maxsize(rmd); + maxsize = region_scale_get_maxsize(rmd); if (*size > maxsize && maxsize > 0) - *size= maxsize; + *size = maxsize; } } @@ -1707,22 +1708,22 @@ static void region_scale_toggle_hidden(bContext *C, RegionMoveData *rmd) static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) { - RegionMoveData *rmd= op->customdata; + RegionMoveData *rmd = op->customdata; int delta; /* execute the events */ switch (event->type) { case MOUSEMOVE: - if (rmd->edge==AE_LEFT_TO_TOPRIGHT || rmd->edge==AE_RIGHT_TO_TOPLEFT) { - delta= event->x - rmd->origx; - if (rmd->edge==AE_LEFT_TO_TOPRIGHT) delta= -delta; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + delta = event->x - rmd->origx; + if (rmd->edge == AE_LEFT_TO_TOPRIGHT) delta = -delta; - rmd->ar->sizex= rmd->origval + delta; + rmd->ar->sizex = rmd->origval + delta; CLAMP(rmd->ar->sizex, 0, rmd->maxsize); if (rmd->ar->sizex < UI_UNIT_X) { - rmd->ar->sizex= rmd->origval; + rmd->ar->sizex = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } @@ -1730,33 +1731,33 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) region_scale_toggle_hidden(C, rmd); } else { - int maxsize= region_scale_get_maxsize(rmd); - delta= event->y - rmd->origy; - if (rmd->edge==AE_BOTTOM_TO_TOPLEFT) delta= -delta; + int maxsize = region_scale_get_maxsize(rmd); + delta = event->y - rmd->origy; + if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta; - rmd->ar->sizey= rmd->origval + delta; + rmd->ar->sizey = rmd->origval + delta; CLAMP(rmd->ar->sizey, 0, rmd->maxsize); /* note, 'UI_UNIT_Y/4' means you need to drag the header almost * all the way down for it to become hidden, this is done * otherwise its too easy to do this by accident */ - if (rmd->ar->sizey < UI_UNIT_Y/4) { - rmd->ar->sizey= rmd->origval; + if (rmd->ar->sizey < UI_UNIT_Y / 4) { + rmd->ar->sizey = rmd->origval; if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) - rmd->ar->sizey= maxsize; + rmd->ar->sizey = maxsize; else if (rmd->ar->flag & RGN_FLAG_HIDDEN) region_scale_toggle_hidden(C, rmd); } ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); break; case LEFTMOUSE: - if (event->val==KM_RELEASE) { + if (event->val == KM_RELEASE) { if (ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if (rmd->ar->flag & RGN_FLAG_HIDDEN) { @@ -1767,7 +1768,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) } ED_area_tag_redraw(rmd->sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } MEM_freeN(op->customdata); op->customdata = NULL; @@ -1813,8 +1814,8 @@ static void SCREEN_OT_region_scale(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int frame_offset_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); int delta; delta = RNA_int_get(op->ptr, "delta"); @@ -1825,7 +1826,7 @@ static int frame_offset_exec(bContext *C, wmOperator *op) sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, CTX_data_scene(C)); return OPERATOR_FINISHED; } @@ -1834,6 +1835,7 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) { ot->name = "Frame Offset"; ot->idname = "SCREEN_OT_frame_offset"; + ot->description = "Move current frame forward/backward by a given number"; ot->exec = frame_offset_exec; @@ -1848,9 +1850,9 @@ static void SCREEN_OT_frame_offset(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int frame_jump_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - wmTimer *animtimer= CTX_wm_screen(C)->animtimer; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + wmTimer *animtimer = CTX_wm_screen(C)->animtimer; /* Don't change CFRA directly if animtimer is running as this can cause * first/last frame not to be actually shown (bad since for example physics @@ -1862,19 +1864,19 @@ static int frame_jump_exec(bContext *C, wmOperator *op) sad->flag |= ANIMPLAY_FLAG_USE_NEXT_FRAME; if (RNA_boolean_get(op->ptr, "end")) - sad->nextfra= PEFRA; + sad->nextfra = PEFRA; else - sad->nextfra= PSFRA; + sad->nextfra = PSFRA; } else { if (RNA_boolean_get(op->ptr, "end")) - CFRA= PEFRA; + CFRA = PEFRA; else - CFRA= PSFRA; + CFRA = PSFRA; sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } return OPERATOR_FINISHED; @@ -1901,21 +1903,21 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int keyframe_jump_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - bDopeSheet ads= {NULL}; + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + bDopeSheet ads = {NULL}; DLRBT_Tree keys; ActKeyColumn *ak; float cfra; - short next= RNA_boolean_get(op->ptr, "next"); + short next = RNA_boolean_get(op->ptr, "next"); short done = 0; /* sanity checks */ if (scene == NULL) return OPERATOR_CANCELLED; - cfra= (float)(CFRA); + cfra = (float)(CFRA); /* init binarytree-list for getting keyframes */ BLI_dlrbTree_init(&keys); @@ -1932,14 +1934,14 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) /* find matching keyframe in the right direction */ do { if (next) - ak= (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra); + ak = (ActKeyColumn *)BLI_dlrbTree_search_next(&keys, compare_ak_cfraPtr, &cfra); else - ak= (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra); + ak = (ActKeyColumn *)BLI_dlrbTree_search_prev(&keys, compare_ak_cfraPtr, &cfra); if (ak) { if (CFRA != (int)ak->cfra) { /* this changes the frame, so set the frame and we're done */ - CFRA= (int)ak->cfra; + CFRA = (int)ak->cfra; done = 1; } else { @@ -1958,7 +1960,7 @@ static int keyframe_jump_exec(bContext *C, wmOperator *op) sound_seek_scene(bmain, scene); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -1984,35 +1986,35 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) /* function to be called outside UI context, or for redo */ static int screen_set_exec(bContext *C, wmOperator *op) { - bScreen *screen= CTX_wm_screen(C); - bScreen *screen_prev= screen; + bScreen *screen = CTX_wm_screen(C); + bScreen *screen_prev = screen; - ScrArea *sa= CTX_wm_area(C); - int tot= BLI_countlist(&CTX_data_main(C)->screen); - int delta= RNA_int_get(op->ptr, "delta"); + ScrArea *sa = CTX_wm_area(C); + int tot = BLI_countlist(&CTX_data_main(C)->screen); + int delta = RNA_int_get(op->ptr, "delta"); /* temp screens are for userpref or render display */ if (screen->temp) return OPERATOR_CANCELLED; - if (delta==1) { + if (delta == 1) { while (tot--) { - screen= screen->id.next; - if (screen==NULL) screen= CTX_data_main(C)->screen.first; - if (screen->winid==0 && screen->full==0 && screen != screen_prev) + screen = screen->id.next; + if (screen == NULL) screen = CTX_data_main(C)->screen.first; + if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) break; } } - else if (delta== -1) { + else if (delta == -1) { while (tot--) { - screen= screen->id.prev; - if (screen==NULL) screen= CTX_data_main(C)->screen.last; - if (screen->winid==0 && screen->full==0 && screen != screen_prev) + screen = screen->id.prev; + if (screen == NULL) screen = CTX_data_main(C)->screen.last; + if (screen->winid == 0 && screen->full == 0 && screen != screen_prev) break; } } else { - screen= NULL; + screen = NULL; } if (screen && screen_prev != screen) { @@ -2047,15 +2049,15 @@ static void SCREEN_OT_screen_set(wmOperatorType *ot) static int screen_full_area_exec(bContext *C, wmOperator *UNUSED(op)) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa=NULL; + ScrArea *sa = NULL; /* search current screen for 'fullscreen' areas */ /* prevents restoring info header, when mouse is over it */ - for (sa=screen->areabase.first; sa; sa=sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full) break; } - if (sa==NULL) sa= CTX_wm_area(C); + if (sa == NULL) sa = CTX_wm_area(C); ED_screen_full_toggle(C, CTX_wm_window(C), sa); return OPERATOR_FINISHED; @@ -2104,11 +2106,10 @@ static void SCREEN_OT_screen_full_area(wmOperatorType *ot) * call exit() and remove handler when LMB confirm */ -typedef struct sAreaJoinData -{ - ScrArea *sa1; /* first area to be considered */ - ScrArea *sa2; /* second area to be considered */ - ScrArea *scr; /* designed for removal */ +typedef struct sAreaJoinData { + ScrArea *sa1; /* first area to be considered */ + ScrArea *sa2; /* second area to be considered */ + ScrArea *scr; /* designed for removal */ } sAreaJoinData; @@ -2119,40 +2120,40 @@ typedef struct sAreaJoinData static int area_join_init(bContext *C, wmOperator *op) { ScrArea *sa1, *sa2; - sAreaJoinData* jd= NULL; + sAreaJoinData *jd = NULL; int x1, y1; int x2, y2; - int shared= 0; + int shared = 0; /* required properties, make negative to get return 0 if not set by caller */ - x1= RNA_int_get(op->ptr, "min_x"); - y1= RNA_int_get(op->ptr, "min_y"); - x2= RNA_int_get(op->ptr, "max_x"); - y2= RNA_int_get(op->ptr, "max_y"); + x1 = RNA_int_get(op->ptr, "min_x"); + y1 = RNA_int_get(op->ptr, "min_y"); + x2 = RNA_int_get(op->ptr, "max_x"); + y2 = RNA_int_get(op->ptr, "max_y"); sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1); sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2); - if (sa1==NULL || sa2==NULL || sa1==sa2) + if (sa1 == NULL || sa2 == NULL || sa1 == sa2) return 0; /* do areas share an edge? */ - if (sa1->v1==sa2->v1 || sa1->v1==sa2->v2 || sa1->v1==sa2->v3 || sa1->v1==sa2->v4) shared++; - if (sa1->v2==sa2->v1 || sa1->v2==sa2->v2 || sa1->v2==sa2->v3 || sa1->v2==sa2->v4) shared++; - if (sa1->v3==sa2->v1 || sa1->v3==sa2->v2 || sa1->v3==sa2->v3 || sa1->v3==sa2->v4) shared++; - if (sa1->v4==sa2->v1 || sa1->v4==sa2->v2 || sa1->v4==sa2->v3 || sa1->v4==sa2->v4) shared++; - if (shared!=2) { + if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++; + if (sa1->v2 == sa2->v1 || sa1->v2 == sa2->v2 || sa1->v2 == sa2->v3 || sa1->v2 == sa2->v4) shared++; + if (sa1->v3 == sa2->v1 || sa1->v3 == sa2->v2 || sa1->v3 == sa2->v3 || sa1->v3 == sa2->v4) shared++; + if (sa1->v4 == sa2->v1 || sa1->v4 == sa2->v2 || sa1->v4 == sa2->v3 || sa1->v4 == sa2->v4) shared++; + if (shared != 2) { printf("areas don't share edge\n"); return 0; } - jd = (sAreaJoinData*)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); + jd = (sAreaJoinData *)MEM_callocN(sizeof (sAreaJoinData), "op_area_join"); jd->sa1 = sa1; jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM; jd->sa2 = sa2; jd->sa2->flag |= AREA_FLAG_DRAWJOINTO; - op->customdata= jd; + op->customdata = jd; return 1; } @@ -2203,19 +2204,19 @@ static int area_join_exec(bContext *C, wmOperator *op) static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) { - if (event->type==EVT_ACTIONZONE_AREA) { - sActionzoneData *sad= event->customdata; + if (event->type == EVT_ACTIONZONE_AREA) { + sActionzoneData *sad = event->customdata; - if (sad->modifier>0) { + if (sad->modifier > 0) { return OPERATOR_PASS_THROUGH; } /* verify *sad itself */ - if (sad==NULL || sad->sa1==NULL || sad->sa2==NULL) + if (sad == NULL || sad->sa1 == NULL || sad->sa2 == NULL) return OPERATOR_PASS_THROUGH; /* is this our *sad? if areas equal it should be passed on */ - if (sad->sa1==sad->sa2) + if (sad->sa1 == sad->sa2) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ @@ -2258,7 +2259,7 @@ static int area_join_cancel(bContext *C, wmOperator *op) /* modal callback while selecting area (space) that will be removed */ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); sAreaJoinData *jd = (sAreaJoinData *)op->customdata; /* execute the events */ @@ -2300,7 +2301,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) } else { /* we are back in the area previously selected for keeping - * we swap the areas if possible to allow user to choose */ + * we swap the areas if possible to allow user to choose */ if (jd->sa2 != NULL) { if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM; if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO; @@ -2325,14 +2326,14 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) } } } - break; + break; case LEFTMOUSE: - if (event->val==KM_RELEASE) { + if (event->val == KM_RELEASE) { ED_area_tag_redraw(jd->sa1); ED_area_tag_redraw(jd->sa2); area_join_apply(C, op); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); area_join_exit(C, op); return OPERATOR_FINISHED; } @@ -2361,7 +2362,7 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) ot->poll = screen_active_editable; ot->cancel = area_join_cancel; - ot->flag = OPTYPE_BLOCKING|OPTYPE_INTERNAL; + ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; /* rna */ RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX); @@ -2377,20 +2378,20 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, wmEvent *even uiPopupMenu *pup; uiLayout *layout; PointerRNA ptr1, ptr2; - ScrEdge *actedge= screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y); + ScrEdge *actedge = screen_find_active_scredge(CTX_wm_screen(C), event->x, event->y); - if (actedge==NULL) return OPERATOR_CANCELLED; + if (actedge == NULL) return OPERATOR_CANCELLED; - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); WM_operator_properties_create(&ptr1, "SCREEN_OT_area_join"); /* mouse cursor on edge, '4' can fail on wide edges... */ - RNA_int_set(&ptr1, "min_x", event->x+4); - RNA_int_set(&ptr1, "min_y", event->y+4); - RNA_int_set(&ptr1, "max_x", event->x-4); - RNA_int_set(&ptr1, "max_y", event->y-4); + RNA_int_set(&ptr1, "min_x", event->x + 4); + RNA_int_set(&ptr1, "min_y", event->y + 4); + RNA_int_set(&ptr1, "max_x", event->x - 4); + RNA_int_set(&ptr1, "max_y", event->y - 4); WM_operator_properties_create(&ptr2, "SCREEN_OT_area_split"); @@ -2425,18 +2426,18 @@ static void SCREEN_OT_area_options(wmOperatorType *ot) static int spacedata_cleanup(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); bScreen *screen; ScrArea *sa; - int tot= 0; + int tot = 0; - for (screen= bmain->screen.first; screen; screen= screen->id.next) { - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (screen = bmain->screen.first; screen; screen = screen->id.next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->spacedata.first != sa->spacedata.last) { - SpaceLink *sl= sa->spacedata.first; + SpaceLink *sl = sa->spacedata.first; BLI_remlink(&sa->spacedata, sl); - tot+= BLI_countlist(&sa->spacedata); + tot += BLI_countlist(&sa->spacedata); BKE_spacedata_freelist(&sa->spacedata); BLI_addtail(&sa->spacedata, sl); } @@ -2464,7 +2465,7 @@ static void SCREEN_OT_spacedata_cleanup(wmOperatorType *ot) static int repeat_last_exec(bContext *C, wmOperator *UNUSED(op)) { - wmOperator *lastop= CTX_wm_manager(C)->operators.last; + wmOperator *lastop = CTX_wm_manager(C)->operators.last; if (lastop) WM_operator_repeat(C, lastop); @@ -2488,20 +2489,20 @@ static void SCREEN_OT_repeat_last(wmOperatorType *ot) static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); wmOperator *lastop; uiPopupMenu *pup; uiLayout *layout; int items, i; - items= BLI_countlist(&wm->operators); - if (items==0) + items = BLI_countlist(&wm->operators); + if (items == 0) return OPERATOR_CANCELLED; - pup= uiPupMenuBegin(C, op->type->name, ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); - for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--) + for (i = items - 1, lastop = wm->operators.last; lastop; lastop = lastop->prev, i--) uiItemIntO(layout, lastop->type->name, ICON_NONE, op->type->idname, "index", i); uiPupMenuEnd(C, pup); @@ -2511,9 +2512,9 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(ev static int repeat_history_exec(bContext *C, wmOperator *op) { - wmWindowManager *wm= CTX_wm_manager(C); + wmWindowManager *wm = CTX_wm_manager(C); - op= BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); + op = BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index")); if (op) { /* let's put it as last operator in list */ BLI_remlink(&wm->operators, op); @@ -2545,7 +2546,7 @@ static void SCREEN_OT_repeat_history(wmOperatorType *ot) static int redo_last_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - wmOperator *lastop= WM_operator_last_redo(C); + wmOperator *lastop = WM_operator_last_redo(C); if (lastop) WM_operator_redo_popup(C, lastop); @@ -2571,27 +2572,27 @@ static void SCREEN_OT_redo_last(wmOperatorType *ot) /* insert a region in the area region list */ static int region_quadview_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); /* some rules... */ - if (ar->regiontype!=RGN_TYPE_WINDOW) + if (ar->regiontype != RGN_TYPE_WINDOW) BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted"); - else if (ar->alignment==RGN_ALIGN_QSPLIT) { - ScrArea *sa= CTX_wm_area(C); + else if (ar->alignment == RGN_ALIGN_QSPLIT) { + ScrArea *sa = CTX_wm_area(C); ARegion *arn; /* keep current region */ - ar->alignment= 0; + ar->alignment = 0; - if (sa->spacetype==SPACE_VIEW3D) { - RegionView3D *rv3d= ar->regiondata; - rv3d->viewlock= 0; + if (sa->spacetype == SPACE_VIEW3D) { + RegionView3D *rv3d = ar->regiondata; + rv3d->viewlock = 0; rv3d->rflag &= ~RV3D_CLIPPING; } - for (ar= sa->regionbase.first; ar; ar= arn) { - arn= ar->next; - if (ar->alignment==RGN_ALIGN_QSPLIT) { + for (ar = sa->regionbase.first; ar; ar = arn) { + arn = ar->next; + if (ar->alignment == RGN_ALIGN_QSPLIT) { ED_region_exit(C, ar); BKE_area_region_free(sa->type, ar); BLI_remlink(&sa->regionbase, ar); @@ -2599,24 +2600,24 @@ static int region_quadview_exec(bContext *C, wmOperator *op) } } ED_area_tag_redraw(sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } else if (ar->next) BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted"); else { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); ARegion *newar; int count; - ar->alignment= RGN_ALIGN_QSPLIT; + ar->alignment = RGN_ALIGN_QSPLIT; - for (count=0; count<3; count++) { - newar= BKE_area_region_copy(sa->type, ar); + for (count = 0; count < 3; count++) { + newar = BKE_area_region_copy(sa->type, ar); BLI_addtail(&sa->regionbase, newar); } /* lock views and set them */ - if (sa->spacetype==SPACE_VIEW3D) { + if (sa->spacetype == SPACE_VIEW3D) { /* run ED_view3d_lock() so the correct 'rv3d->viewquat' is set, * otherwise when restoring rv3d->localvd the 'viewquat' won't * match the 'view', set on entering localview See: [#26315], @@ -2625,31 +2626,31 @@ static int region_quadview_exec(bContext *C, wmOperator *op) * localview with a 4-split would assign these view locks */ RegionView3D *rv3d; - rv3d= ar->regiondata; - rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_FRONT; rv3d->persp= RV3D_ORTHO; + rv3d = ar->regiondata; + rv3d->viewlock = RV3D_LOCKED; rv3d->view = RV3D_VIEW_FRONT; rv3d->persp = RV3D_ORTHO; ED_view3d_lock(rv3d); - if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } - ar= ar->next; - rv3d= ar->regiondata; - rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_TOP; rv3d->persp= RV3D_ORTHO; + ar = ar->next; + rv3d = ar->regiondata; + rv3d->viewlock = RV3D_LOCKED; rv3d->view = RV3D_VIEW_TOP; rv3d->persp = RV3D_ORTHO; ED_view3d_lock(rv3d); - if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } - ar= ar->next; - rv3d= ar->regiondata; - rv3d->viewlock= RV3D_LOCKED; rv3d->view= RV3D_VIEW_RIGHT; rv3d->persp= RV3D_ORTHO; + ar = ar->next; + rv3d = ar->regiondata; + rv3d->viewlock = RV3D_LOCKED; rv3d->view = RV3D_VIEW_RIGHT; rv3d->persp = RV3D_ORTHO; ED_view3d_lock(rv3d); - if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) { rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } - ar= ar->next; - rv3d= ar->regiondata; - rv3d->view= RV3D_VIEW_CAMERA; rv3d->persp= RV3D_CAMOB; + ar = ar->next; + rv3d = ar->regiondata; + rv3d->view = RV3D_VIEW_CAMERA; rv3d->persp = RV3D_CAMOB; ED_view3d_lock(rv3d); - if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat);} + if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; copy_qt_qt(rv3d->localvd->viewquat, rv3d->viewquat); } } ED_area_tag_redraw(sa); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); } @@ -2677,22 +2678,22 @@ static void SCREEN_OT_region_quadview(wmOperatorType *ot) /* flip a region alignment */ static int region_flip_exec(bContext *C, wmOperator *UNUSED(op)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); if (!ar) return OPERATOR_CANCELLED; - if (ar->alignment==RGN_ALIGN_TOP) - ar->alignment= RGN_ALIGN_BOTTOM; - else if (ar->alignment==RGN_ALIGN_BOTTOM) - ar->alignment= RGN_ALIGN_TOP; - else if (ar->alignment==RGN_ALIGN_LEFT) - ar->alignment= RGN_ALIGN_RIGHT; - else if (ar->alignment==RGN_ALIGN_RIGHT) - ar->alignment= RGN_ALIGN_LEFT; + if (ar->alignment == RGN_ALIGN_TOP) + ar->alignment = RGN_ALIGN_BOTTOM; + else if (ar->alignment == RGN_ALIGN_BOTTOM) + ar->alignment = RGN_ALIGN_TOP; + else if (ar->alignment == RGN_ALIGN_LEFT) + ar->alignment = RGN_ALIGN_RIGHT; + else if (ar->alignment == RGN_ALIGN_RIGHT) + ar->alignment = RGN_ALIGN_LEFT; ED_area_tag_redraw(CTX_wm_area(C)); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2703,6 +2704,7 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) /* identifiers */ ot->name = "Flip Region"; ot->idname = "SCREEN_OT_region_flip"; + ot->description = "Toggle the region's alignment (left/right or top/bottom)"; /* api callbacks */ ot->exec = region_flip_exec; @@ -2715,14 +2717,14 @@ static void SCREEN_OT_region_flip(wmOperatorType *ot) /* flip a header region alignment */ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); /* find the header region * - try context first, but upon failing, search all regions in area... */ if ((ar == NULL) || (ar->regiontype != RGN_TYPE_HEADER)) { - ScrArea *sa= CTX_wm_area(C); - ar= BKE_area_find_region_type(sa, RGN_TYPE_HEADER); + ScrArea *sa = CTX_wm_area(C); + ar = BKE_area_find_region_type(sa, RGN_TYPE_HEADER); /* don't do anything if no region */ if (ar == NULL) @@ -2730,18 +2732,18 @@ static int header_flip_exec(bContext *C, wmOperator *UNUSED(op)) } /* copied from SCREEN_OT_region_flip */ - if (ar->alignment==RGN_ALIGN_TOP) - ar->alignment= RGN_ALIGN_BOTTOM; - else if (ar->alignment==RGN_ALIGN_BOTTOM) - ar->alignment= RGN_ALIGN_TOP; - else if (ar->alignment==RGN_ALIGN_LEFT) - ar->alignment= RGN_ALIGN_RIGHT; - else if (ar->alignment==RGN_ALIGN_RIGHT) - ar->alignment= RGN_ALIGN_LEFT; + if (ar->alignment == RGN_ALIGN_TOP) + ar->alignment = RGN_ALIGN_BOTTOM; + else if (ar->alignment == RGN_ALIGN_BOTTOM) + ar->alignment = RGN_ALIGN_TOP; + else if (ar->alignment == RGN_ALIGN_LEFT) + ar->alignment = RGN_ALIGN_RIGHT; + else if (ar->alignment == RGN_ALIGN_RIGHT) + ar->alignment = RGN_ALIGN_LEFT; ED_area_tag_redraw(CTX_wm_area(C)); - WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_SCREEN | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2752,6 +2754,7 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) /* identifiers */ ot->name = "Flip Header Region"; ot->idname = "SCREEN_OT_header_flip"; + ot->description = "Toggle the header over/below the main window area"; /* api callbacks */ ot->exec = header_flip_exec; @@ -2764,13 +2767,13 @@ static void SCREEN_OT_header_flip(wmOperatorType *ot) static int header_toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= CTX_wm_region(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); uiPopupMenu *pup; uiLayout *layout; - pup= uiPupMenuBegin(C, "Header", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Header", ICON_NONE); + layout = uiPupMenuLayout(pup); // XXX SCREEN_OT_region_flip doesn't work - gets wrong context for active region, so added custom operator if (ar->alignment == RGN_ALIGN_TOP) @@ -2820,7 +2823,7 @@ static int match_area_with_refresh(int spacetype, int refresh) static int match_region_with_redraws(int spacetype, int regiontype, int redraws) { - if (regiontype==RGN_TYPE_WINDOW) { + if (regiontype == RGN_TYPE_WINDOW) { switch (spacetype) { case SPACE_VIEW3D: @@ -2835,7 +2838,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) break; case SPACE_TIME: /* if only 1 window or 3d windows, we do timeline too */ - if (redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN)) + if (redraws & (TIME_ALL_ANIM_WIN | TIME_REGION | TIME_ALL_3D_WIN)) return 1; break; case SPACE_BUTS: @@ -2843,7 +2846,7 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) return 1; break; case SPACE_SEQ: - if (redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) + if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) return 1; break; case SPACE_NODE: @@ -2861,8 +2864,8 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) } } - else if (regiontype==RGN_TYPE_UI) { - if (spacetype==SPACE_CLIP) { + else if (regiontype == RGN_TYPE_UI) { + if (spacetype == SPACE_CLIP) { /* Track Preview button is on Properties Editor in SpaceClip, * and it's very common case when users want it be refreshing * during playback, so asking people to enable special option @@ -2874,14 +2877,14 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) if (redraws & TIME_ALL_BUTS_WIN) return 1; } - else if (regiontype==RGN_TYPE_HEADER) { - if (spacetype==SPACE_TIME) + else if (regiontype == RGN_TYPE_HEADER) { + if (spacetype == SPACE_TIME) return 1; } - else if (regiontype==RGN_TYPE_PREVIEW) { + else if (regiontype == RGN_TYPE_PREVIEW) { switch (spacetype) { case SPACE_SEQ: - if (redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN)) + if (redraws & (TIME_SEQ | TIME_ALL_ANIM_WIN)) return 1; break; case SPACE_CLIP: @@ -2893,21 +2896,21 @@ static int match_region_with_redraws(int spacetype, int regiontype, int redraws) static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); - if (screen->animtimer && screen->animtimer==event->customdata) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; + if (screen->animtimer && screen->animtimer == event->customdata) { + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + wmTimer *wt = screen->animtimer; + ScreenAnimData *sad = wt->customdata; ScrArea *sa; int sync; float time; /* sync, don't sync, or follow scene setting */ - if (sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; - else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; - else sync= (scene->flag & SCE_FRAME_DROP); + if (sad->flag & ANIMPLAY_FLAG_SYNC) sync = 1; + else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync = 0; + else sync = (scene->flag & SCE_FRAME_DROP); if ((scene->audio.flag & AUDIO_SYNC) && (sad->flag & ANIMPLAY_FLAG_REVERSE) == FALSE && @@ -2942,13 +2945,13 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* jump back to end? */ if (PRVRANGEON) { if (scene->r.cfra < scene->r.psfra) { - scene->r.cfra= scene->r.pefra; + scene->r.cfra = scene->r.pefra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } else { if (scene->r.cfra < scene->r.sfra) { - scene->r.cfra= scene->r.efra; + scene->r.cfra = scene->r.efra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } @@ -2957,13 +2960,13 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* jump back to start? */ if (PRVRANGEON) { if (scene->r.cfra > scene->r.pefra) { - scene->r.cfra= scene->r.psfra; + scene->r.cfra = scene->r.psfra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } else { if (scene->r.cfra > scene->r.efra) { - scene->r.cfra= scene->r.sfra; + scene->r.cfra = scene->r.sfra; sad->flag |= ANIMPLAY_FLAG_JUMPED; } } @@ -2982,14 +2985,14 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e /* since we follow drawflags, we can't send notifier but tag regions ourselves */ ED_update_for_newframe(CTX_data_main(C), scene, screen, 1); - for (sa= screen->areabase.first; sa; sa= sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { ARegion *ar; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar==sad->ar) + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar == sad->ar) ED_region_tag_redraw(ar); else - if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) - ED_region_tag_redraw(ar); + if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) + ED_region_tag_redraw(ar); } if (match_area_with_refresh(sa->spacetype, sad->refresh)) @@ -3006,7 +3009,7 @@ static int screen_animation_step(bContext *C, wmOperator *UNUSED(op), wmEvent *e * since the frames-per-second value may have been changed */ // TODO: this may make evaluation a bit slower if the value doesn't change... any way to avoid this? - wt->timestep= (1.0/FPS); + wt->timestep = (1.0 / FPS); return OPERATOR_FINISHED; } @@ -3032,7 +3035,7 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) /* toggle operator */ int ED_screen_animation_play(bContext *C, int sync, int mode) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); if (screen->animtimer) { @@ -3041,7 +3044,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) sound_stop_scene(scene); } else { - int refresh= SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ + int refresh = SPACE_TIME; /* these settings are currently only available from a menu in the TimeLine */ if (mode == 1) // XXX only play audio forwards!? sound_play_scene(scene); @@ -3049,10 +3052,10 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) ED_screen_animation_timer(C, screen->redraws_flag, refresh, sync, mode); if (screen->animtimer) { - wmTimer *wt= screen->animtimer; - ScreenAnimData *sad= wt->customdata; + wmTimer *wt = screen->animtimer; + ScreenAnimData *sad = wt->customdata; - sad->ar= CTX_wm_region(C); + sad->ar = CTX_wm_region(C); } } @@ -3061,11 +3064,11 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) static int screen_animation_play_exec(bContext *C, wmOperator *op) { - int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; - int sync= -1; + int mode = (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; + int sync = -1; if (RNA_struct_property_is_set(op->ptr, "sync")) - sync= (RNA_boolean_get(op->ptr, "sync")); + sync = (RNA_boolean_get(op->ptr, "sync")); return ED_screen_animation_play(C, sync, mode); } @@ -3092,19 +3095,19 @@ static void SCREEN_OT_animation_play(wmOperatorType *ot) static int screen_animation_cancel_exec(bContext *C, wmOperator *op) { - bScreen *screen= CTX_wm_screen(C); + bScreen *screen = CTX_wm_screen(C); if (screen->animtimer) { if (RNA_boolean_get(op->ptr, "restore_frame")) { - ScreenAnimData *sad= screen->animtimer->customdata; - Scene *scene= CTX_data_scene(C); + ScreenAnimData *sad = screen->animtimer->customdata; + Scene *scene = CTX_data_scene(C); /* reset current frame before stopping, and just send a notifier to deal with the rest * (since playback still needs to be stopped) */ - scene->r.cfra= sad->sfra; + scene->r.cfra = sad->sfra; - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } /* call the other "toggling" operator to clean up now */ @@ -3152,11 +3155,11 @@ static void SCREEN_OT_animation_cancel(wmOperatorType *ot) #if 0 static int border_select_do(bContext *C, wmOperator *op) { - int event_type= RNA_int_get(op->ptr, "event_type"); + int event_type = RNA_int_get(op->ptr, "event_type"); - if (event_type==LEFTMOUSE) + if (event_type == LEFTMOUSE) printf("border select do select\n"); - else if (event_type==RIGHTMOUSE) + else if (event_type == RIGHTMOUSE) printf("border select deselect\n"); else printf("border select do something\n"); @@ -3194,10 +3197,10 @@ static void SCREEN_OT_border_select(wmOperatorType *ot) static int fullscreen_back_exec(bContext *C, wmOperator *op) { bScreen *screen = CTX_wm_screen(C); - ScrArea *sa=NULL; + ScrArea *sa = NULL; /* search current screen for 'fullscreen' areas */ - for (sa=screen->areabase.first; sa; sa=sa->next) { + for (sa = screen->areabase.first; sa; sa = sa->next) { if (sa->full) break; } if (!sa) { @@ -3229,12 +3232,12 @@ static int userpref_show_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *ev rcti rect; int sizex, sizey; - sizex= 800; - sizey= 480; + sizex = 800; + sizey = 480; /* some magic to calculate postition */ - rect.xmin = event->x + CTX_wm_window(C)->posx - sizex/2; - rect.ymin = event->y + CTX_wm_window(C)->posy - sizey/2; + rect.xmin = event->x + CTX_wm_window(C)->posx - sizex / 2; + rect.ymin = event->y + CTX_wm_window(C)->posy - sizey / 2; rect.xmax = rect.xmin + sizex; rect.ymax = rect.ymin + sizey; @@ -3261,11 +3264,11 @@ static void SCREEN_OT_userpref_show(struct wmOperatorType *ot) static int screen_new_exec(bContext *C, wmOperator *UNUSED(op)) { - wmWindow *win= CTX_wm_window(C); - bScreen *sc= CTX_wm_screen(C); + wmWindow *win = CTX_wm_window(C); + bScreen *sc = CTX_wm_screen(C); - sc= ED_screen_duplicate(win, sc); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENBROWSE, sc); + sc = ED_screen_duplicate(win, sc); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENBROWSE, sc); return OPERATOR_FINISHED; } @@ -3282,16 +3285,16 @@ static void SCREEN_OT_new(wmOperatorType *ot) ot->poll = WM_operator_winactive; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************* delete screen operator *********************/ static int screen_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - bScreen *sc= CTX_wm_screen(C); + bScreen *sc = CTX_wm_screen(C); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENDELETE, sc); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENDELETE, sc); return OPERATOR_FINISHED; } @@ -3307,22 +3310,22 @@ static void SCREEN_OT_delete(wmOperatorType *ot) ot->exec = screen_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************* new scene operator *********************/ static int scene_new_exec(bContext *C, wmOperator *op) { - Scene *newscene, *scene= CTX_data_scene(C); - Main *bmain= CTX_data_main(C); - int type= RNA_enum_get(op->ptr, "type"); + Scene *newscene, *scene = CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + int type = RNA_enum_get(op->ptr, "type"); if (type == SCE_COPY_NEW) { - newscene= add_scene("Scene"); + newscene = BKE_scene_add("Scene"); } else { /* different kinds of copying */ - newscene= copy_scene(scene, type); + newscene = BKE_scene_copy(scene, type); /* these can't be handled in blenkernel curently, so do them here */ if (type == SCE_COPY_LINK_DATA) { @@ -3335,14 +3338,14 @@ static int scene_new_exec(bContext *C, wmOperator *op) ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); + WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, newscene); return OPERATOR_FINISHED; } static void SCENE_OT_new(wmOperatorType *ot) { - static EnumPropertyItem type_items[]= { + static EnumPropertyItem type_items[] = { {SCE_COPY_NEW, "NEW", 0, "New", "Add new scene"}, {SCE_COPY_EMPTY, "EMPTY", 0, "Copy Settings", "Make a copy without any objects"}, {SCE_COPY_LINK_OB, "LINK_OBJECTS", 0, "Link Objects", "Link to the objects from the current scene"}, @@ -3360,7 +3363,7 @@ static void SCENE_OT_new(wmOperatorType *ot) ot->invoke = WM_menu_invoke; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", ""); @@ -3370,14 +3373,14 @@ static void SCENE_OT_new(wmOperatorType *ot) static int scene_delete_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ED_screen_delete_scene(C, scene); if (G.debug & G_DEBUG) printf("scene delete %p\n", scene); - WM_event_add_notifier(C, NC_SCENE|NA_REMOVED, scene); + WM_event_add_notifier(C, NC_SCENE | NA_REMOVED, scene); return OPERATOR_FINISHED; } @@ -3393,7 +3396,7 @@ static void SCENE_OT_delete(wmOperatorType *ot) ot->exec = scene_delete_exec; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************** Assigning operatortypes to global list, adding handlers **************** */ @@ -3462,7 +3465,7 @@ static void keymap_modal_set(wmKeyConfig *keyconf) wmKeyMap *keymap; /* Standard Modal keymap ------------------------------------------------ */ - keymap= WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items); + keymap = WM_modalkeymap_add(keyconf, "Standard Modal Map", modal_items); WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, KM_MODAL_CANCEL); WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, KM_MODAL_APPLY); @@ -3478,8 +3481,8 @@ static void keymap_modal_set(wmKeyConfig *keyconf) static int open_file_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event)) { - if (drag->type==WM_DRAG_PATH) { - if (drag->icon==ICON_FILE_BLEND) + if (drag->type == WM_DRAG_PATH) { + if (drag->icon == ICON_FILE_BLEND) return 1; } return 0; @@ -3489,7 +3492,7 @@ static void open_file_drop_copy(wmDrag *drag, wmDropBox *drop) { /* copy drag path to properties */ RNA_string_set(drop->ptr, "filepath", drag->path); - drop->opcontext= WM_OP_EXEC_DEFAULT; + drop->opcontext = WM_OP_EXEC_DEFAULT; } @@ -3540,7 +3543,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "SCREEN_OT_screencast", F3KEY, KM_PRESS, KM_ALT, 0); /* tests */ - WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_region_quadview", QKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_repeat_last", RKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0); @@ -3555,12 +3558,12 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* undo */ #ifdef __APPLE__ WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0); - WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0); - WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_OSKEY, 0); + WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_OSKEY, 0); + WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_OSKEY, 0); #endif WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0); - WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); - WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT|KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); + WM_keymap_add_item(keymap, "ED_OT_undo_history", ZKEY, KM_PRESS, KM_ALT | KM_CTRL, 0); /* render */ @@ -3575,7 +3578,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #ifdef __APPLE__ WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", COMMAKEY, KM_PRESS, KM_OSKEY, 0); #endif - WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + WM_keymap_add_item(keymap, "SCREEN_OT_userpref_show", UKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); /* Anim Playback ------------------------------------------------ */ @@ -3590,8 +3593,8 @@ void ED_keymap_screen(wmKeyConfig *keyconf) RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELDOWNMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", 1); RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", WHEELUPMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "delta", -1); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", TRUE); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0)->ptr, "end", FALSE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", UPARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", DOWNARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0)->ptr, "end", FALSE); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", TRUE); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "end", FALSE); @@ -3609,7 +3612,7 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", TRUE); + RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0)->ptr, "reverse", TRUE); WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", MEDIAPLAY, KM_PRESS, 0, 0); @@ -3619,17 +3622,17 @@ void ED_keymap_screen(wmKeyConfig *keyconf) #if 0 // XXX: disabled for restoring later... bad implementation keymap = WM_keymap_find(keyconf, "Frames", 0, 0); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); + RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "reverse", TRUE); - RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); + RNA_boolean_set(kmi->ptr, "reverse", TRUE); + RNA_boolean_set(kmi->ptr, "cycle_speed", TRUE); WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0); #endif /* dropbox for entire window */ - lb= WM_dropboxmap_find("Window", 0, 0); + lb = WM_dropboxmap_find("Window", 0, 0); WM_dropbox_add(lb, "WM_OT_open_mainfile", open_file_drop_poll, open_file_drop_copy); keymap_modal_set(keyconf); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 22a1770412f..256df21b79a 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -78,18 +78,18 @@ typedef struct ScreenshotData { /* get shot from frontbuffer */ static unsigned int *screenshot(bContext *C, int *dumpsx, int *dumpsy) { - wmWindow *win= CTX_wm_window(C); - int x=0, y=0; - unsigned int *dumprect= NULL; - - x= 0; - y= 0; - *dumpsx= win->sizex; - *dumpsy= win->sizey; + wmWindow *win = CTX_wm_window(C); + int x = 0, y = 0; + unsigned int *dumprect = NULL; + + x = 0; + y = 0; + *dumpsx = win->sizex; + *dumpsy = win->sizey; if (*dumpsx && *dumpsy) { - dumprect= MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); + dumprect = MEM_mallocN(sizeof(int) * (*dumpsx) * (*dumpsy), "dumprect"); glReadBuffer(GL_FRONT); glReadPixels(x, y, *dumpsx, *dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); glFinish(); @@ -108,17 +108,17 @@ static int screenshot_data_create(bContext *C, wmOperator *op) /* do redraw so we don't show popups/menus */ WM_redraw_windows(C); - dumprect= screenshot(C, &dumpsx, &dumpsy); + dumprect = screenshot(C, &dumpsx, &dumpsy); if (dumprect) { - ScreenshotData *scd= MEM_callocN(sizeof(ScreenshotData), "screenshot"); - ScrArea *sa= CTX_wm_area(C); + ScreenshotData *scd = MEM_callocN(sizeof(ScreenshotData), "screenshot"); + ScrArea *sa = CTX_wm_area(C); - scd->dumpsx= dumpsx; - scd->dumpsy= dumpsy; - scd->dumprect= dumprect; + scd->dumpsx = dumpsx; + scd->dumpsy = dumpsy; + scd->dumprect = dumprect; if (sa) { - scd->crop= sa->totrct; + scd->crop = sa->totrct; } BKE_imformat_defaults(&scd->im_format); @@ -128,46 +128,46 @@ static int screenshot_data_create(bContext *C, wmOperator *op) return TRUE; } else { - op->customdata= NULL; + op->customdata = NULL; return FALSE; } } static void screenshot_data_free(wmOperator *op) { - ScreenshotData *scd= op->customdata; + ScreenshotData *scd = op->customdata; if (scd) { if (scd->dumprect) MEM_freeN(scd->dumprect); MEM_freeN(scd); - op->customdata= NULL; + op->customdata = NULL; } } static void screenshot_crop(ImBuf *ibuf, rcti crop) { - unsigned int *to= ibuf->rect; - unsigned int *from= ibuf->rect + crop.ymin*ibuf->x + crop.xmin; - int y, cropw= crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin; + unsigned int *to = ibuf->rect; + unsigned int *from = ibuf->rect + crop.ymin * ibuf->x + crop.xmin; + int y, cropw = crop.xmax - crop.xmin, croph = crop.ymax - crop.ymin; if (cropw > 0 && croph > 0) { - for (y=0; yx) - memmove(to, from, sizeof(unsigned int)*cropw); + for (y = 0; y < croph; y++, to += cropw, from += ibuf->x) + memmove(to, from, sizeof(unsigned int) * cropw); - ibuf->x= cropw; - ibuf->y= croph; + ibuf->x = cropw; + ibuf->y = croph; } } static int screenshot_exec(bContext *C, wmOperator *op) { - ScreenshotData *scd= op->customdata; + ScreenshotData *scd = op->customdata; if (scd == NULL) { /* when running exec directly */ screenshot_data_create(C, op); - scd= op->customdata; + scd = op->customdata; } if (scd) { @@ -179,8 +179,8 @@ static int screenshot_exec(bContext *C, wmOperator *op) BLI_path_abs(path, G.main->name); /* operator ensures the extension */ - ibuf= IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); - ibuf->rect= scd->dumprect; + ibuf = IMB_allocImBuf(scd->dumpsx, scd->dumpsy, 24, 0); + ibuf->rect = scd->dumprect; /* crop to show only single editor */ if (!RNA_boolean_get(op->ptr, "full")) @@ -190,7 +190,7 @@ static int screenshot_exec(bContext *C, wmOperator *op) /* bw screenshot? - users will notice if it fails! */ IMB_color_to_bw(ibuf); } - BKE_write_ibuf(ibuf, path, &scd->im_format); + BKE_imbuf_write(ibuf, path, &scd->im_format); IMB_freeImBuf(ibuf); } @@ -255,6 +255,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) { ot->name = "Save Screenshot"; /* weak: opname starting with 'save' makes filewindow give save-over */ ot->idname = "SCREEN_OT_screenshot"; + ot->description = "Capture a picture of the active area or whole Blender window"; ot->invoke = screenshot_invoke; ot->check = screenshot_check; @@ -265,8 +266,8 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) ot->flag = 0; - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE, FILE_SPECIAL, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screenshot the whole Blender window"); } /* *************** screenshot movie job ************************* */ @@ -284,7 +285,7 @@ typedef struct ScreenshotJob { static void screenshot_freejob(void *sjv) { - ScreenshotJob *sj= sjv; + ScreenshotJob *sj = sjv; if (sj->dumprect) MEM_freeN(sj->dumprect); @@ -296,15 +297,15 @@ static void screenshot_freejob(void *sjv) /* called before redraw notifiers, copies a new dumprect */ static void screenshot_updatejob(void *sjv) { - ScreenshotJob *sj= sjv; + ScreenshotJob *sj = sjv; unsigned int *dumprect; - if (sj->dumprect==NULL) { - dumprect= MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); + if (sj->dumprect == NULL) { + dumprect = MEM_mallocN(sizeof(int) * sj->dumpsx * sj->dumpsy, "dumprect"); glReadPixels(sj->x, sj->y, sj->dumpsx, sj->dumpsy, GL_RGBA, GL_UNSIGNED_BYTE, dumprect); glFinish(); - sj->dumprect= dumprect; + sj->dumprect = dumprect; } } @@ -312,13 +313,13 @@ static void screenshot_updatejob(void *sjv) /* only this runs inside thread */ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float *UNUSED(progress)) { - ScreenshotJob *sj= sjv; - RenderData rd= sj->scene->r; - bMovieHandle *mh= BKE_get_movie_handle(sj->scene->r.im_format.imtype); + ScreenshotJob *sj = sjv; + RenderData rd = sj->scene->r; + bMovieHandle *mh = BKE_movie_handle_get(sj->scene->r.im_format.imtype); /* we need this as local variables for renderdata */ - rd.frs_sec= U.scrcastfps; - rd.frs_sec_base= 1.0f; + rd.frs_sec = U.scrcastfps; + rd.frs_sec_base = 1.0f; if (BKE_imtype_is_movie(rd.im_format.imtype)) { if (!mh->start_movie(sj->scene, &rd, sj->dumpsx, sj->dumpsy, &sj->reports)) { @@ -327,20 +328,20 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } } else - mh= NULL; + mh = NULL; - sj->stop= stop; - sj->do_update= do_update; + sj->stop = stop; + sj->do_update = do_update; - *do_update= 1; // wait for opengl rect + *do_update = 1; // wait for opengl rect - while (*stop==0) { + while (*stop == 0) { if (sj->dumprect) { if (mh) { if (mh->append_movie(&rd, rd.sfra, rd.cfra, (int *)sj->dumprect, - sj->dumpsx, sj->dumpsy, &sj->reports)) + sj->dumpsx, sj->dumpsy, &sj->reports)) { BKE_reportf(&sj->reports, RPT_INFO, "Appended frame: %d", rd.cfra); printf("Appended frame %d\n", rd.cfra); @@ -350,16 +351,16 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } } else { - ImBuf *ibuf= IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); + ImBuf *ibuf = IMB_allocImBuf(sj->dumpsx, sj->dumpsy, rd.im_format.planes, 0); char name[FILE_MAX]; int ok; BKE_makepicstring(name, rd.pic, sj->bmain->name, rd.cfra, rd.im_format.imtype, rd.scemode & R_EXTENSION, TRUE); - ibuf->rect= sj->dumprect; - ok= BKE_write_ibuf(ibuf, name, &rd.im_format); + ibuf->rect = sj->dumprect; + ok = BKE_imbuf_write(ibuf, name, &rd.im_format); - if (ok==0) { + if (ok == 0) { printf("Write error: cannot save %s\n", name); BKE_reportf(&sj->reports, RPT_INFO, "Write error: cannot save %s\n", name); break; @@ -374,9 +375,9 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float } MEM_freeN(sj->dumprect); - sj->dumprect= NULL; + sj->dumprect = NULL; - *do_update= 1; + *do_update = 1; rd.cfra++; @@ -393,38 +394,38 @@ static void screenshot_startjob(void *sjv, short *stop, short *do_update, float static int screencast_exec(bContext *C, wmOperator *op) { - bScreen *screen= CTX_wm_screen(C); - wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0); - ScreenshotJob *sj= MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); + bScreen *screen = CTX_wm_screen(C); + wmJob *steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), screen, "Screencast", 0); + ScreenshotJob *sj = MEM_callocN(sizeof(ScreenshotJob), "screenshot job"); /* setup sj */ if (RNA_boolean_get(op->ptr, "full")) { - wmWindow *win= CTX_wm_window(C); - sj->x= 0; - sj->y= 0; - sj->dumpsx= win->sizex; - sj->dumpsy= win->sizey; + wmWindow *win = CTX_wm_window(C); + sj->x = 0; + sj->y = 0; + sj->dumpsx = win->sizex; + sj->dumpsy = win->sizey; } else { - ScrArea *curarea= CTX_wm_area(C); - sj->x= curarea->totrct.xmin; - sj->y= curarea->totrct.ymin; - sj->dumpsx= curarea->totrct.xmax - sj->x; - sj->dumpsy= curarea->totrct.ymax - sj->y; + ScrArea *curarea = CTX_wm_area(C); + sj->x = curarea->totrct.xmin; + sj->y = curarea->totrct.ymin; + sj->dumpsx = curarea->totrct.xmax - sj->x; + sj->dumpsy = curarea->totrct.ymax - sj->y; } - sj->bmain= CTX_data_main(C); - sj->scene= CTX_data_scene(C); + sj->bmain = CTX_data_main(C); + sj->scene = CTX_data_scene(C); BKE_reports_init(&sj->reports, RPT_PRINT); /* setup job */ WM_jobs_customdata(steve, sj, screenshot_freejob); - WM_jobs_timer(steve, 0.1, 0, NC_SCREEN|ND_SCREENCAST); + WM_jobs_timer(steve, 0.1, 0, NC_SCREEN | ND_SCREENCAST); WM_jobs_callbacks(steve, screenshot_startjob, NULL, screenshot_updatejob, NULL); WM_jobs_start(CTX_wm_manager(C), steve); - WM_event_add_notifier(C, NC_SCREEN|ND_SCREENCAST, screen); + WM_event_add_notifier(C, NC_SCREEN | ND_SCREENCAST, screen); return OPERATOR_FINISHED; } @@ -433,6 +434,7 @@ void SCREEN_OT_screencast(wmOperatorType *ot) { ot->name = "Make Screencast"; ot->idname = "SCREEN_OT_screencast"; + ot->description = "Capture a video of the active area or whole Blender window"; ot->invoke = WM_operator_confirm; ot->exec = screencast_exec; @@ -441,8 +443,5 @@ void SCREEN_OT_screencast(wmOperatorType *ot) ot->flag = 0; RNA_def_property(ot->srna, "filepath", PROP_STRING, PROP_FILEPATH); - RNA_def_boolean(ot->srna, "full", 1, "Full Screen", ""); + RNA_def_boolean(ot->srna, "full", 1, "Full Screen", "Screencast the whole Blender window"); } - - - diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt index cf8179b4d0e..043b7ecb5cb 100644 --- a/source/blender/editors/sculpt_paint/CMakeLists.txt +++ b/source/blender/editors/sculpt_paint/CMakeLists.txt @@ -42,6 +42,7 @@ set(SRC paint_cursor.c paint_hide.c paint_image.c + paint_mask.c paint_ops.c paint_stroke.c paint_undo.c diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index 47536d99fcb..87bc89f810c 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -45,6 +45,7 @@ #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "BKE_ccg.h" #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_mesh.h" @@ -83,10 +84,14 @@ static int planes_contain_v3(float (*planes)[4], int totplane, const float p[3]) /* return true if the element should be hidden/shown */ static int is_effected(PartialVisArea area, float planes[4][4], - const float co[3]) + const float co[3], + const float mask) { if (area == PARTIALVIS_ALL) return 1; + else if (area == PARTIALVIS_MASKED) { + return mask > 0.5; + } else { int inside = planes_contain_v3(planes, 4, co); return ((inside && area == PARTIALVIS_INSIDE) || @@ -101,20 +106,24 @@ static void partialvis_update_mesh(Object *ob, PartialVisArea area, float planes[4][4]) { + Mesh *me = ob->data; MVert *mvert; + float *paint_mask; int *vert_indices; int any_changed = 0, any_visible = 0, totvert, i; BLI_pbvh_node_num_verts(pbvh, node, NULL, &totvert); BLI_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); + paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); for (i = 0; i < totvert; i++) { MVert *v = &mvert[vert_indices[i]]; + float vmask = paint_mask ? paint_mask[vert_indices[i]] : 0; /* hide vertex if in the hide volume */ - if (is_effected(area, planes, v->co)) { + if (is_effected(area, planes, v->co, vmask)) { if (action == PARTIALVIS_HIDE) v->flag |= ME_HIDE; else @@ -141,16 +150,18 @@ static void partialvis_update_grids(Object *ob, PartialVisArea area, float planes[4][4]) { - DMGridData **grids; + CCGElem **grids; + CCGKey key; BLI_bitmap *grid_hidden; int any_visible = 0; - int *grid_indices, gridsize, totgrid, any_changed, i; + int *grid_indices, totgrid, any_changed, i; /* get PBVH data */ BLI_pbvh_node_get_grids(pbvh, node, - &grid_indices, &totgrid, NULL, &gridsize, + &grid_indices, &totgrid, NULL, NULL, &grids, NULL); grid_hidden = BLI_pbvh_grid_hidden(pbvh); + BLI_pbvh_get_grid_key(pbvh, &key); sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); @@ -164,7 +175,7 @@ static void partialvis_update_grids(Object *ob, switch (action) { case PARTIALVIS_HIDE: /* create grid flags data */ - gh = grid_hidden[g] = BLI_BITMAP_NEW(gridsize * gridsize, + gh = grid_hidden[g] = BLI_BITMAP_NEW(key.grid_area, "partialvis_update_grids"); break; case PARTIALVIS_SHOW: @@ -182,21 +193,23 @@ static void partialvis_update_grids(Object *ob, continue; } - for (y = 0; y < gridsize; y++) { - for (x = 0; x < gridsize; x++) { - const float *co = grids[g][y * gridsize + x].co; + for (y = 0; y < key.grid_size; y++) { + for (x = 0; x < key.grid_size; x++) { + CCGElem *elem = CCG_grid_elem(&key, grids[g], x, y); + const float *co = CCG_elem_co(&key, elem); + float mask = *CCG_elem_mask(&key, elem); /* skip grid element if not in the effected area */ - if (is_effected(area, planes, co)) { + if (is_effected(area, planes, co, mask)) { /* set or clear the hide flag */ - BLI_BITMAP_MODIFY(gh, y * gridsize + x, + BLI_BITMAP_MODIFY(gh, y * key.grid_size + x, action == PARTIALVIS_HIDE); any_changed = 1; } /* keep track of whether any elements are still hidden */ - if (BLI_BITMAP_GET(gh, y * gridsize + x)) + if (BLI_BITMAP_GET(gh, y * key.grid_size + x)) any_hidden = 1; else any_visible = 1; @@ -263,7 +276,9 @@ static void get_pbvh_nodes(PBVH *pbvh, cb = BLI_pbvh_node_planes_exclude_AABB; break; case PARTIALVIS_ALL: + case PARTIALVIS_MASKED: cb = NULL; + break; } BLI_pbvh_search_gather(pbvh, cb, clip_planes, nodes, totnode); @@ -328,9 +343,9 @@ static int hide_show_exec(bContext *C, wmOperator *op) /* ensure that edges and faces get hidden as well (not used by * sculpt but it looks wrong when entering editmode otherwise) */ if (pbvh_type == PBVH_FACES) { - mesh_flush_hidden_from_verts(me->mvert, me->mloop, - me->medge, me->totedge, - me->mpoly, me->totpoly); + BKE_mesh_flush_hidden_from_verts(me->mvert, me->mloop, + me->medge, me->totedge, + me->mpoly, me->totpoly); } ED_region_tag_redraw(ar); @@ -342,7 +357,7 @@ static int hide_show_invoke(bContext *C, wmOperator *op, wmEvent *event) { PartialVisArea area = RNA_enum_get(op->ptr, "area"); - if (area != PARTIALVIS_ALL) + if (!ELEM(area, PARTIALVIS_ALL, PARTIALVIS_MASKED)) return WM_border_select_invoke(C, op, event); else return op->type->exec(C, op); @@ -353,17 +368,21 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) static EnumPropertyItem action_items[] = { {PARTIALVIS_HIDE, "HIDE", 0, "Hide", "Hide vertices"}, {PARTIALVIS_SHOW, "SHOW", 0, "Show", "Show vertices"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem area_items[] = { {PARTIALVIS_OUTSIDE, "OUTSIDE", 0, "Outside", "Hide or show vertices outside the selection"}, {PARTIALVIS_INSIDE, "INSIDE", 0, "Inside", "Hide or show vertices inside the selection"}, {PARTIALVIS_ALL, "ALL", 0, "All", "Hide or show all vertices"}, - {0, NULL, 0, NULL, NULL}}; + {PARTIALVIS_MASKED, "MASKED", 0, "Masked", "Hide or show vertices that are masked (minimum mask value of 0.5)"}, + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Hide/Show"; ot->idname = "PAINT_OT_hide_show"; + ot->description = "Hide/show some vertices"; /* api callbacks */ ot->invoke = hide_show_invoke; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a025a84bea9..c46c153aa70 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -310,7 +310,7 @@ typedef struct ProjPaintState { short do_occlude; /* Use raytraced occlusion? - ortherwise will paint right through to the back*/ short do_backfacecull; /* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */ short do_mask_normal; /* mask out pixels based on their normals */ - short do_new_shading_nodes; /* cache scene_use_new_shading_nodes value */ + short do_new_shading_nodes; /* cache BKE_scene_use_new_shading_nodes value */ float normal_angle; /* what angle to mask at*/ float normal_angle_inner; float normal_angle_range; /* difference between normal_angle and normal_angle_inner, for easy access */ @@ -526,7 +526,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) { Image *ima; - if (scene_use_new_shading_nodes(s->scene)) { + if (BKE_scene_use_new_shading_nodes(s->scene)) { MFace *mf = &s->dm_mface[face_index]; ED_object_get_active_image(s->ob, mf->mat_nr + 1, &ima, NULL, NULL); } @@ -542,7 +542,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa { Image *ima; - if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ + if (ps->do_new_shading_nodes) { /* cached BKE_scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface + face_index; ED_object_get_active_image(ps->ob, mf->mat_nr + 1, &ima, NULL, NULL); } @@ -4775,7 +4775,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1; ps->do_occlude = (settings->imapaint.flag & IMAGEPAINT_PROJECT_XRAY) ? 0 : 1; ps->do_mask_normal = (settings->imapaint.flag & IMAGEPAINT_PROJECT_FLAT) ? 0 : 1; - ps->do_new_shading_nodes = scene_use_new_shading_nodes(scene); /* only cache the value */ + ps->do_new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* only cache the value */ if (ps->tool == PAINT_TOOL_CLONE) ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE); @@ -4858,7 +4858,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) if (pop->mode != PAINT_MODE_2D) { Object *ob = OBACT; - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (!me) { return 0; @@ -5160,6 +5160,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Image Paint"; ot->idname = "PAINT_OT_image_paint"; + ot->description = "Paint a stroke into the image"; /* api callbacks */ ot->exec = paint_exec; @@ -5387,6 +5388,7 @@ void PAINT_OT_grab_clone(wmOperatorType *ot) /* identifiers */ ot->name = "Grab Clone"; ot->idname = "PAINT_OT_grab_clone"; + ot->description = "Move the clone source image"; /* api callbacks */ ot->exec = grab_clone_exec; @@ -5451,7 +5453,7 @@ static int image_paint_sample_color_poll(bContext *C) if (CTX_wm_view3d(C)) { Object *obact = CTX_data_active_object(C); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { - Mesh *me = get_mesh(obact); + Mesh *me = BKE_mesh_from_object(obact); if (me) { return !(me->editflag & ME_EDIT_PAINT_MASK); } @@ -5469,6 +5471,7 @@ void PAINT_OT_sample_color(wmOperatorType *ot) /* identifiers */ ot->name = "Sample Color"; ot->idname = "PAINT_OT_sample_color"; + ot->description = "Use the mouse to sample a color in the image"; /* api callbacks */ ot->exec = sample_color_exec; @@ -5520,6 +5523,7 @@ void PAINT_OT_clone_cursor_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Clone Cursor"; ot->idname = "PAINT_OT_clone_cursor_set"; + ot->description = "Set the location of the clone cursor"; /* api callbacks */ ot->exec = set_clone_cursor_exec; @@ -5554,12 +5558,12 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) if (ob == NULL) return OPERATOR_CANCELLED; - if (object_data_is_libdata(ob)) { + if (BKE_object_obdata_is_libdata(ob)) { BKE_report(op->reports, RPT_ERROR, "Can't edit external libdata"); return OPERATOR_CANCELLED; } - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects"); @@ -5602,6 +5606,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Texture Paint Toggle"; ot->idname = "PAINT_OT_texture_paint_toggle"; + ot->description = "Toggle texture paint mode in 3D view"; /* api callbacks */ ot->exec = texture_paint_toggle_exec; @@ -5794,7 +5799,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - image = BKE_add_image_imbuf(ibuf); + image = BKE_image_add_from_imbuf(ibuf); if (image) { /* now for the trickyness. store the view projection here! diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 65fb65c1553..a97563b258f 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -43,6 +43,7 @@ struct PaintStroke; struct PointerRNA; struct rcti; struct Scene; +struct RegionView3D; struct VPaint; struct ViewContext; struct wmEvent; @@ -56,8 +57,8 @@ typedef void (*StrokeUpdateStep)(struct bContext *C, struct PaintStroke *stroke, typedef void (*StrokeDone)(const struct bContext *C, struct PaintStroke *stroke); struct PaintStroke *paint_stroke_new(struct bContext *C, - StrokeGetLocation get_location, StrokeTestStart test_start, - StrokeUpdateStep update_step, StrokeDone done, int event_type); + StrokeGetLocation get_location, StrokeTestStart test_start, + StrokeUpdateStep update_step, StrokeDone done, int event_type); void paint_stroke_data_free(struct wmOperator *op); int paint_space_stroke_enabled(struct Brush *br); @@ -115,24 +116,24 @@ void SCULPT_OT_uv_sculpt_stroke(struct wmOperatorType *ot); * its minimum and maximum corners) into a screen-space rectangle, * returns zero if the result is empty */ int paint_convert_bb_to_rect(struct rcti *rect, - const float bb_min[3], - const float bb_max[3], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob); + const float bb_min[3], + const float bb_max[3], + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob); /* Get four planes in object-space that describe the projection of * screen_rect from screen into object-space (essentially converting a * 2D screens-space bounding box into four 3D planes) */ void paint_calc_redraw_planes(float planes[4][4], - const struct ARegion *ar, - struct RegionView3D *rv3d, - struct Object *ob, - const struct rcti *screen_rect); + const struct ARegion *ar, + struct RegionView3D *rv3d, + struct Object *ob, + const struct rcti *screen_rect); void projectf(struct bglMats *mats, const float v[3], float p[2]); float paint_calc_object_space_radius(struct ViewContext *vc, const float center[3], float pixel_radius); -float paint_get_tex_pixel(struct Brush* br, float u, float v); +float paint_get_tex_pixel(struct Brush *br, float u, float v); int imapaint_pick_face(struct ViewContext *vc, const int mval[2], unsigned int *index, unsigned int totface); void imapaint_pick_uv(struct Scene *scene, struct Object *ob, unsigned int faceindex, const int xy[2], float uv[2]); @@ -179,9 +180,19 @@ typedef enum { typedef enum { PARTIALVIS_INSIDE, PARTIALVIS_OUTSIDE, - PARTIALVIS_ALL + PARTIALVIS_ALL, + PARTIALVIS_MASKED } PartialVisArea; void PAINT_OT_hide_show(struct wmOperatorType *ot); +/* paint_mask.c */ + +typedef enum { + PAINT_MASK_FLOOD_VALUE, + PAINT_MASK_INVERT +} PaintMaskFloodMode; + +void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot); + #endif /* __PAINT_INTERN_H__ */ diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c new file mode 100644 index 00000000000..000f43b0dec --- /dev/null +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -0,0 +1,143 @@ +/* + * $Id$ + * + * ***** 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 by Nicholas Bishop + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/editors/sculpt_paint/paint_mask.c + * \ingroup edsculpt + */ + +#include "MEM_guardedalloc.h" + +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" +#include "DNA_object_types.h" + +#include "BLI_pbvh.h" + +#include "BKE_ccg.h" +#include "BKE_context.h" +#include "BKE_DerivedMesh.h" +#include "BKE_multires.h" +#include "BKE_paint.h" +#include "BKE_subsurf.h" + +#include "RNA_access.h" +#include "RNA_define.h" + +#include "WM_api.h" +#include "WM_types.h" + +#include "ED_screen.h" + +#include "paint_intern.h" +#include "sculpt_intern.h" /* for undo push */ + +#include + +static void mask_flood_fill_set_elem(float *elem, + PaintMaskFloodMode mode, + float value) +{ + switch(mode) { + case PAINT_MASK_FLOOD_VALUE: + (*elem) = value; + break; + case PAINT_MASK_INVERT: + (*elem) = 1.0f - (*elem); + break; + } +} + +static int mask_flood_fill_exec(bContext *C, wmOperator *op) +{ + ARegion *ar = CTX_wm_region(C); + Object *ob = CTX_data_active_object(C); + PaintMaskFloodMode mode; + float value; + DerivedMesh *dm; + PBVH *pbvh; + PBVHNode **nodes; + int totnode, i; + + mode = RNA_enum_get(op->ptr, "mode"); + value = RNA_float_get(op->ptr, "value"); + + dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); + pbvh = dm->getPBVH(ob, dm); + ob->sculpt->pbvh = pbvh; + + BLI_pbvh_search_gather(pbvh, NULL, NULL, &nodes, &totnode); + + sculpt_undo_push_begin("Mask flood fill"); + + for(i = 0; i < totnode; i++) { + PBVHVertexIter vi; + + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + + BLI_pbvh_vertex_iter_begin(pbvh, nodes[i], vi, PBVH_ITER_UNIQUE) { + mask_flood_fill_set_elem(vi.mask, mode, value); + } BLI_pbvh_vertex_iter_end; + + BLI_pbvh_node_mark_update(nodes[i]); + if(BLI_pbvh_type(pbvh) == PBVH_GRIDS) + multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); + } + + sculpt_undo_push_end(); + + if(nodes) + MEM_freeN(nodes); + + ED_region_tag_redraw(ar); + + return OPERATOR_FINISHED; +} + +void PAINT_OT_mask_flood_fill(struct wmOperatorType *ot) +{ + static EnumPropertyItem mode_items[] = { + {PAINT_MASK_FLOOD_VALUE, "VALUE", 0, "Value", "Set mask to the level specified by the \"value\" property"}, + {PAINT_MASK_INVERT, "INVERT", 0, "Invert", "Invert the mask"}, + {0}}; + + /* identifiers */ + ot->name = "Mask Flood Fill"; + ot->idname = "PAINT_OT_mask_flood_fill"; + + /* api callbacks */ + ot->exec = mask_flood_fill_exec; + ot->poll = sculpt_mode_poll; + + ot->flag = OPTYPE_REGISTER; + + /* rna */ + RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL); + RNA_def_float(ot->srna, "value", 0, 0, 1, "Value", "Mask level to use when mode is \"Value\"; zero means no masking and one is fully masked", 0, 1); +} diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 2699e9f56f8..f8ed20430e7 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" #include +#include "BLI_listbase.h" #include "BLI_string.h" #include "BLI_utildefines.h" @@ -160,6 +161,7 @@ static void PAINT_OT_vertex_color_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Vertex Colors"; ot->idname = "PAINT_OT_vertex_color_set"; + ot->description = "Fill the active vertex color layer with the current paint color"; /* api callbacks */ ot->exec = vertex_color_set_exec; @@ -203,6 +205,11 @@ static int brush_tool(const Brush *brush, size_t tool_offset) return *(((char *)brush) + tool_offset); } +static void brush_tool_set(const Brush *brush, size_t tool_offset, int tool) +{ + *(((char *)brush) + tool_offset) = tool; +} + /* generic functions for setting the active brush based on the tool */ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) { @@ -226,11 +233,49 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c return NULL; } -static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, const size_t tool_offset, const int ob_mode) +static Brush *brush_tool_toggle(Main *bmain, Brush *brush_orig, const int tool, const size_t tool_offset, const int ob_mode) +{ + if (!brush_orig || brush_tool(brush_orig, tool_offset) != tool) { + Brush *br; + /* if the current brush is not using the desired tool, look + for one that is */ + br = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + /* store the previously-selected brush */ + if (br) + br->toggle_brush = brush_orig; + + return br; + } + else if (brush_orig->toggle_brush && + BLI_findindex(bmain->brush.first, brush_orig->toggle_brush) != -1) + { + /* if current brush is using the desired tool, try to toggle + back to the previously selected brush (if it was set, and + if it still exists) */ + return brush_orig->toggle_brush; + } + else + return NULL; +} + +static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, + const size_t tool_offset, const int ob_mode, + const char *tool_name, int create_missing, + int toggle) { struct Brush *brush, *brush_orig = paint_brush(paint); - brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + if (toggle) + brush = brush_tool_toggle(bmain, brush_orig, tool, tool_offset, ob_mode); + else + brush = brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); + + if (!brush && brush_tool(brush_orig, tool_offset) != tool && create_missing) { + brush = BKE_brush_add(tool_name); + brush_tool_set(brush, tool_offset, tool); + brush->ob_mode = ob_mode; + brush->toggle_brush = brush_orig; + } if (brush) { paint_brush_set(paint, brush); @@ -251,6 +296,9 @@ static int brush_select_exec(bContext *C, wmOperator *op) ToolSettings *toolsettings = CTX_data_tool_settings(C); Paint *paint = NULL; int tool, paint_mode = RNA_enum_get(op->ptr, "paint_mode"); + int create_missing = RNA_boolean_get(op->ptr, "create_missing"); + int toggle = RNA_boolean_get(op->ptr, "toggle"); + const char *tool_name = "Brush"; size_t tool_offset; if (paint_mode == OB_MODE_ACTIVE) { @@ -273,29 +321,35 @@ static int brush_select_exec(bContext *C, wmOperator *op) paint = &toolsettings->sculpt->paint; tool_offset = offsetof(Brush, sculpt_tool); tool = RNA_enum_get(op->ptr, "sculpt_tool"); + RNA_enum_name_from_value(brush_sculpt_tool_items, tool, &tool_name); break; case OB_MODE_VERTEX_PAINT: paint = &toolsettings->vpaint->paint; tool_offset = offsetof(Brush, vertexpaint_tool); tool = RNA_enum_get(op->ptr, "vertex_paint_tool"); + RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); break; case OB_MODE_WEIGHT_PAINT: paint = &toolsettings->wpaint->paint; /* vertexpaint_tool is used for weight paint mode */ tool_offset = offsetof(Brush, vertexpaint_tool); tool = RNA_enum_get(op->ptr, "weight_paint_tool"); + RNA_enum_name_from_value(brush_vertex_tool_items, tool, &tool_name); break; case OB_MODE_TEXTURE_PAINT: paint = &toolsettings->imapaint.paint; tool_offset = offsetof(Brush, imagepaint_tool); tool = RNA_enum_get(op->ptr, "texture_paint_tool"); + RNA_enum_name_from_value(brush_image_tool_items, tool, &tool_name); break; default: /* invalid paint mode */ return OPERATOR_CANCELLED; } - return brush_generic_tool_set(bmain, paint, tool, tool_offset, paint_mode); + return brush_generic_tool_set(bmain, paint, tool, tool_offset, + paint_mode, tool_name, create_missing, + toggle); } static void PAINT_OT_brush_select(wmOperatorType *ot) @@ -326,6 +380,9 @@ static void PAINT_OT_brush_select(wmOperatorType *ot) RNA_def_enum(ot->srna, "vertex_paint_tool", brush_vertex_tool_items, 0, "Vertex Paint Tool", ""); RNA_def_enum(ot->srna, "weight_paint_tool", brush_vertex_tool_items, 0, "Weight Paint Tool", ""); RNA_def_enum(ot->srna, "texture_paint_tool", brush_image_tool_items, 0, "Texture Paint Tool", ""); + + RNA_def_boolean(ot->srna, "toggle", 0, "Toggle", "Toggle between two brushes rather than cycling"); + RNA_def_boolean(ot->srna, "create_missing", 0, "Create Missing", "If the requested brush type does not exist, create a new brush"); } static wmKeyMapItem *keymap_brush_select(wmKeyMap *keymap, int paint_mode, @@ -442,6 +499,9 @@ void ED_operatortypes_paint(void) /* partial visibility */ WM_operatortype_append(PAINT_OT_hide_show); + + /* paint masking */ + WM_operatortype_append(PAINT_OT_mask_flood_fill); } @@ -575,6 +635,15 @@ void ED_keymap_paint(wmKeyConfig *keyconf) for (i = 0; i <= 5; i++) RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); + /* Clear mask */ + kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", MKEY, KM_PRESS, KM_ALT, 0); + RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_FLOOD_VALUE); + RNA_float_set(kmi->ptr, "value", 0); + + /* Invert mask */ + kmi = WM_keymap_add_item(keymap, "PAINT_OT_mask_flood_fill", IKEY, KM_PRESS, KM_CTRL, 0); + RNA_enum_set(kmi->ptr, "mode", PAINT_MASK_INVERT); + /* multires switch */ kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0); RNA_int_set(kmi->ptr, "level", 1); @@ -597,6 +666,9 @@ void ED_keymap_paint(wmKeyConfig *keyconf) keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_FLATTEN, TKEY, KM_SHIFT); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CLAY, CKEY, 0); keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_CREASE, CKEY, KM_SHIFT); + kmi = keymap_brush_select(keymap, OB_MODE_SCULPT, SCULPT_TOOL_MASK, MKEY, 0); + RNA_boolean_set(kmi->ptr, "toggle", 1); + RNA_boolean_set(kmi->ptr, "create_missing", 1); /* */ kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", AKEY, KM_PRESS, 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index fe228839c47..9832bcf1528 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -188,7 +188,11 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev output[1] = event->y; if ((stroke->brush->flag & BRUSH_SMOOTH_STROKE) && - !ELEM4(stroke->brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK) && + !ELEM4(stroke->brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK) && !(stroke->brush->flag & BRUSH_ANCHORED) && !(stroke->brush->flag & BRUSH_RESTORE_MESH)) { @@ -279,7 +283,7 @@ PaintStroke *paint_stroke_new(bContext *C, void paint_stroke_data_free(struct wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; } static void stroke_done(struct bContext *C, struct wmOperator *op) @@ -323,13 +327,13 @@ struct wmKeyMap *paint_stroke_modal_keymap(struct wmKeyConfig *keyconf) { 0 } }; - static const char *name= "Paint Stroke Modal"; + static const char *name = "Paint Stroke Modal"; - struct wmKeyMap *keymap= WM_modalkeymap_get(keyconf, name); + struct wmKeyMap *keymap = WM_modalkeymap_get(keyconf, name); /* this function is called for each spacetype, only needs to add map once */ if (!keymap) { - keymap= WM_modalkeymap_add(keyconf, name, modal_items); + keymap = WM_modalkeymap_add(keyconf, name, modal_items); /* items for modal map */ WM_modalkeymap_add_item( diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index fb5ddda7a3e..4c374674c9a 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -186,7 +186,7 @@ float paint_get_tex_pixel(Brush *br, float u, float v) hasrgb = multitex_ext(br->mtex.tex, co, NULL, NULL, 0, &texres); if (hasrgb & TEX_RGB) - texres.tin = (0.35f * texres.tr + 0.45f * texres.tg + 0.2f * texres.tb) * texres.ta; + texres.tin = rgb_to_grayscale(&texres.tr) * texres.ta; return texres.tin; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 37d5af553ab..c01da3a816f 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -93,7 +93,7 @@ static int vertex_paint_use_fast_update_check(Object *ob) DerivedMesh *dm = ob->derivedFinal; if (dm) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); if (me && me->mcol) { return (me->mcol == CustomData_get_layer(&dm->faceData, CD_MCOL)); } @@ -110,7 +110,7 @@ static int vertex_paint_use_tessface_check(Object *ob) DerivedMesh *dm = ob->derivedFinal; if (dm) { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); return (me->mpoly == CustomData_get_layer(&dm->faceData, CD_MPOLY)); } @@ -239,7 +239,7 @@ static void do_shared_vertex_tesscol(Mesh *me) mface = me->mface; mcol = (char *)me->mcol; for (a = me->totface; a > 0; a--, mface++, mcol += 16) { - if ((use_face_sel == FALSE)|| (mface->flag & ME_FACE_SEL)) { + if ((use_face_sel == FALSE) || (mface->flag & ME_FACE_SEL)) { scol = scolmain + 4 * mface->v1; mcol[1] = scol[1]; mcol[2] = scol[2]; mcol[3] = scol[3]; scol = scolmain + 4 * mface->v2; @@ -317,7 +317,7 @@ static void make_vertexcol(Object *ob) /* single ob */ { Mesh *me; if (!ob || ob->id.lib) return; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL) return; if (me->edit_btmesh) return; @@ -433,7 +433,7 @@ void vpaint_fill(Object *ob, unsigned int paintcol) MLoopCol *lcol; int i, j, selected; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return; if (!me->mloopcol) make_vertexcol(ob); @@ -551,7 +551,7 @@ void vpaint_dogamma(Scene *scene) unsigned char *cp, gamtab[256]; ob = OBACT; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (!(ob->mode & OB_MODE_VERTEX_PAINT)) return; if (me == 0 || me->mcol == 0 || me->totface == 0) return; @@ -1007,7 +1007,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) short change = FALSE; view3d_set_viewcontext(C, &vc); - me = get_mesh(vc.obact); + me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { int index; @@ -1075,6 +1075,7 @@ void PAINT_OT_weight_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Sample Weight"; ot->idname = "PAINT_OT_weight_sample"; + ot->description = "Use the mouse to sample a weight in the 3D view"; /* api callbacks */ ot->invoke = weight_sample_invoke; @@ -1094,7 +1095,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA Mesh *me; view3d_set_viewcontext(C, &vc); - me = get_mesh(vc.obact); + me = BKE_mesh_from_object(vc.obact); if (me && me->dvert && vc.v3d && vc.rv3d) { int index; @@ -1176,6 +1177,7 @@ void PAINT_OT_weight_sample_group(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Sample Group"; ot->idname = "PAINT_OT_weight_sample_group"; + ot->description = "Select one of the vertex groups available under current mouse position"; /* api callbacks */ ot->exec = weight_sample_group_exec; @@ -1975,7 +1977,7 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ VPaint *wp = scene->toolsettings->wpaint; Mesh *me; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (ob->id.lib || me == NULL) return OPERATOR_PASS_THROUGH; if (ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; @@ -2038,6 +2040,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint Mode"; ot->idname = "PAINT_OT_weight_paint_toggle"; + ot->description = "Toggle weight paint mode in 3D view"; /* api callbacks */ ot->exec = set_wpaint; @@ -2139,7 +2142,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED return FALSE; } - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; /* if nothing was added yet, we make dverts and a vertex deform group */ @@ -2154,7 +2157,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED if ((modob = modifiers_isDeformedByArmature(ob))) { Bone *actbone = ((bArmature *)modob->data)->act_bone; if (actbone) { - bPoseChannel *pchan = get_pose_channel(modob->pose, actbone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(modob->pose, actbone->name); if (pchan) { bDeformGroup *dg = defgroup_find_name(ob, pchan->name); @@ -2490,6 +2493,7 @@ void PAINT_OT_weight_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Weight Paint"; ot->idname = "PAINT_OT_weight_paint"; + ot->description = "Paint a stroke in the current vertex group's weights"; /* api callbacks */ ot->invoke = wpaint_invoke; @@ -2522,6 +2526,7 @@ void PAINT_OT_weight_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Weight"; ot->idname = "PAINT_OT_weight_set"; + ot->description = "Fill the active vertex group with the current paint weight"; /* api callbacks */ ot->exec = weight_paint_set_exec; @@ -2541,9 +2546,9 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ VPaint *vp = scene->toolsettings->vpaint; Mesh *me; - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); - if (me == NULL || object_data_is_libdata(ob)) { + if (me == NULL || BKE_object_obdata_is_libdata(ob)) { ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } @@ -2586,6 +2591,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Paint Mode"; ot->idname = "PAINT_OT_vertex_paint_toggle"; + ot->description = "Toggle the vertex paint mode in 3D view"; /* api callbacks */ ot->exec = set_vpaint; @@ -2678,7 +2684,7 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent float mat[4][4], imat[4][4]; /* context checks could be a poll() */ - me = get_mesh(ob); + me = BKE_mesh_from_object(ob); if (me == NULL || me->totpoly == 0) return OPERATOR_PASS_THROUGH; @@ -2726,7 +2732,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); MFace *mface = &me->mface[index]; unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index; unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index; @@ -2771,7 +2777,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, { ViewContext *vc = &vpd->vc; Brush *brush = paint_brush(&vp->paint); - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); MPoly *mpoly = &me->mpoly[index]; MFace *mf; MCol *mc; @@ -2991,6 +2997,7 @@ void PAINT_OT_vertex_paint(wmOperatorType *ot) /* identifiers */ ot->name = "Vertex Paint"; ot->idname = "PAINT_OT_vertex_paint"; + ot->description = "Paint a stroke in the active vertex color layer"; /* api callbacks */ ot->invoke = vpaint_invoke; @@ -3040,6 +3047,8 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) /* identifiers */ ot->name = "Weight from Bones"; ot->idname = "PAINT_OT_weight_from_bones"; + ot->description = "Set the weights of the groups matching the attached armature's selected bones, " + "using the distance between the vertices and the bones"; /* api callbacks */ ot->exec = weight_from_bones_exec; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fa560dc138c..2d3a7680963 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -52,6 +52,7 @@ #include "DNA_brush_types.h" #include "BKE_brush.h" +#include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -108,7 +109,7 @@ float *ED_sculpt_get_last_stroke(struct Object *ob) int ED_sculpt_minmax(bContext *C, float *min, float *max) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (ob && ob->sculpt && ob->sculpt->last_stroke_valid) { copy_v3_v3(min, ob->sculpt->last_stroke); @@ -123,7 +124,7 @@ int ED_sculpt_minmax(bContext *C, float *min, float *max) /* Sculpt mode handles multires differently from regular meshes, but only if * it's the last modifier on the stack and it is not on the first level */ -struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) +MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) { Mesh *me = (Mesh *)ob->data; ModifierData *md; @@ -257,6 +258,7 @@ typedef struct StrokeCache { float vertex_rotation; char saved_active_brush_name[MAX_ID_NAME]; + char saved_mask_brush_tool; int alt_smooth; float plane_trim_squared; @@ -289,11 +291,16 @@ static void paint_mesh_restore_co(Sculpt *sd, SculptSession *ss) if (unode) { PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - copy_v3_v3(vd.co, unode->co[vd.i]); - if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); - else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); - + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (unode->type == SCULPT_UNDO_COORDS) { + copy_v3_v3(vd.co, unode->co[vd.i]); + if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); + else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); + } + else if (unode->type == SCULPT_UNDO_MASK) { + *vd.mask = unode->mask[vd.i]; + } if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } BLI_pbvh_vertex_iter_end; @@ -639,6 +646,15 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) case SCULPT_TOOL_DRAW: case SCULPT_TOOL_LAYER: return alpha * flip * pressure * overlap * feather; + + case SCULPT_TOOL_MASK: + overlap = (1 + overlap) / 2; + switch ((BrushMaskTool)brush->mask_tool) { + case BRUSH_MASK_DRAW: + return alpha * flip * pressure * overlap * feather; + case BRUSH_MASK_SMOOTH: + return alpha * pressure * feather; + } case SCULPT_TOOL_CREASE: case SCULPT_TOOL_BLOB: @@ -701,7 +717,8 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], const float len, const float sculpt_normal[3], const short vno[3], - const float fno[3]) + const float fno[3], + const float mask) { MTex *mtex = &br->mtex; float avg = 1; @@ -796,6 +813,9 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], avg *= frontface(br, sculpt_normal, vno, fno); + /* Paint mask */ + avg *= 1.0f - mask; + return avg; } @@ -882,7 +902,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod sculpt_brush_test_init(ss, &test); if (ss->cache->original) { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { float fno[3]; @@ -893,7 +914,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, vd.co)) { if (vd.no) { float fno[3]; @@ -1014,7 +1036,36 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert) copy_v3_v3(avg, deform_co ? deform_co[vert] : mvert[vert].co); } -static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength) +/* Similar to neighbor_average(), but returns an averaged mask value + instead of coordinate. Also does not restrict based on border or + corner vertices. */ +static float neighbor_average_mask(SculptSession *ss, unsigned vert) +{ + const float *vmask = ss->vmask; + float avg = 0; + int i, total = 0; + + for (i = 0; i < ss->pmap[vert].count; i++) { + const MPoly *p = &ss->mpoly[ss->pmap[vert].indices[i]]; + unsigned f_adj_v[3]; + + if (poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) { + int j; + + for (j = 0; j < 3; j++) { + avg += vmask[f_adj_v[j]]; + total++; + } + } + } + + if (total > 0) + return avg / (float)total; + else + return vmask[vert]; +} + +static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength, int smooth_mask) { Brush *brush = paint_brush(&sd->paint); PBVHVertexIter vd; @@ -1024,19 +1075,29 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno); - float avg[3], val[3]; + ss->cache->view_normal, vd.no, vd.fno, + smooth_mask ? 0 : *vd.mask); + if (smooth_mask) { + float val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; + val *= fade * bstrength; + *vd.mask += val; + CLAMP(*vd.mask, 0, 1); + } + else { + float avg[3], val[3]; - neighbor_average(ss, avg, vd.vert_indices[vd.i]); - sub_v3_v3v3(val, avg, vd.co); - mul_v3_fl(val, fade); + neighbor_average(ss, avg, vd.vert_indices[vd.i]); + sub_v3_v3v3(val, avg, vd.co); + mul_v3_fl(val, fade); - add_v3_v3(val, vd.co); + add_v3_v3(val, vd.co); - sculpt_clip(sd, ss, vd.co, val); + sculpt_clip(sd, ss, vd.co, val); + } if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; @@ -1045,13 +1106,16 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, BLI_pbvh_vertex_iter_end; } -static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, float bstrength) +static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, + float bstrength, int smooth_mask) { Brush *brush = paint_brush(&sd->paint); SculptBrushTest test; - DMGridData **griddata, *data; + CCGElem **griddata, *data; + CCGKey key; DMGridAdjacency *gridadj, *adj; - float (*tmpgrid)[3], (*tmprow)[3]; + float (*tmpgrid_co)[3], (*tmprow_co)[3]; + float *tmpgrid_mask, *tmprow_mask; int v1, v2, v3, v4; int *grid_indices, totgrid, gridsize, i, x, y; @@ -1061,24 +1125,40 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no BLI_pbvh_node_get_grids(ss->pbvh, node, &grid_indices, &totgrid, NULL, &gridsize, &griddata, &gridadj); + BLI_pbvh_get_grid_key(ss->pbvh, &key); #pragma omp critical { - tmpgrid = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid"); - tmprow = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow"); + if (smooth_mask) { + tmpgrid_mask = MEM_mallocN(sizeof(float) * gridsize * gridsize, "tmpgrid_mask"); + tmprow_mask = MEM_mallocN(sizeof(float) * gridsize, "tmprow_mask"); + } + else { + tmpgrid_co = MEM_mallocN(sizeof(float) * 3 * gridsize * gridsize, "tmpgrid_co"); + tmprow_co = MEM_mallocN(sizeof(float) * 3 * gridsize, "tmprow_co"); + } } for (i = 0; i < totgrid; ++i) { data = griddata[grid_indices[i]]; adj = &gridadj[grid_indices[i]]; - memset(tmpgrid, 0, sizeof(float) * 3 * gridsize * gridsize); + if (smooth_mask) + memset(tmpgrid_mask, 0, sizeof(float) * gridsize * gridsize); + else + memset(tmpgrid_co, 0, sizeof(float) * 3 * gridsize * gridsize); for (y = 0; y < gridsize - 1; y++) { - float tmp[3]; - v1 = y * gridsize; - add_v3_v3v3(tmprow[0], data[v1].co, data[v1 + gridsize].co); + if (smooth_mask) { + tmprow_mask[0] = (*CCG_elem_offset_mask(&key, data, v1) + + *CCG_elem_offset_mask(&key, data, v1 + gridsize)); + } + else { + add_v3_v3v3(tmprow_co[0], + CCG_elem_offset_co(&key, data, v1), + CCG_elem_offset_co(&key, data, v1 + gridsize)); + } for (x = 0; x < gridsize - 1; x++) { v1 = x + y * gridsize; @@ -1086,13 +1166,31 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no v3 = v1 + gridsize; v4 = v3 + 1; - add_v3_v3v3(tmprow[x + 1], data[v2].co, data[v4].co); - add_v3_v3v3(tmp, tmprow[x + 1], tmprow[x]); + if (smooth_mask) { + float tmp; - add_v3_v3(tmpgrid[v1], tmp); - add_v3_v3(tmpgrid[v2], tmp); - add_v3_v3(tmpgrid[v3], tmp); - add_v3_v3(tmpgrid[v4], tmp); + tmprow_mask[x + 1] = (*CCG_elem_offset_mask(&key, data, v2) + + *CCG_elem_offset_mask(&key, data, v4)); + tmp = tmprow_mask[x + 1] + tmprow_mask[x]; + + tmpgrid_mask[v1] += tmp; + tmpgrid_mask[v2] += tmp; + tmpgrid_mask[v3] += tmp; + tmpgrid_mask[v4] += tmp; + } + else { + float tmp[3]; + + add_v3_v3v3(tmprow_co[x + 1], + CCG_elem_offset_co(&key, data, v2), + CCG_elem_offset_co(&key, data, v4)); + add_v3_v3v3(tmp, tmprow_co[x + 1], tmprow_co[x]); + + add_v3_v3(tmpgrid_co[v1], tmp); + add_v3_v3(tmpgrid_co[v2], tmp); + add_v3_v3(tmpgrid_co[v3], tmp); + add_v3_v3(tmpgrid_co[v4], tmp); + } } } @@ -1101,6 +1199,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no for (x = 0; x < gridsize; ++x) { float *co; float *fno; + float *mask; int index; if (x == 0 && adj->index[0] == -1) @@ -1116,33 +1215,40 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no continue; index = x + y * gridsize; - co = data[index].co; - fno = data[index].no; + co = CCG_elem_offset_co(&key, data, index); + fno = CCG_elem_offset_no(&key, data, index); + mask = CCG_elem_offset_mask(&key, data, index); if (sculpt_brush_test(&test, co)) { + const float strength_mask = (smooth_mask ? 0 : *mask); const float fade = bstrength * tex_strength(ss, brush, co, test.dist, - ss->cache->view_normal, NULL, fno); - float *avg, val[3]; - float n; - - avg = tmpgrid[x + y * gridsize]; - - n = 1 / 16.0f; - + ss->cache->view_normal, + NULL, fno, strength_mask); + float n = 1.0f / 16.0f; + if (x == 0 || x == gridsize - 1) n *= 2; - + if (y == 0 || y == gridsize - 1) n *= 2; + + if (smooth_mask) { + *mask += ((tmpgrid_mask[x + y * gridsize] * n) - *mask) * fade; + } + else { + float *avg, val[3]; - mul_v3_fl(avg, n); + avg = tmpgrid_co[x + y * gridsize]; - sub_v3_v3v3(val, avg, co); - mul_v3_fl(val, fade); + mul_v3_fl(avg, n); - add_v3_v3(val, co); + sub_v3_v3v3(val, avg, co); + mul_v3_fl(val, fade); - sculpt_clip(sd, ss, co, val); + add_v3_v3(val, co); + + sculpt_clip(sd, ss, co, val); + } } } } @@ -1150,12 +1256,19 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no #pragma omp critical { - MEM_freeN(tmpgrid); - MEM_freeN(tmprow); + if (smooth_mask) { + MEM_freeN(tmpgrid_mask); + MEM_freeN(tmprow_mask); + } + else { + MEM_freeN(tmpgrid_co); + MEM_freeN(tmprow_co); + } } } -static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float bstrength) +static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, + float bstrength, int smooth_mask) { SculptSession *ss = ob->sculpt; const int max_iterations = 4; @@ -1172,10 +1285,13 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (n = 0; n < totnode; n++) { if (ss->multires) { - do_multires_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); + do_multires_smooth_brush(sd, ss, nodes[n], + iteration != count ? 1.0f : last, smooth_mask); + } + else if (ss->pmap) { + do_mesh_smooth_brush(sd, ss, nodes[n], + iteration != count ? 1.0f : last, smooth_mask); } - else if (ss->pmap) - do_mesh_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } if (ss->multires) @@ -1186,7 +1302,54 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { SculptSession *ss = ob->sculpt; - smooth(sd, ob, nodes, totnode, ss->cache->bstrength); + smooth(sd, ob, nodes, totnode, ss->cache->bstrength, FALSE); +} + +static void do_mask_brush_draw(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = paint_brush(&sd->paint); + float bstrength = ss->cache->bstrength; + int n; + + /* threaded loop over nodes */ + #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) + for (n = 0; n < totnode; n++) { + PBVHVertexIter vd; + SculptBrushTest test; + + sculpt_brush_test_init(ss, &test); + + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { + if (sculpt_brush_test(&test, vd.co)) { + float fade = tex_strength(ss, brush, vd.co, test.dist, + ss->cache->view_normal, vd.no, vd.fno, 0); + + (*vd.mask) += fade * bstrength; + CLAMP(*vd.mask, 0, 1); + + if (vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } + BLI_pbvh_vertex_iter_end; + } + } +} + +static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +{ + SculptSession *ss = ob->sculpt; + Brush *brush = paint_brush(&sd->paint); + + switch ((BrushMaskTool)brush->mask_tool) { + case BRUSH_MASK_DRAW: + do_mask_brush_draw(sd, ob, nodes, totnode); + break; + case BRUSH_MASK_SMOOTH: + smooth(sd, ob, nodes, totnode, ss->cache->bstrength, TRUE); + break; + } } static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) @@ -1215,11 +1378,12 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ float fade = tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno); + area_normal, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], offset, fade); @@ -1239,6 +1403,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod float offset[3], area_normal[3]; float bstrength = ss->cache->bstrength; float flippedbstrength, crease_correction; + float brush_alpha; int n; calc_sculpt_normal(sd, ob, area_normal, nodes, totnode); @@ -1249,11 +1414,10 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_v3_fl(offset, bstrength); /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ - - if (BKE_brush_alpha_get(scene, brush) > 0.0f) - crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor / (BKE_brush_alpha_get(scene, brush) * BKE_brush_alpha_get(scene, brush)); - else - crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; + crease_correction = brush->crease_pinch_factor * brush->crease_pinch_factor; + brush_alpha = BKE_brush_alpha_get(scene, brush); + if (brush_alpha > 0.0f) + crease_correction /= brush_alpha * brush_alpha; /* we always want crease to pinch or blob to relax even when draw is negative */ flippedbstrength = (bstrength < 0) ? -crease_correction * bstrength : crease_correction * bstrength; @@ -1271,11 +1435,12 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ const float fade = tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno); + area_normal, vd.no, vd.fno, *vd.mask); float val1[3]; float val2[3]; @@ -1313,10 +1478,12 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno); + ss->cache->view_normal, vd.no, + vd.fno, *vd.mask); float val[3]; sub_v3_v3v3(val, test.location, vd.co); @@ -1378,7 +1545,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL); + an, origno[vd.i], NULL, *vd.mask); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -1417,10 +1584,11 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1467,10 +1635,11 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -1516,10 +1685,11 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL); + an, origno[vd.i], NULL, *vd.mask); mul_v3_v3fl(proxy[vd.i], cono, fade); @@ -1570,10 +1740,11 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, origco[vd.i], test.dist, - an, origno[vd.i], NULL); + an, origno[vd.i], NULL, *vd.mask); mul_v3_m4v3(proxy[vd.i], m, origco[vd.i]); sub_v3_v3(proxy[vd.i], origco[vd.i]); @@ -1610,7 +1781,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode SculptUndoNode *unode; float (*origco)[3], *layer_disp; /* XXX: layer brush needs conversion to proxy but its more complicated */ - /* proxy= BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; */ + /* proxy = BLI_pbvh_node_add_proxy(ss->pbvh, nodes[n])->co; */ unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); origco = unode->co; @@ -1623,10 +1794,11 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - area_normal, vd.no, vd.fno); + area_normal, vd.no, vd.fno, *vd.mask); float *disp = &layer_disp[vd.i]; float val[3]; @@ -1675,10 +1847,11 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, test.dist, - ss->cache->view_normal, vd.no, vd.fno); + ss->cache->view_normal, vd.no, vd.fno, *vd.mask); float val[3]; if (vd.fno) copy_v3_v3(val, vd.fno); @@ -1718,7 +1891,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sculpt_brush_test_init(ss, &test); if (ss->cache->original) { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { add_v3_v3(private_fc, unode->co[vd.i]); private_count++; @@ -1727,7 +1901,8 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, vd.co)) { add_v3_v3(private_fc, vd.co); private_count++; @@ -1783,7 +1958,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, sculpt_brush_test_init(ss, &test); if (ss->cache->original) { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { /* for area normal */ float fno[3]; @@ -1799,7 +1975,8 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, BLI_pbvh_vertex_iter_end; } else { - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_fast(&test, vd.co)) { /* for area normal */ if (vd.no) { @@ -1928,7 +2105,8 @@ static void point_plane_project(float intr[3], float co[3], float plane_normal[3 static int plane_trim(StrokeCache *cache, Brush *brush, float val[3]) { - return !(brush->flag & BRUSH_PLANE_TRIM) || (dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared); + return (!(brush->flag & BRUSH_PLANE_TRIM) || + ((dot_v3v3(val, val) <= cache->radius_squared * cache->plane_trim_squared))); } static int plane_point_side_flip(float co[3], float plane_normal[3], float plane_center[3], int flip) @@ -2002,7 +2180,8 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { float intr[3]; float val[3]; @@ -2013,7 +2192,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2073,7 +2252,8 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { if (plane_point_side_flip(vd.co, an, fc, flip)) { float intr[3]; @@ -2086,7 +2266,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2174,7 +2354,8 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_cube(&test, vd.co, mat)) { if (plane_point_side_flip(vd.co, sn, fc, flip)) { float intr[3]; @@ -2187,7 +2368,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, ss->cache->radius * test.dist, - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2237,7 +2418,8 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { if (plane_point_side(vd.co, an, fc)) { float intr[3]; @@ -2250,7 +2432,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2300,7 +2482,8 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { if (sculpt_brush_test_sq(&test, vd.co)) { if (!plane_point_side(vd.co, an, fc)) { float intr[3]; @@ -2313,7 +2496,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod if (plane_trim(ss->cache, brush, val)) { const float fade = bstrength * tex_strength(ss, brush, vd.co, sqrt(test.dist), - an, vd.no, vd.fno); + an, vd.no, vd.fno, *vd.mask); mul_v3_v3fl(proxy[vd.i], val, fade); @@ -2371,7 +2554,9 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) for (a = 0; a < me->totvert; a++, mvert++) copy_v3_v3(mvert->co, vertCos[a]); - mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL); + BKE_mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, + me->mpoly, me->totloop, me->totpoly, + NULL, NULL, 0, NULL, NULL); } /* apply new coords on active key block */ @@ -2389,14 +2574,20 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) data.ss = ss; data.sd = sd; data.radius_squared = ss->cache->radius_squared; - data.original = ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_LAYER); + data.original = ELEM4(brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_LAYER); BLI_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); /* Only act if some verts are inside the brush area */ if (totnode) { #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) for (n = 0; n < totnode; n++) { - sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); + sculpt_undo_push_node(ob, nodes[n], + brush->sculpt_tool == SCULPT_TOOL_MASK ? + SCULPT_UNDO_MASK : SCULPT_UNDO_COORDS); BLI_pbvh_node_mark_update(nodes[n]); } @@ -2453,14 +2644,18 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) case SCULPT_TOOL_SCRAPE: do_scrape_brush(sd, ob, nodes, totnode); break; + case SCULPT_TOOL_MASK: + do_mask_brush(sd, ob, nodes, totnode); + break; } - if (brush->sculpt_tool != SCULPT_TOOL_SMOOTH && brush->autosmooth_factor > 0) { + if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_MASK) && + brush->autosmooth_factor > 0) { if (brush->flag & BRUSH_INVERSE_SMOOTH_PRESSURE) { - smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure)); + smooth(sd, ob, nodes, totnode, brush->autosmooth_factor * (1 - ss->cache->pressure), FALSE); } else { - smooth(sd, ob, nodes, totnode, brush->autosmooth_factor); + smooth(sd, ob, nodes, totnode, brush->autosmooth_factor, FALSE); } } @@ -2513,7 +2708,8 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { float val[3]; int p; @@ -2583,7 +2779,8 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) for (n = 0; n < totnode; n++) { PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) + { sculpt_flush_pbvhvert_deform(ob, &vd); if (vertCos) { @@ -2604,7 +2801,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) /* Modifiers could depend on mesh normals, so we should update them/ * Note, then if sculpting happens on locked key, normals should be re-calculated * after applying coords from keyblock on base mesh */ - mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); + BKE_mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); } else if (ss->kb) { sculpt_update_keyblock(ob); @@ -2627,8 +2824,8 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, * XXX However, a different approach appears to be needed */ #if 0 if (sd->flags & SCULPT_SYMMETRY_FEATHER) { - float frac = 1.0f/max_overlap_count(sd); - float reduce = (feather-frac)/(1-frac); + float frac = 1.0f / max_overlap_count(sd); + float reduce = (feather - frac) / (1 - frac); printf("feather: %f frac: %f reduce: %f\n", feather, frac, reduce); @@ -2756,7 +2953,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->face_normals = NULL; } else { - Mesh *me = get_mesh(ob); + Mesh *me = BKE_mesh_from_object(ob); ss->totvert = me->totvert; ss->totpoly = me->totpoly; ss->mvert = me->mvert; @@ -2764,6 +2961,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->mloop = me->mloop; ss->face_normals = NULL; ss->multires = NULL; + ss->vmask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); } /* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */ @@ -2887,7 +3085,7 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) ss->cache->clip_tolerance[i]) { ss->cache->clip_tolerance[i] = - mmd->tolerance; + mmd->tolerance; } } } @@ -2940,15 +3138,22 @@ static void sculpt_update_cache_invariants(bContext *C, Sculpt *sd, SculptSessio /* Alt-Smooth */ if (ss->cache->alt_smooth) { - Paint *p = &sd->paint; - Brush *br; + if (brush->sculpt_tool == SCULPT_TOOL_MASK) { + cache->saved_mask_brush_tool = brush->mask_tool; + brush->mask_tool = BRUSH_MASK_SMOOTH; + } + else { + Paint *p = &sd->paint; + Brush *br; - BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); + BLI_strncpy(cache->saved_active_brush_name, brush->id.name + 2, + sizeof(cache->saved_active_brush_name)); - br = (Brush *)find_id("BR", "Smooth"); - if (br) { - paint_brush_set(p, br); - brush = br; + br = (Brush *)BKE_libblock_find_name(ID_BR, "Smooth"); + if (br) { + paint_brush_set(p, br); + brush = br; + } } } @@ -3134,7 +3339,9 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, if (cache->first_time) { if (!BKE_brush_use_locked_size(scene, brush)) { - cache->initial_radius = paint_calc_object_space_radius(cache->vc, cache->true_location, BKE_brush_size_get(scene, brush)); + cache->initial_radius = paint_calc_object_space_radius(cache->vc, + cache->true_location, + BKE_brush_size_get(scene, brush)); BKE_brush_unprojected_radius_set(scene, brush, cache->initial_radius); } else { @@ -3361,6 +3568,8 @@ static int sculpt_brush_stroke_init(bContext *C, wmOperator *op) is_smooth |= mode == BRUSH_STROKE_SMOOTH; is_smooth |= brush->sculpt_tool == SCULPT_TOOL_SMOOTH; + is_smooth |= ((brush->sculpt_tool == SCULPT_TOOL_MASK) && + (brush->mask_tool == BRUSH_MASK_SMOOTH)); sculpt_update_mesh_elements(scene, sd, ob, is_smooth); @@ -3507,15 +3716,20 @@ static void sculpt_stroke_done(const bContext *C, struct PaintStroke *UNUSED(str /* Alt-Smooth */ if (ss->cache->alt_smooth) { - Paint *p = &sd->paint; - brush = (Brush *)find_id("BR", ss->cache->saved_active_brush_name); - if (brush) { - paint_brush_set(p, brush); + if (brush->sculpt_tool == SCULPT_TOOL_MASK) { + brush->mask_tool = ss->cache->saved_mask_brush_tool; + } + else { + Paint *p = &sd->paint; + brush = (Brush *)BKE_libblock_find_name(ID_BR, ss->cache->saved_active_brush_name); + if (brush) { + paint_brush_set(p, brush); + } } } /* update last stroke position */ - ob->sculpt->last_stroke_valid= 1; + ob->sculpt->last_stroke_valid = 1; copy_v3_v3(ob->sculpt->last_stroke, ss->cache->true_location); mul_m4_v3(ob->obmat, ob->sculpt->last_stroke); @@ -3621,8 +3835,9 @@ static void SCULPT_OT_brush_stroke(wmOperatorType *ot) }; /* identifiers */ - ot->name = "Sculpt Mode"; + ot->name = "Sculpt"; ot->idname = "SCULPT_OT_brush_stroke"; + ot->description = "Sculpt a stroke into the geometry"; /* api callbacks */ ot->invoke = sculpt_brush_stroke_invoke; @@ -3668,6 +3883,7 @@ static void SCULPT_OT_set_persistent_base(wmOperatorType *ot) /* identifiers */ ot->name = "Set Persistent Base"; ot->idname = "SCULPT_OT_set_persistent_base"; + ot->description = "Reset the copy of the mesh that is being sculpted on"; /* api callbacks */ ot->exec = sculpt_set_persistent_base; @@ -3685,6 +3901,71 @@ static void sculpt_init_session(Scene *scene, Object *ob) sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0); } +void ED_sculpt_mask_layers_ensure(Object *ob, MultiresModifierData *mmd) +{ + float *paint_mask; + Mesh *me = ob->data; + + paint_mask = CustomData_get_layer(&me->vdata, CD_PAINT_MASK); + + /* if multires is active, create a grid paint mask layer if there + isn't one already */ + if (mmd && !CustomData_has_layer(&me->ldata, CD_GRID_PAINT_MASK)) { + GridPaintMask *gmask; + int level = MAX2(1, mmd->sculptlvl); + int gridsize = ccg_gridsize(level); + int gridarea = gridsize * gridsize; + int i, j; + + gmask = CustomData_add_layer(&me->ldata, CD_GRID_PAINT_MASK, + CD_CALLOC, NULL, me->totloop); + + for (i = 0; i < me->totloop; i++) { + GridPaintMask *gpm = &gmask[i]; + + gpm->level = level; + gpm->data = MEM_callocN(sizeof(float) * gridarea, + "GridPaintMask.data"); + } + + /* if vertices already have mask, copy into multires data */ + if (paint_mask) { + for (i = 0; i < me->totpoly; i++) { + const MPoly *p = &me->mpoly[i]; + float avg = 0; + + /* mask center */ + for (j = 0; j < p->totloop; j++) { + const MLoop *l = &me->mloop[p->loopstart + j]; + avg += paint_mask[l->v]; + } + avg /= (float)p->totloop; + + /* fill in multires mask corner */ + for (j = 0; j < p->totloop; j++) { + GridPaintMask *gpm = &gmask[p->loopstart + j]; + const MLoop *l = &me->mloop[p->loopstart + j]; + const MLoop *prev = ME_POLY_LOOP_PREV(me->mloop, p, j); + const MLoop *next = ME_POLY_LOOP_NEXT(me->mloop, p, j); + + gpm->data[0] = avg; + gpm->data[1] = (paint_mask[l->v] + + paint_mask[next->v]) * 0.5f; + gpm->data[2] = (paint_mask[l->v] + + paint_mask[prev->v]) * 0.5f; + gpm->data[3] = paint_mask[l->v]; + } + } + } + } + + /* create vertex paint mask layer if there isn't one already */ + if (!paint_mask) { + CustomData_add_layer(&me->vdata, CD_PAINT_MASK, + CD_CALLOC, NULL, me->totvert); + } +} + static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); @@ -3731,6 +4012,9 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) sculpt_init_session(scene, ob); + /* Mask layer is required */ + ED_sculpt_mask_layers_ensure(ob, mmd); + paint_init(&ts->sculpt->paint, PAINT_CURSOR_SCULPT); paint_cursor_start(C, sculpt_poll); @@ -3746,6 +4030,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) /* identifiers */ ot->name = "Sculpt Mode"; ot->idname = "SCULPT_OT_sculptmode_toggle"; + ot->description = "Toggle sculpt mode in 3D view"; /* api callbacks */ ot->exec = sculpt_toggle_mode; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 8ccf55ec4fb..f4467dc22fc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -53,7 +53,7 @@ struct SculptStroke; /* Interface */ struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct Object *ob); -void sculpt(Sculpt *sd); +void sculpt(struct Sculpt *sd); int sculpt_mode_poll(struct bContext *C); int sculpt_poll(struct bContext *C); @@ -69,7 +69,8 @@ int sculpt_stroke_get_location(bContext *C, float out[3], float mouse[2]); typedef enum { SCULPT_UNDO_COORDS, - SCULPT_UNDO_HIDDEN + SCULPT_UNDO_HIDDEN, + SCULPT_UNDO_MASK } SculptUndoType; typedef struct SculptUndoNode { @@ -77,24 +78,25 @@ typedef struct SculptUndoNode { SculptUndoType type; - char idname[MAX_ID_NAME]; /* name instead of pointer*/ - void *node; /* only during push, not valid afterwards! */ + char idname[MAX_ID_NAME]; /* name instead of pointer*/ + void *node; /* only during push, not valid afterwards! */ float (*co)[3]; float (*orig_co)[3]; short (*no)[3]; + float *mask; int totvert; /* non-multires */ - int maxvert; /* to verify if totvert it still the same */ - int *index; /* to restore into right location */ + int maxvert; /* to verify if totvert it still the same */ + int *index; /* to restore into right location */ BLI_bitmap vert_hidden; /* multires */ - int maxgrid; /* same for grid */ - int gridsize; /* same for grid */ - int totgrid; /* to restore into right location */ - int *grids; /* to restore into right location */ + int maxgrid; /* same for grid */ + int gridsize; /* same for grid */ + int totgrid; /* to restore into right location */ + int *grids; /* to restore into right location */ BLI_bitmap *grid_hidden; /* layer brush */ diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c08ed2e85b9..d233c45a230 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -47,6 +47,7 @@ #include "DNA_scene_types.h" #include "DNA_mesh_types.h" +#include "BKE_ccg.h" #include "BKE_cdderivedmesh.h" #include "BKE_context.h" #include "BKE_depsgraph.h" @@ -76,7 +77,10 @@ static void update_cb(PBVHNode *node, void *rebuild) BLI_pbvh_node_fully_hidden_set(node, 0); } -static void sculpt_undo_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3]) +static void sculpt_undo_restore_deformed(const SculptSession *ss, + SculptUndoNode *unode, + int uindex, int oindex, + float coord[3]) { if (unode->orig_co) { swap_v3_v3(coord, unode->orig_co[uindex]); @@ -154,19 +158,21 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo } else if (unode->maxgrid && dm->getGridData) { /* multires restore */ - DMGridData **grids, *grid; + CCGElem **grids, *grid; + CCGKey key; float (*co)[3]; int gridsize; grids = dm->getGridData(dm); gridsize = dm->getGridSize(dm); + dm->getGridKey(dm, &key); co = unode->co; for (j = 0; j < unode->totgrid; j++) { grid = grids[unode->grids[j]]; for (i = 0; i < gridsize * gridsize; i++, co++) - swap_v3_v3(grid[i].co, co[0]); + swap_v3_v3(CCG_elem_offset_co(&key, grid, i), co[0]); } } @@ -211,6 +217,49 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm, return 1; } +static int sculpt_undo_restore_mask(bContext *C, DerivedMesh *dm, SculptUndoNode *unode) +{ + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + MVert *mvert; + float *vmask; + int *index, i, j; + + if (unode->maxvert) { + /* regular mesh restore */ + + index = unode->index; + mvert = ss->mvert; + vmask = ss->vmask; + + for (i = 0; i < unode->totvert; i++) { + SWAP(float, vmask[index[i]], unode->mask[i]); + mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; + } + } + else if (unode->maxgrid && dm->getGridData) { + /* multires restore */ + CCGElem **grids, *grid; + CCGKey key; + float *mask; + int gridsize; + + grids = dm->getGridData(dm); + gridsize = dm->getGridSize(dm); + dm->getGridKey(dm, &key); + + mask = unode->mask; + for (j = 0; j < unode->totgrid; j++) { + grid = grids[unode->grids[j]]; + + for (i = 0; i < gridsize * gridsize; i++, mask++) + SWAP(float, *CCG_elem_offset_mask(&key, grid, i), *mask); + } + } + + return 1; +} + static void sculpt_undo_restore(bContext *C, ListBase *lb) { Scene *scene = CTX_data_scene(C); @@ -254,6 +303,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if (sculpt_undo_restore_hidden(C, dm, unode)) rebuild = 1; break; + case SCULPT_UNDO_MASK: + if (sculpt_undo_restore_mask(C, dm, unode)) + update = 1; + break; } } @@ -276,8 +329,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) if (ss->modifiers_active) { Mesh *mesh = ob->data; - mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, - mesh->mface, mesh->totface, NULL); + BKE_mesh_calc_normals_tessface(mesh->mvert, mesh->totvert, + mesh->mface, mesh->totface, NULL); free_sculptsession_deformMats(ss); tag_update |= 1; @@ -318,6 +371,8 @@ static void sculpt_undo_free(ListBase *lb) } MEM_freeN(unode->grid_hidden); } + if (unode->mask) + MEM_freeN(unode->mask); } } @@ -385,7 +440,10 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, case SCULPT_UNDO_COORDS: unode->co = MEM_mapallocN(sizeof(float) * 3 * allvert, "SculptUndoNode.co"); unode->no = MEM_mapallocN(sizeof(short) * 3 * allvert, "SculptUndoNode.no"); - undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * 3 + sizeof(short) * 3 + sizeof(int)) * allvert); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, + (sizeof(float) * 3 + + sizeof(short) * 3 + + sizeof(int)) * allvert); break; case SCULPT_UNDO_HIDDEN: if (maxgrid) @@ -394,6 +452,10 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, unode->vert_hidden = BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); break; + case SCULPT_UNDO_MASK: + unode->mask = MEM_mapallocN(sizeof(float) * allvert, "SculptUndoNode.mask"); + undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float) * sizeof(int)) * allvert); + break; } BLI_addtail(lb, unode); @@ -422,7 +484,8 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode) SculptSession *ss = ob->sculpt; PBVHVertexIter vd; - BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) { + BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) + { copy_v3_v3(unode->co[vd.i], vd.co); if (vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); else normal_float_to_short_v3(unode->no[vd.i], vd.fno); @@ -455,6 +518,18 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) } } +static void sculpt_undo_store_mask(Object *ob, SculptUndoNode *unode) +{ + SculptSession *ss = ob->sculpt; + PBVHVertexIter vd; + + BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) + { + unode->mask[vd.i] = *vd.mask; + } + BLI_pbvh_vertex_iter_end; +} + SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType type) { @@ -495,6 +570,9 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, case SCULPT_UNDO_HIDDEN: sculpt_undo_store_hidden(ob, unode); break; + case SCULPT_UNDO_MASK: + sculpt_undo_store_mask(ob, unode); + break; } /* store active shape key */ diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 24bc01989fc..e91b29ff0c1 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -286,11 +286,11 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) for (cfra = (scene->r.sfra > 0) ? (scene->r.sfra - 1) : 0; cfra <= scene->r.efra + 1; cfra++) { scene->r.cfra = cfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); } scene->r.cfra = oldfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 024a9ffb57d..3961e566f80 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -73,22 +73,22 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - float y= 0.0f; + View2D *v2d = &ar->v2d; + float y = 0.0f; size_t items; int height; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); + height = ((items * ACHANNEL_STEP) + (ACHANNEL_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) @@ -99,16 +99,16 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) UI_view2d_sync(NULL, ac->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)ACHANNEL_FIRST; + { /* first pass: just the standard GL-drawing for backdrop + text */ + y = (float)ACHANNEL_FIRST; - for (ale= anim_data.first; ale; ale= ale->next) { - float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc); @@ -118,19 +118,19 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) y -= ACHANNEL_STEP; } } - { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + { /* second pass: widgets */ + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - y= (float)ACHANNEL_FIRST; + y = (float)ACHANNEL_FIRST; - for (ale= anim_data.first; ale; ale= ale->next) { - float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); @@ -153,7 +153,7 @@ void draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) /* Keyframes */ /* extra padding for lengths (to go under scrollers) */ -#define EXTRA_SCROLL_PAD 100.0f +#define EXTRA_SCROLL_PAD 100.0f /* draw keyframes in each channel */ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) @@ -162,9 +162,9 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - bDopeSheet *ads= &saction->ads; - AnimData *adt= NULL; + View2D *v2d = &ar->v2d; + bDopeSheet *ads = &saction->ads; + AnimData *adt = NULL; float act_start, act_end, y; size_t items; @@ -196,41 +196,41 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); + height = ((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); /* 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); /* first backdrop strips */ - y= (float)(-ACHANNEL_HEIGHT); + y = (float)(-ACHANNEL_HEIGHT); glEnable(GL_BLEND); - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { - bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale); - int sel=0; + bAnimChannelType *acf = ANIM_channel_get_typeinfo(ale); + int sel = 0; /* determine if any need to draw channel */ if (ale->datatype != ALE_NONE) { /* determine if channel is selected */ if (acf->has_setting(ac, ale, ACHANNEL_SETTING_SELECT)) - sel= ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); + sel = ANIM_channel_setting_get(ac, ale, ACHANNEL_SETTING_SELECT); if (ELEM3(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET, ANIMCONT_SHAPEKEY)) { switch (ale->type) { @@ -239,7 +239,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) // FIXME: hardcoded colors - reddish color from NLA glColor4f(0.8f, 0.2f, 0.0f, 0.4f); } - break; + break; case ANIMTYPE_SCENE: case ANIMTYPE_OBJECT: @@ -247,7 +247,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (sel) glColor4ub(col1b[0], col1b[1], col1b[2], 0x45); else glColor4ub(col1b[0], col1b[1], col1b[2], 0x22); } - break; + break; case ANIMTYPE_FILLACTD: case ANIMTYPE_DSSKEY: @@ -256,39 +256,39 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) if (sel) glColor4ub(col2b[0], col2b[1], col2b[2], 0x45); else glColor4ub(col2b[0], col2b[1], col2b[2], 0x22); } - break; + break; case ANIMTYPE_GROUP: { if (sel) glColor4ub(col1a[0], col1a[1], col1a[2], 0x22); else glColor4ub(col2a[0], col2a[1], col2a[2], 0x22); } - break; + break; default: { if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); } - break; + break; } /* draw region twice: firstly backdrop, then the current range */ - glRectf(v2d->cur.xmin, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); if (ac->datatype == ANIMCONT_ACTION) - glRectf(act_start, (float)y-ACHANNEL_HEIGHT_HALF, act_end, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(act_start, (float)y - ACHANNEL_HEIGHT_HALF, act_end, (float)y + ACHANNEL_HEIGHT_HALF); } else if (ac->datatype == ANIMCONT_GPENCIL) { /* frames less than one get less saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22); else glColor4ub(col2[0], col2[1], col2[2], 0x22); - glRectf(0.0f, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(0.0f, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y + ACHANNEL_HEIGHT_HALF); /* frames one and higher get a saturated background */ if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44); else glColor4ub(col2[0], col2[1], col2[2], 0x44); - glRectf(v2d->cur.xmin, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF); + glRectf(v2d->cur.xmin, (float)y - ACHANNEL_HEIGHT_HALF, v2d->cur.xmax + EXTRA_SCROLL_PAD, (float)y + ACHANNEL_HEIGHT_HALF); } } } @@ -303,19 +303,19 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) * This is to try to optimize this for heavier data sets * 2) Keyframes which are out of view horizontally are disregarded */ - y= (float)(-ACHANNEL_HEIGHT); + y = (float)(-ACHANNEL_HEIGHT); - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* check if anything to show for this channel */ if (ale->datatype != ALE_NONE) { - adt= ANIM_nla_mapping_get(ac, ale); + adt = ANIM_nla_mapping_get(ac, ale); /* draw 'keyframes' for each specific datatype */ switch (ale->datatype) { @@ -344,7 +344,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) } } - y-= ACHANNEL_STEP; + y -= ACHANNEL_STEP; } /* free tempolary channels used for drawing */ @@ -355,8 +355,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); - glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD); - glVertex2f(saction->timeslide, v2d->cur.ymax); + glVertex2f(saction->timeslide, v2d->cur.ymin - EXTRA_SCROLL_PAD); + glVertex2f(saction->timeslide, v2d->cur.ymax); glEnd(); } } diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index a44eca17dfd..73c36fd8086 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -86,7 +86,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) uiIDContextProperty(C, &ptr, &prop); if (prop) { - bAction *action=NULL, *oldact=NULL; + bAction *action = NULL, *oldact = NULL; PointerRNA oldptr; /* create action - the way to do this depends on whether we've got an @@ -96,13 +96,13 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) oldptr = RNA_property_pointer_get(&ptr, prop); oldact = (bAction *)oldptr.id.data; - if (oldact && GS(oldact->id.name)==ID_AC) { + if (oldact && GS(oldact->id.name) == ID_AC) { /* make a copy of the existing action */ - action= copy_action(oldact); + action = BKE_action_copy(oldact); } else { /* just make a new (empty) action */ - action= add_empty_action("Action"); + action = add_empty_action("Action"); } /* when creating new ID blocks, use is already 1 (fake user), @@ -116,7 +116,7 @@ static int act_new_exec(bContext *C, wmOperator *UNUSED(op)) } /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -130,11 +130,11 @@ void ACTION_OT_new(wmOperatorType *ot) /* api callbacks */ ot->exec = act_new_exec; - // NOTE: this is used in the NLA too... + // NOTE: this is used in the NLA too... //ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -143,9 +143,9 @@ void ACTION_OT_new(wmOperatorType *ot) /* *************************** Localise Markers ***************************** */ /* ensure that there is: - * 1) an active action editor - * 2) that the mode will have an active action available - * 3) that the set of markers being shown are the scene markers, not the list we're merging + * 1) an active action editor + * 2) that the mode will have an active action available + * 3) that the set of markers being shown are the scene markers, not the list we're merging * 4) that there are some selected markers */ static int act_markers_make_local_poll(bContext *C) @@ -170,14 +170,14 @@ static int act_markers_make_local_poll(bContext *C) return ED_markers_get_first_selected(ED_context_get_markers(C)) != NULL; } -static int act_markers_make_local_exec (bContext *C, wmOperator *UNUSED(op)) +static int act_markers_make_local_exec(bContext *C, wmOperator *UNUSED(op)) { ListBase *markers = ED_context_get_markers(C); SpaceAction *sact = CTX_wm_space_action(C); - bAction *act = (sact)? sact->action : NULL; + bAction *act = (sact) ? sact->action : NULL; - TimeMarker *marker, *markern=NULL; + TimeMarker *marker, *markern = NULL; /* sanity checks */ if (ELEM(NULL, markers, act)) @@ -198,8 +198,8 @@ static int act_markers_make_local_exec (bContext *C, wmOperator *UNUSED(op)) sact->flag |= SACTION_POSEMARKERS_SHOW; /* notifiers - both sets, as this change affects both */ - WM_event_add_notifier(C, NC_SCENE|ND_MARKERS, NULL); - WM_event_add_notifier(C, NC_ANIMATION|ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_MARKERS, NULL); return OPERATOR_FINISHED; } @@ -216,7 +216,7 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot) ot->poll = act_markers_make_local_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -225,7 +225,7 @@ void ACTION_OT_markers_make_local(wmOperatorType *ot) /* *************************** Calculate Range ************************** */ /* Get the min/max keyframes*/ -static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, const short onlySel) +static void get_keyframe_extents(bAnimContext *ac, float *min, float *max, const short onlySel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -234,43 +234,43 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons /* get data to filter, from Action or Dopesheet */ // XXX: what is sel doing here?! // Commented it, was breaking things (eg. the "auto preview range" tool). - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_SEL *//*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ - *min= 999999999.0f; - *max= -999999999.0f; + *min = 999999999.0f; + *max = -999999999.0f; /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (ale->datatype == ALE_GPFRAME) { - bGPDlayer *gpl= ale->data; + bGPDlayer *gpl = ale->data; bGPDframe *gpf; /* find gp-frame which is less than or equal to cframe */ - for (gpf= gpl->frames.first; gpf; gpf= gpf->next) { - *min= MIN2(*min, gpf->framenum); - *max= MAX2(*max, gpf->framenum); + for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { + *min = MIN2(*min, gpf->framenum); + *max = MAX2(*max, gpf->framenum); } } else { - FCurve *fcu= (FCurve *)ale->key_data; + FCurve *fcu = (FCurve *)ale->key_data; float tmin, tmax; /* get range and apply necessary scaling before processing */ calc_fcurve_range(fcu, &tmin, &tmax, onlySel, TRUE); if (adt) { - tmin= BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP); - tmax= BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP); + tmin = BKE_nla_tweakedit_remap(adt, tmin, NLATIME_CONVERT_MAP); + tmax = BKE_nla_tweakedit_remap(adt, tmax, NLATIME_CONVERT_MAP); } /* try to set cur using these values, if they're more extreme than previously set values */ - *min= MIN2(*min, tmin); - *max= MAX2(*max, tmax); + *min = MIN2(*min, tmin); + *max = MAX2(*max, tmax); } } @@ -280,12 +280,12 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max, cons else { /* set default range */ if (ac->scene) { - *min= (float)ac->scene->r.sfra; - *max= (float)ac->scene->r.efra; + *min = (float)ac->scene->r.sfra; + *max = (float)ac->scene->r.efra; } else { - *min= -5; - *max= 100; + *min = -5; + *max = 100; } } } @@ -304,17 +304,17 @@ static int actkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) if (ac.scene == NULL) return OPERATOR_CANCELLED; else - scene= ac.scene; + scene = ac.scene; /* set the range directly */ get_keyframe_extents(&ac, &min, &max, FALSE); scene->r.flag |= SCER_PRV_RANGE; - scene->r.psfra= (int)floor(min + 0.5f); - scene->r.pefra= (int)floor(max + 0.5f); + scene->r.psfra = (int)floor(min + 0.5f); + scene->r.pefra = (int)floor(max + 0.5f); /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -331,7 +331,7 @@ void ACTION_OT_previewrange_set(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** View-All Operator ****************** */ @@ -345,12 +345,12 @@ static int actkeys_viewall(bContext *C, const short onlySel) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - v2d= &ac.ar->v2d; + v2d = &ac.ar->v2d; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); - extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -393,7 +393,7 @@ void ACTION_OT_view_all(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void ACTION_OT_view_selected(wmOperatorType *ot) @@ -408,7 +408,7 @@ void ACTION_OT_view_selected(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -417,20 +417,20 @@ void ACTION_OT_view_selected(wmOperatorType *ot) /* ******************** Copy/Paste Keyframes Operator ************************* */ /* NOTE: the backend code for this is shared with the graph editor */ -static short copy_action_keys (bAnimContext *ac) +static short copy_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* clear buffer first */ free_anim_copybuf(); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* copy keyframes */ - ok= copy_animedit_keys(ac, &anim_data); + ok = copy_animedit_keys(ac, &anim_data); /* clean up */ BLI_freelistN(&anim_data); @@ -439,18 +439,18 @@ static short copy_action_keys (bAnimContext *ac) } -static short paste_action_keys (bAnimContext *ac, - const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) +static short paste_action_keys(bAnimContext *ac, + const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* paste keyframes */ - ok= paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); + ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); /* clean up */ BLI_freelistN(&anim_data); @@ -496,22 +496,22 @@ void ACTION_OT_copy(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int actkeys_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; - const eKeyPasteOffset offset_mode= RNA_enum_get(op->ptr, "offset"); - const eKeyMergeMode merge_mode= RNA_enum_get(op->ptr, "merge"); + const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); + const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* ac.reports by default will be the global reports list, which won't show warnings */ - ac.reports= op->reports; + ac.reports = op->reports; /* paste keyframes */ if (ac.datatype == ANIMCONT_GPENCIL) { @@ -530,7 +530,7 @@ static int actkeys_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -548,7 +548,7 @@ void ACTION_OT_paste(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); @@ -573,13 +573,13 @@ static void insert_action_keys(bAnimContext *ac, short mode) int filter; ReportList *reports = ac->reports; - Scene *scene= ac->scene; + Scene *scene = ac->scene; short flag = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); - if (mode == 2) filter |= ANIMFILTER_SEL; - else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + if (mode == 2) filter |= ANIMFILTER_SEL; + else if (mode == 3) filter |= ANIMFILTER_ACTGROUPED; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -587,20 +587,20 @@ static void insert_action_keys(bAnimContext *ac, short mode) flag = ANIM_get_keyframing_flags(scene, 1); /* insert keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; float cfra; /* adjust current frame for NLA-scaling */ if (adt) - cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else - cfra= (float)CFRA; + cfra = (float)CFRA; /* if there's an id */ if (ale->id) - insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); else insert_vert_fcurve(fcu, cfra, fcu->curval, 0); } @@ -622,7 +622,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* what channels to affect? */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* insert keyframes */ insert_action_keys(&ac, mode); @@ -631,7 +631,7 @@ static int actkeys_insertkey_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -649,7 +649,7 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_insertkey_types, 0, "Type", ""); @@ -657,7 +657,7 @@ void ACTION_OT_keyframe_insert(wmOperatorType *ot) /* ******************** Duplicate Keyframes Operator ************************* */ -static void duplicate_action_keys (bAnimContext *ac) +static void duplicate_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -665,13 +665,13 @@ static void duplicate_action_keys (bAnimContext *ac) /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_FCURVE) duplicate_fcurve_keys((FCurve *)ale->key_data); else @@ -700,7 +700,7 @@ static int actkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -725,12 +725,12 @@ void ACTION_OT_duplicate(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Delete Keyframes Operator ************************* */ -static void delete_action_keys (bAnimContext *ac) +static void delete_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -738,16 +738,16 @@ static void delete_action_keys (bAnimContext *ac) /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type != ANIMTYPE_GPLAYER) { - FCurve *fcu= (FCurve *)ale->key_data; - AnimData *adt= ale->adt; + FCurve *fcu = (FCurve *)ale->key_data; + AnimData *adt = ale->adt; /* delete selected keyframes only */ delete_fcurve_keys(fcu); @@ -782,7 +782,7 @@ static int actkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -800,23 +800,23 @@ void ACTION_OT_delete(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clean Keyframes Operator ************************* */ -static void clean_action_keys (bAnimContext *ac, float thresh) +static void clean_action_keys(bAnimContext *ac, float thresh) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and clean curves */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) clean_fcurve((FCurve *)ale->key_data, thresh); /* free temp data */ @@ -837,7 +837,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get cleaning threshold */ - thresh= RNA_float_get(op->ptr, "threshold"); + thresh = RNA_float_get(op->ptr, "threshold"); /* clean keyframes */ clean_action_keys(&ac, thresh); @@ -846,7 +846,7 @@ static int actkeys_clean_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -864,7 +864,7 @@ void ACTION_OT_clean(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); @@ -873,18 +873,18 @@ void ACTION_OT_clean(wmOperatorType *ot) /* ******************** Sample Keyframes Operator *********************** */ /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ -static void sample_action_keys (bAnimContext *ac) +static void sample_action_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) sample_fcurve((FCurve *)ale->key_data); /* admin and redraws */ @@ -910,7 +910,7 @@ static int actkeys_sample_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -927,7 +927,7 @@ void ACTION_OT_sample(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -936,8 +936,8 @@ void ACTION_OT_sample(wmOperatorType *ot) /* ******************** Set Extrapolation-Type Operator *********************** */ /* defines for make/clear cyclic extrapolation tools */ -#define MAKE_CYCLIC_EXPO -1 -#define CLEAR_CYCLIC_EXPO -2 +#define MAKE_CYCLIC_EXPO -1 +#define CLEAR_CYCLIC_EXPO -2 /* defines for set extrapolation-type for selected keyframes tool */ static EnumPropertyItem prop_actkeys_expo_types[] = { @@ -957,16 +957,16 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting mode per F-Curve */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; if (mode >= 0) { /* just set mode setting */ - fcu->extend= mode; + fcu->extend = mode; } else { /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation @@ -981,7 +981,7 @@ static void setexpo_action_keys(bAnimContext *ac, short mode) } else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ - FModifier *fcm, *fcn=NULL; + FModifier *fcm, *fcn = NULL; for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; @@ -1011,7 +1011,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setexpo_action_keys(&ac, mode); @@ -1020,7 +1020,7 @@ static int actkeys_expo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1038,7 +1038,7 @@ void ACTION_OT_extrapolation_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_expo_types, 0, "Type", ""); @@ -1052,16 +1052,16 @@ static void setipo_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditFunc set_cb= ANIM_editkeyframes_ipo(mode); + KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); /* cleanup */ @@ -1082,7 +1082,7 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setipo_action_keys(&ac, mode); @@ -1091,7 +1091,7 @@ static int actkeys_ipo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1109,7 +1109,7 @@ void ACTION_OT_interpolation_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); @@ -1124,18 +1124,18 @@ static void sethandles_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditFunc edit_cb= ANIM_editkeyframes_handles(mode); - KeyframeEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); + KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { @@ -1162,7 +1162,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ sethandles_action_keys(&ac, mode); @@ -1171,7 +1171,7 @@ static int actkeys_handletype_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1189,7 +1189,7 @@ void ACTION_OT_handle_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", ""); @@ -1203,16 +1203,16 @@ static void setkeytype_action_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditFunc set_cb= ANIM_editkeyframes_keytype(mode); + KeyframeEditFunc set_cb = ANIM_editkeyframes_keytype(mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, NULL); /* cleanup */ @@ -1233,7 +1233,7 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setkeytype_action_keys(&ac, mode); @@ -1242,7 +1242,7 @@ static int actkeys_keytype_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1260,7 +1260,7 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", beztriple_keyframe_type_items, 0, "Type", ""); @@ -1275,10 +1275,10 @@ void ACTION_OT_keyframe_type(wmOperatorType *ot) static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -1286,11 +1286,11 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) /* init edit data */ /* loop over action data, averaging values */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(&ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(&ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); @@ -1304,13 +1304,13 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) /* set the new current frame value, based on the average time */ if (ked.i1) { - Scene *scene= ac.scene; - CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f); - SUBFRA= 0.f; + Scene *scene = ac.scene; + CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f); + SUBFRA = 0.f; } /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -1327,7 +1327,7 @@ void ACTION_OT_frame_jump(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Snap Keyframes Operator *********************** */ @@ -1348,28 +1348,28 @@ static void snap_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_snap(mode); + edit_cb = ANIM_editkeyframes_snap(mode); - ked.scene= ac->scene; + ked.scene = ac->scene; if (mode == ACTKEYS_SNAP_NEAREST_MARKER) { - ked.list.first= (ac->markers) ? ac->markers->first : NULL; - ked.list.last= (ac->markers) ? ac->markers->last : NULL; + ked.list.first = (ac->markers) ? ac->markers->first : NULL; + ked.list.last = (ac->markers) ? ac->markers->last : NULL; } /* snap keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -1401,7 +1401,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get snapping mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* snap keyframes */ snap_action_keys(&ac, mode); @@ -1410,7 +1410,7 @@ static int actkeys_snap_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1428,7 +1428,7 @@ void ACTION_OT_snap(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_snap_types, 0, "Type", ""); @@ -1451,39 +1451,39 @@ static void mirror_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc edit_cb; /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_mirror(mode); + edit_cb = ANIM_editkeyframes_mirror(mode); - ked.scene= ac->scene; + ked.scene = ac->scene; /* for 'first selected marker' mode, need to find first selected marker first! */ // XXX should this be made into a helper func in the API? if (mode == ACTKEYS_MIRROR_MARKER) { - TimeMarker *marker= NULL; + TimeMarker *marker = NULL; /* find first selected marker */ - marker= ED_markers_get_first_selected(ac->markers); + marker = ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) - ked.f1= (float)marker->frame; + ked.f1 = (float)marker->frame; else return; } /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* mirror keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -1515,7 +1515,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) return OPERATOR_PASS_THROUGH; /* get mirroring mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* mirror keyframes */ mirror_action_keys(&ac, mode); @@ -1524,7 +1524,7 @@ static int actkeys_mirror_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1542,7 +1542,7 @@ void ACTION_OT_mirror(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_actkeys_mirror_types, 0, "Type", ""); diff --git a/source/blender/editors/space_action/action_intern.h b/source/blender/editors/space_action/action_intern.h index 7074a109228..c684ae1de51 100644 --- a/source/blender/editors/space_action/action_intern.h +++ b/source/blender/editors/space_action/action_intern.h @@ -61,14 +61,14 @@ void ACTION_OT_clickselect(struct wmOperatorType *ot); /* defines for left-right select tool */ enum { - ACTKEYS_LRSEL_TEST = 0, + ACTKEYS_LRSEL_TEST = 0, ACTKEYS_LRSEL_LEFT, ACTKEYS_LRSEL_RIGHT } eActKeys_LeftRightSelect_Mode; /* defines for column-select mode */ enum { - ACTKEYS_COLUMNSEL_KEYS = 0, + ACTKEYS_COLUMNSEL_KEYS = 0, ACTKEYS_COLUMNSEL_CFRA, ACTKEYS_COLUMNSEL_MARKERS_COLUMN, ACTKEYS_COLUMNSEL_MARKERS_BETWEEN, diff --git a/source/blender/editors/space_action/action_ops.c b/source/blender/editors/space_action/action_ops.c index f502a97967f..e4a161e3e22 100644 --- a/source/blender/editors/space_action/action_ops.c +++ b/source/blender/editors/space_action/action_ops.c @@ -45,6 +45,7 @@ #include "action_intern.h" #include "RNA_access.h" +#include "RNA_define.h" #include "WM_api.h" #include "WM_types.h" @@ -54,7 +55,7 @@ void action_operatortypes(void) { /* keyframes */ - /* selection */ + /* selection */ WM_operatortype_append(ACTION_OT_clickselect); WM_operatortype_append(ACTION_OT_select_all_toggle); WM_operatortype_append(ACTION_OT_select_border); @@ -64,7 +65,7 @@ void action_operatortypes(void) WM_operatortype_append(ACTION_OT_select_less); WM_operatortype_append(ACTION_OT_select_leftright); - /* editing */ + /* editing */ WM_operatortype_append(ACTION_OT_snap); WM_operatortype_append(ACTION_OT_mirror); WM_operatortype_append(ACTION_OT_frame_jump); @@ -93,9 +94,10 @@ void ED_operatormacros_action(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("ACTION_OT_duplicate_move", "Duplicate", + "Make a copy of all selected keyframes and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Make a copy of all selected keyframes and move them"; WM_operatortype_macro_define(ot, "ACTION_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); @@ -105,82 +107,82 @@ void ED_operatormacros_action(void) /* ************************** registration - keymaps **********************************/ -static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) +static void action_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; /* action_select.c - selection tools */ - /* click-select */ + /* click-select */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "column", TRUE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "column", FALSE); - kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "column", TRUE); - /* select left/right */ + /* select left/right */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); - kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); + kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_TEST); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT); - /* deselect all */ + /* deselect all */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", FALSE); + RNA_boolean_set(kmi->ptr, "invert", FALSE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", TRUE); + RNA_boolean_set(kmi->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); kmi = WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - /* column select */ + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN); - /* select more/less */ + /* select more/less */ WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - /* select linekd */ + /* select linekd */ WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0); /* action_edit.c */ - /* snap - current frame to selected keys */ - // TODO: maybe since this is called jump, we're better to have it on -J? - WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* snap - current frame to selected keys */ + // TODO: maybe since this is called jump, we're better to have it on -J? + WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - /* menu + single-step transform */ + /* menu + single-step transform */ WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); - /* menu + set setting */ + /* menu + set setting */ WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); - /* destructive */ + /* destructive */ WM_keymap_add_item(keymap, "ACTION_OT_clean", OKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); @@ -190,19 +192,19 @@ static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "ACTION_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); - /* copy/paste */ + /* copy/paste */ WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); - /* auto-set range */ - WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + /* auto-set range */ + WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "ACTION_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* animation module */ - /* channels list - * NOTE: these operators were originally for the channels list, but are added here too for convenience... - */ + /* channels list + * NOTE: these operators were originally for the channels list, but are added here too for convenience... + */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); /* transform system */ diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c index a28f8ee1b99..0c6b0f5eb3d 100644 --- a/source/blender/editors/space_action/action_select.c +++ b/source/blender/editors/space_action/action_select.c @@ -79,42 +79,42 @@ /* Deselects keyframes in the action editor * - This is called by the deselect all operator, as well as other ones! * - * - test: check if select or deselect all + * - test: check if select or deselect all * - sel: how to select keyframes (SELECT_*) */ -static void deselect_action_keys (bAnimContext *ac, short test, short sel) +static void deselect_action_keys(bAnimContext *ac, short test, short sel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; /* determine type-based settings */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* init BezTriple looping data */ - test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* See if we should be selecting or deselecting */ if (test) { - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) { if (is_gplayer_frame_selected(ale->data)) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } else { if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } @@ -122,10 +122,10 @@ static void deselect_action_keys (bAnimContext *ac, short test, short sel) } /* convert sel to selectmode, and use that to get editor */ - sel_cb= ANIM_editkeyframes_select(sel); + sel_cb = ANIM_editkeyframes_select(sel); /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_GPLAYER) set_gplayer_frame_selection(ale->data, sel); else @@ -153,7 +153,7 @@ static int actkeys_deselectall_exec(bContext *C, wmOperator *op) deselect_action_keys(&ac, 1, SELECT_ADD); /* set notifier that keyframe selection have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -170,7 +170,7 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -178,7 +178,7 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) /* ******************** Border Select Operator **************************** */ /* This operator currently works in one of three ways: - * -> BKEY - 1) all keyframes within region are selected (ACTKEYS_BORDERSEL_ALLKEYS) + * -> BKEY - 1) all keyframes within region are selected (ACTKEYS_BORDERSEL_ALLKEYS) * -> ALT-BKEY - depending on which axis of the region was larger... * -> 2) x-axis, so select all frames within frame range (ACTKEYS_BORDERSEL_FRAMERANGE) * -> 3) y-axis, so select all frames within channels that region included (ACTKEYS_BORDERSEL_CHANNELS) @@ -186,13 +186,13 @@ void ACTION_OT_select_all_toggle(wmOperatorType *ot) /* defines for borderselect mode */ enum { - ACTKEYS_BORDERSEL_ALLKEYS = 0, + ACTKEYS_BORDERSEL_ALLKEYS = 0, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_CHANNELS, } /*eActKeys_BorderSelect_Mode*/; -static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short selectmode) +static void borderselect_action(bAnimContext *ac, rcti rect, short mode, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -200,52 +200,52 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; - float ymin=0, ymax=(float)(-ACHANNEL_HEIGHT_HALF); + float ymin = 0, ymax = (float)(-ACHANNEL_HEIGHT_HALF); /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ - UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing/validation funcs */ - select_cb= ANIM_editkeyframes_select(selectmode); + select_cb = ANIM_editkeyframes_select(selectmode); if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); else - ok_cb= NULL; + ok_cb = NULL; /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* get new vertical minimum extent of channel */ - ymin= ymax - ACHANNEL_STEP; + ymin = ymax - ACHANNEL_STEP; /* set horizontal range (if applicable) */ if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) { /* if channel is mapped in NLA, apply correction */ if (adt) { - ked.f1= BKE_nla_tweakedit_remap(adt, rectf.xmin, NLATIME_CONVERT_UNMAP); - ked.f2= BKE_nla_tweakedit_remap(adt, rectf.xmax, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, rectf.xmin, NLATIME_CONVERT_UNMAP); + ked.f2 = BKE_nla_tweakedit_remap(adt, rectf.xmax, NLATIME_CONVERT_UNMAP); } else { - ked.f1= rectf.xmin; - ked.f2= rectf.xmax; + ked.f1 = rectf.xmin; + ked.f2 = rectf.xmax; } } /* perform vertical suitability check (if applicable) */ if ( (mode == ACTKEYS_BORDERSEL_FRAMERANGE) || - !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) + !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) { /* loop over data selecting */ if (ale->type == ANIMTYPE_GPLAYER) @@ -255,7 +255,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short } /* set minimum extent to be the maximum of the next channel */ - ymax=ymin; + ymax = ymin; } /* cleanup */ @@ -268,7 +268,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short mode=0, selectmode=0; + short mode = 0, selectmode = 0; int gesture_mode, extend; /* get editor data */ @@ -276,7 +276,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_action_keys(&ac, 1, SELECT_SUBTRACT); @@ -286,7 +286,7 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) rect.xmax = RNA_int_get(op->ptr, "xmax"); rect.ymax = RNA_int_get(op->ptr, "ymax"); - gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); + gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); if (gesture_mode == GESTURE_MODAL_SELECT) selectmode = SELECT_ADD; else @@ -300,18 +300,18 @@ static int actkeys_borderselect_exec(bContext *C, wmOperator *op) * used for tweaking timing when "blocking", while channels is not that useful... */ if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) - mode= ACTKEYS_BORDERSEL_FRAMERANGE; + mode = ACTKEYS_BORDERSEL_FRAMERANGE; else - mode= ACTKEYS_BORDERSEL_CHANNELS; + mode = ACTKEYS_BORDERSEL_CHANNELS; } else - mode= ACTKEYS_BORDERSEL_ALLKEYS; + mode = ACTKEYS_BORDERSEL_ALLKEYS; /* apply borderselect action */ borderselect_action(&ac, rect, mode, selectmode); /* set notifier that keyframe selection have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -332,7 +332,7 @@ void ACTION_OT_select_border(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -362,14 +362,14 @@ static EnumPropertyItem prop_column_select_types[] = { /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in graph_select.c * should de-duplicate - campbell */ -static void markers_selectkeys_between (bAnimContext *ac) +static void markers_selectkeys_between(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; float min, max; /* get extreme markers */ @@ -378,19 +378,19 @@ static void markers_selectkeys_between (bAnimContext *ac) max += 0.5f; /* get editing funcs + data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); - ked.f1= min; - ked.f2= max; + ked.f1 = min; + ked.f2 = max; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys in-between */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -411,16 +411,16 @@ static void markers_selectkeys_between (bAnimContext *ac) /* Selects all visible keyframes in the same frames as the specified elements */ -static void columnselect_action_keys (bAnimContext *ac, short mode) +static void columnselect_action_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - Scene *scene= ac->scene; + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* initialize keyframe editing data */ @@ -428,17 +428,17 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) switch (mode) { case ACTKEYS_COLUMNSEL_KEYS: /* list of selected keys */ if (ac->datatype == ANIMCONT_GPENCIL) { - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) gplayer_make_cfra_list(ale->data, &ked.list, 1); } else { - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); } BLI_freelistN(&anim_data); @@ -446,10 +446,10 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) case ACTKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ - ce= MEM_callocN(sizeof(CfraElem), "cfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - ce->cfra= (float)CFRA; + ce->cfra = (float)CFRA; break; case ACTKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ @@ -461,30 +461,30 @@ static void columnselect_action_keys (bAnimContext *ac, short mode) } /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(SELECT_ADD); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ - for (ce= ked.list.first; ce; ce= ce->next) { + for (ce = ked.list.first; ce; ce = ce->next) { /* set frame for validation callback to refer to */ if (adt) - ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); else - ked.f1= ce->cfra; + ked.f1 = ce->cfra; /* select elements with frame number matching cfraelem */ if (ale->type == ANIMTYPE_GPLAYER) @@ -511,7 +511,7 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* action to take depends on the mode */ - mode= RNA_enum_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); if (mode == ACTKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); @@ -519,7 +519,7 @@ static int actkeys_columnselect_exec(bContext *C, wmOperator *op) columnselect_action_keys(&ac, mode); /* set notifier that keyframe selection have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -536,7 +536,7 @@ void ACTION_OT_select_column(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); @@ -544,11 +544,11 @@ void ACTION_OT_select_column(wmOperatorType *ot) /* ******************** Select Linked Operator *********************** */ -static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) +static int actkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -560,11 +560,11 @@ static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { @@ -577,7 +577,7 @@ static int actkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -594,38 +594,38 @@ void ACTION_OT_select_linked(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select More/Less Operators *********************** */ /* Common code to perform selection */ -static void select_moreless_action_keys (bAnimContext *ac, short mode) +static void select_moreless_action_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc build_cb; /* init selmap building data */ - build_cb= ANIM_editkeyframes_buildselmap(mode); + build_cb = ANIM_editkeyframes_buildselmap(mode); /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; /* build up map of whether F-Curve's keyframes should be selected or not */ - ked.data= MEM_callocN(fcu->totvert, "selmap actEdit more"); + ked.data = MEM_callocN(fcu->totvert, "selmap actEdit more"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); /* based on this map, adjust the selection status of the keyframes */ @@ -633,7 +633,7 @@ static void select_moreless_action_keys (bAnimContext *ac, short mode) /* free the selmap used here */ MEM_freeN(ked.data); - ked.data= NULL; + ked.data = NULL; } /* Cleanup */ @@ -642,7 +642,7 @@ static void select_moreless_action_keys (bAnimContext *ac, short mode) /* ----------------- */ -static int actkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) +static int actkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -654,7 +654,7 @@ static int actkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_action_keys(&ac, SELMAP_MORE); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -671,12 +671,12 @@ void ACTION_OT_select_more(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ----------------- */ -static int actkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) +static int actkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -688,7 +688,7 @@ static int actkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_action_keys(&ac, SELMAP_LESS); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -705,7 +705,7 @@ void ACTION_OT_select_less(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select Left/Right Operator ************************* */ @@ -721,19 +721,19 @@ static EnumPropertyItem prop_actkeys_leftright_select_types[] = { /* --------------------------------- */ -static void actkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode) +static void actkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; - Scene *scene= ac->scene; + KeyframeEditData ked = {{NULL}}; + Scene *scene = ac->scene; /* if select mode is replace, deselect all keyframes (and channels) first */ - if (select_mode==SELECT_REPLACE) { - select_mode= SELECT_ADD; + if (select_mode == SELECT_REPLACE) { + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -742,8 +742,8 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s } /* set callbacks and editing data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(select_mode); if (leftright == ACTKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; @@ -756,14 +756,14 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s /* filter data */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY*/ | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -777,16 +777,16 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s } /* Sync marker support */ - if (select_mode==SELECT_ADD) { - SpaceAction *saction= (SpaceAction *)ac->sl; + if (select_mode == SELECT_ADD) { + SpaceAction *saction = (SpaceAction *)ac->sl; if ((saction) && (saction->flag & SACTION_MARKERS_MOVE)) { ListBase *markers = ED_animcontext_get_markers(ac); TimeMarker *marker; - for (marker= markers->first; marker; marker= marker->next) { - if ( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || - ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) ) + for (marker = markers->first; marker; marker = marker->next) { + if ( ((leftright == ACTKEYS_LRSEL_LEFT) && (marker->frame < CFRA)) || + ((leftright == ACTKEYS_LRSEL_RIGHT) && (marker->frame >= CFRA)) ) { marker->flag |= SELECT; } @@ -803,7 +803,7 @@ static void actkeys_select_leftright (bAnimContext *ac, short leftright, short s /* ----------------- */ -static int actkeys_select_leftright_exec (bContext *C, wmOperator *op) +static int actkeys_select_leftright_exec(bContext *C, wmOperator *op) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -815,9 +815,9 @@ static int actkeys_select_leftright_exec (bContext *C, wmOperator *op) /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* if "test" mode is set, we don't have any info to set this with */ if (leftright == ACTKEYS_LRSEL_TEST) @@ -827,12 +827,12 @@ static int actkeys_select_leftright_exec (bContext *C, wmOperator *op) actkeys_select_leftright(&ac, leftright, selectmode); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int actkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -843,9 +843,9 @@ static int actkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent /* handle mode-based testing */ if (leftright == ACTKEYS_LRSEL_TEST) { - Scene *scene= ac.scene; - ARegion *ar= ac.ar; - View2D *v2d= &ar->v2d; + Scene *scene = ac.scene; + ARegion *ar = ac.ar; + View2D *v2d = &ar->v2d; float x; /* determine which side of the current frame mouse is on */ @@ -873,7 +873,7 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_actkeys_leftright_select_types, ACTKEYS_LRSEL_TEST, "Mode", ""); @@ -891,20 +891,20 @@ void ACTION_OT_select_leftright(wmOperatorType *ot) */ /* sensitivity factor for frame-selections */ -#define FRAME_CLICK_THRESH 0.1f +#define FRAME_CLICK_THRESH 0.1f /* ------------------- */ /* option 1) select keyframe directly under mouse */ -static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) +static void actkeys_mselect_single(bAnimContext *ac, bAnimListElem *ale, short select_mode, float selx) { - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc select_cb, ok_cb; /* get functions for selecting keyframes */ - select_cb= ANIM_editkeyframes_select(select_mode); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); - ked.f1= selx; + select_cb = ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); + ked.f1 = selx; /* select the nominated keyframe on the given frame */ if (ale->type == ANIMTYPE_GPLAYER) @@ -919,34 +919,34 @@ static void actkeys_mselect_single (bAnimContext *ac, bAnimListElem *ale, short /* Option 3) Selects all visible keyframes in the same frame as the mouse click */ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float selx) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc select_cb, ok_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(select_mode); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ if (ac->datatype == ANIMCONT_GPENCIL) - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE /*| ANIMFILTER_CURVESONLY */ | ANIMFILTER_NODUPLIS); else - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* set frame for validation callback to refer to */ if (adt) - ked.f1= BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else - ked.f1= selx; + ked.f1 = selx; /* select elements with frame number matching cfra */ if (ale->type == ANIMTYPE_GPLAYER) @@ -962,14 +962,14 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se /* ------------------- */ -static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select_mode, short column) +static void mouse_action_keys(bAnimContext *ac, const int mval[2], short select_mode, short column) { ListBase anim_data = {NULL, NULL}; DLRBT_Tree anim_keys; bAnimListElem *ale; int filter; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; bDopeSheet *ads = NULL; int channel_index; short found = 0; @@ -979,22 +979,22 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select /* get dopesheet info */ if (ac->datatype == ANIMCONT_DOPESHEET) - ads= ac->data; + ads = ac->data; /* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */ UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); UI_view2d_listview_view_to_cell(v2d, 0, ACHANNEL_STEP, 0, (float)ACHANNEL_HEIGHT_HALF, x, y, NULL, &channel_index); /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click (size of keyframe icon) */ - UI_view2d_region_to_view(v2d, mval[0]-7, mval[1], &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, mval[0] - 7, mval[1], &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, mval[0] + 7, mval[1], &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* try to get channel */ - ale= BLI_findlink(&anim_data, channel_index); + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ printf("Error: animation channel (index = %d) not found in mouse_action_keys()\n", channel_index); @@ -1003,8 +1003,8 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select } else { /* found match - must return here... */ - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - ActKeyColumn *ak, *akn=NULL; + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + ActKeyColumn *ak, *akn = NULL; /* make list of keyframes */ BLI_dlrbTree_init(&anim_keys); @@ -1013,28 +1013,28 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select switch (ale->datatype) { case ALE_SCE: { - Scene *scene= (Scene *)ale->key_data; + Scene *scene = (Scene *)ale->key_data; scene_to_keylist(ads, scene, &anim_keys, NULL); } - break; + break; case ALE_OB: { - Object *ob= (Object *)ale->key_data; + Object *ob = (Object *)ale->key_data; ob_to_keylist(ads, ob, &anim_keys, NULL); } - break; + break; case ALE_ACT: { - bAction *act= (bAction *)ale->key_data; + bAction *act = (bAction *)ale->key_data; action_to_keylist(adt, act, &anim_keys, NULL); } - break; + break; case ALE_FCURVE: { - FCurve *fcu= (FCurve *)ale->key_data; + FCurve *fcu = (FCurve *)ale->key_data; fcurve_to_keylist(adt, fcu, &anim_keys, NULL); } - break; + break; } } else if (ale->type == ANIMTYPE_SUMMARY) { @@ -1043,7 +1043,7 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select } else if (ale->type == ANIMTYPE_GROUP) { // TODO: why don't we just give groups key_data too? - bActionGroup *agrp= (bActionGroup *)ale->data; + bActionGroup *agrp = (bActionGroup *)ale->data; agroup_to_keylist(adt, agrp, &anim_keys, NULL); } else if (ale->type == ANIMTYPE_GPLAYER) { @@ -1053,20 +1053,20 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select } /* start from keyframe at root of BST, traversing until we find one within the range that was clicked on */ - for (ak= anim_keys.root; ak; ak= akn) { + for (ak = anim_keys.root; ak; ak = akn) { if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) { /* set the frame to use, and apply inverse-correction for NLA-mapping * so that the frame will get selected by the selection functions without * requiring to map each frame once again... */ - selx= BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP); - found= 1; + selx = BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP); + found = 1; break; } else if (ak->cfra < rectf.xmin) - akn= ak->right; + akn = ak->right; else - akn= ak->left; + akn = ak->left; } /* remove active channel from list of channels for separate treatment (since it's needed later on) */ @@ -1095,13 +1095,13 @@ static void mouse_action_keys (bAnimContext *ac, const int mval[2], short select /* Highlight Action-Group or F-Curve? */ if (ale && ale->data) { if (ale->type == ANIMTYPE_GROUP) { - bActionGroup *agrp= ale->data; + bActionGroup *agrp = ale->data; agrp->flag |= AGRP_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, agrp, ANIMTYPE_GROUP); } else if (ale->type == ANIMTYPE_FCURVE) { - FCurve *fcu= ale->data; + FCurve *fcu = ale->data; fcu->flag |= FCURVE_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, fcu, ANIMTYPE_FCURVE); @@ -1157,21 +1157,21 @@ static int actkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* column selection */ - column= RNA_boolean_get(op->ptr, "column"); + column = RNA_boolean_get(op->ptr, "column"); /* select keyframe(s) based upon mouse position*/ mouse_action_keys(&ac, event->mval, selectmode, column); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); /* for tweak grab to work */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } void ACTION_OT_clickselect(wmOperatorType *ot) @@ -1186,7 +1186,7 @@ void ACTION_OT_clickselect(wmOperatorType *ot) ot->poll = ED_operator_action_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index c1875eb3a9a..ae4020aaaba 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -60,67 +60,67 @@ #include "ED_anim_api.h" #include "ED_markers.h" -#include "action_intern.h" // own include +#include "action_intern.h" /* own include */ /* ******************** default callbacks for action space ***************** */ static SpaceLink *action_new(const bContext *C) { - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); SpaceAction *saction; ARegion *ar; - saction= MEM_callocN(sizeof(SpaceAction), "initaction"); - saction->spacetype= SPACE_ACTION; + saction = MEM_callocN(sizeof(SpaceAction), "initaction"); + saction->spacetype = SPACE_ACTION; saction->autosnap = SACTSNAP_FRAME; - saction->mode= SACTCONT_DOPESHEET; + saction->mode = SACTCONT_DOPESHEET; saction->ads.filterflag |= ADS_FILTER_SUMMARY; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for action"); + ar = MEM_callocN(sizeof(ARegion), "header for action"); BLI_addtail(&saction->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel area for action"); + ar = MEM_callocN(sizeof(ARegion), "channel area for action"); BLI_addtail(&saction->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - /* only need to set scroll settings, as this will use 'listview' v2d configuration */ + /* only need to set scroll settings, as this will use 'listview' v2d configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for action"); + ar = MEM_callocN(sizeof(ARegion), "main area for action"); BLI_addtail(&saction->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = -10.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(sa->winx); ar->v2d.tot.ymax = 0.0f; ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.minzoom = 0.01f; + ar->v2d.maxzoom = 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.keepzoom= V2D_LOCKZOOM_Y; - ar->v2d.keepofs= V2D_KEEPOFS_Y; - ar->v2d.align= V2D_ALIGN_NO_POS_Y; + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; + ar->v2d.keepofs = V2D_KEEPOFS_Y; + ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; return (SpaceLink *)saction; @@ -143,7 +143,7 @@ static void action_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *action_duplicate(SpaceLink *sl) { - SpaceAction *sactionn= MEM_dupallocN(sl); + SpaceAction *sactionn = MEM_dupallocN(sl); /* clear or remove stuff from old */ @@ -167,12 +167,12 @@ static void action_main_area_init(wmWindowManager *wm, ARegion *ar) static void action_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceAction *saction= CTX_wm_space_action(C); + SpaceAction *saction = CTX_wm_space_action(C); bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - short unit=0, flag=0; + short unit = 0, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -181,8 +181,8 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit= (saction->flag & SACTION_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + unit = (saction->flag & SACTION_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -192,14 +192,14 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) } /* current frame */ - if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((saction->flag & SACTION_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; + if (saction->flag & SACTION_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((saction->flag & SACTION_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ UI_view2d_view_orthoSpecial(ar, v2d, 1); - flag = (ac.markers && (ac.markers != &ac.scene->markers))? DRAW_MARKERS_LOCAL : 0; + flag = (ac.markers && (ac.markers != &ac.scene->markers)) ? DRAW_MARKERS_LOCAL : 0; draw_markers_time(C, flag); /* preview range */ @@ -210,7 +210,7 @@ static void action_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -231,7 +231,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear and setup matrix */ @@ -249,7 +249,7 @@ static void action_channel_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -299,7 +299,7 @@ static void action_channel_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -346,7 +346,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn) break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -354,7 +354,7 @@ static void action_main_area_listener(ARegion *ar, wmNotifier *wmn) /* editor level listener */ static void action_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceAction *saction= (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -379,7 +379,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_SCENE: switch (wmn->data) { - case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_OB_SELECT: saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -392,7 +392,7 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_OBJECT: switch (wmn->data) { - case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_BONE_ACTIVE: saction->flag |= SACTION_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -446,7 +446,7 @@ static void action_header_area_listener(ARegion *ar, wmNotifier *wmn) static void action_refresh(const bContext *C, ScrArea *sa) { - SpaceAction *saction= (SpaceAction *)sa->spacedata.first; + SpaceAction *saction = (SpaceAction *)sa->spacedata.first; /* update the state of the animchannels in response to changes from the data they represent * NOTE: the temp flag is used to indicate when this needs to be done, and will be cleared once handled @@ -464,52 +464,52 @@ static void action_refresh(const bContext *C, ScrArea *sa) /* only called once, from space/spacetypes.c */ void ED_spacetype_action(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype action"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype action"); ARegionType *art; - st->spaceid= SPACE_ACTION; + st->spaceid = SPACE_ACTION; strncpy(st->name, "Action", BKE_ST_MAXNAME); - st->new= action_new; - st->free= action_free; - st->init= action_init; - st->duplicate= action_duplicate; - st->operatortypes= action_operatortypes; - st->keymap= action_keymap; - st->listener= action_listener; - st->refresh= action_refresh; + st->new = action_new; + st->free = action_free; + st->init = action_init; + st->duplicate = action_duplicate; + st->operatortypes = action_operatortypes; + st->keymap = action_keymap; + st->listener = action_listener; + st->refresh = action_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_WINDOW; - art->init= action_main_area_init; - art->draw= action_main_area_draw; - art->listener= action_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->init = action_main_area_init; + art->draw = action_main_area_draw; + art->listener = action_main_area_listener; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= action_header_area_init; - art->draw= action_header_area_draw; - art->listener= action_header_area_listener; + art->init = action_header_area_init; + art->draw = action_header_area_draw; + art->listener = action_header_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: channels */ - art= MEM_callocN(sizeof(ARegionType), "spacetype action region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype action region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= action_channel_area_init; - art->draw= action_channel_area_draw; - art->listener= action_channel_area_listener; + art->init = action_channel_area_init; + art->draw = action_channel_area_draw; + art->listener = action_channel_area_listener; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 20d5257a62f..d1c2c1e092f 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -63,15 +63,15 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" // own include static int set_pointer_type(ButsContextPath *path, bContextDataResult *result, StructRNA *type) { PointerRNA *ptr; int a; - for (a=0; alen; a++) { - ptr= &path->ptr[a]; + for (a = 0; a < path->len; a++) { + ptr = &path->ptr[a]; if (RNA_struct_is_a(ptr->type, type)) { CTX_data_pointer_set(result, ptr->id.data, ptr->type, ptr->data); @@ -87,8 +87,8 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) PointerRNA *ptr; int a; - for (a=0; alen; a++) { - ptr= &path->ptr[a]; + for (a = 0; a < path->len; a++) { + ptr = &path->ptr[a]; if (RNA_struct_is_a(ptr->type, type)) return ptr; @@ -101,7 +101,7 @@ static PointerRNA *get_pointer_type(ButsContextPath *path, StructRNA *type) static int buttons_context_path_scene(ButsContextPath *path) { - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* this one just verifies */ return RNA_struct_is_a(ptr->type, &RNA_Scene); @@ -113,7 +113,7 @@ static int buttons_context_path_world(ButsContextPath *path) { Scene *scene; World *world; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) world, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_World)) { @@ -121,8 +121,8 @@ static int buttons_context_path_world(ButsContextPath *path) } /* if we have a scene, use the scene's world */ else if (buttons_context_path_scene(path)) { - scene= path->ptr[path->len-1].data; - world= scene->world; + scene = path->ptr[path->len - 1].data; + world = scene->world; if (world) { RNA_id_pointer_create(&scene->world->id, &path->ptr[path->len]); @@ -143,7 +143,7 @@ static int buttons_context_path_object(ButsContextPath *path) { Scene *scene; Object *ob; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) object, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Object)) { @@ -151,8 +151,8 @@ static int buttons_context_path_object(ButsContextPath *path) } /* if we have a scene, use the scene's active object */ else if (buttons_context_path_scene(path)) { - scene= path->ptr[path->len-1].data; - ob= (scene->basact)? scene->basact->object: NULL; + scene = path->ptr[path->len - 1].data; + ob = (scene->basact) ? scene->basact->object : NULL; if (ob) { RNA_id_pointer_create(&ob->id, &path->ptr[path->len]); @@ -169,7 +169,7 @@ static int buttons_context_path_object(ButsContextPath *path) static int buttons_context_path_data(ButsContextPath *path, int type) { Object *ob; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a data, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) return 1; @@ -182,7 +182,7 @@ static int buttons_context_path_data(ButsContextPath *path, int type) else if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) return 1; /* try to get an object in the path, no pinning supported here */ else if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && (type == -1 || type == ob->type)) { RNA_id_pointer_create(ob->data, &path->ptr[path->len]); @@ -201,7 +201,7 @@ static int buttons_context_path_modifier(ButsContextPath *path) Object *ob; if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE)) return 1; @@ -213,7 +213,7 @@ static int buttons_context_path_modifier(ButsContextPath *path) static int buttons_context_path_material(ButsContextPath *path, int for_texture) { Object *ob; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; Material *ma; /* if we already have a (pinned) material, we're done */ @@ -222,17 +222,17 @@ static int buttons_context_path_material(ButsContextPath *path, int for_texture) } /* if we have an object, use the object material slot */ else if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type)) { - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; if (for_texture && give_current_material_texture_node(ma)) return 1; - ma= give_node_material(ma); + ma = give_node_material(ma); if (ma) { RNA_id_pointer_create(&ma->id, &path->ptr[path->len]); path->len++; @@ -252,11 +252,11 @@ static int buttons_context_path_bone(ButsContextPath *path) /* if we have an armature, get the active bone */ if (buttons_context_path_data(path, OB_ARMATURE)) { - arm= path->ptr[path->len-1].data; + arm = path->ptr[path->len - 1].data; if (arm->edbo) { if (arm->act_edbone) { - edbo= arm->act_edbone; + edbo = arm->act_edbone; RNA_pointer_create(&arm->id, &RNA_EditBone, edbo, &path->ptr[path->len]); path->len++; return 1; @@ -277,7 +277,7 @@ static int buttons_context_path_bone(ButsContextPath *path) static int buttons_context_path_pose_bone(ButsContextPath *path) { - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) PoseBone, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_PoseBone)) { @@ -286,15 +286,15 @@ static int buttons_context_path_pose_bone(ButsContextPath *path) /* if we have an armature, get the active bone */ if (buttons_context_path_object(path)) { - Object *ob= path->ptr[path->len-1].data; - bArmature *arm= ob->data; /* path->ptr[path->len-1].data - works too */ + Object *ob = path->ptr[path->len - 1].data; + bArmature *arm = ob->data; /* path->ptr[path->len-1].data - works too */ if (ob->type != OB_ARMATURE || arm->edbo) { return 0; } else { if (arm->act_bone) { - bPoseChannel *pchan= get_pose_channel(ob->pose, arm->act_bone->name); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, arm->act_bone->name); if (pchan) { RNA_pointer_create(&ob->id, &RNA_PoseBone, pchan, &path->ptr[path->len]); path->len++; @@ -313,7 +313,7 @@ static int buttons_context_path_particle(ButsContextPath *path) { Object *ob; ParticleSystem *psys; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have (pinned) particle settings, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_ParticleSettings)) { @@ -321,10 +321,10 @@ static int buttons_context_path_particle(ButsContextPath *path) } /* if we have an object, get the active particle system */ if (buttons_context_path_object(path)) { - ob= path->ptr[path->len-1].data; + ob = path->ptr[path->len - 1].data; if (ob && ob->type == OB_MESH) { - psys= psys_get_current(ob); + psys = psys_get_current(ob); RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &path->ptr[path->len]); path->len++; @@ -339,8 +339,8 @@ static int buttons_context_path_particle(ButsContextPath *path) static int buttons_context_path_brush(ButsContextPath *path) { Scene *scene; - Brush *br= NULL; - PointerRNA *ptr= &path->ptr[path->len-1]; + Brush *br = NULL; + PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a (pinned) brush, we're done */ if (RNA_struct_is_a(ptr->type, &RNA_Brush)) { @@ -348,10 +348,10 @@ static int buttons_context_path_brush(ButsContextPath *path) } /* if we have a scene, use the toolsettings brushes */ else if (buttons_context_path_scene(path)) { - scene= path->ptr[path->len-1].data; + scene = path->ptr[path->len - 1].data; if (scene) - br= paint_brush(paint_get_active(scene)); + br = paint_brush(paint_get_active(scene)); if (br) { RNA_id_pointer_create((ID *)br, &path->ptr[path->len]); @@ -369,7 +369,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur { if (ct) { /* new shading system */ - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; ID *id; /* if we already have a (pinned) texture, we're done */ @@ -379,7 +379,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur if (!ct->user) return 0; - id= ct->user->id; + id = ct->user->id; if (id) { if (GS(id->name) == ID_BR) @@ -411,7 +411,7 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur World *wo; ParticleSystem *psys; Tex *tex; - PointerRNA *ptr= &path->ptr[path->len-1]; + PointerRNA *ptr = &path->ptr[path->len - 1]; int orig_len = path->len; /* if we already have a (pinned) texture, we're done */ @@ -420,10 +420,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try brush */ if ((path->tex_ctx == SB_TEXC_BRUSH) && buttons_context_path_brush(path)) { - br= path->ptr[path->len-1].data; + br = path->ptr[path->len - 1].data; if (br) { - tex= give_current_brush_texture(br); + tex = give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -432,10 +432,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try world */ if ((path->tex_ctx == SB_TEXC_WORLD) && buttons_context_path_world(path)) { - wo= path->ptr[path->len-1].data; + wo = path->ptr[path->len - 1].data; - if (wo && GS(wo->id.name)==ID_WO) { - tex= give_current_world_texture(wo); + if (wo && GS(wo->id.name) == ID_WO) { + tex = give_current_world_texture(wo); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -444,19 +444,19 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try particles */ if ((path->tex_ctx == SB_TEXC_PARTICLES) && buttons_context_path_particle(path)) { - if (path->ptr[path->len-1].type == &RNA_ParticleSettings) { - ParticleSettings *part = path->ptr[path->len-1].data; + if (path->ptr[path->len - 1].type == &RNA_ParticleSettings) { + ParticleSettings *part = path->ptr[path->len - 1].data; - tex= give_current_particle_texture(part); + tex = give_current_particle_texture(part); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; return 1; } else { - psys= path->ptr[path->len-1].data; + psys = path->ptr[path->len - 1].data; - if (psys && psys->part && GS(psys->part->id.name)==ID_PA) { - tex= give_current_particle_texture(psys->part); + if (psys && psys->part && GS(psys->part->id.name) == ID_PA) { + tex = give_current_particle_texture(psys->part); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -466,10 +466,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try material */ if (buttons_context_path_material(path, 1)) { - ma= path->ptr[path->len-1].data; + ma = path->ptr[path->len - 1].data; if (ma) { - tex= give_current_material_texture(ma); + tex = give_current_material_texture(ma); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -478,10 +478,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur } /* try lamp */ if (buttons_context_path_data(path, OB_LAMP)) { - la= path->ptr[path->len-1].data; + la = path->ptr[path->len - 1].data; if (la) { - tex= give_current_lamp_texture(la); + tex = give_current_lamp_texture(la); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -491,10 +491,10 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur /* try brushes again in case of no material, lamp, etc */ path->len = orig_len; if (buttons_context_path_brush(path)) { - br= path->ptr[path->len-1].data; + br = path->ptr[path->len - 1].data; if (br) { - tex= give_current_brush_texture(br); + tex = give_current_brush_texture(br); RNA_id_pointer_create(&tex->id, &path->ptr[path->len]); path->len++; @@ -510,17 +510,17 @@ static int buttons_context_path_texture(ButsContextPath *path, ButsContextTextur static int buttons_context_path(const bContext *C, ButsContextPath *path, int mainb, int flag) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); ID *id; int found; memset(path, 0, sizeof(*path)); - path->flag= flag; + path->flag = flag; path->tex_ctx = sbuts->texture_context; /* if some ID datablock is pinned, set the root pointer */ if (sbuts->pinid) { - id= sbuts->pinid; + id = sbuts->pinid; RNA_id_pointer_create(id, &path->ptr[0]); path->len++; @@ -528,7 +528,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma /* no pinned root, use scene as root */ if (path->len == 0) { - id= (ID*)CTX_data_scene(C); + id = (ID *)CTX_data_scene(C); RNA_id_pointer_create(id, &path->ptr[0]); path->len++; } @@ -538,41 +538,41 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma switch (mainb) { case BCONTEXT_SCENE: case BCONTEXT_RENDER: - found= buttons_context_path_scene(path); + found = buttons_context_path_scene(path); break; case BCONTEXT_WORLD: - found= buttons_context_path_world(path); + found = buttons_context_path_world(path); break; case BCONTEXT_OBJECT: case BCONTEXT_PHYSICS: case BCONTEXT_CONSTRAINT: - found= buttons_context_path_object(path); + found = buttons_context_path_object(path); break; case BCONTEXT_MODIFIER: - found= buttons_context_path_modifier(path); + found = buttons_context_path_modifier(path); break; case BCONTEXT_DATA: - found= buttons_context_path_data(path, -1); + found = buttons_context_path_data(path, -1); break; case BCONTEXT_PARTICLE: - found= buttons_context_path_particle(path); + found = buttons_context_path_particle(path); break; case BCONTEXT_MATERIAL: - found= buttons_context_path_material(path, 0); + found = buttons_context_path_material(path, 0); break; case BCONTEXT_TEXTURE: - found= buttons_context_path_texture(path, sbuts->texuser); + found = buttons_context_path_texture(path, sbuts->texuser); break; case BCONTEXT_BONE: - found= buttons_context_path_bone(path); + found = buttons_context_path_bone(path); if (!found) - found= buttons_context_path_data(path, OB_ARMATURE); + found = buttons_context_path_data(path, OB_ARMATURE); break; case BCONTEXT_BONE_CONSTRAINT: - found= buttons_context_path_pose_bone(path); + found = buttons_context_path_pose_bone(path); break; default: - found= 0; + found = 0; break; } @@ -581,7 +581,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma static int buttons_shading_context(const bContext *C, int mainb) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (ELEM3(mainb, BCONTEXT_MATERIAL, BCONTEXT_WORLD, BCONTEXT_TEXTURE)) return 1; @@ -593,7 +593,7 @@ static int buttons_shading_context(const bContext *C, int mainb) static int buttons_shading_new_context(const bContext *C, int flag) { - Object *ob= CTX_data_active_object(C); + Object *ob = CTX_data_active_object(C); if (flag & (1 << BCONTEXT_MATERIAL)) return BCONTEXT_MATERIAL; @@ -609,29 +609,29 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) { ButsContextPath *path; PointerRNA *ptr; - int a, pflag= 0, flag= 0; + int a, pflag = 0, flag = 0; buttons_texture_context_compute(C, sbuts); if (!sbuts->path) - sbuts->path= MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); + sbuts->path = MEM_callocN(sizeof(ButsContextPath), "ButsContextPath"); - path= sbuts->path; + path = sbuts->path; /* for each context, see if we can compute a valid path to it, if * this is the case, we know we have to display the button */ - for (a=0; aptr[path->len-1]; + ptr = &path->ptr[path->len - 1]; if (ptr->type) - sbuts->dataicon= RNA_struct_ui_icon(ptr->type); + sbuts->dataicon = RNA_struct_ui_icon(ptr->type); else - sbuts->dataicon= ICON_EMPTY_DATA; + sbuts->dataicon = ICON_EMPTY_DATA; } } } @@ -639,21 +639,21 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) /* always try to use the tab that was explicitly * set to the user, so that once that context comes * back, the tab is activated again */ - sbuts->mainb= sbuts->mainbuser; + sbuts->mainb = sbuts->mainbuser; /* in case something becomes invalid, change */ if ((flag & (1 << sbuts->mainb)) == 0) { if (sbuts->flag & SB_SHADING_CONTEXT) { /* try to keep showing shading related buttons */ - sbuts->mainb= buttons_shading_new_context(C, flag); + sbuts->mainb = buttons_shading_new_context(C, flag); } else if (flag & BCONTEXT_OBJECT) { - sbuts->mainb= BCONTEXT_OBJECT; + sbuts->mainb = BCONTEXT_OBJECT; } else { - for (a=0; amainb= a; + sbuts->mainb = a; break; } } @@ -664,9 +664,9 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) if (!(flag & (1 << sbuts->mainb))) { if (flag & (1 << BCONTEXT_OBJECT)) - sbuts->mainb= BCONTEXT_OBJECT; + sbuts->mainb = BCONTEXT_OBJECT; else - sbuts->mainb= BCONTEXT_SCENE; + sbuts->mainb = BCONTEXT_SCENE; } if (buttons_shading_context(C, sbuts->mainb)) @@ -674,7 +674,7 @@ void buttons_context_compute(const bContext *C, SpaceButs *sbuts) else sbuts->flag &= ~SB_SHADING_CONTEXT; - sbuts->pathflag= flag; + sbuts->pathflag = flag; } /************************* Context Callback ************************/ @@ -684,12 +684,13 @@ const char *buttons_context_dir[] = { "meta_ball", "lamp", "speaker", "camera", "material", "material_slot", "texture", "texture_slot", "texture_user", "bone", "edit_bone", "pose_bone", "particle_system", "particle_system_editable", - "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL}; + "cloth", "soft_body", "fluid", "smoke", "collision", "brush", "dynamic_paint", NULL +}; int buttons_context(const bContext *C, const char *member, bContextDataResult *result) { - SpaceButs *sbuts= CTX_wm_space_buts(C); - ButsContextPath *path= sbuts?sbuts->path:NULL; + SpaceButs *sbuts = CTX_wm_space_buts(C); + ButsContextPath *path = sbuts ? sbuts->path : NULL; if (!path) return 0; @@ -744,7 +745,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "texture")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; if (ct) { /* new shading system */ @@ -758,15 +759,15 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "material_slot")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr) { - Object *ob= ptr->data; + Object *ob = ptr->data; if (ob && OB_TYPE_SUPPORT_MATERIAL(ob->type) && ob->totcol) { /* a valid actcol isn't ensured [#27526] */ - int matnr= ob->actcol-1; - if (matnr < 0) matnr= 0; + int matnr = ob->actcol - 1; + if (matnr < 0) matnr = 0; CTX_data_pointer_set(result, &ob->id, &RNA_MaterialSlot, &ob->mat[matnr]); } } @@ -774,20 +775,20 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "texture_user")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; if (!ct) - return -1; /* old shading system (found but not available) */ + return -1; /* old shading system (found but not available) */ if (ct->user && ct->user->ptr.data) { - ButsTextureUser *user= ct->user; + ButsTextureUser *user = ct->user; CTX_data_pointer_set(result, user->ptr.id.data, user->ptr.type, user->ptr.data); } return 1; } else if (CTX_data_equals(member, "texture_node")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; if (ct) { /* new shading system */ @@ -800,11 +801,11 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r /* old shading system */ PointerRNA *ptr; - if ((ptr=get_pointer_type(path, &RNA_Material))) { - Material *ma= ptr->data; + if ((ptr = get_pointer_type(path, &RNA_Material))) { + Material *ma = ptr->data; if (ma) { - bNode *node= give_current_material_texture_node(ma); + bNode *node = give_current_material_texture_node(ma); CTX_data_pointer_set(result, &ma->nodetree->id, &RNA_Node, node); } } @@ -813,14 +814,14 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r } } else if (CTX_data_equals(member, "texture_slot")) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; PointerRNA *ptr; if (ct) - return 0; /* new shading system */ + return 0; /* new shading system */ - if ((ptr=get_pointer_type(path, &RNA_Material))) { - Material *ma= ptr->data; + if ((ptr = get_pointer_type(path, &RNA_Material))) { + Material *ma = ptr->data; /* if we have a node material, get slot from material in material node */ if (ma && ma->use_nodes && ma->nodetree) { @@ -829,7 +830,7 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r if (give_current_material_texture_node(ma)) return 0; - ma= give_node_material(ma); + ma = give_node_material(ma); if (ma) CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); else @@ -839,26 +840,26 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r CTX_data_pointer_set(result, &ma->id, &RNA_MaterialTextureSlot, ma->mtex[(int)ma->texact]); } } - else if ((ptr=get_pointer_type(path, &RNA_Lamp))) { - Lamp *la= ptr->data; + else if ((ptr = get_pointer_type(path, &RNA_Lamp))) { + Lamp *la = ptr->data; if (la) CTX_data_pointer_set(result, &la->id, &RNA_LampTextureSlot, la->mtex[(int)la->texact]); } - else if ((ptr=get_pointer_type(path, &RNA_World))) { - World *wo= ptr->data; + else if ((ptr = get_pointer_type(path, &RNA_World))) { + World *wo = ptr->data; if (wo) CTX_data_pointer_set(result, &wo->id, &RNA_WorldTextureSlot, wo->mtex[(int)wo->texact]); } - else if ((ptr=get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ - Brush *br= ptr->data; + else if ((ptr = get_pointer_type(path, &RNA_Brush))) { /* how to get this into context? */ + Brush *br = ptr->data; if (br) CTX_data_pointer_set(result, &br->id, &RNA_BrushTextureSlot, &br->mtex); } - else if ((ptr=get_pointer_type(path, &RNA_ParticleSystem))) { - ParticleSettings *part= ((ParticleSystem *)ptr->data)->part; + else if ((ptr = get_pointer_type(path, &RNA_ParticleSystem))) { + ParticleSettings *part = ((ParticleSystem *)ptr->data)->part; if (part) CTX_data_pointer_set(result, &part->id, &RNA_ParticleSettingsTextureSlot, part->mtex[(int)part->texact]); @@ -883,59 +884,59 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "particle_system_editable")) { - if (PE_poll((bContext*)C)) + if (PE_poll((bContext *)C)) set_pointer_type(path, result, &RNA_ParticleSystem); else CTX_data_pointer_set(result, NULL, &RNA_ParticleSystem, NULL); return 1; } else if (CTX_data_equals(member, "cloth")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Cloth); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Cloth); CTX_data_pointer_set(result, &ob->id, &RNA_ClothModifier, md); return 1; } } else if (CTX_data_equals(member, "soft_body")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Softbody); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Softbody); CTX_data_pointer_set(result, &ob->id, &RNA_SoftBodyModifier, md); return 1; } } else if (CTX_data_equals(member, "fluid")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Fluidsim); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Fluidsim); CTX_data_pointer_set(result, &ob->id, &RNA_FluidSimulationModifier, md); return 1; } } else if (CTX_data_equals(member, "smoke")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Smoke); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Smoke); CTX_data_pointer_set(result, &ob->id, &RNA_SmokeModifier, md); return 1; } } else if (CTX_data_equals(member, "collision")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_Collision); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_Collision); CTX_data_pointer_set(result, &ob->id, &RNA_CollisionModifier, md); return 1; } @@ -945,11 +946,11 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r return 1; } else if (CTX_data_equals(member, "dynamic_paint")) { - PointerRNA *ptr= get_pointer_type(path, &RNA_Object); + PointerRNA *ptr = get_pointer_type(path, &RNA_Object); if (ptr && ptr->data) { - Object *ob= ptr->data; - ModifierData *md= modifiers_findByType(ob, eModifierType_DynamicPaint); + Object *ob = ptr->data; + ModifierData *md = modifiers_findByType(ob, eModifierType_DynamicPaint); CTX_data_pointer_set(result, &ob->id, &RNA_DynamicPaintModifier, md); return 1; } @@ -965,21 +966,21 @@ int buttons_context(const bContext *C, const char *member, bContextDataResult *r static void pin_cb(bContext *C, void *UNUSED(arg1), void *UNUSED(arg2)) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); if (sbuts->flag & SB_PIN_CONTEXT) { - sbuts->pinid= buttons_context_id_path(C); + sbuts->pinid = buttons_context_id_path(C); } else - sbuts->pinid= NULL; + sbuts->pinid = NULL; ED_area_tag_redraw(CTX_wm_area(C)); } void buttons_context_draw(const bContext *C, uiLayout *layout) { - SpaceButs *sbuts= CTX_wm_space_buts(C); - ButsContextPath *path= sbuts->path; + SpaceButs *sbuts = CTX_wm_space_buts(C); + ButsContextPath *path = sbuts->path; uiLayout *row; uiBlock *block; uiBut *but; @@ -990,28 +991,28 @@ void buttons_context_draw(const bContext *C, uiLayout *layout) if (!path) return; - row= uiLayoutRow(layout, 1); + row = uiLayoutRow(layout, 1); uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT); - block= uiLayoutGetBlock(row); + block = uiLayoutGetBlock(row); uiBlockSetEmboss(block, UI_EMBOSSN); but = uiDefIconButBitC(block, ICONTOG, SB_PIN_CONTEXT, 0, ICON_UNPINNED, 0, 0, UI_UNIT_X, UI_UNIT_Y, &sbuts->flag, 0, 0, 0, 0, "Follow context or keep fixed datablock displayed"); uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */ uiButSetFunc(but, pin_cb, NULL, NULL); - for (a=0; alen; a++) { - ptr= &path->ptr[a]; + for (a = 0; a < path->len; a++) { + ptr = &path->ptr[a]; if (a != 0) uiItemL(row, "", VICO_SMALL_TRI_RIGHT_VEC); if (ptr->data) { - icon= RNA_struct_ui_icon(ptr->type); - name= RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); + icon = RNA_struct_ui_icon(ptr->type); + name = RNA_struct_name_get_alloc(ptr, namebuf, sizeof(namebuf), NULL); if (name) { if (!ELEM(sbuts->mainb, BCONTEXT_RENDER, BCONTEXT_SCENE) && ptr->type == &RNA_Scene) - uiItemLDrag(row, ptr, "", icon); /* save some space */ + uiItemLDrag(row, ptr, "", icon); /* save some space */ else uiItemLDrag(row, ptr, name, icon); @@ -1033,24 +1034,24 @@ void buttons_context_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"); + pt = MEM_callocN(sizeof(PanelType), "spacetype buttons panel context"); strcpy(pt->idname, "BUTTONS_PT_context"); strcpy(pt->label, "Context"); - pt->draw= buttons_panel_context; - pt->flag= PNL_NO_HEADER; + pt->draw = buttons_panel_context; + pt->flag = PNL_NO_HEADER; BLI_addtail(&art->paneltypes, pt); } ID *buttons_context_id_path(const bContext *C) { - SpaceButs *sbuts= CTX_wm_space_buts(C); - ButsContextPath *path= sbuts->path; + SpaceButs *sbuts = CTX_wm_space_buts(C); + ButsContextPath *path = sbuts->path; PointerRNA *ptr; int a; if (path->len) { - for (a=path->len-1; a>=0; a--) { - ptr= &path->ptr[a]; + for (a = path->len - 1; a >= 0; a--) { + ptr = &path->ptr[a]; /* pin particle settings instead of system, since only settings are an idblock*/ if (sbuts->mainb == BCONTEXT_PARTICLE && sbuts->flag & SB_PIN_CONTEXT) { diff --git a/source/blender/editors/space_buttons/buttons_header.c b/source/blender/editors/space_buttons/buttons_header.c index 2385bfd75b7..661f7ad7d0f 100644 --- a/source/blender/editors/space_buttons/buttons_header.c +++ b/source/blender/editors/space_buttons/buttons_header.c @@ -51,8 +51,8 @@ #include "buttons_intern.h" -#define B_CONTEXT_SWITCH 101 -#define B_BUTSPREVIEW 102 +#define B_CONTEXT_SWITCH 101 +#define B_BUTSPREVIEW 102 static void set_texture_context(bContext *C, SpaceButs *sbuts) { @@ -63,7 +63,7 @@ static void set_texture_context(bContext *C, SpaceButs *sbuts) case BCONTEXT_DATA: { Object *ob = CTX_data_active_object(C); - if (ob && ob->type==OB_LAMP) + if (ob && ob->type == OB_LAMP) sbuts->texture_context = SB_TEXC_MAT_OR_LAMP; break; } @@ -78,7 +78,7 @@ static void set_texture_context(bContext *C, SpaceButs *sbuts) static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); if (!sbuts) /* editor type switch */ return; @@ -90,28 +90,28 @@ static void do_buttons_buttons(bContext *C, void *UNUSED(arg), int event) set_texture_context(C, sbuts); - sbuts->preview= 1; + sbuts->preview = 1; break; } - sbuts->mainbuser= sbuts->mainb; + sbuts->mainbuser = sbuts->mainb; } -#define BUT_UNIT_X (UI_UNIT_X+2) +#define BUT_UNIT_X (UI_UNIT_X + 2) void buttons_header_buttons(const bContext *C, ARegion *ar) { - SpaceButs *sbuts= CTX_wm_space_buts(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); uiBlock *block; uiBut *but; - int xco, yco= 2; + int xco, yco = 2; buttons_context_compute(C, sbuts); - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetHandleFunc(block, do_buttons_buttons, NULL); - xco= ED_area_header_switchbutton(C, block, yco); + xco = ED_area_header_switchbutton(C, block, yco); uiBlockSetEmboss(block, UI_EMBOSS); @@ -122,8 +122,8 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) uiBlockBeginAlign(block); #define BUTTON_HEADER_CTX(_ctx, _icon, _tip) \ - if (sbuts->pathflag & (1<<_ctx)) { \ - but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco+=BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ + if (sbuts->pathflag & (1 << _ctx)) { \ + but = uiDefIconButS(block, ROW, B_CONTEXT_SWITCH, _icon, xco += BUT_UNIT_X, yco, BUT_UNIT_X, UI_UNIT_Y, &(sbuts->mainb), 0.0, (float)_ctx, 0, 0, TIP_(_tip)); \ uiButClearFlag(but, UI_BUT_UNDO); \ } \ @@ -143,12 +143,12 @@ void buttons_header_buttons(const bContext *C, ARegion *ar) #undef BUTTON_HEADER_CTX - xco+= BUT_UNIT_X; + xco += BUT_UNIT_X; uiBlockEndAlign(block); /* always as last */ - UI_view2d_totRect_set(&ar->v2d, xco+(UI_UNIT_X/2), ar->v2d.tot.ymax-ar->v2d.tot.ymin); + UI_view2d_totRect_set(&ar->v2d, xco + (UI_UNIT_X / 2), ar->v2d.tot.ymax - ar->v2d.tot.ymin); uiEndBlock(C, block); uiDrawBlock(C, block); diff --git a/source/blender/editors/space_buttons/buttons_intern.h b/source/blender/editors/space_buttons/buttons_intern.h index 8d0f84cf70f..5700d361e15 100644 --- a/source/blender/editors/space_buttons/buttons_intern.h +++ b/source/blender/editors/space_buttons/buttons_intern.h @@ -47,17 +47,17 @@ struct uiLayout; struct wmOperatorType; /* buts->scaflag */ -#define BUTS_SENS_SEL 1 -#define BUTS_SENS_ACT 2 -#define BUTS_SENS_LINK 4 -#define BUTS_CONT_SEL 8 -#define BUTS_CONT_ACT 16 -#define BUTS_CONT_LINK 32 -#define BUTS_ACT_SEL 64 -#define BUTS_ACT_ACT 128 -#define BUTS_ACT_LINK 256 -#define BUTS_SENS_STATE 512 -#define BUTS_ACT_STATE 1024 +#define BUTS_SENS_SEL 1 +#define BUTS_SENS_ACT 2 +#define BUTS_SENS_LINK 4 +#define BUTS_CONT_SEL 8 +#define BUTS_CONT_ACT 16 +#define BUTS_CONT_LINK 32 +#define BUTS_ACT_SEL 64 +#define BUTS_ACT_ACT 128 +#define BUTS_ACT_LINK 256 +#define BUTS_SENS_STATE 512 +#define BUTS_ACT_STATE 1024 /* context data */ diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index ec1c74013e0..c29a8c3934e 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -56,22 +56,22 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" /* own include */ /********************** toolbox operator *********************/ static int toolbox_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { - bScreen *sc= CTX_wm_screen(C); - SpaceButs *sbuts= CTX_wm_space_buts(C); + bScreen *sc = CTX_wm_screen(C); + SpaceButs *sbuts = CTX_wm_space_buts(C); PointerRNA ptr; uiPopupMenu *pup; uiLayout *layout; RNA_pointer_create(&sc->id, &RNA_SpaceProperties, sbuts, &ptr); - pup= uiPupMenuBegin(C, "Align", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Align", ICON_NONE); + layout = uiPupMenuLayout(pup); uiItemsEnumR(layout, &ptr, "align"); uiPupMenuEnd(C, pup); @@ -99,15 +99,15 @@ typedef struct FileBrowseOp { static int file_browse_exec(bContext *C, wmOperator *op) { - FileBrowseOp *fbo= op->customdata; + FileBrowseOp *fbo = op->customdata; ID *id; char *str, path[FILE_MAX]; - const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; + const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - if (RNA_struct_property_is_set(op->ptr, path_prop)==0 || fbo==NULL) + if (RNA_struct_property_is_set(op->ptr, path_prop) == 0 || fbo == NULL) return OPERATOR_CANCELLED; - str= RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); + str = RNA_string_get_alloc(op->ptr, path_prop, NULL, 0); /* add slash for directories, important for some properties */ if (RNA_property_subtype(fbo->prop) == PROP_DIRPATH) { @@ -119,7 +119,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) BLI_path_abs(path, id ? ID_BLEND_PATH(G.main, id) : G.main->name); if (BLI_is_dir(path)) { - str = MEM_reallocN(str, strlen(str)+2); + str = MEM_reallocN(str, strlen(str) + 2); BLI_add_slash(str); } else @@ -133,7 +133,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) /* special, annoying exception, filesel on redo panel [#26618] */ { - wmOperator *redo_op= WM_operator_last_redo(C); + wmOperator *redo_op = WM_operator_last_redo(C); if (redo_op) { if (fbo->ptr.data == redo_op->ptr->data) { ED_undo_operator_repeat(C, redo_op); @@ -149,7 +149,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) static int file_browse_cancel(bContext *UNUSED(C), wmOperator *op) { MEM_freeN(op->customdata); - op->customdata= NULL; + op->customdata = NULL; return OPERATOR_CANCELLED; } @@ -171,7 +171,7 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) if (!prop) return OPERATOR_CANCELLED; - str= RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); + str = RNA_property_string_get_alloc(&ptr, prop, NULL, 0, NULL); /* useful yet irritating feature, Shift+Click to open the file * Alt+Click to browse a folder in the OS's browser */ @@ -179,9 +179,9 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) PointerRNA props_ptr; if (event->alt) { - char *lslash= BLI_last_slash(str); + char *lslash = BLI_last_slash(str); if (lslash) - *lslash= '\0'; + *lslash = '\0'; } @@ -194,11 +194,11 @@ static int file_browse_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } else { - const char *path_prop= RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; - fbo= MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); - fbo->ptr= ptr; - fbo->prop= prop; - op->customdata= fbo; + const char *path_prop = RNA_struct_find_property(op->ptr, "directory") ? "directory" : "filepath"; + fbo = MEM_callocN(sizeof(FileBrowseOp), "FileBrowseOp"); + fbo->ptr = ptr; + fbo->prop = prop; + op->customdata = fbo; RNA_string_set(op->ptr, path_prop, str); MEM_freeN(str); @@ -230,7 +230,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) ot->cancel = file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /* second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY */ @@ -247,5 +247,5 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot) ot->cancel = file_browse_cancel; /* properties */ - WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, 0, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } diff --git a/source/blender/editors/space_buttons/buttons_texture.c b/source/blender/editors/space_buttons/buttons_texture.c index ba37cb8a892..5c5c24f7bc1 100644 --- a/source/blender/editors/space_buttons/buttons_texture.c +++ b/source/blender/editors/space_buttons/buttons_texture.c @@ -68,17 +68,17 @@ #include "../interface/interface_intern.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" // own include /************************* Texture User **************************/ static void buttons_texture_user_property_add(ListBase *users, ID *id, - PointerRNA ptr, PropertyRNA *prop, - const char *category, int icon, const char *name) + PointerRNA ptr, PropertyRNA *prop, + const char *category, int icon, const char *name) { ButsTextureUser *user = MEM_callocN(sizeof(ButsTextureUser), "ButsTextureUser"); - user->id= id; + user->id = id; user->ptr = ptr; user->prop = prop; user->category = category; @@ -90,12 +90,12 @@ static void buttons_texture_user_property_add(ListBase *users, ID *id, } static void buttons_texture_user_node_add(ListBase *users, ID *id, - bNodeTree *ntree, bNode *node, - const char *category, int icon, const char *name) + bNodeTree *ntree, bNode *node, + const char *category, int icon, const char *name) { ButsTextureUser *user = MEM_callocN(sizeof(ButsTextureUser), "ButsTextureUser"); - user->id= id; + user->id = id; user->ntree = ntree; user->node = node; user->category = category; @@ -107,12 +107,12 @@ static void buttons_texture_user_node_add(ListBase *users, ID *id, } static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, - bNodeTree *ntree, const char *category) + bNodeTree *ntree, const char *category) { bNode *node; if (ntree) { - for (node=ntree->nodes.first; node; node=node->next) { + for (node = ntree->nodes.first; node; node = node->next) { if (node->typeinfo->nclass == NODE_CLASS_TEXTURE) { PointerRNA ptr; /* PropertyRNA *prop; */ /* UNUSED */ @@ -121,10 +121,10 @@ static void buttons_texture_users_find_nodetree(ListBase *users, ID *id, /* prop = RNA_struct_find_property(&ptr, "texture"); */ /* UNUSED */ buttons_texture_user_node_add(users, id, ntree, node, - category, RNA_struct_ui_icon(ptr.type), node->name); + category, RNA_struct_ui_icon(ptr.type), node->name); } else if (node->type == NODE_GROUP && node->id) { - buttons_texture_users_find_nodetree(users, id, (bNodeTree*)node->id, category); + buttons_texture_users_find_nodetree(users, id, (bNodeTree *)node->id, category); } } } @@ -140,48 +140,48 @@ static void buttons_texture_modifier_foreach(void *userData, Object *ob, Modifie prop = RNA_struct_find_property(&ptr, propname); buttons_texture_user_property_add(users, &ob->id, ptr, prop, - "Modifiers", RNA_struct_ui_icon(ptr.type), md->name); + "Modifiers", RNA_struct_ui_icon(ptr.type), md->name); } static void buttons_texture_users_from_context(ListBase *users, const bContext *C, SpaceButs *sbuts) { - Scene *scene= NULL; - Object *ob= NULL; - Material *ma= NULL; - Lamp *la= NULL; - World *wrld= NULL; - Brush *brush= NULL; + Scene *scene = NULL; + Object *ob = NULL; + Material *ma = NULL; + Lamp *la = NULL; + World *wrld = NULL; + Brush *brush = NULL; ID *pinid = sbuts->pinid; /* get data from context */ if (pinid) { if (GS(pinid->name) == ID_SCE) - scene= (Scene*)pinid; + scene = (Scene *)pinid; else if (GS(pinid->name) == ID_OB) - ob= (Object*)pinid; + ob = (Object *)pinid; else if (GS(pinid->name) == ID_LA) - la= (Lamp*)pinid; + la = (Lamp *)pinid; else if (GS(pinid->name) == ID_WO) - wrld= (World*)pinid; + wrld = (World *)pinid; else if (GS(pinid->name) == ID_MA) - ma= (Material*)pinid; + ma = (Material *)pinid; else if (GS(pinid->name) == ID_BR) - brush= (Brush*)pinid; + brush = (Brush *)pinid; } if (!scene) - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if (!(pinid || pinid == &scene->id)) { - ob= (scene->basact)? scene->basact->object: NULL; - wrld= scene->world; - brush= paint_brush(paint_get_active(scene)); + ob = (scene->basact) ? scene->basact->object : NULL; + wrld = scene->world; + brush = paint_brush(paint_get_active(scene)); } if (ob && ob->type == OB_LAMP && !la) - la= ob->data; + la = ob->data; if (ob && !ma) - ma= give_current_material(ob, ob->actcol); + ma = give_current_material(ob, ob->actcol); /* fill users */ users->first = users->last = NULL; @@ -194,7 +194,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World"); if (ob) { - ParticleSystem *psys= psys_get_current(ob); + ParticleSystem *psys = psys_get_current(ob); MTex *mtex; int a; @@ -204,7 +204,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * /* particle systems */ if (psys) { /* todo: these slots are not in the UI */ - for (a=0; apart->mtex[a]; if (mtex) { @@ -215,7 +215,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &psys->part->id, ptr, prop, - "Particles", RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name); + "Particles", RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name); } } } @@ -229,7 +229,7 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &ob->id, ptr, prop, - "Fields", ICON_FORCE_TEXTURE, "Texture Field"); + "Fields", ICON_FORCE_TEXTURE, "Texture Field"); } } @@ -239,10 +239,10 @@ static void buttons_texture_users_from_context(ListBase *users, const bContext * PropertyRNA *prop; RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mtex, &ptr); - prop= RNA_struct_find_property(&ptr, "texture"); + prop = RNA_struct_find_property(&ptr, "texture"); buttons_texture_user_property_add(users, &brush->id, ptr, prop, - "Brush", ICON_BRUSH_DATA, brush->id.name+2); + "Brush", ICON_BRUSH_DATA, brush->id.name + 2); } } @@ -250,22 +250,22 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) { /* gatheravailable texture users in context. runs on every draw of * properties editor, before the buttons are created. */ - ButsContextTexture *ct= sbuts->texuser; - Scene *scene= CTX_data_scene(C); + ButsContextTexture *ct = sbuts->texuser; + Scene *scene = CTX_data_scene(C); - if (!scene_use_new_shading_nodes(scene)) { + if (!BKE_scene_use_new_shading_nodes(scene)) { if (ct) { BLI_freelistN(&ct->users); MEM_freeN(ct); - sbuts->texuser= NULL; + sbuts->texuser = NULL; } return; } if (!ct) { - ct= MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); - sbuts->texuser= ct; + ct = MEM_callocN(sizeof(ButsContextTexture), "ButsContextTexture"); + sbuts->texuser = ct; } else { BLI_freelistN(&ct->users); @@ -275,7 +275,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* set one user as active based on active index */ if (ct->index >= BLI_countlist(&ct->users)) - ct->index= 0; + ct->index = 0; ct->user = BLI_findlink(&ct->users, ct->index); ct->texture = NULL; @@ -287,7 +287,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* get texture datablock pointer if it's a property */ texptr = RNA_property_pointer_get(&ct->user->ptr, ct->user->prop); - tex = (RNA_struct_is_a(texptr.type, &RNA_Texture))? texptr.data: NULL; + tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL; ct->texture = tex; } @@ -296,7 +296,7 @@ void buttons_texture_context_compute(const bContext *C, SpaceButs *sbuts) /* detect change of active texture node in same node tree, in that * case we also automatically switch to the other node */ - for (user=ct->users.first; user; user=user->next) { + for (user = ct->users.first; user; user = user->next) { if (user->ntree == ct->user->ntree && user->node != ct->user->node) { if (user->node->flag & NODE_ACTIVE_TEXTURE) { ct->user = user; @@ -313,8 +313,8 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) { /* callback when selecting a texture user in the menu */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; - ButsTextureUser *user = (ButsTextureUser*)user_p; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; + ButsTextureUser *user = (ButsTextureUser *)user_p; PointerRNA texptr; Tex *tex; @@ -328,7 +328,7 @@ static void template_texture_select(bContext *C, void *user_p, void *UNUSED(arg) } else { texptr = RNA_property_pointer_get(&user->ptr, user->prop); - tex = (RNA_struct_is_a(texptr.type, &RNA_Texture))? texptr.data: NULL; + tex = (RNA_struct_is_a(texptr.type, &RNA_Texture)) ? texptr.data : NULL; ct->texture = tex; } @@ -341,27 +341,27 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void *UNUS { /* callback when opening texture user selection menu, to create buttons. */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; uiBlock *block = uiLayoutGetBlock(layout); const char *last_category = NULL; - for (user=ct->users.first; user; user=user->next) { + for (user = ct->users.first; user; user = user->next) { uiBut *but; char name[UI_MAX_NAME_STR]; /* add label per category */ if (!last_category || strcmp(last_category, user->category) != 0) { uiItemL(layout, user->category, ICON_NONE); - but= block->buttons.last; - but->flag= UI_TEXT_LEFT; + but = block->buttons.last; + but->flag = UI_TEXT_LEFT; } /* create button */ BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); - but = uiDefIconTextBut(block, BUT, 0, user->icon, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, ""); + but = uiDefIconTextBut(block, BUT, 0, user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, ""); uiButSetNFunc(but, template_texture_select, MEM_dupallocN(user), NULL); last_category = user->category; @@ -374,7 +374,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) * gathered before drawing in ButsContextTexture, we merely need to * display the current item. */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; uiBlock *block = uiLayoutGetBlock(layout); uiBut *but; ButsTextureUser *user; @@ -384,7 +384,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) return; /* get current user */ - user= ct->user; + user = ct->user; if (!user) { uiItemL(layout, "No textures in context.", ICON_NONE); @@ -396,15 +396,15 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) if (user->icon) { but = uiDefIconTextMenuBut(block, template_texture_user_menu, NULL, - user->icon, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + user->icon, name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } else { but = uiDefMenuBut(block, template_texture_user_menu, NULL, - name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, ""); + name, 0, 0, UI_UNIT_X * 4, UI_UNIT_Y, ""); } /* some cosmetic tweaks */ - but->type= MENU; + but->type = MENU; but->flag |= UI_TEXT_LEFT; but->flag &= ~UI_ICON_SUBMENU; } @@ -414,13 +414,13 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) static void template_texture_show(bContext *C, void *data_p, void *prop_p) { SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; if (!ct) return; - for (user=ct->users.first; user; user=user->next) + for (user = ct->users.first; user; user = user->next) if (user->ptr.data == data_p && user->prop == prop_p) break; @@ -429,9 +429,9 @@ static void template_texture_show(bContext *C, void *data_p, void *prop_p) template_texture_select(C, user, NULL); /* change context */ - sbuts->mainb= BCONTEXT_TEXTURE; - sbuts->mainbuser= sbuts->mainb; - sbuts->preview= 1; + sbuts->mainb = BCONTEXT_TEXTURE; + sbuts->mainbuser = sbuts->mainb; + sbuts->preview = 1; /* redraw editor */ ED_area_tag_redraw(CTX_wm_area(C)); @@ -442,7 +442,7 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope { /* button to quickly show texture in texture tab */ SpaceButs *sbuts = CTX_wm_space_buts(C); - ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL; + ButsContextTexture *ct = (sbuts) ? sbuts->texuser : NULL; ButsTextureUser *user; /* only show button in other tabs in properties editor */ @@ -450,7 +450,7 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope return; /* find corresponding texture user */ - for (user=ct->users.first; user; user=user->next) + for (user = ct->users.first; user; user = user->next) if (user->ptr.data == ptr->data && user->prop == prop) break; @@ -460,7 +460,7 @@ void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, Prope uiBut *but; but = uiDefIconBut(block, BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab"); + NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab"); uiButSetFunc(but, template_texture_show, user->ptr.data, user->prop); } } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 7e9ccdfb414..d1737fcd065 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -55,7 +55,7 @@ #include "ED_render.h" -#include "buttons_intern.h" // own include +#include "buttons_intern.h" /* own include */ /* ******************** default callbacks for buttons space ***************** */ @@ -64,30 +64,30 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) ARegion *ar; SpaceButs *sbuts; - sbuts= MEM_callocN(sizeof(SpaceButs), "initbuts"); - sbuts->spacetype= SPACE_BUTS; - sbuts->align= BUT_VERTICAL; + sbuts = MEM_callocN(sizeof(SpaceButs), "initbuts"); + sbuts->spacetype = SPACE_BUTS; + sbuts->align = BUT_VERTICAL; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for buts"); + ar = MEM_callocN(sizeof(ARegion), "header for buts"); BLI_addtail(&sbuts->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_TOP; #if 0 /* context area */ - ar= MEM_callocN(sizeof(ARegion), "context area for buts"); + ar = MEM_callocN(sizeof(ARegion), "context area for buts"); BLI_addtail(&sbuts->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_TOP; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_TOP; #endif /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for buts"); + ar = MEM_callocN(sizeof(ARegion), "main area for buts"); BLI_addtail(&sbuts->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; return (SpaceLink *)sbuts; } @@ -95,13 +95,13 @@ static SpaceLink *buttons_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void buttons_free(SpaceLink *sl) { - SpaceButs *sbuts= (SpaceButs*) sl; + SpaceButs *sbuts = (SpaceButs *) sl; if (sbuts->path) MEM_freeN(sbuts->path); if (sbuts->texuser) { - ButsContextTexture *ct= sbuts->texuser; + ButsContextTexture *ct = sbuts->texuser; BLI_freelistN(&ct->users); MEM_freeN(ct); } @@ -110,24 +110,24 @@ static void buttons_free(SpaceLink *sl) /* spacetype; init callback */ static void buttons_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceButs *sbuts= sa->spacedata.first; + SpaceButs *sbuts = sa->spacedata.first; /* auto-align based on size */ if (sbuts->align == BUT_AUTO || !sbuts->align) { if (sa->winx > sa->winy) - sbuts->align= BUT_HORIZONTAL; + sbuts->align = BUT_HORIZONTAL; else - sbuts->align= BUT_VERTICAL; + sbuts->align = BUT_VERTICAL; } } static SpaceLink *buttons_duplicate(SpaceLink *sl) { - SpaceButs *sbutsn= MEM_dupallocN(sl); + SpaceButs *sbutsn = MEM_dupallocN(sl); /* clear or remove stuff from old */ - sbutsn->path= NULL; - sbutsn->texuser= NULL; + sbutsn->path = NULL; + sbutsn->texuser = NULL; return (SpaceLink *)sbutsn; } @@ -146,8 +146,8 @@ static void buttons_main_area_init(wmWindowManager *wm, ARegion *ar) static void buttons_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceButs *sbuts= CTX_wm_space_buts(C); - int vertical= (sbuts->align == BUT_VERTICAL); + SpaceButs *sbuts = CTX_wm_space_buts(C); + int vertical = (sbuts->align == BUT_VERTICAL); buttons_context_compute(C, sbuts); @@ -178,8 +178,8 @@ static void buttons_main_area_draw(const bContext *C, ARegion *ar) else if (sbuts->mainb == BCONTEXT_BONE_CONSTRAINT) ED_region_panels(C, ar, vertical, "bone_constraint", sbuts->mainb); - sbuts->re_align= 0; - sbuts->mainbo= sbuts->mainb; + sbuts->re_align = 0; + sbuts->mainbo = sbuts->mainb; } static void buttons_operatortypes(void) @@ -205,7 +205,7 @@ static void buttons_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar) static void buttons_header_area_draw(const bContext *C, ARegion *ar) { /* clear */ - UI_ThemeClearColor(ED_screen_area_active(C)?TH_HEADER:TH_HEADERDESEL); + UI_ThemeClearColor(ED_screen_area_active(C) ? TH_HEADER : TH_HEADERDESEL); glClear(GL_COLOR_BUFFER_BIT); /* set view2d view matrix for scrolling (without scrollers) */ @@ -221,7 +221,7 @@ static void buttons_header_area_draw(const bContext *C, ARegion *ar) * showing that button set, to reduce unnecessary drawing. */ static void buttons_area_redraw(ScrArea *sa, short buttons) { - SpaceButs *sbuts= sa->spacedata.first; + SpaceButs *sbuts = sa->spacedata.first; /* if the area's current button set is equal to the one to redraw */ if (sbuts->mainb == buttons) @@ -231,7 +231,7 @@ static void buttons_area_redraw(ScrArea *sa, short buttons) /* reused! */ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceButs *sbuts= sa->spacedata.first; + SpaceButs *sbuts = sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -243,11 +243,11 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_FRAME: /* any buttons area can have animated properties so redraw all */ ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case ND_OB_ACTIVE: ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case ND_KEYINGSET: buttons_area_redraw(sa, BCONTEXT_SCENE); @@ -265,7 +265,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) switch (wmn->data) { case ND_TRANSFORM: buttons_area_redraw(sa, BCONTEXT_OBJECT); - buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ + buttons_area_redraw(sa, BCONTEXT_DATA); /* autotexpace flag */ break; case ND_POSE: buttons_area_redraw(sa, BCONTEXT_DATA); @@ -280,7 +280,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); else buttons_area_redraw(sa, BCONTEXT_MODIFIER); - buttons_area_redraw(sa, BCONTEXT_PHYSICS); + buttons_area_redraw(sa, BCONTEXT_PHYSICS); break; case ND_CONSTRAINT: buttons_area_redraw(sa, BCONTEXT_CONSTRAINT); @@ -289,7 +289,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_PARTICLE: if (wmn->action == NA_EDITED) buttons_area_redraw(sa, BCONTEXT_PARTICLE); - sbuts->preview= 1; + sbuts->preview = 1; break; case ND_DRAW: buttons_area_redraw(sa, BCONTEXT_OBJECT); @@ -298,7 +298,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_SHADING: case ND_SHADING_DRAW: /* currently works by redraws... if preview is set, it (re)starts job */ - sbuts->preview= 1; + sbuts->preview = 1; break; default: /* Not all object RNA props have a ND_ notifier (yet) */ @@ -321,17 +321,17 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case ND_SHADING_DRAW: case ND_NODES: /* currently works by redraws... if preview is set, it (re)starts job */ - sbuts->preview= 1; + sbuts->preview = 1; break; } break; case NC_WORLD: buttons_area_redraw(sa, BCONTEXT_WORLD); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_LAMP: buttons_area_redraw(sa, BCONTEXT_DATA); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_BRUSH: buttons_area_redraw(sa, BCONTEXT_TEXTURE); @@ -339,7 +339,7 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) case NC_TEXTURE: case NC_IMAGE: ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_SPACE: if (wmn->data == ND_SPACE_PROPERTIES) @@ -358,17 +358,17 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_NODE: - if (wmn->action==NA_SELECTED) { + if (wmn->action == NA_SELECTED) { ED_area_tag_redraw(sa); /* new active node, update texture preview */ if (sbuts->mainb == BCONTEXT_TEXTURE) - sbuts->preview= 1; + sbuts->preview = 1; } break; /* Listener for preview render, when doing an global undo. */ case NC_WINDOW: ED_area_tag_redraw(sa); - sbuts->preview= 1; + sbuts->preview = 1; break; case NC_LINESTYLE: ED_area_tag_redraw(sa); @@ -383,39 +383,39 @@ static void buttons_area_listener(ScrArea *sa, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_buttons(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype buttons"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype buttons"); ARegionType *art; - st->spaceid= SPACE_BUTS; + st->spaceid = SPACE_BUTS; strncpy(st->name, "Buttons", BKE_ST_MAXNAME); - st->new= buttons_new; - st->free= buttons_free; - st->init= buttons_init; - st->duplicate= buttons_duplicate; - st->operatortypes= buttons_operatortypes; - st->keymap= buttons_keymap; - st->listener= buttons_area_listener; - st->context= buttons_context; + st->new = buttons_new; + st->free = buttons_free; + st->init = buttons_init; + st->duplicate = buttons_duplicate; + st->operatortypes = buttons_operatortypes; + st->keymap = buttons_keymap; + st->listener = buttons_area_listener; + st->context = buttons_context; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); art->regionid = RGN_TYPE_WINDOW; - art->init= buttons_main_area_init; - art->draw= buttons_main_area_draw; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_FRAMES; + art->init = buttons_main_area_init; + art->draw = buttons_main_area_draw; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); buttons_context_register(art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype buttons region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= buttons_header_area_init; - art->draw= buttons_header_area_draw; + art->init = buttons_header_area_init; + art->draw = buttons_header_area_draw; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 5761a285d72..18f191a46a6 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -165,9 +165,10 @@ void uiTemplateTrack(uiLayout *layout, PointerRNA *ptr, const char *propname) block = uiLayoutAbsoluteBlock(layout); - scopes->track_preview_height = (scopes->track_preview_height<=UI_UNIT_Y)?UI_UNIT_Y:scopes->track_preview_height; + scopes->track_preview_height = (scopes->track_preview_height <= UI_UNIT_Y)?UI_UNIT_Y : scopes->track_preview_height; - uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax-rect.xmin, scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); + uiDefBut(block, TRACKPREVIEW, 0, "", rect.xmin, rect.ymin, rect.xmax - rect.xmin, + scopes->track_preview_height, scopes, 0, 0, 0, 0, ""); } /********************* Marker Template ************************/ @@ -213,7 +214,7 @@ static void marker_update_cb(bContext *C, void *arg_cb, void *UNUSED(arg)) marker->flag = cb->marker_flag; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); } static void marker_block_handler(bContext *C, void *arg_cb, int event) @@ -227,12 +228,12 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) marker = BKE_tracking_ensure_marker(cb->track, cb->framenr); if (event == B_MARKER_POS) { - marker->pos[0] = cb->marker_pos[0]/width; - marker->pos[1] = cb->marker_pos[1]/height; + marker->pos[0] = cb->marker_pos[0] / width; + marker->pos[1] = cb->marker_pos[1] / height; /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); ok = TRUE; } @@ -278,17 +279,17 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) sub_v2_v2v2(search_dim, cb->track->search_max, cb->track->search_min); - dim[0] = cb->track_search[0]/width; - dim[1] = cb->track_search[1]/height; + dim[0] = cb->track_search[0] / width; + dim[1] = cb->track_search[1] / height; sub_v2_v2(dim, search_dim); mul_v2_fl(dim, 0.5f); - cb->track->search_min[0]-= dim[0]; - cb->track->search_min[1]-= dim[1]; + cb->track->search_min[0] -= dim[0]; + cb->track->search_min[1] -= dim[1]; - cb->track->search_max[0]+= dim[0]; - cb->track->search_max[1]+= dim[1]; + cb->track->search_max[0] += dim[0]; + cb->track->search_max[1] += dim[1]; BKE_tracking_clamp_track(cb->track, CLAMP_SEARCH_DIM); @@ -314,16 +315,17 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) /* to update position of "parented" objects */ DAG_id_tag_update(&cb->clip->id, 0); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); ok = TRUE; } if (ok) - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, cb->clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, cb->clip); } -void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, PointerRNA *trackptr, int compact) +void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *userptr, + PointerRNA *trackptr, int compact) { PropertyRNA *prop; uiBlock *block; @@ -375,7 +377,8 @@ void uiTemplateMarker(uiLayout *layout, PointerRNA *ptr, const char *propname, P else tip = "Marker is enabled at current frame"; - bt = uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, &cb->marker_flag, 0, 0, 1, 0, tip); + bt = uiDefIconButBitI(block, TOGN, MARKER_DISABLED, 0, ICON_RESTRICT_VIEW_OFF, 0, 0, 20, 20, + &cb->marker_flag, 0, 0, 1, 0, tip); uiButSetNFunc(bt, marker_update_cb, cb, NULL); } else { diff --git a/source/blender/editors/space_clip/clip_dopesheet_draw.c b/source/blender/editors/space_clip/clip_dopesheet_draw.c index 574eb5b2570..84209f7b744 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_draw.c +++ b/source/blender/editors/space_clip/clip_dopesheet_draw.c @@ -122,13 +122,13 @@ static void draw_keyframe_shape(float x, float y, float xscale, float yscale, sh /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.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)); + UI_ThemeColorShadeAlpha(TH_STRIP_SELECT, 50, -255 * (1.0f - alpha)); else glColor4f(0.91f, 0.91f, 0.91f, alpha); diff --git a/source/blender/editors/space_clip/clip_dopesheet_ops.c b/source/blender/editors/space_clip/clip_dopesheet_ops.c index 9b9190e3e05..0fd17523425 100644 --- a/source/blender/editors/space_clip/clip_dopesheet_ops.c +++ b/source/blender/editors/space_clip/clip_dopesheet_ops.c @@ -100,7 +100,7 @@ static int dopesheet_select_channel_exec(bContext *C, wmOperator *op) current_channel_index++; } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -129,7 +129,7 @@ void CLIP_OT_dopesheet_select_channel(wmOperatorType *ot) ot->poll = dopesheet_select_channel_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index 33bc67db8e4..f92f639586d 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -87,7 +87,7 @@ void clip_draw_curfra_label(SpaceClip *sc, float x, float y) glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f); UI_ThemeColor(TH_TEXT); - BLF_position(fontid, x+2.0f, y+2.0f, 0.0f); + BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f); BLF_draw(fontid, numstr, sizeof(numstr)); } @@ -128,7 +128,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc int framenr; MovieTrackingMarker *marker; - while (amarkersnr) { + while (a < track->markersnr) { if (track->markers[a].framenr >= i) break; @@ -191,7 +191,7 @@ static void draw_movieclip_cache(SpaceClip *sc, ARegion *ar, MovieClip *clip, Sc x = (sc->user.framenr - sfra) / (efra - sfra + 1) * ar->winx; UI_ThemeColor(TH_CFRAME); - glRecti(x, 0, x+framelen, 8); + glRecti(x, 0, x + framelen, 8); clip_draw_curfra_label(sc, x, 8.0f); } @@ -267,7 +267,7 @@ static void draw_movieclip_buffer(SpaceClip *sc, ARegion *ar, ImBuf *ibuf, * be binder fallback to simple draw pixels solution */ if (need_fallback) { /* set zoom */ - glPixelZoom(zoomx*width/ibuf->x, zoomy*height/ibuf->y); + glPixelZoom(zoomx * width / ibuf->x, zoomy * height / ibuf->y); glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); @@ -346,7 +346,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin b = count; i = framenr; - while (i <= framenr+count) { + while (i <= framenr + count) { marker = BKE_tracking_get_marker(track, i); if (!marker || marker->flag & MARKER_DISABLED) @@ -357,7 +357,7 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin curindex = b; add_v2_v2v2(path[b++], marker->pos, track->offset); - ED_clip_point_undistorted_pos(sc, path[b-1], path[b-1]); + ED_clip_point_undistorted_pos(sc, path[b - 1], path[b - 1]); } else break; @@ -414,7 +414,8 @@ static void draw_track_path(SpaceClip *sc, MovieClip *UNUSED(clip), MovieTrackin glPointSize(1.0f); } -static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height) +static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int width, int height) { int tiny = sc->flag & SC_SHOW_TINY_MARKER; int show_search = FALSE; @@ -434,7 +435,7 @@ static void draw_marker_outline(SpaceClip *sc, MovieTrackingTrack *track, MovieT ED_clip_point_undistorted_pos(sc, pos, pos); - if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (BLI_in_rctf(&r, pos[0] - marker_pos[0], pos[1] - marker_pos[1])) { if (tiny) glPointSize(3.0f); else glPointSize(4.0f); glBegin(GL_POINTS); @@ -513,7 +514,8 @@ static void track_colors(MovieTrackingTrack *track, int act, float col[3], float } } -static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int width, int height, int act, int sel) +static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int width, int height, int act, int sel) { int tiny = sc->flag & SC_SHOW_TINY_MARKER; int show_search = 0; @@ -521,8 +523,8 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra track_colors(track, act, col, scol); - px[0]= 1.0f / width / sc->zoom; - px[1]= 1.0f / height / sc->zoom; + px[0] = 1.0f / width / sc->zoom; + px[1] = 1.0f / height / sc->zoom; /* marker position and offset position */ if ((track->flag & SELECT) == sel && (marker->flag & MARKER_DISABLED) == 0) { @@ -548,7 +550,7 @@ static void draw_marker_areas(SpaceClip *sc, MovieTrackingTrack *track, MovieTra add_v2_v2v2(pos, marker->pos, track->offset); ED_clip_point_undistorted_pos(sc, pos, pos); - if (BLI_in_rctf(&r, pos[0]-marker_pos[0], pos[1]-marker_pos[1])) { + if (BLI_in_rctf(&r, pos[0] - marker_pos[0], pos[1] - marker_pos[1])) { if (!tiny) glPointSize(2.0f); @@ -768,18 +770,18 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } glBegin(GL_QUADS); - glVertex3f(x-tdx, y+tdy, 0); - glVertex3f(x+tdx, y+tdy, 0); - glVertex3f(x+tdx, y-tdy, 0); - glVertex3f(x-tdx, y-tdy, 0); + glVertex3f(x - tdx, y + tdy, 0); + glVertex3f(x + tdx, y + tdy, 0); + glVertex3f(x + tdx, y - tdy, 0); + glVertex3f(x - tdx, y - tdy, 0); glEnd(); /* search re-sizing triangle */ x = track->search_max[0]; y = track->search_min[1]; - tdx = searchdx*2.0f; - tdy = searchdy*2.0f; + tdx = searchdx * 2.0f; + tdy = searchdy * 2.0f; if (outline) { tdx += px[0]; @@ -788,12 +790,12 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glBegin(GL_TRIANGLES); glVertex3f(x, y, 0); - glVertex3f(x-tdx, y, 0); - glVertex3f(x, y+tdy, 0); + glVertex3f(x - tdx, y, 0); + glVertex3f(x, y + tdy, 0); glEnd(); } - if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT)==sel || outline)) { + if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) { if (!outline) { if (track->pat_flag & SELECT) glColor3fv(scol); @@ -814,10 +816,10 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo } glBegin(GL_QUADS); - glVertex3f(x-tdx, y+tdy, 0); - glVertex3f(x+tdx, y+tdy, 0); - glVertex3f(x+tdx, y-tdy, 0); - glVertex3f(x-tdx, y-tdy, 0); + glVertex3f(x - tdx, y + tdy, 0); + glVertex3f(x + tdx, y + tdy, 0); + glVertex3f(x + tdx, y - tdy, 0); + glVertex3f(x - tdx, y - tdy, 0); glEnd(); /* pattern re-sizing triangle */ @@ -834,8 +836,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glBegin(GL_TRIANGLES); glVertex3f(x, y, 0); - glVertex3f(x-tdx, y, 0); - glVertex3f(x, y+tdy, 0); + glVertex3f(x - tdx, y, 0); + glVertex3f(x, y + tdy, 0); glEnd(); } @@ -845,8 +847,8 @@ static void draw_marker_slide_zones(SpaceClip *sc, MovieTrackingTrack *track, Mo glLineWidth(1.0f); } -static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, float marker_pos[2], int act, - int width, int height, float zoomx, float zoomy) +static void draw_marker_texts(SpaceClip *sc, MovieTrackingTrack *track, MovieTrackingMarker *marker, + float marker_pos[2], int act, int width, int height, float zoomx, float zoomy) { char str[128] = {0}, state[64] = {0}; float dx = 0.0f, dy = 0.0f, fontsize, pos[3]; @@ -971,7 +973,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* count */ track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) @@ -988,7 +990,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1009,7 +1011,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if (sc->flag & SC_SHOW_TRACK_PATH) { track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) + if ((track->flag & TRACK_HIDDEN) == 0) draw_track_path(sc, clip, track); track = track->next; @@ -1020,7 +1022,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1044,7 +1046,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, track = tracksbase->first; fp = marker_pos; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { int act = track == act_track; marker = BKE_tracking_get_marker(track, framenr); @@ -1066,7 +1068,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, /* active marker would be displayed on top of everything else */ if (act_track) { - if ((act_track->flag & TRACK_HIDDEN)==0) { + if ((act_track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(act_track, framenr); if (MARKER_VISIBLE(sc, act_track, marker)) { @@ -1096,7 +1098,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, if (MARKER_VISIBLE(sc, track, marker)) { float npos[2]; copy_v4_v4(vec, track->bundle_pos); - vec[3]=1; + vec[3] = 1; mul_v4_m4v4(pos, mat, vec); @@ -1111,7 +1113,7 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, sub_v2_v2(vec, npos); - if (len_v2(vec)< 3.0f) + if (len_v2(vec) < 3.0f) glColor3f(0.0f, 1.0f, 0.0f); else glColor3f(1.0f, 0.0f, 0.0f); @@ -1165,7 +1167,8 @@ static void draw_tracking_tracks(SpaceClip *sc, ARegion *ar, MovieClip *clip, MEM_freeN(marker_pos); } -static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int width, int height, float zoomx, float zoomy) +static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, + int width, int height, float zoomx, float zoomy) { float x, y; const int n = 10; @@ -1199,9 +1202,9 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid for (a = 0; a < 4; a++) { if (a < 2) - val[a][a%2] = FLT_MAX; + val[a][a % 2] = FLT_MAX; else - val[a][a%2] = -FLT_MAX; + val[a][a % 2] = -FLT_MAX; } zero_v2(pos); @@ -1213,10 +1216,10 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid for (a = 0; a < 4; a++) { int ok; - if (a<2) - ok = tpos[a%2] < val[a][a%2]; + if (a < 2) + ok = tpos[a % 2] < val[a][a % 2]; else - ok = tpos[a%2] > val[a][a%2]; + ok = tpos[a % 2] > val[a][a % 2]; if (ok) { copy_v2_v2(val[a], tpos); @@ -1310,11 +1313,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid pos[0] = stroke->points[i].x * width; pos[1] = stroke->points[i].y * height * aspy; - npos[0] = stroke->points[i+1].x * width; - npos[1] = stroke->points[i+1].y * height * aspy; + npos[0] = stroke->points[i + 1].x * width; + npos[1] = stroke->points[i + 1].y * height * aspy; len = len_v2v2(pos, npos); - steps = ceil(len/5.0f); + steps = ceil(len / 5.0f); /* we want to distort only long straight lines */ if (stroke->totpoints == 2) { @@ -1323,11 +1326,11 @@ static void draw_distortion(SpaceClip *sc, ARegion *ar, MovieClip *clip, int wid } sub_v2_v2v2(dpos, npos, pos); - mul_v2_fl(dpos, 1.0f/steps); + mul_v2_fl(dpos, 1.0f / steps); for (j = 0; j <= steps; j++) { BKE_tracking_apply_intrinsics(tracking, pos, tpos); - glVertex2f(tpos[0]/width, tpos[1]/(height*aspy)); + glVertex2f(tpos[0] / width, tpos[1] / (height*aspy)); add_v2_v2(pos, dpos); } @@ -1434,7 +1437,7 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d) if (onlyv2d) { /* if manual calibration is used then grease pencil data is already * drawed in draw_distortion */ - if ((sc->flag & SC_MANUAL_CALIBRATION)==0 || sc->mode != SC_MODE_DISTORTION) { + if ((sc->flag & SC_MANUAL_CALIBRATION) == 0 || sc->mode != SC_MODE_DISTORTION) { ibuf = ED_space_clip_get_buffer(sc); if (ibuf) { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index bd34a51819c..b3ac535ab9d 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -162,7 +162,7 @@ void ED_space_clip_set(bContext *C, bScreen *screen, SpaceClip *sc, MovieClip *c } if (C) - WM_event_add_notifier(C, NC_MOVIECLIP|NA_SELECTED, sc->clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_SELECTED, sc->clip); } MovieClip *ED_space_clip(SpaceClip *sc) @@ -220,8 +220,8 @@ void ED_space_clip_zoom(SpaceClip *sc, ARegion *ar, float *zoomx, float *zoomy) ED_space_clip_size(sc, &width, &height); - *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1)/(float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin)*width); - *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1)/(float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin)*height); + *zoomx = (float)(ar->winrct.xmax - ar->winrct.xmin + 1) / (float)((ar->v2d.cur.xmax - ar->v2d.cur.xmin) * width); + *zoomy = (float)(ar->winrct.ymax - ar->winrct.ymin + 1) / (float)((ar->v2d.cur.ymax - ar->v2d.cur.ymin) * height); } void ED_space_clip_aspect(SpaceClip *sc, float *aspx, float *aspy) @@ -317,7 +317,8 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) return FALSE; /* center view */ - clip_view_center_to_point(sc, (max[0]+min[0])/(2*frame_width), (max[1]+min[1])/(2*frame_height)); + clip_view_center_to_point(sc, (max[0] + min[0]) / (2 * frame_width), + (max[1] + min[1]) / (2 * frame_height)); w = max[0] - min[0]; h = max[1] - min[1]; @@ -337,7 +338,7 @@ int ED_clip_view_selection(SpaceClip *sc, ARegion *ar, int fit) newzoom = 1.0f / power_of_2(1.0f / MIN2(zoomx, zoomy)); - if (fit || sc->zoom>newzoom) + if (fit || sc->zoom > newzoom) sc->zoom = newzoom; } @@ -455,16 +456,11 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) if (need_rebind) { int width = ibuf->x, height = ibuf->y; - float *frect = NULL, *fscalerect = NULL; - unsigned int *rect = NULL, *scalerect = NULL; int need_recreate = 0; if (width > GL_MAX_TEXTURE_SIZE || height > GL_MAX_TEXTURE_SIZE) return 0; - rect = ibuf->rect; - frect = ibuf->rect_float; - /* if image resolution changed (e.g. switched to proxy display) texture need to be recreated */ need_recreate = context->image_width != ibuf->x || context->image_height != ibuf->y; @@ -497,10 +493,13 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) glBindTexture(GL_TEXTURE_2D, context->texture); } - if (frect) - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16, width, height, 0, GL_RGBA, GL_FLOAT, frect); - else - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rect); + if (ibuf->rect_float) { + if (ibuf->rect == NULL) + IMB_rect_from_float(ibuf); + } + + if (ibuf->rect) + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); /* store settings */ context->texture_allocated = 1; @@ -508,11 +507,6 @@ int ED_space_clip_load_movieclip_buffer(SpaceClip *sc, ImBuf *ibuf) context->image_width = ibuf->x; context->image_height = ibuf->y; context->framenr = sc->user.framenr; - - if (fscalerect) - MEM_freeN(fscalerect); - if (scalerect) - MEM_freeN(scalerect); } else { /* displaying exactly the same image which was loaded t oa texture, diff --git a/source/blender/editors/space_clip/clip_graph_draw.c b/source/blender/editors/space_clip/clip_graph_draw.c index 9f9bdcb6cd2..853a7d7cad1 100644 --- a/source/blender/editors/space_clip/clip_graph_draw.c +++ b/source/blender/editors/space_clip/clip_graph_draw.c @@ -81,7 +81,7 @@ static void draw_curve_knot(float x, float y, float xscale, float yscale, float glPushMatrix(); glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); glCallList(displist); glPopMatrix(); @@ -166,7 +166,8 @@ static void draw_tracks_curves(View2D *v2d, SpaceClip *sc) /* draw graph lines */ glEnable(GL_BLEND); - clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, tracking_segment_start_cb, tracking_segment_end_cb); + clip_graph_tracking_values_iterate(sc, act_track, tracking_segment_point_cb, + tracking_segment_start_cb, tracking_segment_end_cb); glDisable(GL_BLEND); /* selected knot handles on top of curves */ @@ -183,10 +184,10 @@ static void draw_frame_curves(SpaceClip *sc) glColor3f(0.0f, 0.0f, 1.0f); - for (i = 0; icamnr; i++) { + for (i = 0; i < reconstruction->camnr; i++) { MovieReconstructedCamera *camera = &reconstruction->cameras[i]; - if (lines && camera->framenr!=prevfra+1) { + if (lines && camera->framenr != prevfra + 1) { glEnd(); lines = 0; } diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index efe48cd4b36..10692ada5d9 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -144,7 +144,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, MovieTrackingTrack *tr float d = dx * dx + dy * dy; if (data->marker == NULL || d < data->min_dist) { - float co[2]= {marker->framenr, val}; + float co[2] = {marker->framenr, val}; data->track = track; data->marker = marker; @@ -252,7 +252,7 @@ static int mouse_select(bContext *C, float co[2], int extend) } if (sel) - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -358,7 +358,7 @@ static int border_select_graph_exec(bContext *C, wmOperator *op) clip_graph_tracking_values_iterate_track(sc, act_track, &userdata, border_select_cb, NULL, NULL); if (userdata.change) { - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -430,7 +430,7 @@ static int graph_select_all_markers_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -447,7 +447,7 @@ void CLIP_OT_graph_select_all_markers(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -481,7 +481,7 @@ void CLIP_OT_graph_delete_curve(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** delete knot operator ********************/ @@ -522,7 +522,7 @@ void CLIP_OT_graph_delete_knot(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /******************** view all operator ********************/ @@ -662,7 +662,7 @@ static int graph_disable_markers_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -686,7 +686,7 @@ void CLIP_OT_graph_disable_markers(wmOperatorType *ot) ot->poll = ED_space_clip_graph_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index b05d204b07b..117e599cbbb 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -93,8 +93,8 @@ static void sclip_zoom_set(SpaceClip *sc, ARegion *ar, float zoom, float locatio if ((U.uiflag & USER_ZOOM_TO_MOUSEPOS) && location) { ED_space_clip_size(sc, &width, &height); - sc->xof += ((location[0] - 0.5f) * width-sc->xof) * (sc->zoom-oldzoom) / sc->zoom; - sc->yof += ((location[1] - 0.5f) * height-sc->yof) * (sc->zoom-oldzoom) / sc->zoom; + sc->xof += ((location[0] - 0.5f) * width - sc->xof) * (sc->zoom - oldzoom) / sc->zoom; + sc->yof += ((location[1] - 0.5f) * height - sc->yof) * (sc->zoom - oldzoom) / sc->zoom; } } @@ -164,7 +164,8 @@ static int open_exec(bContext *C, wmOperator *op) if (op->customdata) MEM_freeN(op->customdata); - BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, errno ? strerror(errno) : "Unsupported movie clip format"); + BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s.", str, + errno ? strerror(errno) : "Unsupported movie clip format"); return OPERATOR_CANCELLED; } @@ -188,7 +189,7 @@ static int open_exec(bContext *C, wmOperator *op) ED_space_clip_set(C, screen, sc, clip); } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_ADDED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_ADDED, clip); MEM_freeN(op->customdata); @@ -233,10 +234,11 @@ void CLIP_OT_open(wmOperatorType *ot) ot->cancel = open_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|IMAGEFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH|WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | IMAGEFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, + WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY); } /******************* reload clip operator *********************/ @@ -250,7 +252,7 @@ static int reload_exec(bContext *C, wmOperator *UNUSED(op)) BKE_movieclip_reload(clip); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -500,7 +502,7 @@ static int view_zoom_modal(bContext *C, wmOperator *op, wmEvent *event) switch (event->type) { case MOUSEMOVE: - factor = 1.0f + (vpd->x-event->x + vpd->y - event->y) / 300.0f; + factor = 1.0f + (vpd->x - event->x + vpd->y - event->y) / 300.0f; RNA_float_set(op->ptr, "factor", factor); sclip_zoom_set(sc, ar, vpd->zoom * factor, vpd->location); ED_region_tag_redraw(CTX_wm_region(C)); @@ -529,7 +531,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "View Zoom"; ot->idname = "CLIP_OT_view_zoom"; - ot->description = "Zoom on/out the view"; + ot->description = "Zoom in/out the view"; /* api callbacks */ ot->exec = view_zoom_exec; @@ -539,7 +541,7 @@ void CLIP_OT_view_zoom(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_GRAB_POINTER; + ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER; /* properties */ RNA_def_float(ot->srna, "factor", 0.0f, 0.0f, FLT_MAX, @@ -586,7 +588,8 @@ void CLIP_OT_view_zoom_in(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* properties */ - RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in screen coordinates", -10.0f, 10.0f); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in screen coordinates", -10.0f, 10.0f); } static int view_zoom_out_exec(bContext *C, wmOperator *op) @@ -627,7 +630,8 @@ void CLIP_OT_view_zoom_out(wmOperatorType *ot) ot->poll = ED_space_clip_view_clip_poll; /* properties */ - RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); + RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MAX, FLT_MAX, "Location", + "Cursor location in normalised (0.0-1.0) coordinates", -10.0f, 10.0f); } /********************** view zoom ratio operator *********************/ @@ -781,7 +785,7 @@ static void change_frame_apply(bContext *C, wmOperator *op) /* do updates */ sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } static int change_frame_exec(bContext *C, wmOperator *op) @@ -867,7 +871,7 @@ void CLIP_OT_change_frame(wmOperatorType *ot) ot->poll = change_frame_poll; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -904,16 +908,16 @@ static int proxy_bitflag_to_array(int size_flag, int build_sizes[4], int undisto int size_nr = undistort ? 1 : 0; if (size_flag & size_flags[size_nr][0]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_25; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_25; if (size_flag & size_flags[size_nr][1]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_50; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_50; if (size_flag & size_flags[size_nr][2]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_75; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_75; if (size_flag & size_flags[size_nr][3]) - build_sizes[build_count++]= MCLIP_PROXY_RENDER_SIZE_100; + build_sizes[build_count++] = MCLIP_PROXY_RENDER_SIZE_100; return build_count; } @@ -958,7 +962,8 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog if (clip->source != MCLIP_SRC_MOVIE) BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, NULL, cfra, build_sizes, build_count, 0); - BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, build_undistort_sizes, build_undistort_count, 1); + BKE_movieclip_build_proxy_frame(clip, pj->clip_flag, distortion, cfra, + build_undistort_sizes, build_undistort_count, 1); if (*stop || G.afbreek) break; @@ -986,7 +991,7 @@ static void proxy_endjob(void *pjv) BKE_movieclip_reload(pj->clip); - WM_main_add_notifier(NC_MOVIECLIP|ND_DISPLAY, pj->clip); + WM_main_add_notifier(NC_MOVIECLIP | ND_DISPLAY, pj->clip); } static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) @@ -1015,7 +1020,7 @@ static int clip_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) } WM_jobs_customdata(steve, pj, proxy_freejob); - WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|ND_DISPLAY, 0); + WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | ND_DISPLAY, 0); WM_jobs_callbacks(steve, proxy_startjob, NULL, NULL, proxy_endjob); G.afbreek = 0; @@ -1057,7 +1062,7 @@ static int mode_set_exec(bContext *C, wmOperator *op) sc->mode = mode; } - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_CLIP, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_CLIP, NULL); return OPERATOR_FINISHED; } @@ -1093,14 +1098,15 @@ void ED_operatormacros_clip(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("CLIP_OT_add_marker_move", "Add Marker and Move", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Add new marker and move it on movie"; + ot = WM_operatortype_append_macro("CLIP_OT_add_marker_move", "Add Marker and Move", + "Add new marker and move it on movie", OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CLIP_OT_add_marker"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_struct_idprops_unset(otmacro->ptr, "release_confirm"); - ot = WM_operatortype_append_macro("CLIP_OT_add_marker_slide", "Add Marker and Slide", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Add new marker and slide it with mouse until mouse button release"; + ot = WM_operatortype_append_macro("CLIP_OT_add_marker_slide", "Add Marker and Slide", + "Add new marker and slide it with mouse until mouse button release", + OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "CLIP_OT_add_marker"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(otmacro->ptr, "release_confirm", TRUE); diff --git a/source/blender/editors/space_clip/clip_toolbar.c b/source/blender/editors/space_clip/clip_toolbar.c index da8bf8fedd9..3ffba75f2ef 100644 --- a/source/blender/editors/space_clip/clip_toolbar.c +++ b/source/blender/editors/space_clip/clip_toolbar.c @@ -151,7 +151,7 @@ static ARegion *clip_has_tools_region(ScrArea *sa) BLI_insertlinkafter(&sa->regionbase, artool, arprops); arprops->regiontype = RGN_TYPE_TOOL_PROPS; - arprops->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + arprops->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; } return artool; diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index 2545106d132..4142c30d825 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -190,20 +190,21 @@ void clip_delete_track(bContext *C, MovieClip *clip, ListBase *tracksbase, Movie BKE_tracking_free_track(track); BLI_freelinkN(tracksbase, track); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); if (update_stab) { tracking->stabilization.ok = FALSE; - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } DAG_id_tag_update(&clip->id, 0); if (has_bundle) - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); } -void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, MovieTrackingTrack *track, MovieTrackingMarker *marker) +void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, + MovieTrackingTrack *track, MovieTrackingMarker *marker) { if (track->markersnr == 1) { clip_delete_track(C, clip, tracksbase, track); @@ -211,7 +212,7 @@ void clip_delete_marker(bContext *C, MovieClip *clip, ListBase *tracksbase, Movi else { BKE_tracking_delete_marker(track, marker->framenr); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); } } @@ -253,7 +254,7 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) /* because the frame number text is subject to the same scaling as the contents of the view */ UI_view2d_getscale(v2d, &xscale, &yscale); - glScalef(1.0f/xscale, 1.0f, 1.0f); + glScalef(1.0f / xscale, 1.0f, 1.0f); clip_draw_curfra_label(sc, (float)sc->user.framenr * xscale, 18); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 1c0d2db91a9..a3e17d420b3 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -81,7 +81,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) if (sc->view == SC_VIEW_DOPESHEET) { ar->v2d.tot.xmin = -10.0f; - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; ar->v2d.tot.xmax = (float)(sa->winx); ar->v2d.tot.ymax = 0.0f; @@ -95,7 +95,7 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.minzoom = 0.01f; ar->v2d.maxzoom = 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); ar->v2d.keepzoom = V2D_LOCKZOOM_Y; ar->v2d.keepofs = V2D_KEEPOFS_Y; @@ -116,8 +116,8 @@ static void init_preview_region(const bContext *C, ARegion *ar) ar->v2d.max[0] = MAXFRAMEF; ar->v2d.max[1] = FLT_MAX; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); ar->v2d.minzoom = 0.0f; ar->v2d.maxzoom = 0.0f; @@ -232,7 +232,8 @@ static SpaceLink *clip_new(const bContext *C) sc = MEM_callocN(sizeof(SpaceClip), "initclip"); sc->spacetype = SPACE_CLIP; - sc->flag = SC_SHOW_MARKER_PATTERN|SC_SHOW_TRACK_PATH|SC_MANUAL_CALIBRATION|SC_SHOW_GRAPH_TRACKS|SC_SHOW_GRAPH_FRAMES; + sc->flag = SC_SHOW_MARKER_PATTERN | SC_SHOW_TRACK_PATH | SC_MANUAL_CALIBRATION | + SC_SHOW_GRAPH_TRACKS | SC_SHOW_GRAPH_FRAMES; sc->zoom = 1.0f; sc->path_length = 20; sc->scopes.track_preview_height = 120; @@ -256,7 +257,7 @@ static SpaceLink *clip_new(const bContext *C) BLI_addtail(&sc->regionbase, ar); ar->regiontype = RGN_TYPE_TOOL_PROPS; - ar->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + ar->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; /* properties view */ ar = MEM_callocN(sizeof(ARegion), "properties for clip"); @@ -369,12 +370,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) } break; case NC_SCREEN: - if (wmn->data ==ND_ANIMPLAY) { + if (wmn->data == ND_ANIMPLAY) { ED_area_tag_redraw(sa); } break; case NC_SPACE: - if (wmn->data ==ND_SPACE_CLIP) { + if (wmn->data == ND_SPACE_CLIP) { clip_scopes_tag_refresh(sa); clip_stabilization_tag_refresh(sa); ED_area_tag_redraw(sa); @@ -512,7 +513,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "backwards", FALSE); RNA_boolean_set(kmi->ptr, "sequence", TRUE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_track_markers", TKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0); RNA_boolean_set(kmi->ptr, "backwards", TRUE); RNA_boolean_set(kmi->ptr, "sequence", TRUE); @@ -560,16 +561,16 @@ static void clip_keymap(struct wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "CLIP_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* jump to special frame */ - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 0); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 1); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", LEFTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 2); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_frame_jump", RIGHTARROWKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "position", 3); /* "timeline" */ @@ -645,7 +646,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO); RNA_boolean_set(kmi->ptr, "clear_active", FALSE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", FALSE); @@ -690,7 +691,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_UPTO); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); - kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "CLIP_OT_clear_track_path", TKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0); RNA_enum_set(kmi->ptr, "action", TRACK_CLEAR_ALL); RNA_boolean_set(kmi->ptr, "clear_active", TRUE); @@ -708,7 +709,7 @@ static void clip_keymap(struct wmKeyConfig *keyconf) RNA_boolean_set(kmi->ptr, "extend", TRUE); /* toggle */ } -const char *clip_context_dir[]= {"edit_movieclip", NULL}; +const char *clip_context_dir[] = {"edit_movieclip", NULL}; static int clip_context(const bContext *C, const char *member, bContextDataResult *result) { @@ -879,8 +880,8 @@ static void clip_refresh(const bContext *C, ScrArea *sa) ar_tool_props->v2d.flag &= ~V2D_IS_INITIALISED; view_changed = TRUE; } - if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV))) { - ar_tool_props->alignment = RGN_ALIGN_BOTTOM|RGN_SPLIT_PREV; + if (ar_tool_props && (ar_tool_props->alignment != (RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV))) { + ar_tool_props->alignment = RGN_ALIGN_BOTTOM | RGN_SPLIT_PREV; view_changed = TRUE; } } @@ -984,8 +985,8 @@ static void movieclip_main_area_set_view2d(SpaceClip *sc, ARegion *ar) ar->v2d.mask.ymax = winy; /* which part of the image space do we see? */ - x1 = ar->winrct.xmin + (winx-sc->zoom * w) / 2.0f; - y1 = ar->winrct.ymin + (winy-sc->zoom * h) / 2.0f; + x1 = ar->winrct.xmin + (winx - sc->zoom * w) / 2.0f; + y1 = ar->winrct.ymin + (winy - sc->zoom * h) / 2.0f; x1 -= sc->zoom * sc->xof; y1 -= sc->zoom * sc->yof; @@ -1146,7 +1147,8 @@ static void dopesheet_area_draw(const bContext *C, ARegion *ar) /* time grid */ unit = (sc->flag & SC_SHOW_SECONDS)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, + V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -1298,11 +1300,11 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (wmn->data ==ND_GPENCIL) + if (wmn->data == ND_GPENCIL) ED_region_tag_redraw(ar); break; case NC_BRUSH: - if (wmn->action ==NA_EDITED) + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1336,7 +1338,7 @@ void ED_spacetype_clip(void) art->init = clip_main_area_init; art->draw = clip_main_area_draw; art->listener = clip_main_area_listener; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_GPENCIL; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_GPENCIL; BLI_addhead(&st->regiontypes, art); @@ -1347,7 +1349,7 @@ void ED_spacetype_clip(void) art->init = clip_preview_area_init; art->draw = clip_preview_area_draw; art->listener = clip_preview_area_listener; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; BLI_addhead(&st->regiontypes, art); @@ -1355,7 +1357,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region properties"); art->regionid = RGN_TYPE_UI; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->init = clip_properties_area_init; art->draw = clip_properties_area_draw; art->listener = clip_properties_area_listener; @@ -1366,7 +1368,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region tools"); art->regionid = RGN_TYPE_TOOLS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_props_area_listener; art->init = clip_tools_area_init; art->draw = clip_tools_area_draw; @@ -1378,7 +1380,7 @@ void ED_spacetype_clip(void) art->regionid = RGN_TYPE_TOOL_PROPS; art->prefsizex = 0; art->prefsizey = 120; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_props_area_listener; art->init = clip_tools_area_init; art->draw = clip_tools_area_draw; @@ -1390,7 +1392,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; art->init = clip_header_area_init; art->draw = clip_header_area_draw; @@ -1403,7 +1405,7 @@ void ED_spacetype_clip(void) art = MEM_callocN(sizeof(ARegionType), "spacetype clip channels region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = UI_COMPACT_PANEL_WIDTH; - art->keymapflag = ED_KEYMAP_FRAMES|ED_KEYMAP_UI; + art->keymapflag = ED_KEYMAP_FRAMES | ED_KEYMAP_UI; art->listener = clip_channels_area_listener; art->init = clip_channels_area_init; art->draw = clip_channels_area_draw; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 825415764f1..fc93bcc0409 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -116,7 +116,7 @@ static int add_marker_exec(bContext *C, wmOperator *op) sc->xlockof = 0; sc->ylockof = 0; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -145,7 +145,7 @@ void CLIP_OT_add_marker(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float_vector(ot->srna, "location", 2, NULL, -FLT_MIN, FLT_MAX, @@ -190,7 +190,7 @@ void CLIP_OT_delete_track(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** delete marker operator *********************/ @@ -211,7 +211,7 @@ static int delete_marker_exec(bContext *C, wmOperator *UNUSED(op)) MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, framenr); if (marker) { - has_selection |= track->markersnr>1; + has_selection |= track->markersnr > 1; clip_delete_marker(C, clip, tracksbase, track, marker); } @@ -241,7 +241,7 @@ void CLIP_OT_delete_marker(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** slide marker operator *********************/ @@ -357,8 +357,8 @@ static int mouse_on_corner(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + tdx && co[1] >= crn[1] - tdy && co[1] <= crn[1] + dy; } else { - crn[0] = marker->pos[0]+min[0]; - crn[1] = marker->pos[1]+max[1]; + crn[0] = marker->pos[0] + min[0]; + crn[1] = marker->pos[1] + max[1]; inside = co[0] >= crn[0] - dx && co[0] <= crn[0] + dx && co[1] >= crn[1] - dy && co[1] <= crn[1] + dy; } @@ -374,7 +374,7 @@ static int mouse_on_offset(SpaceClip *sc, MovieTrackingTrack *track, MovieTracki add_v2_v2v2(pos, marker->pos, track->offset); dx = 12.0f / width / sc->zoom; - dy = 12.0f / height /sc->zoom; + dy = 12.0f / height / sc->zoom; dx = MIN2(dx, (track->pat_max[0] - track->pat_min[0]) / 2.0f); dy = MIN2(dy, (track->pat_max[1] - track->pat_min[1]) / 2.0f); @@ -421,21 +421,26 @@ static void *slide_marker_customdata(bContext *C, wmEvent *event) if ((marker->flag & MARKER_DISABLED) == 0) { if (!customdata) if (mouse_on_offset(sc, track, marker, co, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, SLIDE_ACTION_POS, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_POINT, + SLIDE_ACTION_POS, width, height); if (sc->flag & SC_SHOW_MARKER_SEARCH) { if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 1, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_OFFSET, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, + SLIDE_ACTION_OFFSET, width, height); else if (mouse_on_corner(sc, track, marker, TRACK_AREA_SEARCH, co, 0, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_SEARCH, + SLIDE_ACTION_SIZE, width, height); } if (!customdata && (sc->flag & SC_SHOW_MARKER_PATTERN)) { if (mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 1, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_OFFSET, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, + SLIDE_ACTION_OFFSET, width, height); if (!customdata && mouse_on_corner(sc, track, marker, TRACK_AREA_PAT, co, 0, width, height)) - customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, SLIDE_ACTION_SIZE, width, height); + customdata = create_slide_marker_data(sc, track, marker, event, TRACK_AREA_PAT, + SLIDE_ACTION_SIZE, width, height); } if (customdata) @@ -465,7 +470,7 @@ static int slide_marker_invoke(bContext *C, wmOperator *op, wmEvent *event) hide_cursor(C); WM_event_add_modal_handler(C, op); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_RUNNING_MODAL; } @@ -490,7 +495,7 @@ static void cancel_mouse_slide(SlideMarkerData *data) else { int a; - for (a = 0; atrack->markersnr; a++) + for (a = 0; a < data->track->markersnr; a++) copy_v2_v2(data->track->markers[a].pos, data->smarkers[a]); copy_v2_v2(data->offset, data->soff); @@ -527,8 +532,8 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) /* no break! update area size */ case MOUSEMOVE: - mdelta[0] = event->mval[0]-data->mval[0]; - mdelta[1] = event->mval[1]-data->mval[1]; + mdelta[0] = event->mval[0] - data->mval[0]; + mdelta[1] = event->mval[1] - data->mval[1]; dx = mdelta[0] / data->width / sc->zoom; @@ -554,7 +559,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) data->marker->flag &= ~MARKER_TRACKED; } - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); DAG_id_tag_update(&sc->clip->id, 0); } else { @@ -580,7 +585,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) else { int a; - for (a = 0; atrack->markersnr; a++) + for (a = 0; a < data->track->markersnr; a++) add_v2_v2v2(data->track->markers[a].pos, data->smarkers[a], d); sub_v2_v2v2(data->offset, data->soff, d); @@ -591,7 +596,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) } } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); break; @@ -613,7 +618,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, wmEvent *event) show_cursor(C); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_CANCELLED; } @@ -634,7 +639,7 @@ void CLIP_OT_slide_marker(wmOperatorType *ot) ot->modal = slide_marker_modal; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_GRAB_POINTER|OPTYPE_BLOCKING; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_POINTER | OPTYPE_BLOCKING; /* properties */ RNA_def_float_vector(ot->srna, "offset", 2, NULL, -FLT_MAX, FLT_MAX, @@ -657,10 +662,10 @@ static int mouse_on_side(float co[2], float x1, float y1, float x2, float y2, fl static int mouse_on_rect(float co[2], float pos[2], float min[2], float max[2], float epsx, float epsy) { - return mouse_on_side(co, pos[0]+min[0], pos[1]+min[1], pos[0]+max[0], pos[1]+min[1], epsx, epsy) || - mouse_on_side(co, pos[0]+min[0], pos[1]+min[1], pos[0]+min[0], pos[1]+max[1], epsx, epsy) || - mouse_on_side(co, pos[0]+min[0], pos[1]+max[1], pos[0]+max[0], pos[1]+max[1], epsx, epsy) || - mouse_on_side(co, pos[0]+max[0], pos[1]+min[1], pos[0]+max[0], pos[1]+max[1], epsx, epsy); + return mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + max[0], pos[1] + min[1], epsx, epsy) || + mouse_on_side(co, pos[0] + min[0], pos[1] + min[1], pos[0] + min[0], pos[1] + max[1], epsx, epsy) || + mouse_on_side(co, pos[0] + min[0], pos[1] + max[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy) || + mouse_on_side(co, pos[0] + max[0], pos[1] + min[1], pos[0] + max[0], pos[1] + max[1], epsx, epsy); } static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *track) @@ -671,9 +676,9 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac ED_space_clip_size(sc, &width, &height); - epsx = MIN4(track->pat_min[0]-track->search_min[0], track->search_max[0]-track->pat_max[0], + epsx = MIN4(track->pat_min[0] - track->search_min[0], track->search_max[0] - track->pat_max[0], fabsf(track->pat_min[0]), fabsf(track->pat_max[0])) / 2; - epsy = MIN4(track->pat_min[1]-track->search_min[1], track->search_max[1]-track->pat_max[1], + epsy = MIN4(track->pat_min[1] - track->search_min[1], track->search_max[1] - track->pat_max[1], fabsf(track->pat_min[1]), fabsf(track->pat_max[1])) / 2; epsx = MAX2(epsx, 2.0f / width); @@ -684,7 +689,7 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac return TRACK_AREA_SEARCH; } - if ((marker->flag & MARKER_DISABLED)== 0) { + if ((marker->flag & MARKER_DISABLED) == 0) { if (sc->flag & SC_SHOW_MARKER_PATTERN) if (mouse_on_rect(co, marker->pos, track->pat_min, track->pat_max, epsx, epsy)) return TRACK_AREA_PAT; @@ -692,8 +697,11 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac epsx = 12.0f / width; epsy = 12.0f / height; - if (fabsf(co[0]-marker->pos[0]-track->offset[0])< epsx && fabsf(co[1]-marker->pos[1]-track->offset[1])<=epsy) + if (fabsf(co[0] - marker->pos[0] - track->offset[0]) < epsx && + fabsf(co[1] - marker->pos[1] - track->offset[1]) <= epsy) + { return TRACK_AREA_POINT; + } } return TRACK_AREA_NONE; @@ -702,7 +710,7 @@ static int track_mouse_area(SpaceClip *sc, float co[2], MovieTrackingTrack *trac static float dist_to_rect(float co[2], float pos[2], float min[2], float max[2]) { float d1, d2, d3, d4; - float p[2] = {co[0]-pos[0], co[1]-pos[1]}; + float p[2] = {co[0] - pos[0], co[1] - pos[1]}; float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}, v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; @@ -726,8 +734,9 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas if (((cur->flag & TRACK_HIDDEN) == 0) && MARKER_VISIBLE(sc, cur, marker)) { float dist, d1, d2 = FLT_MAX, d3 = FLT_MAX; - d1 = sqrtf((co[0]-marker->pos[0]-cur->offset[0])*(co[0]-marker->pos[0]-cur->offset[0])+ - (co[1]-marker->pos[1]-cur->offset[1])*(co[1]-marker->pos[1]-cur->offset[1])); /* distance to marker point */ + /* distance to marker point */ + d1 = sqrtf((co[0] - marker->pos[0] - cur->offset[0]) * (co[0] - marker->pos[0] - cur->offset[0]) + + (co[1] - marker->pos[1] - cur->offset[1]) * (co[1] - marker->pos[1] - cur->offset[1])); /* distance to pattern boundbox */ if (sc->flag & SC_SHOW_MARKER_PATTERN) @@ -740,7 +749,7 @@ static MovieTrackingTrack *find_nearest_track(SpaceClip *sc, ListBase *tracksbas /* choose minimal distance. useful for cases of overlapped markers. */ dist = MIN3(d1, d2, d3); - if (track == NULL || disttracking.act_track = slidedata->track; - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); MEM_freeN(slidedata); @@ -890,7 +899,7 @@ static int border_select_exec(bContext *C, wmOperator *op) if (MARKER_VISIBLE(sc, track, marker)) { if (BLI_in_rctf(&rectf, marker->pos[0], marker->pos[1])) { - BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); + BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT); } else if (!extend) { BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, 1); @@ -906,7 +915,7 @@ static int border_select_exec(bContext *C, wmOperator *op) if (change) { BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -981,7 +990,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) MovieTrackingMarker *marker = BKE_tracking_get_marker(track, sc->user.framenr); if (MARKER_VISIBLE(sc, track, marker) && marker_inside_ellipse(marker, offset, ellipse)) { - BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode!=GESTURE_MODAL_SELECT); + BKE_tracking_track_flag(track, TRACK_AREA_ALL, SELECT, mode != GESTURE_MODAL_SELECT); change = TRUE; } @@ -993,7 +1002,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) if (change) { BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -1015,7 +1024,7 @@ void CLIP_OT_select_circle(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX); @@ -1057,7 +1066,7 @@ static int select_all_exec(bContext *C, wmOperator *op) track = tracksbase->first; while (track) { - if ((track->flag & TRACK_HIDDEN)==0) { + if ((track->flag & TRACK_HIDDEN) == 0) { marker = BKE_tracking_get_marker(track, framenr); if (MARKER_VISIBLE(sc, track, marker)) { @@ -1092,7 +1101,7 @@ static int select_all_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_GEOM|ND_SELECT, NULL); + WM_event_add_notifier(C, NC_GEOM | ND_SELECT, NULL); return OPERATOR_FINISHED; } @@ -1109,7 +1118,7 @@ void CLIP_OT_select_all(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; WM_operator_properties_select_all(ot); } @@ -1133,7 +1142,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) marker = BKE_tracking_get_marker(track, sc->user.framenr); if (group == 0) { /* Keyframed */ - ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED)==0; + ok = marker->framenr == sc->user.framenr && (marker->flag & MARKER_TRACKED) == 0; } else if (group == 1) { /* Estimated */ ok = marker->framenr != sc->user.framenr; @@ -1174,7 +1183,7 @@ static int select_groped_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); return OPERATOR_FINISHED; } @@ -1202,7 +1211,7 @@ void CLIP_OT_select_grouped(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* proeprties */ RNA_def_enum(ot->srna, "group", select_group_items, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); @@ -1254,10 +1263,10 @@ static void clear_invisible_track_selection(SpaceClip *sc, MovieClip *clip) ListBase *tracksbase = BKE_tracking_get_tracks(&clip->tracking); int hidden = 0; - if ((sc->flag & SC_SHOW_MARKER_PATTERN)==0) + if ((sc->flag & SC_SHOW_MARKER_PATTERN) == 0) hidden |= TRACK_AREA_PAT; - if ((sc->flag & SC_SHOW_MARKER_SEARCH)==0) + if ((sc->flag & SC_SHOW_MARKER_SEARCH) == 0) hidden |= TRACK_AREA_SEARCH; if (hidden) { @@ -1284,7 +1293,7 @@ static void track_init_markers(SpaceClip *sc, MovieClip *clip, int *frames_limit track = tracksbase->first; while (track) { if (TRACK_VIEW_SELECTED(sc, track)) { - if ((track->flag & TRACK_HIDDEN)==0 && (track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { BKE_tracking_ensure_marker(track, framenr); if (track->frames_limit) { @@ -1391,15 +1400,15 @@ static void track_markers_startjob(void *tmv, short *stop, short *do_update, flo if (!BKE_tracking_next(tmj->context)) break; - exec_time = PIL_check_seconds_timer()-start_time; + exec_time = PIL_check_seconds_timer() - start_time; if (tmj->delay > (float)exec_time) - PIL_sleep_ms(tmj->delay-(float)exec_time); + PIL_sleep_ms(tmj->delay - (float)exec_time); } else if (!BKE_tracking_next(tmj->context)) break; *do_update = TRUE; - *progress = (float)(framenr-tmj->sfra) / (tmj->efra-tmj->sfra); + *progress = (float)(framenr - tmj->sfra) / (tmj->efra - tmj->sfra); if (tmj->backwards) framenr--; @@ -1435,7 +1444,7 @@ static void track_markers_freejob(void *tmv) MEM_freeN(tmj); - WM_main_add_notifier(NC_SCENE|ND_FRAME, tmj->scene); + WM_main_add_notifier(NC_SCENE | ND_FRAME, tmj->scene); } static int track_markers_exec(bContext *C, wmOperator *op) @@ -1450,7 +1459,7 @@ static int track_markers_exec(bContext *C, wmOperator *op) int sequence = RNA_boolean_get(op->ptr, "sequence"); int frames_limit; - if (track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip) == 0) return OPERATOR_CANCELLED; track_init_markers(sc, clip, &frames_limit); @@ -1462,8 +1471,10 @@ static int track_markers_exec(bContext *C, wmOperator *op) /* limit frames to be tracked by user setting */ if (frames_limit) { - if (backwards) efra = MAX2(efra, sfra-frames_limit); - else efra = MIN2(efra, sfra+frames_limit); + if (backwards) + efra = MAX2(efra, sfra - frames_limit); + else + efra = MIN2(efra, sfra + frames_limit); } if (!track_markers_check_direction(backwards, framenr, efra)) @@ -1489,8 +1500,8 @@ static int track_markers_exec(bContext *C, wmOperator *op) /* update scene current frame to the lastes tracked frame */ scene->r.cfra = framenr; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } @@ -1513,7 +1524,7 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve if (clip->tracking_context) return OPERATOR_CANCELLED; - if (track_count_markers(sc, clip)==0) + if (track_count_markers(sc, clip) == 0) return OPERATOR_CANCELLED; if (!sequence) @@ -1534,8 +1545,10 @@ static int track_markers_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(eve * with fixed FPS. To deal with editor refresh we have to synchronize * tracks from job and tracks in clip. Do this in timer callback * to prevent threading conflicts. */ - if (tmj->delay>0) WM_jobs_timer(steve, tmj->delay/1000.0f, NC_MOVIECLIP|NA_EVALUATED, 0); - else WM_jobs_timer(steve, 0.2, NC_MOVIECLIP|NA_EVALUATED, 0); + if (tmj->delay > 0) + WM_jobs_timer(steve, tmj->delay / 1000.0f, NC_MOVIECLIP | NA_EVALUATED, 0); + else + WM_jobs_timer(steve, 0.2, NC_MOVIECLIP | NA_EVALUATED, 0); WM_jobs_callbacks(steve, track_markers_startjob, NULL, track_markers_updatejob, NULL); @@ -1554,7 +1567,7 @@ static int track_markers_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *eve { /* no running tracking, remove handler and pass through */ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ switch (event->type) { @@ -1691,8 +1704,8 @@ static void solve_camera_freejob(void *scv) DAG_id_tag_update(&clip->id, 0); - WM_main_add_notifier(NC_MOVIECLIP|NA_EVALUATED, clip); - WM_main_add_notifier(NC_OBJECT|ND_TRANSFORM, NULL); + WM_main_add_notifier(NC_MOVIECLIP | NA_EVALUATED, clip); + WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, NULL); /* update active clip displayed in scene buttons */ WM_main_add_notifier(NC_SCENE, scene); @@ -1753,12 +1766,12 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even /* hide reconstruction statistics from previous solve */ reconstruction->flag &= ~TRACKING_RECONSTRUCTED; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); /* setup job */ steve = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), sa, "Solve Camera", WM_JOB_PROGRESS); WM_jobs_customdata(steve, scj, solve_camera_freejob); - WM_jobs_timer(steve, 0.1, NC_MOVIECLIP|NA_EVALUATED, 0); + WM_jobs_timer(steve, 0.1, NC_MOVIECLIP | NA_EVALUATED, 0); WM_jobs_callbacks(steve, solve_camera_startjob, NULL, solve_camera_updatejob, NULL); G.afbreek = 0; @@ -1776,7 +1789,7 @@ static int solve_camera_modal(bContext *C, wmOperator *UNUSED(op), wmEvent *even { /* no running solver, remove handler and pass through */ if (0 == WM_jobs_test(CTX_wm_manager(C), CTX_wm_area(C))) - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; /* running tracking */ switch (event->type) { @@ -1802,7 +1815,7 @@ void CLIP_OT_solve_camera(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clear solution operator *********************/ @@ -1832,8 +1845,8 @@ static int clear_solution_exec(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); return OPERATOR_FINISHED; } @@ -1850,7 +1863,7 @@ void CLIP_OT_clear_solution(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clear track operator *********************/ @@ -1878,7 +1891,7 @@ static int clear_track_path_exec(bContext *C, wmOperator *op) } } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -1902,7 +1915,7 @@ void CLIP_OT_clear_track_path(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* proeprties */ RNA_def_enum(ot->srna, "action", clear_path_actions, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute"); @@ -1921,7 +1934,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED)==0) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_LOCKED) == 0) { MovieTrackingMarker *marker = BKE_tracking_ensure_marker(track, sc->user.framenr); if (action == 0) @@ -1936,7 +1949,7 @@ static int disable_markers_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -1960,7 +1973,7 @@ void CLIP_OT_disable_markers(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Disable action to execute"); @@ -1973,13 +1986,13 @@ static Object *get_camera_with_movieclip(Scene *scene, MovieClip *clip) Object *camera = scene->camera; Base *base; - if (camera && object_get_movieclip(scene, camera, 0)==clip) + if (camera && BKE_object_movieclip_get(scene, camera, 0) == clip) return camera; base = scene->base.first; while (base) { if (base->object->type == OB_CAMERA) { - if (object_get_movieclip(scene, base->object, 0)==clip) { + if (BKE_object_movieclip_get(scene, base->object, 0) == clip) { camera = base->object; break; } @@ -2069,7 +2082,7 @@ static void object_solver_inverted_matrix(Scene *scene, Object *ob, float invmat if (!found) { Object *cam = data->camera ? data->camera : scene->camera; - where_is_object_mat(scene, cam, invmat); + BKE_object_where_is_calc_mat4(scene, cam, invmat); } mult_m4_m4m4(invmat, invmat, data->invmat); @@ -2144,7 +2157,7 @@ static int set_origin_exec(bContext *C, wmOperator *op) track = track->next; } - mul_v3_fl(median, 1.0f/selected_count); + mul_v3_fl(median, 1.0f / selected_count); BKE_get_tracking_mat(scene, camera, mat); @@ -2162,8 +2175,8 @@ static int set_origin_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2180,7 +2193,7 @@ void CLIP_OT_set_origin(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "use_median", 0, "Use Median", "Set origin to median point of selected bundles"); @@ -2196,7 +2209,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb int flip = FALSE; float mat[4][4], vec[3], obmat[4][4], dvec[3]; - object_to_mat4(ob, obmat); + BKE_object_to_mat4(ob, obmat); BKE_get_tracking_mat(scene, camera, mat); mul_v3_m4v3(vec, mat, track->bundle_pos); @@ -2254,7 +2267,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb else { copy_v3_v3(mat[1], vec); - if (is_camera || fabsf(vec[2])<1e-3f) { + if (is_camera || fabsf(vec[2]) < 1e-3f) { mat[1][2] = 0.0f; mat[2][0] = 0.0f; mat[2][1] = 0.0f; mat[2][2] = 1.0f; cross_v3_v3v3(mat[0], mat[1], mat[2]); @@ -2281,7 +2294,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb if (!flip) { float lmat[4][4], ilmat[4][4], rmat[3][3]; - object_rot_to_mat3(ob, rmat); + BKE_object_rot_to_mat3(ob, rmat); invert_m3(rmat); mul_m4_m4m3(mat, mat, rmat); @@ -2296,7 +2309,7 @@ static void set_axis(Scene *scene, Object *ob, MovieClip *clip, MovieTrackingOb } } - object_apply_mat4(ob, mat, 0, 0); + BKE_object_apply_mat4(ob, mat, 0, 0); } static int set_plane_exec(bContext *C, wmOperator *op) @@ -2318,7 +2331,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) {1.0f, 0.0f, 0.0f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}; /* 90 degrees Y-axis rotation matrix */ - if (count_selected_bundles(C)!=3) { + if (count_selected_bundles(C) != 3) { BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor"); return OPERATOR_CANCELLED; @@ -2339,7 +2352,7 @@ static int set_plane_exec(bContext *C, wmOperator *op) /* get 3 bundles to use as reference */ track = tracksbase->first; - while (track && tot<3) { + while (track && tot < 3) { if (track->flag & TRACK_HAS_BUNDLE && TRACK_VIEW_SELECTED(sc, track)) { mul_v3_m4v3(vec[tot], mat, track->bundle_pos); @@ -2383,30 +2396,30 @@ static int set_plane_exec(bContext *C, wmOperator *op) if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { invert_m4(mat); - object_to_mat4(object, obmat); + BKE_object_to_mat4(object, obmat); mult_m4_m4m4(mat, mat, obmat); mult_m4_m4m4(newmat, rot, mat); - object_apply_mat4(object, newmat, 0, 0); + BKE_object_apply_mat4(object, newmat, 0, 0); /* make camera have positive z-coordinate */ - if (object->loc[2]<0) { + if (object->loc[2] < 0) { invert_m4(rot); mult_m4_m4m4(newmat, rot, mat); - object_apply_mat4(object, newmat, 0, 0); + BKE_object_apply_mat4(object, newmat, 0, 0); } } else { - object_apply_mat4(object, mat, 0, 0); + BKE_object_apply_mat4(object, mat, 0, 0); } - where_is_object(scene, object); + BKE_object_where_is_calc(scene, object); set_axis(scene, object, clip, tracking_object, axis_track, 'X'); DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2429,7 +2442,7 @@ void CLIP_OT_set_plane(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "plane", plane_items, 0, "Plane", "Plane to be used for orientation"); @@ -2449,7 +2462,7 @@ static int set_axis_exec(bContext *C, wmOperator *op) ListBase *tracksbase; int axis = RNA_enum_get(op->ptr, "axis"); - if (count_selected_bundles(C)!=1) { + if (count_selected_bundles(C) != 1) { BKE_report(op->reports, RPT_ERROR, "Single track with bundle should be selected to define axis"); return OPERATOR_CANCELLED; @@ -2477,8 +2490,8 @@ static int set_axis_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&clip->id, 0); DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; } @@ -2501,7 +2514,7 @@ void CLIP_OT_set_axis(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "axis", axis_actions, 0, "Axis", "Axis to use to align bundle along"); @@ -2551,7 +2564,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) sub_v3_v3(vec[0], vec[1]); - if (len_v3(vec[0])>1e-5f) { + if (len_v3(vec[0]) > 1e-5f) { scale = dist / len_v3(vec[0]); if (tracking_object->flag & TRACKING_OBJECT_CAMERA) { @@ -2561,7 +2574,7 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) else if (!scale_solution) { Object *solver_camera = object_solver_camera(scene, object); - object->size[0] = object->size[1] = object->size[2] = 1.0f/scale; + object->size[0] = object->size[1] = object->size[2] = 1.0f / scale; if (solver_camera) { object->size[0] /= solver_camera->size[0]; @@ -2578,8 +2591,8 @@ static int do_set_scale(bContext *C, wmOperator *op, int scale_solution) if (object) DAG_id_tag_update(&object->id, OB_RECALC_OB); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); } return OPERATOR_FINISHED; @@ -2614,7 +2627,7 @@ void CLIP_OT_set_scale(wmOperatorType *ot) ot->poll = set_orientation_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX, @@ -2666,7 +2679,7 @@ void CLIP_OT_set_solution_scale(wmOperatorType *ot) ot->poll = set_solution_scale_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "distance", 0.0f, -FLT_MAX, FLT_MAX, @@ -2686,10 +2699,10 @@ static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op)) if (width == 0 || height == 0) return OPERATOR_CANCELLED; - clip->tracking.camera.principal[0] = ((float)width)/2.0f; - clip->tracking.camera.principal[1] = ((float)height)/2.0f; + clip->tracking.camera.principal[0] = ((float)width) / 2.0f; + clip->tracking.camera.principal[1] = ((float)height) / 2.0f; - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -2706,7 +2719,7 @@ void CLIP_OT_set_center_principal(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** hide tracks operator *********************/ @@ -2745,7 +2758,7 @@ static int hide_tracks_exec(bContext *C, wmOperator *op) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2762,7 +2775,7 @@ void CLIP_OT_hide_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected tracks"); @@ -2787,7 +2800,7 @@ static int hide_tracks_clear_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_dopesheet_tag_update(tracking); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2804,7 +2817,7 @@ void CLIP_OT_hide_tracks_clear(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** detect features operator *********************/ @@ -2862,7 +2875,7 @@ static int detect_features_exec(bContext *C, wmOperator *op) IMB_freeImBuf(ibuf); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2886,7 +2899,7 @@ void CLIP_OT_detect_features(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_frame_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "placement", placement_items, 0, "Placement", "Placement for detected features"); @@ -2914,8 +2927,8 @@ static int frame_jump_exec(bContext *C, wmOperator *op) delta = pos == 1 ? 1 : -1; - while (sc->user.framenr+delta >= SFRA && sc->user.framenr+delta <= EFRA) { - MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr+delta); + while (sc->user.framenr + delta >= SFRA && sc->user.framenr + delta <= EFRA) { + MovieTrackingMarker *marker = BKE_tracking_exact_marker(track, sc->user.framenr + delta); if (!marker || marker->flag & MARKER_DISABLED) break; @@ -2933,7 +2946,7 @@ static int frame_jump_exec(bContext *C, wmOperator *op) a += delta; - while (a+delta >= SFRA && a+delta <= EFRA) { + while (a + delta >= SFRA && a + delta <= EFRA) { MovieReconstructedCamera *cam; cam = BKE_tracking_get_reconstructed_camera(tracking, object, a); @@ -2953,10 +2966,10 @@ static int frame_jump_exec(bContext *C, wmOperator *op) CFRA = sc->user.framenr; sound_seek_scene(CTX_data_main(C), CTX_data_scene(C)); - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, NULL); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, NULL); return OPERATOR_FINISHED; } @@ -2981,7 +2994,7 @@ void CLIP_OT_frame_jump(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "position", position_items, 0, "Position", "Position to jump to"); @@ -3021,7 +3034,7 @@ static int join_tracks_exec(bContext *C, wmOperator *op) track = next; } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3038,7 +3051,7 @@ void CLIP_OT_join_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_size_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** lock tracks operator *********************/ @@ -3064,7 +3077,7 @@ static int lock_tracks_exec(bContext *C, wmOperator *op) track = track->next; } - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EVALUATED, clip); return OPERATOR_FINISHED; } @@ -3088,7 +3101,7 @@ void CLIP_OT_lock_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_enum(ot->srna, "action", actions_items, 0, "Action", "Lock action to execute"); @@ -3121,7 +3134,7 @@ static int track_copy_color_exec(bContext *C, wmOperator *UNUSED(op)) track = track->next; } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); return OPERATOR_FINISHED; } @@ -3138,7 +3151,7 @@ void CLIP_OT_track_copy_color(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** add 2d stabilization tracks operator *********************/ @@ -3155,7 +3168,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) track = tracksbase->first; while (track) { - if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB)==0) { + if (TRACK_VIEW_SELECTED(sc, track) && (track->flag & TRACK_USE_2D_STAB) == 0) { track->flag |= TRACK_USE_2D_STAB; stab->tot_track++; @@ -3169,7 +3182,7 @@ static int stabilize_2d_add_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3187,7 +3200,7 @@ void CLIP_OT_stabilize_2d_add(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** remove 2d stabilization tracks operator *********************/ @@ -3211,7 +3224,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) stab->act_track--; stab->tot_track--; - if (stab->act_track<0) + if (stab->act_track < 0) stab->act_track = 0; update = 1; @@ -3229,7 +3242,7 @@ static int stabilize_2d_remove_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3247,7 +3260,7 @@ void CLIP_OT_stabilize_2d_remove(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** select 2d stabilization tracks operator *********************/ @@ -3273,7 +3286,7 @@ static int stabilize_2d_select_exec(bContext *C, wmOperator *UNUSED(op)) } if (update) - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); return OPERATOR_FINISHED; } @@ -3290,7 +3303,7 @@ void CLIP_OT_stabilize_2d_select(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** set 2d stabilization rotation track operator *********************/ @@ -3309,7 +3322,7 @@ static int stabilize_2d_set_rotation_exec(bContext *C, wmOperator *UNUSED(op)) stab->ok = 0; DAG_id_tag_update(&clip->id, 0); - WM_event_add_notifier(C, NC_MOVIECLIP|ND_DISPLAY, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); } return OPERATOR_FINISHED; @@ -3327,7 +3340,7 @@ void CLIP_OT_stabilize_2d_set_rotation(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** clean tracks operator *********************/ @@ -3342,30 +3355,30 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) if (del) new_markers = MEM_callocN(markersnr*sizeof(MovieTrackingMarker), "track cleaned markers"); - for (a = 0; a= 0) { - end = a == markersnr-1; - end |= (a < markersnr-1) && (markers[a].framenr != markers[a+1].framenr-1 || - markers[a].flag & MARKER_DISABLED); + end = a == markersnr - 1; + end |= (a < markersnr - 1) && (markers[a].framenr != markers[a + 1].framenr - 1 || + markers[a].flag & MARKER_DISABLED); } if (end) { int segok = 1, len = 0; - if (a != prev && markers[a].framenr != markers[a-1].framenr+1) - len = a-prev; + if (a != prev && markers[a].framenr != markers[a - 1].framenr + 1) + len = a - prev; else if (markers[a].flag & MARKER_DISABLED) - len = a-prev; - else len = a-prev+1; + len = a - prev; + else len = a - prev + 1; if (frames) { if (len < frames) { @@ -3386,7 +3399,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) /* place disabled marker in front of current segment */ if (start_disabled) { - memcpy(new_markers+count, markers+prev, sizeof(MovieTrackingMarker)); + memcpy(new_markers + count, markers + prev, sizeof(MovieTrackingMarker)); new_markers[count].framenr--; new_markers[count].flag |= MARKER_DISABLED; @@ -3394,7 +3407,7 @@ static int is_track_clean(MovieTrackingTrack *track, int frames, int del) start_disabled = 0; } - memcpy(new_markers+count, markers+prev, t*sizeof(MovieTrackingMarker)); + memcpy(new_markers + count, markers + prev, t * sizeof(MovieTrackingMarker)); count += t; } else if (markers[a].flag & MARKER_DISABLED) { @@ -3443,11 +3456,11 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) while (track) { next = track->next; - if ((track->flag & TRACK_HIDDEN)==0 && (track->flag & TRACK_LOCKED)==0) { + if ((track->flag & TRACK_HIDDEN) == 0 && (track->flag & TRACK_LOCKED) == 0) { int ok = 1; ok = (is_track_clean(track, frames, action == TRACKING_CLEAN_DELETE_SEGMENT)) && - (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE)==0 || track->error < error); + (error == 0.0f || (track->flag & TRACK_HAS_BUNDLE) == 0 || track->error < error); if (!ok) { if (action == TRACKING_CLEAN_SELECT) { @@ -3476,7 +3489,7 @@ static int clean_tracks_exec(bContext *C, wmOperator *op) track = next; } - WM_event_add_notifier(C, NC_MOVIECLIP|ND_SELECT, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | ND_SELECT, clip); return OPERATOR_FINISHED; } @@ -3518,7 +3531,7 @@ void CLIP_OT_clean_tracks(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_int(ot->srna, "frames", 0, 0, INT_MAX, "Tracked Frames", @@ -3538,7 +3551,7 @@ static int tracking_object_new_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_new_object(tracking, "Object"); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3555,7 +3568,7 @@ void CLIP_OT_tracking_object_new(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** remove tracking object *********************/ @@ -3576,7 +3589,7 @@ static int tracking_object_remove_exec(bContext *C, wmOperator *op) BKE_tracking_remove_object(tracking, object); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3593,7 +3606,7 @@ void CLIP_OT_tracking_object_remove(wmOperatorType *ot) ot->poll = ED_space_clip_tracking_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /********************** copy tracks to clipboard operator *********************/ @@ -3647,7 +3660,7 @@ static int paste_tracks_exec(bContext *C, wmOperator *UNUSED(op)) BKE_tracking_clipboard_paste_tracks(tracking, object); - WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip); + WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); return OPERATOR_FINISHED; } @@ -3664,5 +3677,5 @@ void CLIP_OT_paste_tracks(wmOperatorType *ot) ot->poll = paste_tracks_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } diff --git a/source/blender/editors/space_console/console_intern.h b/source/blender/editors/space_console/console_intern.h index 33588cc0923..c0abd094e62 100644 --- a/source/blender/editors/space_console/console_intern.h +++ b/source/blender/editors/space_console/console_intern.h @@ -58,6 +58,7 @@ void CONSOLE_OT_history_append(struct wmOperatorType *ot); void CONSOLE_OT_scrollback_append(struct wmOperatorType *ot); void CONSOLE_OT_clear(struct wmOperatorType *ot); +void CONSOLE_OT_clear_line(struct wmOperatorType *ot); void CONSOLE_OT_history_cycle(struct wmOperatorType *ot); void CONSOLE_OT_copy(struct wmOperatorType *ot); void CONSOLE_OT_paste(struct wmOperatorType *ot); diff --git a/source/blender/editors/space_console/console_ops.c b/source/blender/editors/space_console/console_ops.c index ef036b071be..5d63a223c08 100644 --- a/source/blender/editors/space_console/console_ops.c +++ b/source/blender/editors/space_console/console_ops.c @@ -519,6 +519,39 @@ void CONSOLE_OT_delete(wmOperatorType *ot) RNA_def_enum(ot->srna, "type", console_delete_type_items, DEL_NEXT_CHAR, "Type", "Which part of the text to delete"); } +static int console_clear_line_exec(bContext *C, wmOperator *UNUSED(op)) +{ + SpaceConsole *sc = CTX_wm_space_console(C); + ARegion *ar = CTX_wm_region(C); + ConsoleLine *ci = console_history_verify(C); + + if (ci->len == 0) { + return OPERATOR_CANCELLED; + } + + console_history_add(C, ci); + console_history_add(C, NULL); + + console_textview_update_rect(sc, ar); + + ED_area_tag_redraw(CTX_wm_area(C)); + + console_scroll_bottom(ar); + + return OPERATOR_FINISHED; +} + +void CONSOLE_OT_clear_line(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Clear Line"; + ot->description = "Clear the line and store in history"; + ot->idname = "CONSOLE_OT_clear_line"; + + /* api callbacks */ + ot->exec = console_clear_line_exec; + ot->poll = ED_operator_console_active; +} /* the python exec operator uses this */ static int console_clear_exec(bContext *C, wmOperator *op) @@ -571,7 +604,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) SpaceConsole *sc = CTX_wm_space_console(C); ARegion *ar = CTX_wm_region(C); - ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevernts crashes when no command line */ + ConsoleLine *ci = console_history_verify(C); /* TODO - stupid, just prevents crashes when no command line */ short reverse = RNA_boolean_get(op->ptr, "reverse"); /* assumes down, reverse is up */ int prev_len = ci->len; @@ -584,7 +617,7 @@ static int console_history_cycle_exec(bContext *C, wmOperator *op) console_history_free(sc, ci_prev); } - if (reverse) { /* last item in mistory */ + if (reverse) { /* last item in history */ ci = sc->history.last; BLI_remlink(&sc->history, ci); BLI_addhead(&sc->history, ci); diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 39757aa393a..a25606db2b3 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -250,8 +250,9 @@ static void console_operatortypes(void) /* for use by python only */ WM_operatortype_append(CONSOLE_OT_history_append); WM_operatortype_append(CONSOLE_OT_scrollback_append); - - WM_operatortype_append(CONSOLE_OT_clear); + + WM_operatortype_append(CONSOLE_OT_clear); + WM_operatortype_append(CONSOLE_OT_clear_line); WM_operatortype_append(CONSOLE_OT_history_cycle); WM_operatortype_append(CONSOLE_OT_copy); WM_operatortype_append(CONSOLE_OT_paste); @@ -312,6 +313,8 @@ static void console_keymap(struct wmKeyConfig *keyconf) RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", DELKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_NEXT_WORD); RNA_enum_set(WM_keymap_add_item(keymap, "CONSOLE_OT_delete", BACKSPACEKEY, KM_PRESS, KM_CTRL, 0)->ptr, "type", DEL_PREV_WORD); + WM_keymap_add_item(keymap, "CONSOLE_OT_clear_line", RETKEY, KM_PRESS, KM_SHIFT, 0); + #ifdef WITH_PYTHON WM_keymap_add_item(keymap, "CONSOLE_OT_execute", RETKEY, KM_PRESS, 0, 0); /* python operator - space_text.py */ WM_keymap_add_item(keymap, "CONSOLE_OT_execute", PADENTER, KM_PRESS, 0, 0); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0c94bff8803..28ac674f079 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -391,8 +391,8 @@ void fsmenu_read_system(struct FSMenu* fsmenu) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction - | kLSSharedFileListDoNotMountVolumes, + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, &cfURL, NULL); if (err != noErr) continue; @@ -440,8 +440,8 @@ void fsmenu_read_system(struct FSMenu* fsmenu) itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i); err = LSSharedFileListItemResolve(itemRef, - kLSSharedFileListNoUserInteraction - | kLSSharedFileListDoNotMountVolumes, + kLSSharedFileListNoUserInteraction | + kLSSharedFileListDoNotMountVolumes, &cfURL, NULL); if (err != noErr) continue; diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 8bc2eda7e33..ddcd46ba817 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -67,12 +67,12 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" // own include /* XXX */ /* temporary definition for limits of float number buttons (FLT_MAX tends to infinity with old system) */ -#define UI_FLT_MAX 10000.0f +#define UI_FLT_MAX 10000.0f /* ******************* graph editor space & buttons ************** */ @@ -98,7 +98,7 @@ static void do_graph_region_buttons(bContext *UNUSED(C), void *UNUSED(arg), int static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve **fcu) { bAnimContext ac; - bAnimListElem *elem= NULL; + bAnimListElem *elem = NULL; /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) * to work correctly is able to be correctly retrieved. There's no point showing empty panels? @@ -107,14 +107,14 @@ static int graph_panel_context(const bContext *C, bAnimListElem **ale, FCurve ** return 0; /* try to find 'active' F-Curve */ - elem= get_active_fcurve_channel(&ac); + elem = get_active_fcurve_channel(&ac); if (elem == NULL) return 0; if (fcu) - *fcu= (FCurve*)elem->data; + *fcu = (FCurve *)elem->data; if (ale) - *ale= elem; + *ale = elem; else MEM_freeN(elem); @@ -131,9 +131,9 @@ static int graph_panel_poll(const bContext *C, PanelType *UNUSED(pt)) /* Graph Editor View Settings */ static void graph_panel_view(const bContext *C, Panel *pa) { - bScreen *sc= CTX_wm_screen(C); - SpaceIpo *sipo= CTX_wm_space_graph(C); - Scene *scene= CTX_data_scene(C); + bScreen *sc = CTX_wm_screen(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); + Scene *scene = CTX_data_scene(C); PointerRNA spaceptr, sceneptr; uiLayout *col, *sub, *row; @@ -142,21 +142,21 @@ static void graph_panel_view(const bContext *C, Panel *pa) RNA_pointer_create(&sc->id, &RNA_SpaceGraphEditor, sipo, &spaceptr); /* 2D-Cursor */ - col= uiLayoutColumn(pa->layout, 0); - uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); + col = uiLayoutColumn(pa->layout, 0); + uiItemR(col, &spaceptr, "show_cursor", 0, NULL, ICON_NONE); - sub= uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); - - sub= uiLayoutColumn(col, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); - row= uiLayoutSplit(sub, 0.7, 1); - uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); - uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); - row= uiLayoutSplit(sub, 0.7, 1); - uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); - uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); + uiItemO(sub, IFACE_("Cursor from Selection"), ICON_NONE, "GRAPH_OT_frame_jump"); + + sub = uiLayoutColumn(col, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&spaceptr, "show_cursor")); + row = uiLayoutSplit(sub, 0.7, 1); + uiItemR(row, &sceneptr, "frame_current", 0, IFACE_("Cursor X"), ICON_NONE); + uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_CFRA); + row = uiLayoutSplit(sub, 0.7, 1); + uiItemR(row, &spaceptr, "cursor_position_y", 0, IFACE_("Cursor Y"), ICON_NONE); + uiItemEnumO(row, "GRAPH_OT_snap", IFACE_("To Keys"), 0, "type", GRAPHKEYS_SNAP_VALUE); } /* ******************* active F-Curve ************** */ @@ -175,7 +175,7 @@ static void graph_panel_properties(const bContext *C, Panel *pa) if (!graph_panel_context(C, &ale, &fcu)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_graph_region_buttons, NULL); /* F-Curve pointer */ @@ -183,26 +183,26 @@ static void graph_panel_properties(const bContext *C, Panel *pa) /* user-friendly 'name' for F-Curve */ /* TODO: only show the path if this is invalid? */ - col= uiLayoutColumn(layout, 0); - icon= getname_anim_fcurve(name, ale->id, fcu); - uiItemL(col, name, icon); + col = uiLayoutColumn(layout, 0); + icon = getname_anim_fcurve(name, ale->id, fcu); + uiItemL(col, name, icon); /* RNA-Path Editing - only really should be enabled when things aren't working */ - col= uiLayoutColumn(layout, 1); - uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED)!=0); - uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); - uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiLayoutSetEnabled(col, (fcu->flag & FCURVE_DISABLED) != 0); + uiItemR(col, &fcu_ptr, "data_path", 0, "", ICON_RNA); + uiItemR(col, &fcu_ptr, "array_index", 0, NULL, ICON_NONE); /* color settings */ - col= uiLayoutColumn(layout, 1); - uiItemL(col, IFACE_("Display Color:"), ICON_NONE); + col = uiLayoutColumn(layout, 1); + uiItemL(col, IFACE_("Display Color:"), ICON_NONE); - row= uiLayoutRow(col, 1); - uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); + row = uiLayoutRow(col, 1); + uiItemR(row, &fcu_ptr, "color_mode", 0, "", ICON_NONE); - sub= uiLayoutRow(row, 1); - uiLayoutSetEnabled(sub, (fcu->color_mode==FCURVE_COLOR_CUSTOM)); - uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); + sub = uiLayoutRow(row, 1); + uiLayoutSetEnabled(sub, (fcu->color_mode == FCURVE_COLOR_CUSTOM)); + uiItemR(sub, &fcu_ptr, "color", 0, "", ICON_NONE); MEM_freeN(ale); } @@ -226,13 +226,13 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT * - this is a reasonable assumption, given that whenever anyone * wants to edit numerically, there is likely to only be 1 vert selected */ - for (i=0, b=fcu->bezt; i < fcu->totvert; i++, b++) { + for (i = 0, b = fcu->bezt; i < fcu->totvert; i++, b++) { if (BEZSELECTED(b)) { /* found * - 'previous' is either the one before, of the keyframe itself (which is still fine) * XXX: we can just make this null instead if needed */ - *prevbezt = (i > 0) ? b-1 : b; + *prevbezt = (i > 0) ? b - 1 : b; *bezt = b; return 1; @@ -246,7 +246,7 @@ static short get_active_fcurve_keyframe_edit(FCurve *fcu, BezTriple **bezt, BezT /* update callback for active keyframe properties - base updates stuff */ static void graphedit_activekey_update_cb(bContext *C, void *fcu_ptr, void *UNUSED(bezt_ptr)) { - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); const short use_handle = !(sipo->flag & SIPO_NOHANDLES); FCurve *fcu = (FCurve *)fcu_ptr; @@ -265,8 +265,8 @@ static void graphedit_activekey_handles_cb(bContext *C, void *fcu_ptr, void *bez */ if (ELEM(bezt->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM(bezt->h2, HD_AUTO, HD_AUTO_ANIM)) { /* by changing to aligned handles, these can now be moved... */ - bezt->h1= HD_ALIGN; - bezt->h2= HD_ALIGN; + bezt->h1 = HD_ALIGN; + bezt->h2 = HD_ALIGN; } /* now call standard updates */ @@ -307,56 +307,56 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) } /* interpolation */ - col= uiLayoutColumn(layout, 0); - uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); + col = uiLayoutColumn(layout, 0); + uiItemR(col, &bezt_ptr, "interpolation", 0, NULL, ICON_NONE); /* numerical coordinate editing - * - we use the button-versions of the calls so that we can attach special update handlers - * and unit conversion magic that cannot be achieved using a purely RNA-approach + * - we use the button-versions of the calls so that we can attach special update handlers + * and unit conversion magic that cannot be achieved using a purely RNA-approach */ // XXX: - col= uiLayoutColumn(layout, 1); - /* keyframe itself */ - { - uiItemL(col, IFACE_("Key:"), ICON_NONE); - - but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); - - but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); - uiButSetUnitType(but, unit); - } - - /* previous handle - only if previous was Bezier interpolation */ - if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { - uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); - - but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - - but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - uiButSetUnitType(but, unit); - } - - /* next handle - only if current is Bezier interpolation */ - if (bezt->ipo == BEZT_IPO_BEZ) { - uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); - - but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - - but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, - &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); - uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); - uiButSetUnitType(but, unit); - } + col = uiLayoutColumn(layout, 1); + /* keyframe itself */ + { + uiItemL(col, IFACE_("Key:"), ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, IFACE_("Frame"), 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "co", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, IFACE_("Value"), 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "co", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_update_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } + + /* previous handle - only if previous was Bezier interpolation */ + if ((prevbezt) && (prevbezt->ipo == BEZT_IPO_BEZ)) { + uiItemL(col, IFACE_("Left Handle:"), ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_left", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_left", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } + + /* next handle - only if current is Bezier interpolation */ + if (bezt->ipo == BEZT_IPO_BEZ) { + uiItemL(col, IFACE_("Right Handle:"), ICON_NONE); + + but = uiDefButR(block, NUM, B_REDR, "X", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_right", 0, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + + but = uiDefButR(block, NUM, B_REDR, "Y", 0, 0, UI_UNIT_X, UI_UNIT_Y, + &bezt_ptr, "handle_right", 1, 0, 0, -1, -1, NULL); + uiButSetFunc(but, graphedit_activekey_handles_cb, fcu, bezt); + uiButSetUnitType(but, unit); + } } else { if ((fcu->bezt == NULL) && (fcu->modifiers.first)) { @@ -378,12 +378,12 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa) /* ******************* drivers ******************************** */ -#define B_IPO_DEPCHANGE 10 +#define B_IPO_DEPCHANGE 10 static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int event) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); switch (event) { case B_IPO_DEPCHANGE: @@ -394,19 +394,19 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e /* force an update of depsgraph */ DAG_ids_flush_update(bmain, 0); } - break; + break; } /* default for now */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); // XXX could use better notifier + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); // XXX could use better notifier } /* callback to remove the active driver */ -static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg)) +static void driver_remove_cb(bContext *C, void *ale_v, void *UNUSED(arg)) { - bAnimListElem *ale= (bAnimListElem *)ale_v; - ID *id= ale->id; - FCurve *fcu= ale->data; + bAnimListElem *ale = (bAnimListElem *)ale_v; + ID *id = ale->id; + FCurve *fcu = ale->data; ReportList *reports = CTX_wm_reports(C); /* try to get F-Curve that driver lives on, and ID block which has this AnimData */ @@ -418,29 +418,29 @@ static void driver_remove_cb (bContext *C, void *ale_v, void *UNUSED(arg)) } /* callback to add a target variable to the active driver */ -static void driver_add_var_cb (bContext *UNUSED(C), void *driver_v, void *UNUSED(arg)) +static void driver_add_var_cb(bContext *UNUSED(C), void *driver_v, void *UNUSED(arg)) { - ChannelDriver *driver= (ChannelDriver *)driver_v; + ChannelDriver *driver = (ChannelDriver *)driver_v; /* add a new variable */ driver_add_new_variable(driver); } /* callback to remove target variable from active driver */ -static void driver_delete_var_cb (bContext *UNUSED(C), void *driver_v, void *dvar_v) +static void driver_delete_var_cb(bContext *UNUSED(C), void *driver_v, void *dvar_v) { - ChannelDriver *driver= (ChannelDriver *)driver_v; - DriverVar *dvar= (DriverVar *)dvar_v; + ChannelDriver *driver = (ChannelDriver *)driver_v; + DriverVar *dvar = (DriverVar *)dvar_v; /* remove the active variable */ driver_free_variable(driver, dvar); } /* callback to reset the driver's flags */ -static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg)) +static void driver_update_flags_cb(bContext *UNUSED(C), void *fcu_v, void *UNUSED(arg)) { - FCurve *fcu= (FCurve *)fcu_v; - ChannelDriver *driver= fcu->driver; + FCurve *fcu = (FCurve *)fcu_v; + ChannelDriver *driver = fcu->driver; /* clear invalid flags */ fcu->flag &= ~FCURVE_DISABLED; // XXX? @@ -450,7 +450,7 @@ static void driver_update_flags_cb (bContext *UNUSED(C), void *fcu_v, void *UNUS /* drivers panel poll */ static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) { - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); if (sipo->mode != SIPO_MODE_DRIVERS) return 0; @@ -461,7 +461,7 @@ static int graph_panel_drivers_poll(const bContext *C, PanelType *UNUSED(pt)) /* settings for 'single property' driver variable type */ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; + DriverTarget *dtar = &dvar->targets[0]; PointerRNA dtar_ptr; uiLayout *row, *col; @@ -469,8 +469,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* Target ID */ - row= uiLayoutRow(layout, 0); - uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); + row = uiLayoutRow(layout, 0); + uiTemplateAnyID(row, &dtar_ptr, "id", "id_type", IFACE_("Prop:")); /* Target Property */ // TODO: make this less technical... @@ -480,7 +480,7 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* get pointer for resolving the property selected */ RNA_id_pointer_create(dtar->id, &root_ptr); - col= uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, 1); /* rna path */ uiTemplatePathBuilder(col, &dtar_ptr, "data_path", &root_ptr, IFACE_("Path")); } @@ -489,8 +489,8 @@ static void graph_panel_driverVar__singleProp(uiLayout *layout, ID *id, DriverVa /* settings for 'rotation difference' driver variable type */ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; - DriverTarget *dtar2= &dvar->targets[1]; + DriverTarget *dtar = &dvar->targets[0]; + DriverTarget *dtar2 = &dvar->targets[1]; Object *ob1 = (Object *)dtar->id; Object *ob2 = (Object *)dtar2->id; PointerRNA dtar_ptr, dtar2_ptr; @@ -501,32 +501,32 @@ static void graph_panel_driverVar__rotDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Bone 1:")); - if (dtar->id && ob1->pose) { - PointerRNA tar_ptr; + if (dtar->id && ob1->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); - uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); + uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Bone 2:")); - if (dtar2->id && ob2->pose) { - PointerRNA tar_ptr; + if (dtar2->id && ob2->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); - uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); + uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } } /* settings for 'location difference' driver variable type */ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; - DriverTarget *dtar2= &dvar->targets[1]; + DriverTarget *dtar = &dvar->targets[0]; + DriverTarget *dtar2 = &dvar->targets[1]; Object *ob1 = (Object *)dtar->id; Object *ob2 = (Object *)dtar2->id; PointerRNA dtar_ptr, dtar2_ptr; @@ -537,35 +537,35 @@ static void graph_panel_driverVar__locDiff(uiLayout *layout, ID *id, DriverVar * RNA_pointer_create(id, &RNA_DriverTarget, dtar2, &dtar2_ptr); /* Bone 1 */ - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone 1:")); - if (dtar->id && ob1->pose) { - PointerRNA tar_ptr; + if (dtar->id && ob1->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); - uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar->id, &RNA_Pose, ob1->pose, &tar_ptr); + uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); + uiItemR(col, &dtar_ptr, "transform_space", 0, NULL, ICON_NONE); - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar2_ptr, "id", "id_type", IFACE_("Ob/Bone 2:")); - if (dtar2->id && ob2->pose) { - PointerRNA tar_ptr; + if (dtar2->id && ob2->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); - uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar2->id, &RNA_Pose, ob2->pose, &tar_ptr); + uiItemPointerR(col, &dtar2_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE); + uiItemR(col, &dtar2_ptr, "transform_space", 0, NULL, ICON_NONE); } /* settings for 'transform channel' driver variable type */ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar *dvar) { - DriverTarget *dtar= &dvar->targets[0]; + DriverTarget *dtar = &dvar->targets[0]; Object *ob = (Object *)dtar->id; PointerRNA dtar_ptr; uiLayout *col, *sub; @@ -574,19 +574,19 @@ static void graph_panel_driverVar__transChan(uiLayout *layout, ID *id, DriverVar RNA_pointer_create(id, &RNA_DriverTarget, dtar, &dtar_ptr); /* properties */ - col= uiLayoutColumn(layout, 1); - uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); + col = uiLayoutColumn(layout, 1); + uiTemplateAnyID(col, &dtar_ptr, "id", "id_type", IFACE_("Ob/Bone:")); - if (dtar->id && ob->pose) { - PointerRNA tar_ptr; + if (dtar->id && ob->pose) { + PointerRNA tar_ptr; - RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr); - uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); - } + RNA_pointer_create(dtar->id, &RNA_Pose, ob->pose, &tar_ptr); + uiItemPointerR(col, &dtar_ptr, "bone_target", &tar_ptr, "bones", "", ICON_BONE_DATA); + } - sub= uiLayoutColumn(layout, 1); - uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); - uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); + sub = uiLayoutColumn(layout, 1); + uiItemR(sub, &dtar_ptr, "transform_type", 0, NULL, ICON_NONE); + uiItemR(sub, &dtar_ptr, "transform_space", 0, IFACE_("Space"), ICON_NONE); } /* driver settings for active F-Curve (only for 'Drivers' mode) */ @@ -605,125 +605,125 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* Get settings from context */ if (!graph_panel_context(C, &ale, &fcu)) return; - driver= fcu->driver; + driver = fcu->driver; /* set event handler for panel */ - block= uiLayoutGetBlock(pa->layout); // xxx? + block = uiLayoutGetBlock(pa->layout); // xxx? uiBlockSetHandleFunc(block, do_graph_region_driver_buttons, NULL); /* general actions - management */ - col= uiLayoutColumn(pa->layout, 0); - block= uiLayoutGetBlock(col); - but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10*UI_UNIT_X, 22, - NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); - uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); - - but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10*UI_UNIT_X, 18, - NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); - uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); + col = uiLayoutColumn(pa->layout, 0); + block = uiLayoutGetBlock(col); + but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Update Dependencies"), 0, 0, 10 * UI_UNIT_X, 22, + NULL, 0.0, 0.0, 0, 0, TIP_("Force updates of dependencies")); + uiButSetFunc(but, driver_update_flags_cb, fcu, NULL); + + but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Remove Driver"), 0, 0, 10 * UI_UNIT_X, 18, + NULL, 0.0, 0.0, 0, 0, TIP_("Remove this driver")); + uiButSetNFunc(but, driver_remove_cb, MEM_dupallocN(ale), NULL); /* driver-level settings - type, expressions, and errors */ RNA_pointer_create(ale->id, &RNA_Driver, driver, &driver_ptr); - col= uiLayoutColumn(pa->layout, 1); - block= uiLayoutGetBlock(col); - uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); + col = uiLayoutColumn(pa->layout, 1); + block = uiLayoutGetBlock(col); + uiItemR(col, &driver_ptr, "type", 0, NULL, ICON_NONE); + + /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */ + if (driver->type == DRIVER_TYPE_PYTHON) { + /* expression */ + uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); + + /* errors? */ + if (driver->flag & DRIVER_FLAG_INVALID) + uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR); + } + else { + /* errors? */ + if (driver->flag & DRIVER_FLAG_INVALID) + uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); + } - /* show expression box if doing scripted drivers, and/or error messages when invalid drivers exist */ - if (driver->type == DRIVER_TYPE_PYTHON) { - /* expression */ - uiItemR(col, &driver_ptr, "expression", 0, IFACE_("Expr"), ICON_NONE); - - /* errors? */ - if (driver->flag & DRIVER_FLAG_INVALID) - uiItemL(col, IFACE_("ERROR: invalid Python expression"), ICON_ERROR); - } - else { - /* errors? */ - if (driver->flag & DRIVER_FLAG_INVALID) - uiItemL(col, IFACE_("ERROR: invalid target channel(s)"), ICON_ERROR); - } + col = uiLayoutColumn(pa->layout, 1); + /* debug setting */ + uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); - col= uiLayoutColumn(pa->layout, 1); - /* debug setting */ - uiItemR(col, &driver_ptr, "show_debug_info", 0, NULL, ICON_NONE); - - /* value of driver */ - if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - uiLayout *row= uiLayoutRow(col, 1); - char valBuf[32]; + /* value of driver */ + if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { + uiLayout *row = uiLayoutRow(col, 1); + char valBuf[32]; - uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); + uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); - uiItemL(row, valBuf, ICON_NONE); - } + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); + uiItemL(row, valBuf, ICON_NONE); + } /* add driver variables */ - col= uiLayoutColumn(pa->layout, 0); - block= uiLayoutGetBlock(col); - but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10*UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); - uiButSetFunc(but, driver_add_var_cb, driver, NULL); + col = uiLayoutColumn(pa->layout, 0); + block = uiLayoutGetBlock(col); + but = uiDefBut(block, BUT, B_IPO_DEPCHANGE, IFACE_("Add Variable"), 0, 0, 10 * UI_UNIT_X, UI_UNIT_Y, + NULL, 0.0, 0.0, 0, 0, TIP_("Add a new target variable for this Driver")); + uiButSetFunc(but, driver_add_var_cb, driver, NULL); /* loop over targets, drawing them */ - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { PointerRNA dvar_ptr; uiLayout *box, *row; /* sub-layout column for this variable's settings */ - col= uiLayoutColumn(pa->layout, 1); + col = uiLayoutColumn(pa->layout, 1); /* header panel */ - box= uiLayoutBox(col); - /* first row context info for driver */ - RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); - - row= uiLayoutRow(box, 0); - block= uiLayoutGetBlock(row); - /* variable name */ - uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); - - /* remove button */ - uiBlockSetEmboss(block, UI_EMBOSSN); - but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, - NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); - uiButSetFunc(but, driver_delete_var_cb, driver, dvar); - uiBlockSetEmboss(block, UI_EMBOSS); - - /* variable type */ - row= uiLayoutRow(box, 0); - uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); + box = uiLayoutBox(col); + /* first row context info for driver */ + RNA_pointer_create(ale->id, &RNA_DriverVariable, dvar, &dvar_ptr); + + row = uiLayoutRow(box, 0); + block = uiLayoutGetBlock(row); + /* variable name */ + uiItemR(row, &dvar_ptr, "name", 0, "", ICON_NONE); + + /* remove button */ + uiBlockSetEmboss(block, UI_EMBOSSN); + but = uiDefIconBut(block, BUT, B_IPO_DEPCHANGE, ICON_X, 290, 0, UI_UNIT_X, UI_UNIT_Y, + NULL, 0.0, 0.0, 0.0, 0.0, IFACE_("Delete target variable")); + uiButSetFunc(but, driver_delete_var_cb, driver, dvar); + uiBlockSetEmboss(block, UI_EMBOSS); + + /* variable type */ + row = uiLayoutRow(box, 0); + uiItemR(row, &dvar_ptr, "type", 0, "", ICON_NONE); /* variable type settings */ - box= uiLayoutBox(col); - /* controls to draw depends on the type of variable */ - switch (dvar->type) { - case DVAR_TYPE_SINGLE_PROP: /* single property */ - graph_panel_driverVar__singleProp(box, ale->id, dvar); - break; - case DVAR_TYPE_ROT_DIFF: /* rotational difference */ - graph_panel_driverVar__rotDiff(box, ale->id, dvar); - break; - case DVAR_TYPE_LOC_DIFF: /* location difference */ - graph_panel_driverVar__locDiff(box, ale->id, dvar); - break; - case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */ - graph_panel_driverVar__transChan(box, ale->id, dvar); - break; - } + box = uiLayoutBox(col); + /* controls to draw depends on the type of variable */ + switch (dvar->type) { + case DVAR_TYPE_SINGLE_PROP: /* single property */ + graph_panel_driverVar__singleProp(box, ale->id, dvar); + break; + case DVAR_TYPE_ROT_DIFF: /* rotational difference */ + graph_panel_driverVar__rotDiff(box, ale->id, dvar); + break; + case DVAR_TYPE_LOC_DIFF: /* location difference */ + graph_panel_driverVar__locDiff(box, ale->id, dvar); + break; + case DVAR_TYPE_TRANSFORM_CHAN: /* transform channel */ + graph_panel_driverVar__transChan(box, ale->id, dvar); + break; + } - /* value of variable */ - if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { - char valBuf[32]; + /* value of variable */ + if (driver->flag & DRIVER_FLAG_SHOWDEBUG) { + char valBuf[32]; - box= uiLayoutBox(col); - row= uiLayoutRow(box, 1); - uiItemL(row, IFACE_("Value:"), ICON_NONE); - - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); - uiItemL(row, valBuf, ICON_NONE); - } + box = uiLayoutBox(col); + row = uiLayoutRow(box, 1); + uiItemL(row, IFACE_("Value:"), ICON_NONE); + + BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); + uiItemL(row, valBuf, ICON_NONE); + } } /* cleanup */ @@ -733,7 +733,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa) /* ******************* f-modifiers ******************************** */ /* all the drawing code is in editors/animation/fmodifier_ui.c */ -#define B_FMODIFIER_REDRAW 20 +#define B_FMODIFIER_REDRAW 20 static void do_graph_region_modifier_buttons(bContext *C, void *UNUSED(arg), int event) { @@ -755,27 +755,27 @@ static void graph_panel_modifiers(const bContext *C, Panel *pa) if (!graph_panel_context(C, &ale, &fcu)) return; - block= uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_graph_region_modifier_buttons, NULL); /* 'add modifier' button at top of panel */ { - row= uiLayoutRow(pa->layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(pa->layout, 0); + block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a 'add modifier' operator uiDefButO(block, BUT, "GRAPH_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), 10, 0, 150, 20, TIP_("Adds a new F-Curve Modifier for the active F-Curve")); /* copy/paste (as sub-row)*/ - row= uiLayoutRow(row, 1); - uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); - uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); + row = uiLayoutRow(row, 1); + uiItemO(row, "", ICON_COPYDOWN, "GRAPH_OT_fmodifier_copy"); + uiItemO(row, "", ICON_PASTEDOWN, "GRAPH_OT_fmodifier_paste"); } /* draw each modifier */ - for (fcm= fcu->modifiers.first; fcm; fcm= fcm->next) { - col= uiLayoutColumn(pa->layout, 1); + for (fcm = fcu->modifiers.first; fcm; fcm = fcm->next) { + col = uiLayoutColumn(pa->layout, 1); ANIM_uiTemplate_fmodifier_draw(col, ale->id, &fcu->modifiers, fcm); } @@ -789,47 +789,47 @@ void graph_buttons_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel view"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel view"); strcpy(pt->idname, "GRAPH_PT_view"); strcpy(pt->label, N_("View Properties")); - pt->draw= graph_panel_view; + pt->draw = graph_panel_view; pt->flag |= PNL_DEFAULT_CLOSED; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); strcpy(pt->idname, "GRAPH_PT_properties"); strcpy(pt->label, N_("Active F-Curve")); - pt->draw= graph_panel_properties; - pt->poll= graph_panel_poll; + pt->draw = graph_panel_properties; + pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel properties"); strcpy(pt->idname, "GRAPH_PT_key_properties"); strcpy(pt->label, N_("Active Keyframe")); - pt->draw= graph_panel_key_properties; - pt->poll= graph_panel_poll; + pt->draw = graph_panel_key_properties; + pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel drivers"); strcpy(pt->idname, "GRAPH_PT_drivers"); strcpy(pt->label, N_("Drivers")); - pt->draw= graph_panel_drivers; - pt->poll= graph_panel_drivers_poll; + pt->draw = graph_panel_drivers; + pt->poll = graph_panel_drivers_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers"); + pt = MEM_callocN(sizeof(PanelType), "spacetype graph panel modifiers"); strcpy(pt->idname, "GRAPH_PT_modifiers"); strcpy(pt->label, N_("Modifiers")); - pt->draw= graph_panel_modifiers; - pt->poll= graph_panel_poll; + pt->draw = graph_panel_modifiers; + pt->poll = graph_panel_poll; BLI_addtail(&art->paneltypes, pt); } static int graph_properties(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= graph_has_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = graph_has_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index e772e2856c1..ddca0030cf5 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -84,11 +84,11 @@ static float fcurve_display_alpha(FCurve *fcu) /* Envelope -------------- */ // TODO: draw a shaded poly showing the region of influence too!!! -static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) +static void draw_fcurve_modifier_controls_envelope(FModifier *fcm, View2D *v2d) { - FMod_Envelope *env= (FMod_Envelope *)fcm->data; + FMod_Envelope *env = (FMod_Envelope *)fcm->data; FCM_EnvelopeData *fed; - const float fac= 0.05f * (v2d->cur.xmax - v2d->cur.xmin); + const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin); int i; /* draw two black lines showing the standard reference levels */ @@ -96,11 +96,11 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) setlinestyle(5); glBegin(GL_LINES); - glVertex2f(v2d->cur.xmin, env->midval+env->min); - glVertex2f(v2d->cur.xmax, env->midval+env->min); + glVertex2f(v2d->cur.xmin, env->midval + env->min); + glVertex2f(v2d->cur.xmax, env->midval + env->min); - glVertex2f(v2d->cur.xmin, env->midval+env->max); - glVertex2f(v2d->cur.xmax, env->midval+env->max); + glVertex2f(v2d->cur.xmin, env->midval + env->max); + glVertex2f(v2d->cur.xmax, env->midval + env->max); glEnd(); // GL_LINES setlinestyle(0); @@ -114,7 +114,7 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) * drawing bugs that some drivers have (probably legacy ones only though) */ bglBegin(GL_POINTS); - for (i=0, fed=env->data; i < env->totvert; i++, fed++) { + for (i = 0, fed = env->data; i < env->totvert; i++, fed++) { /* only draw if visible * - min/max here are fixed, not relative */ @@ -134,10 +134,10 @@ static void draw_fcurve_modifier_controls_envelope (FModifier *fcm, View2D *v2d) /* Points ---------------- */ /* helper func - draw keyframe vertices only for an F-Curve */ -static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel) +static void draw_fcurve_vertices_keyframes(FCurve *fcu, SpaceIpo *UNUSED(sipo), View2D *v2d, short edit, short sel) { - BezTriple *bezt= fcu->bezt; - const float fac= 0.05f * (v2d->cur.xmax - v2d->cur.xmin); + BezTriple *bezt = fcu->bezt; + const float fac = 0.05f * (v2d->cur.xmax - v2d->cur.xmin); int i; /* we use bgl points not standard gl points, to workaround vertex @@ -174,18 +174,18 @@ static void draw_fcurve_vertices_keyframes (FCurve *fcu, SpaceIpo *UNUSED(sipo), * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't * have a consistent appearance (due to off-pixel alignments)... */ -static void draw_fcurve_handle_control (float x, float y, float xscale, float yscale, float hsize) +static void draw_fcurve_handle_control(float x, float y, float xscale, float yscale, float hsize) { - static GLuint displist=0; + static GLuint displist = 0; /* initialize round circle shape */ if (displist == 0) { GLUquadricObj *qobj; - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); - qobj = gluNewQuadric(); + qobj = gluNewQuadric(); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluDisk(qobj, 0, 0.7, 8, 1); gluDeleteQuadric(qobj); @@ -195,26 +195,26 @@ static void draw_fcurve_handle_control (float x, float y, float xscale, float ys /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); /* draw! */ glCallList(displist); /* restore view transform */ - glScalef(xscale/hsize, yscale/hsize, 1.0); + glScalef(xscale / hsize, yscale / hsize, 1.0); glTranslatef(-x, -y, 0.0f); } /* helper func - draw handle vertices only for an F-Curve (if it is not protected) */ -static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only) +static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2d, short sel, short sel_handle_only) { - BezTriple *bezt= fcu->bezt; + BezTriple *bezt = fcu->bezt; BezTriple *prevbezt = NULL; float hsize, xscale, yscale; int i; /* get view settings */ - hsize= UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); + hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE); UI_view2d_getscale(v2d, &xscale, &yscale); /* set handle color */ @@ -222,10 +222,10 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v else UI_ThemeColor(TH_HANDLE_VERTEX); /* anti-aliased lines for more consistent appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - for (i=0; i < fcu->totvert; i++, prevbezt=bezt, bezt++) { + for (i = 0; i < fcu->totvert; i++, prevbezt = bezt, bezt++) { /* Draw the editmode handles for a bezier curve (others don't have handles) * if their selection status matches the selection status we're drawing for * - first handle only if previous beztriple was bezier-mode @@ -234,31 +234,31 @@ static void draw_fcurve_vertices_handles (FCurve *fcu, SpaceIpo *sipo, View2D *v * Also, need to take into account whether the keyframe was selected * if a Graph Editor option to only show handles of selected keys is on. */ - if ( !sel_handle_only || BEZSELECTED(bezt) ) { - if ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) { - if ((bezt->f1 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/ + if (!sel_handle_only || BEZSELECTED(bezt) ) { + if ( (!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) ) { + if ((bezt->f1 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[0][0] < v2d->cur.xmax)*/ draw_fcurve_handle_control(bezt->vec[0][0], bezt->vec[0][1], xscale, yscale, hsize); } - if (bezt->ipo==BEZT_IPO_BEZ) { - if ((bezt->f3 & SELECT) == sel)/* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/ + if (bezt->ipo == BEZT_IPO_BEZ) { + if ((bezt->f3 & SELECT) == sel) /* && v2d->cur.xmin < bezt->vec[2][0] < v2d->cur.xmax)*/ draw_fcurve_handle_control(bezt->vec[2][0], bezt->vec[2][1], xscale, yscale, hsize); } } } - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } /* helper func - set color to draw F-Curve data with */ -static void set_fcurve_vertex_color (FCurve *fcu, short sel) +static void set_fcurve_vertex_color(FCurve *fcu, short sel) { /* Fade the 'intensity' of the vertices based on the selection of the curves too */ - int alphaOffset= (int)((fcurve_display_alpha(fcu) - 1.0f) * 255); + int alphaOffset = (int)((fcurve_display_alpha(fcu) - 1.0f) * 255); /* Set color of curve vertex based on state of curve (i.e. 'Edit' Mode) */ - if ((fcu->flag & FCURVE_PROTECTED)==0) { + if ((fcu->flag & FCURVE_PROTECTED) == 0) { /* Curve's points ARE BEING edited */ if (sel) UI_ThemeColorShadeAlpha(TH_VERTEX_SELECT, 0, alphaOffset); else UI_ThemeColorShadeAlpha(TH_VERTEX, 0, alphaOffset); @@ -271,14 +271,14 @@ static void set_fcurve_vertex_color (FCurve *fcu, short sel) } -static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only) +static void draw_fcurve_vertices(SpaceIpo *sipo, ARegion *ar, FCurve *fcu, short do_handles, short sel_handle_only) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; /* only draw points if curve is visible - * - draw unselected points before selected points as separate passes to minimise color-changing overhead + * - draw unselected points before selected points as separate passes to minimise color-changing overhead * (XXX dunno if this is faster than drawing all in one pass though) - * and also to make sure in the case of overlapping points that the selected is always visible + * and also to make sure in the case of overlapping points that the selected is always visible * - draw handles before keyframes, so that keyframes will overlap handles (keyframes are more important for users) */ @@ -308,14 +308,14 @@ static void draw_fcurve_vertices (SpaceIpo *sipo, ARegion *ar, FCurve *fcu, shor static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu) { /* don't draw handle lines if handles are not to be shown */ - if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */ - (fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */ -#if 0 /* handles can still be selected and handle types set, better draw - campbell */ - (fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */ + if ( (sipo->flag & SIPO_NOHANDLES) || /* handles shouldn't be shown anywhere */ + (fcu->flag & FCURVE_PROTECTED) || /* keyframes aren't editable */ +#if 0 /* handles can still be selected and handle types set, better draw - campbell */ + (fcu->flag & FCURVE_INT_VALUES) || /* editing the handles here will cause weird/incorrect interpolation issues */ #endif - ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */ - (fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */ - ) + ((fcu->grp) && (fcu->grp->flag & AGRP_PROTECTED)) || /* group that curve belongs to is not editable */ + (fcu->totvert <= 1) /* do not show handles if there is only 1 keyframe, otherwise they all clump together in an ugly ball */ + ) { return 0; } @@ -326,7 +326,7 @@ static int draw_fcurve_handles_check(SpaceIpo *sipo, FCurve *fcu) /* draw lines for F-Curve handles only (this is only done in EditMode) * note: draw_fcurve_handles_check must be checked before running this. */ -static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) +static void draw_fcurve_handles(SpaceIpo *sipo, FCurve *fcu) { int sel, b; @@ -339,13 +339,13 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) /* slightly hacky, but we want to draw unselected points before selected ones * so that selected points are clearly visible */ - for (sel= 0; sel < 2; sel++) { - BezTriple *bezt=fcu->bezt, *prevbezt=NULL; - int basecol= (sel)? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; + for (sel = 0; sel < 2; sel++) { + BezTriple *bezt = fcu->bezt, *prevbezt = NULL; + int basecol = (sel) ? TH_HANDLE_SEL_FREE : TH_HANDLE_FREE; float *fp; unsigned char col[4]; - for (b= 0; b < fcu->totvert; b++, prevbezt=bezt, bezt++) { + for (b = 0; b < fcu->totvert; b++, prevbezt = bezt, bezt++) { /* if only selected keyframes can get their handles shown, * check that keyframe is selected */ @@ -355,50 +355,50 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) } /* draw handle with appropriate set of colors if selection is ok */ - if ((bezt->f2 & SELECT)==sel) { - fp= bezt->vec[0]; + if ((bezt->f2 & SELECT) == sel) { + fp = bezt->vec[0]; /* only draw first handle if previous segment had handles */ - if ((!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ))) { + if ((!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { UI_GetThemeColor3ubv(basecol + bezt->h1, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp); glVertex2fv(fp+3); + glVertex2fv(fp); glVertex2fv(fp + 3); } /* only draw second handle if this segment is bezier */ if (bezt->ipo == BEZT_IPO_BEZ) { UI_GetThemeColor3ubv(basecol + bezt->h2, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp+3); glVertex2fv(fp+6); + glVertex2fv(fp + 3); glVertex2fv(fp + 6); } } else { /* only draw first handle if previous segment was had handles, and selection is ok */ - if ( ((bezt->f1 & SELECT)==sel) && - ( (!prevbezt && (bezt->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ)) ) ) + if ( ((bezt->f1 & SELECT) == sel) && + ( (!prevbezt && (bezt->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ)) ) ) { - fp= bezt->vec[0]; + fp = bezt->vec[0]; UI_GetThemeColor3ubv(basecol + bezt->h1, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp); glVertex2fv(fp+3); + glVertex2fv(fp); glVertex2fv(fp + 3); } /* only draw second handle if this segment is bezier, and selection is ok */ - if ( ((bezt->f3 & SELECT)==sel) && - (bezt->ipo == BEZT_IPO_BEZ) ) + if ( ((bezt->f3 & SELECT) == sel) && + (bezt->ipo == BEZT_IPO_BEZ) ) { - fp= bezt->vec[1]; + fp = bezt->vec[1]; UI_GetThemeColor3ubv(basecol + bezt->h2, col); - col[3]= fcurve_display_alpha(fcu) * 255; + col[3] = fcurve_display_alpha(fcu) * 255; glColor4ubv((GLubyte *)col); - glVertex2fv(fp); glVertex2fv(fp+3); + glVertex2fv(fp); glVertex2fv(fp + 3); } } } @@ -413,21 +413,21 @@ static void draw_fcurve_handles (SpaceIpo *sipo, FCurve *fcu) * NOTE: the caller MUST HAVE GL_LINE_SMOOTH & GL_BLEND ENABLED, otherwise, the controls don't * have a consistent appearance (due to off-pixel alignments)... */ -static void draw_fcurve_sample_control (float x, float y, float xscale, float yscale, float hsize) +static void draw_fcurve_sample_control(float x, float y, float xscale, float yscale, float hsize) { - static GLuint displist=0; + static GLuint displist = 0; /* initialize X shape */ if (displist == 0) { - displist= glGenLists(1); + displist = glGenLists(1); glNewList(displist, GL_COMPILE); glBegin(GL_LINES); - glVertex2f(-0.7f, -0.7f); - glVertex2f(+0.7f, +0.7f); + glVertex2f(-0.7f, -0.7f); + glVertex2f(+0.7f, +0.7f); - glVertex2f(-0.7f, +0.7f); - glVertex2f(+0.7f, -0.7f); + glVertex2f(-0.7f, +0.7f); + glVertex2f(+0.7f, -0.7f); glEnd(); // GL_LINES glEndList(); @@ -435,52 +435,52 @@ static void draw_fcurve_sample_control (float x, float y, float xscale, float ys /* adjust view transform before starting */ glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, 1.0f/yscale*hsize, 1.0f); + glScalef(1.0f / xscale * hsize, 1.0f / yscale * hsize, 1.0f); /* draw! */ glCallList(displist); /* restore view transform */ - glScalef(xscale/hsize, yscale/hsize, 1.0); + glScalef(xscale / hsize, yscale / hsize, 1.0); glTranslatef(-x, -y, 0.0f); } /* helper func - draw keyframe vertices only for an F-Curve */ -static void draw_fcurve_samples (SpaceIpo *sipo, ARegion *ar, FCurve *fcu) +static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu) { FPoint *first, *last; float hsize, xscale, yscale; /* get view settings */ - hsize= UI_GetThemeValuef(TH_VERTEX_SIZE); + hsize = UI_GetThemeValuef(TH_VERTEX_SIZE); UI_view2d_getscale(&ar->v2d, &xscale, &yscale); /* set vertex color */ - if (fcu->flag & (FCURVE_ACTIVE|FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI); + if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI); else UI_ThemeColor(TH_TEXT); /* get verts */ - first= fcu->fpt; - last= (first) ? (first + (fcu->totvert-1)) : (NULL); + first = fcu->fpt; + last = (first) ? (first + (fcu->totvert - 1)) : (NULL); /* draw */ if (first && last) { /* anti-aliased lines for more consistent appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); draw_fcurve_sample_control(first->vec[0], first->vec[1], xscale, yscale, hsize); draw_fcurve_sample_control(last->vec[0], last->vec[1], xscale, yscale, hsize); glDisable(GL_BLEND); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); } } /* Curve ---------------- */ /* helper func - just draw the F-Curve by sampling the visible region (for drawing curves with modifiers) */ -static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid) +static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d, View2DGrid *grid) { ChannelDriver *driver; float samplefreq, ctime; @@ -496,33 +496,33 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2 /* disable any drivers temporarily */ - driver= fcu->driver; - fcu->driver= NULL; + driver = fcu->driver; + fcu->driver = NULL; /* compute unit correction factor */ - unitFac= ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, fcu, 0); /* Note about sampling frequency: - * Ideally, this is chosen such that we have 1-2 pixels = 1 segment + * Ideally, this is chosen such that we have 1-2 pixels = 1 segment * which means that our curves can be as smooth as possible. However, - * this does mean that curves may not be fully accurate (i.e. if they have - * sudden spikes which happen at the sampling point, we may have problems). - * Also, this may introduce lower performance on less densely detailed curves,' + * this does mean that curves may not be fully accurate (i.e. if they have + * sudden spikes which happen at the sampling point, we may have problems). + * Also, this may introduce lower performance on less densely detailed curves,' * though it is impossible to predict this from the modifiers! * * If the automatically determined sampling frequency is likely to cause an infinite * loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value - * chosen here is just the coarsest value which still looks reasonable... + * chosen here is just the coarsest value which still looks reasonable... */ - /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */ - // TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? - samplefreq= dx / U.v2d_min_gridsize; - if (samplefreq < 0.00001f) samplefreq= 0.00001f; + /* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */ + // TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted? + samplefreq = dx / U.v2d_min_gridsize; + if (samplefreq < 0.00001f) samplefreq = 0.00001f; /* the start/end times are simply the horizontal extents of the 'cur' rect */ - stime= v2d->cur.xmin; - etime= v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */ + stime = v2d->cur.xmin; + etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */ /* at each sampling interval, add a new vertex @@ -531,22 +531,22 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2 */ glBegin(GL_LINE_STRIP); - for (ctime= stime; ctime <= etime; ctime += samplefreq) + for (ctime = stime; ctime <= etime; ctime += samplefreq) glVertex2f(ctime, evaluate_fcurve(fcu, ctime) * unitFac); glEnd(); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } /* helper func - draw a samples-based F-Curve */ -static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) +static void draw_fcurve_curve_samples(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) { - FPoint *prevfpt= fcu->fpt; - FPoint *fpt= prevfpt + 1; + FPoint *prevfpt = fcu->fpt; + FPoint *fpt = prevfpt + 1; float fac, v[2]; - int b= fcu->totvert-1; + int b = fcu->totvert - 1; glBegin(GL_LINE_STRIP); @@ -555,18 +555,18 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi /* extrapolate to left? - left-side of view comes before first keyframe? */ if (prevfpt->vec[0] > v2d->cur.xmin) { - v[0]= v2d->cur.xmin; + v[0] = v2d->cur.xmin; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ - v[1]= prevfpt->vec[1]; + v[1] = prevfpt->vec[1]; } else { /* extrapolate linear dosnt use the handle, use the next points center instead */ - fac= (prevfpt->vec[0]-fpt->vec[0])/(prevfpt->vec[0]-v[0]); - if (fac) fac= 1.0f/fac; - v[1]= prevfpt->vec[1]-fac*(prevfpt->vec[1]-fpt->vec[1]); + fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); + if (fac) fac = 1.0f / fac; + v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } glVertex2fv(v); @@ -583,7 +583,7 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi glVertex2fv(prevfpt->vec); /* get next pointers */ - prevfpt= fpt; + prevfpt = fpt; fpt++; /* last point? */ @@ -593,19 +593,19 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi /* extrapolate to right? (see code for left-extrapolation above too) */ if (prevfpt->vec[0] < v2d->cur.xmax) { - v[0]= v2d->cur.xmax; + v[0] = v2d->cur.xmax; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (fcu->totvert == 1)) { /* based on last keyframe's value */ - v[1]= prevfpt->vec[1]; + v[1] = prevfpt->vec[1]; } else { /* extrapolate linear dosnt use the handle, use the previous points center instead */ - fpt = prevfpt-1; - fac= (prevfpt->vec[0]-fpt->vec[0])/(prevfpt->vec[0]-v[0]); - if (fac) fac= 1.0f/fac; - v[1]= prevfpt->vec[1]-fac*(prevfpt->vec[1]-fpt->vec[1]); + fpt = prevfpt - 1; + fac = (prevfpt->vec[0] - fpt->vec[0]) / (prevfpt->vec[0] - v[0]); + if (fac) fac = 1.0f / fac; + v[1] = prevfpt->vec[1] - fac * (prevfpt->vec[1] - fpt->vec[1]); } glVertex2fv(v); @@ -618,14 +618,14 @@ static void draw_fcurve_curve_samples (bAnimContext *ac, ID *id, FCurve *fcu, Vi } /* helper func - draw one repeat of an F-Curve */ -static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) +static void draw_fcurve_curve_bezts(bAnimContext *ac, ID *id, FCurve *fcu, View2D *v2d) { - BezTriple *prevbezt= fcu->bezt; - BezTriple *bezt= prevbezt+1; + BezTriple *prevbezt = fcu->bezt; + BezTriple *bezt = prevbezt + 1; float v1[2], v2[2], v3[2], v4[2]; float *fp, data[120]; - float fac= 0.0f; - int b= fcu->totvert-1; + float fac = 0.0f; + int b = fcu->totvert - 1; int resol; glBegin(GL_LINE_STRIP); @@ -636,24 +636,24 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View /* extrapolate to left? */ if (prevbezt->vec[1][0] > v2d->cur.xmin) { /* left-side of view comes before first keyframe, so need to extend as not cyclic */ - v1[0]= v2d->cur.xmin; + v1[0] = v2d->cur.xmin; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo==BEZT_IPO_CONST) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* just extend across the first keyframe's value */ - v1[1]= prevbezt->vec[1][1]; + v1[1] = prevbezt->vec[1][1]; } - else if (prevbezt->ipo==BEZT_IPO_LIN) { + else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the next points center instead */ - fac= (prevbezt->vec[1][0]-bezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[1][1]-bezt->vec[1][1]); + fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); } else { /* based on angle of handle 1 (relative to keyframe) */ - fac= (prevbezt->vec[0][0]-prevbezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[0][1]-prevbezt->vec[1][1]); + fac = (prevbezt->vec[0][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[0][1] - prevbezt->vec[1][1]); } glVertex2fv(v1); @@ -661,28 +661,28 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View /* if only one keyframe, add it now */ if (fcu->totvert == 1) { - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } /* draw curve between first and last keyframe (if there are enough to do so) */ // TODO: optimize this to not have to calc stuff out of view too? while (b--) { - if (prevbezt->ipo==BEZT_IPO_CONST) { + if (prevbezt->ipo == BEZT_IPO_CONST) { /* Constant-Interpolation: draw segment between previous keyframe and next, but holding same value */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); - v1[0]= bezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = bezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } - else if (prevbezt->ipo==BEZT_IPO_LIN) { + else if (prevbezt->ipo == BEZT_IPO_LIN) { /* Linear interpolation: just add one point (which should add a new line segment) */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } else { @@ -693,74 +693,74 @@ static void draw_fcurve_curve_bezts (bAnimContext *ac, ID *id, FCurve *fcu, View /* resol depends on distance between points (not just horizontal) OR is a fixed high res */ // TODO: view scale should factor into this someday too... if (fcu->driver) - resol= 32; + resol = 32; else - resol= (int)(5.0f*len_v2v2(bezt->vec[1], prevbezt->vec[1])); + resol = (int)(5.0f * len_v2v2(bezt->vec[1], prevbezt->vec[1])); if (resol < 2) { /* only draw one */ - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } else { /* clamp resolution to max of 32 */ // NOTE: higher values will crash - if (resol > 32) resol= 32; + if (resol > 32) resol = 32; - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; - v2[0]= prevbezt->vec[2][0]; - v2[1]= prevbezt->vec[2][1]; - - v3[0]= bezt->vec[0][0]; - v3[1]= bezt->vec[0][1]; - v4[0]= bezt->vec[1][0]; - v4[1]= bezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; + v2[0] = prevbezt->vec[2][0]; + v2[1] = prevbezt->vec[2][1]; + + v3[0] = bezt->vec[0][0]; + v3[1] = bezt->vec[0][1]; + v4[0] = bezt->vec[1][0]; + v4[1] = bezt->vec[1][1]; correct_bezpart(v1, v2, v3, v4); - BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float)*3); - BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data+1, resol, sizeof(float)*3); + BKE_curve_forward_diff_bezier(v1[0], v2[0], v3[0], v4[0], data, resol, sizeof(float) * 3); + BKE_curve_forward_diff_bezier(v1[1], v2[1], v3[1], v4[1], data + 1, resol, sizeof(float) * 3); - for (fp= data; resol; resol--, fp+= 3) + for (fp = data; resol; resol--, fp += 3) glVertex2fv(fp); } } /* get next pointers */ - prevbezt= bezt; + prevbezt = bezt; bezt++; /* last point? */ if (b == 0) { - v1[0]= prevbezt->vec[1][0]; - v1[1]= prevbezt->vec[1][1]; + v1[0] = prevbezt->vec[1][0]; + v1[1] = prevbezt->vec[1][1]; glVertex2fv(v1); } } /* extrapolate to right? (see code for left-extrapolation above too) */ if (prevbezt->vec[1][0] < v2d->cur.xmax) { - v1[0]= v2d->cur.xmax; + v1[0] = v2d->cur.xmax; /* y-value depends on the interpolation */ - if ((fcu->extend==FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo==BEZT_IPO_CONST) || (fcu->totvert==1)) { + if ((fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) || (fcu->flag & FCURVE_INT_VALUES) || (prevbezt->ipo == BEZT_IPO_CONST) || (fcu->totvert == 1)) { /* based on last keyframe's value */ - v1[1]= prevbezt->vec[1][1]; + v1[1] = prevbezt->vec[1][1]; } - else if (prevbezt->ipo==BEZT_IPO_LIN) { + else if (prevbezt->ipo == BEZT_IPO_LIN) { /* extrapolate linear dosnt use the handle, use the previous points center instead */ - bezt = prevbezt-1; - fac= (prevbezt->vec[1][0]-bezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[1][1]-bezt->vec[1][1]); + bezt = prevbezt - 1; + fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[1][1] - bezt->vec[1][1]); } else { /* based on angle of handle 1 (relative to keyframe) */ - fac= (prevbezt->vec[2][0]-prevbezt->vec[1][0])/(prevbezt->vec[1][0]-v1[0]); - if (fac) fac= 1.0f/fac; - v1[1]= prevbezt->vec[1][1]-fac*(prevbezt->vec[2][1]-prevbezt->vec[1][1]); + fac = (prevbezt->vec[2][0] - prevbezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); + if (fac) fac = 1.0f / fac; + v1[1] = prevbezt->vec[1][1] - fac * (prevbezt->vec[2][1] - prevbezt->vec[1][1]); } glVertex2fv(v1); @@ -786,13 +786,13 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) glLineWidth(3.0f); /* anti-aliased lines for less jagged appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); /* the ghost curves are simply sampled F-Curves stored in sipo->ghostCurves */ - for (fcu= sipo->ghostCurves.first; fcu; fcu= fcu->next) { + for (fcu = sipo->ghostCurves.first; fcu; fcu = fcu->next) { /* set whatever color the curve has set - * - this is set by the function which creates these + * - this is set by the function which creates these * - draw with a fixed opacity of 2 */ glColor4f(fcu->color[0], fcu->color[1], fcu->color[2], 0.5f); @@ -805,7 +805,7 @@ void graph_draw_ghost_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar) setlinestyle(0); glLineWidth(1.0f); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -819,18 +819,18 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid int filter; /* build list of curves to draw */ - filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); filter |= ((sel) ? (ANIMFILTER_SEL) : (ANIMFILTER_UNSEL)); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* for each curve: * draw curve, then handle-lines, and finally vertices in this order so that - * the data will be layered correctly + * the data will be layered correctly */ - for (ale=anim_data.first; ale; ale=ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - FModifier *fcm= find_active_fmodifier(&fcu->modifiers); - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + FModifier *fcm = find_active_fmodifier(&fcu->modifiers); + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* map keyframes for drawing if scaled F-Curve */ if (adt) @@ -868,7 +868,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid } /* anti-aliased lines for less jagged appearance */ - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glEnable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); /* draw F-Curve */ @@ -890,7 +890,7 @@ void graph_draw_curves(bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGrid setlinestyle(0); glLineWidth(1.0); - if ((sipo->flag & SIPO_BEAUTYDRAW_OFF)==0) glDisable(GL_LINE_SMOOTH); + if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) glDisable(GL_LINE_SMOOTH); glDisable(GL_BLEND); } @@ -953,35 +953,35 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - float y= 0.0f, height; + View2D *v2d = &ar->v2d; + float y = 0.0f, height; size_t items; - int i=0; + int i = 0; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of ACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= (float)((items*ACHANNEL_STEP) + (ACHANNEL_HEIGHT*2)); + height = (float)((items * ACHANNEL_STEP) + (ACHANNEL_HEIGHT * 2)); UI_view2d_totRect_set(v2d, ar->winx, height); /* loop through channels, and set up drawing depending on their type */ - { /* first pass: just the standard GL-drawing for backdrop + text */ - y= (float)ACHANNEL_FIRST; + { /* first pass: just the standard GL-drawing for backdrop + text */ + y = (float)ACHANNEL_FIRST; - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw(ac, ale, yminc, ymaxc); @@ -991,23 +991,23 @@ void graph_draw_channel_names(bContext *C, bAnimContext *ac, ARegion *ar) y -= ACHANNEL_STEP; } } - { /* second pass: widgets */ - uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + { /* second pass: widgets */ + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - y= (float)ACHANNEL_FIRST; + y = (float)ACHANNEL_FIRST; /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - for (ale= anim_data.first, i=0; ale; ale= ale->next, i++) { - const float yminc= (float)(y - ACHANNEL_HEIGHT_HALF); - const float ymaxc= (float)(y + ACHANNEL_HEIGHT_HALF); + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { + const float yminc = (float)(y - ACHANNEL_HEIGHT_HALF); + const float ymaxc = (float)(y + ACHANNEL_HEIGHT_HALF); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 5f8281fda5b..7371202b4fb 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -90,21 +90,21 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa int filter; /* get data to filter, from Dopesheet */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ - if (xmin) *xmin= 999999999.0f; - if (xmax) *xmax= -999999999.0f; - if (ymin) *ymin= 999999999.0f; - if (ymax) *ymax= -999999999.0f; + if (xmin) *xmin = 999999999.0f; + if (xmax) *xmax = -999999999.0f; + if (ymin) *ymin = 999999999.0f; + if (ymax) *ymax = -999999999.0f; /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; float txmin, txmax, tymin, tymax; float unitFac; @@ -113,20 +113,20 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa /* apply NLA scaling */ if (adt) { - txmin= BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); - txmax= BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); + txmin = BKE_nla_tweakedit_remap(adt, txmin, NLATIME_CONVERT_MAP); + txmax = BKE_nla_tweakedit_remap(adt, txmax, NLATIME_CONVERT_MAP); } /* apply unit corrections */ - unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); tymin *= unitFac; tymax *= unitFac; /* try to set cur using these values, if they're more extreme than previously set values */ - if ((xmin) && (txmin < *xmin)) *xmin= txmin; - if ((xmax) && (txmax > *xmax)) *xmax= txmax; - if ((ymin) && (tymin < *ymin)) *ymin= tymin; - if ((ymax) && (tymax > *ymax)) *ymax= tymax; + if ((xmin) && (txmin < *xmin)) *xmin = txmin; + if ((xmax) && (txmax > *xmax)) *xmax = txmax; + if ((ymin) && (tymin < *ymin)) *ymin = tymin; + if ((ymax) && (tymax > *ymax)) *ymax = tymax; } /* ensure that the extents are not too extreme that view implodes...*/ @@ -139,16 +139,16 @@ void get_graph_keyframe_extents(bAnimContext *ac, float *xmin, float *xmax, floa else { /* set default range */ if (ac->scene) { - if (xmin) *xmin= (float)ac->scene->r.sfra; - if (xmax) *xmax= (float)ac->scene->r.efra; + if (xmin) *xmin = (float)ac->scene->r.sfra; + if (xmax) *xmax = (float)ac->scene->r.efra; } else { - if (xmin) *xmin= -5; - if (xmax) *xmax= 100; + if (xmin) *xmin = -5; + if (xmax) *xmax = 100; } - if (ymin) *ymin= -5; - if (ymax) *ymax= 5; + if (ymin) *ymin = -5; + if (ymax) *ymax = 5; } } @@ -166,17 +166,17 @@ static int graphkeys_previewrange_exec(bContext *C, wmOperator *UNUSED(op)) if (ac.scene == NULL) return OPERATOR_CANCELLED; else - scene= ac.scene; + scene = ac.scene; /* set the range directly */ get_graph_keyframe_extents(&ac, &min, &max, NULL, NULL, FALSE); scene->r.flag |= SCER_PRV_RANGE; - scene->r.psfra= (int)floor(min + 0.5f); - scene->r.pefra= (int)floor(max + 0.5f); + scene->r.psfra = (int)floor(min + 0.5f); + scene->r.pefra = (int)floor(max + 0.5f); /* set notifier that things have changed */ // XXX err... there's nothing for frame ranges yet, but this should do fine too - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -193,7 +193,7 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ****************** View-All Operator ****************** */ @@ -207,16 +207,16 @@ static int graphkeys_viewall(bContext *C, const short selOnly) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - v2d= &ac.ar->v2d; + v2d = &ac.ar->v2d; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_graph_keyframe_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, &v2d->cur.ymin, &v2d->cur.ymax, selOnly); - extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; - extra= 0.1f * (v2d->cur.ymax - v2d->cur.ymin); + extra = 0.1f * (v2d->cur.ymax - v2d->cur.ymin); v2d->cur.ymin -= extra; v2d->cur.ymax += extra; @@ -255,7 +255,7 @@ void GRAPH_OT_view_all(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void GRAPH_OT_view_selected(wmOperatorType *ot) @@ -270,7 +270,7 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; // XXX: unchecked poll to get fsamples working too, but makes modifier damage trickier... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Create Ghost-Curves Operator *********************** */ @@ -279,9 +279,9 @@ void GRAPH_OT_view_selected(wmOperatorType *ot) */ /* Bake each F-Curve into a set of samples, and store as a ghost curve */ -static void create_ghost_curves (bAnimContext *ac, int start, int end) +static void create_ghost_curves(bAnimContext *ac, int start, int end) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -296,51 +296,51 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end) } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - FCurve *gcu= MEM_callocN(sizeof(FCurve), "Ghost FCurve"); - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - ChannelDriver *driver= fcu->driver; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + FCurve *gcu = MEM_callocN(sizeof(FCurve), "Ghost FCurve"); + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + ChannelDriver *driver = fcu->driver; FPoint *fpt; float unitFac; int cfra; /* disable driver so that it don't muck up the sampling process */ - fcu->driver= NULL; + fcu->driver = NULL; /* calculate unit-mapping factor */ - unitFac= ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); + unitFac = ANIM_unit_mapping_get_factor(ac->scene, ale->id, fcu, 0); /* create samples, but store them in a new curve * - we cannot use fcurve_store_samples() as that will only overwrite the original curve */ - gcu->fpt= fpt= MEM_callocN(sizeof(FPoint)*(end-start+1), "Ghost FPoint Samples"); - gcu->totvert= end - start + 1; + gcu->fpt = fpt = MEM_callocN(sizeof(FPoint) * (end - start + 1), "Ghost FPoint Samples"); + gcu->totvert = end - start + 1; /* use the sampling callback at 1-frame intervals from start to end frames */ - for (cfra= start; cfra <= end; cfra++, fpt++) { - float cfrae= BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); + for (cfra = start; cfra <= end; cfra++, fpt++) { + float cfrae = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); - fpt->vec[0]= cfrae; - fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) * unitFac; + fpt->vec[0] = cfrae; + fpt->vec[1] = fcurve_samplingcb_evalcurve(fcu, NULL, cfrae) * unitFac; } /* set color of ghost curve * - make the color slightly darker */ - gcu->color[0]= fcu->color[0] - 0.07f; - gcu->color[1]= fcu->color[1] - 0.07f; - gcu->color[2]= fcu->color[2] - 0.07f; + gcu->color[0] = fcu->color[0] - 0.07f; + gcu->color[1] = fcu->color[1] - 0.07f; + gcu->color[2] = fcu->color[2] - 0.07f; /* store new ghost curve */ BLI_addtail(&sipo->ghostCurves, gcu); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } /* admin and redraws */ @@ -360,9 +360,9 @@ static int graphkeys_create_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op) return OPERATOR_CANCELLED; /* ghost curves are snapshots of the visible portions of the curves, so set range to be the visible range */ - v2d= &ac.ar->v2d; - start= (int)v2d->cur.xmin; - end= (int)v2d->cur.xmax; + v2d = &ac.ar->v2d; + start = (int)v2d->cur.xmin; + end = (int)v2d->cur.xmax; /* bake selected curves into a ghost curve */ create_ghost_curves(&ac, start, end); @@ -385,7 +385,7 @@ void GRAPH_OT_ghost_curves_create(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; // todo: add props for start/end frames } @@ -401,7 +401,7 @@ static int graphkeys_clear_ghostcurves_exec(bContext *C, wmOperator *UNUSED(op)) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - sipo= (SpaceIpo *)ac.sl; + sipo = (SpaceIpo *)ac.sl; /* if no ghost curves, don't do anything */ if (sipo->ghostCurves.first == NULL) @@ -428,7 +428,7 @@ void GRAPH_OT_ghost_curves_clear(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -451,11 +451,11 @@ static void insert_graph_keys(bAnimContext *ac, short mode) int filter; ReportList *reports = ac->reports; - Scene *scene= ac->scene; + Scene *scene = ac->scene; short flag = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (mode == 2) filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); @@ -464,20 +464,20 @@ static void insert_graph_keys(bAnimContext *ac, short mode) flag = ANIM_get_keyframing_flags(scene, 1); /* insert keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; float cfra; /* adjust current frame for NLA-mapping */ if (adt) - cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); + cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); else - cfra= (float)CFRA; + cfra = (float)CFRA; /* if there's an id */ if (ale->id) - insert_keyframe(reports, ale->id, NULL, ((fcu->grp)?(fcu->grp->name):(NULL)), fcu->rna_path, fcu->array_index, cfra, flag); + insert_keyframe(reports, ale->id, NULL, ((fcu->grp) ? (fcu->grp->name) : (NULL)), fcu->rna_path, fcu->array_index, cfra, flag); else insert_vert_fcurve(fcu, cfra, fcu->curval, 0); } @@ -497,7 +497,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* which channels to affect? */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* insert keyframes */ insert_graph_keys(&ac, mode); @@ -506,7 +506,7 @@ static int graphkeys_insertkey_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -524,7 +524,7 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_insertkey_types, 0, "Type", ""); @@ -532,7 +532,7 @@ void GRAPH_OT_keyframe_insert(wmOperatorType *ot) /* ******************** Click-Insert Keyframes Operator ************************* */ -static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) +static int graphkeys_click_insert_exec(bContext *C, wmOperator *op) { bAnimContext ac; bAnimListElem *ale; @@ -545,7 +545,7 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get active F-Curve 'anim-list-element' */ - ale= get_active_fcurve_channel(&ac); + ale = get_active_fcurve_channel(&ac); if (ELEM(NULL, ale, ale->data)) { if (ale) MEM_freeN(ale); return OPERATOR_CANCELLED; @@ -557,12 +557,12 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) */ if (fcurve_is_keyframable(fcu)) { /* get frame and value from props */ - frame= RNA_float_get(op->ptr, "frame"); - val= RNA_float_get(op->ptr, "value"); + frame = RNA_float_get(op->ptr, "frame"); + val = RNA_float_get(op->ptr, "value"); /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */ - adt= ANIM_nla_mapping_get(&ac, ale); - frame= BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); + adt = ANIM_nla_mapping_get(&ac, ale); + frame = BKE_nla_tweakedit_remap(adt, frame, NLATIME_CONVERT_UNMAP); /* apply inverse unit-mapping to value to get correct value for F-Curves */ val *= ANIM_unit_mapping_get_factor(ac.scene, ale->id, fcu, 1); @@ -584,13 +584,13 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op) MEM_freeN(ale); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; } -static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, wmEvent *evt) +static int graphkeys_click_insert_invoke(bContext *C, wmOperator *op, wmEvent *evt) { bAnimContext ac; ARegion *ar; @@ -603,11 +603,11 @@ static int graphkeys_click_insert_invoke (bContext *C, wmOperator *op, wmEvent * return OPERATOR_CANCELLED; /* store mouse coordinates in View2D space, into the operator's properties */ - ar= ac.ar; - v2d= &ar->v2d; + ar = ac.ar; + v2d = &ar->v2d; - mval[0]= (evt->x - ar->winrct.xmin); - mval[1]= (evt->y - ar->winrct.ymin); + mval[0] = (evt->x - ar->winrct.xmin); + mval[1] = (evt->y - ar->winrct.ymin); UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y); @@ -631,7 +631,7 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) ot->poll = graphop_active_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_float(ot->srna, "frame", 1.0f, -FLT_MAX, FLT_MAX, "Frame Number", "Frame to insert keyframe on", 0, 100); @@ -641,20 +641,20 @@ void GRAPH_OT_click_insert(wmOperatorType *ot) /* ******************** Copy/Paste Keyframes Operator ************************* */ /* NOTE: the backend code for this is shared with the dopesheet editor */ -static short copy_graph_keys (bAnimContext *ac) +static short copy_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* clear buffer first */ free_anim_copybuf(); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* copy keyframes */ - ok= copy_animedit_keys(ac, &anim_data); + ok = copy_animedit_keys(ac, &anim_data); /* clean up */ BLI_freelistN(&anim_data); @@ -662,18 +662,18 @@ static short copy_graph_keys (bAnimContext *ac) return ok; } -static short paste_graph_keys (bAnimContext *ac, - const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) +static short paste_graph_keys(bAnimContext *ac, + const eKeyPasteOffset offset_mode, const eKeyMergeMode merge_mode) { ListBase anim_data = {NULL, NULL}; - int filter, ok=0; + int filter, ok = 0; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* paste keyframes */ - ok= paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); + ok = paste_animedit_keys(ac, &anim_data, offset_mode, merge_mode); /* clean up */ BLI_freelistN(&anim_data); @@ -713,7 +713,7 @@ void GRAPH_OT_copy(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -722,15 +722,15 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) { bAnimContext ac; - const eKeyPasteOffset offset_mode= RNA_enum_get(op->ptr, "offset"); - const eKeyMergeMode merge_mode= RNA_enum_get(op->ptr, "merge"); + const eKeyPasteOffset offset_mode = RNA_enum_get(op->ptr, "offset"); + const eKeyMergeMode merge_mode = RNA_enum_get(op->ptr, "merge"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* ac.reports by default will be the global reports list, which won't show warnings */ - ac.reports= op->reports; + ac.reports = op->reports; /* paste keyframes - non-zero return means an error occurred while trying to paste */ if (paste_graph_keys(&ac, offset_mode, merge_mode)) { @@ -741,7 +741,7 @@ static int graphkeys_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -759,7 +759,7 @@ void GRAPH_OT_paste(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_enum(ot->srna, "offset", keyframe_paste_offset_items, KEYFRAME_PASTE_OFFSET_CFRA_START, "Offset", "Paste time offset of keys"); RNA_def_enum(ot->srna, "merge", keyframe_paste_merge_items, KEYFRAME_PASTE_MERGE_MIX, "Type", "Method of merging pasted keys and existing"); @@ -767,18 +767,18 @@ void GRAPH_OT_paste(wmOperatorType *ot) /* ******************** Duplicate Keyframes Operator ************************* */ -static void duplicate_graph_keys (bAnimContext *ac) +static void duplicate_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { duplicate_fcurve_keys((FCurve *)ale->key_data); } @@ -803,7 +803,7 @@ static int graphkeys_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -828,7 +828,7 @@ void GRAPH_OT_duplicate(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -836,20 +836,20 @@ void GRAPH_OT_duplicate(wmOperatorType *ot) /* ******************** Delete Keyframes Operator ************************* */ -static void delete_graph_keys (bAnimContext *ac) +static void delete_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and delete selected keys */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + AnimData *adt = ale->adt; /* delete selected keyframes only */ delete_fcurve_keys(fcu); @@ -880,7 +880,7 @@ static int graphkeys_delete_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -898,23 +898,23 @@ void GRAPH_OT_delete(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clean Keyframes Operator ************************* */ -static void clean_graph_keys (bAnimContext *ac, float thresh) +static void clean_graph_keys(bAnimContext *ac, float thresh) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_SEL | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and clean curves */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) clean_fcurve((FCurve *)ale->key_data, thresh); /* free temp data */ @@ -933,7 +933,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get cleaning threshold */ - thresh= RNA_float_get(op->ptr, "threshold"); + thresh = RNA_float_get(op->ptr, "threshold"); /* clean keyframes */ clean_graph_keys(&ac, thresh); @@ -942,7 +942,7 @@ static int graphkeys_clean_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -960,7 +960,7 @@ void GRAPH_OT_clean(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_float(ot->srna, "threshold", 0.001f, 0.0f, FLT_MAX, "Threshold", "", 0.0f, 1000.0f); @@ -970,29 +970,29 @@ void GRAPH_OT_clean(wmOperatorType *ot) /* This operator bakes the data of the selected F-Curves to F-Points */ /* Bake each F-Curve into a set of samples */ -static void bake_graph_curves (bAnimContext *ac, int start, int end) +static void bake_graph_curves(bAnimContext *ac, int start, int end) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - ChannelDriver *driver= fcu->driver; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + ChannelDriver *driver = fcu->driver; /* disable driver so that it don't muck up the sampling process */ - fcu->driver= NULL; + fcu->driver = NULL; /* create samples */ fcurve_store_samples(fcu, NULL, start, end, fcurve_samplingcb_evalcurve); /* restore driver */ - fcu->driver= driver; + fcu->driver = driver; } /* admin and redraws */ @@ -1004,7 +1004,7 @@ static void bake_graph_curves (bAnimContext *ac, int start, int end) static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - Scene *scene= NULL; + Scene *scene = NULL; int start, end; /* get editor data */ @@ -1013,9 +1013,9 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) /* for now, init start/end from preview-range extents */ // TODO: add properties for this - scene= ac.scene; - start= PSFRA; - end= PEFRA; + scene = ac.scene; + start = PSFRA; + end = PEFRA; /* bake keyframes */ bake_graph_curves(&ac, start, end); @@ -1025,7 +1025,7 @@ static int graphkeys_bake_exec(bContext *C, wmOperator *UNUSED(op)) /* set notifier that keyframes have changed */ // NOTE: some distinction between order/number of keyframes and type should be made? - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1043,7 +1043,7 @@ void GRAPH_OT_bake(wmOperatorType *ot) ot->poll = graphop_selected_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; // todo: add props for start/end frames } @@ -1069,9 +1069,9 @@ typedef struct tSoundBakeInfo { /* Sampling callback used to determine the value from the sound to * save in the F-Curve at the specified frame */ -static float fcurve_samplingcb_sound (FCurve *UNUSED(fcu), void *data, float evaltime) +static float fcurve_samplingcb_sound(FCurve *UNUSED(fcu), void *data, float evaltime) { - tSoundBakeInfo *sbi= (tSoundBakeInfo *)data; + tSoundBakeInfo *sbi = (tSoundBakeInfo *)data; int position = evaltime - sbi->cfra; if ((position < 0) || (position >= sbi->length)) @@ -1090,7 +1090,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) int filter; tSoundBakeInfo sbi; - Scene *scene= NULL; + Scene *scene = NULL; int start, end; char path[FILE_MAX]; @@ -1101,20 +1101,20 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); - scene= ac.scene; /* current scene */ + scene = ac.scene; /* current scene */ /* store necessary data for the baking steps */ sbi.samples = AUD_readSoundBuffer(path, - RNA_float_get(op->ptr, "low"), - RNA_float_get(op->ptr, "high"), - RNA_float_get(op->ptr, "attack"), - RNA_float_get(op->ptr, "release"), - RNA_float_get(op->ptr, "threshold"), - RNA_boolean_get(op->ptr, "accumulate"), - RNA_boolean_get(op->ptr, "use_additive"), - RNA_boolean_get(op->ptr, "square"), - RNA_float_get(op->ptr, "sthreshold"), - FPS, &sbi.length); + RNA_float_get(op->ptr, "low"), + RNA_float_get(op->ptr, "high"), + RNA_float_get(op->ptr, "attack"), + RNA_float_get(op->ptr, "release"), + RNA_float_get(op->ptr, "threshold"), + RNA_boolean_get(op->ptr, "accumulate"), + RNA_boolean_get(op->ptr, "use_additive"), + RNA_boolean_get(op->ptr, "square"), + RNA_float_get(op->ptr, "sthreshold"), + FPS, &sbi.length); if (sbi.samples == NULL) { BKE_report(op->reports, RPT_ERROR, "Unsupported audio format"); @@ -1126,12 +1126,12 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) end = CFRA + sbi.length - 1; /* filter anim channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through all selected F-Curves, replacing its data with the sound samples */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* sample the sound */ fcurve_store_samples(fcu, &sbi, start, end, fcurve_samplingcb_sound); @@ -1147,7 +1147,7 @@ static int graphkeys_sound_bake_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that 'keyframes' have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1163,7 +1163,7 @@ static int graphkeys_sound_bake_exec(bContext *UNUSED(C), wmOperator *op) #endif //WITH_AUDASPACE -static int graphkeys_sound_bake_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int graphkeys_sound_bake_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; @@ -1187,10 +1187,10 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) ot->poll = graphop_selected_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ - WM_operator_properties_filesel(ot, FOLDERFILE|SOUNDFILE|MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); + WM_operator_properties_filesel(ot, FOLDERFILE | SOUNDFILE | MOVIEFILE, FILE_SPECIAL, FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); RNA_def_float(ot->srna, "low", 0.0f, 0.0, 100000.0, "Lowest frequency", "", 0.1, 1000.00); RNA_def_float(ot->srna, "high", 100000.0, 0.0, 100000.0, "Highest frequency", "", 0.1, 1000.00); RNA_def_float(ot->srna, "attack", 0.005, 0.0, 2.0, "Attack time", "", 0.01, 0.1); @@ -1208,18 +1208,18 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) */ /* Evaluates the curves between each selected keyframe on each frame, and keys the value */ -static void sample_graph_keys (bAnimContext *ac) +static void sample_graph_keys(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through filtered data and add keys between selected keyframes on every frame */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) sample_fcurve((FCurve *)ale->key_data); /* admin and redraws */ @@ -1243,7 +1243,7 @@ static int graphkeys_sample_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1260,7 +1260,7 @@ void GRAPH_OT_sample(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1270,8 +1270,8 @@ void GRAPH_OT_sample(wmOperatorType *ot) /* ******************** Set Extrapolation-Type Operator *********************** */ /* defines for make/clear cyclic extrapolation tools */ -#define MAKE_CYCLIC_EXPO -1 -#define CLEAR_CYCLIC_EXPO -2 +#define MAKE_CYCLIC_EXPO -1 +#define CLEAR_CYCLIC_EXPO -2 /* defines for set extrapolation-type for selected keyframes tool */ static EnumPropertyItem prop_graphkeys_expo_types[] = { @@ -1291,16 +1291,16 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) int filter; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting mode per F-Curve */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; if (mode >= 0) { /* just set mode setting */ - fcu->extend= mode; + fcu->extend = mode; } else { /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation @@ -1315,7 +1315,7 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode) } else if (mode == CLEAR_CYCLIC_EXPO) { /* remove all the modifiers fitting this description */ - FModifier *fcm, *fcn=NULL; + FModifier *fcm, *fcn = NULL; for (fcm = fcu->modifiers.first; fcm; fcm = fcn) { fcn = fcm->next; @@ -1343,7 +1343,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setexpo_graph_keys(&ac, mode); @@ -1352,7 +1352,7 @@ static int graphkeys_expo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1370,7 +1370,7 @@ void GRAPH_OT_extrapolation_type(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_expo_types, 0, "Type", ""); @@ -1384,16 +1384,16 @@ static void setipo_graph_keys(bAnimContext *ac, short mode) ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - KeyframeEditFunc set_cb= ANIM_editkeyframes_ipo(mode); + KeyframeEditFunc set_cb = ANIM_editkeyframes_ipo(mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting BezTriple interpolation * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(NULL, ale->key_data, NULL, set_cb, calchandles_fcurve); /* cleanup */ @@ -1412,7 +1412,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ setipo_graph_keys(&ac, mode); @@ -1421,7 +1421,7 @@ static int graphkeys_ipo_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } @@ -1439,7 +1439,7 @@ void GRAPH_OT_interpolation_type(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", beztriple_interpolation_mode_items, 0, "Type", ""); @@ -1454,18 +1454,18 @@ static void sethandles_graph_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - KeyframeEditFunc edit_cb= ANIM_editkeyframes_handles(mode); - KeyframeEditFunc sel_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + KeyframeEditFunc edit_cb = ANIM_editkeyframes_handles(mode); + KeyframeEditFunc sel_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* loop through setting flags for handles * Note: we do not supply KeyframeEditData to the looper yet. Currently that's not necessary here... */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* any selected keyframes for editing? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, sel_cb, NULL)) { @@ -1489,7 +1489,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get handle setting mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* set handle type */ sethandles_graph_keys(&ac, mode); @@ -1498,12 +1498,12 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframe properties have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); return OPERATOR_FINISHED; } - void GRAPH_OT_handle_type (wmOperatorType *ot) +void GRAPH_OT_handle_type(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Keyframe Handle Type"; @@ -1516,7 +1516,7 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", keyframe_handle_type_items, 0, "Type", ""); @@ -1536,39 +1536,39 @@ static int graphkeys_handletype_exec(bContext *C, wmOperator *op) typedef struct tEulerFilter { struct tEulerFilter *next, *prev; - ID *id; /* ID-block which owns the channels */ - FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */ - char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */ + ID *id; /* ID-block which owns the channels */ + FCurve *(fcurves[3]); /* 3 Pointers to F-Curves */ + char *rna_path; /* Pointer to one of the RNA Path's used by one of the F-Curves */ } tEulerFilter; -static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) +static int graphkeys_euler_filter_exec(bContext *C, wmOperator *op) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; ListBase eulers = {NULL, NULL}; - tEulerFilter *euf= NULL; - int groups=0, failed=0; + tEulerFilter *euf = NULL; + int groups = 0, failed = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* The process is done in two passes: - * 1) Sets of three related rotation curves are identified from the selected channels, + * 1) Sets of three related rotation curves are identified from the selected channels, * and are stored as a single 'operation unit' for the next step * 2) Each set of three F-Curves is processed for each keyframe, with the values being - * processed as necessary + * processed as necessary */ /* step 1: extract only the rotation f-curves */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { FCurve *fcu = (FCurve *)ale->data; /* check if this is an appropriate F-Curve @@ -1579,8 +1579,8 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) continue; else if (ELEM3(fcu->array_index, 0, 1, 2) == 0) { BKE_reportf(op->reports, RPT_WARNING, - "Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)", - (ale->id)? ale->id->name:"", fcu->rna_path, fcu->array_index); + "Euler Rotation F-Curve has invalid index (ID='%s', Path='%s', Index=%d)", + (ale->id) ? ale->id->name : "", fcu->rna_path, fcu->array_index); continue; } @@ -1588,19 +1588,19 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) * so if the paths or the ID's don't match up, then a curve needs to be added * to a new group */ - if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path)==0)) { + if ((euf) && (euf->id == ale->id) && (strcmp(euf->rna_path, fcu->rna_path) == 0)) { /* this should be fine to add to the existing group then */ - euf->fcurves[fcu->array_index]= fcu; + euf->fcurves[fcu->array_index] = fcu; } else { /* just add to a new block */ - euf= MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"); + euf = MEM_callocN(sizeof(tEulerFilter), "tEulerFilter"); BLI_addtail(&eulers, euf); groups++; - euf->id= ale->id; + euf->id = ale->id; euf->rna_path = fcu->rna_path; /* this should be safe, since we're only using it for a short time */ - euf->fcurves[fcu->array_index]= fcu; + euf->fcurves[fcu->array_index] = fcu; } } BLI_freelistN(&anim_data); @@ -1613,7 +1613,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) /* step 2: go through each set of curves, processing the values at each keyframe * - it is assumed that there must be a full set of keyframes at each keyframe position */ - for (euf= eulers.first; euf; euf= euf->next) { + for (euf = eulers.first; euf; euf = euf->next) { int f; /* sanity check: ensure that there are enough F-Curves to work on in this group */ @@ -1621,11 +1621,11 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) if (ELEM3(NULL, euf->fcurves[0], euf->fcurves[1], euf->fcurves[2])) { /* report which components are missing */ BKE_reportf(op->reports, RPT_WARNING, - "Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'", - (euf->fcurves[0]==NULL)? "X":"", - (euf->fcurves[1]==NULL)? "Y":"", - (euf->fcurves[2]==NULL)? "Z":"", - euf->id->name, euf->rna_path); + "Missing %s%s%s component(s) of euler rotation for ID='%s' and RNA-Path='%s'", + (euf->fcurves[0] == NULL) ? "X" : "", + (euf->fcurves[1] == NULL) ? "Y" : "", + (euf->fcurves[2] == NULL) ? "Z" : "", + euf->id->name, euf->rna_path); /* keep track of number of failed sets, and carry on to next group */ failed++; @@ -1636,7 +1636,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) // FIXME: there are more complicated methods that will be needed to fix more cases than just some for (f = 0; f < 3; f++) { FCurve *fcu = euf->fcurves[f]; - BezTriple *bezt, *prev=NULL; + BezTriple *bezt, *prev = NULL; unsigned int i; /* skip if not enough vets to do a decent analysis of... */ @@ -1644,7 +1644,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) continue; /* prev follows bezt, bezt = "current" point to be fixed */ - for (i=0, bezt=fcu->bezt; i < fcu->totvert; i++, prev=bezt, bezt++) { + for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, prev = bezt, bezt++) { /* our method depends on determining a "difference" from the previous vert */ if (prev == NULL) continue; @@ -1661,7 +1661,7 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) bezt->vec[2][1] += fac; } } - else /* if (prev->vec[1][1] < bezt->vec[1][1]) */ { + else { /* if (prev->vec[1][1] < bezt->vec[1][1]) */ while (fabsf(bezt->vec[1][1] - prev->vec[1][1]) >= (float)M_PI) { bezt->vec[0][1] -= fac; bezt->vec[1][1] -= fac; @@ -1677,20 +1677,20 @@ static int graphkeys_euler_filter_exec (bContext *C, wmOperator *op) /* updates + finishing warnings */ if (failed == groups) { BKE_report(op->reports, RPT_ERROR, - "No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); + "No Euler Rotations could be corrected, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); return OPERATOR_CANCELLED; } else { if (failed) { BKE_report(op->reports, RPT_ERROR, - "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); + "Some Euler Rotations couldn't be corrected due to missing/unselected/out-of-order F-Curves, ensure each rotation has keys for all components, and that F-Curves for these are in consecutive XYZ order and selected"); } /* validate keyframes after editing */ ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); /* done at last */ return OPERATOR_FINISHED; @@ -1709,7 +1709,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ***************** Jump to Selected Frames Operator *********************** */ @@ -1718,7 +1718,7 @@ void GRAPH_OT_euler_filter(wmOperatorType *ot) static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditData ked; @@ -1731,11 +1731,11 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) memset(&ked, 0, sizeof(KeyframeEditData)); /* loop over action data, averaging values */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(&ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(&ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); @@ -1749,24 +1749,24 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_calc_average, NULL); /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE|ANIM_UNITCONV_ONLYKEYS); + ANIM_unit_mapping_apply_fcurve(ac.scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | ANIM_UNITCONV_ONLYKEYS); } BLI_freelistN(&anim_data); /* set the new current frame and cursor values, based on the average time and value */ if (ked.i1) { - SpaceIpo *sipo= (SpaceIpo *)ac.sl; - Scene *scene= ac.scene; + SpaceIpo *sipo = (SpaceIpo *)ac.sl; + Scene *scene = ac.scene; /* take the average values, rounding to the nearest int for the current frame */ - CFRA= (int)floor((ked.f1 / ked.i1) + 0.5f); - SUBFRA= 0.f; - sipo->cursorVal= ked.f2 / (float)ked.i1; + CFRA = (int)floor((ked.f1 / ked.i1) + 0.5f); + SUBFRA = 0.f; + sipo->cursorVal = ked.f2 / (float)ked.i1; } /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, ac.scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, ac.scene); return OPERATOR_FINISHED; } @@ -1783,7 +1783,7 @@ void GRAPH_OT_frame_jump(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Snap Keyframes Operator *********************** */ @@ -1810,26 +1810,26 @@ static void snap_graph_keys(bAnimContext *ac, short mode) KeyframeEditFunc edit_cb; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_snap(mode); + edit_cb = ANIM_editkeyframes_snap(mode); memset(&ked, 0, sizeof(KeyframeEditData)); - ked.scene= ac->scene; + ked.scene = ac->scene; if (mode == GRAPHKEYS_SNAP_NEAREST_MARKER) { - ked.list.first= (ac->markers) ? ac->markers->first : NULL; - ked.list.last= (ac->markers) ? ac->markers->last : NULL; + ked.list.first = (ac->markers) ? ac->markers->first : NULL; + ked.list.last = (ac->markers) ? ac->markers->last : NULL; } else if (mode == GRAPHKEYS_SNAP_VALUE) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - ked.f1= (sipo) ? sipo->cursorVal : 0.0f; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + ked.f1 = (sipo) ? sipo->cursorVal : 0.0f; } /* snap keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0); @@ -1861,7 +1861,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get snapping mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* snap keyframes */ snap_graph_keys(&ac, mode); @@ -1870,7 +1870,7 @@ static int graphkeys_snap_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -1888,7 +1888,7 @@ void GRAPH_OT_snap(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_snap_types, 0, "Type", ""); @@ -1917,37 +1917,37 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) KeyframeEditFunc edit_cb; /* get beztriple editing callbacks */ - edit_cb= ANIM_editkeyframes_mirror(mode); + edit_cb = ANIM_editkeyframes_mirror(mode); memset(&ked, 0, sizeof(KeyframeEditData)); - ked.scene= ac->scene; + ked.scene = ac->scene; /* for 'first selected marker' mode, need to find first selected marker first! */ // XXX should this be made into a helper func in the API? if (mode == GRAPHKEYS_MIRROR_MARKER) { - TimeMarker *marker= NULL; + TimeMarker *marker = NULL; /* find first selected marker */ - marker= ED_markers_get_first_selected(ac->markers); + marker = ED_markers_get_first_selected(ac->markers); /* store marker's time (if available) */ if (marker) - ked.f1= (float)marker->frame; + ked.f1 = (float)marker->frame; else return; } else if (mode == GRAPHKEYS_MIRROR_VALUE) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - ked.f1= (sipo) ? sipo->cursorVal : 0.0f; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + ked.f1 = (sipo) ? sipo->cursorVal : 0.0f; } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* mirror keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS); @@ -1961,7 +1961,7 @@ static void mirror_graph_keys(bAnimContext *ac, short mode) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, edit_cb, calchandles_fcurve); /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS|ANIM_UNITCONV_RESTORE); + ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_ONLYKEYS | ANIM_UNITCONV_RESTORE); } BLI_freelistN(&anim_data); @@ -1979,7 +1979,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get mirroring mode */ - mode= RNA_enum_get(op->ptr, "type"); + mode = RNA_enum_get(op->ptr, "type"); /* mirror keyframes */ mirror_graph_keys(&ac, mode); @@ -1988,7 +1988,7 @@ static int graphkeys_mirror_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2006,7 +2006,7 @@ void GRAPH_OT_mirror(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", prop_graphkeys_mirror_types, 0, "Type", ""); @@ -2026,11 +2026,11 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* smooth keyframes */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* For now, we can only smooth by flattening handles AND smoothing curve values. * Perhaps the mode argument could be removed, as that functionality is offerred through * Snap->Flatten Handles anyway. @@ -2043,7 +2043,7 @@ static int graphkeys_smooth_exec(bContext *C, wmOperator *UNUSED(op)) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2060,7 +2060,7 @@ void GRAPH_OT_smooth(wmOperatorType *ot) ot->poll = graphop_editable_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ @@ -2069,19 +2069,19 @@ void GRAPH_OT_smooth(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ /* present a special customised popup menu for this, with some filtering */ -static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) +static int graph_fmodifier_add_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { wmOperatorType *ot = WM_operatortype_find("GRAPH_OT_fmodifier_add", 1); uiPopupMenu *pup; uiLayout *layout; int i; - pup= uiPupMenuBegin(C, IFACE_("Add F-Curve Modifier"), ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, IFACE_("Add F-Curve Modifier"), ICON_NONE); + layout = uiPupMenuLayout(pup); /* start from 1 to skip the 'Invalid' modifier type */ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { - FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i); + FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i); PointerRNA props_ptr; /* check if modifier is valid for this context */ @@ -2089,11 +2089,11 @@ static int graph_fmodifier_add_invoke (bContext *C, wmOperator *op, wmEvent *UNU continue; /* create operator menu item with relevant properties filled in */ - props_ptr= uiItemFullO_ptr(layout, ot, IFACE_(fmi->name), ICON_NONE, - NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); - /* the only thing that gets set from the menu is the type of F-Modifier to add */ + props_ptr = uiItemFullO_ptr(layout, ot, IFACE_(fmi->name), ICON_NONE, + NULL, WM_OP_EXEC_REGION_WIN, UI_ITEM_O_RETURN_PROPS); + /* the only thing that gets set from the menu is the type of F-Modifier to add */ RNA_enum_set(&props_ptr, "type", i); - /* the following properties are just repeats of existing ones... */ + /* the following properties are just repeats of existing ones... */ RNA_boolean_set(&props_ptr, "only_active", RNA_boolean_get(op->ptr, "only_active")); } uiItemS(layout); @@ -2116,23 +2116,23 @@ static int graph_fmodifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get type of modifier to add */ - type= RNA_enum_get(op->ptr, "type"); + type = RNA_enum_get(op->ptr, "type"); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_NODUPLIS); if (RNA_boolean_get(op->ptr, "only_active")) - filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled? + filter |= ANIMFILTER_ACTIVE; // FIXME: enforce in this case only a single channel to get handled? else - filter |= (ANIMFILTER_SEL|ANIMFILTER_CURVE_VISIBLE); + filter |= (ANIMFILTER_SEL | ANIMFILTER_CURVE_VISIBLE); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* add f-modifier to each curve */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; FModifier *fcm; /* add F-Modifier of specified type to active F-Curve, and make it the active one */ - fcm= add_fmodifier(&fcu->modifiers, type); + fcm = add_fmodifier(&fcu->modifiers, type); if (fcm) set_active_fmodifier(&fcu->modifiers, fcm); else { @@ -2165,7 +2165,7 @@ void GRAPH_OT_fmodifier_add(wmOperatorType *ot) ot->poll = graphop_selected_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); @@ -2188,14 +2188,14 @@ static int graph_fmodifier_copy_exec(bContext *C, wmOperator *op) free_fmodifiers_copybuf(); /* get the active F-Curve */ - ale= get_active_fcurve_channel(&ac); + ale = get_active_fcurve_channel(&ac); /* if this exists, call the copy F-Modifiers API function */ if (ale && ale->data) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; // TODO: when 'active' vs 'all' boolean is added, change last param! - ok= ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); + ok = ANIM_fmodifiers_copy_to_buf(&fcu->modifiers, 0); /* free temp data now */ MEM_freeN(ale); @@ -2222,7 +2222,7 @@ void GRAPH_OT_fmodifier_copy(wmOperatorType *ot) ot->poll = graphop_active_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one"); @@ -2235,19 +2235,19 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok=0; + int filter, ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* paste modifiers */ for (ale = anim_data.first; ale; ale = ale->next) { - FCurve *fcu= (FCurve *)ale->data; + FCurve *fcu = (FCurve *)ale->data; // TODO: do we want to replace existing modifiers? add user pref for that! ok += ANIM_fmodifiers_paste_from_buf(&fcu->modifiers, 0); @@ -2262,7 +2262,7 @@ static int graph_fmodifier_paste_exec(bContext *C, wmOperator *op) ANIM_editkeyframes_refresh(&ac); /* set notifier that keyframes have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -2284,7 +2284,7 @@ void GRAPH_OT_fmodifier_paste(wmOperatorType *ot) ot->poll = graphop_active_fcurve_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************************************************************** */ diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index d7274b07985..47b55ae90ab 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -70,14 +70,14 @@ void GRAPH_OT_clickselect(struct wmOperatorType *ot); /* defines for left-right select tool */ enum { - GRAPHKEYS_LRSEL_TEST = 0, + GRAPHKEYS_LRSEL_TEST = 0, GRAPHKEYS_LRSEL_LEFT, GRAPHKEYS_LRSEL_RIGHT } eGraphKeys_LeftRightSelect_Mode; /* defines for column-select mode */ enum { - GRAPHKEYS_COLUMNSEL_KEYS = 0, + GRAPHKEYS_COLUMNSEL_KEYS = 0, GRAPHKEYS_COLUMNSEL_CFRA, GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN, GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN, @@ -86,7 +86,7 @@ enum { /* ***************************************** */ /* graph_edit.c */ -void get_graph_keyframe_extents (struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected); +void get_graph_keyframe_extents(struct bAnimContext *ac, float *xmin, float *xmax, float *ymin, float *ymax, const short do_selected); void GRAPH_OT_previewrange_set(struct wmOperatorType *ot); void GRAPH_OT_view_all(struct wmOperatorType *ot); @@ -172,4 +172,3 @@ void graphedit_operatortypes(void); #endif /* __GRAPH_INTERN_H__ */ - diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 2887fa1c881..62aebcb4edc 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -69,22 +69,22 @@ /* Set the new frame number */ static void graphview_cursor_apply(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceIpo *sipo= CTX_wm_space_graph(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); /* adjust the frame * NOTE: sync this part of the code with ANIM_OT_change_frame */ - CFRA= RNA_int_get(op->ptr, "frame"); - SUBFRA=0.f; + CFRA = RNA_int_get(op->ptr, "frame"); + SUBFRA = 0.f; sound_seek_scene(bmain, scene); /* set the cursor value */ - sipo->cursorVal= RNA_float_get(op->ptr, "value"); + sipo->cursorVal = RNA_float_get(op->ptr, "value"); /* send notifiers - notifiers for frame should force an update for both vars ok... */ - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); } /* ... */ @@ -101,7 +101,7 @@ static int graphview_cursor_exec(bContext *C, wmOperator *op) /* set the operator properties from the initial event */ static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); float viewx, viewy; /* abort if not active region (should not really be possible) */ @@ -112,8 +112,8 @@ static void graphview_cursor_setprops(bContext *C, wmOperator *op, wmEvent *even UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &viewx, &viewy); /* store the values in the operator properties */ - /* frame is rounded to the nearest int, since frames are ints */ - RNA_int_set(op->ptr, "frame", (int)floor(viewx+0.5f)); + /* frame is rounded to the nearest int, since frames are ints */ + RNA_int_set(op->ptr, "frame", (int)floor(viewx + 0.5f)); RNA_float_set(op->ptr, "value", viewy); } @@ -153,7 +153,7 @@ static int graphview_cursor_modal(bContext *C, wmOperator *op, wmEvent *event) /* we check for either mouse-button to end, as checking for ACTIONMOUSE (which is used to init * the modal op) doesn't work for some reason */ - if (event->val==KM_RELEASE) + if (event->val == KM_RELEASE) return OPERATOR_FINISHED; break; } @@ -175,7 +175,7 @@ static void GRAPH_OT_cursor_set(wmOperatorType *ot) ot->poll = ED_operator_graphedit_active; /* flags */ - ot->flag = OPTYPE_BLOCKING|OPTYPE_UNDO; + ot->flag = OPTYPE_BLOCKING | OPTYPE_UNDO; /* rna */ RNA_def_int(ot->srna, "frame", 0, MINAFRAME, MAXFRAME, "Frame", "", MINAFRAME, MAXFRAME); @@ -198,7 +198,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_ghost_curves_clear); /* keyframes */ - /* selection */ + /* selection */ WM_operatortype_append(GRAPH_OT_clickselect); WM_operatortype_append(GRAPH_OT_select_all_toggle); WM_operatortype_append(GRAPH_OT_select_border); @@ -208,7 +208,7 @@ void graphedit_operatortypes(void) WM_operatortype_append(GRAPH_OT_select_less); WM_operatortype_append(GRAPH_OT_select_leftright); - /* editing */ + /* editing */ WM_operatortype_append(GRAPH_OT_snap); WM_operatortype_append(GRAPH_OT_mirror); WM_operatortype_append(GRAPH_OT_frame_jump); @@ -241,9 +241,10 @@ void ED_operatormacros_graph(void) wmOperatorType *ot; wmOperatorTypeMacro *otmacro; - ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); + ot = WM_operatortype_append_macro("GRAPH_OT_duplicate_move", "Duplicate", + "Make a copy of all selected keyframes and move them", + OPTYPE_UNDO | OPTYPE_REGISTER); if (ot) { - ot->description = "Make a copy of all selected keyframes and move them"; WM_operatortype_macro_define(ot, "GRAPH_OT_duplicate"); otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_transform"); RNA_enum_set(otmacro->ptr, "mode", TFM_TIME_DUPLICATE); @@ -253,7 +254,7 @@ void ED_operatormacros_graph(void) /* ************************** registration - keymaps **********************************/ -static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) +static void graphedit_keymap_keyframes(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; @@ -261,95 +262,95 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", HKEY, KM_PRESS, KM_CTRL, 0); RNA_string_set(kmi->ptr, "data_path", "space_data.show_handles"); - /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons - * This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values - */ + /* NOTE: 'ACTIONMOUSE' not 'LEFTMOUSE', as user may have swapped mouse-buttons + * This keymap is supposed to override ANIM_OT_change_frame, which does the same except it doesn't do y-values + */ WM_keymap_add_item(keymap, "GRAPH_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); /* graph_select.c - selection tools */ - /* click-select */ + /* click-select */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", TRUE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", TRUE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", FALSE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "curves", FALSE); - RNA_boolean_set(kmi->ptr, "column", TRUE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_boolean_set(kmi->ptr, "curves", TRUE); - RNA_boolean_set(kmi->ptr, "column", FALSE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_boolean_set(kmi->ptr, "curves", TRUE); - RNA_boolean_set(kmi->ptr, "column", FALSE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "curves", FALSE); + RNA_boolean_set(kmi->ptr, "column", TRUE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "curves", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_ALT | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "curves", TRUE); + RNA_boolean_set(kmi->ptr, "column", FALSE); /* select left/right */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_TEST); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", GRAPHKEYS_LRSEL_RIGHT); - /* deselect all */ + /* deselect all */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", FALSE); + RNA_boolean_set(kmi->ptr, "invert", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", TRUE); + RNA_boolean_set(kmi->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); - RNA_boolean_set(kmi->ptr, "include_handles", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "include_handles", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - RNA_boolean_set(kmi->ptr, "include_handles", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "include_handles", FALSE); kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); - RNA_boolean_set(kmi->ptr, "include_handles", TRUE); - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); - RNA_boolean_set(kmi->ptr, "include_handles", TRUE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "include_handles", TRUE); + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_select_border", BKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "include_handles", TRUE); - /* column select */ + /* column select */ RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_KEYS); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_CFRA); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN); RNA_enum_set(WM_keymap_add_item(keymap, "GRAPH_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN); - /* select more/less */ + /* select more/less */ WM_keymap_add_item(keymap, "GRAPH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0); - /* select linked */ + /* select linked */ WM_keymap_add_item(keymap, "GRAPH_OT_select_linked", LKEY, KM_PRESS, 0, 0); /* graph_edit.c */ - /* snap - current frame to selected keys */ - // TODO: maybe since this is called jump, we're better to have it on -J? - WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* snap - current frame to selected keys */ + // TODO: maybe since this is called jump, we're better to have it on -J? + WM_keymap_add_item(keymap, "GRAPH_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); - /* menu + single-step transform */ + /* menu + single-step transform */ WM_keymap_add_item(keymap, "GRAPH_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0); @@ -357,7 +358,7 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "GRAPH_OT_interpolation_type", TKEY, KM_PRESS, 0, 0); - /* destructive */ + /* destructive */ WM_keymap_add_item(keymap, "GRAPH_OT_clean", OKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_smooth", OKEY, KM_PRESS, KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0); @@ -369,27 +370,27 @@ static void graphedit_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap) WM_keymap_add_item(keymap, "GRAPH_OT_duplicate_move", DKEY, KM_PRESS, KM_SHIFT, 0); - /* insertkey */ + /* insertkey */ WM_keymap_add_item(keymap, "GRAPH_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_click_insert", LEFTMOUSE, KM_CLICK, KM_CTRL, 0); - /* copy/paste */ + /* copy/paste */ WM_keymap_add_item(keymap, "GRAPH_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_add_item(keymap, "GRAPH_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0); - /* auto-set range */ - WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); + /* auto-set range */ + WM_keymap_add_item(keymap, "GRAPH_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL | KM_ALT, 0); WM_keymap_add_item(keymap, "GRAPH_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "GRAPH_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); - /* F-Modifiers */ - kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* F-Modifiers */ + kmi = WM_keymap_add_item(keymap, "GRAPH_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "only_active", FALSE); /* animation module */ - /* channels list - * NOTE: these operators were originally for the channels list, but are added here too for convenience... - */ + /* channels list + * NOTE: these operators were originally for the channels list, but are added here too for convenience... + */ WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0); /* transform system */ @@ -408,7 +409,7 @@ void graphedit_keymap(wmKeyConfig *keyconf) /* keymap for all regions */ keymap = WM_keymap_find(keyconf, "Graph Editor Generic", SPACE_IPO, 0); WM_keymap_add_item(keymap, "GRAPH_OT_properties", NKEY, KM_PRESS, 0, 0); - /* extrapolation works on channels, not keys */ + /* extrapolation works on channels, not keys */ WM_keymap_add_item(keymap, "GRAPH_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); /* channels */ diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 7c72fa0834d..33e32363cf5 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -76,48 +76,48 @@ /* Deselects keyframes in the Graph Editor * - This is called by the deselect all operator, as well as other ones! * - * - test: check if select or deselect all + * - test: check if select or deselect all * - sel: how to select keyframes * 0 = deselect * 1 = select * 2 = invert * - do_channels: whether to affect selection status of channels */ -static void deselect_graph_keys (bAnimContext *ac, short test, short sel, short do_channels) +static void deselect_graph_keys(bAnimContext *ac, short test, short sel, short do_channels) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - KeyframeEditData ked= {{NULL}}; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + KeyframeEditData ked = {{NULL}}; KeyframeEditFunc test_cb, sel_cb; /* determine type-based settings */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* init BezTriple looping data */ - test_cb= ANIM_editkeyframes_ok(BEZT_OK_SELECTED); + test_cb = ANIM_editkeyframes_ok(BEZT_OK_SELECTED); /* See if we should be selecting or deselecting */ if (test) { - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, test_cb, NULL)) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } } /* convert sel to selectmode, and use that to get editor */ - sel_cb= ANIM_editkeyframes_select(sel); + sel_cb = ANIM_editkeyframes_select(sel); /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* Keyframes First */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, sel_cb, NULL); @@ -161,7 +161,7 @@ static int graphkeys_deselectall_exec(bContext *C, wmOperator *op) deselect_graph_keys(&ac, 1, SELECT_ADD, TRUE); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -178,7 +178,7 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* props */ ot->prop = RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -186,7 +186,7 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) /* ******************** Border Select Operator **************************** */ /* This operator currently works in one of three ways: - * -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION) + * -> BKEY - 1) all keyframes within region are selected (validation with BEZT_OK_REGION) * -> ALT-BKEY - depending on which axis of the region was larger... * -> 2) x-axis, so select all frames within frame range (validation with BEZT_OK_FRAMERANGE) * -> 3) y-axis, so select all frames within channels that region included (validation with BEZT_OK_VALUERANGE) @@ -197,16 +197,16 @@ void GRAPH_OT_select_all_toggle(wmOperatorType *ot) * this, and allow handles to be considered independently too. * Also, for convenience, handles should get same status as keyframe (if it was within bounds). */ -static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles) +static void borderselect_graphkeys(bAnimContext *ac, rcti rect, short mode, short selectmode, short incl_handles) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter, mapping_flag; - SpaceIpo *sipo= (SpaceIpo *)ac->sl; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; KeyframeEditData ked; KeyframeEditFunc ok_cb, select_cb; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; /* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */ @@ -214,29 +214,29 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* get beztriple editing/validation funcs */ - select_cb= ANIM_editkeyframes_select(selectmode); - ok_cb= ANIM_editkeyframes_ok(mode); + select_cb = ANIM_editkeyframes_select(selectmode); + ok_cb = ANIM_editkeyframes_ok(mode); /* init editing data */ memset(&ked, 0, sizeof(KeyframeEditData)); - ked.data= &rectf; + ked.data = &rectf; /* treat handles separately? */ if (incl_handles) { ked.iterflags |= KEYFRAME_ITER_INCL_HANDLES; - mapping_flag= 0; + mapping_flag = 0; } else - mapping_flag= ANIM_UNITCONV_ONLYKEYS; + mapping_flag = ANIM_UNITCONV_ONLYKEYS; /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); + FCurve *fcu = (FCurve *)ale->key_data; /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, mapping_flag); @@ -245,19 +245,19 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho * guess when a callback might use something different */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles==0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, incl_handles == 0); /* set horizontal range (if applicable) * NOTE: these values are only used for x-range and y-range but not region - * (which uses ked.data, i.e. rectf) + * (which uses ked.data, i.e. rectf) */ if (mode != BEZT_OK_VALUERANGE) { - ked.f1= rectf.xmin; - ked.f2= rectf.xmax; + ked.f1 = rectf.xmin; + ked.f2 = rectf.xmax; } else { - ked.f1= rectf.ymin; - ked.f2= rectf.ymax; + ked.f1 = rectf.ymin; + ked.f2 = rectf.ymax; } /* firstly, check if any keyframes will be hit by this */ @@ -275,10 +275,10 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho /* un-apply NLA mapping from all the keyframes */ if (adt) - ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles==0); + ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, incl_handles == 0); /* unapply unit corrections */ - ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE|mapping_flag); + ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, ANIM_UNITCONV_RESTORE | mapping_flag); } /* cleanup */ @@ -291,7 +291,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short mode=0, selectmode=0; + short mode = 0, selectmode = 0; short incl_handles; int extend; @@ -300,7 +300,7 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_graph_keys(&ac, 1, SELECT_SUBTRACT, TRUE); @@ -308,10 +308,10 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) * - 'gesture_mode' from the operator specifies how to select * - 'include_handles' from the operator specifies whether to include handles in the selection */ - if (RNA_int_get(op->ptr, "gesture_mode")==GESTURE_MODAL_SELECT) - selectmode= SELECT_ADD; + if (RNA_int_get(op->ptr, "gesture_mode") == GESTURE_MODAL_SELECT) + selectmode = SELECT_ADD; else - selectmode= SELECT_SUBTRACT; + selectmode = SELECT_SUBTRACT; incl_handles = RNA_boolean_get(op->ptr, "include_handles"); @@ -329,18 +329,18 @@ static int graphkeys_borderselect_exec(bContext *C, wmOperator *op) * used for tweaking timing when "blocking", while channels is not that useful... */ if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) - mode= BEZT_OK_FRAMERANGE; + mode = BEZT_OK_FRAMERANGE; else - mode= BEZT_OK_VALUERANGE; + mode = BEZT_OK_VALUERANGE; } else - mode= BEZT_OK_REGION; + mode = BEZT_OK_REGION; /* apply borderselect action */ borderselect_graphkeys(&ac, rect, mode, selectmode, incl_handles); /* send notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -361,7 +361,7 @@ void GRAPH_OT_select_border(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* rna */ WM_operator_properties_gesture_border(ot, TRUE); @@ -392,14 +392,14 @@ static EnumPropertyItem prop_column_select_types[] = { /* Selects all visible keyframes between the specified markers */ /* TODO, this is almost an _exact_ duplicate of a function of the same name in action_select.c * should de-duplicate - campbell */ -static void markers_selectkeys_between (bAnimContext *ac) +static void markers_selectkeys_between(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; float min, max; /* get extreme markers */ @@ -408,19 +408,19 @@ static void markers_selectkeys_between (bAnimContext *ac) max += 0.5f; /* get editing funcs + data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); - ked.f1= min; - ked.f2= max; + ked.f1 = min; + ked.f2 = max; /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys in-between */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -438,13 +438,13 @@ static void markers_selectkeys_between (bAnimContext *ac) /* Selects all visible keyframes in the same frames as the specified elements */ -static void columnselect_graph_keys (bAnimContext *ac, short mode) +static void columnselect_graph_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - Scene *scene= ac->scene; + Scene *scene = ac->scene; CfraElem *ce; KeyframeEditFunc select_cb, ok_cb; KeyframeEditData ked; @@ -455,10 +455,10 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) /* build list of columns */ switch (mode) { case GRAPHKEYS_COLUMNSEL_KEYS: /* list of selected keys */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) + for (ale = anim_data.first; ale; ale = ale->next) ANIM_fcurve_keyframes_loop(&ked, ale->key_data, NULL, bezt_to_cfraelem, NULL); BLI_freelistN(&anim_data); @@ -466,10 +466,10 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) case GRAPHKEYS_COLUMNSEL_CFRA: /* current frame */ /* make a single CfraElem for storing this */ - ce= MEM_callocN(sizeof(CfraElem), "cfraElem"); + ce = MEM_callocN(sizeof(CfraElem), "cfraElem"); BLI_addtail(&ked.list, ce); - ce->cfra= (float)CFRA; + ce->cfra = (float)CFRA; break; case GRAPHKEYS_COLUMNSEL_MARKERS_COLUMN: /* list of selected markers */ @@ -481,24 +481,24 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) } /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(SELECT_ADD); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(SELECT_ADD); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* loop over cfraelems (stored in the KeyframeEditData->list) * - we need to do this here, as we can apply fewer NLA-mapping conversions */ - for (ce= ked.list.first; ce; ce= ce->next) { + for (ce = ked.list.first; ce; ce = ce->next) { /* set frame for validation callback to refer to */ - ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); /* select elements with frame number matching cfraelem */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -522,7 +522,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* action to take depends on the mode */ - mode= RNA_enum_get(op->ptr, "mode"); + mode = RNA_enum_get(op->ptr, "mode"); if (mode == GRAPHKEYS_COLUMNSEL_MARKERS_BETWEEN) markers_selectkeys_between(&ac); @@ -530,7 +530,7 @@ static int graphkeys_columnselect_exec(bContext *C, wmOperator *op) columnselect_graph_keys(&ac, mode); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -547,7 +547,7 @@ void GRAPH_OT_select_column(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_column_select_types, 0, "Mode", ""); @@ -555,11 +555,11 @@ void GRAPH_OT_select_column(wmOperatorType *ot) /* ******************** Select Linked Operator *********************** */ -static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) +static int graphkeys_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -571,11 +571,11 @@ static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* check if anything selected? */ if (ANIM_fcurve_keyframes_loop(NULL, fcu, NULL, ok_cb, NULL)) { @@ -588,7 +588,7 @@ static int graphkeys_select_linked_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -605,15 +605,15 @@ void GRAPH_OT_select_linked(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select More/Less Operators *********************** */ /* Common code to perform selection */ -static void select_moreless_graph_keys (bAnimContext *ac, short mode) +static void select_moreless_graph_keys(bAnimContext *ac, short mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -622,22 +622,22 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode) /* init selmap building data */ - build_cb= ANIM_editkeyframes_buildselmap(mode); + build_cb = ANIM_editkeyframes_buildselmap(mode); memset(&ked, 0, sizeof(KeyframeEditData)); /* loop through all of the keys and select additional keyframes based on these */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; /* only continue if F-Curve has keyframes */ if (fcu->bezt == NULL) continue; /* build up map of whether F-Curve's keyframes should be selected or not */ - ked.data= MEM_callocN(fcu->totvert, "selmap graphEdit"); + ked.data = MEM_callocN(fcu->totvert, "selmap graphEdit"); ANIM_fcurve_keyframes_loop(&ked, fcu, NULL, build_cb, NULL); /* based on this map, adjust the selection status of the keyframes */ @@ -645,7 +645,7 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode) /* free the selmap used here */ MEM_freeN(ked.data); - ked.data= NULL; + ked.data = NULL; } /* Cleanup */ @@ -654,7 +654,7 @@ static void select_moreless_graph_keys (bAnimContext *ac, short mode) /* ----------------- */ -static int graphkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) +static int graphkeys_select_more_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -666,7 +666,7 @@ static int graphkeys_select_more_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_graph_keys(&ac, SELMAP_MORE); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -683,12 +683,12 @@ void GRAPH_OT_select_more(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ----------------- */ -static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) +static int graphkeys_select_less_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -700,7 +700,7 @@ static int graphkeys_select_less_exec (bContext *C, wmOperator *UNUSED(op)) select_moreless_graph_keys(&ac, SELMAP_LESS); /* set notifier that keyframe selection has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -717,7 +717,7 @@ void GRAPH_OT_select_less(wmOperatorType *ot) ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; } /* ******************** Select Left/Right Operator ************************* */ @@ -733,19 +733,19 @@ static EnumPropertyItem prop_graphkeys_leftright_select_types[] = { /* --------------------------------- */ -static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short select_mode) +static void graphkeys_select_leftright(bAnimContext *ac, short leftright, short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; KeyframeEditFunc ok_cb, select_cb; - KeyframeEditData ked= {{NULL}}; - Scene *scene= ac->scene; + KeyframeEditData ked = {{NULL}}; + Scene *scene = ac->scene; /* if select mode is replace, deselect all keyframes (and channels) first */ - if (select_mode==SELECT_REPLACE) { - select_mode= SELECT_ADD; + if (select_mode == SELECT_REPLACE) { + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -754,8 +754,8 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short } /* set callbacks and editing data */ - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); - select_cb= ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAMERANGE); + select_cb = ANIM_editkeyframes_select(select_mode); if (leftright == GRAPHKEYS_LRSEL_LEFT) { ked.f1 = MINAFRAMEF; @@ -767,12 +767,12 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short } /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select keys */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); if (adt) { ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1); @@ -789,7 +789,7 @@ static void graphkeys_select_leftright (bAnimContext *ac, short leftright, short /* ----------------- */ -static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op) +static int graphkeys_select_leftright_exec(bContext *C, wmOperator *op) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -801,9 +801,9 @@ static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op) /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* if "test" mode is set, we don't have any info to set this with */ if (leftright == GRAPHKEYS_LRSEL_TEST) @@ -813,12 +813,12 @@ static int graphkeys_select_leftright_exec (bContext *C, wmOperator *op) graphkeys_select_leftright(&ac, leftright, selectmode); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int graphkeys_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -829,9 +829,9 @@ static int graphkeys_select_leftright_invoke (bContext *C, wmOperator *op, wmEve /* handle mode-based testing */ if (leftright == GRAPHKEYS_LRSEL_TEST) { - Scene *scene= ac.scene; - ARegion *ar= ac.ar; - View2D *v2d= &ar->v2d; + Scene *scene = ac.scene; + ARegion *ar = ac.ar; + View2D *v2d = &ar->v2d; float x; /* determine which side of the current frame mouse is on */ @@ -854,12 +854,12 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot) ot->description = "Select keyframes to the left or the right of the current frame"; /* api callbacks */ - ot->invoke= graphkeys_select_leftright_invoke; + ot->invoke = graphkeys_select_leftright_invoke; ot->exec = graphkeys_select_leftright_exec; ot->poll = graphop_visible_keyframes_poll; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_graphkeys_leftright_select_types, GRAPHKEYS_LRSEL_TEST, "Mode", ""); @@ -880,26 +880,26 @@ void GRAPH_OT_select_leftright(wmOperatorType *ot) typedef struct tNearestVertInfo { struct tNearestVertInfo *next, *prev; - FCurve *fcu; /* F-Curve that keyframe comes from */ + FCurve *fcu; /* F-Curve that keyframe comes from */ - BezTriple *bezt; /* keyframe to consider */ - FPoint *fpt; /* sample point to consider */ + BezTriple *bezt; /* keyframe to consider */ + FPoint *fpt; /* sample point to consider */ - short hpoint; /* the handle index that we hit (eHandleIndex) */ - short sel; /* whether the handle is selected or not */ - int dist; /* distance from mouse to vert */ + short hpoint; /* the handle index that we hit (eHandleIndex) */ + short sel; /* whether the handle is selected or not */ + int dist; /* distance from mouse to vert */ } tNearestVertInfo; /* Tags for the type of graph vert that we have */ typedef enum eGraphVertIndex { - NEAREST_HANDLE_LEFT = -1, + NEAREST_HANDLE_LEFT = -1, NEAREST_HANDLE_KEY, NEAREST_HANDLE_RIGHT } eGraphVertIndex; /* Tolerance for absolute radius (in pixels) of the vert from the cursor to use */ // TODO: perhaps this should depend a bit on the size that the user set the vertices to be? -#define GVERTSEL_TOL 10 +#define GVERTSEL_TOL 10 /* ....... */ @@ -908,13 +908,13 @@ typedef enum eGraphVertIndex { static int fcurve_handle_sel_check(SpaceIpo *sipo, BezTriple *bezt) { if (sipo->flag & SIPO_NOHANDLES) return 0; - if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt)==0) return 0; + if ((sipo->flag & SIPO_SELVHANDLESONLY) && BEZSELECTED(bezt) == 0) return 0; return 1; } /* check if the given vertex is within bounds or not */ // TODO: should we return if we hit something? -static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2]) +static void nearest_fcurve_vert_store(ListBase *matches, View2D *v2d, FCurve *fcu, BezTriple *bezt, FPoint *fpt, short hpoint, const int mval[2]) { /* Keyframes or Samples? */ if (bezt) { @@ -922,16 +922,16 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f /* convert from data-space to screen coordinates * NOTE: hpoint+1 gives us 0,1,2 respectively for each handle, - * needed to access the relevant vertex coordinates in the 3x3 - * 'vec' matrix + * needed to access the relevant vertex coordinates in the 3x3 + * 'vec' matrix */ - UI_view2d_view_to_region(v2d, bezt->vec[hpoint+1][0], bezt->vec[hpoint+1][1], &screen_co[0], &screen_co[1]); + UI_view2d_view_to_region(v2d, bezt->vec[hpoint + 1][0], bezt->vec[hpoint + 1][1], &screen_co[0], &screen_co[1]); /* check if distance from mouse cursor to vert in screen space is within tolerance */ - // XXX: inlined distance calculation, since we cannot do this on ints using the math lib... + // XXX: inlined distance calculation, since we cannot do this on ints using the math lib... //dist = len_v2v2(mval, screen_co); - dist = sqrt((mval[0] - screen_co[0])*(mval[0] - screen_co[0]) + - (mval[1] - screen_co[1])*(mval[1] - screen_co[1])); + dist = sqrt((mval[0] - screen_co[0]) * (mval[0] - screen_co[0]) + + (mval[1] - screen_co[1]) * (mval[1] - screen_co[1])); if (dist <= GVERTSEL_TOL) { tNearestVertInfo *nvi = (tNearestVertInfo *)matches->last; @@ -941,7 +941,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f if ((nvi) && (nvi->fcu == fcu)) { /* replace if we are closer, or if equal and that one wasn't selected but we are... */ if ( (nvi->dist > dist) || ((nvi->sel == 0) && BEZSELECTED(bezt)) ) - replace= 1; + replace = 1; } /* add new if not replacing... */ if (replace == 0) @@ -953,7 +953,7 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f nvi->hpoint = hpoint; nvi->dist = dist; - nvi->sel= BEZSELECTED(bezt); // XXX... should this use the individual verts instead? + nvi->sel = BEZSELECTED(bezt); // XXX... should this use the individual verts instead? /* add to list of matches if appropriate... */ if (replace == 0) @@ -966,27 +966,27 @@ static void nearest_fcurve_vert_store (ListBase *matches, View2D *v2d, FCurve *f } /* helper for find_nearest_fcurve_vert() - build the list of nearest matches */ -static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ListBase *matches) +static void get_nearest_fcurve_verts_list(bAnimContext *ac, const int mval[2], ListBase *matches) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - SpaceIpo *sipo= (SpaceIpo *)ac->sl; - View2D *v2d= &ac->ar->v2d; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; + View2D *v2d = &ac->ar->v2d; /* get curves to search through * - if the option to only show keyframes that belong to selected F-Curves is enabled, * include the 'only selected' flag... */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); - if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code... + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + if (sipo->flag & SIPO_SELCUVERTSONLY) // FIXME: this should really be check for by the filtering code... filter |= ANIMFILTER_SEL; ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->key_data; - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->key_data; + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* apply unit corrections */ ANIM_unit_mapping_apply_fcurve(ac->scene, ale->id, ale->key_data, 0); @@ -996,17 +996,17 @@ static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0); if (fcu->bezt) { - BezTriple *bezt1=fcu->bezt, *prevbezt=NULL; + BezTriple *bezt1 = fcu->bezt, *prevbezt = NULL; int i; - for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) { + for (i = 0; i < fcu->totvert; i++, prevbezt = bezt1, bezt1++) { /* keyframe */ nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_KEY, mval); /* handles - only do them if they're visible */ if (fcurve_handle_sel_check(sipo, bezt1) && (fcu->totvert > 1)) { /* first handle only visible if previous segment had handles */ - if ((!prevbezt && (bezt1->ipo==BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo==BEZT_IPO_BEZ))) { + if ((!prevbezt && (bezt1->ipo == BEZT_IPO_BEZ)) || (prevbezt && (prevbezt->ipo == BEZT_IPO_BEZ))) { nearest_fcurve_vert_store(matches, v2d, fcu, bezt1, NULL, NEAREST_HANDLE_LEFT, mval); } @@ -1035,7 +1035,7 @@ static void get_nearest_fcurve_verts_list (bAnimContext *ac, const int mval[2], } /* helper for find_nearest_fcurve_vert() - get the best match to use */ -static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) +static tNearestVertInfo *get_best_nearest_fcurve_vert(ListBase *matches) { tNearestVertInfo *nvi = NULL; short found = 0; @@ -1047,7 +1047,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) /* if list only has 1 item, remove it from the list and return */ if (matches->first == matches->last) { /* need to remove from the list, otherwise it gets freed and then we can't return it */ - nvi= matches->first; + nvi = matches->first; BLI_remlink(matches, nvi); return nvi; @@ -1066,7 +1066,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) else { /* if vert is selected, we've got what we want... */ if (nvi->sel) - found= 1; + found = 1; } } @@ -1081,7 +1081,7 @@ static tNearestVertInfo *get_best_nearest_fcurve_vert (ListBase *matches) /* Find the nearest vertices (either a handle or the keyframe) that are nearest to the mouse cursor (in area coordinates) * NOTE: the match info found must still be freed */ -static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int mval[2]) +static tNearestVertInfo *find_nearest_fcurve_vert(bAnimContext *ac, const int mval[2]) { ListBase matches = {NULL, NULL}; tNearestVertInfo *nvi; @@ -1090,7 +1090,7 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int m get_nearest_fcurve_verts_list(ac, mval, &matches); /* step 2: find the best vert */ - nvi= get_best_nearest_fcurve_vert(&matches); + nvi = get_best_nearest_fcurve_vert(&matches); BLI_freelistN(&matches); @@ -1101,11 +1101,11 @@ static tNearestVertInfo *find_nearest_fcurve_vert (bAnimContext *ac, const int m /* ------------------- */ /* option 1) select keyframe directly under mouse */ -static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_mode, short curves_only) +static void mouse_graph_keys(bAnimContext *ac, const int mval[2], short select_mode, short curves_only) { - SpaceIpo *sipo= (SpaceIpo *)ac->sl; + SpaceIpo *sipo = (SpaceIpo *)ac->sl; tNearestVertInfo *nvi; - BezTriple *bezt= NULL; + BezTriple *bezt = NULL; /* find the beztriple that we're selecting, and the handle that was clicked on */ nvi = find_nearest_fcurve_vert(ac, mval); @@ -1117,7 +1117,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* deselect all other curves? */ if (select_mode == SELECT_REPLACE) { /* reset selection mode */ - select_mode= SELECT_ADD; + select_mode = SELECT_ADD; /* deselect all other keyframes (+ F-Curves too) */ deselect_graph_keys(ac, 0, SELECT_SUBTRACT, TRUE); @@ -1132,10 +1132,10 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* if points can be selected on this F-Curve */ // TODO: what about those with no keyframes? - if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED)==0)) { + if ((curves_only == 0) && ((nvi->fcu->flag & FCURVE_PROTECTED) == 0)) { /* only if there's keyframe */ if (nvi->bezt) { - bezt= nvi->bezt; /* used to check bezt seletion is set */ + bezt = nvi->bezt; /* used to check bezt seletion is set */ /* depends on selection mode */ if (select_mode == SELECT_INVERT) { /* keyframe - invert select of all */ @@ -1182,7 +1182,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ memset(&ked, 0, sizeof(KeyframeEditData)); /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(select_mode); + select_cb = ANIM_editkeyframes_select(select_mode); /* select all keyframes */ ANIM_fcurve_keyframes_loop(&ked, nvi->fcu, NULL, select_cb, NULL); @@ -1212,7 +1212,7 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* set active F-Curve (NOTE: sync the filter flags with findnearest_fcurve_vert) */ /* needs to be called with (sipo->flag & SIPO_SELCUVERTSONLY) otherwise the active flag won't be set [#26452] */ if (nvi->fcu->flag & FCURVE_SELECTED) { - int filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nvi->fcu, ANIMTYPE_FCURVE); } @@ -1224,9 +1224,9 @@ static void mouse_graph_keys (bAnimContext *ac, const int mval[2], short select_ /* (see graphkeys_select_leftright) */ /* Option 3) Selects all visible keyframes in the same frame as the mouse click */ -static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short select_mode) +static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short select_mode) { - ListBase anim_data= {NULL, NULL}; + ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; @@ -1245,14 +1245,14 @@ static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short /* get frame number on which elements should be selected */ // TODO: should we restrict to integer frames only? if (nvi->bezt) - selx= nvi->bezt->vec[1][0]; + selx = nvi->bezt->vec[1][0]; else if (nvi->fpt) - selx= nvi->fpt->vec[0]; + selx = nvi->fpt->vec[0]; /* if select mode is replace, deselect all keyframes first */ - if (select_mode==SELECT_REPLACE) { + if (select_mode == SELECT_REPLACE) { /* reset selection mode to add to selection */ - select_mode= SELECT_ADD; + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -1264,23 +1264,23 @@ static void graphkeys_mselect_column (bAnimContext *ac, const int mval[2], short memset(&ked, 0, sizeof(KeyframeEditData)); /* set up BezTriple edit callbacks */ - select_cb= ANIM_editkeyframes_select(select_mode); - ok_cb= ANIM_editkeyframes_ok(BEZT_OK_FRAME); + select_cb = ANIM_editkeyframes_select(select_mode); + ok_cb = ANIM_editkeyframes_ok(BEZT_OK_FRAME); /* loop through all of the keys and select additional keyframes * based on the keys found to be selected above */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ANIM_nla_mapping_get(ac, ale); + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ANIM_nla_mapping_get(ac, ale); /* set frame for validation callback to refer to */ if (adt) - ked.f1= BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); + ked.f1 = BKE_nla_tweakedit_remap(adt, selx, NLATIME_CONVERT_UNMAP); else - ked.f1= selx; + ked.f1 = selx; /* select elements with frame number matching cfra */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); @@ -1306,9 +1306,9 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* figure out action to take */ if (RNA_boolean_get(op->ptr, "column")) { @@ -1325,10 +1325,10 @@ static int graphkeys_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *ev } /* set notifier that keyframe selection (and also channel selection in some cases) has changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); /* for tweak grab to work */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } void GRAPH_OT_clickselect(wmOperatorType *ot) diff --git a/source/blender/editors/space_graph/graph_utils.c b/source/blender/editors/space_graph/graph_utils.c index 46c886b7d3c..93dfd3644dd 100644 --- a/source/blender/editors/space_graph/graph_utils.c +++ b/source/blender/editors/space_graph/graph_utils.c @@ -54,7 +54,7 @@ #include "ED_anim_api.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" // own include /* ************************************************************** */ /* Active F-Curve */ @@ -65,17 +65,17 @@ * * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome */ -bAnimListElem *get_active_fcurve_channel (bAnimContext *ac) +bAnimListElem *get_active_fcurve_channel(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; - int filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE); + int filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_ACTIVE); size_t items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* We take the first F-Curve only, since some other ones may have had 'active' flag set * if they were from linked data. */ if (items) { - bAnimListElem *ale= (bAnimListElem *)anim_data.first; + bAnimListElem *ale = (bAnimListElem *)anim_data.first; /* remove first item from list, then free the rest of the list and return the stored one */ BLI_remlink(&anim_data, ale); @@ -97,7 +97,7 @@ int graphop_visible_keyframes_poll(bContext *C) bAnimContext ac; bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); size_t items; int filter; short found = 0; @@ -114,13 +114,13 @@ int graphop_visible_keyframes_poll(bContext *C) /* loop over the visible (selection doesn't matter) F-Curves, and see if they're suitable * stopping on the first successful match */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) return 0; - for (ale = anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; /* visible curves for selection must fulfill the following criteria: * - it has bezier keyframes @@ -146,7 +146,7 @@ int graphop_editable_keyframes_poll(bContext *C) bAnimContext ac; bAnimListElem *ale; ListBase anim_data = {NULL, NULL}; - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); size_t items; int filter; short found = 0; @@ -163,13 +163,13 @@ int graphop_editable_keyframes_poll(bContext *C) /* loop over the editable F-Curves, and see if they're suitable * stopping on the first successful match */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_FOREDIT | ANIMFILTER_CURVE_VISIBLE); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) return 0; - for (ale = anim_data.first; ale; ale= ale->next) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + FCurve *fcu = (FCurve *)ale->data; /* editable curves must fulfill the following criteria: * - it has bezier keyframes @@ -195,8 +195,8 @@ int graphop_active_fcurve_poll(bContext *C) { bAnimContext ac; bAnimListElem *ale; - ScrArea *sa= CTX_wm_area(C); - short has_fcurve= 0; + ScrArea *sa = CTX_wm_area(C); + short has_fcurve = 0; /* firstly, check if in Graph Editor */ // TODO: also check for region? @@ -208,15 +208,15 @@ int graphop_active_fcurve_poll(bContext *C) return 0; /* try to get the Active F-Curve */ - ale= get_active_fcurve_channel(&ac); + ale = get_active_fcurve_channel(&ac); if (ale == NULL) return 0; /* free temp data... */ - has_fcurve= ((ale->data) && (ale->type == ANIMTYPE_FCURVE)); + has_fcurve = ((ale->data) && (ale->type == ANIMTYPE_FCURVE)); if (has_fcurve) { - FCurve *fcu= (FCurve *)ale->data; - has_fcurve= (fcu->flag & FCURVE_VISIBLE)!=0; + FCurve *fcu = (FCurve *)ale->data; + has_fcurve = (fcu->flag & FCURVE_VISIBLE) != 0; } MEM_freeN(ale); @@ -230,7 +230,7 @@ int graphop_selected_fcurve_poll(bContext *C) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; - ScrArea *sa= CTX_wm_area(C); + ScrArea *sa = CTX_wm_area(C); size_t items; int filter; @@ -246,7 +246,7 @@ int graphop_selected_fcurve_poll(bContext *C) /* get the editable + selected F-Curves, and as long as we got some, we can return * NOTE: curve-visible flag isn't included, otherwise selecting a curve via list to edit is too cumbersome */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) return 0; diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c index 1b60a0a39ac..ffff86df4eb 100644 --- a/source/blender/editors/space_graph/space_graph.c +++ b/source/blender/editors/space_graph/space_graph.c @@ -61,7 +61,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "graph_intern.h" // own include +#include "graph_intern.h" // own include /* ******************** manage regions ********************* */ @@ -69,20 +69,20 @@ ARegion *graph_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after main */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for graph"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for graph"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; @@ -94,71 +94,71 @@ ARegion *graph_has_buttons_region(ScrArea *sa) static SpaceLink *graph_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceIpo *sipo; /* Graph Editor - general stuff */ - sipo= MEM_callocN(sizeof(SpaceIpo), "init graphedit"); - sipo->spacetype= SPACE_IPO; + sipo = MEM_callocN(sizeof(SpaceIpo), "init graphedit"); + sipo->spacetype = SPACE_IPO; - sipo->autosnap= SACTSNAP_FRAME; + sipo->autosnap = SACTSNAP_FRAME; /* allocate DopeSheet data for Graph Editor */ - sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source= (ID *)scene; + sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); + sipo->ads->source = (ID *)scene; /* settings for making it easier by default to just see what you're interested in tweaking */ sipo->ads->filterflag |= ADS_FILTER_ONLYSEL; sipo->flag |= SIPO_SELVHANDLESONLY; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "header for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* channels */ - ar= MEM_callocN(sizeof(ARegion), "channels area for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "channels area for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM); + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); /* ui buttons */ - ar= MEM_callocN(sizeof(ARegion), "buttons area for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "buttons area for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for graphedit"); + ar = MEM_callocN(sizeof(ARegion), "main area for graphedit"); BLI_addtail(&sipo->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = 0.0f; ar->v2d.tot.ymin = (float)scene->r.sfra - 10.0f; ar->v2d.tot.xmax = (float)scene->r.efra; ar->v2d.tot.ymax = 10.0f; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= FLT_MIN; - ar->v2d.min[1]= FLT_MIN; + ar->v2d.min[0] = FLT_MIN; + ar->v2d.min[1] = FLT_MIN; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= FLT_MAX; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = FLT_MAX; - ar->v2d.scroll= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); - ar->v2d.scroll |= (V2D_SCROLL_LEFT|V2D_SCROLL_SCALE_VERTICAL); + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_LEFT | V2D_SCROLL_SCALE_VERTICAL); - ar->v2d.keeptot= 0; + ar->v2d.keeptot = 0; return (SpaceLink *)sipo; } @@ -166,7 +166,7 @@ static SpaceLink *graph_new(const bContext *C) /* not spacelink itself */ static void graph_free(SpaceLink *sl) { - SpaceIpo *si= (SpaceIpo *)sl; + SpaceIpo *si = (SpaceIpo *)sl; if (si->ads) { BLI_freelistN(&si->ads->chanbase); @@ -181,12 +181,12 @@ static void graph_free(SpaceLink *sl) /* spacetype; init callback */ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first; + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; /* init dopesheet data if non-existant (i.e. for old files) */ if (sipo->ads == NULL) { - sipo->ads= MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); - sipo->ads->source= (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... + sipo->ads = MEM_callocN(sizeof(bDopeSheet), "GraphEdit DopeSheet"); + sipo->ads->source = (ID *)(G.main->scene.first); // FIXME: this is a really nasty hack here for now... } ED_area_tag_refresh(sa); @@ -194,11 +194,11 @@ static void graph_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *graph_duplicate(SpaceLink *sl) { - SpaceIpo *sipon= MEM_dupallocN(sl); + SpaceIpo *sipon = MEM_dupallocN(sl); /* clear or remove stuff from old */ BLI_duplicatelist(&sipon->ghostCurves, &((SpaceIpo *)sl)->ghostCurves); - sipon->ads= MEM_dupallocN(sipon->ads); + sipon->ads = MEM_dupallocN(sipon->ads); return (SpaceLink *)sipon; } @@ -220,13 +220,13 @@ static void graph_main_area_init(wmWindowManager *wm, ARegion *ar) static void graph_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceIpo *sipo= CTX_wm_space_graph(C); + SpaceIpo *sipo = CTX_wm_space_graph(C); bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; float col[3]; - short unitx=0, unity=V2D_UNIT_VALUES, flag=0; + short unitx = 0, unity = V2D_UNIT_VALUES, flag = 0; /* clear and setup matrix */ UI_GetThemeColor3fv(TH_BACK, col); @@ -236,8 +236,8 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* grid */ - unitx= (sipo->flag & SIPO_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; - grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); + unitx = (sipo->flag & SIPO_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMESCALE; + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); /* draw data */ @@ -260,29 +260,29 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_grid_free(grid); /* horizontal component of value-cursor (value line before the current frame line) */ - if ((sipo->flag & SIPO_NODRAWCURSOR)==0) { + if ((sipo->flag & SIPO_NODRAWCURSOR) == 0) { float vec[2]; /* Draw a green line to indicate the cursor value */ - vec[1]= sipo->cursorVal; + vec[1] = sipo->cursorVal; UI_ThemeColorShadeAlpha(TH_CFRAME, -10, -50); glLineWidth(2.0); glEnable(GL_BLEND); glBegin(GL_LINE_STRIP); - vec[0]= v2d->cur.xmin; - glVertex2fv(vec); + vec[0] = v2d->cur.xmin; + glVertex2fv(vec); - vec[0]= v2d->cur.xmax; - glVertex2fv(vec); + vec[0] = v2d->cur.xmax; + glVertex2fv(vec); glEnd(); // GL_LINE_STRIP glDisable(GL_BLEND); } /* current frame */ - if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((sipo->flag & SIPO_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; + if (sipo->flag & SIPO_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((sipo->flag & SIPO_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ @@ -297,8 +297,8 @@ static void graph_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - // FIXME: args for scrollers depend on the type of data being shown... - scrollers= UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); + // FIXME: args for scrollers depend on the type of data being shown... + scrollers = UI_view2d_scrollers_calc(C, v2d, unitx, V2D_GRID_NOCLAMP, unity, V2D_GRID_NOCLAMP); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -319,7 +319,7 @@ static void graph_channel_area_init(wmWindowManager *wm, ARegion *ar) static void graph_channel_area_draw(const bContext *C, ARegion *ar) { bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; float col[3]; @@ -332,14 +332,14 @@ static void graph_channel_area_draw(const bContext *C, ARegion *ar) /* draw channels */ if (ANIM_animdata_get_context(C, &ac)) { - graph_draw_channel_names((bContext*)C, &ac, ar); + graph_draw_channel_names((bContext *)C, &ac, ar); } /* reset view matrix */ UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -418,7 +418,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } @@ -427,7 +427,7 @@ static void graph_region_listener(ARegion *ar, wmNotifier *wmn) /* editor level listener */ static void graph_listener(ScrArea *sa, wmNotifier *wmn) { - SpaceIpo *sipo= (SpaceIpo *)sa->spacedata.first; + SpaceIpo *sipo = (SpaceIpo *)sa->spacedata.first; /* context changes */ switch (wmn->category) { @@ -440,7 +440,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_SCENE: switch (wmn->data) { - case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_OB_ACTIVE: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_OB_SELECT: sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -453,7 +453,7 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) break; case NC_OBJECT: switch (wmn->data) { - case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ + case ND_BONE_SELECT: /* selection changed, so force refresh to flush (needs flag set to do syncing) */ case ND_BONE_ACTIVE: sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); @@ -472,16 +472,16 @@ static void graph_listener(ScrArea *sa, wmNotifier *wmn) sipo->flag |= SIPO_TEMP_NEEDCHANSYNC; ED_area_tag_refresh(sa); } - break; + break; case NC_SPACE: if (wmn->data == ND_SPACE_GRAPH) ED_area_tag_redraw(sa); break; - // XXX: restore the case below if not enough updates occur... - //default: - // if (wmn->data==ND_KEYS) - // ED_area_tag_redraw(sa); + // XXX: restore the case below if not enough updates occur... + //default: + // if (wmn->data==ND_KEYS) + // ED_area_tag_redraw(sa); } } @@ -498,13 +498,13 @@ static void graph_refresh(const bContext *C, ScrArea *sa) { } - break; + break; case SIPO_MODE_DRIVERS: /* drivers only */ { } - break; + break; } /* region updates? */ @@ -528,15 +528,15 @@ static void graph_refresh(const bContext *C, ScrArea *sa) int i; /* build list of F-Curves which will be visible as channels in channel-region - * - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a - * mismatch between channel-colors and the drawn curves + * - we don't include ANIMFILTER_CURVEVISIBLE filter, as that will result in a + * mismatch between channel-colors and the drawn curves */ - filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_NODUPLIS); - items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_NODUPLIS); + items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop over F-Curves, assigning colors */ - for (ale=anim_data.first, i=0; ale; ale= ale->next, i++) { - FCurve *fcu= (FCurve *)ale->data; + for (ale = anim_data.first, i = 0; ale; ale = ale->next, i++) { + FCurve *fcu = (FCurve *)ale->data; /* set color of curve here */ switch (fcu->color_mode) { @@ -551,7 +551,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. * TODO: find a way to module the hue so that not all curves have same color... */ - float *col= fcu->color; + float *col = fcu->color; switch (fcu->array_index) { case 0: @@ -569,7 +569,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) break; } } - break; + break; case FCURVE_COLOR_AUTO_RAINBOW: default: @@ -579,7 +579,7 @@ static void graph_refresh(const bContext *C, ScrArea *sa) */ getcolor_fcurve_rainbow(i, items, fcu->color); } - break; + break; } } @@ -591,10 +591,10 @@ static void graph_refresh(const bContext *C, ScrArea *sa) /* only called once, from space/spacetypes.c */ void ED_spacetype_ipo(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype ipo"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype ipo"); ARegionType *art; - st->spaceid= SPACE_IPO; + st->spaceid = SPACE_IPO; strncpy(st->name, "Graph", BKE_ST_MAXNAME); st->new = graph_new; @@ -612,7 +612,7 @@ void ED_spacetype_ipo(void) art->init = graph_main_area_init; art->draw = graph_main_area_draw; art->listener = graph_region_listener; - art->keymapflag = ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); @@ -620,7 +620,7 @@ void ED_spacetype_ipo(void) art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_HEADER; art->prefsizey = HEADERY; - art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; art->listener = graph_region_listener; art->init = graph_header_area_init; art->draw = graph_header_area_draw; @@ -631,7 +631,7 @@ void ED_spacetype_ipo(void) art = MEM_callocN(sizeof(ARegionType), "spacetype graphedit region"); art->regionid = RGN_TYPE_CHANNELS; art->prefsizex = 200 + V2D_SCROLL_WIDTH; /* 200 is the 'standard', but due to scrollers, we want a bit more to fit the lock icons in */ - art->keymapflag = ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES; art->listener = graph_region_listener; art->init = graph_channel_area_init; art->draw = graph_channel_area_draw; diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index ecbd9a4033a..de171bc45f8 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -146,7 +146,7 @@ static void image_info(Scene *scene, ImageUser *iuser, Image *ima, ImBuf *ibuf, /* the frame number, even if we cant */ if (ima->source == IMA_SRC_SEQUENCE) { /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */ - const int framenr = BKE_image_user_get_frame(iuser, CFRA, 0); + const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0); ofs += sprintf(str + ofs, ", Frame: %d", framenr); } @@ -430,7 +430,7 @@ static void set_frames_cb(bContext *C, void *ima_v, void *iuser_v) if (ima->anim) { iuser->frames = IMB_anim_get_duration(ima->anim, IMB_TC_RECORD_RUN); - BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(iuser, scene->r.cfra, 0); } } diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index bbc12520978..58fbceb999d 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -833,7 +833,7 @@ static int image_open_exec(bContext *C, wmOperator *op) errno = 0; - ima = BKE_add_image_file(str); + ima = BKE_image_load_exists(str); if (!ima) { if (op->customdata) MEM_freeN(op->customdata); @@ -1150,7 +1150,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI /* TODO, better solution, if a 24bit image is painted onto it may contain alpha */ if (ibuf->userflags & IB_BITMAPDIRTY) { /* it has been painted onto */ /* checks each pixel, not ideal */ - ibuf->planes = BKE_alphatest_ibuf(ibuf) ? 32 : 24; + ibuf->planes = BKE_imbuf_alpha_test(ibuf) ? 32 : 24; } } @@ -1167,7 +1167,7 @@ static void save_image_doit(bContext *C, SpaceImage *sima, wmOperator *op, SaveI BKE_image_release_renderresult(scene, ima); } else { - if (BKE_write_ibuf_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { + if (BKE_imbuf_write_as(ibuf, simopts->filepath, &simopts->im_format, save_copy)) { ok = TRUE; } } @@ -1528,7 +1528,7 @@ static int image_new_exec(bContext *C, wmOperator *op) if (!alpha) color[3] = 1.0f; - ima = BKE_add_image_size(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); + ima = BKE_image_add_generated(width, height, name, alpha ? 32 : 24, floatbuf, uvtestgrid, color); if (!ima) return OPERATOR_CANCELLED; @@ -2173,7 +2173,7 @@ void IMAGE_OT_curves_point_set(wmOperatorType *ot) /* identifiers */ ot->name = "Set Curves Point"; ot->idname = "IMAGE_OT_curves_point_set"; - ot->description = "Set black or white point for curves"; + ot->description = "Set black point or white point for curves"; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; @@ -2408,7 +2408,7 @@ void ED_image_update_frame(const Main *mainp, int cfra) if (tex->type == TEX_IMAGE && tex->ima) { if (ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { if (tex->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&tex->iuser, cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, cfra, 0); } } } @@ -2423,12 +2423,12 @@ void ED_image_update_frame(const Main *mainp, int cfra) BGpic *bgpic; for (bgpic = v3d->bgpicbase.first; bgpic; bgpic = bgpic->next) if (bgpic->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&bgpic->iuser, cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, cfra, 0); } else if (sa->spacetype == SPACE_IMAGE) { SpaceImage *sima = sa->spacedata.first; if (sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, cfra, 0); + BKE_image_user_frame_calc(&sima->iuser, cfra, 0); } else if (sa->spacetype == SPACE_NODE) { SpaceNode *snode = sa->spacedata.first; @@ -2440,7 +2440,7 @@ void ED_image_update_frame(const Main *mainp, int cfra) ImageUser *iuser = node->storage; if (ELEM(ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) if (iuser->flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(iuser, cfra, 0); + BKE_image_user_frame_calc(iuser, cfra, 0); } } } diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 447028b8bef..9e0f538056c 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -590,7 +590,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) ima = ED_space_image(sima); if (sima->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&sima->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&sima->iuser, scene->r.cfra, 0); /* check if we have to set the image from the editmesh */ if (ima && (ima->source == IMA_SRC_VIEWER || sima->pin)) ; @@ -599,7 +599,7 @@ static void image_refresh(const bContext *C, ScrArea *UNUSED(sa)) struct BMEditMesh *em = me->edit_btmesh; int sloppy = 1; /* partially selected face is ok */ - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { /* new shading system, get image from material */ BMFace *efa = BM_active_face_get(em->bm, sloppy); diff --git a/source/blender/editors/space_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 0cc212f9c34..7870e64228a 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -107,7 +107,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) stats->totcurve += totob; if (ob->disp.first) - count_displist(&ob->disp, &tot, &totf); + BKE_displist_count(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; @@ -124,7 +124,7 @@ static void stats_object(Object *ob, int sel, int totob, SceneStats *stats) case OB_MBALL: { int tot = 0, totf = 0; - count_displist(&ob->disp, &tot, &totf); + BKE_displist_count(&ob->disp, &tot, &totf); tot *= totob; totf *= totob; diff --git a/source/blender/editors/space_logic/logic_window.c b/source/blender/editors/space_logic/logic_window.c index 184357344e1..97b6c32d81d 100644 --- a/source/blender/editors/space_logic/logic_window.c +++ b/source/blender/editors/space_logic/logic_window.c @@ -1084,7 +1084,7 @@ static void get_armature_bone_constraint(Object *ob, const char *posechannel, co { /* check that bone exist in the active object */ if (ob->type == OB_ARMATURE && ob->pose) { - bPoseChannel *pchan= get_pose_channel(ob->pose, posechannel); + bPoseChannel *pchan= BKE_pose_channel_find_name(ob->pose, posechannel); if (pchan) { bConstraint *con= BLI_findstring(&pchan->constraints, constraint_name, offsetof(bConstraint, name)); if (con) { @@ -4789,7 +4789,7 @@ void logic_buttons(bContext *C, ARegion *ar) } if (ob==NULL) return; -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar); block= uiBeginBlock(C, ar, numstr, UI_EMBOSS); @@ -4833,7 +4833,7 @@ void logic_buttons(bContext *C, ARegion *ar) ob= (Object *)idar[a]; // uiClearButLock(); -// uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); +// uiSetButLock(BKE_object_is_libdata(ob), ERROR_LIBDATA_MESSAGE); if ( (ob->scavisflag & OB_VIS_CONT) == 0) continue; /* presume it is only objects for now */ @@ -4970,7 +4970,7 @@ void logic_buttons(bContext *C, ARegion *ar) for (a=0; ascavisflag & OB_VIS_SENS) == 0) continue; @@ -5051,7 +5051,7 @@ void logic_buttons(bContext *C, ARegion *ar) for (a=0; ascavisflag & OB_VIS_ACT) == 0) continue; /* presume it is only objects for now */ diff --git a/source/blender/editors/space_logic/space_logic.c b/source/blender/editors/space_logic/space_logic.c index 93105c39f39..1caf1075ae6 100644 --- a/source/blender/editors/space_logic/space_logic.c +++ b/source/blender/editors/space_logic/space_logic.c @@ -152,7 +152,7 @@ static void logic_free(SpaceLink *UNUSED(sl)) // Spacelogic *slogic= (SpaceLogic*) sl; // if (slogic->gpd) -// XXX free_gpencil_data(slogic->gpd); +// XXX BKE_gpencil_free(slogic->gpd); } diff --git a/source/blender/editors/space_nla/nla_buttons.c b/source/blender/editors/space_nla/nla_buttons.c index 17be87052c4..bbb6e7992f7 100644 --- a/source/blender/editors/space_nla/nla_buttons.c +++ b/source/blender/editors/space_nla/nla_buttons.c @@ -62,13 +62,13 @@ #include "UI_interface.h" #include "UI_resources.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include /* ******************* nla editor space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 +#define B_NOP 1 +#define B_REDR 2 /* -------------- */ @@ -81,16 +81,16 @@ static void do_nla_region_buttons(bContext *C, void *UNUSED(arg), int event) } /* default for now */ - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_SCENE|ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_TRANSFORM, NULL); } static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA *nlt_ptr, PointerRNA *strip_ptr) { bAnimContext ac; - bAnimListElem *ale= NULL; + bAnimListElem *ale = NULL; ListBase anim_data = {NULL, NULL}; - short found=0; + short found = 0; int filter; /* for now, only draw if we could init the anim-context info (necessary for all animation-related tools) @@ -103,15 +103,15 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA * - we need the channels flag to get the active AnimData block when there are no NLA Tracks */ // XXX: double-check active! - filter= (ANIMFILTER_DATA_VISIBLE|ANIMFILTER_LIST_VISIBLE|ANIMFILTER_ACTIVE|ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { switch (ale->type) { case ANIMTYPE_NLATRACK: /* NLA Track - The primary data type which should get caught */ { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; /* found it, now set the pointers */ if (adt_ptr) { @@ -124,18 +124,18 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA } if (strip_ptr) { /* NLA-Strip pointer */ - NlaStrip *strip= BKE_nlastrip_find_active(nlt); + NlaStrip *strip = BKE_nlastrip_find_active(nlt); RNA_pointer_create(ale->id, &RNA_NlaStrip, strip, strip_ptr); } - found= 1; + found = 1; } - break; + break; - case ANIMTYPE_SCENE: /* Top-Level Widgets doubling up as datablocks */ + case ANIMTYPE_SCENE: /* Top-Level Widgets doubling up as datablocks */ case ANIMTYPE_OBJECT: case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -157,11 +157,11 @@ static int nla_panel_context(const bContext *C, PointerRNA *adt_ptr, PointerRNA /* set found status to -1, since setting to 1 would break the loop * and potentially skip an active NLA-Track in some cases... */ - found= -1; + found = -1; } } } - break; + break; } if (found > 0) @@ -209,7 +209,7 @@ static int nla_strip_actclip_panel_poll(const bContext *C, PanelType *UNUSED(pt) if (ptr.data == NULL) return 0; - strip= ptr.data; + strip = ptr.data; return (strip->type == NLASTRIP_TYPE_CLIP); } @@ -223,7 +223,7 @@ static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) if (ptr.data == NULL) return 0; - strip= ptr.data; + strip = ptr.data; if (strip->type == NLASTRIP_TYPE_SOUND) return 0; @@ -234,11 +234,11 @@ static int nla_strip_eval_panel_poll(const bContext *C, PanelType *UNUSED(pt)) /* -------------- */ /* active AnimData */ -static void nla_panel_animdata (const bContext *C, Panel *pa) +static void nla_panel_animdata(const bContext *C, Panel *pa) { PointerRNA adt_ptr; /* AnimData *adt; */ - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; @@ -248,32 +248,32 @@ static void nla_panel_animdata (const bContext *C, Panel *pa) /* adt= adt_ptr.data; */ - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Active Action Properties ------------------------------------- */ /* action */ - row= uiLayoutRow(layout, 1); - uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators + row = uiLayoutRow(layout, 1); + uiTemplateID(row, (bContext *)C, &adt_ptr, "action", "ACTION_OT_new", NULL, NULL /*"ACTION_OT_unlink"*/); // XXX: need to make these operators /* extrapolation */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &adt_ptr, "action_extrapolation", 0, NULL, ICON_NONE); /* blending */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &adt_ptr, "action_blend_type", 0, NULL, ICON_NONE); /* influence */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &adt_ptr, "action_influence", 0, NULL, ICON_NONE); } /* active NLA-Track */ -static void nla_panel_track (const bContext *C, Panel *pa) +static void nla_panel_track(const bContext *C, Panel *pa) { PointerRNA nlt_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *row; uiBlock *block; @@ -281,19 +281,19 @@ static void nla_panel_track (const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, &nlt_ptr, NULL)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Info - Active NLA-Context:Track ---------------------- */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); + row = uiLayoutRow(layout, 1); + uiItemR(row, &nlt_ptr, "name", 0, NULL, ICON_NLA); } /* generic settings for active NLA-Strip */ static void nla_panel_properties(const bContext *C, Panel *pa) { PointerRNA strip_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *column, *row, *sub; uiBlock *block; short showEvalProps = 1; @@ -301,20 +301,20 @@ static void nla_panel_properties(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Strip Properties ------------------------------------- */ /* strip type */ - row= uiLayoutColumn(layout, 1); - uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? - uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); + row = uiLayoutColumn(layout, 1); + uiItemR(row, &strip_ptr, "name", 0, NULL, ICON_NLA); // XXX icon? + uiItemR(row, &strip_ptr, "type", 0, NULL, ICON_NONE); /* strip extents */ - column= uiLayoutColumn(layout, 1); - uiItemL(column, "Strip Extents:", ICON_NONE); - uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiItemL(column, "Strip Extents:", ICON_NONE); + uiItemR(column, &strip_ptr, "frame_start", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "frame_end", 0, NULL, ICON_NONE); /* Evaluation-Related Strip Properties ------------------ */ @@ -325,31 +325,31 @@ static void nla_panel_properties(const bContext *C, Panel *pa) /* only show if allowed to... */ if (showEvalProps) { /* extrapolation */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "extrapolation", 0, NULL, ICON_NONE); /* blending */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); + row = uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "blend_type", 0, NULL, ICON_NONE); /* blend in/out + autoblending * - blend in/out can only be set when autoblending is off */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence")==0); - uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? - - sub= uiLayoutColumn(column, 1); - uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend")==0); - uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); - uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_influence") == 0); + uiItemR(column, &strip_ptr, "use_auto_blend", 0, NULL, ICON_NONE); // XXX as toggle? + + sub = uiLayoutColumn(column, 1); + uiLayoutSetActive(sub, RNA_boolean_get(&strip_ptr, "use_auto_blend") == 0); + uiItemR(sub, &strip_ptr, "blend_in", 0, NULL, ICON_NONE); + uiItemR(sub, &strip_ptr, "blend_out", 0, NULL, ICON_NONE); /* settings */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); - uiItemL(column, "Playback Settings:", ICON_NONE); - uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, !(RNA_boolean_get(&strip_ptr, "use_animated_influence") || RNA_boolean_get(&strip_ptr, "use_animated_time"))); + uiItemL(column, "Playback Settings:", ICON_NONE); + uiItemR(column, &strip_ptr, "mute", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "use_reverse", 0, NULL, ICON_NONE); } } @@ -358,7 +358,7 @@ static void nla_panel_properties(const bContext *C, Panel *pa) static void nla_panel_actclip(const bContext *C, Panel *pa) { PointerRNA strip_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *column, *row; uiBlock *block; @@ -366,35 +366,35 @@ static void nla_panel_actclip(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* Strip Properties ------------------------------------- */ /* action pointer */ - row= uiLayoutRow(layout, 1); - uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); + row = uiLayoutRow(layout, 1); + uiItemR(row, &strip_ptr, "action", 0, NULL, ICON_ACTION); /* action extents */ // XXX custom names were used here (to avoid the prefixes)... probably not necessary in future? - column= uiLayoutColumn(layout, 1); - uiItemL(column, "Action Extents:", ICON_NONE); - uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); - uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); - uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); + column = uiLayoutColumn(layout, 1); + uiItemL(column, "Action Extents:", ICON_NONE); + uiItemR(column, &strip_ptr, "action_frame_start", 0, "Start Frame", ICON_NONE); + uiItemR(column, &strip_ptr, "action_frame_end", 0, "End Frame", ICON_NONE); + uiItemO(column, NULL, ICON_NONE, "NLA_OT_action_sync_length"); /* action usage */ - column= uiLayoutColumn(layout, 1); - uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time")==0); - uiItemL(column, "Playback Settings:", ICON_NONE); - uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); - uiItemR(column, &strip_ptr, "repeat", 0, NULL, ICON_NONE); + column = uiLayoutColumn(layout, 1); + uiLayoutSetActive(column, RNA_boolean_get(&strip_ptr, "use_animated_time") == 0); + uiItemL(column, "Playback Settings:", ICON_NONE); + uiItemR(column, &strip_ptr, "scale", 0, NULL, ICON_NONE); + uiItemR(column, &strip_ptr, "repeat", 0, NULL, ICON_NONE); } /* evaluation settings for active NLA-Strip */ static void nla_panel_evaluation(const bContext *C, Panel *pa) { PointerRNA strip_ptr; - uiLayout *layout= pa->layout; + uiLayout *layout = pa->layout; uiLayout *col, *sub; uiBlock *block; @@ -402,22 +402,22 @@ static void nla_panel_evaluation(const bContext *C, Panel *pa) if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - block= uiLayoutGetBlock(layout); + block = uiLayoutGetBlock(layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); - col= uiLayoutColumn(layout, 1); + col = uiLayoutColumn(layout, 1); uiItemR(col, &strip_ptr, "use_animated_influence", 0, NULL, ICON_NONE); - sub= uiLayoutColumn(col, 1); + sub = uiLayoutColumn(col, 1); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_influence")); uiItemR(sub, &strip_ptr, "influence", 0, NULL, ICON_NONE); - col= uiLayoutColumn(layout, 1); - sub= uiLayoutRow(col, 0); + col = uiLayoutColumn(layout, 1); + sub = uiLayoutRow(col, 0); uiItemR(sub, &strip_ptr, "use_animated_time", 0, NULL, ICON_NONE); uiItemR(sub, &strip_ptr, "use_animated_time_cyclic", 0, NULL, ICON_NONE); - sub= uiLayoutRow(col, 0); + sub = uiLayoutRow(col, 0); uiLayoutSetEnabled(sub, RNA_boolean_get(&strip_ptr, "use_animated_time")); uiItemR(sub, &strip_ptr, "strip_time", 0, NULL, ICON_NONE); } @@ -434,30 +434,30 @@ static void nla_panel_modifiers(const bContext *C, Panel *pa) /* check context and also validity of pointer */ if (!nla_panel_context(C, NULL, NULL, &strip_ptr)) return; - strip= strip_ptr.data; + strip = strip_ptr.data; - block= uiLayoutGetBlock(pa->layout); + block = uiLayoutGetBlock(pa->layout); uiBlockSetHandleFunc(block, do_nla_region_buttons, NULL); /* 'add modifier' button at top of panel */ { - row= uiLayoutRow(pa->layout, 0); - block= uiLayoutGetBlock(row); + row = uiLayoutRow(pa->layout, 0); + block = uiLayoutGetBlock(row); // XXX for now, this will be a operator button which calls a temporary 'add modifier' operator // FIXME: we need to set the only-active property so that this will only add modifiers for the active strip (not all selected) uiDefButO(block, BUT, "NLA_OT_fmodifier_add", WM_OP_INVOKE_REGION_WIN, IFACE_("Add Modifier"), 10, 0, 150, 20, - TIP_("Adds a new F-Modifier for the active NLA Strip")); + TIP_("Adds a new F-Modifier for the active NLA Strip")); /* copy/paste (as sub-row)*/ - row= uiLayoutRow(row, 1); - uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); - uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); + row = uiLayoutRow(row, 1); + uiItemO(row, "", ICON_COPYDOWN, "NLA_OT_fmodifier_copy"); + uiItemO(row, "", ICON_PASTEDOWN, "NLA_OT_fmodifier_paste"); } /* draw each modifier */ - for (fcm= strip->modifiers.first; fcm; fcm= fcm->next) { - col= uiLayoutColumn(pa->layout, 1); + for (fcm = strip->modifiers.first; fcm; fcm = fcm->next) { + col = uiLayoutColumn(pa->layout, 1); ANIM_uiTemplate_fmodifier_draw(col, strip_ptr.id.data, &strip->modifiers, fcm); } @@ -470,54 +470,54 @@ void nla_buttons_register(ARegionType *art) { PanelType *pt; - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel animdata"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel animdata"); strcpy(pt->idname, "NLA_PT_animdata"); strcpy(pt->label, "Animation Data"); - pt->draw= nla_panel_animdata; - pt->poll= nla_animdata_panel_poll; - pt->flag= PNL_DEFAULT_CLOSED; + pt->draw = nla_panel_animdata; + pt->poll = nla_animdata_panel_poll; + pt->flag = PNL_DEFAULT_CLOSED; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel track"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel track"); strcpy(pt->idname, "NLA_PT_track"); strcpy(pt->label, "Active Track"); - pt->draw= nla_panel_track; - pt->poll= nla_track_panel_poll; + pt->draw = nla_panel_track; + pt->poll = nla_track_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); strcpy(pt->idname, "NLA_PT_properties"); strcpy(pt->label, "Active Strip"); - pt->draw= nla_panel_properties; - pt->poll= nla_strip_panel_poll; + pt->draw = nla_panel_properties; + pt->poll = nla_strip_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel properties"); strcpy(pt->idname, "NLA_PT_actionclip"); strcpy(pt->label, "Action Clip"); - pt->draw= nla_panel_actclip; - pt->poll= nla_strip_actclip_panel_poll; + pt->draw = nla_panel_actclip; + pt->poll = nla_strip_actclip_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel evaluation"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel evaluation"); strcpy(pt->idname, "NLA_PT_evaluation"); strcpy(pt->label, "Evaluation"); - pt->draw= nla_panel_evaluation; - pt->poll= nla_strip_eval_panel_poll; + pt->draw = nla_panel_evaluation; + pt->poll = nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); - pt= MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers"); + pt = MEM_callocN(sizeof(PanelType), "spacetype nla panel modifiers"); strcpy(pt->idname, "NLA_PT_modifiers"); strcpy(pt->label, "Modifiers"); - pt->draw= nla_panel_modifiers; - pt->poll= nla_strip_eval_panel_poll; + pt->draw = nla_panel_modifiers; + pt->poll = nla_strip_eval_panel_poll; BLI_addtail(&art->paneltypes, pt); } static int nla_properties(bContext *C, wmOperator *UNUSED(op)) { - ScrArea *sa= CTX_wm_area(C); - ARegion *ar= nla_has_buttons_region(sa); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = nla_has_buttons_region(sa); if (ar) ED_region_toggle_hidden(C, ar); diff --git a/source/blender/editors/space_nla/nla_channels.c b/source/blender/editors/space_nla/nla_channels.c index 69e1e089bf6..11a39693168 100644 --- a/source/blender/editors/space_nla/nla_channels.c +++ b/source/blender/editors/space_nla/nla_channels.c @@ -61,7 +61,7 @@ #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include /* *********************************************** */ /* Operators for NLA channels-list which need to be different from the standard Animation Editor ones */ @@ -74,22 +74,22 @@ * --> Most channels are now selection only... */ -static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, short selectmode) +static int mouse_nla_channels(bAnimContext *ac, float x, int channel_index, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; int notifierFlags = 0; /* get the channel that was clicked on */ - /* filter channels */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + /* filter channels */ + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - /* get channel from index */ - ale= BLI_findlink(&anim_data, channel_index); + /* get channel from index */ + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ if (G.debug & G_DEBUG) @@ -104,8 +104,8 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho switch (ale->type) { case ANIMTYPE_SCENE: { - Scene *sce= (Scene *)ale->data; - AnimData *adt= sce->adt; + Scene *sce = (Scene *)ale->data; + AnimData *adt = sce->adt; /* set selection status */ if (selectmode == SELECT_INVERT) { @@ -118,23 +118,23 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho if (adt) adt->flag |= ADT_UI_SELECTED; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_OBJECT: { - bDopeSheet *ads= (bDopeSheet *)ac->data; - Scene *sce= (Scene *)ads->source; - Base *base= (Base *)ale->data; - Object *ob= base->object; - AnimData *adt= ob->adt; + bDopeSheet *ads = (bDopeSheet *)ac->data; + Scene *sce = (Scene *)ads->source; + Base *base = (Base *)ale->data; + Object *ob = base->object; + AnimData *adt = ob->adt; if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection status */ if (selectmode == SELECT_INVERT) { /* swap select */ base->flag ^= SELECT; - ob->flag= base->flag; + ob->flag = base->flag; if (adt) adt->flag ^= ADT_UI_SELECTED; } @@ -143,10 +143,10 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho /* deselect all */ // TODO: should this deselect all other types of channels too? - for (b= sce->base.first; b; b= b->next) { + for (b = sce->base.first; b; b = b->next) { b->flag &= ~SELECT; - b->object->flag= b->flag; - if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED|ADT_UI_ACTIVE); + b->object->flag = b->flag; + if (b->object->adt) b->object->adt->flag &= ~(ADT_UI_SELECTED | ADT_UI_ACTIVE); } /* select object now */ @@ -159,13 +159,13 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho adt->flag |= ADT_UI_ACTIVE; /* notifiers - channel was selected */ - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } } - break; + break; case ANIMTYPE_FILLACTD: /* Action Expander */ - case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ + case ANIMTYPE_DSMAT: /* Datablock AnimData Expanders */ case ANIMTYPE_DSLAM: case ANIMTYPE_DSCAM: case ANIMTYPE_DSCUR: @@ -199,47 +199,47 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ale->adt->flag |= ADT_UI_ACTIVE; } - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } - break; + break; case ANIMTYPE_NLATRACK: { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; short offset; /* offset for start of channel (on LHS of channel-list) */ if (ale->id) { /* special exception for materials and particles */ if (ELEM(GS(ale->id->name), ID_MA, ID_PA)) - offset= 21 + NLACHANNEL_BUTTON_WIDTH; + offset = 21 + NLACHANNEL_BUTTON_WIDTH; else - offset= 14; + offset = 14; } else - offset= 0; + offset = 0; - if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { /* toggle protection (only if there's a toggle there) */ nlt->flag ^= NLATRACK_PROTECTED; /* notifier flags - channel was edited */ - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - else if (x >= (v2d->cur.xmax-2*NLACHANNEL_BUTTON_WIDTH)) { + else if (x >= (v2d->cur.xmax - 2 * NLACHANNEL_BUTTON_WIDTH)) { /* toggle mute */ nlt->flag ^= NLATRACK_MUTED; /* notifier flags - channel was edited */ - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } - else if (x <= ((NLACHANNEL_BUTTON_WIDTH*2)+offset)) { + else if (x <= ((NLACHANNEL_BUTTON_WIDTH * 2) + offset)) { /* toggle 'solo' */ BKE_nlatrack_solo_toggle(adt, nlt); /* notifier flags - channel was edited */ - notifierFlags |= (ND_ANIMCHAN|NA_EDITED); + notifierFlags |= (ND_ANIMCHAN | NA_EDITED); } else if (nlaedit_is_tweakmode_on(ac) == 0) { /* set selection */ @@ -258,19 +258,19 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK); /* notifier flags - channel was selected */ - notifierFlags |= (ND_ANIMCHAN|NA_SELECTED); + notifierFlags |= (ND_ANIMCHAN | NA_SELECTED); } } - break; + break; case ANIMTYPE_NLAACTION: { - AnimData *adt= BKE_animdata_from_id(ale->id); + AnimData *adt = BKE_animdata_from_id(ale->id); - if (x >= (v2d->cur.xmax-NLACHANNEL_BUTTON_WIDTH)) { + if (x >= (v2d->cur.xmax - NLACHANNEL_BUTTON_WIDTH)) { if (nlaedit_is_tweakmode_on(ac) == 0) { /* 'push-down' action - only usable when not in TweakMode */ // TODO: make this use the operator instead of calling the function directly - // however, calling the operator requires that we supply the args, and that works with proper buttons only + // however, calling the operator requires that we supply the args, and that works with proper buttons only BKE_nla_action_pushdown(adt); } else { @@ -282,7 +282,7 @@ static int mouse_nla_channels (bAnimContext *ac, float x, int channel_index, sho notifierFlags |= ND_NLA_ACTCHANGE; } } - break; + break; default: if (G.debug & G_DEBUG) @@ -315,15 +315,15 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e return OPERATOR_CANCELLED; /* get useful pointers from animation context data */ - snla= (SpaceNla *)ac.sl; - ar= ac.ar; - v2d= &ar->v2d; + snla = (SpaceNla *)ac.sl; + ar = ac.ar; + v2d = &ar->v2d; /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* figure out which channel user clicked in * Note: although channels technically start at y= NLACHANNEL_FIRST, we need to adjust by half a channel's height @@ -334,10 +334,10 @@ static int nlachannels_mouseclick_invoke(bContext *C, wmOperator *op, wmEvent *e UI_view2d_listview_view_to_cell(v2d, NLACHANNEL_NAMEWIDTH, NLACHANNEL_STEP(snla), 0, (float)NLACHANNEL_HEIGHT_HALF(snla), x, y, NULL, &channel_index); /* handle mouse-click in the relevant channel then */ - notifierFlags= mouse_nla_channels(&ac, x, channel_index, selectmode); + notifierFlags = mouse_nla_channels(&ac, x, channel_index, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|notifierFlags, NULL); + WM_event_add_notifier(C, NC_ANIMATION | notifierFlags, NULL); return OPERATOR_FINISHED; } @@ -354,7 +354,7 @@ void NLA_OT_channels_click(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY @@ -366,7 +366,7 @@ void NLA_OT_channels_click(wmOperatorType *ot) /* ******************** Add Tracks Operator ***************************** */ /* Add NLA Tracks to the same AnimData block as a selected track, or above the selected tracks */ -static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) +static int nlaedit_add_tracks_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -375,21 +375,21 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) int filter; AnimData *lastAdt = NULL; - short above_sel= RNA_boolean_get(op->ptr, "above_selected"); + short above_sel = RNA_boolean_get(op->ptr, "above_selected"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* add tracks... */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; /* check if just adding a new track above this one, * or whether we're adding a new one to the top of the stack that this one belongs to @@ -401,7 +401,7 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) else if ((lastAdt == NULL) || (adt != lastAdt)) { /* add one track to the top of the owning AnimData's stack, then don't add anymore to this stack */ add_nlatrack(adt, NULL); - lastAdt= adt; + lastAdt = adt; } } } @@ -410,7 +410,7 @@ static int nlaedit_add_tracks_exec (bContext *C, wmOperator *op) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -428,7 +428,7 @@ void NLA_OT_tracks_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_boolean(ot->srna, "above_selected", 0, "Above Selected", "Add a new NLA Track above every existing selected one"); @@ -437,7 +437,7 @@ void NLA_OT_tracks_add(wmOperatorType *ot) /* ******************** Delete Tracks Operator ***************************** */ /* Delete selected NLA Tracks */ -static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_delete_tracks_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -450,14 +450,14 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* delete tracks */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; /* if track is currently 'solo', then AnimData should have its * 'has solo' flag disabled @@ -474,7 +474,7 @@ static int nlaedit_delete_tracks_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -492,7 +492,7 @@ void NLA_OT_delete_tracks(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index d331415bc46..c12cd6f2d39 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -66,7 +66,7 @@ #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" /* own include */ /* *********************************************** */ @@ -77,29 +77,29 @@ /* get colors for drawing Action-Line * NOTE: color returned includes fine-tuned alpha! */ -static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) +static void nla_action_get_color(AnimData *adt, bAction *act, float color[4]) { if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { // greenish color (same as tweaking strip) - hardcoded for now - color[0]= 0.30f; - color[1]= 0.95f; - color[2]= 0.10f; - color[3]= 0.30f; + color[0] = 0.30f; + color[1] = 0.95f; + color[2] = 0.10f; + color[3] = 0.30f; } else { if (act) { // reddish color - hardcoded for now - color[0]= 0.8f; - color[1]= 0.2f; - color[2]= 0.0f; - color[3]= 0.4f; + color[0] = 0.8f; + color[1] = 0.2f; + color[2] = 0.0f; + color[3] = 0.4f; } else { // greyish-red color - hardcoded for now - color[0]= 0.6f; - color[1]= 0.5f; - color[2]= 0.5f; - color[3]= 0.3f; + color[0] = 0.6f; + color[1] = 0.5f; + color[2] = 0.5f; + color[3] = 0.3f; } } @@ -109,7 +109,7 @@ static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) } /* draw the keyframes in the specified Action */ -static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax) +static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax) { DLRBT_Tree keys; ActKeyColumn *ak; @@ -132,13 +132,13 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, color[3] *= 2.5f; glColor4fv(color); - /* - draw a rect from the first to the last frame (no extra overlaps for now) + /* - draw a rect from the first to the last frame (no extra overlaps for now) * that is slightly stumpier than the track background (hardcoded 2-units here) */ - f1= ((ActKeyColumn *)keys.first)->cfra; - f2= ((ActKeyColumn *)keys.last)->cfra; + f1 = ((ActKeyColumn *)keys.first)->cfra; + f2 = ((ActKeyColumn *)keys.last)->cfra; - glRectf(f1, ymin+2, f2, ymax-2); + glRectf(f1, ymin + 2, f2, ymax - 2); /* get View2D scaling factor */ @@ -150,7 +150,7 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, /* just draw each keyframe as a simple dot (regardless of the selection status) * - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction */ - for (ak= keys.first; ak; ak= ak->next) + for (ak = keys.first; ak; ak = ak->next) draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, ak->key_type, KEYFRAME_SHAPE_FRAME, 1.0f); /* free icons */ @@ -160,23 +160,23 @@ static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, /* Strips (Proper) ---------------------- */ /* get colors for drawing NLA-Strips */ -static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float color[3]) +static void nla_strip_get_color_inside(AnimData *adt, NlaStrip *strip, float color[3]) { if (strip->type == NLASTRIP_TYPE_TRANSITION) { /* Transition Clip */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bright blue color */ // FIXME: hardcoded temp-hack colors - color[0]= 0.18f; - color[1]= 0.46f; - color[2]= 0.86f; + color[0] = 0.18f; + color[1] = 0.46f; + color[2] = 0.86f; } else { /* normal, unselected strip - use (hardly noticeable) blue tinge */ // FIXME: hardcoded temp-hack colors - color[0]= 0.11f; - color[1]= 0.15f; - color[2]= 0.19f; + color[0] = 0.11f; + color[1] = 0.15f; + color[2] = 0.19f; } } else if (strip->type == NLASTRIP_TYPE_META) { @@ -185,16 +185,16 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bold purple color */ // FIXME: hardcoded temp-hack colors - color[0]= 0.41f; - color[1]= 0.13f; - color[2]= 0.59f; + color[0] = 0.41f; + color[1] = 0.13f; + color[2] = 0.59f; } else { /* normal, unselected strip - use (hardly noticeable) dark purple tinge */ // FIXME: hardcoded temp-hack colors - color[0]= 0.20f; - color[1]= 0.15f; - color[2]= 0.26f; + color[0] = 0.20f; + color[1] = 0.15f; + color[2] = 0.26f; } } else if (strip->type == NLASTRIP_TYPE_SOUND) { @@ -202,16 +202,16 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bright teal color */ // FIXME: hardcoded temp-hack colors - color[0]= 0.12f; - color[1]= 0.48f; - color[2]= 0.48f; + color[0] = 0.12f; + color[1] = 0.48f; + color[2] = 0.48f; } else { /* normal, unselected strip - use (hardly noticeable) teal tinge */ // FIXME: hardcoded temp-hack colors - color[0]= 0.17f; - color[1]= 0.24f; - color[2]= 0.24f; + color[0] = 0.17f; + color[1] = 0.24f; + color[2] = 0.24f; } } else { @@ -221,18 +221,18 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co * however, this case should be skipped for when not in EditMode... */ // FIXME: hardcoded temp-hack colors - color[0]= 0.3f; - color[1]= 0.95f; - color[2]= 0.1f; + color[0] = 0.3f; + color[1] = 0.95f; + color[2] = 0.1f; } else if (strip->flag & NLASTRIP_FLAG_TWEAKUSER) { /* alert user that this strip is also used by the tweaking track (this is set when going into * 'editmode' for that strip), since the edits made here may not be what the user anticipated */ // FIXME: hardcoded temp-hack colors - color[0]= 0.85f; - color[1]= 0.0f; - color[2]= 0.0f; + color[0] = 0.85f; + color[1] = 0.0f; + color[2] = 0.0f; } else if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected strip - use theme color for selected */ @@ -246,7 +246,7 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co } /* helper call for drawing influence/time control curves for a given NLA-strip */ -static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) +static void nla_draw_strip_curves(NlaStrip *strip, float yminc, float ymaxc) { const float yheight = ymaxc - yminc; @@ -261,39 +261,39 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) /* influence -------------------------- */ if (strip->flag & NLASTRIP_FLAG_USR_INFLUENCE) { - FCurve *fcu= list_find_fcurve(&strip->fcurves, "influence", 0); + FCurve *fcu = list_find_fcurve(&strip->fcurves, "influence", 0); float cfra; /* plot the curve (over the strip's main region) */ glBegin(GL_LINE_STRIP); - /* sample at 1 frame intervals, and draw - * - min y-val is yminc, max is y-maxc, so clamp in those regions - */ - for (cfra= strip->start; cfra <= strip->end; cfra += 1.0f) { - float y= evaluate_fcurve(fcu, cfra); // assume this to be in 0-1 range - glVertex2f(cfra, ((y*yheight)+yminc)); - } + /* sample at 1 frame intervals, and draw + * - min y-val is yminc, max is y-maxc, so clamp in those regions + */ + for (cfra = strip->start; cfra <= strip->end; cfra += 1.0f) { + float y = evaluate_fcurve(fcu, cfra); // assume this to be in 0-1 range + glVertex2f(cfra, ((y * yheight) + yminc)); + } glEnd(); // GL_LINE_STRIP } else { /* use blend in/out values only if both aren't zero */ - if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f))==0) { + if ((IS_EQF(strip->blendin, 0.0f) && IS_EQF(strip->blendout, 0.0f)) == 0) { glBegin(GL_LINE_STRIP); - /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ - if (IS_EQF(strip->blendin, 0.0f) == 0) { - glVertex2f(strip->start, yminc); - glVertex2f(strip->start + strip->blendin, ymaxc); - } - else - glVertex2f(strip->start, ymaxc); + /* start of strip - if no blendin, start straight at 1, otherwise from 0 to 1 over blendin frames */ + if (IS_EQF(strip->blendin, 0.0f) == 0) { + glVertex2f(strip->start, yminc); + glVertex2f(strip->start + strip->blendin, ymaxc); + } + else + glVertex2f(strip->start, ymaxc); - /* end of strip */ - if (IS_EQF(strip->blendout, 0.0f) == 0) { - glVertex2f(strip->end - strip->blendout, ymaxc); - glVertex2f(strip->end, yminc); - } - else - glVertex2f(strip->end, ymaxc); + /* end of strip */ + if (IS_EQF(strip->blendout, 0.0f) == 0) { + glVertex2f(strip->end - strip->blendout, ymaxc); + glVertex2f(strip->end, yminc); + } + else + glVertex2f(strip->end, ymaxc); glEnd(); // GL_LINE_STRIP } } @@ -307,9 +307,9 @@ static void nla_draw_strip_curves (NlaStrip *strip, float yminc, float ymaxc) } /* main call for drawing a single NLA-strip */ -static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) +static void nla_draw_strip(SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStrip *strip, View2D *v2d, float yminc, float ymaxc) { - short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO)==0); + short nonSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); float color[3]; /* get color of strip */ @@ -335,34 +335,34 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* draw the rect to the edge of the screen */ glBegin(GL_QUADS); - glVertex2f(v2d->cur.xmin, yminc); - glVertex2f(v2d->cur.xmin, ymaxc); - glVertex2f(strip->start, ymaxc); - glVertex2f(strip->start, yminc); + glVertex2f(v2d->cur.xmin, yminc); + glVertex2f(v2d->cur.xmin, ymaxc); + glVertex2f(strip->start, ymaxc); + glVertex2f(strip->start, yminc); glEnd(); } - /* no break needed... */ + /* no break needed... */ /* this only draws after the strip */ case NLASTRIP_EXTEND_HOLD_FORWARD: /* only need to try and draw if the next strip doesn't occur immediately after */ - if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end)==0)) { + if ((strip->next == NULL) || (IS_EQF(strip->next->start, strip->end) == 0)) { /* set the drawing color to the color of the strip, but this time less faint */ glColor4f(color[0], color[1], color[2], 0.3f); /* draw the rect to the next strip or the edge of the screen */ glBegin(GL_QUADS); - glVertex2f(strip->end, yminc); - glVertex2f(strip->end, ymaxc); + glVertex2f(strip->end, yminc); + glVertex2f(strip->end, ymaxc); - if (strip->next) { - glVertex2f(strip->next->start, ymaxc); - glVertex2f(strip->next->start, yminc); - } - else { - glVertex2f(v2d->cur.xmax, ymaxc); - glVertex2f(v2d->cur.xmax, yminc); - } + if (strip->next) { + glVertex2f(strip->next->start, ymaxc); + glVertex2f(strip->next->start, yminc); + } + else { + glVertex2f(v2d->cur.xmax, ymaxc); + glVertex2f(v2d->cur.xmax, yminc); + } glEnd(); } break; @@ -385,7 +385,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr glColor4f(color[0], color[1], color[2], 0.1f); glEnable(GL_BLEND); - glRectf(strip->start, yminc, strip->end, ymaxc); + glRectf(strip->start, yminc, strip->end, ymaxc); glDisable(GL_BLEND); } @@ -417,7 +417,7 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr uiDrawBoxShade(GL_LINE_LOOP, strip->start, yminc, strip->end, ymaxc, 0.0, 0.0, 0.1); /* if action-clip strip, draw lines delimiting repeats too (in the same color as outline) */ - if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f)==0) { + if ((strip->type == NLASTRIP_TYPE_CLIP) && IS_EQF(strip->repeat, 1.0f) == 0) { float repeatLen = (strip->actend - strip->actstart) * strip->scale; int i; @@ -429,20 +429,20 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr /* don't draw if line would end up on or after the end of the strip */ if (repeatPos < strip->end) - fdrawline(repeatPos, yminc+4, repeatPos, ymaxc-4); + fdrawline(repeatPos, yminc + 4, repeatPos, ymaxc - 4); } } /* or if meta-strip, draw lines delimiting extents of sub-strips (in same color as outline, if more than 1 exists) */ else if ((strip->type == NLASTRIP_TYPE_META) && (strip->strips.first != strip->strips.last)) { NlaStrip *cs; - float y= (ymaxc-yminc)/2.0f + yminc; + float y = (ymaxc - yminc) / 2.0f + yminc; /* only draw first-level of child-strips, but don't draw any lines on the endpoints */ - for (cs= strip->strips.first; cs; cs= cs->next) { + for (cs = strip->strips.first; cs; cs = cs->next) { /* draw start-line if not same as end of previous (and only if not the first strip) * - on upper half of strip */ - if ((cs->prev) && IS_EQF(cs->prev->end, cs->start)==0) + if ((cs->prev) && IS_EQF(cs->prev->end, cs->start) == 0) fdrawline(cs->start, y, cs->start, ymaxc); /* draw end-line if not the last strip @@ -458,9 +458,9 @@ static void nla_draw_strip (SpaceNla *snla, AnimData *adt, NlaTrack *nlt, NlaStr } /* add the relevant text to the cache of text-strings to draw in pixelspace */ -static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) +static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, int index, View2D *v2d, float yminc, float ymaxc) { - short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO)==0); + short notSolo = ((adt && (adt->flag & ADT_NLA_SOLO_TRACK)) && (nlt->flag & NLATRACK_SOLO) == 0); char str[256]; char col[4]; float xofs; @@ -475,18 +475,18 @@ static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ - if (strip->flag & (NLASTRIP_FLAG_ACTIVE|NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_TWEAKUSER)) { - col[0]= col[1]= col[2]= 0; + if (strip->flag & (NLASTRIP_FLAG_ACTIVE | NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_TWEAKUSER)) { + col[0] = col[1] = col[2] = 0; } else { - col[0]= col[1]= col[2]= 255; + col[0] = col[1] = col[2] = 255; } /* text opacity depends on whether if there's a solo'd track, this isn't it */ if (notSolo == 0) - col[3]= 255; + col[3] = 255; else - col[3]= 128; + col[3] = 128; /* determine the amount of padding required - cannot be constant otherwise looks weird in some cases */ if ((strip->end - strip->start) <= 5.0f) @@ -523,13 +523,13 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V * - 1 dp is compromise between lack of precision (ints only, as per sequencer) * while also preserving some accuracy, since we do use floats */ - /* start frame */ + /* start frame */ BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->start); - UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, numstr, col); + UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, col); - /* end frame */ + /* end frame */ BLI_snprintf(numstr, sizeof(numstr), "%.1f", strip->end); - UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, numstr, col); + UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, col); } /* ---------------------- */ @@ -540,49 +540,49 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) bAnimListElem *ale; int filter; - View2D *v2d= &ar->v2d; - float y= 0.0f; + View2D *v2d = &ar->v2d; + float y = 0.0f; size_t items; int height; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla)*2)); + height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); /* 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); /* loop through channels, and set up drawing depending on their type */ - y= (float)(-NLACHANNEL_HEIGHT(snla)); + y = (float)(-NLACHANNEL_HEIGHT(snla)); - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* data to draw depends on the type of channel */ switch (ale->type) { case ANIMTYPE_NLATRACK: { - AnimData *adt= ale->adt; - NlaTrack *nlt= (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; int index; /* draw each strip in the track (if visible) */ - for (strip=nlt->strips.first, index=1; strip; strip=strip->next, index++) { + for (strip = nlt->strips.first, index = 1; strip; strip = strip->next, index++) { if (BKE_nlastrip_within_bounds(strip, v2d->cur.xmin, v2d->cur.xmax)) { /* draw the visualisation of the strip */ nla_draw_strip(snla, adt, nlt, strip, v2d, yminc, ymaxc); @@ -598,11 +598,11 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) } } } - break; + break; case ANIMTYPE_NLAACTION: { - AnimData *adt= ale->adt; + AnimData *adt = ale->adt; float color[4]; /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, @@ -618,27 +618,27 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* draw slightly shifted up for greater separation from standard channels, * but also slightly shorter for some more contrast when viewing the strips */ - glRectf(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); + glRectf(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); /* draw keyframes in the action */ - nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc+NLACHANNEL_SKIP, ymaxc-NLACHANNEL_SKIP); + nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc + NLACHANNEL_SKIP, ymaxc - NLACHANNEL_SKIP); /* draw 'embossed' lines above and below the strip for effect */ - /* white base-lines */ + /* white base-lines */ glLineWidth(2.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.3); - fdrawline(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, yminc+NLACHANNEL_SKIP); - fdrawline(v2d->cur.xmin, ymaxc-NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); - /* black top-lines */ + /* black top-lines */ glLineWidth(1.0f); glColor3f(0.0f, 0.0f, 0.0f); - fdrawline(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, yminc+NLACHANNEL_SKIP); - fdrawline(v2d->cur.xmin, ymaxc-NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, yminc + NLACHANNEL_SKIP, v2d->cur.xmax, yminc + NLACHANNEL_SKIP); + fdrawline(v2d->cur.xmin, ymaxc - NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc - NLACHANNEL_SKIP); glDisable(GL_BLEND); } - break; + break; } } @@ -655,40 +655,40 @@ void draw_nla_main_data(bAnimContext *ac, SpaceNla *snla, ARegion *ar) /* old code for drawing NLA channels using GL only */ // TODO: depreceate this code... -static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) +static void draw_nla_channel_list_gl(bAnimContext *ac, ListBase *anim_data, View2D *v2d, float y) { SpaceNla *snla = (SpaceNla *)ac->sl; bAnimListElem *ale; float x = 0.0f; /* loop through channels, and set up drawing depending on their type */ - for (ale= anim_data->first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); - const float ydatac= (float)(y - 7); + for (ale = anim_data->first; ale; ale = ale->next) { + const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + const float ydatac = (float)(y - 7); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { AnimData *adt = ale->adt; - short indent= 0, offset= 0, sel= 0, group= 0, nonSolo= 0; - int expand= -1, protect = -1, special= -1, mute = -1; + short indent = 0, offset = 0, sel = 0, group = 0, nonSolo = 0; + int expand = -1, protect = -1, special = -1, mute = -1; char name[128]; - short doDraw=0; + short doDraw = 0; /* determine what needs to be drawn */ switch (ale->type) { case ANIMTYPE_NLATRACK: /* NLA Track */ { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; /* 'solo' as the 'special' button? */ if (nlt->flag & NLATRACK_SOLO) - special= ICON_SOLO_ON; + special = ICON_SOLO_ON; else - special= ICON_SOLO_OFF; + special = ICON_SOLO_OFF; /* if this track is active and we're tweaking it, don't draw these toggles */ // TODO: need a special macro for this... @@ -708,7 +708,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie if ((adt) && (adt->flag & ADT_NLA_SOLO_TRACK)) { if ((nlt->flag & NLATRACK_SOLO) == 0) { /* tag for special non-solo handling; also hide the mute toggles */ - nonSolo= 1; + nonSolo = 1; mute = 0; } } @@ -717,26 +717,26 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie BLI_strncpy(name, nlt->name, sizeof(name)); // draw manually still - doDraw= 1; + doDraw = 1; } - break; + break; case ANIMTYPE_NLAACTION: /* NLA Action-Line */ { - bAction *act= (bAction *)ale->data; + bAction *act = (bAction *)ale->data; group = 5; special = ICON_ACTION; if (act) - BLI_snprintf(name, sizeof(name), "%s", act->id.name+2); + BLI_snprintf(name, sizeof(name), "%s", act->id.name + 2); else BLI_strncpy(name, "", sizeof(name)); // draw manually still - doDraw= 1; + doDraw = 1; } - break; + break; default: /* handled by standard channel-drawing API */ // draw backdrops only... @@ -749,8 +749,8 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie if (ale->id) { /* special exception for textures */ if (GS(ale->id->name) == ID_TE) { - offset= 14; - indent= 1; + offset = 14; + indent = 1; } /* special exception for nodetrees */ else if (GS(ale->id->name) == ID_NT) { @@ -760,30 +760,32 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie case NTREE_SHADER: { /* same as for textures */ - offset= 14; - indent= 1; + offset = 14; + indent = 1; } - break; + break; case NTREE_TEXTURE: { /* even more */ - offset= 21; - indent= 1; + offset = 21; + indent = 1; } - break; + break; default: /* normal will do */ - offset= 14; + offset = 14; break; } } - else - offset= 14; + else { + offset = 14; + } + } + else { + offset = 0; } - else - offset= 0; /* now, start drawing based on this information */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -799,12 +801,12 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie } else { /* if a track is being solo'd, action is ignored, so draw less boldly (alpha lower) */ - float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK))? 0.3f : 1.0f; + float alpha = (adt && (adt->flag & ADT_NLA_SOLO_TRACK)) ? 0.3f : 1.0f; if (ale->data) - glColor4f(0.8f, 0.2f, 0.0f, alpha); // reddish color - hardcoded for now + glColor4f(0.8f, 0.2f, 0.0f, alpha); // reddish color - hardcoded for now else - glColor4f(0.6f, 0.5f, 0.5f, alpha); // greyish-red color - hardcoded for now + glColor4f(0.6f, 0.5f, 0.5f, alpha); // greyish-red color - hardcoded for now } offset += 7 * indent; @@ -815,35 +817,35 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* draw slightly shifted up vertically to look like it has more separation from other channels, * but we then need to slightly shorten it so that it doesn't look like it overlaps */ - uiDrawBox(GL_POLYGON, x+offset, yminc+NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc+NLACHANNEL_SKIP-1, 8); + uiDrawBox(GL_POLYGON, x + offset, yminc + NLACHANNEL_SKIP, (float)v2d->cur.xmax, ymaxc + NLACHANNEL_SKIP - 1, 8); /* clear group value, otherwise we cause errors... */ group = 0; } else { /* NLA tracks - darker color if not solo track when we're showing solo */ - UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0)? 20 : -20)); + UI_ThemeColorShade(TH_HEADER, ((nonSolo == 0) ? 20 : -20)); indent += group; offset += 7 * indent; glBegin(GL_QUADS); - glVertex2f(x+offset, yminc); - glVertex2f(x+offset, ymaxc); - glVertex2f((float)v2d->cur.xmax, ymaxc); - glVertex2f((float)v2d->cur.xmax, yminc); + glVertex2f(x + offset, yminc); + glVertex2f(x + offset, ymaxc); + glVertex2f((float)v2d->cur.xmax, ymaxc); + glVertex2f((float)v2d->cur.xmax, yminc); glEnd(); } /* draw expand/collapse triangle */ if (expand > 0) { - UI_icon_draw(x+offset, ydatac, expand); + UI_icon_draw(x + offset, ydatac, expand); offset += 17; } /* draw special icon indicating certain data-types */ if (special > -1) { /* for normal channels */ - UI_icon_draw(x+offset, ydatac, special); + UI_icon_draw(x + offset, ydatac, special); offset += 17; } glDisable(GL_BLEND); @@ -854,7 +856,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie else UI_ThemeColor(TH_TEXT); offset += 3; - UI_DrawString(x+offset, y-4, name); + UI_DrawString(x + offset, y - 4, name); /* reset offset - for RHS of panel */ offset = 0; @@ -866,18 +868,18 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* draw protect 'lock' */ if (protect > -1) { offset = 16; - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, protect); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, protect); } /* draw mute 'eye' */ if (mute > -1) { offset += 16; - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, mute); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, mute); } /* draw NLA-action line 'status-icons' - only when there's an action */ if ((ale->type == ANIMTYPE_NLAACTION) && (ale->data)) { - AnimData *adt= ale->adt; + AnimData *adt = ale->adt; offset += 16; @@ -886,28 +888,28 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie /* toggle for tweaking with mapping/no-mapping (i.e. 'in place editing' toggle) */ // for now, use pin icon to symbolise this if (adt->flag & ADT_NLA_EDIT_NOMAP) - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_PINNED); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_PINNED); else - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_UNPINNED); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_UNPINNED); - fdrawline((float)(v2d->cur.xmax-offset), yminc, - (float)(v2d->cur.xmax-offset), ymaxc); + fdrawline((float)(v2d->cur.xmax - offset), yminc, + (float)(v2d->cur.xmax - offset), ymaxc); offset += 16; /* 'tweaking action' indicator - not a button */ - UI_icon_draw((float)(v2d->cur.xmax-offset), ydatac, ICON_EDIT); + UI_icon_draw((float)(v2d->cur.xmax - offset), ydatac, ICON_EDIT); } else { /* XXX firstly draw a little rect to help identify that it's different from the toggles */ glBegin(GL_LINE_LOOP); - glVertex2f((float)v2d->cur.xmax-offset-1, y-7); - glVertex2f((float)v2d->cur.xmax-offset-1, y+9); - glVertex2f((float)v2d->cur.xmax-1, y+9); - glVertex2f((float)v2d->cur.xmax-1, y-7); + glVertex2f((float)v2d->cur.xmax - offset - 1, y - 7); + glVertex2f((float)v2d->cur.xmax - offset - 1, y + 9); + glVertex2f((float)v2d->cur.xmax - 1, y + 9); + glVertex2f((float)v2d->cur.xmax - 1, y - 7); glEnd(); // GL_LINES /* 'push down' icon for normal active-actions */ - UI_icon_draw((float)v2d->cur.xmax-offset, ydatac, ICON_FREEZE); + UI_icon_draw((float)v2d->cur.xmax - offset, ydatac, ICON_FREEZE); } } @@ -927,22 +929,22 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar) int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ar->v2d; - float y= 0.0f; + View2D *v2d = &ar->v2d; + float y = 0.0f; size_t items; int height; /* build list of channels to draw */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); - items= ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + items = ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* Update max-extent of channels here (taking into account scrollers): - * - this is done to allow the channel list to be scrollable, but must be done here - * to avoid regenerating the list again and/or also because channels list is drawn first + * - this is done to allow the channel list to be scrollable, but must be done here + * to avoid regenerating the list again and/or also because channels list is drawn first * - offset of NLACHANNEL_HEIGHT*2 is added to the height of the channels, as first is for * start of list offset, and the second is as a correction for the scrollers. */ - height= ((items*NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla)*2)); + height = ((items * NLACHANNEL_STEP(snla)) + (NLACHANNEL_HEIGHT(snla) * 2)); /* don't use totrect set, as the width stays the same * (NOTE: this is ok here, the configuration is pretty straightforward) */ @@ -951,29 +953,29 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar) UI_view2d_sync(NULL, ac->sa, v2d, V2D_LOCK_COPY); /* draw channels */ - { /* first pass: backdrops + oldstyle drawing */ - y= (float)(-NLACHANNEL_HEIGHT(snla)); + { /* first pass: backdrops + oldstyle drawing */ + y = (float)(-NLACHANNEL_HEIGHT(snla)); draw_nla_channel_list_gl(ac, &anim_data, v2d, y); } - { /* second pass: UI widgets */ - uiBlock *block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + { /* second pass: UI widgets */ + uiBlock *block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); size_t channel_index = 0; - y= (float)(-NLACHANNEL_HEIGHT(snla)); + y = (float)(-NLACHANNEL_HEIGHT(snla)); /* set blending again, as may not be set in previous step */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); /* loop through channels, and set up drawing depending on their type */ - for (ale= anim_data.first; ale; ale= ale->next) { - const float yminc= (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); - const float ymaxc= (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); + for (ale = anim_data.first; ale; ale = ale->next) { + const float yminc = (float)(y - NLACHANNEL_HEIGHT_HALF(snla)); + const float ymaxc = (float)(y + NLACHANNEL_HEIGHT_HALF(snla)); /* check if visible */ - if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || - IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) + if (IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) || + IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) ) { /* draw all channels using standard channel-drawing API */ ANIM_channel_draw_widgets(C, ac, ale, block, yminc, ymaxc, channel_index); diff --git a/source/blender/editors/space_nla/nla_edit.c b/source/blender/editors/space_nla/nla_edit.c index 994021db9ff..8a7e2a8a904 100644 --- a/source/blender/editors/space_nla/nla_edit.c +++ b/source/blender/editors/space_nla/nla_edit.c @@ -69,7 +69,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include #include "nla_private.h" // FIXME... maybe this shouldn't be included? /* *********************************************** */ @@ -80,12 +80,12 @@ void ED_nla_postop_refresh(bAnimContext *ac) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - short filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + short filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); /* get blocks to work on */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { /* performing auto-blending, extend-mode validation, etc. */ BKE_nla_validate_state(ale->data); } @@ -102,21 +102,21 @@ void ED_nla_postop_refresh(bAnimContext *ac) * as if it were the normal Active-Action of its AnimData block. */ -static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) +static int nlaedit_enable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - int ok=0; + int ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ @@ -126,8 +126,8 @@ static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) } /* for each AnimData block with NLA-data, try setting it in tweak-mode */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ale->data; /* try entering tweakmode if valid */ ok += BKE_nla_tweakmode_enter(adt); @@ -144,7 +144,7 @@ static int nlaedit_enable_tweakmode_exec (bContext *C, wmOperator *op) ac.scene->flag |= SCE_NLA_EDIT_ON; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } else { BKE_report(op->reports, RPT_ERROR, "No active strip(s) to enter tweakmode on"); @@ -167,12 +167,12 @@ void NLA_OT_tweakmode_enter(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ------------- */ -static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) +static int nlaedit_disable_tweakmode_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -185,7 +185,7 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the AnimData blocks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ANIMDATA); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* if no blocks, popup error? */ @@ -195,8 +195,8 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) } /* for each AnimData block with NLA-data, try exitting tweak-mode */ - for (ale= anim_data.first; ale; ale= ale->next) { - AnimData *adt= ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + AnimData *adt = ale->data; /* try entering tweakmode if valid */ BKE_nla_tweakmode_exit(adt); @@ -213,7 +213,7 @@ static int nlaedit_disable_tweakmode_exec (bContext *C, wmOperator *op) ac.scene->flag &= ~SCE_NLA_EDIT_ON; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); } /* done */ @@ -232,7 +232,7 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_on; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ @@ -241,24 +241,24 @@ void NLA_OT_tweakmode_exit(wmOperatorType *ot) /* *************************** Calculate Range ************************** */ /* Get the min/max strip extents */ -static void get_nlastrip_extents (bAnimContext *ac, float *min, float *max, const short onlySel) +static void get_nlastrip_extents(bAnimContext *ac, float *min, float *max, const short onlySel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; /* get data to filter */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_NODUPLIS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* set large values to try to override */ - *min= 999999999.0f; - *max= -999999999.0f; + *min = 999999999.0f; + *max = -999999999.0f; /* check if any channels to set range with */ if (anim_data.first) { /* go through channels, finding max extents */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; @@ -278,12 +278,12 @@ static void get_nlastrip_extents (bAnimContext *ac, float *min, float *max, cons else { /* set default range */ if (ac->scene) { - *min= (float)ac->scene->r.sfra; - *max= (float)ac->scene->r.efra; + *min = (float)ac->scene->r.sfra; + *max = (float)ac->scene->r.efra; } else { - *min= -5; - *max= 100; + *min = -5; + *max = 100; } } } @@ -299,12 +299,12 @@ static int nlaedit_viewall(bContext *C, const short onlySel) /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - v2d= &ac.ar->v2d; + v2d = &ac.ar->v2d; /* set the horizontal range, with an extra offset so that the extreme keys will be in view */ get_nlastrip_extents(&ac, &v2d->cur.xmin, &v2d->cur.xmax, onlySel); - extra= 0.1f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -347,7 +347,7 @@ void NLA_OT_view_all(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } void NLA_OT_view_selected(wmOperatorType *ot) @@ -362,7 +362,7 @@ void NLA_OT_view_selected(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ @@ -373,7 +373,7 @@ void NLA_OT_view_selected(wmOperatorType *ot) /* add the specified action as new strip */ -static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) +static int nlaedit_add_actionclip_exec(bContext *C, wmOperator *op) { bAnimContext ac; Scene *scene; @@ -391,11 +391,11 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; - scene= ac.scene; - cfra= (float)CFRA; + scene = ac.scene; + cfra = (float)CFRA; /* get action to use */ - act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); + act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); @@ -405,15 +405,15 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) else if (act->idroot == 0) { /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ BKE_reportf(op->reports, RPT_WARNING, - "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", - act->id.name+2); + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name + 2); } /* get a list of the editable tracks being shown in the NLA * - this is limited to active ones for now, but could be expanded to */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT); - items= ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_ACTIVE | ANIMFILTER_FOREDIT); + items = ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); if (items == 0) { BKE_report(op->reports, RPT_ERROR, "No active track(s) to add strip to"); @@ -421,33 +421,33 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) } /* for every active track, try to add strip to free space in track or to the top of the stack if no space */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; - NlaStrip *strip= NULL; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + NlaStrip *strip = NULL; /* sanity check: only apply actions of the right type for this ID * NOTE: in the case that this hasn't been set, we've already warned the user about this already */ if ((act->idroot) && (act->idroot != GS(ale->id->name))) { BKE_reportf(op->reports, RPT_ERROR, - "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'", - act->id.name+2, ale->id->name); + "Couldn't add action '%s' as it cannot be used relative to ID-blocks of type '%s'", + act->id.name + 2, ale->id->name); continue; } /* create a new strip, and offset it to start on the current frame */ - strip= add_nlastrip(act); + strip = add_nlastrip(act); - strip->end += (cfra - strip->start); - strip->start = cfra; + strip->end += (cfra - strip->start); + strip->start = cfra; /* firstly try adding strip to our current track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt= add_nlatrack(adt, NULL); + nlt = add_nlatrack(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -462,7 +462,7 @@ static int nlaedit_add_actionclip_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -483,11 +483,11 @@ void NLA_OT_actionclip_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* props */ - // TODO: this would be nicer as an ID-pointer... - prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); + // TODO: this would be nicer as an ID-pointer... + prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); RNA_def_enum_funcs(prop, RNA_action_itemf); ot->prop = prop; } @@ -495,7 +495,7 @@ void NLA_OT_actionclip_add(wmOperatorType *ot) /* ******************** Add Transition Operator ***************************** */ /* Add a new transition strip between selected strips */ -static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) +static int nlaedit_add_transition_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -510,23 +510,23 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *s1, *s2; /* get initial pair of strips */ if (ELEM(nlt->strips.first, NULL, nlt->strips.last)) continue; - s1= nlt->strips.first; - s2= s1->next; + s1 = nlt->strips.first; + s2 = s1->next; /* loop over strips */ - for (; s1 && s2; s1=s2, s2=s2->next) { + for (; s1 && s2; s1 = s2, s2 = s2->next) { NlaStrip *strip; /* check if both are selected */ @@ -537,7 +537,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) continue; /* make sure neither one is a transition * - although this is impossible to create with the standard tools, - * the user may have altered the settings + * the user may have altered the settings */ if (ELEM(NLASTRIP_TYPE_TRANSITION, s1->type, s2->type)) continue; @@ -546,25 +546,25 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) continue; /* allocate new strip */ - strip= MEM_callocN(sizeof(NlaStrip), "NlaStrip"); + strip = MEM_callocN(sizeof(NlaStrip), "NlaStrip"); BLI_insertlinkafter(&nlt->strips, s1, strip); /* set the type */ - strip->type= NLASTRIP_TYPE_TRANSITION; + strip->type = NLASTRIP_TYPE_TRANSITION; /* generic settings * - selected flag to highlight this to the user * - auto-blends to ensure that blend in/out values are automatically * determined by overlaps of strips */ - strip->flag = NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_AUTO_BLENDS; + strip->flag = NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_AUTO_BLENDS; /* range is simply defined as the endpoints of the adjacent strips */ - strip->start = s1->end; - strip->end = s2->start; + strip->start = s1->end; + strip->end = s2->start; /* scale and repeat aren't of any use, but shouldn't ever be 0 */ - strip->scale= 1.0f; + strip->scale = 1.0f; strip->repeat = 1.0f; /* auto-name it */ @@ -584,7 +584,7 @@ static int nlaedit_add_transition_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -607,13 +607,13 @@ void NLA_OT_transition_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Add Sound Clip Operator ***************************** */ /* Add a new sound clip */ -static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_add_sound_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -632,16 +632,16 @@ static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) cfra = CFRA; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, add sound clips if it belongs to a speaker */ // TODO: what happens if there aren't any tracks... well that's a more general problem for later - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { Object *ob = (Object *)ale->id; /* may not be object until we actually check! */ AnimData *adt = ale->adt; - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* does this belong to speaker - assumed to live on Object level only */ @@ -649,17 +649,17 @@ static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) continue; /* create a new strip, and offset it to start on the current frame */ - strip= add_nla_soundstrip(ac.scene, ob->data); + strip = add_nla_soundstrip(ac.scene, ob->data); - strip->start += cfra; - strip->end += cfra; + strip->start += cfra; + strip->end += cfra; /* firstly try adding strip to our current track, but if that fails, add to a new track */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* trying to add to the current failed (no space), * so add a new track to the stack, and add to that... */ - nlt= add_nlatrack(adt, NULL); + nlt = add_nlatrack(adt, NULL); BKE_nlatrack_add_strip(nlt, strip); } @@ -674,7 +674,7 @@ static int nlaedit_add_sound_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -692,14 +692,14 @@ void NLA_OT_soundclip_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Add Meta-Strip Operator ***************************** */ /* Add new meta-strips incorporating the selected strips */ /* add the specified action as new strip */ -static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_add_meta_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -712,20 +712,20 @@ static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *strip; /* create meta-strips from the continuous chains of selected strips */ BKE_nlastrips_make_metas(&nlt->strips, 0); /* name the metas */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* auto-name this strip if selected (that means it is a meta) */ if (strip->flag & NLASTRIP_FLAG_SELECT) BKE_nlastrip_validate_name(adt, strip); @@ -736,7 +736,7 @@ static int nlaedit_add_meta_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -754,13 +754,13 @@ void NLA_OT_meta_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Remove Meta-Strip Operator ***************************** */ /* Separate out the strips held by the selected meta-strips */ -static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_remove_meta_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -773,12 +773,12 @@ static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each track, find pairs of strips to add transitions to */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; /* clear all selected meta-strips, regardless of whether they are temporary or not */ BKE_nlastrips_clear_metas(&nlt->strips, 1, 0); @@ -788,7 +788,7 @@ static int nlaedit_remove_meta_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -806,7 +806,7 @@ void NLA_OT_meta_remove(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Duplicate Strips Operator ************************** */ @@ -814,7 +814,7 @@ void NLA_OT_meta_remove(wmOperatorType *ot) * the originals were housed in. */ -static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -829,25 +829,25 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* duplicate strips in tracks starting from the last one so that we're * less likely to duplicate strips we just duplicated... */ - for (ale= anim_data.last; ale; ale= ale->prev) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.last; ale; ale = ale->prev) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *strip, *nstrip, *next; NlaTrack *track; - for (strip= nlt->strips.first; strip; strip= next) { - next= strip->next; + for (strip = nlt->strips.first; strip; strip = next) { + next = strip->next; /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { /* make a copy (assume that this is possible) */ - nstrip= copy_nlastrip(strip); + nstrip = copy_nlastrip(strip); /* in case there's no space in the track above, or we haven't got a reference to it yet, try adding */ if (BKE_nlatrack_add_strip(nlt->next, nstrip) == 0) { @@ -855,12 +855,12 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) * - if the current one is the last one, nlt->next will be NULL, which defaults to adding * at the top of the stack anyway... */ - track= add_nlatrack(adt, nlt->next); + track = add_nlatrack(adt, nlt->next); BKE_nlatrack_add_strip(track, nstrip); } /* deselect the original and the active flag */ - strip->flag &= ~(NLASTRIP_FLAG_SELECT|NLASTRIP_FLAG_ACTIVE); + strip->flag &= ~(NLASTRIP_FLAG_SELECT | NLASTRIP_FLAG_ACTIVE); /* auto-name newly created strip */ BKE_nlastrip_validate_name(adt, nstrip); @@ -878,7 +878,7 @@ static int nlaedit_duplicate_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -910,7 +910,7 @@ void NLA_OT_duplicate(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* to give to transform */ RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", ""); @@ -919,7 +919,7 @@ void NLA_OT_duplicate(wmOperatorType *ot) /* ******************** Delete Strips Operator ***************************** */ /* Deletes the selected NLA-Strips */ -static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_delete_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -932,16 +932,16 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, delete all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *nstrip; - for (strip= nlt->strips.first; strip; strip= nstrip) { - nstrip= strip->next; + for (strip = nlt->strips.first; strip; strip = nstrip) { + nstrip = strip->next; /* if selected, delete */ if (strip->flag & NLASTRIP_FLAG_SELECT) { @@ -949,7 +949,7 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) if ((strip->prev) && (strip->prev->type == NLASTRIP_TYPE_TRANSITION)) free_nlastrip(&nlt->strips, strip->prev); if ((nstrip) && (nstrip->type == NLASTRIP_TYPE_TRANSITION)) { - nstrip= nstrip->next; + nstrip = nstrip->next; free_nlastrip(&nlt->strips, strip->next); } @@ -966,7 +966,7 @@ static int nlaedit_delete_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -984,17 +984,17 @@ void NLA_OT_delete(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Split Strips Operator ***************************** */ /* Splits the selected NLA-Strips into two strips at the midpoint of the strip */ // TODO's? -// - multiple splits -// - variable-length splits? +// - multiple splits +// - variable-length splits? /* split a given Action-Clip strip */ -static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra) +static void nlaedit_split_strip_actclip(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, float cfra) { NlaStrip *nstrip; float splitframe, splitaframe; @@ -1004,44 +1004,44 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip */ if ((cfra > strip->start) && (cfra < strip->end)) { /* use the current frame */ - splitframe= cfra; - splitaframe= nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP); + splitframe = cfra; + splitaframe = nlastrip_get_frame(strip, cfra, NLATIME_CONVERT_UNMAP); } else { /* split in the middle */ float len; - /* strip extents */ - len= strip->end - strip->start; + /* strip extents */ + len = strip->end - strip->start; if (IS_EQF(len, 0.0f)) return; else - splitframe= strip->start + (len / 2.0f); + splitframe = strip->start + (len / 2.0f); - /* action range */ - len= strip->actend - strip->actstart; + /* action range */ + len = strip->actend - strip->actstart; if (IS_EQF(len, 0.0f)) - splitaframe= strip->actend; + splitaframe = strip->actend; else - splitaframe= strip->actstart + (len / 2.0f); + splitaframe = strip->actstart + (len / 2.0f); } /* make a copy (assume that this is possible) and append * it immediately after the current strip */ - nstrip= copy_nlastrip(strip); + nstrip = copy_nlastrip(strip); BLI_insertlinkafter(&nlt->strips, strip, nstrip); /* set the endpoint of the first strip and the start of the new strip * to the splitframe values calculated above */ - strip->end= splitframe; - nstrip->start= splitframe; + strip->end = splitframe; + nstrip->start = splitframe; if ((splitaframe > strip->actstart) && (splitaframe < strip->actend)) { /* only do this if we're splitting down the middle... */ - strip->actend= splitaframe; - nstrip->actstart= splitaframe; + strip->actend = splitaframe; + nstrip->actstart = splitaframe; } /* clear the active flag from the copy */ @@ -1052,7 +1052,7 @@ static void nlaedit_split_strip_actclip (AnimData *adt, NlaTrack *nlt, NlaStrip } /* split a given Meta strip */ -static void nlaedit_split_strip_meta (NlaTrack *nlt, NlaStrip *strip) +static void nlaedit_split_strip_meta(NlaTrack *nlt, NlaStrip *strip) { /* simply ungroup it for now... */ BKE_nlastrips_clear_metastrip(&nlt->strips, strip); @@ -1060,7 +1060,7 @@ static void nlaedit_split_strip_meta (NlaTrack *nlt, NlaStrip *strip) /* ----- */ -static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_split_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1073,17 +1073,17 @@ static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, split all selected strips into two strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - AnimData *adt= ale->adt; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + AnimData *adt = ale->adt; NlaStrip *strip, *next; - for (strip= nlt->strips.first; strip; strip= next) { - next= strip->next; + for (strip = nlt->strips.first; strip; strip = next) { + next = strip->next; /* if selected, split the strip at its midpoint */ if (strip->flag & NLASTRIP_FLAG_SELECT) { @@ -1111,7 +1111,7 @@ static int nlaedit_split_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1129,13 +1129,13 @@ void NLA_OT_split(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Bake Strips Operator ***************************** */ /* Bakes the NLA Strips for the active AnimData blocks */ -static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_bake_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1149,11 +1149,11 @@ static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_ANIMDATA | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each AnimData block, bake strips to animdata... */ - for (ale= anim_data.first; ale; ale= ale->next) { + for (ale = anim_data.first; ale; ale = ale->next) { //BKE_nla_bake(ac.scene, ale->id, ale->data, flag); } @@ -1164,7 +1164,7 @@ static int nlaedit_bake_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1182,7 +1182,7 @@ void NLA_OT_bake(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ @@ -1191,7 +1191,7 @@ void NLA_OT_bake(wmOperatorType *ot) /* ******************** Toggle Muting Operator ************************** */ /* Toggles whether strips are muted or not */ -static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_toggle_mute_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1204,16 +1204,16 @@ static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* go over all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* for every selected strip, toggle muting */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (strip->flag & NLASTRIP_FLAG_SELECT) { /* just flip the mute flag for now */ // TODO: have a pre-pass to check if mute all or unmute all? @@ -1226,7 +1226,7 @@ static int nlaedit_toggle_mute_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1244,13 +1244,13 @@ void NLA_OT_mute_toggle(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Swap Strips Operator ************************** */ /* Tries to exchange strips within their owner tracks */ -static int nlaedit_swap_exec (bContext *C, wmOperator *op) +static int nlaedit_swap_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1263,15 +1263,15 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* consider each track in turn */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; - NlaStrip *strip, *stripN=NULL; - NlaStrip *sa=NULL, *sb=NULL; + NlaStrip *strip, *stripN = NULL; + NlaStrip *sa = NULL, *sb = NULL; /* make temporary metastrips so that entire islands of selections can be moved around */ BKE_nlastrips_make_metas(&nlt->strips, 1); @@ -1289,7 +1289,7 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) } /* get two selected strips only (these will be metas due to prev step) to operate on - * - only allow swapping 2, as with more the context becomes unclear + * - only allow swapping 2, as with more the context becomes unclear */ for (strip = nlt->strips.first; strip; strip = stripN) { stripN = strip->next; @@ -1314,8 +1314,8 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) if (strip) { /* too many selected warning */ BKE_reportf(op->reports, RPT_WARNING, - "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", - nlt->name); + "Too many clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", + nlt->name); } else if (sa == NULL) { /* no warning as this is just a common case, and it may get annoying when doing multiple tracks */ @@ -1323,8 +1323,8 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) else if (sb == NULL) { /* too few selected warning */ BKE_reportf(op->reports, RPT_WARNING, - "Too few clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", - nlt->name); + "Too few clusters of strips selected in NLA Track (%s): needs exactly 2 to be selected", + nlt->name); } else { float nsa[2], nsb[2]; @@ -1334,16 +1334,16 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) BLI_remlink(&nlt->strips, sb); /* calculate new extents for strips */ - /* a --> b */ + /* a --> b */ nsa[0] = sb->start; nsa[1] = sb->start + (sa->end - sa->start); - /* b --> a */ + /* b --> a */ nsb[0] = sa->start; nsb[1] = sa->start + (sb->end - sb->start); /* check if the track has room for the strips to be swapped */ if (BKE_nlastrips_has_space(&nlt->strips, nsa[0], nsa[1]) && - BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) + BKE_nlastrips_has_space(&nlt->strips, nsb[0], nsb[1])) { /* set new extents for strips then */ sa->start = nsa[0]; @@ -1358,12 +1358,12 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) /* not enough room to swap, so show message */ if ((sa->flag & NLASTRIP_FLAG_TEMP_META) || (sb->flag & NLASTRIP_FLAG_TEMP_META)) { BKE_report(op->reports, RPT_WARNING, - "Cannot swap selected strips as they will not be able to fit in their new places"); + "Cannot swap selected strips as they will not be able to fit in their new places"); } else { BKE_reportf(op->reports, RPT_WARNING, - "Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places", - sa->name, sb->name); + "Cannot swap '%s' and '%s' as one or both will not be able to fit in their new places", + sa->name, sb->name); } } @@ -1383,7 +1383,7 @@ static int nlaedit_swap_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1401,13 +1401,13 @@ void NLA_OT_swap(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Move Strips Up Operator ************************** */ /* Tries to move the selected strips into the track above if possible. */ -static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_move_up_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1420,15 +1420,15 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* since we're potentially moving strips from lower tracks to higher tracks, we should * loop over the tracks in reverse order to avoid moving earlier strips up multiple tracks */ - for (ale= anim_data.last; ale; ale= ale->prev) { - NlaTrack *nlt= (NlaTrack *)ale->data; - NlaTrack *nltn= nlt->next; + for (ale = anim_data.last; ale; ale = ale->prev) { + NlaTrack *nlt = (NlaTrack *)ale->data; + NlaTrack *nltn = nlt->next; NlaStrip *strip, *stripn; /* if this track has no tracks after it, skip for now... */ @@ -1436,8 +1436,8 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) continue; /* for every selected strip, try to move */ - for (strip= nlt->strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = nlt->strips.first; strip; strip = stripn) { + stripn = strip->next; if (strip->flag & NLASTRIP_FLAG_SELECT) { /* check if the track above has room for this strip */ @@ -1457,7 +1457,7 @@ static int nlaedit_move_up_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1475,13 +1475,13 @@ void NLA_OT_move_up(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Move Strips Down Operator ************************** */ /* Tries to move the selected strips into the track above if possible. */ -static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_move_down_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1494,15 +1494,15 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* loop through the tracks in normal order, since we're pushing strips down, * strips won't get operated on twice */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; - NlaTrack *nltp= nlt->prev; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; + NlaTrack *nltp = nlt->prev; NlaStrip *strip, *stripn; /* if this track has no tracks before it, skip for now... */ @@ -1510,8 +1510,8 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) continue; /* for every selected strip, try to move */ - for (strip= nlt->strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = nlt->strips.first; strip; strip = stripn) { + stripn = strip->next; if (strip->flag & NLASTRIP_FLAG_SELECT) { /* check if the track below has room for this strip */ @@ -1531,7 +1531,7 @@ static int nlaedit_move_down_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1549,36 +1549,36 @@ void NLA_OT_move_down(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Sync Action Length Operator ***************************** */ /* Recalculate the extents of the action ranges used for the selected strips */ -static int nlaedit_sync_actlen_exec (bContext *C, wmOperator *op) +static int nlaedit_sync_actlen_exec(bContext *C, wmOperator *op) { bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - short active_only= RNA_boolean_get(op->ptr, "active"); + short active_only = RNA_boolean_get(op->ptr, "active"); /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); if (active_only) filter |= ANIMFILTER_ACTIVE; ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, apply scale of all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip selection/active status check */ if (active_only) { if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) @@ -1607,7 +1607,7 @@ static int nlaedit_sync_actlen_exec (bContext *C, wmOperator *op) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1625,7 +1625,7 @@ void NLA_OT_action_sync_length(wmOperatorType *ot) ot->poll = ED_operator_nla_active; // XXX: is this satisfactory... probably requires a check for active strip... /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_boolean(ot->srna, "active", 1, "Active Strip Only", "Only sync the active length for the active strip"); @@ -1635,21 +1635,21 @@ void NLA_OT_action_sync_length(wmOperatorType *ot) /* Reset the scaling of the selected strips to 1.0f */ /* apply scaling to keyframe */ -static short bezt_apply_nlamapping (KeyframeEditData *ked, BezTriple *bezt) +static short bezt_apply_nlamapping(KeyframeEditData *ked, BezTriple *bezt) { /* NLA-strip which has this scaling is stored in ked->data */ - NlaStrip *strip= (NlaStrip *)ked->data; + NlaStrip *strip = (NlaStrip *)ked->data; /* adjust all the times */ - bezt->vec[0][0]= nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP); - bezt->vec[1][0]= nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP); - bezt->vec[2][0]= nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP); + bezt->vec[0][0] = nlastrip_get_frame(strip, bezt->vec[0][0], NLATIME_CONVERT_MAP); + bezt->vec[1][0] = nlastrip_get_frame(strip, bezt->vec[1][0], NLATIME_CONVERT_MAP); + bezt->vec[2][0] = nlastrip_get_frame(strip, bezt->vec[2][0], NLATIME_CONVERT_MAP); /* nothing to return or else we exit */ return 0; } -static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_apply_scale_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1657,24 +1657,24 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) bAnimListElem *ale; int filter; - KeyframeEditData ked= {{NULL}}; + KeyframeEditData ked = {{NULL}}; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* init the editing data */ /* for each NLA-Track, apply scale of all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip must be selected, and must be action-clip only (transitions don't have scale) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { /* if the referenced action is used by other strips, make this strip use its own copy */ @@ -1682,22 +1682,22 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) continue; if (strip->act->id.us > 1) { /* make a copy of the Action to work on */ - bAction *act= copy_action(strip->act); + bAction *act = BKE_action_copy(strip->act); /* set this as the new referenced action, decrementing the users of the old one */ strip->act->id.us--; - strip->act= act; + strip->act = act; } /* setup iterator, and iterate over all the keyframes in the action, applying this scaling */ - ked.data= strip; + ked.data = strip; ANIM_animchanneldata_keyframes_loop(&ked, ac.ads, strip->act, ALE_ACT, NULL, bezt_apply_nlamapping, calchandles_fcurve); /* clear scale of strip now that it has been applied, * and recalculate the extents of the action now that it has been scaled * but leave everything else alone */ - strip->scale= 1.0f; + strip->scale = 1.0f; calc_action_range(strip->act, &strip->actstart, &strip->actend, 0); } } @@ -1707,7 +1707,7 @@ static int nlaedit_apply_scale_exec (bContext *C, wmOperator *UNUSED(op)) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1725,13 +1725,13 @@ void NLA_OT_apply_scale(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Clear Scale Operator ***************************** */ /* Reset the scaling of the selected strips to 1.0f */ -static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) +static int nlaedit_clear_scale_exec(bContext *C, wmOperator *UNUSED(op)) { bAnimContext ac; @@ -1744,15 +1744,15 @@ static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, reset scale of all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* strip must be selected, and must be action-clip only (transitions don't have scale) */ if ((strip->flag & NLASTRIP_FLAG_SELECT) && (strip->type == NLASTRIP_TYPE_CLIP)) { PointerRNA strip_ptr; @@ -1770,7 +1770,7 @@ static int nlaedit_clear_scale_exec (bContext *C, wmOperator *UNUSED(op)) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1788,7 +1788,7 @@ void NLA_OT_clear_scale(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Snap Strips Operator ************************** */ @@ -1803,7 +1803,7 @@ static EnumPropertyItem prop_nlaedit_snap_types[] = { {0, NULL, 0, NULL, NULL} }; -static int nlaedit_snap_exec (bContext *C, wmOperator *op) +static int nlaedit_snap_exec(bContext *C, wmOperator *op) { bAnimContext ac; @@ -1820,18 +1820,18 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* get some necessary vars */ - scene= ac.scene; - secf= (float)FPS; + scene = ac.scene; + secf = (float)FPS; /* since we may add tracks, perform this in reverse order */ - for (ale= anim_data.last; ale; ale= ale->prev) { + for (ale = anim_data.last; ale; ale = ale->prev) { ListBase tmp_strips = {NULL, NULL}; - AnimData *adt= ale->adt; - NlaTrack *nlt= (NlaTrack *)ale->data; + AnimData *adt = ale->adt; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip, *stripn; NlaTrack *track; @@ -1841,37 +1841,37 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) /* apply the snapping to all the temp meta-strips, then put them in a separate list to be added * back to the original only if they still fit */ - for (strip= nlt->strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = nlt->strips.first; strip; strip = stripn) { + stripn = strip->next; if (strip->flag & NLASTRIP_FLAG_TEMP_META) { float start, end; /* get the existing end-points */ - start= strip->start; - end= strip->end; + start = strip->start; + end = strip->end; /* calculate new start position based on snapping mode */ switch (mode) { case NLAEDIT_SNAP_CFRA: /* to current frame */ - strip->start= (float)CFRA; + strip->start = (float)CFRA; break; case NLAEDIT_SNAP_NEAREST_FRAME: /* to nearest frame */ - strip->start= floorf(start+0.5f); + strip->start = floorf(start + 0.5f); break; case NLAEDIT_SNAP_NEAREST_SECOND: /* to nearest second */ - strip->start= floorf(start/secf + 0.5f) * secf; + strip->start = floorf(start / secf + 0.5f) * secf; break; case NLAEDIT_SNAP_NEAREST_MARKER: /* to nearest marker */ - strip->start= (float)ED_markers_find_nearest_marker_time(ac.markers, start); + strip->start = (float)ED_markers_find_nearest_marker_time(ac.markers, start); break; default: /* just in case... no snapping */ - strip->start= start; + strip->start = start; break; } /* get new endpoint based on start-point (and old length) */ - strip->end= strip->start + (end - start); + strip->end = strip->start + (end - start); /* apply transforms to meta-strip to its children */ BKE_nlameta_flush_transforms(strip); @@ -1883,8 +1883,8 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) } /* try adding each meta-strip back to the track one at a time, to make sure they'll fit */ - for (strip= tmp_strips.first; strip; strip= stripn) { - stripn= strip->next; + for (strip = tmp_strips.first; strip; strip = stripn) { + stripn = strip->next; /* remove from temp-strips list */ BLI_remlink(&tmp_strips, strip); @@ -1892,7 +1892,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) /* in case there's no space in the current track, try adding */ if (BKE_nlatrack_add_strip(nlt, strip) == 0) { /* need to add a new track above the current one */ - track= add_nlatrack(adt, nlt); + track = add_nlatrack(adt, nlt); BKE_nlatrack_add_strip(track, strip); /* clear temp meta-strips on this new track, as we may not be able to get back to it */ @@ -1911,7 +1911,7 @@ static int nlaedit_snap_exec (bContext *C, wmOperator *op) ED_nla_postop_refresh(&ac); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1930,7 +1930,7 @@ void NLA_OT_snap(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", prop_nlaedit_snap_types, 0, "Type", ""); @@ -1942,18 +1942,18 @@ void NLA_OT_snap(wmOperatorType *ot) /* ******************** Add F-Modifier Operator *********************** */ /* present a special customised popup menu for this, with some filtering */ -static int nla_fmodifier_add_invoke (bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) +static int nla_fmodifier_add_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *UNUSED(event)) { uiPopupMenu *pup; uiLayout *layout; int i; - pup= uiPupMenuBegin(C, "Add F-Modifier", ICON_NONE); - layout= uiPupMenuLayout(pup); + pup = uiPupMenuBegin(C, "Add F-Modifier", ICON_NONE); + layout = uiPupMenuLayout(pup); /* start from 1 to skip the 'Invalid' modifier type */ for (i = 1; i < FMODIFIER_NUM_TYPES; i++) { - FModifierTypeInfo *fmi= get_fmodifier_typeinfo(i); + FModifierTypeInfo *fmi = get_fmodifier_typeinfo(i); /* check if modifier is valid for this context */ if (fmi == NULL) @@ -1980,7 +1980,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) int filter; FModifier *fcm; - int type= RNA_enum_get(op->ptr, "type"); + int type = RNA_enum_get(op->ptr, "type"); short onlyActive = RNA_boolean_get(op->ptr, "only_active"); /* get editor data */ @@ -1988,24 +1988,24 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip=strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* can F-Modifier be added to the current strip? */ if (onlyActive) { /* if not active, cannot add since we're only adding to active strip */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE)==0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) continue; } else { /* strip must be selected, since we're not just doing active */ - if ((strip->flag & NLASTRIP_FLAG_SELECT)==0) + if ((strip->flag & NLASTRIP_FLAG_SELECT) == 0) continue; } @@ -2014,14 +2014,14 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) continue; /* add F-Modifier of specified type to selected, and make it the active one */ - fcm= add_fmodifier(&strip->modifiers, type); + fcm = add_fmodifier(&strip->modifiers, type); if (fcm) set_active_fmodifier(&strip->modifiers, fcm); else { BKE_reportf(op->reports, RPT_ERROR, - "Modifier couldn't be added to (%s : %s) (see console for details)", - nlt->name, strip->name); + "Modifier couldn't be added to (%s : %s) (see console for details)", + nlt->name, strip->name); } } } @@ -2030,7 +2030,7 @@ static int nla_fmodifier_add_exec(bContext *C, wmOperator *op) BLI_freelistN(&anim_data); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -2049,7 +2049,7 @@ void NLA_OT_fmodifier_add(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "type", fmodifier_type_items, 0, "Type", ""); @@ -2063,7 +2063,7 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok=0; + int filter, ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) @@ -2073,17 +2073,17 @@ static int nla_fmodifier_copy_exec(bContext *C, wmOperator *op) free_fmodifiers_copybuf(); /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip=strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* only add F-Modifier if on active strip? */ - if ((strip->flag & NLASTRIP_FLAG_ACTIVE)==0) + if ((strip->flag & NLASTRIP_FLAG_ACTIVE) == 0) continue; // TODO: when 'active' vs 'all' boolean is added, change last param! @@ -2112,7 +2112,7 @@ void NLA_OT_fmodifier_copy(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ //ot->prop = RNA_def_boolean(ot->srna, "all", 1, "All F-Modifiers", "Copy all the F-Modifiers, instead of just the active one"); @@ -2125,22 +2125,22 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) bAnimContext ac; ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; - int filter, ok=0; + int filter, ok = 0; /* get editor data */ if (ANIM_animdata_get_context(C, &ac) == 0) return OPERATOR_CANCELLED; /* get a list of the editable tracks being shown in the NLA */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_SEL | ANIMFILTER_FOREDIT); ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype); /* for each NLA-Track, add the specified modifier to all selected strips */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; - for (strip= nlt->strips.first; strip; strip=strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { // TODO: do we want to replace existing modifiers? add user pref for that! ok += ANIM_fmodifiers_paste_from_buf(&strip->modifiers, 0); } @@ -2153,7 +2153,7 @@ static int nla_fmodifier_paste_exec(bContext *C, wmOperator *op) if (ok) { /* set notifier that things have changed */ /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_EDITED, NULL); return OPERATOR_FINISHED; } else { @@ -2174,7 +2174,7 @@ void NLA_OT_fmodifier_paste(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *********************************************** */ diff --git a/source/blender/editors/space_nla/nla_intern.h b/source/blender/editors/space_nla/nla_intern.h index 9d0762ce108..398d2d5f1f4 100644 --- a/source/blender/editors/space_nla/nla_intern.h +++ b/source/blender/editors/space_nla/nla_intern.h @@ -55,7 +55,7 @@ void draw_nla_channel_list(bContext *C, bAnimContext *ac, ARegion *ar); /* defines for left-right select tool */ enum { - NLAEDIT_LRSEL_TEST = -1, + NLAEDIT_LRSEL_TEST = -1, NLAEDIT_LRSEL_NONE, NLAEDIT_LRSEL_LEFT, NLAEDIT_LRSEL_RIGHT @@ -131,7 +131,7 @@ void NLA_OT_delete_tracks(wmOperatorType *ot); /* nla_ops.c */ int nlaop_poll_tweakmode_off(bContext *C); -int nlaop_poll_tweakmode_on (bContext *C); +int nlaop_poll_tweakmode_on(bContext *C); short nlaedit_is_tweakmode_on(bAnimContext *ac); diff --git a/source/blender/editors/space_nla/nla_ops.c b/source/blender/editors/space_nla/nla_ops.c index b320adc25fb..3a74d0b4c9c 100644 --- a/source/blender/editors/space_nla/nla_ops.c +++ b/source/blender/editors/space_nla/nla_ops.c @@ -53,7 +53,7 @@ #include "RNA_access.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" /* own include */ /* ************************** poll callbacks for operators **********************************/ @@ -63,7 +63,7 @@ int nlaop_poll_tweakmode_off(bContext *C) Scene *scene; /* for now, we check 2 things: - * 1) active editor must be NLA + * 1) active editor must be NLA * 2) tweakmode is currently set as a 'per-scene' flag * so that it will affect entire NLA data-sets, * but not all AnimData blocks will be in tweakmode for @@ -72,7 +72,7 @@ int nlaop_poll_tweakmode_off(bContext *C) if (ED_operator_nla_active(C) == 0) return 0; - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if ((scene == NULL) || (scene->flag & SCE_NLA_EDIT_ON)) return 0; @@ -85,7 +85,7 @@ int nlaop_poll_tweakmode_on(bContext *C) Scene *scene; /* for now, we check 2 things: - * 1) active editor must be NLA + * 1) active editor must be NLA * 2) tweakmode is currently set as a 'per-scene' flag * so that it will affect entire NLA data-sets, * but not all AnimData blocks will be in tweakmode for @@ -94,7 +94,7 @@ int nlaop_poll_tweakmode_on(bContext *C) if (ED_operator_nla_active(C) == 0) return 0; - scene= CTX_data_scene(C); + scene = CTX_data_scene(C); if ((scene == NULL) || !(scene->flag & SCE_NLA_EDIT_ON)) return 0; @@ -173,119 +173,119 @@ static void nla_keymap_channels(wmKeyMap *keymap) /* NLA-specific (different to standard channels keymap) -------------------------- */ /* selection */ - /* click-select */ - // XXX for now, only leftmouse.... + /* click-select */ + // XXX for now, only leftmouse.... kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, 0, 0); RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_channels_click", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "extend", TRUE); /* channel operations */ - /* add tracks */ + /* add tracks */ kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", FALSE); - kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi = WM_keymap_add_item(keymap, "NLA_OT_tracks_add", AKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); RNA_boolean_set(kmi->ptr, "above_selected", TRUE); - /* delete tracks */ + /* delete tracks */ WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_delete_tracks", DELKEY, KM_PRESS, 0, 0); } -static void nla_keymap_main (wmKeyConfig *keyconf, wmKeyMap *keymap) +static void nla_keymap_main(wmKeyConfig *keyconf, wmKeyMap *keymap) { wmKeyMapItem *kmi; /* selection */ - /* click select */ + /* click select */ kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_boolean_set(kmi->ptr, "extend", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_click_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_boolean_set(kmi->ptr, "extend", TRUE); - /* select left/right */ + /* select left/right */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); - kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0); - RNA_boolean_set(kmi->ptr, "extend", TRUE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); + kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); + RNA_boolean_set(kmi->ptr, "extend", TRUE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_TEST); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_LEFT); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "extend", FALSE); - RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); + RNA_boolean_set(kmi->ptr, "extend", FALSE); + RNA_enum_set(kmi->ptr, "mode", NLAEDIT_LRSEL_RIGHT); - /* deselect all */ - /* TODO: uniformize with other select_all ops? */ + /* deselect all */ + /* TODO: uniformize with other select_all ops? */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "invert", FALSE); + RNA_boolean_set(kmi->ptr, "invert", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0); - RNA_boolean_set(kmi->ptr, "invert", TRUE); + RNA_boolean_set(kmi->ptr, "invert", TRUE); - /* borderselect */ + /* borderselect */ kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, 0, 0); - RNA_boolean_set(kmi->ptr, "axis_range", FALSE); + RNA_boolean_set(kmi->ptr, "axis_range", FALSE); kmi = WM_keymap_add_item(keymap, "NLA_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0); - RNA_boolean_set(kmi->ptr, "axis_range", TRUE); + RNA_boolean_set(kmi->ptr, "axis_range", TRUE); /* view*/ - /* auto-set range */ + /* auto-set range */ //WM_keymap_add_item(keymap, "NLA_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); WM_keymap_add_item(keymap, "NLA_OT_view_all", HOMEKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); /* editing */ - /* tweakmode - * - enter and exit are separate operators with the same hotkey... - * This works as they use different poll()'s - */ + /* tweakmode + * - enter and exit are separate operators with the same hotkey... + * This works as they use different poll()'s + */ WM_keymap_add_item(keymap, "NLA_OT_tweakmode_enter", TABKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_tweakmode_exit", TABKEY, KM_PRESS, 0, 0); - /* add strips */ + /* add strips */ WM_keymap_add_item(keymap, "NLA_OT_actionclip_add", AKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_transition_add", TKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_soundclip_add", KKEY, KM_PRESS, KM_SHIFT, 0); - /* meta-strips */ + /* meta-strips */ WM_keymap_add_item(keymap, "NLA_OT_meta_add", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "NLA_OT_meta_remove", GKEY, KM_PRESS, KM_ALT, 0); - /* duplicate */ + /* duplicate */ WM_keymap_add_item(keymap, "NLA_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0); - /* delete */ + /* delete */ WM_keymap_add_item(keymap, "NLA_OT_delete", XKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "NLA_OT_delete", DELKEY, KM_PRESS, 0, 0); - /* split */ + /* split */ WM_keymap_add_item(keymap, "NLA_OT_split", YKEY, KM_PRESS, 0, 0); - /* toggles */ + /* toggles */ WM_keymap_add_item(keymap, "NLA_OT_mute_toggle", HKEY, KM_PRESS, 0, 0); - /* swap */ + /* swap */ WM_keymap_add_item(keymap, "NLA_OT_swap", FKEY, KM_PRESS, KM_ALT, 0); - /* move up */ + /* move up */ WM_keymap_add_item(keymap, "NLA_OT_move_up", PAGEUPKEY, KM_PRESS, 0, 0); - /* move down */ + /* move down */ WM_keymap_add_item(keymap, "NLA_OT_move_down", PAGEDOWNKEY, KM_PRESS, 0, 0); - /* apply scale */ + /* apply scale */ WM_keymap_add_item(keymap, "NLA_OT_apply_scale", AKEY, KM_PRESS, KM_CTRL, 0); - /* clear scale */ + /* clear scale */ WM_keymap_add_item(keymap, "NLA_OT_clear_scale", SKEY, KM_PRESS, KM_ALT, 0); - /* snap */ + /* snap */ WM_keymap_add_item(keymap, "NLA_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0); - /* add f-modifier */ - WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + /* add f-modifier */ + WM_keymap_add_item(keymap, "NLA_OT_fmodifier_add", MKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0); /* transform system */ transform_keymap_for_space(keyconf, keymap, SPACE_NLA); @@ -318,4 +318,3 @@ void nla_keymap(wmKeyConfig *keyconf) keymap = WM_keymap_find(keyconf, "NLA Editor", SPACE_NLA, 0); nla_keymap_main(keyconf, keymap); } - diff --git a/source/blender/editors/space_nla/nla_select.c b/source/blender/editors/space_nla/nla_select.c index cfd4a3202d2..1ba15d529e8 100644 --- a/source/blender/editors/space_nla/nla_select.c +++ b/source/blender/editors/space_nla/nla_select.c @@ -57,12 +57,12 @@ #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" // own include /* ******************** Utilities ***************************************** */ /* Convert SELECT_* flags to ACHANNEL_SETFLAG_* flags */ -static short selmodes_to_flagmodes (short sel) +static short selmodes_to_flagmodes(short sel) { /* convert selection modes to selection modes */ switch (sel) { @@ -98,13 +98,13 @@ enum { /* Deselects strips in the NLA Editor * - This is called by the deselect all operator, as well as other ones! * - * - test: check if select or deselect all (1) or clear all active (2) + * - test: check if select or deselect all (1) or clear all active (2) * - sel: how to select keyframes * 0 = deselect * 1 = select * 2 = invert */ -static void deselect_nla_strips (bAnimContext *ac, short test, short sel) +static void deselect_nla_strips(bAnimContext *ac, short test, short sel) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; @@ -113,21 +113,21 @@ static void deselect_nla_strips (bAnimContext *ac, short test, short sel) /* determine type-based settings */ // FIXME: double check whether ANIMFILTER_LIST_VISIBLE is needed! - filter= (ANIMFILTER_DATA_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE); /* filter data */ ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* See if we should be selecting or deselecting */ if (test == DESELECT_STRIPS_TEST) { - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* if any strip is selected, break out, since we should now be deselecting */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (strip->flag & NLASTRIP_FLAG_SELECT) { - sel= SELECT_SUBTRACT; + sel = SELECT_SUBTRACT; break; } } @@ -138,15 +138,15 @@ static void deselect_nla_strips (bAnimContext *ac, short test, short sel) } /* convert selection modes to selection modes */ - smode= selmodes_to_flagmodes(sel); + smode = selmodes_to_flagmodes(sel); /* Now set the flags */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* apply same selection to all strips */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { /* set selection */ if (test != DESELECT_STRIPS_CLEARACTIVE) ACHANNEL_SET_FLAG(strip, smode, NLASTRIP_FLAG_SELECT); @@ -178,7 +178,7 @@ static int nlaedit_deselectall_exec(bContext *C, wmOperator *op) deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_ADD); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -195,7 +195,7 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER/*|OPTYPE_UNDO*/; + ot->flag = OPTYPE_REGISTER /*|OPTYPE_UNDO*/; /* props */ RNA_def_boolean(ot->srna, "invert", 0, "Invert", ""); @@ -203,57 +203,57 @@ void NLA_OT_select_all_toggle(wmOperatorType *ot) /* ******************** Border Select Operator **************************** */ /* This operator currently works in one of three ways: - * -> BKEY - 1) all strips within region are selected (NLAEDIT_BORDERSEL_ALLSTRIPS) - * -> ALT-BKEY - depending on which axis of the region was larger... - * -> 2) x-axis, so select all frames within frame range (NLAEDIT_BORDERSEL_FRAMERANGE) - * -> 3) y-axis, so select all frames within channels that region included (NLAEDIT_BORDERSEL_CHANNELS) + * -> BKEY - 1) all strips within region are selected (NLAEDIT_BORDERSEL_ALLSTRIPS) + * -> ALT-BKEY - depending on which axis of the region was larger... + * -> 2) x-axis, so select all frames within frame range (NLAEDIT_BORDERSEL_FRAMERANGE) + * -> 3) y-axis, so select all frames within channels that region included (NLAEDIT_BORDERSEL_CHANNELS) */ /* defines for borderselect mode */ enum { - NLA_BORDERSEL_ALLSTRIPS = 0, + NLA_BORDERSEL_ALLSTRIPS = 0, NLA_BORDERSEL_FRAMERANGE, NLA_BORDERSEL_CHANNELS, } /* eNLAEDIT_BorderSelect_Mode */; -static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, short selectmode) +static void borderselect_nla_strips(bAnimContext *ac, rcti rect, short mode, short selectmode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ac->ar->v2d; + View2D *v2d = &ac->ar->v2d; rctf rectf; - float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax=0; + float ymin /* =(float)(-NLACHANNEL_HEIGHT(snla)) */ /* UNUSED */, ymax = 0; /* convert border-region to view coordinates */ - UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin); - UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax-2, &rectf.xmax, &rectf.ymax); + UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin + 2, &rectf.xmin, &rectf.ymin); + UI_view2d_region_to_view(v2d, rect.xmax, rect.ymax - 2, &rectf.xmax, &rectf.ymax); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* convert selection modes to selection modes */ - selectmode= selmodes_to_flagmodes(selectmode); + selectmode = selmodes_to_flagmodes(selectmode); /* loop over data, doing border select */ - for (ale= anim_data.first; ale; ale= ale->next) { - ymin= ymax - NLACHANNEL_STEP(snla); + for (ale = anim_data.first; ale; ale = ale->next) { + ymin = ymax - NLACHANNEL_STEP(snla); /* perform vertical suitability check (if applicable) */ if ( (mode == NLA_BORDERSEL_FRAMERANGE) || - !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) + !((ymax < rectf.ymin) || (ymin > rectf.ymax)) ) { /* loop over data selecting (only if NLA-Track) */ if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* only select strips if they fall within the required ranges (if applicable) */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if ( (mode == NLA_BORDERSEL_CHANNELS) || BKE_nlastrip_within_bounds(strip, rectf.xmin, rectf.xmax)) { @@ -268,7 +268,7 @@ static void borderselect_nla_strips (bAnimContext *ac, rcti rect, short mode, sh } /* set minimum extent to be the maximum of the next channel */ - ymax= ymin; + ymax = ymin; } /* cleanup */ @@ -281,7 +281,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) { bAnimContext ac; rcti rect; - short mode=0, selectmode=0; + short mode = 0, selectmode = 0; int extend; /* get editor data */ @@ -289,7 +289,7 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; /* clear all selection if not extending selection */ - extend= RNA_boolean_get(op->ptr, "extend"); + extend = RNA_boolean_get(op->ptr, "extend"); if (!extend) deselect_nla_strips(&ac, DESELECT_STRIPS_TEST, SELECT_SUBTRACT); @@ -312,18 +312,18 @@ static int nlaedit_borderselect_exec(bContext *C, wmOperator *op) * used for tweaking timing when "blocking", while channels is not that useful... */ if ((rect.xmax - rect.xmin) >= (rect.ymax - rect.ymin)) - mode= NLA_BORDERSEL_FRAMERANGE; + mode = NLA_BORDERSEL_FRAMERANGE; else - mode= NLA_BORDERSEL_CHANNELS; + mode = NLA_BORDERSEL_CHANNELS; } else - mode= NLA_BORDERSEL_ALLSTRIPS; + mode = NLA_BORDERSEL_ALLSTRIPS; /* apply borderselect action */ borderselect_nla_strips(&ac, rect, mode, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); return OPERATOR_FINISHED; } @@ -344,7 +344,7 @@ void NLA_OT_select_border(wmOperatorType *ot) ot->poll = nlaop_poll_tweakmode_off; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, 1); @@ -365,13 +365,13 @@ static EnumPropertyItem prop_nlaedit_leftright_select_types[] = { /* ------------------- */ -static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftright, short select_mode) +static void nlaedit_select_leftright(bContext *C, bAnimContext *ac, short leftright, short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale; int filter; - Scene *scene= ac->scene; + Scene *scene = ac->scene; float xmin, xmax; /* if currently in tweakmode, exit tweakmode first */ @@ -379,8 +379,8 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr WM_operator_name_call(C, "NLA_OT_tweakmode_exit", WM_OP_EXEC_DEFAULT, NULL); /* if select mode is replace, deselect all keyframes (and channels) first */ - if (select_mode==SELECT_REPLACE) { - select_mode= SELECT_ADD; + if (select_mode == SELECT_REPLACE) { + select_mode = SELECT_ADD; /* - deselect all other keyframes, so that just the newly selected remain * - channels aren't deselected, since we don't re-select any as a consequence @@ -398,20 +398,20 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr xmax = MAXFRAMEF; } - select_mode= selmodes_to_flagmodes(select_mode); + select_mode = selmodes_to_flagmodes(select_mode); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* select strips on the side where most data occurs */ - for (ale= anim_data.first; ale; ale= ale->next) { - NlaTrack *nlt= (NlaTrack *)ale->data; + for (ale = anim_data.first; ale; ale = ale->next) { + NlaTrack *nlt = (NlaTrack *)ale->data; NlaStrip *strip; /* check each strip to see if it is appropriate */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) { ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); } @@ -424,7 +424,7 @@ static void nlaedit_select_leftright (bContext *C, bAnimContext *ac, short leftr /* ------------------- */ -static int nlaedit_select_leftright_exec (bContext *C, wmOperator *op) +static int nlaedit_select_leftright_exec(bContext *C, wmOperator *op) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -436,9 +436,9 @@ static int nlaedit_select_leftright_exec (bContext *C, wmOperator *op) /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* if "test" mode is set, we don't have any info to set this with */ if (leftright == NLAEDIT_LRSEL_TEST) @@ -448,12 +448,12 @@ static int nlaedit_select_leftright_exec (bContext *C, wmOperator *op) nlaedit_select_leftright(C, &ac, leftright, selectmode); /* set notifier that keyframe selection (and channels too) have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME|ND_ANIMCHAN|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | ND_ANIMCHAN | NA_SELECTED, NULL); return OPERATOR_FINISHED; } -static int nlaedit_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent *event) +static int nlaedit_select_leftright_invoke(bContext *C, wmOperator *op, wmEvent *event) { bAnimContext ac; short leftright = RNA_enum_get(op->ptr, "mode"); @@ -464,9 +464,9 @@ static int nlaedit_select_leftright_invoke (bContext *C, wmOperator *op, wmEvent /* handle mode-based testing */ if (leftright == NLAEDIT_LRSEL_TEST) { - Scene *scene= ac.scene; - ARegion *ar= ac.ar; - View2D *v2d= &ar->v2d; + Scene *scene = ac.scene; + ARegion *ar = ac.ar; + View2D *v2d = &ar->v2d; float x; /* determine which side of the current frame mouse is on */ @@ -494,7 +494,7 @@ void NLA_OT_select_leftright(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ ot->prop = RNA_def_enum(ot->srna, "mode", prop_nlaedit_leftright_select_types, NLAEDIT_LRSEL_TEST, "Mode", ""); @@ -505,15 +505,15 @@ void NLA_OT_select_leftright(wmOperatorType *ot) /* ******************** Mouse-Click Select Operator *********************** */ /* select strip directly under mouse */ -static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], short select_mode) +static void mouse_nla_strips(bContext *C, bAnimContext *ac, const int mval[2], short select_mode) { ListBase anim_data = {NULL, NULL}; bAnimListElem *ale = NULL; int filter; SpaceNla *snla = (SpaceNla *)ac->sl; - View2D *v2d= &ac->ar->v2d; - Scene *scene= ac->scene; + View2D *v2d = &ac->ar->v2d; + Scene *scene = ac->scene; NlaStrip *strip = NULL; int channel_index; float xmin, xmax, dummy; @@ -527,15 +527,15 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], /* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click * (that is the size of keyframe icons, so user should be expecting similar tolerances) */ - UI_view2d_region_to_view(v2d, mval[0]-7, mval[1], &xmin, &dummy); - UI_view2d_region_to_view(v2d, mval[0]+7, mval[1], &xmax, &dummy); + UI_view2d_region_to_view(v2d, mval[0] - 7, mval[1], &xmin, &dummy); + UI_view2d_region_to_view(v2d, mval[0] + 7, mval[1], &xmax, &dummy); /* filter data */ - filter= (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); + filter = (ANIMFILTER_DATA_VISIBLE | ANIMFILTER_LIST_VISIBLE | ANIMFILTER_LIST_CHANNELS); ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype); /* try to get channel */ - ale= BLI_findlink(&anim_data, channel_index); + ale = BLI_findlink(&anim_data, channel_index); if (ale == NULL) { /* channel not found */ printf("Error: animation channel (index = %d) not found in mouse_nla_strips()\n", channel_index); @@ -545,10 +545,10 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], else { /* found some channel - we only really should do somethign when its an Nla-Track */ if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; /* loop over NLA-strips in this track, trying to find one which occurs in the necessary bounds */ - for (strip= nlt->strips.first; strip; strip= strip->next) { + for (strip = nlt->strips.first; strip; strip = strip->next) { if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) break; } @@ -580,7 +580,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], /* Highlight NLA-Track */ if (ale->type == ANIMTYPE_NLATRACK) { - NlaTrack *nlt= (NlaTrack *)ale->data; + NlaTrack *nlt = (NlaTrack *)ale->data; nlt->flag |= NLATRACK_SELECTED; ANIM_set_active_channel(ac, ac->data, ac->datatype, filter, nlt, ANIMTYPE_NLATRACK); @@ -591,7 +591,7 @@ static void mouse_nla_strips (bContext *C, bAnimContext *ac, const int mval[2], if (ale) { /* select the strip accordingly (if a matching one was found) */ if (strip) { - select_mode= selmodes_to_flagmodes(select_mode); + select_mode = selmodes_to_flagmodes(select_mode); ACHANNEL_SET_FLAG(strip, select_mode, NLASTRIP_FLAG_SELECT); /* if we selected it, we can make it active too @@ -629,18 +629,18 @@ static int nlaedit_clickselect_invoke(bContext *C, wmOperator *op, wmEvent *even /* select mode is either replace (deselect all, then add) or add/extend */ if (RNA_boolean_get(op->ptr, "extend")) - selectmode= SELECT_INVERT; + selectmode = SELECT_INVERT; else - selectmode= SELECT_REPLACE; + selectmode = SELECT_REPLACE; /* select strips based upon mouse position */ mouse_nla_strips(C, &ac, event->mval, selectmode); /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA|NA_SELECTED, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_SELECTED, NULL); /* for tweak grab to work */ - return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH; + return OPERATOR_FINISHED | OPERATOR_PASS_THROUGH; } void NLA_OT_click_select(wmOperatorType *ot) @@ -655,7 +655,7 @@ void NLA_OT_click_select(wmOperatorType *ot) ot->poll = ED_operator_nla_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* id-props */ RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", ""); // SHIFTKEY diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c index 27c48d2232f..7c9014bd45f 100644 --- a/source/blender/editors/space_nla/space_nla.c +++ b/source/blender/editors/space_nla/space_nla.c @@ -60,7 +60,7 @@ #include "UI_resources.h" #include "UI_view2d.h" -#include "nla_intern.h" // own include +#include "nla_intern.h" /* own include */ /* ******************** manage regions ********************* */ @@ -68,20 +68,20 @@ ARegion *nla_has_buttons_region(ScrArea *sa) { ARegion *ar, *arnew; - ar= BKE_area_find_region_type(sa, RGN_TYPE_UI); + ar = BKE_area_find_region_type(sa, RGN_TYPE_UI); if (ar) return ar; /* add subdiv level; after main */ - ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); /* is error! */ - if (ar==NULL) return NULL; + if (ar == NULL) return NULL; - arnew= MEM_callocN(sizeof(ARegion), "buttons for nla"); + arnew = MEM_callocN(sizeof(ARegion), "buttons for nla"); BLI_insertlinkafter(&sa->regionbase, ar, arnew); - arnew->regiontype= RGN_TYPE_UI; - arnew->alignment= RGN_ALIGN_RIGHT; + arnew->regiontype = RGN_TYPE_UI; + arnew->alignment = RGN_ALIGN_RIGHT; arnew->flag = RGN_FLAG_HIDDEN; @@ -94,72 +94,72 @@ ARegion *nla_has_buttons_region(ScrArea *sa) static SpaceLink *nla_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); - ScrArea *sa= CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); + ScrArea *sa = CTX_wm_area(C); ARegion *ar; SpaceNla *snla; - snla= MEM_callocN(sizeof(SpaceNla), "initnla"); - snla->spacetype= SPACE_NLA; + snla = MEM_callocN(sizeof(SpaceNla), "initnla"); + snla->spacetype = SPACE_NLA; /* allocate DopeSheet data for NLA Editor */ - snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); - snla->ads->source= (ID *)scene; + snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + snla->ads->source = (ID *)scene; /* set auto-snapping settings */ snla->autosnap = SACTSNAP_FRAME; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for nla"); + ar = MEM_callocN(sizeof(ARegion), "header for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* channel list region */ - ar= MEM_callocN(sizeof(ARegion), "channel list for nla"); + ar = MEM_callocN(sizeof(ARegion), "channel list for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_CHANNELS; - ar->alignment= RGN_ALIGN_LEFT; + ar->regiontype = RGN_TYPE_CHANNELS; + ar->alignment = RGN_ALIGN_LEFT; - /* only need to set these settings since this will use the 'stack' configuration */ + /* only need to set these settings since this will use the 'stack' configuration */ ar->v2d.scroll = V2D_SCROLL_BOTTOM; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* ui buttons */ - ar= MEM_callocN(sizeof(ARegion), "buttons area for nla"); + ar = MEM_callocN(sizeof(ARegion), "buttons area for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_UI; - ar->alignment= RGN_ALIGN_RIGHT; + ar->regiontype = RGN_TYPE_UI; + ar->alignment = RGN_ALIGN_RIGHT; ar->flag = RGN_FLAG_HIDDEN; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for nla"); + ar = MEM_callocN(sizeof(ARegion), "main area for nla"); BLI_addtail(&snla->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; - ar->v2d.tot.xmin = (float)(SFRA-10); - ar->v2d.tot.ymin = (float)(-sa->winy)/3.0f; - ar->v2d.tot.xmax = (float)(EFRA+10); + ar->v2d.tot.xmin = (float)(SFRA - 10); + ar->v2d.tot.ymin = (float)(-sa->winy) / 3.0f; + ar->v2d.tot.xmax = (float)(EFRA + 10); ar->v2d.tot.ymax = 0.0f; ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 0.0f; - ar->v2d.min[1]= 0.0f; + ar->v2d.min[0] = 0.0f; + ar->v2d.min[1] = 0.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= 10000.0f; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = 10000.0f; - ar->v2d.minzoom= 0.01f; - ar->v2d.maxzoom= 50; - ar->v2d.scroll = (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.minzoom = 0.01f; + ar->v2d.maxzoom = 50; + ar->v2d.scroll = (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.scroll |= (V2D_SCROLL_RIGHT); - ar->v2d.keepzoom= V2D_LOCKZOOM_Y; - ar->v2d.keepofs= V2D_KEEPOFS_Y; - ar->v2d.align= V2D_ALIGN_NO_POS_Y; + ar->v2d.keepzoom = V2D_LOCKZOOM_Y; + ar->v2d.keepofs = V2D_KEEPOFS_Y; + ar->v2d.align = V2D_ALIGN_NO_POS_Y; ar->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; return (SpaceLink *)snla; @@ -168,7 +168,7 @@ static SpaceLink *nla_new(const bContext *C) /* not spacelink itself */ static void nla_free(SpaceLink *sl) { - SpaceNla *snla= (SpaceNla*) sl; + SpaceNla *snla = (SpaceNla *) sl; if (snla->ads) { BLI_freelistN(&snla->ads->chanbase); @@ -180,12 +180,12 @@ static void nla_free(SpaceLink *sl) /* spacetype; init callback */ static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceNla *snla= (SpaceNla *)sa->spacedata.first; + SpaceNla *snla = (SpaceNla *)sa->spacedata.first; /* init dopesheet data if non-existant (i.e. for old files) */ if (snla->ads == NULL) { - snla->ads= MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); - snla->ads->source= (ID *)G.main->scene.first; // XXX this is bad, but we need this to be set correct + snla->ads = MEM_callocN(sizeof(bDopeSheet), "NlaEdit DopeSheet"); + snla->ads->source = (ID *)G.main->scene.first; // XXX this is bad, but we need this to be set correct } ED_area_tag_refresh(sa); @@ -193,10 +193,10 @@ static void nla_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa) static SpaceLink *nla_duplicate(SpaceLink *sl) { - SpaceNla *snlan= MEM_dupallocN(sl); + SpaceNla *snlan = MEM_dupallocN(sl); /* clear or remove stuff from old */ - snlan->ads= MEM_dupallocN(snlan->ads); + snlan->ads = MEM_dupallocN(snlan->ads); return (SpaceLink *)snlan; } @@ -209,10 +209,10 @@ static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar) UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy); /* own keymap */ - /* own channels map first to override some channel keymaps */ + /* own channels map first to override some channel keymaps */ keymap = WM_keymap_find(wm->defaultconf, "NLA Channels", SPACE_NLA, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); - /* now generic channels map for everything else that can apply */ + /* now generic channels map for everything else that can apply */ keymap = WM_keymap_find(wm->defaultconf, "Animation Channels", 0, 0); WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct); @@ -224,7 +224,7 @@ static void nla_channel_area_init(wmWindowManager *wm, ARegion *ar) static void nla_channel_area_draw(const bContext *C, ARegion *ar) { bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear and setup matrix */ @@ -242,7 +242,7 @@ static void nla_channel_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -265,12 +265,12 @@ static void nla_main_area_init(wmWindowManager *wm, ARegion *ar) static void nla_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceNla *snla= CTX_wm_space_nla(C); + SpaceNla *snla = CTX_wm_space_nla(C); bAnimContext ac; - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - short unit=0, flag=0; + short unit = 0, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -279,8 +279,8 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* time grid */ - unit= (snla->flag & SNLA_DRAWTIME)? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; - grid= UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + unit = (snla->flag & SNLA_DRAWTIME) ? V2D_UNIT_SECONDS : V2D_UNIT_FRAMES; + grid = UI_view2d_grid_calc(CTX_data_scene(C), v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); UI_view2d_grid_draw(v2d, grid, V2D_GRIDLINES_ALL); UI_view2d_grid_free(grid); @@ -296,8 +296,8 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* current frame */ - if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; - if ((snla->flag & SNLA_NODRAWCFRANUM)==0) flag |= DRAWCFRA_SHOW_NUMBOX; + if (snla->flag & SNLA_DRAWTIME) flag |= DRAWCFRA_UNIT_SECONDS; + if ((snla->flag & SNLA_NODRAWCFRANUM) == 0) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); /* markers */ @@ -312,7 +312,7 @@ static void nla_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -371,7 +371,7 @@ static void nla_region_listener(ARegion *ar, wmNotifier *wmn) } break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); break; } @@ -417,7 +417,7 @@ static void nla_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -451,7 +451,7 @@ static void nla_channel_area_listener(ARegion *ar, wmNotifier *wmn) break; default: - if (wmn->data==ND_KEYS) + if (wmn->data == ND_KEYS) ED_region_tag_redraw(ar); } } @@ -496,61 +496,61 @@ static void nla_listener(ScrArea *sa, wmNotifier *wmn) /* only called once, from space/spacetypes.c */ void ED_spacetype_nla(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype nla"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype nla"); ARegionType *art; - st->spaceid= SPACE_NLA; + st->spaceid = SPACE_NLA; strncpy(st->name, "NLA", BKE_ST_MAXNAME); - st->new= nla_new; - st->free= nla_free; - st->init= nla_init; - st->duplicate= nla_duplicate; - st->operatortypes= nla_operatortypes; - st->listener= nla_listener; - st->keymap= nla_keymap; + st->new = nla_new; + st->free = nla_free; + st->init = nla_init; + st->duplicate = nla_duplicate; + st->operatortypes = nla_operatortypes; + st->listener = nla_listener; + st->keymap = nla_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_WINDOW; - art->init= nla_main_area_init; - art->draw= nla_main_area_draw; - art->listener= nla_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->init = nla_main_area_init; + art->draw = nla_main_area_draw; + art->listener = nla_main_area_listener; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= nla_header_area_init; - art->draw= nla_header_area_draw; + art->init = nla_header_area_init; + art->draw = nla_header_area_draw; BLI_addhead(&st->regiontypes, art); /* regions: channels */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_CHANNELS; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= nla_channel_area_init; - art->draw= nla_channel_area_draw; - art->listener= nla_channel_area_listener; + art->init = nla_channel_area_init; + art->draw = nla_channel_area_draw; + art->listener = nla_channel_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: UI buttons */ - art= MEM_callocN(sizeof(ARegionType), "spacetype nla region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype nla region"); art->regionid = RGN_TYPE_UI; - art->prefsizex= 200; - art->keymapflag= ED_KEYMAP_UI; - art->listener= nla_region_listener; - art->init= nla_buttons_area_init; - art->draw= nla_buttons_area_draw; + art->prefsizex = 200; + art->keymapflag = ED_KEYMAP_UI; + art->listener = nla_region_listener; + art->init = nla_buttons_area_init; + art->draw = nla_buttons_area_draw; BLI_addhead(&st->regiontypes, art); @@ -559,4 +559,3 @@ void ED_spacetype_nla(void) BKE_spacetype_register(st); } - diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index bfa8111af3e..205202a0658 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -1247,7 +1247,7 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * Scene *scene= CTX_data_scene(C); ImageUser *iuser= node->storage; char numstr[32]; - const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0); + const int framenr= BKE_image_user_frame_get(iuser, CFRA, 0); BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr); uiItemL(layout, numstr, ICON_NONE); } @@ -1262,9 +1262,6 @@ static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA * } col= uiLayoutColumn(layout, 0); - - if (RNA_enum_get(&imaptr, "type")== IMA_TYPE_MULTILAYER) - uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE); } static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr) @@ -1709,25 +1706,30 @@ static void node_draw_input_file_output(const bContext *C, uiBlock *block, bNodeTree *ntree, bNode *node, bNodeSocket *sock, const char *UNUSED(name), int x, int y, int width) { - NodeImageMultiFileSocket *input = sock->storage; uiLayout *layout, *row; PointerRNA nodeptr, inputptr, imfptr; int imtype; int rx, ry; RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr); - RNA_pointer_create(&ntree->id, &RNA_NodeImageFileSocket, input, &inputptr); layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle()); - row = uiLayoutRow(layout, 0); - - uiItemL(row, input->path, 0); + row = uiLayoutRow(layout, 0); imfptr = RNA_pointer_get(&nodeptr, "format"); imtype = RNA_enum_get(&imfptr, "file_format"); - /* in multilayer format all socket format details are ignored */ - if (imtype != R_IMF_IMTYPE_MULTILAYER) { + if (imtype == R_IMF_IMTYPE_MULTILAYER) { + NodeImageMultiFileSocket *input = sock->storage; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr); + + uiItemL(row, input->layer, 0); + } + else { + NodeImageMultiFileSocket *input = sock->storage; PropertyRNA *imtype_prop; const char *imtype_name; + RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr); + + uiItemL(row, input->path, 0); if (!RNA_boolean_get(&inputptr, "use_node_format")) imfptr = RNA_pointer_get(&inputptr, "format"); @@ -1767,10 +1769,18 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_file_add_socket"); - uiTemplateList(layout, C, ptr, "file_inputs", ptr, "active_input_index", NULL, 0, 0, 0); - active_index = RNA_int_get(ptr, "active_input_index"); - RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_inputs"), active_index, &active_input_ptr); + /* using different collection properties if multilayer format is enabled */ + if (multilayer) { + uiTemplateList(layout, C, ptr, "layer_slots", ptr, "active_input_index", NULL, 0, 0, 0); + RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"), active_index, &active_input_ptr); + } + else { + uiTemplateList(layout, C, ptr, "file_slots", ptr, "active_input_index", NULL, 0, 0, 0); + RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"), active_index, &active_input_ptr); + } + /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */ + active_input_ptr.id.data = ptr->id.data; row = uiLayoutRow(layout, 1); op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS); @@ -1779,19 +1789,25 @@ static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C RNA_enum_set(&op_ptr, "direction", 2); if (active_input_ptr.data) { - uiLayout *row, *col; - - col = uiLayoutColumn(layout, 1); - if (multilayer) - uiItemL(col, "Layer Name:", 0); - else + if (multilayer) { + uiLayout *row, *col; + col = uiLayoutColumn(layout, 1); + + uiItemL(col, "Layer:", 0); + row = uiLayoutRow(col, 0); + uiItemR(row, &active_input_ptr, "name", 0, "", 0); + uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); + } + else { + uiLayout *row, *col; + col = uiLayoutColumn(layout, 1); + uiItemL(col, "File Path:", 0); - row = uiLayoutRow(col, 0); - uiItemR(row, &active_input_ptr, "path", 0, "", 0); - uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); - - /* in multilayer format all socket format details are ignored */ - if (!multilayer) { + row = uiLayoutRow(col, 0); + uiItemR(row, &active_input_ptr, "path", 0, "", 0); + uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY); + + /* format details for individual files */ imfptr = RNA_pointer_get(&active_input_ptr, "format"); col = uiLayoutColumn(layout, 1); diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 5166387d6f4..9e59b3372cb 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -243,8 +243,37 @@ static bNode *editnode_get_active(bNodeTree *ntree) return nodeGetActive(ntree); } -void snode_dag_update(bContext *UNUSED(C), SpaceNode *snode) +static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) { + bNode *node; + + if (ntree == lookup) + return 1; + + for (node=ntree->nodes.first; node; node=node->next) + if (node->type == NODE_GROUP && node->id) + if (has_nodetree((bNodeTree*)node->id, lookup)) + return 1; + + return 0; +} + +static void snode_dag_update_group(void *calldata, ID *owner_id, bNodeTree *ntree) +{ + if (has_nodetree(ntree, calldata)) + DAG_id_tag_update(owner_id, 0); +} + +void snode_dag_update(bContext *C, SpaceNode *snode) +{ + Main *bmain = CTX_data_main(C); + + /* for groups, update all ID's using this */ + if (snode->edittree!=snode->nodetree) { + bNodeTreeType *tti= ntreeGetType(snode->edittree->type); + tti->foreach_nodetree(bmain, snode->edittree, snode_dag_update_group); + } + DAG_id_tag_update(snode->id, 0); } @@ -289,7 +318,7 @@ void ED_node_shader_default(Scene *scene, ID *id) Material *ma= (Material*)id; ma->nodetree = ntree; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { output_type = SH_NODE_OUTPUT_MATERIAL; shader_type = SH_NODE_BSDF_DIFFUSE; } @@ -347,7 +376,7 @@ void ED_node_shader_default(Scene *scene, ID *id) nodeAddLink(ntree, in, fromsock, out, tosock); /* default values */ - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { sock= in->inputs.first; copy_v3_v3(((bNodeSocketValueRGBA*)sock->default_value)->value, color); @@ -585,21 +614,6 @@ static void snode_update(SpaceNode *snode, bNode *node) nodeUpdateID(snode->nodetree, gnode->id); } -static int has_nodetree(bNodeTree *ntree, bNodeTree *lookup) -{ - bNode *node; - - if (ntree == lookup) - return 1; - - for (node=ntree->nodes.first; node; node=node->next) - if (node->type == NODE_GROUP && node->id) - if (has_nodetree((bNodeTree*)node->id, lookup)) - return 1; - - return 0; -} - void ED_node_set_active(Main *bmain, bNodeTree *ntree, bNode *node) { int was_active_texture = (node->flag & NODE_ACTIVE_TEXTURE); @@ -1316,6 +1330,7 @@ void NODE_OT_backimage_zoom(wmOperatorType *ot) /* identifiers */ ot->name = "Background Image Zoom"; ot->idname = "NODE_OT_backimage_zoom"; + ot->description = "Zoom in/out the brackground image"; /* api callbacks */ ot->exec = backimage_zoom; @@ -1482,6 +1497,7 @@ void NODE_OT_backimage_sample(wmOperatorType *ot) /* identifiers */ ot->name = "Backimage Sample"; ot->idname = "NODE_OT_backimage_sample"; + ot->description = "Use mouse to sample background image"; /* api callbacks */ ot->invoke = sample_invoke; @@ -1593,6 +1609,7 @@ void NODE_OT_resize(wmOperatorType *ot) /* identifiers */ ot->name = "Resize Node"; ot->idname = "NODE_OT_resize"; + ot->description = "Resize a node"; /* api callbacks */ ot->invoke = node_resize_invoke; @@ -2547,6 +2564,7 @@ void NODE_OT_link(wmOperatorType *ot) /* identifiers */ ot->name = "Link Nodes"; ot->idname = "NODE_OT_link"; + ot->description = "Use the mouse to create a link between two nodes"; /* api callbacks */ ot->invoke = node_link_invoke; @@ -2666,6 +2684,7 @@ void NODE_OT_links_cut(wmOperatorType *ot) ot->name = "Cut links"; ot->idname = "NODE_OT_links_cut"; + ot->description = "Use the mouse to cut (remove) some links"; ot->invoke = WM_gesture_lines_invoke; ot->modal = WM_gesture_lines_modal; @@ -2711,6 +2730,7 @@ void NODE_OT_links_detach(wmOperatorType *ot) { ot->name = "Detach Links"; ot->idname = "NODE_OT_links_detach"; + ot->description = "Remove all links to selected nodes, and try to connect neighbor nodes together"; ot->exec = detach_links_exec; ot->poll = ED_operator_node_active; @@ -2905,6 +2925,7 @@ void NODE_OT_read_renderlayers(wmOperatorType *ot) ot->name = "Read Render Layers"; ot->idname = "NODE_OT_read_renderlayers"; + ot->description = "Read all render layers of all used scenes"; ot->exec = node_read_renderlayers_exec; @@ -2938,6 +2959,7 @@ void NODE_OT_read_fullsamplelayers(wmOperatorType *ot) ot->name = "Read Full Sample Layers"; ot->idname = "NODE_OT_read_fullsamplelayers"; + ot->description = "Read all render layers of current scene, in full sample"; ot->exec = node_read_fullsamplelayers_exec; @@ -2986,6 +3008,7 @@ void NODE_OT_render_changed(wmOperatorType *ot) ot->name = "Render Changed Layer"; ot->idname = "NODE_OT_render_changed"; + ot->description = "Render current scene, when input node's layer has been changed"; ot->exec = node_render_changed_exec; @@ -3408,7 +3431,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) errno= 0; - ima= BKE_add_image_file(path); + ima= BKE_image_load_exists(path); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Can't read: \"%s\", %s", path, errno ? strerror(errno) : "Unsupported image format"); @@ -3418,7 +3441,7 @@ static int node_add_file_exec(bContext *C, wmOperator *op) else if (RNA_struct_property_is_set(op->ptr, "name")) { char name[MAX_ID_NAME-2]; RNA_string_get(op->ptr, "name", name); - ima= (Image *)find_id("IM", name); + ima= (Image *)BKE_libblock_find_name(ID_IM, name); if (!ima) { BKE_reportf(op->reports, RPT_ERROR, "Image named \"%s\", not found", name); @@ -3544,8 +3567,9 @@ static int new_node_tree_exec(bContext *C, wmOperator *op) void NODE_OT_new_node_tree(wmOperatorType *ot) { /* identifiers */ - ot->name = "New node tree"; + ot->name = "New Node Tree"; ot->idname = "NODE_OT_new_node_tree"; + ot->description = "Create a new node tree"; /* api callbacks */ ot->exec = new_node_tree_exec; diff --git a/source/blender/editors/space_node/node_header.c b/source/blender/editors/space_node/node_header.c index 7ddc4bdf857..bb52c1570aa 100644 --- a/source/blender/editors/space_node/node_header.c +++ b/source/blender/editors/space_node/node_header.c @@ -201,7 +201,7 @@ static void node_add_menu(bContext *C, uiLayout *layout, void *arg_nodeclass) } if (ntree->type == NTREE_SHADER) { - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 1c681220016..7d9d7d736f6 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -111,30 +111,31 @@ void ED_operatormacros_node(void) wmOperatorType *ot; wmOperatorTypeMacro *mot; - ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate selected nodes and move them"; + ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", "Duplicate", "Duplicate selected nodes and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); /* modified operator call for duplicating with input links */ - ot = WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Duplicate selected nodes keeping input links and move them"; + ot = WM_operatortype_append_macro("NODE_OT_duplicate_move_keep_inputs", "Duplicate", + "Duplicate selected nodes keeping input links and move them", + OPTYPE_UNDO|OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "NODE_OT_duplicate"); RNA_boolean_set(mot->ptr, "keep_inputs", TRUE); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", OPTYPE_UNDO); - ot->description = "Select node and link it to a viewer node"; + ot = WM_operatortype_append_macro("NODE_OT_select_link_viewer", "Link Viewer", + "Select node and link it to a viewer node", OPTYPE_UNDO); WM_operatortype_macro_define(ot, "NODE_OT_select"); WM_operatortype_macro_define(ot, "NODE_OT_link_viewer"); - ot = WM_operatortype_append_macro("NODE_OT_move_detach_links", "Detach", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Move a node to detach links"; + ot = WM_operatortype_append_macro("NODE_OT_move_detach_links", "Detach", "Move a node to detach links", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_links_detach"); WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - ot = WM_operatortype_append_macro("NODE_OT_move_detach_links_release", "Detach", OPTYPE_UNDO|OPTYPE_REGISTER); - ot->description = "Move a node to detach links"; + ot = WM_operatortype_append_macro("NODE_OT_move_detach_links_release", "Detach", "Move a node to detach links", + OPTYPE_UNDO|OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_links_detach"); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); RNA_boolean_set(mot->ptr, "release_confirm", TRUE); diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index 13e85c7f74d..785eafeb7c9 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -333,7 +333,7 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) int compatibility= 0; if (ntree->type == NTREE_SHADER) { - if (scene_use_new_shading_nodes(arg->scene)) + if (BKE_scene_use_new_shading_nodes(arg->scene)) compatibility= NODE_NEW_SHADING; else compatibility= NODE_OLD_SHADING; diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index 042b668c9cc..7813bbcd9a6 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -74,20 +74,20 @@ static void outliner_height(SpaceOops *soops, ListBase *lb, int *h) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); if (TSELEM_OPEN(tselem, soops)) outliner_height(soops, &te->subtree, h); (*h) += UI_UNIT_Y; - te= te->next; + te = te->next; } } #if 0 // XXX this is currently disabled until te->xend is set correctly static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { // TreeStoreElem *tselem= TREESTORE(te); @@ -97,16 +97,16 @@ static void outliner_width(SpaceOops *soops, ListBase *lb, int *w) *w = te->xend; } outliner_width(soops, &te->subtree, w); - te= te->next; + te = te->next; } } #endif static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int startx) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; while (te) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); // XXX fixme... (currently, we're using a fixed length of 100)! #if 0 if (te->xend) { @@ -114,12 +114,12 @@ static void outliner_rna_width(SpaceOops *soops, ListBase *lb, int *w, int start *w = te->xend; } #endif - if (startx+100 > *w) - *w = startx+100; + if (startx + 100 > *w) + *w = startx + 100; if (TSELEM_OPEN(tselem, soops)) - outliner_rna_width(soops, &te->subtree, w, startx+UI_UNIT_X); - te= te->next; + outliner_rna_width(soops, &te->subtree, w, startx + UI_UNIT_X); + te = te->next; } } @@ -136,9 +136,9 @@ static void restrictbutton_view_cb(bContext *C, void *poin, void *poin2) if (ob->restrictflag & OB_RESTRICT_VIEW) { /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -153,20 +153,20 @@ static void restrictbutton_sel_cb(bContext *C, void *poin, void *poin2) if (ob->restrictflag & OB_RESTRICT_SELECT) { /* Ouch! There is no backwards pointer from Object to Base, * so have to do loop to find it. */ - ED_base_object_select(object_in_scene(ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_DESELECT); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } static void restrictbutton_rend_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, poin); + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, poin); } static void restrictbutton_r_lay_cb(bContext *C, void *poin, void *UNUSED(poin2)) { - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, poin); + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, poin); } static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *poin2) @@ -175,31 +175,31 @@ static void restrictbutton_modifier_cb(bContext *C, void *UNUSED(poin), void *po DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } static void restrictbutton_bone_cb(bContext *C, void *UNUSED(poin), void *poin2) { - Bone *bone= (Bone *)poin2; + Bone *bone = (Bone *)poin2; if (bone && (bone->flag & BONE_HIDDEN_P)) bone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); } static void restrictbutton_ebone_cb(bContext *C, void *UNUSED(poin), void *poin2) { - EditBone *ebone= (EditBone *)poin2; + EditBone *ebone = (EditBone *)poin2; if (ebone && (ebone->flag & BONE_HIDDEN_A)) ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); } static int group_restrict_flag(Group *gr, int flag) { GroupObject *gob; - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->restrictflag & flag) == 0) return 0; } @@ -211,7 +211,7 @@ static int group_select_flag(Group *gr) { GroupObject *gob; - for (gob= gr->gobject.first; gob; gob= gob->next) + for (gob = gr->gobject.first; gob; gob = gob->next) if ((gob->ob->flag & SELECT)) return 1; @@ -225,23 +225,23 @@ void restrictbutton_gr_restrict_flag(void *poin, void *poin2, int flag) Group *gr = (Group *)poin2; if (group_restrict_flag(gr, flag)) { - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { gob->ob->restrictflag &= ~flag; - if (flag==OB_RESTRICT_VIEW) + if (flag == OB_RESTRICT_VIEW) if (gob->ob->flag & SELECT) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_DESELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_DESELECT); } } else { - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { /* not in editmode */ - if (scene->obedit!=gob->ob) { + if (scene->obedit != gob->ob) { gob->ob->restrictflag |= flag; - if (flag==OB_RESTRICT_VIEW) + if (flag == OB_RESTRICT_VIEW) if ((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } } @@ -266,17 +266,17 @@ static void restrictbutton_gr_restrict_render(bContext *C, void *poin, void *poi static void namebutton_cb(bContext *C, void *tsep, char *oldname) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - Object *obedit= CTX_data_edit_object(C); - TreeStore *ts= soops->treestore; - TreeStoreElem *tselem= tsep; + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + Object *obedit = CTX_data_edit_object(C); + TreeStore *ts = soops->treestore; + TreeStoreElem *tselem = tsep; if (ts && tselem) { - TreeElement *te= outliner_find_tse(soops, tselem); + TreeElement *te = outliner_find_tse(soops, tselem); - if (tselem->type==0) { - test_idbutton(tselem->id->name+2); // library.c, unique name and alpha sort + if (tselem->type == 0) { + test_idbutton(tselem->id->name + 2); // library.c, unique name and alpha sort switch (GS(tselem->id->name)) { case ID_MA: @@ -288,11 +288,11 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) case ID_SCE: WM_event_add_notifier(C, NC_SCENE, NULL); break; default: - WM_event_add_notifier(C, NC_ID|NA_RENAME, NULL); break; + WM_event_add_notifier(C, NC_ID | NA_RENAME, NULL); break; } /* Check the library target exists */ if (te->idcode == ID_LI) { - Library *lib= (Library *)tselem->id; + Library *lib = (Library *)tselem->id; char expanded[FILE_MAX]; BKE_library_filepath_set(lib, lib->name); @@ -306,73 +306,73 @@ static void namebutton_cb(bContext *C, void *tsep, char *oldname) } else { switch (tselem->type) { - case TSE_DEFGROUP: - defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object - break; - case TSE_NLA_ACTION: - test_idbutton(tselem->id->name+2); - break; - case TSE_EBONE: - { - bArmature *arm= (bArmature *)tselem->id; - if (arm->edbo) { - EditBone *ebone= te->directdata; - char newname[sizeof(ebone->name)]; - - /* restore bone name */ - BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); - BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); - ED_armature_bone_rename(obedit->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, OBACT); + case TSE_DEFGROUP: + defgroup_unique_name(te->directdata, (Object *)tselem->id); // id = object + break; + case TSE_NLA_ACTION: + test_idbutton(tselem->id->name + 2); + break; + case TSE_EBONE: + { + bArmature *arm = (bArmature *)tselem->id; + if (arm->edbo) { + EditBone *ebone = te->directdata; + char newname[sizeof(ebone->name)]; + + /* restore bone name */ + BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); + BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); + ED_armature_bone_rename(obedit->data, oldname, newname); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, OBACT); + } } - } break; - case TSE_BONE: + case TSE_BONE: { - Bone *bone= te->directdata; + Bone *bone = te->directdata; Object *ob; char newname[sizeof(bone->name)]; // always make current object active tree_element_active(C, scene, soops, te, 1); // was set_active_object() - ob= OBACT; + ob = OBACT; /* restore bone name */ BLI_strncpy(newname, bone->name, sizeof(bone->name)); BLI_strncpy(bone->name, oldname, sizeof(bone->name)); ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_POSE_CHANNEL: + case TSE_POSE_CHANNEL: { - bPoseChannel *pchan= te->directdata; + bPoseChannel *pchan = te->directdata; Object *ob; char newname[sizeof(pchan->name)]; // always make current object active tree_element_active(C, scene, soops, te, 1); // was set_active_object() - ob= OBACT; + ob = OBACT; /* restore bone name */ BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); ED_armature_bone_rename(ob->data, oldname, newname); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_POSEGRP: + case TSE_POSEGRP: { - Object *ob= (Object *)tselem->id; // id = object - bActionGroup *grp= te->directdata; + Object *ob = (Object *)tselem->id; // id = object + bActionGroup *grp = te->directdata; BLI_uniquename(&ob->pose->agroups, grp, "Group", '.', offsetof(bActionGroup, name), sizeof(grp->name)); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, ob); } break; - case TSE_R_LAYER: - break; + case TSE_R_LAYER: + break; } } tselem->flag &= ~TSE_TEXTBUT; @@ -387,120 +387,120 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar Object *ob = NULL; Group *gr = NULL; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { /* objects have toggle-able restriction flags */ - if (tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type == 0 && te->idcode == ID_OB) { PointerRNA ptr; ob = (Object *)tselem->id; RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ptr); uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_view_cb, scene, ob); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide_select", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_sel_cb, scene, ob); - bt= uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, - &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); + bt = uiDefIconButR(block, ICONTOG, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, + &ptr, "hide_render", -1, 0, 0, -1, -1, NULL); uiButSetFunc(bt, restrictbutton_rend_cb, scene, ob); uiBlockSetEmboss(block, UI_EMBOSS); } - if (tselem->type==0 && te->idcode==ID_GR) { + if (tselem->type == 0 && te->idcode == ID_GR) { int restrict_bool; gr = (Group *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_VIEW); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_VIEW); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_VIEW_ON : ICON_RESTRICT_VIEW_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_view, scene, gr); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_SELECT); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_SELECT); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_SELECT_ON : ICON_RESTRICT_SELECT_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_gr_restrict_select, scene, gr); - restrict_bool= group_restrict_flag(gr, OB_RESTRICT_RENDER); - bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); + restrict_bool = group_restrict_flag(gr, OB_RESTRICT_RENDER); + bt = uiDefIconBut(block, ICONTOG, 0, restrict_bool ? ICON_RESTRICT_RENDER_ON : ICON_RESTRICT_RENDER_OFF, (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, NULL, 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_gr_restrict_render, scene, gr); uiBlockSetEmboss(block, UI_EMBOSS); } /* scene render layers and passes have toggle-able flags too! */ - else if (tselem->type==TSE_R_LAYER) { + else if (tselem->type == TSE_R_LAYER) { uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); + bt = uiDefIconButBitI(block, ICONTOGN, SCE_LAY_DISABLE, 0, ICON_CHECKBOX_HLT - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, te->directdata, 0, 0, 0, 0, "Render this RenderLayer"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if (tselem->type==TSE_R_PASS) { - int *layflag= te->directdata; - int passflag= 1<nr; + else if (tselem->type == TSE_R_PASS) { + int *layflag = te->directdata; + int passflag = 1 << tselem->nr; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT-1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Render this Pass"); + bt = uiDefIconButBitI(block, ICONTOG, passflag, 0, ICON_CHECKBOX_HLT - 1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Render this Pass"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); - layflag++; /* is lay_xor */ + layflag++; /* is lay_xor */ if (ELEM8(passflag, SCE_PASS_SPEC, SCE_PASS_SHADOW, SCE_PASS_AO, SCE_PASS_REFLECT, SCE_PASS_REFRACT, SCE_PASS_INDIRECT, SCE_PASS_EMIT, SCE_PASS_ENVIRONMENT)) - bt= uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag)?ICON_DOT:ICON_BLANK1, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); + bt = uiDefIconButBitI(block, TOG, passflag, 0, (*layflag & passflag) ? ICON_DOT : ICON_BLANK1, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, layflag, 0, 0, 0, 0, "Exclude this Pass from Combined"); uiButSetFunc(bt, restrictbutton_r_lay_cb, tselem->id, NULL); uiBlockSetEmboss(block, UI_EMBOSS); } - else if (tselem->type==TSE_MODIFIER) { - ModifierData *md= (ModifierData *)te->directdata; + else if (tselem->type == TSE_MODIFIER) { + ModifierData *md = (ModifierData *)te->directdata; ob = (Object *)tselem->id; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Realtime, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); - bt= uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); + bt = uiDefIconButBitI(block, ICONTOGN, eModifierMode_Render, 0, ICON_RESTRICT_RENDER_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(md->mode), 0, 0, 0, 0, "Restrict/Allow renderability"); uiButSetFunc(bt, restrictbutton_modifier_cb, scene, ob); } - else if (tselem->type==TSE_POSE_CHANNEL) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; + else if (tselem->type == TSE_POSE_CHANNEL) { + bPoseChannel *pchan = (bPoseChannel *)te->directdata; Bone *bone = pchan->bone; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_P, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, bone); - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(bone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_bone_cb, NULL, NULL); } - else if (tselem->type==TSE_EBONE) { - EditBone *ebone= (EditBone *)te->directdata; + else if (tselem->type == TSE_EBONE) { + EditBone *ebone = (EditBone *)te->directdata; uiBlockSetEmboss(block, UI_EMBOSSN); - bt= uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_HIDDEN_A, 0, ICON_RESTRICT_VIEW_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow visibility in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, ebone); - bt= uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, - (int)ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X-1, UI_UNIT_Y-1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); + bt = uiDefIconButBitI(block, ICONTOG, BONE_UNSELECTABLE, 0, ICON_RESTRICT_SELECT_OFF, + (int)ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, (int)te->ys, UI_UNIT_X - 1, UI_UNIT_Y - 1, &(ebone->flag), 0, 0, 0, 0, "Restrict/Allow selection in the 3D View"); uiButSetFunc(bt, restrictbutton_ebone_cb, NULL, NULL); } } @@ -511,23 +511,23 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar static void outliner_draw_rnacols(ARegion *ar, int sizex) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; - float miny = v2d->cur.ymin-V2D_SCROLL_HEIGHT; - if (minytot.ymin) miny = v2d->tot.ymin; + float miny = v2d->cur.ymin - V2D_SCROLL_HEIGHT; + if (miny < v2d->tot.ymin) miny = v2d->tot.ymin; UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* draw column separator lines */ fdrawline((float)sizex, - v2d->cur.ymax, - (float)sizex, - miny); + v2d->cur.ymax, + (float)sizex, + miny); - fdrawline((float)sizex+OL_RNA_COL_SIZEX, - v2d->cur.ymax, - (float)sizex+OL_RNA_COL_SIZEX, - miny); + fdrawline((float)sizex + OL_RNA_COL_SIZEX, + v2d->cur.ymax, + (float)sizex + OL_RNA_COL_SIZEX, + miny); } static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, SpaceOops *soops, int sizex, ListBase *lb) @@ -539,21 +539,21 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa uiBlockSetEmboss(block, UI_EMBOSST); - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->type == TSE_RNA_PROPERTY) { - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; if (!(RNA_property_type(prop) == PROP_POINTER && (TSELEM_OPEN(tselem, soops))) ) - uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + uiDefAutoButR(block, ptr, prop, -1, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } else if (tselem->type == TSE_RNA_ARRAY_ELEM) { - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; - uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y-1); + uiDefAutoButR(block, ptr, prop, te->index, "", ICON_NONE, sizex, (int)te->ys, OL_RNA_COL_SIZEX, UI_UNIT_Y - 1); } } @@ -563,7 +563,7 @@ static void outliner_draw_rnabuts(uiBlock *block, Scene *scene, ARegion *ar, Spa static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *arg2) { - wmOperatorType *ot= arg2; + wmOperatorType *ot = arg2; wmKeyMapItem *kmi = arg_kmi; if (ot) @@ -572,10 +572,10 @@ static void operator_call_cb(struct bContext *UNUSED(C), void *arg_kmi, void *ar static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(arg_kmi), const char *str, uiSearchItems *items) { - GHashIterator *iter= WM_operatortype_iter(); + GHashIterator *iter = WM_operatortype_iter(); - for ( ; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot= BLI_ghashIterator_getValue(iter); + for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { + wmOperatorType *ot = BLI_ghashIterator_getValue(iter); if (BLI_strcasestr(ot->idname, str)) { char name[OP_MAX_TYPENAME]; @@ -583,7 +583,7 @@ static void operator_search_cb(const struct bContext *UNUSED(C), void *UNUSED(ar /* display name for menu */ WM_operator_py_idname(name, ot->idname); - if (0==uiSearchItemAdd(items, name, ot, 0)) + if (0 == uiSearchItemAdd(items, name, ot, 0)) break; } } @@ -595,17 +595,17 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) { static char search[OP_MAX_TYPENAME]; wmEvent event; - wmWindow *win= CTX_wm_window(C); + wmWindow *win = CTX_wm_window(C); wmKeyMapItem *kmi = arg_kmi; - wmOperatorType *ot= WM_operatortype_find(kmi->idname, 0); + wmOperatorType *ot = WM_operatortype_find(kmi->idname, 0); uiBlock *block; uiBut *but; /* clear initial search string, then all items show */ - search[0]= 0; + search[0] = 0; - block= uiBeginBlock(C, ar, "_popup", UI_EMBOSS); - uiBlockSetFlag(block, UI_BLOCK_LOOP|UI_BLOCK_REDRAW|UI_BLOCK_RET_1); + block = uiBeginBlock(C, ar, "_popup", UI_EMBOSS); + uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_REDRAW | UI_BLOCK_RET_1); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 15, 150, uiSearchBoxhHeight(), NULL, 0, 0, 0, 0, NULL); @@ -617,20 +617,20 @@ static uiBlock *operator_search_menu(bContext *C, ARegion *ar, void *arg_kmi) uiBlockSetDirection(block, UI_DOWN); uiEndBlock(C, block); - event= *(win->eventstate); /* XXX huh huh? make api call */ - event.type= EVT_BUT_OPEN; - event.val= KM_PRESS; - event.customdata= but; - event.customdatafree= FALSE; + event = *(win->eventstate); /* XXX huh huh? make api call */ + event.type = EVT_BUT_OPEN; + event.val = KM_PRESS; + event.customdata = but; + event.customdatafree = FALSE; wm_event_add(win, &event); return block; } -#define OL_KM_KEYBOARD 0 -#define OL_KM_MOUSE 1 -#define OL_KM_TWEAK 2 -#define OL_KM_SPECIALS 3 +#define OL_KM_KEYBOARD 0 +#define OL_KM_MOUSE 1 +#define OL_KM_TWEAK 2 +#define OL_KM_SPECIALS 3 static short keymap_menu_type(short type) { @@ -643,11 +643,11 @@ static short keymap_menu_type(short type) static const char *keymap_type_menu(void) { - static const char string[]= - "Event Type%t" - "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) - "|Mouse%x" STRINGIFY(OL_KM_MOUSE) - "|Tweak%x" STRINGIFY(OL_KM_TWEAK) + static const char string[] = + "Event Type%t" + "|Keyboard%x" STRINGIFY(OL_KM_KEYBOARD) + "|Mouse%x" STRINGIFY(OL_KM_MOUSE) + "|Tweak%x" STRINGIFY(OL_KM_TWEAK) // "|Specials%x" STRINGIFY(OL_KM_SPECIALS) ; @@ -656,25 +656,25 @@ static const char *keymap_type_menu(void) static const char *keymap_mouse_menu(void) { - static const char string[]= - "Mouse Event%t" - "|Left Mouse%x" STRINGIFY(LEFTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) - "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) - "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) - "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) - "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) - "|Select Mouse%x" STRINGIFY(SELECTMOUSE) - "|Mouse Move%x" STRINGIFY(MOUSEMOVE) - "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) - "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) - "|Wheel In%x" STRINGIFY(WHEELINMOUSE) - "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) - "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) - "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) - "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) + static const char string[] = + "Mouse Event%t" + "|Left Mouse%x" STRINGIFY(LEFTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Middle Mouse%x" STRINGIFY(MIDDLEMOUSE) + "|Right Mouse%x" STRINGIFY(RIGHTMOUSE) + "|Button4 Mouse%x" STRINGIFY(BUTTON4MOUSE) + "|Button5 Mouse%x" STRINGIFY(BUTTON5MOUSE) + "|Action Mouse%x" STRINGIFY(ACTIONMOUSE) + "|Select Mouse%x" STRINGIFY(SELECTMOUSE) + "|Mouse Move%x" STRINGIFY(MOUSEMOVE) + "|Wheel Up%x" STRINGIFY(WHEELUPMOUSE) + "|Wheel Down%x" STRINGIFY(WHEELDOWNMOUSE) + "|Wheel In%x" STRINGIFY(WHEELINMOUSE) + "|Wheel Out%x" STRINGIFY(WHEELOUTMOUSE) + "|Mouse/Trackpad Pan%x" STRINGIFY(MOUSEPAN) + "|Mouse/Trackpad Zoom%x" STRINGIFY(MOUSEZOOM) + "|Mouse/Trackpad Rotate%x" STRINGIFY(MOUSEROTATE) ; return string; @@ -682,13 +682,13 @@ static const char *keymap_mouse_menu(void) static const char *keymap_tweak_menu(void) { - static const char string[]= - "Tweak Event%t" - "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) - "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) - "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) - "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) - "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) + static const char string[] = + "Tweak Event%t" + "|Left Mouse%x" STRINGIFY(EVT_TWEAK_L) + "|Middle Mouse%x" STRINGIFY(EVT_TWEAK_M) + "|Right Mouse%x" STRINGIFY(EVT_TWEAK_R) + "|Action Mouse%x" STRINGIFY(EVT_TWEAK_A) + "|Select Mouse%x" STRINGIFY(EVT_TWEAK_S) ; return string; @@ -696,17 +696,17 @@ static const char *keymap_tweak_menu(void) static const char *keymap_tweak_dir_menu(void) { - static const char string[]= - "Tweak Direction%t" - "|Any%x" STRINGIFY(KM_ANY) - "|North%x" STRINGIFY(EVT_GESTURE_N) - "|North-East%x" STRINGIFY(EVT_GESTURE_NE) - "|East%x" STRINGIFY(EVT_GESTURE_E) - "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) - "|South%x" STRINGIFY(EVT_GESTURE_S) - "|South-West%x" STRINGIFY(EVT_GESTURE_SW) - "|West%x" STRINGIFY(EVT_GESTURE_W) - "|North-West%x" STRINGIFY(EVT_GESTURE_NW) + static const char string[] = + "Tweak Direction%t" + "|Any%x" STRINGIFY(KM_ANY) + "|North%x" STRINGIFY(EVT_GESTURE_N) + "|North-East%x" STRINGIFY(EVT_GESTURE_NE) + "|East%x" STRINGIFY(EVT_GESTURE_E) + "|Sout-East%x" STRINGIFY(EVT_GESTURE_SE) + "|South%x" STRINGIFY(EVT_GESTURE_S) + "|South-West%x" STRINGIFY(EVT_GESTURE_SW) + "|West%x" STRINGIFY(EVT_GESTURE_W) + "|North-West%x" STRINGIFY(EVT_GESTURE_NW) ; return string; @@ -716,25 +716,25 @@ static const char *keymap_tweak_dir_menu(void) static void keymap_type_cb(bContext *C, void *kmi_v, void *UNUSED(arg_v)) { wmKeyMapItem *kmi = kmi_v; - short maptype= keymap_menu_type(kmi->type); + short maptype = keymap_menu_type(kmi->type); - if (maptype!=kmi->maptype) { + if (maptype != kmi->maptype) { switch (kmi->maptype) { case OL_KM_KEYBOARD: - kmi->type= AKEY; - kmi->val= KM_PRESS; + kmi->type = AKEY; + kmi->val = KM_PRESS; break; case OL_KM_MOUSE: - kmi->type= LEFTMOUSE; - kmi->val= KM_PRESS; + kmi->type = LEFTMOUSE; + kmi->val = KM_PRESS; break; case OL_KM_TWEAK: - kmi->type= EVT_TWEAK_L; - kmi->val= KM_ANY; + kmi->type = EVT_TWEAK_L; + kmi->val = KM_ANY; break; case OL_KM_SPECIALS: - kmi->type= AKEY; - kmi->val= KM_PRESS; + kmi->type = AKEY; + kmi->val = KM_PRESS; } ED_region_tag_redraw(CTX_wm_region(C)); } @@ -747,67 +747,67 @@ static void outliner_draw_keymapbuts(uiBlock *block, ARegion *ar, SpaceOops *soo uiBlockSetEmboss(block, UI_EMBOSST); - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { uiBut *but; const char *str; - int xstart= 240; - int butw1= UI_UNIT_X; /* operator */ - int butw2= 90; /* event type, menus */ - int butw3= 43; /* modifiers */ + int xstart = 240; + int butw1 = UI_UNIT_X; /* operator */ + int butw2 = 90; /* event type, menus */ + int butw3 = 43; /* modifiers */ if (tselem->type == TSE_KEYMAP_ITEM) { wmKeyMapItem *kmi = te->directdata; /* modal map? */ - if (kmi->propvalue); + if (kmi->propvalue) ; else { - uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys+1, butw1, UI_UNIT_Y-1, "Assign new Operator"); + uiDefBlockBut(block, operator_search_menu, kmi, "", xstart, (int)te->ys + 1, butw1, UI_UNIT_Y - 1, "Assign new Operator"); } - xstart+= butw1+10; + xstart += butw1 + 10; /* map type button */ - kmi->maptype= keymap_menu_type(kmi->type); + kmi->maptype = keymap_menu_type(kmi->type); - str= keymap_type_menu(); - but = uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->maptype, 0, 0, 0, 0, "Event type"); + str = keymap_type_menu(); + but = uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->maptype, 0, 0, 0, 0, "Event type"); uiButSetFunc(but, keymap_type_cb, kmi, NULL); - xstart+= butw2+5; + xstart += butw2 + 5; /* edit actual event */ switch (kmi->maptype) { case OL_KM_KEYBOARD: - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, "Key code"); - xstart+= butw2+5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, "Key code"); + xstart += butw2 + 5; break; case OL_KM_MOUSE: - str= keymap_mouse_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Mouse button"); - xstart+= butw2+5; + str = keymap_mouse_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, 0, 0, 0, 0, "Mouse button"); + xstart += butw2 + 5; break; case OL_KM_TWEAK: - str= keymap_tweak_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); - xstart+= butw2+5; - str= keymap_tweak_dir_menu(); - uiDefButS(block, MENU, 0, str, xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); - xstart+= butw2+5; + str = keymap_tweak_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->type, 0, 0, 0, 0, "Tweak gesture"); + xstart += butw2 + 5; + str = keymap_tweak_dir_menu(); + uiDefButS(block, MENU, 0, str, xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->val, 0, 0, 0, 0, "Tweak gesture direction"); + xstart += butw2 + 5; break; } /* modifiers */ - uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys+1, butw3+5, UI_UNIT_Y-1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart+= butw3+5; - uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart+= butw3; - xstart+= 5; - uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys+1, butw3, UI_UNIT_Y-1, &kmi->keymodifier, "Key Modifier code"); - xstart+= butw3+5; + uiDefButS(block, OPTION, 0, "Shift", xstart, (int)te->ys + 1, butw3 + 5, UI_UNIT_Y - 1, &kmi->shift, 0, 0, 0, 0, "Modifier"); xstart += butw3 + 5; + uiDefButS(block, OPTION, 0, "Ctrl", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->ctrl, 0, 0, 0, 0, "Modifier"); xstart += butw3; + uiDefButS(block, OPTION, 0, "Alt", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->alt, 0, 0, 0, 0, "Modifier"); xstart += butw3; + uiDefButS(block, OPTION, 0, "OS", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->oskey, 0, 0, 0, 0, "Modifier"); xstart += butw3; + xstart += 5; + uiDefKeyevtButS(block, 0, "", xstart, (int)te->ys + 1, butw3, UI_UNIT_Y - 1, &kmi->keymodifier, "Key Modifier code"); + xstart += butw3 + 5; /* rna property */ if (kmi->ptr && kmi->ptr->data) { - uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys+1, butw2, UI_UNIT_Y-1, &kmi->oskey, 0, 0, 0, 0, ""); xstart+= butw2; + uiDefBut(block, LABEL, 0, "(RNA property)", xstart, (int)te->ys + 1, butw2, UI_UNIT_Y - 1, &kmi->oskey, 0, 0, 0, 0, ""); xstart += butw2; } (void)xstart; @@ -826,33 +826,33 @@ static void outliner_buttons(const bContext *C, uiBlock *block, ARegion *ar, Spa TreeStoreElem *tselem; int spx, dx, len; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (te->ys+2*UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (te->ys + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && te->ys <= ar->v2d.cur.ymax) { if (tselem->flag & TSE_TEXTBUT) { /* If we add support to rename Sequence. * need change this. */ - if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature + if (tselem->type == TSE_POSE_BASE) continue; // prevent crash when trying to rename 'pose' entry of armature - if (tselem->type==TSE_EBONE) len = sizeof(((EditBone*) 0)->name); - else if (tselem->type==TSE_MODIFIER) len = sizeof(((ModifierData*) 0)->name); - else if (tselem->id && GS(tselem->id->name)==ID_LI) len = sizeof(((Library*) 0)->name); - else len= MAX_ID_NAME-2; + if (tselem->type == TSE_EBONE) len = sizeof(((EditBone *) 0)->name); + else if (tselem->type == TSE_MODIFIER) len = sizeof(((ModifierData *) 0)->name); + else if (tselem->id && GS(tselem->id->name) == ID_LI) len = sizeof(((Library *) 0)->name); + else len = MAX_ID_NAME - 2; - dx= (int)UI_GetStringWidth(te->name); - if (dx<100) dx= 100; - spx=te->xs+2*UI_UNIT_X-4; - if (spx+dx+10>ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax-spx-10; + dx = (int)UI_GetStringWidth(te->name); + if (dx < 100) dx = 100; + spx = te->xs + 2 * UI_UNIT_X - 4; + if (spx + dx + 10 > ar->v2d.cur.xmax) dx = ar->v2d.cur.xmax - spx - 10; - bt= uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx+10, UI_UNIT_Y-1, (void *)te->name, 1.0, (float)len, 0, 0, ""); + bt = uiDefBut(block, TEX, OL_NAMEBUTTON, "", spx, (int)te->ys, dx + 10, UI_UNIT_Y - 1, (void *)te->name, 1.0, (float)len, 0, 0, ""); uiButSetRenameFunc(bt, namebutton_cb, tselem); /* returns false if button got removed */ - if ( 0 == uiButActiveOnly(C, block, bt) ) + if (0 == uiButActiveOnly(C, block, bt) ) tselem->flag &= ~TSE_TEXTBUT; } } @@ -882,8 +882,8 @@ static void tselem_draw_icon_uibut(struct DrawIconArg *arg, int icon) } else { /* XXX investigate: button placement of icons is way different than UI_icon_draw? */ - float ufac= UI_UNIT_X/20.0f; - uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x-3.0f*ufac, arg->y, UI_UNIT_X-4.0f*ufac, UI_UNIT_Y-4.0f*ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); + float ufac = UI_UNIT_X / 20.0f; + uiBut *but = uiDefIconBut(arg->block, LABEL, 0, icon, arg->x - 3.0f * ufac, arg->y, UI_UNIT_X - 4.0f * ufac, UI_UNIT_Y - 4.0f * ufac, NULL, 0.0, 0.0, 1.0, arg->alpha, (arg->id && arg->id->lib) ? arg->id->lib->name : ""); if (arg->id) uiButSetDragID(but, arg->id); @@ -896,15 +896,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto struct DrawIconArg arg; /* make function calls a bit compacter */ - arg.block= block; - arg.id= tselem->id; + arg.block = block; + arg.id = tselem->id; arg.xmax = xmax; - arg.x= x; - arg.y= y; - arg.alpha= alpha; + arg.x = x; + arg.y = y; + arg.alpha = alpha; if (tselem->type) { - switch ( tselem->type) { + switch (tselem->type) { case TSE_ANIM_DATA: UI_icon_draw(x, y, ICON_ANIM_DATA); break; // xxx case TSE_NLA: @@ -930,8 +930,8 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto UI_icon_draw(x, y, ICON_PARTICLES); break; case TSE_MODIFIER: { - Object *ob= (Object *)tselem->id; - ModifierData *md= BLI_findlink(&ob->modifiers, tselem->nr); + Object *ob = (Object *)tselem->id; + ModifierData *md = BLI_findlink(&ob->modifiers, tselem->nr); switch (md->type) { case eModifierType_Subsurf: UI_icon_draw(x, y, ICON_MOD_SUBSURF); break; @@ -1033,15 +1033,15 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto case TSE_POSEGRP_BASE: UI_icon_draw(x, y, ICON_VERTEXSEL); break; case TSE_SEQUENCE: - if (te->idcode==SEQ_MOVIE) + if (te->idcode == SEQ_MOVIE) UI_icon_draw(x, y, ICON_SEQUENCE); - else if (te->idcode==SEQ_META) + else if (te->idcode == SEQ_META) UI_icon_draw(x, y, ICON_DOT); - else if (te->idcode==SEQ_SCENE) + else if (te->idcode == SEQ_SCENE) UI_icon_draw(x, y, ICON_SCENE); - else if (te->idcode==SEQ_SOUND) + else if (te->idcode == SEQ_SOUND) UI_icon_draw(x, y, ICON_SOUND); - else if (te->idcode==SEQ_IMAGE) + else if (te->idcode == SEQ_IMAGE) UI_icon_draw(x, y, ICON_IMAGE_COL); else UI_icon_draw(x, y, ICON_PARTICLES); @@ -1054,7 +1054,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto break; case TSE_RNA_STRUCT: if (RNA_struct_is_ID(te->rnaptr.type)) { - arg.id= (ID *)te->rnaptr.data; + arg.id = (ID *)te->rnaptr.data; tselem_draw_icon_uibut(&arg, RNA_struct_ui_icon(te->rnaptr.type)); } else @@ -1065,7 +1065,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } } else if (GS(tselem->id->name) == ID_OB) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; switch (ob->type) { case OB_LAMP: tselem_draw_icon_uibut(&arg, ICON_OUTLINER_OB_LAMP); break; @@ -1093,7 +1093,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto } } else { - switch ( GS(tselem->id->name)) { + switch (GS(tselem->id->name)) { case ID_SCE: tselem_draw_icon_uibut(&arg, ICON_SCENE_DATA); break; case ID_ME: @@ -1106,7 +1106,7 @@ static void tselem_draw_icon(uiBlock *block, int xmax, float x, float y, TreeSto tselem_draw_icon_uibut(&arg, ICON_OUTLINER_DATA_LATTICE); break; case ID_LA: { - Lamp *la= (Lamp *)tselem->id; + Lamp *la = (Lamp *)tselem->id; switch (la->type) { case LA_LOCAL: @@ -1161,46 +1161,46 @@ static void outliner_draw_iconrow(bContext *C, uiBlock *block, Scene *scene, Spa TreeStoreElem *tselem; int active; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { /* exit drawing early */ if ((*offsx) - UI_UNIT_X > xmax) break; - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* object hierarchy always, further constrained on level */ - if (level<1 || (tselem->type==0 && te->idcode==ID_OB)) { + if (level < 1 || (tselem->type == 0 && te->idcode == ID_OB)) { /* active blocks get white circle */ - if (tselem->type==0) { - if (te->idcode==ID_OB) active= (OBACT==(Object *)tselem->id); - else if (scene->obedit && scene->obedit->data==tselem->id) active= 1; // XXX use context? - else active= tree_element_active(C, scene, soops, te, 0); + if (tselem->type == 0) { + if (te->idcode == ID_OB) active = (OBACT == (Object *)tselem->id); + else if (scene->obedit && scene->obedit->data == tselem->id) active = 1; // XXX use context? + else active = tree_element_active(C, scene, soops, te, 0); } - else active= tree_element_type_active(NULL, scene, soops, te, tselem, 0); + else active = tree_element_type_active(NULL, scene, soops, te, tselem, 0); if (active) { - float ufac= UI_UNIT_X/20.0f; + float ufac = UI_UNIT_X / 20.0f; uiSetRoundBox(UI_CNR_ALL); glColor4ub(255, 255, 255, 100); - uiRoundBox((float) * offsx-0.5f*ufac, (float)ys-1.0f*ufac, (float)*offsx+UI_UNIT_Y-3.0f*ufac, (float)ys+UI_UNIT_Y-3.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); + uiRoundBox((float) *offsx - 0.5f * ufac, (float)ys - 1.0f * ufac, (float)*offsx + UI_UNIT_Y - 3.0f * ufac, (float)ys + UI_UNIT_Y - 3.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac); glEnable(GL_BLEND); /* roundbox disables */ } tselem_draw_icon(block, xmax, (float)*offsx, (float)ys, tselem, te, 0.5f); - te->xs= (float)*offsx; - te->ys= (float)ys; - te->xend= (short)*offsx+UI_UNIT_X; - te->flag |= TE_ICONROW; // for click + te->xs = (float)*offsx; + te->ys = (float)ys; + te->xend = (short)*offsx + UI_UNIT_X; + te->flag |= TE_ICONROW; // for click (*offsx) += UI_UNIT_X; } /* this tree element always has same amount of branches, so don't draw */ - if (tselem->type!=TSE_R_LAYER) - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level+1, xmax, offsx, ys); + if (tselem->type != TSE_R_LAYER) + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, level + 1, xmax, offsx, ys); } } @@ -1211,11 +1211,11 @@ static void outliner_set_coord_tree_element(SpaceOops *soops, TreeElement *te, i TreeElement *ten; /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); + te->xs = (float)startx; + te->ys = (float)(*starty); - for (ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coord_tree_element(soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) { + outliner_set_coord_tree_element(soops, ten, startx + UI_UNIT_X, starty); } } @@ -1224,17 +1224,17 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene { TreeElement *ten; TreeStoreElem *tselem; - float ufac= UI_UNIT_X/20.0f; - int offsx= 0, active=0; // active=1 active obj, else active data + float ufac = UI_UNIT_X / 20.0f; + int offsx = 0, active = 0; // active=1 active obj, else active data - tselem= TREESTORE(te); + tselem = TREESTORE(te); - if (*starty+2*UI_UNIT_Y >= ar->v2d.cur.ymin && *starty<= ar->v2d.cur.ymax) { - int xmax= ar->v2d.cur.xmax; + if (*starty + 2 * UI_UNIT_Y >= ar->v2d.cur.ymin && *starty <= ar->v2d.cur.ymax) { + int xmax = ar->v2d.cur.xmax; /* icons can be ui buts, we don't want it to overlap with restrict */ - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - xmax-= OL_TOGW+UI_UNIT_X; + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + xmax -= OL_TOGW + UI_UNIT_X; glEnable(GL_BLEND); @@ -1242,149 +1242,149 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene * we don't expand items when searching in the datablocks but we * still want to highlight any filter matches. */ - if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis==SO_DATABLOCKS && soops->search_string[0]!=0)) && - (tselem->flag & TSE_SEARCHMATCH)) + if ( (SEARCHING_OUTLINER(soops) || (soops->outlinevis == SO_DATABLOCKS && soops->search_string[0] != 0)) && + (tselem->flag & TSE_SEARCHMATCH)) { char col[4]; UI_GetThemeColorType4ubv(TH_MATCH, SPACE_OUTLINER, col); - col[3]=100; + col[3] = 100; glColor4ubv((GLubyte *)col); - glRecti(startx, *starty+1, ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + glRecti(startx, *starty + 1, ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); } /* colors for active/selected data */ - if (tselem->type==0) { - if (te->idcode==ID_SCE) { + if (tselem->type == 0) { + if (te->idcode == ID_SCE) { if (tselem->id == (ID *)scene) { glColor4ub(255, 255, 255, 100); - active= 2; + active = 2; } } - else if (te->idcode==ID_GR) { + else if (te->idcode == ID_GR) { Group *gr = (Group *)tselem->id; if (group_select_flag(gr)) { char col[4]; UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; glColor4ubv((GLubyte *)col); - active= 2; + active = 2; } } - else if (te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; + else if (te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; - if (ob==OBACT || (ob->flag & SELECT)) { - char col[4]= {0, 0, 0, 0}; + if (ob == OBACT || (ob->flag & SELECT)) { + char col[4] = {0, 0, 0, 0}; /* outliner active ob: always white text, circle color now similar to view3d */ - active= 2; /* means it draws a color circle */ - if (ob==OBACT) { + active = 2; /* means it draws a color circle */ + if (ob == OBACT) { if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_ACTIVE, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; } - active= 1; /* means it draws white text */ + active = 1; /* means it draws white text */ } else if (ob->flag & SELECT) { UI_GetThemeColorType4ubv(TH_SELECT, SPACE_VIEW3D, col); - col[3]= 100; + col[3] = 100; } glColor4ubv((GLubyte *)col); } } - else if (scene->obedit && scene->obedit->data==tselem->id) { + else if (scene->obedit && scene->obedit->data == tselem->id) { glColor4ub(255, 255, 255, 100); - active= 2; + active = 2; } else { if (tree_element_active(C, scene, soops, te, 0)) { glColor4ub(220, 220, 255, 100); - active= 2; + active = 2; } } } else { - if ( tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active= 2; + if (tree_element_type_active(NULL, scene, soops, te, tselem, 0) ) active = 2; glColor4ub(220, 220, 255, 100); } /* active circle */ if (active) { uiSetRoundBox(UI_CNR_ALL); - uiRoundBox((float)startx+UI_UNIT_Y-1.5f*ufac, (float)*starty+2.0f*ufac, (float)startx+2.0f*UI_UNIT_Y-4.0f*ufac, (float)*starty+UI_UNIT_Y-1.0f*ufac, UI_UNIT_Y/2.0f-2.0f*ufac); - glEnable(GL_BLEND); /* roundbox disables it */ + uiRoundBox((float)startx + UI_UNIT_Y - 1.5f * ufac, (float)*starty + 2.0f * ufac, (float)startx + 2.0f * UI_UNIT_Y - 4.0f * ufac, (float)*starty + UI_UNIT_Y - 1.0f * ufac, UI_UNIT_Y / 2.0f - 2.0f * ufac); + glEnable(GL_BLEND); /* roundbox disables it */ te->flag |= TE_ACTIVE; // for lookup in display hierarchies } /* open/close icon, only when sublevels, except for scene */ - if (te->subtree.first || (tselem->type==0 && te->idcode==ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { + if (te->subtree.first || (tselem->type == 0 && te->idcode == ID_SCE) || (te->flag & TE_LAZY_CLOSED)) { int icon_x; - if (tselem->type==0 && ELEM(te->idcode, ID_OB, ID_SCE)) + if (tselem->type == 0 && ELEM(te->idcode, ID_OB, ID_SCE)) icon_x = startx; else - icon_x = startx+5*ufac; + icon_x = startx + 5 * ufac; - // icons a bit higher + // icons a bit higher if (TSELEM_OPEN(tselem, soops)) - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_DOWN); + UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_DOWN); else - UI_icon_draw((float)icon_x, (float)*starty+2*ufac, ICON_DISCLOSURE_TRI_RIGHT); + UI_icon_draw((float)icon_x, (float)*starty + 2 * ufac, ICON_DISCLOSURE_TRI_RIGHT); } - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; /* datatype icon */ if (!(ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM))) { // icons a bit higher - tselem_draw_icon(block, xmax, (float)startx+offsx - 0.5f*ufac, (float)*starty+2.0f*ufac, tselem, te, 1.0f); + tselem_draw_icon(block, xmax, (float)startx + offsx - 0.5f * ufac, (float)*starty + 2.0f * ufac, tselem, te, 1.0f); - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; } else - offsx+= 2*ufac; + offsx += 2 * ufac; - if (tselem->type==0 && tselem->id->lib) { + if (tselem->type == 0 && tselem->id->lib) { glPixelTransferf(GL_ALPHA_SCALE, 0.5f); if (tselem->id->flag & LIB_INDIRECT) - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_INDIRECT); + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_INDIRECT); else - UI_icon_draw((float)startx+offsx, (float)*starty+2*ufac, ICON_LIBRARY_DATA_DIRECT); + UI_icon_draw((float)startx + offsx, (float)*starty + 2 * ufac, ICON_LIBRARY_DATA_DIRECT); glPixelTransferf(GL_ALPHA_SCALE, 1.0f); - offsx+= UI_UNIT_X; + offsx += UI_UNIT_X; } glDisable(GL_BLEND); /* name */ - if (active==1) UI_ThemeColor(TH_TEXT_HI); + if (active == 1) UI_ThemeColor(TH_TEXT_HI); else if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.75f); else UI_ThemeColor(TH_TEXT); - UI_DrawString(startx+offsx, *starty+5*ufac, te->name); + UI_DrawString(startx + offsx, *starty + 5 * ufac, te->name); - offsx+= (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); + offsx += (int)(UI_UNIT_X + UI_GetStringWidth(te->name)); /* closed item, we draw the icons, not when it's a scene, or master-server list though */ if (!TSELEM_OPEN(tselem, soops)) { if (te->subtree.first) { - if (tselem->type==0 && te->idcode==ID_SCE); - else if (tselem->type!=TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ - int tempx= startx+offsx; + if (tselem->type == 0 && te->idcode == ID_SCE) ; + else if (tselem->type != TSE_R_LAYER) { /* this tree element always has same amount of branches, so don't draw */ + int tempx = startx + offsx; // divider UI_ThemeColorShade(TH_BACK, -40); - glRecti(tempx -10, *starty+4, tempx -8, *starty+UI_UNIT_Y-4); + glRecti(tempx - 10, *starty + 4, tempx - 8, *starty + UI_UNIT_Y - 4); glEnable(GL_BLEND); glPixelTransferf(GL_ALPHA_SCALE, 0.5); - outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty+2); + outliner_draw_iconrow(C, block, scene, soops, &te->subtree, 0, xmax, &tempx, *starty + 2); glPixelTransferf(GL_ALPHA_SCALE, 1.0); glDisable(GL_BLEND); @@ -1393,21 +1393,21 @@ static void outliner_draw_tree_element(bContext *C, uiBlock *block, Scene *scene } } /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)*starty; - te->xend= startx+offsx; + te->xs = (float)startx; + te->ys = (float)*starty; + te->xend = startx + offsx; if (TSELEM_OPEN(tselem, soops)) { - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; - for (ten= te->subtree.first; ten; ten= ten->next) - outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) + outliner_draw_tree_element(C, block, scene, ar, soops, ten, startx + UI_UNIT_X, starty); } else { - for (ten= te->subtree.first; ten; ten= ten->next) + for (ten = te->subtree.first; ten; ten = ten->next) outliner_set_coord_tree_element(soops, te, startx, starty); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; } } @@ -1417,30 +1417,30 @@ static void outliner_draw_hierarchy(SpaceOops *soops, ListBase *lb, int startx, TreeStoreElem *tselem; int y1, y2; - if (lb->first==NULL) return; + if (lb->first == NULL) return; - y1=y2= *starty; /* for vertical lines between objects */ - for (te=lb->first; te; te= te->next) { - y2= *starty; - tselem= TREESTORE(te); + y1 = y2 = *starty; /* for vertical lines between objects */ + for (te = lb->first; te; te = te->next) { + y2 = *starty; + tselem = TREESTORE(te); /* horizontal line? */ - if (tselem->type==0 && (te->idcode==ID_OB || te->idcode==ID_SCE)) - glRecti(startx, *starty, startx+UI_UNIT_X, *starty-1); + if (tselem->type == 0 && (te->idcode == ID_OB || te->idcode == ID_SCE)) + glRecti(startx, *starty, startx + UI_UNIT_X, *starty - 1); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) - outliner_draw_hierarchy(soops, &te->subtree, startx+UI_UNIT_X, starty); + outliner_draw_hierarchy(soops, &te->subtree, startx + UI_UNIT_X, starty); } /* vertical line */ - te= lb->last; - if (te->parent || lb->first!=lb->last) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) { + te = lb->last; + if (te->parent || lb->first != lb->last) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == ID_OB) { - glRecti(startx, y1+UI_UNIT_Y, startx+1, y2); + glRecti(startx, y1 + UI_UNIT_Y, startx + 1, y2); } } } @@ -1450,19 +1450,19 @@ static void outliner_draw_struct_marks(ARegion *ar, SpaceOops *soops, ListBase * TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); /* selection status */ if (TSELEM_OPEN(tselem, soops)) if (tselem->type == TSE_RNA_STRUCT) - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, *starty+UI_UNIT_Y-1); + glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, *starty + UI_UNIT_Y - 1); - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { outliner_draw_struct_marks(ar, soops, &te->subtree, starty); if (tselem->type == TSE_RNA_STRUCT) - fdrawline(0, (float)*starty+UI_UNIT_Y, ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (float)*starty+UI_UNIT_Y); + fdrawline(0, (float)*starty + UI_UNIT_Y, ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (float)*starty + UI_UNIT_Y); } } } @@ -1472,14 +1472,14 @@ static void outliner_draw_selection(ARegion *ar, SpaceOops *soops, ListBase *lb, TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); /* selection status */ if (tselem->flag & TSE_SELECTED) { - glRecti(0, *starty+1, (int)ar->v2d.cur.xmax, *starty+UI_UNIT_Y-1); + glRecti(0, *starty + 1, (int)ar->v2d.cur.xmax, *starty + UI_UNIT_Y - 1); } - *starty-= UI_UNIT_Y; + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) outliner_draw_selection(ar, soops, &te->subtree, starty); } } @@ -1497,26 +1497,26 @@ static void outliner_draw_tree(bContext *C, uiBlock *block, Scene *scene, ARegio /* struct marks */ UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); //UI_ThemeColorShade(TH_BACK, -20); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_struct_marks(ar, soops, &soops->tree, &starty); } /* always draw selection fill before hierarchy */ UI_GetThemeColor3fv(TH_SELECT_HIGHLIGHT, col); glColor3fv(col); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; outliner_draw_selection(ar, soops, &soops->tree, &starty); // grey hierarchy lines UI_ThemeColorBlend(TH_BACK, TH_TEXT, 0.4f); - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y/2-OL_Y_OFFSET; - startx= 6; + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y / 2 - OL_Y_OFFSET; + startx = 6; outliner_draw_hierarchy(soops, &soops->tree, startx, &starty); // items themselves - starty= (int)ar->v2d.tot.ymax-UI_UNIT_Y-OL_Y_OFFSET; - startx= 0; - for (te= soops->tree.first; te; te= te->next) { + starty = (int)ar->v2d.tot.ymax - UI_UNIT_Y - OL_Y_OFFSET; + startx = 0; + for (te = soops->tree.first; te; te = te->next) { outliner_draw_tree_element(C, block, scene, ar, soops, te, startx, &starty); } } @@ -1527,12 +1527,12 @@ static void outliner_back(ARegion *ar) int ystart; UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + ystart = (int)ar->v2d.tot.ymax; + ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - while (ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti(0, ystart, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti(0, ystart, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, ystart + UI_UNIT_Y); + ystart -= 2 * UI_UNIT_Y; } } @@ -1542,36 +1542,36 @@ static void outliner_draw_restrictcols(ARegion *ar) /* background underneath */ UI_ThemeColor(TH_BACK); - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, (int)ar->v2d.cur.ymin-V2D_SCROLL_HEIGHT-1, (int)ar->v2d.cur.xmax+V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); + glRecti((int)ar->v2d.cur.xmax - OL_TOGW, (int)ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT - 1, (int)ar->v2d.cur.xmax + V2D_SCROLL_WIDTH, (int)ar->v2d.cur.ymax); UI_ThemeColorShade(TH_BACK, 6); - ystart= (int)ar->v2d.tot.ymax; - ystart= UI_UNIT_Y*(ystart/(UI_UNIT_Y))-OL_Y_OFFSET; + ystart = (int)ar->v2d.tot.ymax; + ystart = UI_UNIT_Y * (ystart / (UI_UNIT_Y)) - OL_Y_OFFSET; - while (ystart+2*UI_UNIT_Y > ar->v2d.cur.ymin) { - glRecti((int)ar->v2d.cur.xmax-OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart+UI_UNIT_Y); - ystart-= 2*UI_UNIT_Y; + while (ystart + 2 * UI_UNIT_Y > ar->v2d.cur.ymin) { + glRecti((int)ar->v2d.cur.xmax - OL_TOGW, ystart, (int)ar->v2d.cur.xmax, ystart + UI_UNIT_Y); + ystart -= 2 * UI_UNIT_Y; } UI_ThemeColorShadeAlpha(TH_BACK, -15, -200); /* view */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_VIEWX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_SELECTX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); /* render */ - fdrawline(ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymax, - ar->v2d.cur.xmax-OL_TOG_RESTRICT_RENDERX, - ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); + fdrawline(ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymax, + ar->v2d.cur.xmax - OL_TOG_RESTRICT_RENDERX, + ar->v2d.cur.ymin - V2D_SCROLL_HEIGHT); } /* ****************************************************** */ @@ -1579,13 +1579,13 @@ static void outliner_draw_restrictcols(ARegion *ar) void draw_outliner(const bContext *C) { - Main *mainvar= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; - SpaceOops *soops= CTX_wm_space_outliner(C); + Main *mainvar = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; + SpaceOops *soops = CTX_wm_space_outliner(C); uiBlock *block; - int sizey= 0, sizex= 0, sizex_rna= 0; + int sizey = 0, sizex = 0, sizex_rna = 0; outliner_build_tree(mainvar, scene, soops); // always @@ -1594,7 +1594,7 @@ void draw_outliner(const bContext *C) if (ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP)) { /* RNA has two columns: - * - column 1 is (max_width + OL_RNA_COL_SPACEX) or + * - column 1 is (max_width + OL_RNA_COL_SPACEX) or * (OL_RNA_COL_X), whichever is wider... * - column 2 is fixed at OL_RNA_COL_SIZEX * @@ -1603,13 +1603,13 @@ void draw_outliner(const bContext *C) /* get actual width of column 1 */ outliner_rna_width(soops, &soops->tree, &sizex_rna, 0); - sizex_rna= MAX2(OL_RNA_COLX, sizex_rna+OL_RNA_COL_SPACEX); + sizex_rna = MAX2(OL_RNA_COLX, sizex_rna + OL_RNA_COL_SPACEX); /* get width of data (for setting 'tot' rect, this is column 1 + column 2 + a bit extra) */ if (soops->outlinevis == SO_KEYMAP) - sizex= sizex_rna + OL_RNA_COL_SIZEX*3 + 50; // XXX this is only really a quick hack to make this wide enough... + sizex = sizex_rna + OL_RNA_COL_SIZEX * 3 + 50; // XXX this is only really a quick hack to make this wide enough... else - sizex= sizex_rna + OL_RNA_COL_SIZEX + 50; + sizex = sizex_rna + OL_RNA_COL_SIZEX + 50; } else { /* width must take into account restriction columns (if visible) so that entries will still be visible */ @@ -1618,8 +1618,8 @@ void draw_outliner(const bContext *C) /* constant offset for restriction columns */ // XXX this isn't that great yet... - if ((soops->flag & SO_HIDE_RESTRICTCOLS)==0) - sizex += OL_TOGW*3; + if ((soops->flag & SO_HIDE_RESTRICTCOLS) == 0) + sizex += OL_TOGW * 3; } /* tweak to display last line (when list bigger than window) */ @@ -1632,13 +1632,13 @@ void draw_outliner(const bContext *C) UI_view2d_totRect_set(v2d, sizex, sizey); /* force display to pixel coords */ - v2d->flag |= (V2D_PIXELOFS_X|V2D_PIXELOFS_Y); + v2d->flag |= (V2D_PIXELOFS_X | V2D_PIXELOFS_Y); /* set matrix for 2d-view controls */ UI_view2d_view_ortho(v2d); /* draw outliner stuff (background, hierachy lines and names) */ outliner_back(ar); - block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); outliner_draw_tree((bContext *)C, block, scene, ar, soops); if (ELEM(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF)) { diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 7b200e9593d..04e9cbf24c2 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -75,13 +75,13 @@ static int outliner_open_back(SpaceOops *soops, TreeElement *te) { TreeStoreElem *tselem; - int retval= 0; + int retval = 0; - for (te= te->parent; te; te= te->parent) { - tselem= TREESTORE(te); + for (te = te->parent; te; te = te->parent) { + tselem = TREESTORE(te); if (tselem->flag & TSE_CLOSED) { tselem->flag &= ~TSE_CLOSED; - retval= 1; + retval = 1; } } return retval; @@ -92,17 +92,17 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { /* check if this tree-element was the one we're seeking */ if (te == teFind) { - *found= 1; + *found = 1; return; } /* try to see if sub-tree contains it then */ outliner_open_reveal(soops, &te->subtree, teFind, found); if (*found) { - tselem= TREESTORE(te); + tselem = TREESTORE(te); if (tselem->flag & TSE_CLOSED) tselem->flag &= ~TSE_CLOSED; return; @@ -119,8 +119,8 @@ static void outliner_open_reveal(SpaceOops *soops, ListBase *lb, TreeElement *te static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement *te, int all, const float mval[2]) { - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); /* all below close/open? */ if (all) { @@ -135,7 +135,7 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_openclose(C, soops, te, all, mval)) return 1; } @@ -146,15 +146,15 @@ static int do_outliner_item_openclose(bContext *C, SpaceOops *soops, TreeElement /* event can enterkey, then it opens/closes */ static int outliner_item_openclose(bContext *C, wmOperator *op, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - int all= RNA_boolean_get(op->ptr, "all"); + int all = RNA_boolean_get(op->ptr, "all"); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_openclose(C, soops, te, all, fmval)) break; } @@ -183,12 +183,12 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, { /* can't rename rna datablocks entries */ if (ELEM3(tselem->type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - /* do nothing */; + /* do nothing */; } else if (ELEM10(tselem->type, TSE_ANIM_DATA, TSE_NLA, TSE_DEFGROUP_BASE, TSE_CONSTRAINT_BASE, TSE_MODIFIER_BASE, - TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) + TSE_SCRIPT_BASE, TSE_POSE_BASE, TSE_POSEGRP_BASE, TSE_R_LAYER_BASE, TSE_R_PASS)) { - BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); + BKE_report(reports, RPT_WARNING, "Cannot edit builtin name"); } else if (ELEM3(tselem->type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) { BKE_report(reports, RPT_WARNING, "Cannot edit sequence name"); @@ -207,27 +207,27 @@ static void do_item_rename(ARegion *ar, TreeElement *te, TreeStoreElem *tselem, void item_rename_cb(bContext *C, Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - ARegion *ar= CTX_wm_region(C); - ReportList *reports= CTX_wm_reports(C); // XXX + ARegion *ar = CTX_wm_region(C); + ReportList *reports = CTX_wm_reports(C); // XXX do_item_rename(ar, te, tselem, reports); } static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, TreeElement *te, const float mval[2]) { - ReportList *reports= CTX_wm_reports(C); // XXX + ReportList *reports = CTX_wm_reports(C); // XXX - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); /* name and first icon */ - if (mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { + if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) { do_item_rename(ar, te, tselem, reports); } return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_rename(C, ar, soops, te, mval)) return 1; } return 0; @@ -235,14 +235,14 @@ static int do_outliner_item_rename(bContext *C, ARegion *ar, SpaceOops *soops, T static int outliner_item_rename(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_rename(C, ar, soops, te, fmval)) break; } @@ -272,12 +272,12 @@ void OUTLINER_OT_item_rename(wmOperatorType *ot) static int outliner_count_levels(SpaceOops *soops, ListBase *lb, int curlevel) { TreeElement *te; - int level=curlevel, lev; + int level = curlevel, lev; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { - lev= outliner_count_levels(soops, &te->subtree, curlevel+1); - if (lev>level) level= lev; + lev = outliner_count_levels(soops, &te->subtree, curlevel + 1); + if (lev > level) level = lev; } return level; } @@ -288,11 +288,11 @@ int outliner_has_one_flag(SpaceOops *soops, ListBase *lb, short flag, short curl TreeStoreElem *tselem; int level; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & flag) return curlevel; - level= outliner_has_one_flag(soops, &te->subtree, flag, curlevel+1); + level = outliner_has_one_flag(soops, &te->subtree, flag, curlevel + 1); if (level) return level; } return 0; @@ -303,9 +303,9 @@ void outliner_set_flag(SpaceOops *soops, ListBase *lb, short flag, short set) TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (set==0) tselem->flag &= ~flag; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (set == 0) tselem->flag &= ~flag; else tselem->flag |= flag; outliner_set_flag(soops, &te->subtree, flag, set); } @@ -321,7 +321,7 @@ int common_restrict_check(bContext *C, Object *ob) /* Don't allow hide an object in edit mode, * check the bug #22153 and #21609, #23977 */ - Object *obedit= CTX_data_edit_object(C); + Object *obedit = CTX_data_edit_object(C); if (obedit && obedit == ob) { /* found object is hidden, reset */ if (ob->restrictflag & OB_RESTRICT_VIEW) @@ -342,13 +342,13 @@ int common_restrict_check(bContext *C, Object *ob) void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; Object *ob = (Object *)tselem->id; /* add check for edit mode */ if (!common_restrict_check(C, ob)) return; - if (base || (base= object_in_scene(ob, scene))) { + if (base || (base = BKE_scene_base_find(scene, ob))) { if ((base->object->restrictflag ^= OB_RESTRICT_VIEW)) { ED_base_object_select(base, BA_DESELECT); } @@ -357,19 +357,19 @@ void object_toggle_visibility_cb(bContext *C, Scene *scene, TreeElement *te, Tre void group_toggle_visibility_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_VIEW); } static int outliner_toggle_visibility_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -386,36 +386,36 @@ void OUTLINER_OT_visibility_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_visibility_exec; ot->poll = ED_operator_outliner_active_no_editobject; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Toggle Selectability ---------------------------------------- */ void object_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { - base->object->restrictflag^=OB_RESTRICT_SELECT; + base->object->restrictflag ^= OB_RESTRICT_SELECT; } } void group_toggle_selectability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_SELECT); } static int outliner_toggle_selectability_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -432,35 +432,35 @@ void OUTLINER_OT_selectability_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_selectability_exec; ot->poll = ED_operator_outliner_active_no_editobject; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* Toggle Renderability ---------------------------------------- */ void object_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { - base->object->restrictflag^=OB_RESTRICT_RENDER; + base->object->restrictflag ^= OB_RESTRICT_RENDER; } } void group_toggle_renderability_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; restrictbutton_gr_restrict_flag(scene, group, OB_RESTRICT_RENDER); } static int outliner_toggle_renderability_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); return OPERATOR_FINISHED; } @@ -476,7 +476,7 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) ot->exec = outliner_toggle_renderability_exec; ot->poll = ED_operator_outliner_active; - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* =============================================== */ @@ -486,8 +486,8 @@ void OUTLINER_OT_renderability_toggle(wmOperatorType *ot) static int outliner_toggle_expanded_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1)) outliner_set_flag(soops, &soops->tree, TSE_CLOSED, 0); @@ -517,9 +517,9 @@ void OUTLINER_OT_expanded_toggle(wmOperatorType *ot) static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1)) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); @@ -528,7 +528,7 @@ static int outliner_toggle_selected_exec(bContext *C, wmOperator *UNUSED(op)) soops->storeflag |= SO_TREESTORE_REDRAW; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -555,10 +555,10 @@ void OUTLINER_OT_selected_toggle(wmOperatorType *ot) static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *so= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= &ar->v2d; + SpaceOops *so = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = &ar->v2d; TreeElement *te; int xdelta, ytop; @@ -567,14 +567,14 @@ static int outliner_show_active_exec(bContext *C, wmOperator *UNUSED(op)) if (OBACT == NULL) return OPERATOR_CANCELLED; - te= outliner_find_id(so, &so->tree, (ID *)OBACT); + te = outliner_find_id(so, &so->tree, (ID *)OBACT); if (te) { /* make te->ys center of view */ - ytop= (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin)/2); - if (ytop>0) ytop= 0; + ytop = (int)(te->ys + (v2d->mask.ymax - v2d->mask.ymin) / 2); + if (ytop > 0) ytop = 0; v2d->cur.ymax = (float)ytop; - v2d->cur.ymin = (float)(ytop-(v2d->mask.ymax - v2d->mask.ymin)); + v2d->cur.ymin = (float)(ytop - (v2d->mask.ymax - v2d->mask.ymin)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - v2d->cur.xmin); @@ -605,16 +605,16 @@ void OUTLINER_OT_show_active(wmOperatorType *ot) static int outliner_scroll_page_exec(bContext *C, wmOperator *op) { - ARegion *ar= CTX_wm_region(C); - int dy= ar->v2d.mask.ymax - ar->v2d.mask.ymin; - int up= 0; + ARegion *ar = CTX_wm_region(C); + int dy = ar->v2d.mask.ymax - ar->v2d.mask.ymin; + int up = 0; if (RNA_boolean_get(op->ptr, "up")) - up= 1; + up = 1; - if (up == 0) dy= -dy; - ar->v2d.cur.ymin+= dy; - ar->v2d.cur.ymax+= dy; + if (up == 0) dy = -dy; + ar->v2d.cur.ymin += dy; + ar->v2d.cur.ymax += dy; ED_region_tag_redraw(ar); @@ -645,17 +645,17 @@ void OUTLINER_OT_scroll_page(wmOperatorType *ot) /* recursive helper for function below */ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, int startx, int *starty) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); /* store coord and continue, we need coordinates for elements outside view too */ - te->xs= (float)startx; - te->ys= (float)(*starty); - *starty-= UI_UNIT_Y; + te->xs = (float)startx; + te->ys = (float)(*starty); + *starty -= UI_UNIT_Y; if (TSELEM_OPEN(tselem, soops)) { TreeElement *ten; - for (ten= te->subtree.first; ten; ten= ten->next) { - outliner_set_coordinates_element(soops, ten, startx+UI_UNIT_X, starty); + for (ten = te->subtree.first; ten; ten = ten->next) { + outliner_set_coordinates_element(soops, ten, startx + UI_UNIT_X, starty); } } @@ -665,20 +665,20 @@ static void outliner_set_coordinates_element(SpaceOops *soops, TreeElement *te, static void outliner_set_coordinates(ARegion *ar, SpaceOops *soops) { TreeElement *te; - int starty= (int)(ar->v2d.tot.ymax)-UI_UNIT_Y; - int startx= 0; + int starty = (int)(ar->v2d.tot.ymax) - UI_UNIT_Y; + int startx = 0; - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { outliner_set_coordinates_element(soops, te, startx, &starty); } } /* find next element that has this name */ -static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) +static TreeElement *outliner_find_name(SpaceOops *soops, ListBase *lb, char *name, int flags, TreeElement *prev, int *prevFound) { TreeElement *te, *tes; - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { int found = outliner_filter_has_name(te, name, flags); if (found) { @@ -694,7 +694,7 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na return te; } - tes= outliner_find_named(soops, &te->subtree, name, flags, prev, prevFound); + tes = outliner_find_name(soops, &te->subtree, name, flags, prev, prevFound); if (tes) return tes; } @@ -705,44 +705,44 @@ static TreeElement *outliner_find_named(SpaceOops *soops, ListBase *lb, char *na static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *soops, int again, int flags) { ReportList *reports = NULL; // CTX_wm_reports(C); - TreeElement *te= NULL; + TreeElement *te = NULL; TreeElement *last_find; TreeStoreElem *tselem; - int ytop, xdelta, prevFound=0; + int ytop, xdelta, prevFound = 0; char name[sizeof(soops->search_string)]; /* get last found tree-element based on stored search_tse */ - last_find= outliner_find_tse(soops, &soops->search_tse); + last_find = outliner_find_tse(soops, &soops->search_tse); /* determine which type of search to do */ if (again && last_find) { /* no popup panel - previous + user wanted to search for next after previous */ BLI_strncpy(name, soops->search_string, sizeof(name)); - flags= soops->search_flags; + flags = soops->search_flags; /* try to find matching element */ - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); - if (te==NULL) { + te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); + if (te == NULL) { /* no more matches after previous, start from beginning again */ - prevFound= 1; - te= outliner_find_named(soops, &soops->tree, name, flags, last_find, &prevFound); + prevFound = 1; + te = outliner_find_name(soops, &soops->tree, name, flags, last_find, &prevFound); } } else { /* pop up panel - no previous, or user didn't want search after previous */ - name[0]= '\0'; + name[0] = '\0'; // XXX if (sbutton(name, 0, sizeof(name)-1, "Find: ") && name[0]) { -// te= outliner_find_named(soops, &soops->tree, name, flags, NULL, &prevFound); +// te= outliner_find_name(soops, &soops->tree, name, flags, NULL, &prevFound); // } // else return; /* XXX RETURN! XXX */ } /* do selection and reveal */ if (te) { - tselem= TREESTORE(te); + tselem = TREESTORE(te); if (tselem) { /* expand branches so that it will be visible, we need to get correct coordinates */ - if ( outliner_open_back(soops, te)) + if (outliner_open_back(soops, te)) outliner_set_coordinates(ar, soops); /* deselect all visible, and select found element */ @@ -750,10 +750,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so tselem->flag |= TSE_SELECTED; /* make te->ys center of view */ - ytop= (int)(te->ys + (ar->v2d.mask.ymax-ar->v2d.mask.ymin)/2); - if (ytop>0) ytop= 0; + ytop = (int)(te->ys + (ar->v2d.mask.ymax - ar->v2d.mask.ymin) / 2); + if (ytop > 0) ytop = 0; ar->v2d.cur.ymax = (float)ytop; - ar->v2d.cur.ymin = (float)(ytop-(ar->v2d.mask.ymax-ar->v2d.mask.ymin)); + ar->v2d.cur.ymin = (float)(ytop - (ar->v2d.mask.ymax - ar->v2d.mask.ymin)); /* make te->xs ==> te->xend center of view */ xdelta = (int)(te->xs - ar->v2d.cur.xmin); @@ -761,10 +761,10 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so ar->v2d.cur.xmax += xdelta; /* store selection */ - soops->search_tse= *tselem; + soops->search_tse = *tselem; BLI_strncpy(soops->search_string, name, sizeof(soops->search_string)); - soops->search_flags= flags; + soops->search_flags = flags; /* redraw */ soops->storeflag |= SO_TREESTORE_REDRAW; @@ -785,34 +785,34 @@ static void outliner_openclose_level(SpaceOops *soops, ListBase *lb, int curleve TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (open) { - if (curlevel<=level) tselem->flag &= ~TSE_CLOSED; + if (curlevel <= level) tselem->flag &= ~TSE_CLOSED; } else { - if (curlevel>=level) tselem->flag |= TSE_CLOSED; + if (curlevel >= level) tselem->flag |= TSE_CLOSED; } - outliner_openclose_level(soops, &te->subtree, curlevel+1, level, open); + outliner_openclose_level(soops, &te->subtree, curlevel + 1, level, open); } } static int outliner_one_level_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - int add= RNA_boolean_get(op->ptr, "open"); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + int add = RNA_boolean_get(op->ptr, "open"); int level; - level= outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); - if (add==1) { + level = outliner_has_one_flag(soops, &soops->tree, TSE_CLOSED, 1); + if (add == 1) { if (level) outliner_openclose_level(soops, &soops->tree, 1, level, 1); } else { - if (level==0) level= outliner_count_levels(soops, &soops->tree, 0); - if (level) outliner_openclose_level(soops, &soops->tree, 1, level-1, 0); + if (level == 0) level = outliner_count_levels(soops, &soops->tree, 0); + if (level) outliner_openclose_level(soops, &soops->tree, 1, level - 1, 0); } ED_region_tag_redraw(ar); @@ -845,10 +845,10 @@ static int subtree_has_objects(SpaceOops *soops, ListBase *lb) TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) return 1; - if ( subtree_has_objects(soops, &te->subtree)) return 1; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == ID_OB) return 1; + if (subtree_has_objects(soops, &te->subtree)) return 1; } return 0; } @@ -860,15 +860,15 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase TreeStoreElem *tselem; /* open all object elems, close others */ - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); - if (tselem->type==0) { - if (te->idcode==ID_SCE) { - if (tselem->id!=(ID *)scene) tselem->flag |= TSE_CLOSED; - else tselem->flag &= ~TSE_CLOSED; + if (tselem->type == 0) { + if (te->idcode == ID_SCE) { + if (tselem->id != (ID *)scene) tselem->flag |= TSE_CLOSED; + else tselem->flag &= ~TSE_CLOSED; } - else if (te->idcode==ID_OB) { + else if (te->idcode == ID_OB) { if (subtree_has_objects(soops, &te->subtree)) tselem->flag &= ~TSE_CLOSED; else tselem->flag |= TSE_CLOSED; } @@ -882,9 +882,9 @@ static void tree_element_show_hierarchy(Scene *scene, SpaceOops *soops, ListBase /* show entire object level hierarchy */ static int outliner_show_hierarchy_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Scene *scene= CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); /* recursively open/close levels */ tree_element_show_hierarchy(scene, soops, &soops->tree); @@ -915,9 +915,9 @@ void OUTLINER_OT_show_hierarchy(wmOperatorType *ot) /* specialized poll callback for these operators to work in Datablocks view only */ static int ed_operator_outliner_datablocks_active(bContext *C) { - ScrArea *sa= CTX_wm_area(C); - if ((sa) && (sa->spacetype==SPACE_OUTLINER)) { - SpaceOops *so= CTX_wm_space_outliner(C); + ScrArea *sa = CTX_wm_area(C); + if ((sa) && (sa->spacetype == SPACE_OUTLINER)) { + SpaceOops *so = CTX_wm_space_outliner(C); return (so->outlinevis == SO_DATABLOCKS); } return 0; @@ -929,7 +929,7 @@ static int ed_operator_outliner_datablocks_active(bContext *C) * this function does not do that yet */ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, - ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) + ID **id, char **path, int *array_index, short *flag, short *UNUSED(groupmode)) { ListBase hierarchy = {NULL, NULL}; LinkData *ld; @@ -937,7 +937,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle TreeStoreElem *tse /* , *tsenext */ /* UNUSED */; PointerRNA *ptr, *nextptr; PropertyRNA *prop; - char *newpath=NULL; + char *newpath = NULL; /* optimize tricks: * - Don't do anything if the selected item is a 'struct', but arrays are allowed @@ -946,28 +946,28 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle return; /* Overview of Algorithm: - * 1. Go up the chain of parents until we find the 'root', taking note of the + * 1. Go up the chain of parents until we find the 'root', taking note of the * levels encountered in reverse-order (i.e. items are added to the start of the list * for more convenient looping later) - * 2. Walk down the chain, adding from the first ID encountered + * 2. Walk down the chain, adding from the first ID encountered * (which will become the 'ID' for the KeyingSet Path), and build a - * path as we step through the chain + * path as we step through the chain */ /* step 1: flatten out hierarchy of parents into a flat chain */ - for (tem= te->parent; tem; tem= tem->parent) { - ld= MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); - ld->data= tem; + for (tem = te->parent; tem; tem = tem->parent) { + ld = MEM_callocN(sizeof(LinkData), "LinkData for tree_element_to_path()"); + ld->data = tem; BLI_addhead(&hierarchy, ld); } /* step 2: step down hierarchy building the path (NOTE: addhead in previous loop was needed so that we can loop like this) */ - for (ld= hierarchy.first; ld; ld= ld->next) { + for (ld = hierarchy.first; ld; ld = ld->next) { /* get data */ - tem= (TreeElement *)ld->data; - tse= TREESTORE(tem); - ptr= &tem->rnaptr; - prop= tem->directdata; + tem = (TreeElement *)ld->data; + tse = TREESTORE(tem); + ptr = &tem->rnaptr; + prop = tem->directdata; /* check if we're looking for first ID, or appending to path */ if (*id) { @@ -977,43 +977,43 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle if (tse->type == TSE_RNA_PROPERTY) { if (RNA_property_type(prop) == PROP_POINTER) { /* for pointer we just append property name */ - newpath= RNA_path_append(*path, ptr, prop, 0, NULL); + newpath = RNA_path_append(*path, ptr, prop, 0, NULL); } else if (RNA_property_type(prop) == PROP_COLLECTION) { char buf[128], *name; - temnext= (TreeElement*)(ld->next->data); + temnext = (TreeElement *)(ld->next->data); /* tsenext= TREESTORE(temnext); */ /* UNUSED */ - nextptr= &temnext->rnaptr; - name= RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); + nextptr = &temnext->rnaptr; + name = RNA_struct_name_get_alloc(nextptr, buf, sizeof(buf), NULL); if (name) { /* if possible, use name as a key in the path */ - newpath= RNA_path_append(*path, NULL, prop, 0, name); + newpath = RNA_path_append(*path, NULL, prop, 0, name); if (name != buf) MEM_freeN(name); } else { /* otherwise use index */ - int index= 0; + int index = 0; - for (temsub=tem->subtree.first; temsub; temsub=temsub->next, index++) + for (temsub = tem->subtree.first; temsub; temsub = temsub->next, index++) if (temsub == temnext) break; - newpath= RNA_path_append(*path, NULL, prop, index, NULL); + newpath = RNA_path_append(*path, NULL, prop, index, NULL); } - ld= ld->next; + ld = ld->next; } } if (newpath) { if (*path) MEM_freeN(*path); - *path= newpath; - newpath= NULL; + *path = newpath; + newpath = NULL; } } else { @@ -1021,12 +1021,12 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle if (tse->type == TSE_RNA_STRUCT) { /* ptr->data not ptr->id.data seems to be the one we want, since ptr->data is sometimes the owner of this ID? */ if (RNA_struct_is_ID(ptr->type)) { - *id= (ID *)ptr->data; + *id = (ID *)ptr->data; /* clear path */ if (*path) { MEM_freeN(*path); - path= NULL; + path = NULL; } } } @@ -1036,13 +1036,13 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle /* step 3: if we've got an ID, add the current item to the path */ if (*id) { /* add the active property to the path */ - ptr= &te->rnaptr; - prop= te->directdata; + ptr = &te->rnaptr; + prop = te->directdata; /* array checks */ if (tselem->type == TSE_RNA_ARRAY_ELEM) { /* item is part of an array, so must set the array_index */ - *array_index= te->index; + *array_index = te->index; } else if (RNA_property_array_length(ptr, prop)) { /* entire array was selected, so keyframe all */ @@ -1050,9 +1050,9 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle } /* path */ - newpath= RNA_path_append(*path, NULL, prop, 0, NULL); + newpath = RNA_path_append(*path, NULL, prop, 0, NULL); if (*path) MEM_freeN(*path); - *path= newpath; + *path = newpath; } /* free temp data */ @@ -1066,7 +1066,7 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle * they depend on having RNA paths and/or hierarchies available. */ enum { - DRIVERS_EDITMODE_ADD = 0, + DRIVERS_EDITMODE_ADD = 0, DRIVERS_EDITMODE_REMOVE, } /*eDrivers_EditModes*/; @@ -1078,22 +1078,22 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL TreeElement *te; TreeStoreElem *tselem; - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); + for (te = tree->first; te; te = te->next) { + tselem = TREESTORE(te); /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; + ID *id = NULL; + char *path = NULL; + int array_index = 0; + short flag = 0; + short groupmode = KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); + &id, &path, &array_index, &flag, &groupmode); } /* only if ID and path were set, should we perform any actions */ @@ -1104,10 +1104,10 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL /* array checks */ if (flag & KSP_FLAG_WHOLE_ARRAY) { /* entire array was selected, so add drivers for all */ - arraylen= RNA_property_array_length(&te->rnaptr, te->directdata); + arraylen = RNA_property_array_length(&te->rnaptr, te->directdata); } else - arraylen= array_index; + arraylen = array_index; /* we should do at least one step */ if (arraylen == array_index) @@ -1122,13 +1122,13 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL /* add a new driver with the information obtained (only if valid) */ ANIM_add_driver(reports, id, path, array_index, dflags, DRIVER_TYPE_PYTHON); } - break; + break; case DRIVERS_EDITMODE_REMOVE: { /* remove driver matching the information obtained (only if valid) */ ANIM_remove_driver(reports, id, path, array_index, dflags); } - break; + break; } } @@ -1149,7 +1149,7 @@ static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, ReportL static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); + SpaceOops *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ if (soutliner == NULL) @@ -1159,7 +1159,7 @@ static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op) do_outliner_drivers_editop(soutliner, &soutliner->tree, op->reports, DRIVERS_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, NC_ANIMATION|ND_FCURVES_ORDER, NULL); // XXX + WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX return OPERATOR_FINISHED; } @@ -1176,7 +1176,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1184,7 +1184,7 @@ void OUTLINER_OT_drivers_add_selected(wmOperatorType *ot) static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); + SpaceOops *soutliner = CTX_wm_space_outliner(C); /* check for invalid states */ if (soutliner == NULL) @@ -1211,7 +1211,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* =============================================== */ @@ -1221,7 +1221,7 @@ void OUTLINER_OT_drivers_delete_selected(wmOperatorType *ot) * they depend on having RNA paths and/or hierarchies available. */ enum { - KEYINGSET_EDITMODE_ADD = 0, + KEYINGSET_EDITMODE_ADD = 0, KEYINGSET_EDITMODE_REMOVE, } /*eKeyingSet_EditModes*/; @@ -1231,7 +1231,7 @@ enum { // TODO: should this be an API func? static KeyingSet *verify_active_keyingset(Scene *scene, short add) { - KeyingSet *ks= NULL; + KeyingSet *ks = NULL; /* sanity check */ if (scene == NULL) @@ -1239,13 +1239,13 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* try to find one from scene */ if (scene->active_keyingset > 0) - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 1); /* add if none found */ // XXX the default settings have yet to evolve - if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); - scene->active_keyingset= BLI_countlist(&scene->keyingsets); + if ((add) && (ks == NULL)) { + ks = BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); + scene->active_keyingset = BLI_countlist(&scene->keyingsets); } return ks; @@ -1257,22 +1257,22 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa TreeElement *te; TreeStoreElem *tselem; - for (te= tree->first; te; te=te->next) { - tselem= TREESTORE(te); + for (te = tree->first; te; te = te->next) { + tselem = TREESTORE(te); /* if item is selected, perform operation */ if (tselem->flag & TSE_SELECTED) { - ID *id= NULL; - char *path= NULL; - int array_index= 0; - short flag= 0; - short groupmode= KSP_GROUP_KSNAME; + ID *id = NULL; + char *path = NULL; + int array_index = 0; + short flag = 0; + short groupmode = KSP_GROUP_KSNAME; /* check if RNA-property described by this selected element is an animatable prop */ if (ELEM(tselem->type, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM) && RNA_property_animateable(&te->rnaptr, te->directdata)) { /* get id + path + index info from the selected element */ tree_element_to_path(soops, te, tselem, - &id, &path, &array_index, &flag, &groupmode); + &id, &path, &array_index, &flag, &groupmode); } /* only if ID and path were set, should we perform any actions */ @@ -1284,22 +1284,22 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa /* add a new path with the information obtained (only if valid) */ // TODO: what do we do with group name? for now, we don't supply one, and just let this use the KeyingSet name BKE_keyingset_add_path(ks, id, NULL, path, array_index, flag, groupmode); - ks->active_path= BLI_countlist(&ks->paths); + ks->active_path = BLI_countlist(&ks->paths); } - break; + break; case KEYINGSET_EDITMODE_REMOVE: { /* find the relevant path, then remove it from the KeyingSet */ - KS_Path *ksp= BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); + KS_Path *ksp = BKE_keyingset_find_path(ks, id, NULL, path, array_index, groupmode); if (ksp) { /* free path's data */ BKE_keyingset_free_path(ks, ksp); - ks->active_path= 0; + ks->active_path = 0; } } - break; + break; } /* free path, since it had to be generated */ @@ -1317,9 +1317,9 @@ static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBa static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); + SpaceOops *soutliner = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ if (ks == NULL) { @@ -1333,7 +1333,7 @@ static int outliner_keyingset_additems_exec(bContext *C, wmOperator *op) do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_ADD); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -1350,7 +1350,7 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } @@ -1358,9 +1358,9 @@ void OUTLINER_OT_keyingset_add_selected(wmOperatorType *ot) static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(op)) { - SpaceOops *soutliner= CTX_wm_space_outliner(C); - Scene *scene= CTX_data_scene(C); - KeyingSet *ks= verify_active_keyingset(scene, 1); + SpaceOops *soutliner = CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + KeyingSet *ks = verify_active_keyingset(scene, 1); /* check for invalid states */ if (soutliner == NULL) @@ -1370,7 +1370,7 @@ static int outliner_keyingset_removeitems_exec(bContext *C, wmOperator *UNUSED(o do_outliner_keyingset_editop(soutliner, ks, &soutliner->tree, KEYINGSET_EDITMODE_REMOVE); /* send notifiers */ - WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); return OPERATOR_FINISHED; } @@ -1387,7 +1387,7 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) ot->poll = ed_operator_outliner_datablocks_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ******************** Parent Drop Operator *********************** */ @@ -1395,23 +1395,23 @@ void OUTLINER_OT_keyingset_remove_selected(wmOperatorType *ot) static int parent_drop_exec(bContext *C, wmOperator *op) { Object *par = NULL, *ob = NULL; - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); int partype = -1; char parname[MAX_ID_NAME], childname[MAX_ID_NAME]; - partype= RNA_enum_get(op->ptr, "type"); + partype = RNA_enum_get(op->ptr, "type"); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)find_id("OB", parname); + par = (Object *)BKE_libblock_find_name(ID_OB, parname); RNA_string_get(op->ptr, "child", childname); - ob= (Object *)find_id("OB", childname); + ob = (Object *)BKE_libblock_find_name(ID_OB, childname); ED_object_parent_set(op->reports, bmain, scene, ob, par, partype); DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; } @@ -1419,8 +1419,8 @@ static int parent_drop_exec(bContext *C, wmOperator *op) /* Used for drag and drop parenting */ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement *te, float *fmval) { - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeStoreElem *tselem= TREESTORE(te); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeStoreElem *tselem = TREESTORE(te); if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* name and first icon */ @@ -1436,10 +1436,10 @@ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement * } /* Not it. Let's look at its children. */ - if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { TreeElement *te_valid; - te_valid= outliner_dropzone_parent(C, event, te, fmval); + te_valid = outliner_dropzone_parent(C, event, te, fmval); if (te_valid) return te_valid; } } @@ -1448,24 +1448,24 @@ TreeElement *outliner_dropzone_parent(bContext *C, wmEvent *event, TreeElement * static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Object *par= NULL; - Object *ob= NULL; - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - TreeElement *te= NULL; - TreeElement *te_found= NULL; + Object *par = NULL; + Object *ob = NULL; + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + TreeElement *te = NULL; + TreeElement *te_found = NULL; char childname[MAX_ID_NAME]; char parname[MAX_ID_NAME]; - int partype= 0; + int partype = 0; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); /* Find object hovered over */ - for (te= soops->tree.first; te; te= te->next) { - te_found= outliner_dropzone_parent(C, event, te, fmval); + for (te = soops->tree.first; te; te = te->next) { + te_found = outliner_dropzone_parent(C, event, te, fmval); if (te_found) break; } @@ -1473,9 +1473,9 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) RNA_string_set(op->ptr, "parent", te_found->name); /* Identify parent and child */ RNA_string_get(op->ptr, "child", childname); - ob= (Object *)find_id("OB", childname); + ob = (Object *)BKE_libblock_find_name(ID_OB, childname); RNA_string_get(op->ptr, "parent", parname); - par= (Object *)find_id("OB", parname); + par = (Object *)BKE_libblock_find_name(ID_OB, parname); if (ELEM(NULL, ob, par)) { if (par == NULL) printf("par==NULL\n"); @@ -1487,20 +1487,20 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) - ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype)) { DAG_scene_sort(bmain, scene); DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, NULL); - WM_event_add_notifier(C, NC_OBJECT|ND_PARENT, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); } } else { /* Menu creation */ - uiPopupMenu *pup= uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); - uiLayout *layout= uiPupMenuLayout(pup); + uiPopupMenu *pup = uiPupMenuBegin(C, IFACE_("Set Parent To"), ICON_NONE); + uiLayout *layout = uiPupMenuLayout(pup); PointerRNA ptr; @@ -1513,7 +1513,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); /* par becomes parent, make the associated menus */ - if (par->type==OB_ARMATURE) { + if (par->type == OB_ARMATURE) { WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); RNA_string_set(&ptr, "parent", parname); RNA_string_set(&ptr, "child", childname); @@ -1549,7 +1549,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) uiItemFullO(layout, "OUTLINER_OT_parent_drop", IFACE_("Bone"), 0, ptr.data, WM_OP_EXEC_DEFAULT, 0); } - else if (par->type==OB_CURVE) { + else if (par->type == OB_CURVE) { WM_operator_properties_create(&ptr, "OUTLINER_OT_parent_drop"); RNA_string_set(&ptr, "parent", parname); RNA_string_set(&ptr, "child", childname); @@ -1606,7 +1606,7 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "child", "Object", MAX_ID_NAME, "Child", "Child Object"); @@ -1616,15 +1616,15 @@ void OUTLINER_OT_parent_drop(wmOperatorType *ot) int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, float *fmval) { - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeStoreElem *tselem= TREESTORE(te); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeStoreElem *tselem = TREESTORE(te); /* Check for row */ if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) { /* Ignore drop on scene tree elements */ if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) { if ((te->idcode == ID_SCE) && - !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) + !ELEM3(tselem->type, TSE_R_LAYER_BASE, TSE_R_LAYER, TSE_R_PASS)) { return 0; } @@ -1639,11 +1639,11 @@ int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, return 1; } - return 0; // ID_OB, but mouse in undefined dropzone. + return 0; // ID_OB, but mouse in undefined dropzone. } /* Not this row. Let's look at its children. */ - if ((tselem->flag & TSE_CLOSED)==0 && (te->subtree.first)) { + if ((tselem->flag & TSE_CLOSED) == 0 && (te->subtree.first)) { for (te = te->subtree.first; te; te = te->next) { if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; @@ -1654,16 +1654,16 @@ int outliner_dropzone_parent_clear(bContext *C, wmEvent *event, TreeElement *te, static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { - Scene *scene= CTX_data_scene(C); - Object *ob= NULL; + Scene *scene = CTX_data_scene(C); + Object *ob = NULL; char obname[MAX_ID_NAME]; RNA_string_get(op->ptr, "dragged_obj", obname); - ob= (Object *)find_id("OB", obname); + ob = (Object *)BKE_libblock_find_name(ID_OB, obname); /* check dragged object (child) is active */ if (ob != CTX_data_active_object(C)) - ED_base_object_select(object_in_scene(ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, ob), BA_SELECT); ED_object_parent_clear(C, RNA_enum_get(op->ptr, "type")); @@ -1683,7 +1683,7 @@ void OUTLINER_OT_parent_clear(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ RNA_def_string(ot->srna, "dragged_obj", "Object", MAX_ID_NAME, "Child", "Child Object"); diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h index b1990d3054e..d8d10519bd6 100644 --- a/source/blender/editors/space_outliner/outliner_intern.h +++ b/source/blender/editors/space_outliner/outliner_intern.h @@ -48,82 +48,82 @@ struct Object; typedef struct TreeElement { struct TreeElement *next, *prev, *parent; ListBase subtree; - float xs, ys; // do selection - int store_index; // offset in tree store - short flag; // flag for non-saved stuff - short index; // index for data arrays - short idcode; // from TreeStore id - short xend; // width of item display, for select + float xs, ys; // do selection + int store_index; // offset in tree store + short flag; // flag for non-saved stuff + short index; // index for data arrays + short idcode; // from TreeStore id + short xend; // width of item display, for select const char *name; - void *directdata; // Armature Bones, Base, Sequence, Strip... - PointerRNA rnaptr; // RNA Pointer + void *directdata; // Armature Bones, Base, Sequence, Strip... + PointerRNA rnaptr; // RNA Pointer } TreeElement; /* TreeElement->flag */ -#define TE_ACTIVE 1 -#define TE_ICONROW 2 -#define TE_LAZY_CLOSED 4 -#define TE_FREE_NAME 8 +#define TE_ACTIVE 1 +#define TE_ICONROW 2 +#define TE_LAZY_CLOSED 4 +#define TE_FREE_NAME 8 /* TreeStoreElem types */ -#define TSE_NLA 1 -#define TSE_NLA_ACTION 2 -#define TSE_DEFGROUP_BASE 3 -#define TSE_DEFGROUP 4 -#define TSE_BONE 5 -#define TSE_EBONE 6 -#define TSE_CONSTRAINT_BASE 7 -#define TSE_CONSTRAINT 8 -#define TSE_MODIFIER_BASE 9 -#define TSE_MODIFIER 10 -#define TSE_LINKED_OB 11 -#define TSE_SCRIPT_BASE 12 -#define TSE_POSE_BASE 13 -#define TSE_POSE_CHANNEL 14 -#define TSE_ANIM_DATA 15 -#define TSE_DRIVER_BASE 16 -#define TSE_DRIVER 17 +#define TSE_NLA 1 +#define TSE_NLA_ACTION 2 +#define TSE_DEFGROUP_BASE 3 +#define TSE_DEFGROUP 4 +#define TSE_BONE 5 +#define TSE_EBONE 6 +#define TSE_CONSTRAINT_BASE 7 +#define TSE_CONSTRAINT 8 +#define TSE_MODIFIER_BASE 9 +#define TSE_MODIFIER 10 +#define TSE_LINKED_OB 11 +#define TSE_SCRIPT_BASE 12 +#define TSE_POSE_BASE 13 +#define TSE_POSE_CHANNEL 14 +#define TSE_ANIM_DATA 15 +#define TSE_DRIVER_BASE 16 +#define TSE_DRIVER 17 -#define TSE_PROXY 18 -#define TSE_R_LAYER_BASE 19 -#define TSE_R_LAYER 20 -#define TSE_R_PASS 21 -#define TSE_LINKED_MAT 22 +#define TSE_PROXY 18 +#define TSE_R_LAYER_BASE 19 +#define TSE_R_LAYER 20 +#define TSE_R_PASS 21 +#define TSE_LINKED_MAT 22 /* NOTE, is used for light group */ -#define TSE_LINKED_LAMP 23 -#define TSE_POSEGRP_BASE 24 -#define TSE_POSEGRP 25 -#define TSE_SEQUENCE 26 -#define TSE_SEQ_STRIP 27 -#define TSE_SEQUENCE_DUP 28 +#define TSE_LINKED_LAMP 23 +#define TSE_POSEGRP_BASE 24 +#define TSE_POSEGRP 25 +#define TSE_SEQUENCE 26 +#define TSE_SEQ_STRIP 27 +#define TSE_SEQUENCE_DUP 28 #define TSE_LINKED_PSYS 29 -#define TSE_RNA_STRUCT 30 -#define TSE_RNA_PROPERTY 31 -#define TSE_RNA_ARRAY_ELEM 32 -#define TSE_NLA_TRACK 33 -#define TSE_KEYMAP 34 -#define TSE_KEYMAP_ITEM 35 +#define TSE_RNA_STRUCT 30 +#define TSE_RNA_PROPERTY 31 +#define TSE_RNA_ARRAY_ELEM 32 +#define TSE_NLA_TRACK 33 +#define TSE_KEYMAP 34 +#define TSE_KEYMAP_ITEM 35 /* button events */ -#define OL_NAMEBUTTON 1 +#define OL_NAMEBUTTON 1 /* get TreeStoreElem associated with a TreeElement * < a: (TreeElement) tree element to find stored element for */ -#define TREESTORE(a) ((a)?soops->treestore->data+(a)->store_index:NULL) +#define TREESTORE(a) ((a) ? soops->treestore->data + (a)->store_index : NULL) /* size constants */ -#define OL_Y_OFFSET 2 +#define OL_Y_OFFSET 2 -#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X*3) -#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X*2) -#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X +#define OL_TOG_RESTRICT_VIEWX (UI_UNIT_X * 3) +#define OL_TOG_RESTRICT_SELECTX (UI_UNIT_X * 2) +#define OL_TOG_RESTRICT_RENDERX UI_UNIT_X #define OL_TOGW OL_TOG_RESTRICT_VIEWX -#define OL_RNA_COLX (UI_UNIT_X*15) -#define OL_RNA_COL_SIZEX (UI_UNIT_X*7.5f) -#define OL_RNA_COL_SPACEX (UI_UNIT_X*2.5f) +#define OL_RNA_COLX (UI_UNIT_X * 15) +#define OL_RNA_COL_SIZEX (UI_UNIT_X * 7.5f) +#define OL_RNA_COL_SPACEX (UI_UNIT_X * 2.5f) /* Outliner Searching -- @@ -145,7 +145,7 @@ typedef struct TreeElement { #define SEARCHING_OUTLINER(sov) (sov->search_flags & SO_SEARCH_RECURSIVE) /* is the currrent element open? if so we also show children */ -#define TSELEM_OPEN(telm,sv) ( (telm->flag & TSE_CLOSED)==0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) +#define TSELEM_OPEN(telm, sv) ( (telm->flag & TSE_CLOSED) == 0 || (SEARCHING_OUTLINER(sv) && (telm->flag & TSE_CHILDSEARCH)) ) /* outliner_tree.c ----------------------------------------------- */ @@ -170,7 +170,7 @@ int tree_element_active(struct bContext *C, struct Scene *scene, SpaceOops *soop /* outliner_edit.c ---------------------------------------------- */ void outliner_do_object_operation(struct bContext *C, struct Scene *scene, struct SpaceOops *soops, struct ListBase *lb, - void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); + void (*operation_cb)(struct bContext *C, struct Scene *scene, struct TreeElement *, struct TreeStoreElem *, TreeStoreElem *)); int common_restrict_check(struct bContext *C, struct Object *ob); diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index 00b3979b074..18769476118 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -73,21 +73,21 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se { TreeElement *te; TreeStoreElem *tselem; - int change= 0; + int change = 0; - for (te= lb->first; te && *index >= 0; te=te->next, (*index)--) { - tselem= TREESTORE(te); + for (te = lb->first; te && *index >= 0; te = te->next, (*index)--) { + tselem = TREESTORE(te); /* if we've encountered the right item, set its 'Outliner' selection status */ if (*index == 0) { /* this should be the last one, so no need to do anything with index */ - if ((te->flag & TE_ICONROW)==0) { + if ((te->flag & TE_ICONROW) == 0) { /* -1 value means toggle testing for now... */ if (*selecting == -1) { if (tselem->flag & TSE_SELECTED) - *selecting= 0; + *selecting = 0; else - *selecting= 1; + *selecting = 1; } /* set selection */ @@ -103,9 +103,9 @@ static int outliner_select(SpaceOops *soops, ListBase *lb, int *index, short *se /* Only try selecting sub-elements if we haven't hit the right element yet * * Hack warning: - * Index must be reduced before supplying it to the sub-tree to try to do - * selection, however, we need to increment it again for the next loop to - * function correctly + * Index must be reduced before supplying it to the sub-tree to try to do + * selection, however, we need to increment it again for the next loop to + * function correctly */ (*index)--; change |= outliner_select(soops, &te->subtree, index, selecting); @@ -124,45 +124,45 @@ static int tree_element_active_renderlayer(bContext *C, TreeElement *te, TreeSto Scene *sce; /* paranoia check */ - if (te->idcode!=ID_SCE) + if (te->idcode != ID_SCE) return 0; - sce= (Scene *)tselem->id; + sce = (Scene *)tselem->id; if (set) { - sce->r.actlay= tselem->nr; - WM_event_add_notifier(C, NC_SCENE|ND_RENDER_OPTIONS, sce); + sce->r.actlay = tselem->nr; + WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, sce); } else { - return sce->r.actlay==tselem->nr; + return sce->r.actlay == tselem->nr; } return 0; } static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); Scene *sce; Base *base; - Object *ob= NULL; + Object *ob = NULL; /* if id is not object, we search back */ - if (te->idcode==ID_OB) ob= (Object *)tselem->id; + if (te->idcode == ID_OB) ob = (Object *)tselem->id; else { - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if (ob==OBACT) return 0; + ob = (Object *)outliner_search_back(soops, te, ID_OB); + if (ob == OBACT) return 0; } - if (ob==NULL) return 0; + if (ob == NULL) return 0; - sce= (Scene *)outliner_search_back(soops, te, ID_SCE); + sce = (Scene *)outliner_search_back(soops, te, ID_SCE); if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } /* find associated base in current scene */ - base= object_in_scene(ob, scene); + base = BKE_scene_base_find(scene, ob); if (base) { - if (set==2) { + if (set == 2) { /* swap select */ if (base->flag & SELECT) ED_base_object_select(base, BA_DESELECT); @@ -171,17 +171,17 @@ static int tree_element_set_active_object(bContext *C, Scene *scene, SpaceOops } else { /* deleselect all */ - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); ED_base_object_select(base, BA_SELECT); } if (C) { ED_base_object_activate(C, base); /* adds notifier */ - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } - if (ob!=scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + if (ob != scene->obedit) + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); return 1; } @@ -192,35 +192,35 @@ static int tree_element_active_material(bContext *C, Scene *scene, SpaceOops *so Object *ob; /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); + ob = (Object *)outliner_search_back(soops, te, ID_OB); // note: ob->matbits can be NULL when a local object points to a library mesh. - if (ob==NULL || ob!=OBACT || ob->matbits==NULL) return 0; // just paranoia + if (ob == NULL || ob != OBACT || ob->matbits == NULL) return 0; // just paranoia /* searching in ob mat array? */ - tes= te->parent; - if (tes->idcode==ID_OB) { + tes = te->parent; + if (tes->idcode == ID_OB) { if (set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 1; // make ob material active too + ob->actcol = te->index + 1; + ob->matbits[te->index] = 1; // make ob material active too } else { - if (ob->actcol == te->index+1) + if (ob->actcol == te->index + 1) if (ob->matbits[te->index]) return 1; } } /* or we search for obdata material */ else { if (set) { - ob->actcol= te->index+1; - ob->matbits[te->index]= 0; // make obdata material active too + ob->actcol = te->index + 1; + ob->matbits[te->index] = 0; // make obdata material active too } else { - if (ob->actcol == te->index+1) - if (ob->matbits[te->index]==0) return 1; + if (ob->actcol == te->index + 1) + if (ob->matbits[te->index] == 0) return 1; } } if (set) { - WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, NULL); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING, NULL); } return 0; } @@ -229,10 +229,10 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo { TreeElement *tep; TreeStoreElem /* *tselem,*/ *tselemp; - Object *ob=OBACT; - SpaceButs *sbuts=NULL; + Object *ob = OBACT; + SpaceButs *sbuts = NULL; - if (ob==NULL) return 0; // no active object + if (ob == NULL) return 0; // no active object /*tselem= TREESTORE(te);*/ /*UNUSED*/ @@ -240,11 +240,11 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo /* XXX removed finding sbuts */ /* where is texture linked to? */ - tep= te->parent; - tselemp= TREESTORE(tep); + tep = te->parent; + tselemp = TREESTORE(tep); - if (tep->idcode==ID_WO) { - World *wrld= (World *)tselemp->id; + if (tep->idcode == ID_WO) { + World *wrld = (World *)tselemp->id; if (set) { if (sbuts) { @@ -252,43 +252,43 @@ static int tree_element_active_texture(bContext *C, Scene *scene, SpaceOops *soo // XXX sbuts->texfrom= 1; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - wrld->texact= te->index; + wrld->texact = te->index; } else if (tselemp->id == (ID *)(scene->world)) { - if (wrld->texact==te->index) return 1; + if (wrld->texact == te->index) return 1; } } - else if (tep->idcode==ID_LA) { - Lamp *la= (Lamp *)tselemp->id; + else if (tep->idcode == ID_LA) { + Lamp *la = (Lamp *)tselemp->id; if (set) { if (sbuts) { // XXX sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 2; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - la->texact= te->index; + la->texact = te->index; } else { if (tselemp->id == ob->data) { - if (la->texact==te->index) return 1; + if (la->texact == te->index) return 1; } } } - else if (tep->idcode==ID_MA) { - Material *ma= (Material *)tselemp->id; + else if (tep->idcode == ID_MA) { + Material *ma = (Material *)tselemp->id; if (set) { if (sbuts) { //sbuts->tabo= TAB_SHADING_TEX; // hack from header_buttonswin.c // XXX sbuts->texfrom= 0; } // XXX extern_set_butspace(F6KEY, 0); // force shading buttons texture - ma->texact= (char)te->index; + ma->texact = (char)te->index; /* also set active material */ - ob->actcol= tep->index+1; + ob->actcol = tep->index + 1; } - else if (tep->flag & TE_ACTIVE) { // this is active material - if (ma->texact==te->index) return 1; + else if (tep->flag & TE_ACTIVE) { // this is active material + if (ma->texact == te->index) return 1; } } @@ -304,8 +304,8 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops Object *ob; /* we search for the object parent */ - ob= (Object *)outliner_search_back(soops, te, ID_OB); - if (ob==NULL || ob!=OBACT) return 0; // just paranoia + ob = (Object *)outliner_search_back(soops, te, ID_OB); + if (ob == NULL || ob != OBACT) return 0; // just paranoia if (set) { // XXX extern_set_butspace(F5KEY, 0); @@ -317,7 +317,7 @@ static int tree_element_active_lamp(bContext *UNUSED(C), Scene *scene, SpaceOops static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOops *soops, TreeElement *te, int set) { - Object *ob= (Object *)outliner_search_back(soops, te, ID_OB); + Object *ob = (Object *)outliner_search_back(soops, te, ID_OB); if (set) return 0; @@ -328,22 +328,22 @@ static int tree_element_active_camera(bContext *UNUSED(C), Scene *scene, SpaceOo static int tree_element_active_world(bContext *C, Scene *scene, SpaceOops *soops, TreeElement *te, int set) { TreeElement *tep; - TreeStoreElem *tselem=NULL; - Scene *sce=NULL; + TreeStoreElem *tselem = NULL; + Scene *sce = NULL; - tep= te->parent; + tep = te->parent; if (tep) { - tselem= TREESTORE(tep); - sce= (Scene *)tselem->id; + tselem = TREESTORE(tep); + sce = (Scene *)tselem->id; } - if (set) { // make new scene active + if (set) { // make new scene active if (sce && scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } } - if (tep==NULL || tselem->id == (ID *)scene) { + if (tep == NULL || tselem->id == (ID *)scene) { if (set) { // XXX extern_set_butspace(F8KEY, 0); } @@ -359,34 +359,34 @@ static int tree_element_active_defgroup(bContext *C, Scene *scene, TreeElement * Object *ob; /* id in tselem is object */ - ob= (Object *)tselem->id; + ob = (Object *)tselem->id; if (set) { - BLI_assert(te->index+1 >= 0); - ob->actdef= te->index+1; + BLI_assert(te->index + 1 >= 0); + ob->actdef = te->index + 1; DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_event_add_notifier(C, NC_OBJECT|ND_TRANSFORM, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, ob); } else { - if (ob==OBACT) - if (ob->actdef== te->index+1) return 1; + if (ob == OBACT) + if (ob->actdef == te->index + 1) return 1; } return 0; } static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; if (set) { if (ob->pose) { - ob->pose->active_group= te->index+1; - WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); + ob->pose->active_group = te->index + 1; + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } } else { - if (ob==OBACT && ob->pose) { - if (ob->pose->active_group== te->index+1) return 1; + if (ob == OBACT && ob->pose) { + if (ob->pose->active_group == te->index + 1) return 1; } } return 0; @@ -394,30 +394,30 @@ static int tree_element_active_posegroup(bContext *C, Scene *scene, TreeElement static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; - bArmature *arm= ob->data; - bPoseChannel *pchan= te->directdata; + Object *ob = (Object *)tselem->id; + bArmature *arm = ob->data; + bPoseChannel *pchan = te->directdata; if (set) { if (!(pchan->bone->flag & BONE_HIDDEN_P)) { - if (set==2) ED_pose_deselectall(ob, 2); // 2 = clear active tag - else ED_pose_deselectall(ob, 0); // 0 = deselect + if (set == 2) ED_pose_deselectall(ob, 2); // 2 = clear active tag + else ED_pose_deselectall(ob, 0); // 0 = deselect - if (set==2 && (pchan->bone->flag & BONE_SELECTED)) { + if (set == 2 && (pchan->bone->flag & BONE_SELECTED)) { pchan->bone->flag &= ~BONE_SELECTED; } else { pchan->bone->flag |= BONE_SELECTED; - arm->act_bone= pchan->bone; + arm->act_bone = pchan->bone; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob); } } else { - if (ob==OBACT && ob->pose) { + if (ob == OBACT && ob->pose) { if (pchan->bone->flag & BONE_SELECTED) return 1; } } @@ -426,29 +426,29 @@ static int tree_element_active_posechannel(bContext *C, Scene *scene, TreeElemen static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *tselem, int set) { - bArmature *arm= (bArmature *)tselem->id; - Bone *bone= te->directdata; + bArmature *arm = (bArmature *)tselem->id; + Bone *bone = te->directdata; if (set) { if (!(bone->flag & BONE_HIDDEN_P)) { - if (set==2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag + if (set == 2) ED_pose_deselectall(OBACT, 2); // 2 is clear active tag else ED_pose_deselectall(OBACT, 0); - if (set==2 && (bone->flag & BONE_SELECTED)) { + if (set == 2 && (bone->flag & BONE_SELECTED)) { bone->flag &= ~BONE_SELECTED; } else { bone->flag |= BONE_SELECTED; - arm->act_bone= bone; + arm->act_bone = bone; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, OBACT); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT); } } else { - Object *ob= OBACT; + Object *ob = OBACT; - if (ob && ob->data==arm) { + if (ob && ob->data == arm) { if (bone->flag & BONE_SELECTED) return 1; } } @@ -460,32 +460,32 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te, static void tree_element_active_ebone__sel(bContext *C, Scene *scene, bArmature *arm, EditBone *ebone, short sel) { if (sel) { - ebone->flag |= BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL; - arm->act_edbone= ebone; + ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL; + arm->act_edbone = ebone; // flush to parent? if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag |= BONE_TIPSEL; } else { - ebone->flag &= ~(BONE_SELECTED|BONE_ROOTSEL|BONE_TIPSEL); + ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL); // flush to parent? if (ebone->parent && (ebone->flag & BONE_CONNECTED)) ebone->parent->flag &= ~BONE_TIPSEL; } - WM_event_add_notifier(C, NC_OBJECT|ND_BONE_ACTIVE, scene->obedit); + WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, scene->obedit); } static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { - bArmature *arm= scene->obedit->data; - EditBone *ebone= te->directdata; + bArmature *arm = scene->obedit->data; + EditBone *ebone = te->directdata; - if (set==1) { + if (set == 1) { if (!(ebone->flag & BONE_HIDDEN_A)) { - ED_armature_deselect_all(scene->obedit, 0); // deselect + ED_armature_deselect_all(scene->obedit, 0); // deselect tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); return 1; } } - else if (set==2) { + else if (set == 2) { if (!(ebone->flag & BONE_HIDDEN_A)) { if (!(ebone->flag & BONE_SELECTED)) { tree_element_active_ebone__sel(C, scene, arm, ebone, TRUE); @@ -507,9 +507,9 @@ static int tree_element_active_ebone(bContext *C, Scene *scene, TreeElement *te, static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_MODIFIER, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); // XXX extern_set_butspace(F9KEY, 0); } @@ -520,9 +520,9 @@ static int tree_element_active_modifier(bContext *C, TreeElement *UNUSED(te), Tr static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE|NA_EDITED, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); // XXX extern_set_butspace(F7KEY, 0); } @@ -533,9 +533,9 @@ static int tree_element_active_psys(bContext *C, Scene *UNUSED(scene), TreeEleme static int tree_element_active_constraint(bContext *C, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { if (set) { - Object *ob= (Object *)tselem->id; + Object *ob = (Object *)tselem->id; - WM_event_add_notifier(C, NC_OBJECT|ND_CONSTRAINT, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, ob); // XXX extern_set_butspace(F7KEY, 0); } @@ -550,12 +550,12 @@ static int tree_element_active_text(bContext *UNUSED(C), Scene *UNUSED(scene), S static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *tselem, int set) { - Object *ob= (Object *)tselem->id; - Base *base= object_in_scene(ob, scene); + Object *ob = (Object *)tselem->id; + Base *base = BKE_scene_base_find(scene, ob); if (set) { if (scene->obedit) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); if (ob->mode & OB_MODE_POSE) ED_armature_exit_posemode(C, base); @@ -570,7 +570,7 @@ static int tree_element_active_pose(bContext *C, Scene *scene, TreeElement *UNUS static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { - Sequence *seq= (Sequence*) te->directdata; + Sequence *seq = (Sequence *) te->directdata; if (set) { // XXX select_single_seq(seq, 1); @@ -585,26 +585,26 @@ static int tree_element_active_sequence(TreeElement *te, TreeStoreElem *UNUSED(t static int tree_element_active_sequence_dup(Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tselem), int set) { Sequence *seq, *p; - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - seq= (Sequence*)te->directdata; - if (set==0) { + seq = (Sequence *)te->directdata; + if (set == 0) { if (seq->flag & SELECT) return(1); return(0); } // XXX select_single_seq(seq, 1); - p= ed->seqbasep->first; + p = ed->seqbasep->first; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } // if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) // XXX select_single_seq(p, 0); - p= p->next; + p = p->next; } return(0); } @@ -613,7 +613,7 @@ static int tree_element_active_keymap_item(bContext *UNUSED(C), TreeElement *te, { wmKeyMapItem *kmi = te->directdata; - if (set==0) { + if (set == 0) { if (kmi->flag & KMI_INACTIVE) return 0; return 1; } @@ -663,7 +663,7 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl return tree_element_active_modifier(C, te, tselem, set); case TSE_LINKED_OB: if (set) tree_element_set_active_object(C, scene, soops, te, set); - else if (tselem->id==(ID *)OBACT) return 1; + else if (tselem->id == (ID *)OBACT) return 1; break; case TSE_LINKED_PSYS: return tree_element_active_psys(C, scene, te, tselem, set); @@ -693,14 +693,14 @@ int tree_element_type_active(bContext *C, Scene *scene, SpaceOops *soops, TreeEl static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, SpaceOops *soops, TreeElement *te, int extend, const float mval[2]) { - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - TreeStoreElem *tselem= TREESTORE(te); - int openclose= 0; + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + TreeStoreElem *tselem = TREESTORE(te); + int openclose = 0; /* open close icon */ - if ((te->flag & TE_ICONROW)==0) { // hidden icon, no open/close - if ( mval[0]>te->xs && mval[0]xs+UI_UNIT_X) - openclose= 1; + if ((te->flag & TE_ICONROW) == 0) { // hidden icon, no open/close + if (mval[0] > te->xs && mval[0] < te->xs + UI_UNIT_X) + openclose = 1; } if (openclose) { @@ -718,62 +718,62 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa return 1; } /* name and first icon */ - else if (mval[0]>te->xs+UI_UNIT_X && mval[0]xend) { + else if (mval[0] > te->xs + UI_UNIT_X && mval[0] < te->xend) { /* always makes active object */ - if (tselem->type!=TSE_SEQUENCE && tselem->type!=TSE_SEQ_STRIP && tselem->type!=TSE_SEQUENCE_DUP) - tree_element_set_active_object(C, scene, soops, te, 1 + (extend!=0 && tselem->type==0)); + if (tselem->type != TSE_SEQUENCE && tselem->type != TSE_SEQ_STRIP && tselem->type != TSE_SEQUENCE_DUP) + tree_element_set_active_object(C, scene, soops, te, 1 + (extend != 0 && tselem->type == 0)); - if (tselem->type==0) { // the lib blocks + if (tselem->type == 0) { // the lib blocks /* editmode? */ - if (te->idcode==ID_SCE) { - if (scene!=(Scene *)tselem->id) { + if (te->idcode == ID_SCE) { + if (scene != (Scene *)tselem->id) { ED_screen_set_scene(C, CTX_wm_screen(C), (Scene *)tselem->id); } } - else if (te->idcode==ID_GR) { - Group *gr= (Group *)tselem->id; + else if (te->idcode == ID_GR) { + Group *gr = (Group *)tselem->id; GroupObject *gob; if (extend) { - int sel= BA_SELECT; - for (gob= gr->gobject.first; gob; gob= gob->next) { + int sel = BA_SELECT; + for (gob = gr->gobject.first; gob; gob = gob->next) { if (gob->ob->flag & SELECT) { - sel= BA_DESELECT; + sel = BA_DESELECT; break; } } - for (gob= gr->gobject.first; gob; gob= gob->next) { - ED_base_object_select(object_in_scene(gob->ob, scene), sel); + for (gob = gr->gobject.first; gob; gob = gob->next) { + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), sel); } } else { - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); - for (gob= gr->gobject.first; gob; gob= gob->next) { + for (gob = gr->gobject.first; gob; gob = gob->next) { if ((gob->ob->flag & SELECT) == 0) - ED_base_object_select(object_in_scene(gob->ob, scene), BA_SELECT); + ED_base_object_select(BKE_scene_base_find(scene, gob->ob), BA_SELECT); } } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } else if (ELEM5(te->idcode, ID_ME, ID_CU, ID_MB, ID_LT, ID_AR)) { WM_operator_name_call(C, "OBJECT_OT_editmode_toggle", WM_OP_INVOKE_REGION_WIN, NULL); } - else { // rest of types + else { // rest of types tree_element_active(C, scene, soops, te, 1); } } - else tree_element_type_active(C, scene, soops, te, tselem, 1+(extend!=0)); + else tree_element_type_active(C, scene, soops, te, tselem, 1 + (extend != 0)); return 1; } } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_item_activate(C, scene, ar, soops, te, extend, mval)) return 1; } return 0; @@ -782,23 +782,23 @@ static int do_outliner_item_activate(bContext *C, Scene *scene, ARegion *ar, Spa /* event can enterkey, then it opens/closes */ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - int extend= RNA_boolean_get(op->ptr, "extend"); + int extend = RNA_boolean_get(op->ptr, "extend"); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - if ( !ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && - !(soops->flag & SO_HIDE_RESTRICTCOLS) && - (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) + if (!ELEM3(soops->outlinevis, SO_DATABLOCKS, SO_USERDEF, SO_KEYMAP) && + !(soops->flag & SO_HIDE_RESTRICTCOLS) && + (fmval[0] > ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX)) { return OPERATOR_CANCELLED; } - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_item_activate(C, scene, ar, soops, te, extend, fmval)) break; } @@ -806,12 +806,12 @@ static int outliner_item_activate(bContext *C, wmOperator *op, wmEvent *event) ED_undo_push(C, "Outliner click event"); } else { - short selecting= -1; + short selecting = -1; int row; /* get row number - 100 here is just a dummy value since we don't need the column */ UI_view2d_listview_view_to_cell(&ar->v2d, 1000, UI_UNIT_Y, 0.0f, OL_Y_OFFSET, - fmval[0], fmval[1], NULL, &row); + fmval[0], fmval[1], NULL, &row); /* select relevant row */ if (outliner_select(soops, &soops->tree, &row, &selecting)) { @@ -847,7 +847,7 @@ void OUTLINER_OT_item_activate(wmOperatorType *ot) /* **************** Border Select Tool ****************** */ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *rectf, TreeElement *te, int gesture_mode) { - TreeStoreElem *tselem= TREESTORE(te); + TreeStoreElem *tselem = TREESTORE(te); if (te->ys <= rectf->ymax && te->ys + UI_UNIT_Y >= rectf->ymin) { if (gesture_mode == GESTURE_MODAL_SELECT) { @@ -869,13 +869,13 @@ static void outliner_item_border_select(Scene *scene, SpaceOops *soops, rctf *re static int outliner_border_select_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - ARegion *ar= CTX_wm_region(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + ARegion *ar = CTX_wm_region(C); TreeElement *te; rcti rect; rctf rectf; - int gesture_mode= RNA_int_get(op->ptr, "gesture_mode"); + int gesture_mode = RNA_int_get(op->ptr, "gesture_mode"); rect.xmin = RNA_int_get(op->ptr, "xmin"); rect.ymin = RNA_int_get(op->ptr, "ymin"); @@ -885,11 +885,11 @@ static int outliner_border_select_exec(bContext *C, wmOperator *op) rect.ymax = RNA_int_get(op->ptr, "ymax"); UI_view2d_region_to_view(&ar->v2d, rect.xmax, rect.ymax, &rectf.xmax, &rectf.ymax); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { outliner_item_border_select(scene, soops, &rectf, te, gesture_mode); } - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; @@ -911,7 +911,7 @@ void OUTLINER_OT_select_border(wmOperatorType *ot) ot->poll = ED_operator_outliner_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ WM_operator_properties_gesture_border(ot, FALSE); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 89eb51f73ba..a3ed2eac2d5 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -77,31 +77,31 @@ /* ************ SELECTION OPERATIONS ********* */ static void set_operation_types(SpaceOops *soops, ListBase *lb, - int *scenelevel, - int *objectlevel, - int *idlevel, - int *datalevel) + int *scenelevel, + int *objectlevel, + int *idlevel, + int *datalevel) { TreeElement *te; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { if (tselem->type) { - if (*datalevel==0) - *datalevel= tselem->type; - else if (*datalevel!=tselem->type) - *datalevel= -1; + if (*datalevel == 0) + *datalevel = tselem->type; + else if (*datalevel != tselem->type) + *datalevel = -1; } else { - int idcode= GS(tselem->id->name); + int idcode = GS(tselem->id->name); switch (idcode) { case ID_SCE: - *scenelevel= 1; + *scenelevel = 1; break; case ID_OB: - *objectlevel= 1; + *objectlevel = 1; break; case ID_ME: case ID_CU: case ID_MB: case ID_LT: @@ -109,9 +109,9 @@ static void set_operation_types(SpaceOops *soops, ListBase *lb, case ID_MA: case ID_TE: case ID_IP: case ID_IM: case ID_SO: case ID_KE: case ID_WO: case ID_AC: case ID_NLA: case ID_TXT: case ID_GR: - if (*idlevel==0) *idlevel= idcode; - else if (*idlevel!=idcode) *idlevel= -1; - break; + if (*idlevel == 0) *idlevel = idcode; + else if (*idlevel != idcode) *idlevel = -1; + break; } } } @@ -130,62 +130,62 @@ static void unlink_action_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNU static void unlink_material_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { - Material **matar=NULL; - int a, totcol=0; + Material **matar = NULL; + int a, totcol = 0; - if ( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - totcol= ob->totcol; - matar= ob->mat; + if (GS(tsep->id->name) == ID_OB) { + Object *ob = (Object *)tsep->id; + totcol = ob->totcol; + matar = ob->mat; } - else if ( GS(tsep->id->name)==ID_ME) { - Mesh *me= (Mesh *)tsep->id; - totcol= me->totcol; - matar= me->mat; + else if (GS(tsep->id->name) == ID_ME) { + Mesh *me = (Mesh *)tsep->id; + totcol = me->totcol; + matar = me->mat; } - else if ( GS(tsep->id->name)==ID_CU) { - Curve *cu= (Curve *)tsep->id; - totcol= cu->totcol; - matar= cu->mat; + else if (GS(tsep->id->name) == ID_CU) { + Curve *cu = (Curve *)tsep->id; + totcol = cu->totcol; + matar = cu->mat; } - else if ( GS(tsep->id->name)==ID_MB) { - MetaBall *mb= (MetaBall *)tsep->id; - totcol= mb->totcol; - matar= mb->mat; + else if (GS(tsep->id->name) == ID_MB) { + MetaBall *mb = (MetaBall *)tsep->id; + totcol = mb->totcol; + matar = mb->mat; } - for (a=0; aindex && matar[a]) { + for (a = 0; a < totcol; a++) { + if (a == te->index && matar[a]) { matar[a]->id.us--; - matar[a]= NULL; + matar[a] = NULL; } } } static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *te, TreeStoreElem *tsep, TreeStoreElem *UNUSED(tselem)) { - MTex **mtex= NULL; + MTex **mtex = NULL; int a; - if ( GS(tsep->id->name)==ID_MA) { - Material *ma= (Material *)tsep->id; - mtex= ma->mtex; + if (GS(tsep->id->name) == ID_MA) { + Material *ma = (Material *)tsep->id; + mtex = ma->mtex; } - else if ( GS(tsep->id->name)==ID_LA) { - Lamp *la= (Lamp *)tsep->id; - mtex= la->mtex; + else if (GS(tsep->id->name) == ID_LA) { + Lamp *la = (Lamp *)tsep->id; + mtex = la->mtex; } - else if ( GS(tsep->id->name)==ID_WO) { - World *wrld= (World *)tsep->id; - mtex= wrld->mtex; + else if (GS(tsep->id->name) == ID_WO) { + World *wrld = (World *)tsep->id; + mtex = wrld->mtex; } else return; - for (a=0; aindex && mtex[a]) { + for (a = 0; a < MAX_MTEX; a++) { + if (a == te->index && mtex[a]) { if (mtex[a]->tex) { mtex[a]->tex->id.us--; - mtex[a]->tex= NULL; + mtex[a]->tex = NULL; } } } @@ -193,16 +193,16 @@ static void unlink_texture_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEle static void unlink_group_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeElement *UNUSED(te), TreeStoreElem *tsep, TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; if (tsep) { - if ( GS(tsep->id->name)==ID_OB) { - Object *ob= (Object *)tsep->id; - ob->dup_group= NULL; + if (GS(tsep->id->name) == ID_OB) { + Object *ob = (Object *)tsep->id; + ob->dup_group = NULL; } } else { - unlink_group(group); + BKE_group_unlink(group); } } @@ -217,16 +217,16 @@ static void unlink_world_cb(bContext *UNUSED(C), Scene *UNUSED(scene), TreeEleme } static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==0) { - TreeStoreElem *tsep= TREESTORE(te->parent); + if (tselem->type == 0) { + TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(C, scene, te, tsep, tselem); } } @@ -240,10 +240,10 @@ static void outliner_do_libdata_operation(bContext *C, Scene *scene, SpaceOops * static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); - if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW)==0)) { + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); + if (base && ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0)) { base->flag |= SELECT; base->object->flag |= SELECT; } @@ -251,9 +251,9 @@ static void object_select_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { base->flag &= ~SELECT; base->object->flag &= ~SELECT; @@ -262,18 +262,18 @@ static void object_deselect_cb(bContext *UNUSED(C), Scene *scene, TreeElement *t static void object_delete_cb(bContext *C, Scene *scene, TreeElement *te, TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Base *base= (Base *)te->directdata; + Base *base = (Base *)te->directdata; - if (base==NULL) - base= object_in_scene((Object *)tselem->id, scene); + if (base == NULL) + base = BKE_scene_base_find(scene, (Object *)tselem->id); if (base) { // check also library later - if (scene->obedit==base->object) - ED_object_exit_editmode(C, EM_FREEDATA|EM_FREEUNDO|EM_WAITCURSOR|EM_DO_UNDO); + if (scene->obedit == base->object) + ED_object_exit_editmode(C, EM_FREEDATA | EM_FREEUNDO | EM_WAITCURSOR | EM_DO_UNDO); ED_base_object_free_and_unlink(CTX_data_main(C), scene, base); - te->directdata= NULL; - tselem->id= NULL; + te->directdata = NULL; + tselem->id = NULL; } } @@ -283,7 +283,7 @@ static void id_local_cb(bContext *C, Scene *UNUSED(scene), TreeElement *UNUSED(t /* if the ID type has no special local function, * just clear the lib */ if (id_make_local(tselem->id, FALSE) == FALSE) { - Main *bmain= CTX_data_main(C); + Main *bmain = CTX_data_main(C); id_clear_lib_data(bmain, tselem->id); } } @@ -344,41 +344,41 @@ static void singleuser_world_cb(bContext *C, Scene *UNUSED(scene), TreeElement * static void group_linkobs2scene_cb(bContext *UNUSED(C), Scene *scene, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tsep), TreeStoreElem *tselem) { - Group *group= (Group *)tselem->id; + Group *group = (Group *)tselem->id; GroupObject *gob; Base *base; - for (gob=group->gobject.first; gob; gob=gob->next) { - base= object_in_scene(gob->ob, scene); + for (gob = group->gobject.first; gob; gob = gob->next) { + base = BKE_scene_base_find(scene, gob->ob); if (base) { base->object->flag |= SELECT; base->flag |= SELECT; } else { /* link to scene */ - base= MEM_callocN(sizeof(Base), "add_base"); + base = MEM_callocN(sizeof(Base), "add_base"); BLI_addhead(&scene->base, base); - base->lay= (1<<20)-1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ + base->lay = (1 << 20) - 1; /*v3d->lay;*/ /* would be nice to use the 3d layer but the include's not here */ gob->ob->flag |= SELECT; base->flag = gob->ob->flag; - base->object= gob->ob; + base->object = gob->ob; id_lib_extern((ID *)gob->ob); /* in case these are from a linked group */ } } } void outliner_do_object_operation(bContext *C, Scene *scene_act, SpaceOops *soops, ListBase *lb, - void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) + void (*operation_cb)(bContext *C, Scene *scene, TreeElement *, TreeStoreElem *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==0 && te->idcode==ID_OB) { + if (tselem->type == 0 && te->idcode == ID_OB) { // when objects selected in other scenes... dunno if that should be allowed - Scene *scene_owner= (Scene *)outliner_search_back(soops, te, ID_SCE); + Scene *scene_owner = (Scene *)outliner_search_back(soops, te, ID_SCE); if (scene_owner && scene_act != scene_owner) { ED_screen_set_scene(C, CTX_wm_screen(C), scene_owner); } @@ -416,7 +416,7 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te FCurve *fcu; /* loop over drivers, performing refresh (i.e. check graph_buttons.c and rna_fcurve.c for details) */ - for (fcu = iat->adt->drivers.first; fcu; fcu= fcu->next) { + for (fcu = iat->adt->drivers.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_DISABLED; if (fcu->driver) @@ -428,70 +428,70 @@ static void refreshdrivers_animdata_cb(int UNUSED(event), TreeElement *UNUSED(te static void pchan_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - bPoseChannel *pchan= (bPoseChannel *)te->directdata; + bPoseChannel *pchan = (bPoseChannel *)te->directdata; - if (event==1) + if (event == 1) pchan->bone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) pchan->bone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { pchan->bone->flag |= BONE_HIDDEN_P; pchan->bone->flag &= ~BONE_SELECTED; } - else if (event==4) + else if (event == 4) pchan->bone->flag &= ~BONE_HIDDEN_P; } static void bone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - Bone *bone= (Bone *)te->directdata; + Bone *bone = (Bone *)te->directdata; - if (event==1) + if (event == 1) bone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) bone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { bone->flag |= BONE_HIDDEN_P; bone->flag &= ~BONE_SELECTED; } - else if (event==4) + else if (event == 4) bone->flag &= ~BONE_HIDDEN_P; } static void ebone_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem)) { - EditBone *ebone= (EditBone *)te->directdata; + EditBone *ebone = (EditBone *)te->directdata; - if (event==1) + if (event == 1) ebone->flag |= BONE_SELECTED; - else if (event==2) + else if (event == 2) ebone->flag &= ~BONE_SELECTED; - else if (event==3) { + else if (event == 3) { ebone->flag |= BONE_HIDDEN_A; - ebone->flag &= ~BONE_SELECTED|BONE_TIPSEL|BONE_ROOTSEL; + ebone->flag &= ~BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL; } - else if (event==4) + else if (event == 4) ebone->flag &= ~BONE_HIDDEN_A; } static void sequence_cb(int event, TreeElement *UNUSED(te), TreeStoreElem *UNUSED(tselem)) { // Sequence *seq= (Sequence*) te->directdata; - if (event==1) { + if (event == 1) { // XXX select_single_seq(seq, 1); } } static void outliner_do_data_operation(SpaceOops *soops, int type, int event, ListBase *lb, - void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) + void (*operation_cb)(int, TreeElement *, TreeStoreElem *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==type) { + if (tselem->type == type) { operation_cb(event, te, tselem); } } @@ -516,34 +516,34 @@ static EnumPropertyItem prop_object_op_types[] = { static int outliner_object_operation_exec(bContext *C, wmOperator *op) { - Main *bmain= CTX_data_main(C); - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Main *bmain = CTX_data_main(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str= NULL; + const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); - if (event==1) { - Scene *sce= scene; // to be able to delete, scenes are set... + if (event == 1) { + Scene *sce = scene; // to be able to delete, scenes are set... outliner_do_object_operation(C, scene, soops, &soops->tree, object_select_cb); if (scene != sce) { ED_screen_set_scene(C, CTX_wm_screen(C), sce); } - str= "Select Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Select Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==2) { + else if (event == 2) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_deselect_cb); - str= "Deselect Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Deselect Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==4) { + else if (event == 4) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_delete_cb); /* XXX: tree management normally happens from draw_outliner(), but when @@ -554,31 +554,31 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) outliner_cleanup_tree(soops); DAG_scene_sort(bmain, scene); - str= "Delete Objects"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); + str = "Delete Objects"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } - else if (event==5) { /* disabled, see above enum (ton) */ + else if (event == 5) { /* disabled, see above enum (ton) */ outliner_do_object_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Objects"; + str = "Localized Objects"; } - else if (event==6) { + else if (event == 6) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_visibility_cb); - str= "Toggle Visibility"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_VISIBLE, scene); + str = "Toggle Visibility"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene); } - else if (event==7) { + else if (event == 7) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_selectability_cb); - str= "Toggle Selectability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_SELECT, scene); + str = "Toggle Selectability"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } - else if (event==8) { + else if (event == 8) { outliner_do_object_operation(C, scene, soops, &soops->tree, object_toggle_renderability_cb); - str= "Toggle Renderability"; - WM_event_add_notifier(C, NC_SCENE|ND_OB_RENDER, scene); + str = "Toggle Renderability"; + WM_event_add_notifier(C, NC_SCENE | ND_OB_RENDER, scene); } - else if (event==9) { + else if (event == 9) { outliner_do_object_operation(C, scene, soops, &soops->tree, item_rename_cb); - str= "Rename Object"; + str = "Rename Object"; } ED_undo_push(C, str); @@ -619,44 +619,44 @@ static EnumPropertyItem prop_group_op_types[] = { static int outliner_group_operation_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); int event; - const char *str= NULL; + const char *str = NULL; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); - if (event==1) { + if (event == 1) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_group_cb); - str= "Unlink group"; + str = "Unlink group"; } - else if (event==2) { + else if (event == 2) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); - str= "Localized Data"; + str = "Localized Data"; } - else if (event==3) { + else if (event == 3) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_linkobs2scene_cb); - str= "Link Group Objects to Scene"; + str = "Link Group Objects to Scene"; } - else if (event==4) { + else if (event == 4) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_visibility_cb); - str= "Toggle Visibility"; + str = "Toggle Visibility"; } - else if (event==5) { + else if (event == 5) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_selectability_cb); - str= "Toggle Selectability"; + str = "Toggle Selectability"; } - else if (event==6) { + else if (event == 6) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, group_toggle_renderability_cb); - str= "Toggle Renderability"; + str = "Toggle Renderability"; } - else if (event==7) { + else if (event == 7) { outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - str= "Rename"; + str = "Rename"; } @@ -711,9 +711,9 @@ static EnumPropertyItem prop_id_op_types[] = { static int outliner_id_operation_exec(bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + Scene *scene = CTX_data_scene(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutlinerIdOpTypes event; /* check for invalid states */ @@ -722,7 +722,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); switch (event) { case OUTLINER_IDOP_UNLINK: @@ -732,25 +732,25 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_action_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case ID_MA: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_material_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink material"); break; case ID_TE: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_texture_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_OB_SHADING, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, NULL); ED_undo_push(C, "Unlink texture"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, unlink_world_cb); - WM_event_add_notifier(C, NC_SCENE|ND_WORLD, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Unlink world"); break; default: @@ -758,7 +758,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } } - break; + break; case OUTLINER_IDOP_LOCAL: { @@ -766,7 +766,7 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_local_cb); ED_undo_push(C, "Localized Data"); } - break; + break; case OUTLINER_IDOP_SINGLE: { @@ -775,14 +775,14 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) case ID_AC: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_action_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Single-User Action"); break; case ID_WO: outliner_do_libdata_operation(C, scene, soops, &soops->tree, singleuser_world_cb); - WM_event_add_notifier(C, NC_SCENE|ND_WORLD, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_WORLD, NULL); ED_undo_push(C, "Single-User World"); break; @@ -791,36 +791,36 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) break; } } - break; + break; case OUTLINER_IDOP_FAKE_ADD: { /* set fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_set_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Add Fake User"); } - break; + break; case OUTLINER_IDOP_FAKE_CLEAR: { /* clear fake user */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, id_fake_user_clear_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Clear Fake User"); } - break; + break; case OUTLINER_IDOP_RENAME: { /* rename */ outliner_do_libdata_operation(C, scene, soops, &soops->tree, item_rename_cb); - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); ED_undo_push(C, "Rename"); } - break; + break; default: // invalid - unhandled @@ -828,10 +828,10 @@ static int outliner_id_operation_exec(bContext *C, wmOperator *op) } /* wrong notifier still... */ - WM_event_add_notifier(C, NC_ID|NA_EDITED, NULL); + WM_event_add_notifier(C, NC_ID | NA_EDITED, NULL); // XXX: this is just so that outliner is always up to date - WM_event_add_notifier(C, NC_SPACE|ND_SPACE_OUTLINER, NULL); + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_OUTLINER, NULL); return OPERATOR_FINISHED; } @@ -857,15 +857,15 @@ void OUTLINER_OT_id_operation(wmOperatorType *ot) /* **************************************** */ static void outliner_do_id_set_operation(SpaceOops *soops, int type, ListBase *lb, ID *newid, - void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) + void (*operation_cb)(TreeElement *, TreeStoreElem *, TreeStoreElem *, ID *)) { TreeElement *te; TreeStoreElem *tselem; - for (te=lb->first; te; te= te->next) { - tselem= TREESTORE(te); + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); if (tselem->flag & TSE_SELECTED) { - if (tselem->type==type) { + if (tselem->type == type) { TreeStoreElem *tsep = TREESTORE(te->parent); operation_cb(te, tselem, tsep, newid); } @@ -898,8 +898,8 @@ static void actionset_id_cb(TreeElement *UNUSED(te), TreeStoreElem *tselem, Tree static int outliner_action_set_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; bAction *act; @@ -909,7 +909,7 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); /* get action to use */ - act= BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); + act = BLI_findlink(&CTX_data_main(C)->action, RNA_enum_get(op->ptr, "action")); if (act == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid Action to add"); @@ -918,20 +918,20 @@ static int outliner_action_set_exec(bContext *C, wmOperator *op) else if (act->idroot == 0) { /* hopefully in this case (i.e. library of userless actions), the user knows what they're doing... */ BKE_reportf(op->reports, RPT_WARNING, - "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", - act->id.name+2); + "Action '%s' does not specify what datablocks it can be used on. Try setting the 'ID Root Type' setting from the Datablocks Editor for this Action to avoid future problems", + act->id.name + 2); } /* perform action if valid channel */ if (datalevel == TSE_ANIM_DATA) - outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID*)act, actionset_id_cb); + outliner_do_id_set_operation(soops, datalevel, &soops->tree, (ID *)act, actionset_id_cb); else if (idlevel == ID_AC) - outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID*)act, actionset_id_cb); + outliner_do_id_set_operation(soops, idlevel, &soops->tree, (ID *)act, actionset_id_cb); else return OPERATOR_CANCELLED; /* set notifier that things have changed */ - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Set action"); /* done */ @@ -956,8 +956,8 @@ void OUTLINER_OT_action_set(wmOperatorType *ot) ot->flag = 0; /* props */ - // TODO: this would be nicer as an ID-pointer... - prop= RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); + // TODO: this would be nicer as an ID-pointer... + prop = RNA_def_enum(ot->srna, "action", DummyRNA_NULL_items, 0, "Action", ""); RNA_def_enum_funcs(prop, RNA_action_itemf); ot->prop = prop; } @@ -989,8 +989,8 @@ static EnumPropertyItem prop_animdata_op_types[] = { static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; eOutliner_AnimDataOps event; short updateDeps = 0; @@ -998,7 +998,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); if (datalevel != TSE_ANIM_DATA) @@ -1015,14 +1015,14 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) /* clear active action - using standard rules */ outliner_do_data_operation(soops, datalevel, event, &soops->tree, unlinkact_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_NLA_ACTCHANGE, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_NLA_ACTCHANGE, NULL); ED_undo_push(C, "Unlink action"); break; case OUTLINER_ANIMOP_REFRESH_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, refreshdrivers_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); //ED_undo_push(C, "Refresh Drivers"); /* no undo needed - shouldn't have any impact? */ updateDeps = 1; break; @@ -1030,7 +1030,7 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) case OUTLINER_ANIMOP_CLEAR_DRV: outliner_do_data_operation(soops, datalevel, event, &soops->tree, cleardrivers_animdata_cb); - WM_event_add_notifier(C, NC_ANIMATION|ND_ANIMCHAN, NULL); + WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN, NULL); ED_undo_push(C, "Clear Drivers"); updateDeps = 1; break; @@ -1084,40 +1084,40 @@ static EnumPropertyItem prop_data_op_types[] = { static int outliner_data_operation_exec(bContext *C, wmOperator *op) { - SpaceOops *soops= CTX_wm_space_outliner(C); - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; + SpaceOops *soops = CTX_wm_space_outliner(C); + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; int event; /* check for invalid states */ if (soops == NULL) return OPERATOR_CANCELLED; - event= RNA_enum_get(op->ptr, "type"); + event = RNA_enum_get(op->ptr, "type"); set_operation_types(soops, &soops->tree, &scenelevel, &objectlevel, &idlevel, &datalevel); - if (datalevel==TSE_POSE_CHANNEL) { - if (event>0) { + if (datalevel == TSE_POSE_CHANNEL) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, pchan_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "PoseChannel operation"); } } - else if (datalevel==TSE_BONE) { - if (event>0) { + else if (datalevel == TSE_BONE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, bone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "Bone operation"); } } - else if (datalevel==TSE_EBONE) { - if (event>0) { + else if (datalevel == TSE_EBONE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, ebone_cb); - WM_event_add_notifier(C, NC_OBJECT|ND_POSE, NULL); + WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL); ED_undo_push(C, "EditBone operation"); } } - else if (datalevel==TSE_SEQUENCE) { - if (event>0) { + else if (datalevel == TSE_SEQUENCE) { + if (event > 0) { outliner_do_data_operation(soops, datalevel, event, &soops->tree, sequence_cb); } } @@ -1151,14 +1151,14 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S { ReportList *reports = CTX_wm_reports(C); // XXX... - if (mval[1]>te->ys && mval[1]ys+UI_UNIT_Y) { - int scenelevel=0, objectlevel=0, idlevel=0, datalevel=0; - TreeStoreElem *tselem= TREESTORE(te); + if (mval[1] > te->ys && mval[1] < te->ys + UI_UNIT_Y) { + int scenelevel = 0, objectlevel = 0, idlevel = 0, datalevel = 0; + TreeStoreElem *tselem = TREESTORE(te); /* select object that's clicked on and popup context menu */ if (!(tselem->flag & TSE_SELECTED)) { - if ( outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) + if (outliner_has_one_flag(soops, &soops->tree, TSE_SELECTED, 1) ) outliner_set_flag(soops, &soops->tree, TSE_SELECTED, 0); tselem->flag |= TSE_SELECTED; @@ -1177,16 +1177,16 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S WM_operator_name_call(C, "OUTLINER_OT_object_operation", WM_OP_INVOKE_REGION_WIN, NULL); } else if (idlevel) { - if (idlevel==-1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); + if (idlevel == -1 || datalevel) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { - if (idlevel==ID_GR) + if (idlevel == ID_GR) WM_operator_name_call(C, "OUTLINER_OT_group_operation", WM_OP_INVOKE_REGION_WIN, NULL); else WM_operator_name_call(C, "OUTLINER_OT_id_operation", WM_OP_INVOKE_REGION_WIN, NULL); } } else if (datalevel) { - if (datalevel==-1) BKE_report(reports, RPT_WARNING, "Mixed selection"); + if (datalevel == -1) BKE_report(reports, RPT_WARNING, "Mixed selection"); else { if (datalevel == TSE_ANIM_DATA) WM_operator_name_call(C, "OUTLINER_OT_animdata_operation", WM_OP_INVOKE_REGION_WIN, NULL); @@ -1202,7 +1202,7 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S return 1; } - for (te= te->subtree.first; te; te= te->next) { + for (te = te->subtree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, mval)) return 1; } @@ -1212,15 +1212,15 @@ static int do_outliner_operation_event(bContext *C, Scene *scene, ARegion *ar, S static int outliner_operation(bContext *C, wmOperator *UNUSED(op), wmEvent *event) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); TreeElement *te; float fmval[2]; - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval+1); + UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], fmval, fmval + 1); - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (do_outliner_operation_event(C, scene, ar, soops, te, event, fmval)) break; } diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 026132e1f16..8a31305d65e 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -82,50 +82,50 @@ /* ********************************************************* */ /* Defines */ -#define TS_CHUNK 128 +#define TS_CHUNK 128 /* ********************************************************* */ /* Persistent Data */ static void outliner_storage_cleanup(SpaceOops *soops) { - TreeStore *ts= soops->treestore; + TreeStore *ts = soops->treestore; if (ts) { TreeStoreElem *tselem; - int a, unused= 0; + int a, unused = 0; /* each element used once, for ID blocks with more users to have each a treestore */ - for (a=0, tselem= ts->data; ausedelem; a++, tselem++) tselem->used= 0; + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) tselem->used = 0; /* cleanup only after reading file or undo step, and always for * RNA datablocks view in order to save memory */ if (soops->storeflag & SO_TREESTORE_CLEANUP) { - for (a=0, tselem= ts->data; ausedelem; a++, tselem++) { - if (tselem->id==NULL) unused++; + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) { + if (tselem->id == NULL) unused++; } if (unused) { if (ts->usedelem == unused) { MEM_freeN(ts->data); - ts->data= NULL; - ts->usedelem= ts->totelem= 0; + ts->data = NULL; + ts->usedelem = ts->totelem = 0; } else { TreeStoreElem *tsnewar, *tsnew; - tsnew=tsnewar= MEM_mallocN((ts->usedelem-unused)*sizeof(TreeStoreElem), "new tselem"); - for (a=0, tselem= ts->data; ausedelem; a++, tselem++) { + tsnew = tsnewar = MEM_mallocN((ts->usedelem - unused) * sizeof(TreeStoreElem), "new tselem"); + for (a = 0, tselem = ts->data; a < ts->usedelem; a++, tselem++) { if (tselem->id) { - *tsnew= *tselem; + *tsnew = *tselem; tsnew++; } } MEM_freeN(ts->data); - ts->data= tsnewar; - ts->usedelem-= unused; - ts->totelem= ts->usedelem; + ts->data = tsnewar; + ts->usedelem -= unused; + ts->totelem = ts->usedelem; } } } @@ -139,45 +139,45 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty int a; /* case 1; no TreeStore */ - if (soops->treestore==NULL) { - soops->treestore= MEM_callocN(sizeof(TreeStore), "treestore"); + if (soops->treestore == NULL) { + soops->treestore = MEM_callocN(sizeof(TreeStore), "treestore"); } - ts= soops->treestore; + ts = soops->treestore; /* check if 'te' is in treestore */ - tselem= ts->data; - for (a=0; ausedelem; a++, tselem++) { - if (tselem->id==id && tselem->used==0) { - if ((type==0 && tselem->type==0) ||(tselem->type==type && tselem->nr==nr)) { - te->store_index= a; - tselem->used= 1; + tselem = ts->data; + for (a = 0; a < ts->usedelem; a++, tselem++) { + if (tselem->id == id && tselem->used == 0) { + if ((type == 0 && tselem->type == 0) || (tselem->type == type && tselem->nr == nr)) { + te->store_index = a; + tselem->used = 1; return; } } } /* add 1 element to treestore */ - if (ts->usedelem==ts->totelem) { + if (ts->usedelem == ts->totelem) { TreeStoreElem *tsnew; - tsnew= MEM_mallocN((ts->totelem+TS_CHUNK)*sizeof(TreeStoreElem), "treestore data"); + tsnew = MEM_mallocN((ts->totelem + TS_CHUNK) * sizeof(TreeStoreElem), "treestore data"); if (ts->data) { - memcpy(tsnew, ts->data, ts->totelem*sizeof(TreeStoreElem)); + memcpy(tsnew, ts->data, ts->totelem * sizeof(TreeStoreElem)); MEM_freeN(ts->data); } - ts->data= tsnew; - ts->totelem+= TS_CHUNK; + ts->data = tsnew; + ts->totelem += TS_CHUNK; } - tselem= ts->data+ts->usedelem; + tselem = ts->data + ts->usedelem; - tselem->type= type; - if (type) tselem->nr= nr; // we're picky! :) - else tselem->nr= 0; - tselem->id= id; + tselem->type = type; + if (type) tselem->nr = nr; // we're picky! :) + else tselem->nr = 0; + tselem->id = id; tselem->used = 0; - tselem->flag= TSE_CLOSED; - te->store_index= ts->usedelem; + tselem->flag = TSE_CLOSED; + te->store_index = ts->usedelem; ts->usedelem++; } @@ -188,7 +188,7 @@ static void check_persistent(SpaceOops *soops, TreeElement *te, ID *id, short ty void outliner_free_tree(ListBase *lb) { while (lb->first) { - TreeElement *te= lb->first; + TreeElement *te = lb->first; outliner_free_tree(&te->subtree); BLI_remlink(lb, te); @@ -207,12 +207,12 @@ void outliner_cleanup_tree(SpaceOops *soops) /* Find ith item from the treestore */ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) { - TreeElement *te= lb->first, *tes; + TreeElement *te = lb->first, *tes; while (te) { - if (te->store_index==store_index) return te; - tes= outliner_find_tree_element(&te->subtree, store_index); + if (te->store_index == store_index) return te; + tes = outliner_find_tree_element(&te->subtree, store_index); if (tes) return tes; - te= te->next; + te = te->next; } return NULL; } @@ -220,17 +220,17 @@ static TreeElement *outliner_find_tree_element(ListBase *lb, int store_index) /* tse is not in the treestore, we use its contents to find a match */ TreeElement *outliner_find_tse(SpaceOops *soops, TreeStoreElem *tse) { - TreeStore *ts= soops->treestore; + TreeStore *ts = soops->treestore; TreeStoreElem *tselem; int a; - if (tse->id==NULL) return NULL; + if (tse->id == NULL) return NULL; /* check if 'tse' is in treestore */ - tselem= ts->data; - for (a=0; ausedelem; a++, tselem++) { - if ((tse->type==0 && tselem->type==0) || (tselem->type==tse->type && tselem->nr==tse->nr)) { - if (tselem->id==tse->id) { + tselem = ts->data; + for (a = 0; a < ts->usedelem; a++, tselem++) { + if ((tse->type == 0 && tselem->type == 0) || (tselem->type == tse->type && tselem->nr == tse->nr)) { + if (tselem->id == tse->id) { break; } } @@ -247,13 +247,13 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) TreeElement *te, *tes; TreeStoreElem *tselem; - for (te= lb->first; te; te= te->next) { - tselem= TREESTORE(te); - if (tselem->type==0) { - if (tselem->id==id) return te; + for (te = lb->first; te; te = te->next) { + tselem = TREESTORE(te); + if (tselem->type == 0) { + if (tselem->id == id) return te; /* only deeper on scene or object */ - if ( te->idcode==ID_OB || te->idcode==ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode==ID_GR)) { - tes= outliner_find_id(soops, &te->subtree, id); + if (te->idcode == ID_OB || te->idcode == ID_SCE || (soops->outlinevis == SO_GROUPS && te->idcode == ID_GR)) { + tes = outliner_find_id(soops, &te->subtree, id); if (tes) return tes; } } @@ -265,12 +265,12 @@ TreeElement *outliner_find_id(SpaceOops *soops, ListBase *lb, ID *id) ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) { TreeStoreElem *tselem; - te= te->parent; + te = te->parent; while (te) { - tselem= TREESTORE(te); - if (tselem->type==0 && te->idcode==idcode) return tselem->id; - te= te->parent; + tselem = TREESTORE(te); + if (tselem->type == 0 && te->idcode == idcode) return tselem->id; + te = te->parent; } return NULL; } @@ -280,28 +280,28 @@ ID *outliner_search_back(SpaceOops *soops, TreeElement *te, short idcode) /* Prototype, see functions below */ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index); + TreeElement *parent, short type, short index); /* -------------------------------------------------------- */ /* special handling of hierarchical non-lib data */ static void outliner_add_bone(SpaceOops *soops, ListBase *lb, ID *id, Bone *curBone, - TreeElement *parent, int *a) + TreeElement *parent, int *a) { - TreeElement *te= outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); + TreeElement *te = outliner_add_element(soops, lb, id, parent, TSE_BONE, *a); (*a)++; - te->name= curBone->name; - te->directdata= curBone; + te->name = curBone->name; + te->directdata = curBone; - for (curBone= curBone->childbase.first; curBone; curBone=curBone->next) { + for (curBone = curBone->childbase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, a); } } /* -------------------------------------------------------- */ -#define LOG2I(x) (int)(log(x)/M_LN2) +#define LOG2I(x) (int)(log(x) / M_LN2) static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, SceneRenderLayer *srl) { @@ -311,82 +311,82 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc /* log stuff is to convert bitflags (powers of 2) to small integers, * in order to not overflow short tselem->nr */ - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); - te->name= "Combined"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_COMBINED)); + te->name = "Combined"; + te->directdata = &srl->passflag; /* save cpu cycles, but we add the first to invoke an open/close triangle */ tselem = TREESTORE(tenla); if (tselem->flag & TSE_CLOSED) return; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); - te->name= "Z"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); - te->name= "Vector"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); - te->name= "Normal"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); - te->name= "UV"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); - te->name= "Mist"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); - te->name= "Index Object"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); - te->name= "Index Material"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_Z)); + te->name = "Z"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); - te->name= "Color"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); - te->name= "Diffuse"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); - te->name= "Specular"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); - te->name= "Shadow"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); - te->name= "AO"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); - te->name= "Reflection"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); - te->name= "Refraction"; - te->directdata= &srl->passflag; - - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); - te->name= "Indirect"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_VECTOR)); + te->name = "Vector"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); - te->name= "Environment"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_NORMAL)); + te->name = "Normal"; + te->directdata = &srl->passflag; - te= outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); - te->name= "Emit"; - te->directdata= &srl->passflag; + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_UV)); + te->name = "UV"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_MIST)); + te->name = "Mist"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXOB)); + te->name = "Index Object"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDEXMA)); + te->name = "Index Material"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_RGBA)); + te->name = "Color"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_DIFFUSE)); + te->name = "Diffuse"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SPEC)); + te->name = "Specular"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_SHADOW)); + te->name = "Shadow"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_AO)); + te->name = "AO"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFLECT)); + te->name = "Reflection"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_REFRACT)); + te->name = "Refraction"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_INDIRECT)); + te->name = "Indirect"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_ENVIRONMENT)); + te->name = "Environment"; + te->directdata = &srl->passflag; + + te = outliner_add_element(soops, &tenla->subtree, id, tenla, TSE_R_PASS, LOG2I(SCE_PASS_EMIT)); + te->name = "Emit"; + te->directdata = &srl->passflag; } #undef LOG2I @@ -394,14 +394,14 @@ static void outliner_add_passes(SpaceOops *soops, TreeElement *tenla, ID *id, Sc static void outliner_add_scene_contents(SpaceOops *soops, ListBase *lb, Scene *sce, TreeElement *te) { SceneRenderLayer *srl; - TreeElement *tenla= outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, lb, sce, te, TSE_R_LAYER_BASE, 0); int a; - tenla->name= "RenderLayers"; - for (a=0, srl= sce->r.layers.first; srl; srl= srl->next, a++) { - TreeElement *tenlay= outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); - tenlay->name= srl->name; - tenlay->directdata= &srl->passflag; + tenla->name = "RenderLayers"; + for (a = 0, srl = sce->r.layers.first; srl; srl = srl->next, a++) { + TreeElement *tenlay = outliner_add_element(soops, &tenla->subtree, sce, te, TSE_R_LAYER, a); + tenlay->name = srl->name; + tenlay->directdata = &srl->passflag; if (srl->light_override) outliner_add_element(soops, &tenlay->subtree, srl->light_override, tenlay, TSE_LINKED_LAMP, 0); @@ -428,66 +428,66 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree outliner_add_element(soops, &te->subtree, ob->poselib, te, 0, 0); // XXX FIXME.. add a special type for this - if (ob->proxy && ob->id.lib==NULL) + if (ob->proxy && ob->id.lib == NULL) outliner_add_element(soops, &te->subtree, ob->proxy, te, TSE_PROXY, 0); outliner_add_element(soops, &te->subtree, ob->data, te, 0, 0); if (ob->pose) { - bArmature *arm= ob->data; + bArmature *arm = ob->data; bPoseChannel *pchan; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSE_BASE, 0); - tenla->name= "Pose"; + tenla->name = "Pose"; /* channels undefined in editmode, but we want the 'tenla' pose icon itself */ if ((arm->edbo == NULL) && (ob->mode & OB_MODE_POSE)) { - int a= 0, const_index= 1000; /* ensure unique id for bone constraints */ + int a = 0, const_index = 1000; /* ensure unique id for bone constraints */ - for (pchan= ob->pose->chanbase.first; pchan; pchan= pchan->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); - ten->name= pchan->name; - ten->directdata= pchan; - pchan->temp= (void *)ten; + for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSE_CHANNEL, a); + ten->name = pchan->name; + ten->directdata = pchan; + pchan->temp = (void *)ten; if (pchan->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten1; - TreeElement *tenla1= outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); + TreeElement *tenla1 = outliner_add_element(soops, &ten->subtree, ob, ten, TSE_CONSTRAINT_BASE, 0); //char *str; - tenla1->name= "Constraints"; - for (con= pchan->constraints.first; con; con= con->next, const_index++) { - ten1= outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); + tenla1->name = "Constraints"; + for (con = pchan->constraints.first; con; con = con->next, const_index++) { + ten1 = outliner_add_element(soops, &tenla1->subtree, ob, tenla1, TSE_CONSTRAINT, const_index); #if 0 /* disabled as it needs to be reworked for recoded constraints system */ - target= get_constraint_target(con, &str); - if (str && str[0]) ten1->name= str; - else if (target) ten1->name= target->id.name+2; - else ten1->name= con->name; + target = get_constraint_target(con, &str); + if (str && str[0]) ten1->name = str; + else if (target) ten1->name = target->id.name + 2; + else ten1->name = con->name; #endif - ten1->name= con->name; - ten1->directdata= con; + ten1->name = con->name; + ten1->directdata = con; /* possible add all other types links? */ } } } /* make hierarchy */ - ten= tenla->subtree.first; + ten = tenla->subtree.first; while (ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - if (tselem->type==TSE_POSE_CHANNEL) { - pchan= (bPoseChannel *)ten->directdata; + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + if (tselem->type == TSE_POSE_CHANNEL) { + pchan = (bPoseChannel *)ten->directdata; if (pchan->parent) { BLI_remlink(&tenla->subtree, ten); - par= (TreeElement *)pchan->parent->temp; + par = (TreeElement *)pchan->parent->temp; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } } - ten= nten; + ten = nten; } } @@ -495,39 +495,39 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (ob->pose->agroups.first) { bActionGroup *agrp; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); - int a= 0; + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_POSEGRP_BASE, 0); + int a = 0; - tenla->name= "Bone Groups"; - for (agrp=ob->pose->agroups.first; agrp; agrp=agrp->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); - ten->name= agrp->name; - ten->directdata= agrp; + tenla->name = "Bone Groups"; + for (agrp = ob->pose->agroups.first; agrp; agrp = agrp->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_POSEGRP, a); + ten->name = agrp->name; + ten->directdata = agrp; } } } - for (a=0; atotcol; a++) + for (a = 0; a < ob->totcol; a++) outliner_add_element(soops, &te->subtree, ob->mat[a], te, 0, a); if (ob->constraints.first) { //Object *target; bConstraint *con; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_CONSTRAINT_BASE, 0); //char *str; - tenla->name= "Constraints"; - for (con=ob->constraints.first, a=0; con; con= con->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); + tenla->name = "Constraints"; + for (con = ob->constraints.first, a = 0; con; con = con->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_CONSTRAINT, a); #if 0 /* disabled due to constraints system targets recode... code here needs review */ - target= get_constraint_target(con, &str); - if (str && str[0]) ten->name= str; - else if (target) ten->name= target->id.name+2; - else ten->name= con->name; + target = get_constraint_target(con, &str); + if (str && str[0]) ten->name = str; + else if (target) ten->name = target->id.name + 2; + else ten->name = con->name; #endif - ten->name= con->name; - ten->directdata= con; + ten->name = con->name; + ten->directdata = con; /* possible add all other types links? */ } } @@ -538,30 +538,30 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree int index; temod->name = "Modifiers"; - for (index=0, md=ob->modifiers.first; md; index++, md=md->next) { + for (index = 0, md = ob->modifiers.first; md; index++, md = md->next) { TreeElement *te = outliner_add_element(soops, &temod->subtree, ob, temod, TSE_MODIFIER, index); - te->name= md->name; + te->name = md->name; te->directdata = md; - if (md->type==eModifierType_Lattice) { - outliner_add_element(soops, &te->subtree, ((LatticeModifierData*) md)->object, te, TSE_LINKED_OB, 0); + if (md->type == eModifierType_Lattice) { + outliner_add_element(soops, &te->subtree, ((LatticeModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Curve) { - outliner_add_element(soops, &te->subtree, ((CurveModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Curve) { + outliner_add_element(soops, &te->subtree, ((CurveModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Armature) { - outliner_add_element(soops, &te->subtree, ((ArmatureModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Armature) { + outliner_add_element(soops, &te->subtree, ((ArmatureModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_Hook) { - outliner_add_element(soops, &te->subtree, ((HookModifierData*) md)->object, te, TSE_LINKED_OB, 0); + else if (md->type == eModifierType_Hook) { + outliner_add_element(soops, &te->subtree, ((HookModifierData *) md)->object, te, TSE_LINKED_OB, 0); } - else if (md->type==eModifierType_ParticleSystem) { + else if (md->type == eModifierType_ParticleSystem) { TreeElement *ten; - ParticleSystem *psys= ((ParticleSystemModifierData*) md)->psys; + ParticleSystem *psys = ((ParticleSystemModifierData *) md)->psys; ten = outliner_add_element(soops, &te->subtree, ob, te, TSE_LINKED_PSYS, 0); ten->directdata = psys; - ten->name = psys->part->id.name+2; + ten->name = psys->part->id.name + 2; } } } @@ -570,13 +570,13 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree if (ob->defbase.first) { bDeformGroup *defgroup; TreeElement *ten; - TreeElement *tenla= outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, ob, te, TSE_DEFGROUP_BASE, 0); - tenla->name= "Vertex Groups"; - for (defgroup=ob->defbase.first, a=0; defgroup; defgroup=defgroup->next, a++) { - ten= outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); - ten->name= defgroup->name; - ten->directdata= defgroup; + tenla->name = "Vertex Groups"; + for (defgroup = ob->defbase.first, a = 0; defgroup; defgroup = defgroup->next, a++) { + ten = outliner_add_element(soops, &tenla->subtree, ob, tenla, TSE_DEFGROUP, a); + ten->name = defgroup->name; + ten->directdata = defgroup; } } @@ -589,147 +589,147 @@ static void outliner_add_object_contents(SpaceOops *soops, TreeElement *te, Tree static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStoreElem *tselem, ID *id) { /* tuck pointer back in object, to construct hierarchy */ - if (GS(id->name)==ID_OB) id->newid= (ID *)te; + if (GS(id->name) == ID_OB) id->newid = (ID *)te; /* expand specific data always */ switch (GS(id->name)) { case ID_LI: { - te->name= ((Library *)id)->name; + te->name = ((Library *)id)->name; } - break; + break; case ID_SCE: { outliner_add_scene_contents(soops, &te->subtree, (Scene *)id, te); } - break; + break; case ID_OB: { outliner_add_object_contents(soops, te, tselem, (Object *)id); } - break; + break; case ID_ME: { - Mesh *me= (Mesh *)id; + Mesh *me = (Mesh *)id; int a; if (me->adt) outliner_add_element(soops, &te->subtree, me, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, &te->subtree, me->key, te, 0, 0); - for (a=0; atotcol; a++) + for (a = 0; a < me->totcol; a++) outliner_add_element(soops, &te->subtree, me->mat[a], te, 0, a); /* could do tfaces with image links, but the images are not grouped nicely. * would require going over all tfaces, sort images in use. etc... */ } - break; + break; case ID_CU: { - Curve *cu= (Curve *)id; + Curve *cu = (Curve *)id; int a; if (cu->adt) outliner_add_element(soops, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - for (a=0; atotcol; a++) + for (a = 0; a < cu->totcol; a++) outliner_add_element(soops, &te->subtree, cu->mat[a], te, 0, a); } - break; + break; case ID_MB: { - MetaBall *mb= (MetaBall *)id; + MetaBall *mb = (MetaBall *)id; int a; if (mb->adt) outliner_add_element(soops, &te->subtree, mb, te, TSE_ANIM_DATA, 0); - for (a=0; atotcol; a++) + for (a = 0; a < mb->totcol; a++) outliner_add_element(soops, &te->subtree, mb->mat[a], te, 0, a); } - break; + break; case ID_MA: { - Material *ma= (Material *)id; + Material *ma = (Material *)id; int a; if (ma->adt) outliner_add_element(soops, &te->subtree, ma, te, TSE_ANIM_DATA, 0); - for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, ma->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_TE: { - Tex *tex= (Tex *)id; + Tex *tex = (Tex *)id; if (tex->adt) outliner_add_element(soops, &te->subtree, tex, te, TSE_ANIM_DATA, 0); outliner_add_element(soops, &te->subtree, tex->ima, te, 0, 0); } - break; + break; case ID_CA: { - Camera *ca= (Camera *)id; + Camera *ca = (Camera *)id; if (ca->adt) outliner_add_element(soops, &te->subtree, ca, te, TSE_ANIM_DATA, 0); } - break; + break; case ID_LA: { - Lamp *la= (Lamp *)id; + Lamp *la = (Lamp *)id; int a; if (la->adt) outliner_add_element(soops, &te->subtree, la, te, TSE_ANIM_DATA, 0); - for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, la->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_SPK: - { - Speaker *spk= (Speaker *)id; + { + Speaker *spk = (Speaker *)id; - if (spk->adt) - outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); - } - break; + if (spk->adt) + outliner_add_element(soops, &te->subtree, spk, te, TSE_ANIM_DATA, 0); + } + break; case ID_WO: { - World *wrld= (World *)id; + World *wrld = (World *)id; int a; if (wrld->adt) outliner_add_element(soops, &te->subtree, wrld, te, TSE_ANIM_DATA, 0); - for (a=0; amtex[a]) outliner_add_element(soops, &te->subtree, wrld->mtex[a]->tex, te, 0, a); } } - break; + break; case ID_KE: { - Key *key= (Key *)id; + Key *key = (Key *)id; if (key->adt) outliner_add_element(soops, &te->subtree, key, te, TSE_ANIM_DATA, 0); } - break; + break; case ID_AC: { // XXX do we want to be exposing the F-Curves here? //bAction *act= (bAction *)id; } - break; + break; case ID_AR: { - bArmature *arm= (bArmature *)id; - int a= 0; + bArmature *arm = (bArmature *)id; + int a = 0; if (arm->adt) outliner_add_element(soops, &te->subtree, arm, te, TSE_ANIM_DATA, 0); @@ -738,115 +738,115 @@ static void outliner_add_id_contents(SpaceOops *soops, TreeElement *te, TreeStor EditBone *ebone; TreeElement *ten; - for (ebone = arm->edbo->first; ebone; ebone=ebone->next, a++) { - ten= outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); - ten->directdata= ebone; - ten->name= ebone->name; - ebone->temp= ten; + for (ebone = arm->edbo->first; ebone; ebone = ebone->next, a++) { + ten = outliner_add_element(soops, &te->subtree, id, te, TSE_EBONE, a); + ten->directdata = ebone; + ten->name = ebone->name; + ebone->temp = ten; } /* make hierarchy */ - ten= arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; + ten = arm->edbo->first ? ((EditBone *)arm->edbo->first)->temp : NULL; while (ten) { - TreeElement *nten= ten->next, *par; - ebone= (EditBone *)ten->directdata; + TreeElement *nten = ten->next, *par; + ebone = (EditBone *)ten->directdata; if (ebone->parent) { BLI_remlink(&te->subtree, ten); - par= ebone->parent->temp; + par = ebone->parent->temp; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } - ten= nten; + ten = nten; } } else { /* do not extend Armature when we have posemode */ - tselem= TREESTORE(te->parent); - if ( GS(tselem->id->name)==ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE); + tselem = TREESTORE(te->parent); + if (GS(tselem->id->name) == ID_OB && ((Object *)tselem->id)->mode & OB_MODE_POSE) ; else { Bone *curBone; - for (curBone=arm->bonebase.first; curBone; curBone=curBone->next) { + for (curBone = arm->bonebase.first; curBone; curBone = curBone->next) { outliner_add_bone(soops, &te->subtree, id, curBone, te, &a); } } } } - break; + break; } } // TODO: this function needs to be split up! It's getting a bit too large... static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *idv, - TreeElement *parent, short type, short index) + TreeElement *parent, short type, short index) { TreeElement *te; TreeStoreElem *tselem; - ID *id= idv; + ID *id = idv; int a = 0; if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - id= ((PointerRNA*)idv)->id.data; - if (!id) id= ((PointerRNA*)idv)->data; + id = ((PointerRNA *)idv)->id.data; + if (!id) id = ((PointerRNA *)idv)->data; } - if (id==NULL) return NULL; + if (id == NULL) return NULL; - te= MEM_callocN(sizeof(TreeElement), "tree elem"); + te = MEM_callocN(sizeof(TreeElement), "tree elem"); /* add to the visual tree */ BLI_addtail(lb, te); /* add to the storage */ check_persistent(soops, te, id, type, index); - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* if we are searching for something expand to see child elements */ if (SEARCHING_OUTLINER(soops)) tselem->flag |= TSE_CHILDSEARCH; - te->parent= parent; - te->index= index; // for data arays - if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)); - else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)); - else if (type==TSE_ANIM_DATA); + te->parent = parent; + te->index = index; // for data arays + if (ELEM3(type, TSE_SEQUENCE, TSE_SEQ_STRIP, TSE_SEQUENCE_DUP)) ; + else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) ; + else if (type == TSE_ANIM_DATA) ; else { - te->name= id->name+2; // default, can be overridden by Library or non-ID data - te->idcode= GS(id->name); + te->name = id->name + 2; // default, can be overridden by Library or non-ID data + te->idcode = GS(id->name); } - if (type==0) { + if (type == 0) { /* ID datablock */ outliner_add_id_contents(soops, te, tselem, id); } - else if (type==TSE_ANIM_DATA) { + else if (type == TSE_ANIM_DATA) { IdAdtTemplate *iat = (IdAdtTemplate *)idv; - AnimData *adt= (AnimData *)iat->adt; + AnimData *adt = (AnimData *)iat->adt; /* this element's info */ - te->name= "Animation"; - te->directdata= adt; + te->name = "Animation"; + te->directdata = adt; /* Action */ outliner_add_element(soops, &te->subtree, adt->action, te, 0, 0); /* Drivers */ if (adt->drivers.first) { - TreeElement *ted= outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); - ID *lastadded= NULL; + TreeElement *ted = outliner_add_element(soops, &te->subtree, adt, te, TSE_DRIVER_BASE, 0); + ID *lastadded = NULL; FCurve *fcu; - ted->name= "Drivers"; + ted->name = "Drivers"; - for (fcu= adt->drivers.first; fcu; fcu= fcu->next) { + for (fcu = adt->drivers.first; fcu; fcu = fcu->next) { if (fcu->driver && fcu->driver->variables.first) { - ChannelDriver *driver= fcu->driver; + ChannelDriver *driver = fcu->driver; DriverVar *dvar; - for (dvar= driver->variables.first; dvar; dvar= dvar->next) { + for (dvar = driver->variables.first; dvar; dvar = dvar->next) { /* loop over all targets used here */ DRIVER_TARGETS_USED_LOOPER(dvar) { if (lastadded != dtar->id) { // XXX this lastadded check is rather lame, and also fails quite badly... outliner_add_element(soops, &ted->subtree, dtar->id, ted, TSE_LINKED_OB, 0); - lastadded= dtar->id; + lastadded = dtar->id; } } DRIVER_TARGETS_LOOPER_END @@ -857,29 +857,29 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* NLA Data */ if (adt->nla_tracks.first) { - TreeElement *tenla= outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); + TreeElement *tenla = outliner_add_element(soops, &te->subtree, adt, te, TSE_NLA, 0); NlaTrack *nlt; - int a= 0; + int a = 0; - tenla->name= "NLA Tracks"; + tenla->name = "NLA Tracks"; - for (nlt= adt->nla_tracks.first; nlt; nlt= nlt->next) { - TreeElement *tenlt= outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); + for (nlt = adt->nla_tracks.first; nlt; nlt = nlt->next) { + TreeElement *tenlt = outliner_add_element(soops, &tenla->subtree, nlt, tenla, TSE_NLA_TRACK, a); NlaStrip *strip; TreeElement *ten; - int b= 0; + int b = 0; - tenlt->name= nlt->name; + tenlt->name = nlt->name; - for (strip=nlt->strips.first; strip; strip=strip->next, b++) { - ten= outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); - if (ten) ten->directdata= strip; + for (strip = nlt->strips.first; strip; strip = strip->next, b++) { + ten = outliner_add_element(soops, &tenlt->subtree, strip->act, tenlt, TSE_NLA_ACTION, b); + if (ten) ten->directdata = strip; } } } } - else if (type==TSE_SEQUENCE) { - Sequence *seq= (Sequence*) idv; + else if (type == TSE_SEQUENCE) { + Sequence *seq = (Sequence *) idv; Sequence *p; /* @@ -887,56 +887,56 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i * only check te->idcode if te->type is equal to zero, * so this is "safe". */ - te->idcode= seq->type; - te->directdata= seq; + te->idcode = seq->type; + te->directdata = seq; - if (seq->type<7) { + if (seq->type < 7) { /* * This work like the sequence. * If the sequence have a name (not default name) * show it, in other case put the filename. */ if (strcmp(seq->name, "SQ")) - te->name= seq->name; + te->name = seq->name; else { if ((seq->strip) && (seq->strip->stripdata)) - te->name= seq->strip->stripdata->name; + te->name = seq->strip->stripdata->name; else - te->name= "SQ None"; + te->name = "SQ None"; } - if (seq->type==SEQ_META) { - te->name= "Meta Strip"; - p= seq->seqbase.first; + if (seq->type == SEQ_META) { + te->name = "Meta Strip"; + p = seq->seqbase.first; while (p) { - outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; + outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + p = p->next; } } else - outliner_add_element(soops, &te->subtree, (void*)seq->strip, te, TSE_SEQ_STRIP, index); + outliner_add_element(soops, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index); } else - te->name= "Effect"; + te->name = "Effect"; } - else if (type==TSE_SEQ_STRIP) { - Strip *strip= (Strip *)idv; + else if (type == TSE_SEQ_STRIP) { + Strip *strip = (Strip *)idv; if (strip->dir) - te->name= strip->dir; + te->name = strip->dir; else - te->name= "Strip None"; - te->directdata= strip; + te->name = "Strip None"; + te->directdata = strip; } - else if (type==TSE_SEQUENCE_DUP) { - Sequence *seq= (Sequence*)idv; + else if (type == TSE_SEQUENCE_DUP) { + Sequence *seq = (Sequence *)idv; - te->idcode= seq->type; - te->directdata= seq; - te->name= seq->strip->stripdata->name; + te->idcode = seq->type; + te->directdata = seq; + te->name = seq->strip->stripdata->name; } else if (ELEM3(type, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, TSE_RNA_ARRAY_ELEM)) { - PointerRNA pptr, propptr, *ptr= (PointerRNA*)idv; + PointerRNA pptr, propptr, *ptr = (PointerRNA *)idv; PropertyRNA *prop, *iterprop; PropertyType proptype; int a, tot; @@ -944,22 +944,22 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i /* we do lazy build, for speed and to avoid infinite recusion */ if (ptr->data == NULL) { - te->name= "(empty)"; + te->name = "(empty)"; } else if (type == TSE_RNA_STRUCT) { /* struct */ - te->name= RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); + te->name = RNA_struct_name_get_alloc(ptr, NULL, 0, NULL); if (te->name) te->flag |= TE_FREE_NAME; else - te->name= RNA_struct_ui_name(ptr->type); + te->name = RNA_struct_ui_name(ptr->type); /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; - iterprop= RNA_struct_iterator_property(ptr->type); - tot= RNA_property_collection_length(ptr, iterprop); + iterprop = RNA_struct_iterator_property(ptr->type); + tot = RNA_property_collection_length(ptr, iterprop); /* auto open these cases */ if (!parent || (RNA_property_type(parent->directdata)) == PROP_POINTER) @@ -967,57 +967,57 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i tselem->flag &= ~TSE_CLOSED; if (TSELEM_OPEN(tselem, soops)) { - for (a=0; asubtree, (void*)ptr, te, TSE_RNA_PROPERTY, a); + for (a = 0; a < tot; a++) + outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_PROPERTY, a); } else if (tot) te->flag |= TE_LAZY_CLOSED; - te->rnaptr= *ptr; + te->rnaptr = *ptr; } else if (type == TSE_RNA_PROPERTY) { /* property */ - iterprop= RNA_struct_iterator_property(ptr->type); + iterprop = RNA_struct_iterator_property(ptr->type); RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); - prop= propptr.data; - proptype= RNA_property_type(prop); + prop = propptr.data; + proptype = RNA_property_type(prop); - te->name= RNA_property_ui_name(prop); - te->directdata= prop; - te->rnaptr= *ptr; + te->name = RNA_property_ui_name(prop); + te->directdata = prop; + te->rnaptr = *ptr; /* If searching don't expand RNA entries */ - if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name)==0) tselem->flag &= ~TSE_CHILDSEARCH; + if (SEARCHING_OUTLINER(soops) && BLI_strcasecmp("RNA", te->name) == 0) tselem->flag &= ~TSE_CHILDSEARCH; if (proptype == PROP_POINTER) { - pptr= RNA_property_pointer_get(ptr, prop); + pptr = RNA_property_pointer_get(ptr, prop); if (pptr.data) { if (TSELEM_OPEN(tselem, soops)) - outliner_add_element(soops, &te->subtree, (void*)&pptr, te, TSE_RNA_STRUCT, -1); + outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, -1); else te->flag |= TE_LAZY_CLOSED; } } else if (proptype == PROP_COLLECTION) { - tot= RNA_property_collection_length(ptr, prop); + tot = RNA_property_collection_length(ptr, prop); if (TSELEM_OPEN(tselem, soops)) { - for (a=0; asubtree, (void*)&pptr, te, TSE_RNA_STRUCT, a); + outliner_add_element(soops, &te->subtree, (void *)&pptr, te, TSE_RNA_STRUCT, a); } } else if (tot) te->flag |= TE_LAZY_CLOSED; } else if (ELEM3(proptype, PROP_BOOLEAN, PROP_INT, PROP_FLOAT)) { - tot= RNA_property_array_length(ptr, prop); + tot = RNA_property_array_length(ptr, prop); if (TSELEM_OPEN(tselem, soops)) { - for (a=0; asubtree, (void*)ptr, te, TSE_RNA_ARRAY_ELEM, a); + for (a = 0; a < tot; a++) + outliner_add_element(soops, &te->subtree, (void *)ptr, te, TSE_RNA_ARRAY_ELEM, a); } else if (tot) te->flag |= TE_LAZY_CLOSED; @@ -1026,51 +1026,51 @@ static TreeElement *outliner_add_element(SpaceOops *soops, ListBase *lb, void *i else if (type == TSE_RNA_ARRAY_ELEM) { char c; - prop= parent->directdata; + prop = parent->directdata; - te->directdata= prop; - te->rnaptr= *ptr; - te->index= index; + te->directdata = prop; + te->rnaptr = *ptr; + te->index = index; - c= RNA_property_array_item_char(prop, index); + c = RNA_property_array_item_char(prop, index); - te->name= MEM_callocN(sizeof(char)*20, "OutlinerRNAArrayName"); + te->name = MEM_callocN(sizeof(char) * 20, "OutlinerRNAArrayName"); if (c) sprintf((char *)te->name, " %c", c); - else sprintf((char *)te->name, " %d", index+1); + else sprintf((char *)te->name, " %d", index + 1); te->flag |= TE_FREE_NAME; } } else if (type == TSE_KEYMAP) { - wmKeyMap *km= (wmKeyMap *)idv; + wmKeyMap *km = (wmKeyMap *)idv; wmKeyMapItem *kmi; char opname[OP_MAX_TYPENAME]; - te->directdata= idv; - te->name= km->idname; + te->directdata = idv; + te->name = km->idname; if (TSELEM_OPEN(tselem, soops)) { - a= 0; + a = 0; for (kmi = km->items.first; kmi; kmi = kmi->next, a++) { - const char *key= WM_key_event_string(kmi->type); + const char *key = WM_key_event_string(kmi->type); if (key[0]) { - wmOperatorType *ot= NULL; + wmOperatorType *ot = NULL; - if (kmi->propvalue); - else ot= WM_operatortype_find(kmi->idname, 0); + if (kmi->propvalue) ; + else ot = WM_operatortype_find(kmi->idname, 0); if (ot || kmi->propvalue) { - TreeElement *ten= outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); + TreeElement *ten = outliner_add_element(soops, &te->subtree, kmi, te, TSE_KEYMAP_ITEM, a); - ten->directdata= kmi; + ten->directdata = kmi; if (kmi->propvalue) { - ten->name= "Modal map, not yet"; + ten->name = "Modal map, not yet"; } else { WM_operator_py_idname(opname, ot->idname); - ten->name= BLI_strdup(opname); + ten->name = BLI_strdup(opname); ten->flag |= TE_FREE_NAME; } } @@ -1099,28 +1099,28 @@ static int need_add_seq_dup(Sequence *seq) * First check backward, if we found a duplicate * sequence before this, don't need it, just return. */ - p= seq->prev; + p = seq->prev; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->prev; + p = p->prev; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(2); - p= p->prev; + p = p->prev; } - p= seq->next; + p = seq->next; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) return(0); - p= p->next; + p = p->next; } return(1); } @@ -1130,16 +1130,16 @@ static void outliner_add_seq_dup(SpaceOops *soops, Sequence *seq, TreeElement *t /* TreeElement *ch; */ /* UNUSED */ Sequence *p; - p= seq; + p = seq; while (p) { if ((!p->strip) || (!p->strip->stripdata) || (!p->strip->stripdata->name)) { - p= p->next; + p = p->next; continue; } if (!strcmp(p->strip->stripdata->name, seq->strip->stripdata->name)) - /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void*)p, te, TSE_SEQUENCE, index); - p= p->next; + /* ch= */ /* UNUSED */ outliner_add_element(soops, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); + p = p->next; } } @@ -1156,22 +1156,22 @@ static void outliner_make_hierarchy(SpaceOops *soops, ListBase *lb) /* build hierarchy */ // XXX also, set extents here... - te= lb->first; + te = lb->first; while (te) { - ten= te->next; - tselem= TREESTORE(te); + ten = te->next; + tselem = TREESTORE(te); - if (tselem->type==0 && te->idcode==ID_OB) { - Object *ob= (Object *)tselem->id; + if (tselem->type == 0 && te->idcode == ID_OB) { + Object *ob = (Object *)tselem->id; if (ob->parent && ob->parent->id.newid) { BLI_remlink(lb, te); - tep= (TreeElement *)ob->parent->id.newid; + tep = (TreeElement *)ob->parent->id.newid; BLI_addtail(&tep->subtree, te); // set correct parent pointers - for (te=tep->subtree.first; te; te= te->next) te->parent= tep; + for (te = tep->subtree.first; te; te = te->next) te->parent = tep; } } - te= ten; + te = ten; } } @@ -1187,20 +1187,20 @@ typedef struct tTreeSort { /* alphabetical comparator */ static int treesort_alpha(const void *v1, const void *v2) { - const tTreeSort *x1= v1, *x2= v2; + const tTreeSort *x1 = v1, *x2 = v2; int comp; /* first put objects last (hierarchy) */ - comp= (x1->idcode==ID_OB); - if (x2->idcode==ID_OB) comp+=2; + comp = (x1->idcode == ID_OB); + if (x2->idcode == ID_OB) comp += 2; - if (comp==1) return 1; - else if (comp==2) return -1; - else if (comp==3) { - comp= strcmp(x1->name, x2->name); + if (comp == 1) return 1; + else if (comp == 2) return -1; + else if (comp == 3) { + comp = strcmp(x1->name, x2->name); - if ( comp>0 ) return 1; - else if ( comp<0) return -1; + if (comp > 0) return 1; + else if (comp < 0) return -1; return 0; } return 0; @@ -1210,23 +1210,23 @@ static int treesort_alpha(const void *v1, const void *v2) #if 0 static int treesort_obtype_alpha(const void *v1, const void *v2) { - const tTreeSort *x1= v1, *x2= v2; + const tTreeSort *x1 = v1, *x2 = v2; /* first put objects last (hierarchy) */ - if (x1->idcode==ID_OB && x2->idcode!=ID_OB) return 1; - else if (x2->idcode==ID_OB && x1->idcode!=ID_OB) return -1; + if (x1->idcode == ID_OB && x2->idcode != ID_OB) return 1; + else if (x2->idcode == ID_OB && x1->idcode != ID_OB) return -1; else { /* 2nd we check ob type */ - if (x1->idcode==ID_OB && x2->idcode==ID_OB) { + if (x1->idcode == ID_OB && x2->idcode == ID_OB) { if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return 1; else if ( ((Object *)x1->id)->type > ((Object *)x2->id)->type) return -1; else return 0; } else { - int comp= strcmp(x1->name, x2->name); + int comp = strcmp(x1->name, x2->name); - if ( comp>0 ) return 1; - else if ( comp<0) return -1; + if (comp > 0) return 1; + else if (comp < 0) return -1; return 0; } } @@ -1238,40 +1238,40 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) { TreeElement *te; TreeStoreElem *tselem; - int totelem=0; + int totelem = 0; - te= lb->last; - if (te==NULL) return; - tselem= TREESTORE(te); + te = lb->last; + if (te == NULL) return; + tselem = TREESTORE(te); /* sorting rules; only object lists or deformgroups */ - if ( (tselem->type==TSE_DEFGROUP) || (tselem->type==0 && te->idcode==ID_OB)) { + if ( (tselem->type == TSE_DEFGROUP) || (tselem->type == 0 && te->idcode == ID_OB)) { /* count first */ - for (te= lb->first; te; te= te->next) totelem++; + for (te = lb->first; te; te = te->next) totelem++; - if (totelem>1) { - tTreeSort *tear= MEM_mallocN(totelem*sizeof(tTreeSort), "tree sort array"); - tTreeSort *tp=tear; - int skip= 0; - - for (te= lb->first; te; te= te->next, tp++) { - tselem= TREESTORE(te); - tp->te= te; - tp->name= te->name; - tp->idcode= te->idcode; - if (tselem->type && tselem->type!=TSE_DEFGROUP) tp->idcode= 0; // don't sort this - tp->id= tselem->id; + if (totelem > 1) { + tTreeSort *tear = MEM_mallocN(totelem * sizeof(tTreeSort), "tree sort array"); + tTreeSort *tp = tear; + int skip = 0; + + for (te = lb->first; te; te = te->next, tp++) { + tselem = TREESTORE(te); + tp->te = te; + tp->name = te->name; + tp->idcode = te->idcode; + if (tselem->type && tselem->type != TSE_DEFGROUP) tp->idcode = 0; // don't sort this + tp->id = tselem->id; } /* keep beginning of list */ - for (tp= tear, skip=0; skipidcode) break; - if (skipfirst=lb->last= NULL; - tp= tear; + lb->first = lb->last = NULL; + tp = tear; while (totelem--) { BLI_addtail(lb, tp->te); tp++; @@ -1280,7 +1280,7 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) } } - for (te= lb->first; te; te= te->next) { + for (te = lb->first; te; te = te->next) { outliner_sort(soops, &te->subtree); } } @@ -1290,36 +1290,36 @@ static void outliner_sort(SpaceOops *soops, ListBase *lb) static int outliner_filter_has_name(TreeElement *te, const char *name, int flags) { #if 0 - int found= 0; + int found = 0; /* determine if match */ if (flags & SO_FIND_CASE_SENSITIVE) { if (flags & SO_FIND_COMPLETE) - found= strcmp(te->name, name) == 0; + found = strcmp(te->name, name) == 0; else - found= strstr(te->name, name) != NULL; + found = strstr(te->name, name) != NULL; } else { if (flags & SO_FIND_COMPLETE) - found= BLI_strcasecmp(te->name, name) == 0; + found = BLI_strcasecmp(te->name, name) == 0; else - found= BLI_strcasestr(te->name, name) != NULL; + found = BLI_strcasestr(te->name, name) != NULL; } #else - int fn_flag= 0; - int found= 0; + int fn_flag = 0; + int found = 0; if ((flags & SO_FIND_CASE_SENSITIVE) == 0) fn_flag |= FNM_CASEFOLD; if (flags & SO_FIND_COMPLETE) { - found= fnmatch(name, te->name, fn_flag)==0; + found = fnmatch(name, te->name, fn_flag) == 0; } else { char fn_name[sizeof(((struct SpaceOops *)NULL)->search_string) + 2]; BLI_snprintf(fn_name, sizeof(fn_name), "*%s*", name); - found= fnmatch(fn_name, te->name, fn_flag)==0; + found = fnmatch(fn_name, te->name, fn_flag) == 0; } return found; #endif @@ -1333,25 +1333,25 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) /* although we don't have any search string, we return TRUE * since the entire tree is ok then... */ - if (soops->search_string[0]==0) + if (soops->search_string[0] == 0) return 1; - for (te= lb->first; te; te= ten) { - ten= te->next; + for (te = lb->first; te; te = ten) { + ten = te->next; - if (0==outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { + if (0 == outliner_filter_has_name(te, soops->search_string, soops->search_flags)) { /* item isn't something we're looking for, but... - * - if the subtree is expanded, check if there are any matches that can be easily found + * - if the subtree is expanded, check if there are any matches that can be easily found * so that searching for "cu" in the default scene will still match the Cube * - otherwise, we can't see within the subtree and the item doesn't match, * so these can be safely ignored (i.e. the subtree can get freed) */ - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* flag as not a found item */ tselem->flag &= ~TSE_SEARCHMATCH; - if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree)==0) { + if ((!TSELEM_OPEN(tselem, soops)) || outliner_filter_tree(soops, &te->subtree) == 0) { outliner_free_tree(&te->subtree); BLI_remlink(lb, te); @@ -1360,7 +1360,7 @@ static int outliner_filter_tree(SpaceOops *soops, ListBase *lb) } } else { - tselem= TREESTORE(te); + tselem = TREESTORE(te); /* flag as a found item - we can then highlight it */ tselem->flag |= TSE_SEARCHMATCH; @@ -1383,14 +1383,14 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) { Base *base; Object *ob; - TreeElement *te=NULL, *ten; + TreeElement *te = NULL, *ten; TreeStoreElem *tselem; - int show_opened= (soops->treestore==NULL); /* on first view, we open scenes */ + int show_opened = (soops->treestore == NULL); /* on first view, we open scenes */ /* Are we looking for something - we want to tag parents to filter child matches * - NOT in datablocks view - searching all datablocks takes way too long to be useful * - this variable is only set once per tree build */ - if (soops->search_string[0]!=0 && soops->outlinevis!=SO_DATABLOCKS) + if (soops->search_string[0] != 0 && soops->outlinevis != SO_DATABLOCKS) soops->search_flags |= SO_SEARCH_RECURSIVE; else soops->search_flags &= ~SO_SEARCH_RECURSIVE; @@ -1402,64 +1402,64 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) outliner_storage_cleanup(soops); /* clear ob id.new flags */ - for (ob= mainvar->object.first; ob; ob= ob->id.next) ob->id.newid= NULL; + for (ob = mainvar->object.first; ob; ob = ob->id.next) ob->id.newid = NULL; /* options */ if (soops->outlinevis == SO_LIBRARIES) { Library *lib; - for (lib= mainvar->library.first; lib; lib= lib->id.next) { - ten= outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); - lib->id.newid= (ID *)ten; + for (lib = mainvar->library.first; lib; lib = lib->id.next) { + ten = outliner_add_element(soops, &soops->tree, lib, NULL, 0, 0); + lib->id.newid = (ID *)ten; } /* make hierarchy */ - ten= soops->tree.first; + ten = soops->tree.first; while (ten) { - TreeElement *nten= ten->next, *par; - tselem= TREESTORE(ten); - lib= (Library *)tselem->id; + TreeElement *nten = ten->next, *par; + tselem = TREESTORE(ten); + lib = (Library *)tselem->id; if (lib->parent) { BLI_remlink(&soops->tree, ten); - par= (TreeElement *)lib->parent->id.newid; + par = (TreeElement *)lib->parent->id.newid; BLI_addtail(&par->subtree, ten); - ten->parent= par; + ten->parent = par; } - ten= nten; + ten = nten; } /* restore newid pointers */ - for (lib= mainvar->library.first; lib; lib= lib->id.next) - lib->id.newid= NULL; + for (lib = mainvar->library.first; lib; lib = lib->id.next) + lib->id.newid = NULL; } else if (soops->outlinevis == SO_ALL_SCENES) { Scene *sce; - for (sce= mainvar->scene.first; sce; sce= sce->id.next) { - te= outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); - tselem= TREESTORE(te); - if (sce==scene && show_opened) + for (sce = mainvar->scene.first; sce; sce = sce->id.next) { + te = outliner_add_element(soops, &soops->tree, sce, NULL, 0, 0); + tselem = TREESTORE(te); + if (sce == scene && show_opened) tselem->flag &= ~TSE_CLOSED; - for (base= sce->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); - ten->directdata= base; + for (base = sce->base.first; base; base = base->next) { + ten = outliner_add_element(soops, &te->subtree, base->object, te, 0, 0); + ten->directdata = base; } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for (base= sce->base.first; base; base= base->next) base->object->id.newid= NULL; + for (base = sce->base.first; base; base = base->next) base->object->id.newid = NULL; } } else if (soops->outlinevis == SO_CUR_SCENE) { outliner_add_scene_contents(soops, &soops->tree, scene, NULL); - for (base= scene->base.first; base; base= base->next) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + for (base = scene->base.first; base; base = base->next) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } outliner_make_hierarchy(soops, &soops->tree); } else if (soops->outlinevis == SO_VISIBLE) { - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & scene->lay) outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); } @@ -1469,102 +1469,102 @@ void outliner_build_tree(Main *mainvar, Scene *scene, SpaceOops *soops) Group *group; GroupObject *go; - for (group= mainvar->group.first; group; group= group->id.next) { + for (group = mainvar->group.first; group; group = group->id.next) { if (group->gobject.first) { - te= outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); + te = outliner_add_element(soops, &soops->tree, group, NULL, 0, 0); - for (go= group->gobject.first; go; go= go->next) { - ten= outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); - ten->directdata= NULL; /* eh, why? */ + for (go = group->gobject.first; go; go = go->next) { + ten = outliner_add_element(soops, &te->subtree, go->ob, te, 0, 0); + ten->directdata = NULL; /* eh, why? */ } outliner_make_hierarchy(soops, &te->subtree); /* clear id.newid, to prevent objects be inserted in wrong scenes (parent in other scene) */ - for (go= group->gobject.first; go; go= go->next) go->ob->id.newid= NULL; + for (go = group->gobject.first; go; go = go->next) go->ob->id.newid = NULL; } } } else if (soops->outlinevis == SO_SAME_TYPE) { - Object *ob= OBACT; + Object *ob = OBACT; if (ob) { - for (base= scene->base.first; base; base= base->next) { - if (base->object->type==ob->type) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + for (base = scene->base.first; base; base = base->next) { + if (base->object->type == ob->type) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } } outliner_make_hierarchy(soops, &soops->tree); } } else if (soops->outlinevis == SO_SELECTED) { - for (base= scene->base.first; base; base= base->next) { + for (base = scene->base.first; base; base = base->next) { if (base->lay & scene->lay) { - if (base==BASACT || (base->flag & SELECT)) { - ten= outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); - ten->directdata= base; + if (base == BASACT || (base->flag & SELECT)) { + ten = outliner_add_element(soops, &soops->tree, base->object, NULL, 0, 0); + ten->directdata = base; } } } outliner_make_hierarchy(soops, &soops->tree); } - else if (soops->outlinevis==SO_SEQUENCE) { + else if (soops->outlinevis == SO_SEQUENCE) { Sequence *seq; - Editing *ed= seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int op; - if (ed==NULL) + if (ed == NULL) return; - seq= ed->seqbasep->first; + seq = ed->seqbasep->first; if (!seq) return; while (seq) { - op= need_add_seq_dup(seq); - if (op==1) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE, 0); + op = need_add_seq_dup(seq); + if (op == 1) { + /* ten= */ outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE, 0); } - else if (op==0) { - ten= outliner_add_element(soops, &soops->tree, (void*)seq, NULL, TSE_SEQUENCE_DUP, 0); + else if (op == 0) { + ten = outliner_add_element(soops, &soops->tree, (void *)seq, NULL, TSE_SEQUENCE_DUP, 0); outliner_add_seq_dup(soops, seq, ten, 0); } - seq= seq->next; + seq = seq->next; } } - else if (soops->outlinevis==SO_DATABLOCKS) { + else if (soops->outlinevis == SO_DATABLOCKS) { PointerRNA mainptr; RNA_main_pointer_create(mainvar, &mainptr); - ten= outliner_add_element(soops, &soops->tree, (void*)&mainptr, NULL, TSE_RNA_STRUCT, -1); + ten = outliner_add_element(soops, &soops->tree, (void *)&mainptr, NULL, TSE_RNA_STRUCT, -1); if (show_opened) { - tselem= TREESTORE(ten); + tselem = TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis==SO_USERDEF) { + else if (soops->outlinevis == SO_USERDEF) { PointerRNA userdefptr; RNA_pointer_create(NULL, &RNA_UserPreferences, &U, &userdefptr); - ten= outliner_add_element(soops, &soops->tree, (void*)&userdefptr, NULL, TSE_RNA_STRUCT, -1); + ten = outliner_add_element(soops, &soops->tree, (void *)&userdefptr, NULL, TSE_RNA_STRUCT, -1); if (show_opened) { - tselem= TREESTORE(ten); + tselem = TREESTORE(ten); tselem->flag &= ~TSE_CLOSED; } } - else if (soops->outlinevis==SO_KEYMAP) { - wmWindowManager *wm= mainvar->wm.first; + else if (soops->outlinevis == SO_KEYMAP) { + wmWindowManager *wm = mainvar->wm.first; wmKeyMap *km; - for (km= wm->defaultconf->keymaps.first; km; km= km->next) { - /* ten= */ outliner_add_element(soops, &soops->tree, (void*)km, NULL, TSE_KEYMAP, 0); + for (km = wm->defaultconf->keymaps.first; km; km = km->next) { + /* ten= */ outliner_add_element(soops, &soops->tree, (void *)km, NULL, TSE_KEYMAP, 0); } } else { - ten= outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); - if (ten) ten->directdata= BASACT; + ten = outliner_add_element(soops, &soops->tree, OBACT, NULL, 0, 0); + if (ten) ten->directdata = BASACT; } outliner_sort(soops, &soops->tree); diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c index c2a3affa1b6..3110ff3e29e 100644 --- a/source/blender/editors/space_outliner/space_outliner.c +++ b/source/blender/editors/space_outliner/space_outliner.c @@ -77,20 +77,20 @@ static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar) static int outliner_parent_drop_poll(bContext *C, wmDrag *drag, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te= NULL; + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if ( GS(id->name) == ID_OB ) { + if (GS(id->name) == ID_OB) { /* Ensure item under cursor is valid drop target */ /* Find object hovered over */ - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { TreeElement *te_valid; - te_valid= outliner_dropzone_parent(C, event, te, fmval); + te_valid = outliner_dropzone_parent(C, event, te, fmval); if (te_valid) return 1; } } @@ -102,30 +102,30 @@ static void outliner_parent_drop_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "child", id->name+2); + RNA_string_set(drop->ptr, "child", id->name + 2); } static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) { - ARegion *ar= CTX_wm_region(C); - SpaceOops *soops= CTX_wm_space_outliner(C); - TreeElement *te= NULL; + ARegion *ar = CTX_wm_region(C); + SpaceOops *soops = CTX_wm_space_outliner(C); + TreeElement *te = NULL; float fmval[2]; UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]); if (drag->type == WM_DRAG_ID) { ID *id = (ID *)drag->poin; - if ( GS(id->name) == ID_OB ) { + if (GS(id->name) == ID_OB) { //TODO: Check if no parent? /* Ensure location under cursor is valid dropzone */ - for (te= soops->tree.first; te; te= te->next) { + for (te = soops->tree.first; te; te = te->next) { if (outliner_dropzone_parent_clear(C, event, te, fmval)) return 1; } /* Check if mouse cursor is below the tree */ - te= soops->tree.last; - while (((te->flag & TE_LAZY_CLOSED)==0) && (te->subtree.last)) { - te= te->subtree.last; + te = soops->tree.last; + while (((te->flag & TE_LAZY_CLOSED) == 0) && (te->subtree.last)) { + te = te->subtree.last; } if (fmval[1] < te->ys) return 1; } @@ -136,7 +136,7 @@ static int outliner_parent_clear_poll(bContext *C, wmDrag *drag, wmEvent *event) static void outliner_parent_clear_copy(wmDrag *drag, wmDropBox *drop) { ID *id = (ID *)drag->poin; - RNA_string_set(drop->ptr, "dragged_obj", id->name+2); + RNA_string_set(drop->ptr, "dragged_obj", id->name + 2); /* Set to simple parent clear type. Avoid menus for drag and drop if possible. * If desired, user can toggle the different "Clear Parent" types in the operator @@ -155,7 +155,7 @@ static void outliner_dropboxes(void) static void outliner_main_area_draw(const bContext *C, ARegion *ar) { - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DScrollers *scrollers; /* clear */ @@ -168,7 +168,7 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -234,11 +234,11 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) /* For updating lamp icons, when changing lamp type */ if (wmn->data == ND_LIGHTING_DRAW) ED_region_tag_redraw(ar); - break; + break; case NC_SPACE: if (wmn->data == ND_SPACE_OUTLINER) ED_region_tag_redraw(ar); - break; + break; case NC_ID: if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); @@ -269,7 +269,7 @@ static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn) ED_region_tag_redraw(ar); break; case ND_ANIMCHAN: - if (wmn->action==NA_SELECTED) + if (wmn->action == NA_SELECTED) ED_region_tag_redraw(ar); break; } @@ -318,35 +318,35 @@ static SpaceLink *outliner_new(const bContext *UNUSED(C)) ARegion *ar; SpaceOops *soutliner; - soutliner= MEM_callocN(sizeof(SpaceOops), "initoutliner"); - soutliner->spacetype= SPACE_OUTLINER; + soutliner = MEM_callocN(sizeof(SpaceOops), "initoutliner"); + soutliner->spacetype = SPACE_OUTLINER; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for outliner"); + ar = MEM_callocN(sizeof(ARegion), "header for outliner"); BLI_addtail(&soutliner->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for outliner"); + ar = MEM_callocN(sizeof(ARegion), "main area for outliner"); BLI_addtail(&soutliner->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; - ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O); - ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y); - ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT); - ar->v2d.keeptot= V2D_KEEPTOT_STRICT; - ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f; + ar->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM_O); + ar->v2d.align = (V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_POS_Y); + ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT); + ar->v2d.keeptot = V2D_KEEPTOT_STRICT; + ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f; - return (SpaceLink*)soutliner; + return (SpaceLink *)soutliner; } /* not spacelink itself */ static void outliner_free(SpaceLink *sl) { - SpaceOops *soutliner= (SpaceOops*)sl; + SpaceOops *soutliner = (SpaceOops *)sl; outliner_free_tree(&soutliner->tree); if (soutliner->treestore) { @@ -364,11 +364,11 @@ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *outliner_duplicate(SpaceLink *sl) { - SpaceOops *soutliner= (SpaceOops *)sl; - SpaceOops *soutlinern= MEM_dupallocN(soutliner); + SpaceOops *soutliner = (SpaceOops *)sl; + SpaceOops *soutlinern = MEM_dupallocN(soutliner); - soutlinern->tree.first= soutlinern->tree.last= NULL; - soutlinern->treestore= NULL; + soutlinern->tree.first = soutlinern->tree.last = NULL; + soutlinern->treestore = NULL; return (SpaceLink *)soutlinern; } @@ -376,41 +376,41 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl) /* only called once, from space_api/spacetypes.c */ void ED_spacetype_outliner(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - st->spaceid= SPACE_OUTLINER; + st->spaceid = SPACE_OUTLINER; strncpy(st->name, "Outliner", BKE_ST_MAXNAME); - st->new= outliner_new; - st->free= outliner_free; - st->init= outliner_init; - st->duplicate= outliner_duplicate; - st->operatortypes= outliner_operatortypes; - st->keymap= outliner_keymap; - st->dropboxes= outliner_dropboxes; + st->new = outliner_new; + st->free = outliner_free; + st->init = outliner_init; + st->duplicate = outliner_duplicate; + st->operatortypes = outliner_operatortypes; + st->keymap = outliner_keymap; + st->dropboxes = outliner_dropboxes; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D; - art->init= outliner_main_area_init; - art->draw= outliner_main_area_draw; - art->free= outliner_main_area_free; - art->listener= outliner_main_area_listener; + art->init = outliner_main_area_init; + art->draw = outliner_main_area_draw; + art->free = outliner_main_area_free; + art->listener = outliner_main_area_listener; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= outliner_header_area_init; - art->draw= outliner_header_area_draw; - art->free= outliner_header_area_free; - art->listener= outliner_header_area_listener; + art->init = outliner_header_area_init; + art->draw = outliner_header_area_draw; + art->free = outliner_header_area_free; + art->listener = outliner_header_area_listener; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_script/script_edit.c b/source/blender/editors/space_script/script_edit.c index 4ff0c7ba5b3..4e6783e1862 100644 --- a/source/blender/editors/space_script/script_edit.c +++ b/source/blender/editors/space_script/script_edit.c @@ -46,7 +46,7 @@ #include "ED_screen.h" -#include "script_intern.h" // own include +#include "script_intern.h" // own include #ifdef WITH_PYTHON #include "BPY_extern.h" /* BPY_script_exec */ @@ -58,7 +58,7 @@ static int run_pyfile_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", path); #ifdef WITH_PYTHON if (BPY_filepath_exec(C, path, op->reports)) { - ARegion *ar= CTX_wm_region(C); + ARegion *ar = CTX_wm_region(C); ED_region_tag_redraw(ar); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_script/script_ops.c b/source/blender/editors/space_script/script_ops.c index 0c99d9b34c4..57a1112a832 100644 --- a/source/blender/editors/space_script/script_ops.c +++ b/source/blender/editors/space_script/script_ops.c @@ -63,6 +63,6 @@ void script_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap = WM_keymap_find(keyconf, "Script", SPACE_SCRIPT, 0); /* TODO - this is just while we have no way to load a text datablock */ - RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0)->ptr, "filepath", "test.py"); + RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", PKEY, KM_PRESS, KM_CTRL | KM_SHIFT | KM_ALT, 0)->ptr, "filepath", "test.py"); } diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c index bad9a01fbcf..1fbd6f08b34 100644 --- a/source/blender/editors/space_script/space_script.c +++ b/source/blender/editors/space_script/space_script.c @@ -57,7 +57,7 @@ #include "BPY_extern.h" #endif -#include "script_intern.h" // own include +#include "script_intern.h" // own include //static script_run_python(char *funcname, ) @@ -70,22 +70,22 @@ static SpaceLink *script_new(const bContext *UNUSED(C)) ARegion *ar; SpaceScript *sscript; - sscript= MEM_callocN(sizeof(SpaceScript), "initscript"); - sscript->spacetype= SPACE_SCRIPT; + sscript = MEM_callocN(sizeof(SpaceScript), "initscript"); + sscript->spacetype = SPACE_SCRIPT; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for script"); + ar = MEM_callocN(sizeof(ARegion), "header for script"); BLI_addtail(&sscript->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for script"); + ar = MEM_callocN(sizeof(ARegion), "main area for script"); BLI_addtail(&sscript->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; /* channel list region XXX */ @@ -96,7 +96,7 @@ static SpaceLink *script_new(const bContext *UNUSED(C)) /* not spacelink itself */ static void script_free(SpaceLink *sl) { - SpaceScript *sscript= (SpaceScript*) sl; + SpaceScript *sscript = (SpaceScript *) sl; #ifdef WITH_PYTHON /*free buttons references*/ @@ -118,7 +118,7 @@ static void script_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa)) static SpaceLink *script_duplicate(SpaceLink *sl) { - SpaceScript *sscriptn= MEM_dupallocN(sl); + SpaceScript *sscriptn = MEM_dupallocN(sl); /* clear or remove stuff from old */ @@ -142,8 +142,8 @@ static void script_main_area_init(wmWindowManager *wm, ARegion *ar) static void script_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - SpaceScript *sscript= (SpaceScript*)CTX_wm_space_data(C); - View2D *v2d= &ar->v2d; + SpaceScript *sscript = (SpaceScript *)CTX_wm_space_data(C); + View2D *v2d = &ar->v2d; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -189,37 +189,37 @@ static void script_main_area_listener(ARegion *UNUSED(ar), wmNotifier *UNUSED(wm /* only called once, from space/spacetypes.c */ void ED_spacetype_script(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype script"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype script"); ARegionType *art; - st->spaceid= SPACE_SCRIPT; + st->spaceid = SPACE_SCRIPT; strncpy(st->name, "Script", BKE_ST_MAXNAME); - st->new= script_new; - st->free= script_free; - st->init= script_init; - st->duplicate= script_duplicate; - st->operatortypes= script_operatortypes; - st->keymap= script_keymap; + st->new = script_new; + st->free = script_free; + st->init = script_init; + st->duplicate = script_duplicate; + st->operatortypes = script_operatortypes; + st->keymap = script_keymap; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype script region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype script region"); art->regionid = RGN_TYPE_WINDOW; - art->init= script_main_area_init; - art->draw= script_main_area_draw; - art->listener= script_main_area_listener; - art->keymapflag= ED_KEYMAP_VIEW2D| ED_KEYMAP_UI|ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction + art->init = script_main_area_init; + art->draw = script_main_area_draw; + art->listener = script_main_area_listener; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_UI | ED_KEYMAP_FRAMES; // XXX need to further test this ED_KEYMAP_UI is needed for button interaction BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype script region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype script region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_HEADER; - art->init= script_header_area_init; - art->draw= script_header_area_draw; + art->init = script_header_area_init; + art->draw = script_header_area_draw; BLI_addhead(&st->regiontypes, art); diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 4bc08242020..2c3924e5407 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -106,7 +106,7 @@ static void sequencer_generic_invoke_path__internal(bContext *C, wmOperator *op, { if (RNA_struct_find_property(op->ptr, identifier)) { Scene *scene = CTX_data_scene(C); - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { char path[sizeof(last_seq->strip->dir)]; BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); @@ -203,7 +203,7 @@ static void seq_load_operator_info(SeqLoadInfo *seq_load, wmOperator *op) static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); Scene *sce_seq; @@ -239,11 +239,11 @@ static int sequencer_add_scene_strip_exec(bContext *C, wmOperator *op) seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0); calc_sequence_disp(scene, seq); - sort_seq(scene); + BKE_sequencer_sort(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); seq->flag |= SELECT; } @@ -302,7 +302,7 @@ void SEQUENCER_OT_scene_strip_add(struct wmOperatorType *ot) static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); MovieClip *clip; @@ -338,11 +338,11 @@ static int sequencer_add_movieclip_strip_exec(bContext *C, wmOperator *op) seqbase_unique_name_recursive(&ed->seqbase, seq); calc_sequence_disp(scene, seq); - sort_seq(scene); + BKE_sequencer_sort(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); seq->flag |= SELECT; } @@ -401,7 +401,7 @@ void SEQUENCER_OT_movieclip_strip_add(struct wmOperatorType *ot) static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoadFunc seq_load_func) { Scene *scene = CTX_data_scene(C); /* only for sound */ - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); SeqLoadInfo seq_load; Sequence *seq; int tot_files; @@ -412,7 +412,10 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad if (seq_load.flag & SEQ_LOAD_REPLACE_SEL) deselect_all_seq(scene); - tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + if (RNA_struct_property_is_set(op->ptr, "files")) + tot_files = RNA_property_collection_length(op->ptr, RNA_struct_find_property(op->ptr, "files")); + else + tot_files = 0; if (tot_files) { /* multiple files */ @@ -450,7 +453,7 @@ static int sequencer_add_generic_strip_exec(bContext *C, wmOperator *op, SeqLoad return OPERATOR_CANCELLED; } - sort_seq(scene); + BKE_sequencer_sort(scene); seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -572,7 +575,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) /* cant use the generic function for this */ Scene *scene = CTX_data_scene(C); /* only for sound */ - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); SeqLoadInfo seq_load; Sequence *seq; @@ -613,7 +616,7 @@ static int sequencer_add_image_strip_exec(bContext *C, wmOperator *op) calc_sequence_disp(scene, seq); - sort_seq(scene); + BKE_sequencer_sort(scene); /* last active name */ strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR - 1); @@ -675,7 +678,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); Sequence *seq; /* generic strip vars */ Strip *strip; @@ -776,11 +779,11 @@ static int sequencer_add_effect_strip_exec(bContext *C, wmOperator *op) /* not sure if this is needed with update_changed_seq_and_deps. * it was NOT called in blender 2.4x, but wont hurt */ - sort_seq(scene); + BKE_sequencer_sort(scene); if (RNA_boolean_get(op->ptr, "replace_sel")) { deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); seq->flag |= SELECT; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 38a5151590e..49fadf300e2 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1062,7 +1062,7 @@ static void draw_seq_strips(const bContext *C, Editing *ed, ARegion *ar) { Scene *scene = CTX_data_scene(C); View2D *v2d = &ar->v2d; - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); int sel = 0, j; float pixelx = (v2d->cur.xmax - v2d->cur.xmin) / (v2d->mask.xmax - v2d->mask.xmin); @@ -1122,7 +1122,7 @@ static void seq_draw_sfra_efra(Scene *scene, View2D *v2d) void draw_timeline_seq(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); SpaceSeq *sseq = CTX_wm_space_seq(C); View2D *v2d = &ar->v2d; View2DScrollers *scrollers; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index b021c233f8c..3d6fbb53e37 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -163,7 +163,7 @@ static void proxy_startjob(void *pjv, short *stop, short *do_update, float *prog static void proxy_endjob(void *pjv) { ProxyJob *pj = pjv; - Editing *ed = seq_give_editing(pj->scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(pj->scene, FALSE); LinkData *link; for (link = pj->queue.first; link; link = link->next) { @@ -180,7 +180,7 @@ static void seq_proxy_build_job(const bContext *C) wmJob *steve; ProxyJob *pj; Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); ScrArea *sa = CTX_wm_area(C); struct SeqIndexBuildContext *context; LinkData *link; @@ -233,9 +233,9 @@ void seq_rectf(Sequence *seq, rctf *rectf) static void UNUSED_FUNCTION(change_plugin_seq) (Scene * scene, char *str) /* called from fileselect */ { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); struct SeqEffectHandle sh; - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); if (last_seq == NULL || last_seq->type != SEQ_PLUGIN) return; @@ -255,7 +255,7 @@ static void UNUSED_FUNCTION(change_plugin_seq) (Scene * scene, char *str) /* cal void boundbox_seq(Scene *scene, rctf *rect) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); float min[2], max[2]; @@ -302,7 +302,7 @@ Sequence *find_neighboring_sequence(Scene *scene, Sequence *test, int lr, int se { /* sel - 0==unselected, 1==selected, -1==done care*/ Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return NULL; @@ -334,7 +334,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i { /* sel - 0==unselected, 1==selected, -1==done care*/ Sequence *seq, *best_seq = NULL; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int dist, best_dist; best_dist = MAXFRAME * 2; @@ -382,7 +382,7 @@ static Sequence *find_next_prev_sequence(Scene *scene, Sequence *test, int lr, i Sequence *find_nearest_seq(Scene *scene, View2D *v2d, int *hand, const int mval[2]) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); float x, y; float pixelx; float handsize; @@ -457,7 +457,7 @@ static int seq_is_predecessor(Sequence *pred, Sequence *seq) void deselect_all_seq(Scene *scene) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; @@ -489,13 +489,13 @@ void recurs_sel_seq(Sequence *seqm) int seq_effect_find_selected(Scene *scene, Sequence *activeseq, int type, Sequence **selseq1, Sequence **selseq2, Sequence **selseq3, const char **error_str) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq1 = NULL, *seq2 = NULL, *seq3 = NULL, *seq; *error_str = NULL; if (!activeseq) - seq2 = seq_active_get(scene); + seq2 = BKE_sequencer_active_get(scene); for (seq = ed->seqbasep->first; seq; seq = seq->next) { if (seq->flag & SELECT) { @@ -597,14 +597,14 @@ static Sequence *del_seq_find_replace_recurs(Scene *scene, Sequence *seq) static void recurs_del_seq_flag(Scene *scene, ListBase *lb, short flag, short deleteall) { Sequence *seq, *seqn; - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); seq = lb->first; while (seq) { seqn = seq->next; if ((seq->flag & flag) || deleteall) { BLI_remlink(lb, seq); - if (seq == last_seq) seq_active_set(scene, NULL); + if (seq == last_seq) BKE_sequencer_active_set(scene, NULL); if (seq->type == SEQ_META) recurs_del_seq_flag(scene, &seq->seqbase, flag, 1); seq_free_sequence(scene, seq); } @@ -839,7 +839,7 @@ static int cut_seq_list(Scene *scene, ListBase *old, ListBase *new, int cutframe static int insert_gap(Scene *scene, int gap, int cfra) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int done = 0; /* all strips >= cfra are shifted */ @@ -862,7 +862,7 @@ static int insert_gap(Scene *scene, int gap, int cfra) static void UNUSED_FUNCTION(touch_seq_files) (Scene * scene) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); char str[256]; /* touch all strips with movies */ @@ -894,7 +894,7 @@ static void UNUSED_FUNCTION(touch_seq_files) (Scene * scene) static void set_filter_seq(Scene *scene) { Sequence *seq; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; @@ -918,8 +918,8 @@ static void set_filter_seq(Scene *scene) static void UNUSED_FUNCTION(seq_remap_paths) (Scene * scene) { - Sequence *seq, *last_seq = seq_active_get(scene); - Editing *ed = seq_give_editing(scene, FALSE); + Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); char from[FILE_MAX], to[FILE_MAX], stripped[FILE_MAX]; @@ -960,7 +960,7 @@ static void UNUSED_FUNCTION(seq_remap_paths) (Scene * scene) static void UNUSED_FUNCTION(no_gaps) (Scene * scene) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int cfra, first = 0, done; @@ -1001,14 +1001,14 @@ static int seq_get_snaplimit(View2D *v2d) /* Operator functions */ int sequencer_edit_poll(bContext *C) { - return (seq_give_editing(CTX_data_scene(C), FALSE) != NULL); + return (BKE_sequencer_editing_get(CTX_data_scene(C), FALSE) != NULL); } #if 0 /* UNUSED */ int sequencer_strip_poll(bContext *C) { Editing *ed; - return (((ed = seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL)); + return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE)) != NULL) && (ed->act_seq != NULL)); } #endif @@ -1016,13 +1016,13 @@ int sequencer_strip_has_path_poll(bContext *C) { Editing *ed; Sequence *seq; - return (((ed = seq_give_editing(CTX_data_scene(C), FALSE)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); + return (((ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE)) != NULL) && ((seq = ed->act_seq) != NULL) && (SEQ_HAS_PATH(seq))); } int sequencer_view_poll(bContext *C) { SpaceSeq *sseq = CTX_wm_space_seq(C); - Editing *ed = seq_give_editing(CTX_data_scene(C), FALSE); + Editing *ed = BKE_sequencer_editing_get(CTX_data_scene(C), FALSE); if (ed && sseq && (sseq->mainb == SEQ_DRAW_IMG_IMBUF)) return 1; @@ -1034,7 +1034,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int snap_frame; @@ -1084,7 +1084,7 @@ static int sequencer_snap_exec(bContext *C, wmOperator *op) } /* as last: */ - sort_seq(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1125,7 +1125,7 @@ void SEQUENCER_OT_snap(struct wmOperatorType *ot) static int sequencer_mute_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int selected; @@ -1172,7 +1172,7 @@ void SEQUENCER_OT_mute(struct wmOperatorType *ot) static int sequencer_unmute_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int selected; @@ -1219,7 +1219,7 @@ void SEQUENCER_OT_unmute(struct wmOperatorType *ot) static int sequencer_lock_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -1252,7 +1252,7 @@ void SEQUENCER_OT_lock(struct wmOperatorType *ot) static int sequencer_unlock_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -1285,7 +1285,7 @@ void SEQUENCER_OT_unlock(struct wmOperatorType *ot) static int sequencer_reload_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int adjust_length = RNA_boolean_get(op->ptr, "adjust_length"); @@ -1331,7 +1331,7 @@ void SEQUENCER_OT_reload(struct wmOperatorType *ot) static int sequencer_refresh_all_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); @@ -1355,7 +1355,7 @@ void SEQUENCER_OT_refresh_all(struct wmOperatorType *ot) static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Sequence *seq1, *seq2, *seq3, *last_seq = seq_active_get(scene); + Sequence *seq1, *seq2, *seq3, *last_seq = BKE_sequencer_active_get(scene); const char *error_msg; if (!seq_effect_find_selected(scene, last_seq, last_seq->type, &seq1, &seq2, &seq3, &error_msg)) { @@ -1385,10 +1385,10 @@ static int sequencer_reassign_inputs_exec(bContext *C, wmOperator *op) static int sequencer_effect_poll(bContext *C) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) { - Sequence *last_seq = seq_active_get(scene); + Sequence *last_seq = BKE_sequencer_active_get(scene); if (last_seq && (last_seq->type & SEQ_EFFECT)) { return 1; } @@ -1416,7 +1416,7 @@ void SEQUENCER_OT_reassign_inputs(struct wmOperatorType *ot) static int sequencer_swap_inputs_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Sequence *seq, *last_seq = seq_active_get(scene); + Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); if (last_seq->seq1 == NULL || last_seq->seq2 == NULL) { BKE_report(op->reports, RPT_ERROR, "No valid inputs to swap"); @@ -1459,7 +1459,7 @@ static EnumPropertyItem prop_cut_types[] = { static int sequencer_cut_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); int cut_side, cut_hard, cut_frame; ListBase newlist; @@ -1499,7 +1499,7 @@ static int sequencer_cut_exec(bContext *C, wmOperator *op) SEQ_END; } /* as last: */ - sort_seq(scene); + BKE_sequencer_sort(scene); } if (changed) { @@ -1567,7 +1567,7 @@ static int apply_unique_name_cb(Sequence *seq, void *arg_pt) static int sequencer_add_duplicate_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); ListBase nseqbase = {NULL, NULL}; @@ -1624,12 +1624,12 @@ void SEQUENCER_OT_duplicate(wmOperatorType *ot) static int sequencer_delete_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; MetaStack *ms; int nothingSelected = TRUE; - seq = seq_active_get(scene); + seq = BKE_sequencer_active_get(scene); if (seq && seq->flag & SELECT) { /* avoid a loop since this is likely to be selected */ nothingSelected = FALSE; } @@ -1695,7 +1695,7 @@ void SEQUENCER_OT_delete(wmOperatorType *ot) static int sequencer_offset_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; /* for effects, try to find a replacement input */ @@ -1747,7 +1747,7 @@ void SEQUENCER_OT_offset_clear(wmOperatorType *ot) static int sequencer_separate_images_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *seq_new; Strip *strip_new; @@ -1811,7 +1811,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) } /* as last: */ - sort_seq(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -1843,8 +1843,8 @@ void SEQUENCER_OT_images_separate(wmOperatorType *ot) static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *last_seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *last_seq = BKE_sequencer_active_get(scene); MetaStack *ms; if (last_seq && last_seq->type == SEQ_META && last_seq->flag & SELECT) { @@ -1856,7 +1856,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) ed->seqbasep = &last_seq->seqbase; - seq_active_set(scene, NULL); + BKE_sequencer_active_set(scene, NULL); } else { @@ -1876,7 +1876,7 @@ static int sequencer_meta_toggle_exec(bContext *C, wmOperator *UNUSED(op)) for (seq = ed->seqbasep->first; seq; seq = seq->next) calc_sequence(scene, seq); - seq_active_set(scene, ms->parseq); + BKE_sequencer_active_set(scene, ms->parseq); ms->parseq->flag |= SELECT; recurs_sel_seq(ms->parseq); @@ -1911,9 +1911,9 @@ void SEQUENCER_OT_meta_toggle(wmOperatorType *ot) static int sequencer_meta_make_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - Sequence *seq, *seqm, *next, *last_seq = seq_active_get(scene); + Sequence *seq, *seqm, *next, *last_seq = BKE_sequencer_active_get(scene); int channel_max = 1; if (seqbase_isolated_sel_check(ed->seqbasep) == FALSE) { @@ -1944,7 +1944,7 @@ static int sequencer_meta_make_exec(bContext *C, wmOperator *op) seqm->strip = MEM_callocN(sizeof(Strip), "metastrip"); seqm->strip->us = 1; - seq_active_set(scene, seqm); + BKE_sequencer_active_set(scene, seqm); if (seq_test_overlap(ed->seqbasep, seqm) ) shuffle_seq(ed->seqbasep, seqm, scene); @@ -1987,9 +1987,9 @@ static int seq_depends_on_meta(Sequence *seq, Sequence *seqm) static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); - Sequence *seq, *last_seq = seq_active_get(scene); /* last_seq checks ed==NULL */ + Sequence *seq, *last_seq = BKE_sequencer_active_get(scene); /* last_seq checks ed==NULL */ if (last_seq == NULL || last_seq->type != SEQ_META) return OPERATOR_CANCELLED; @@ -2020,7 +2020,7 @@ static int sequencer_meta_separate_exec(bContext *C, wmOperator *UNUSED(op)) } } - sort_seq(scene); + BKE_sequencer_sort(scene); seq_update_muting(ed); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2225,7 +2225,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op)) View2D *v2d = UI_view2d_fromcontext(C); ScrArea *area = CTX_wm_area(C); bScreen *sc = CTX_wm_screen(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; int xmin = MAXFRAME * 2; @@ -2300,7 +2300,7 @@ void SEQUENCER_OT_view_selected(wmOperatorType *ot) static int find_next_prev_edit(Scene *scene, int cfra, int side) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *best_seq = NULL, *frame_seq = NULL; int dist, best_dist; @@ -2427,7 +2427,7 @@ static void swap_sequence(Scene *scene, Sequence *seqa, Sequence *seqb) #if 0 static Sequence *sequence_find_parent(Scene *scene, Sequence *child) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *parent = NULL; Sequence *seq; @@ -2447,8 +2447,8 @@ static Sequence *sequence_find_parent(Scene *scene, Sequence *child) static int sequencer_swap_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *active_seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *active_seq = BKE_sequencer_active_get(scene); Sequence *seq, *iseq; int side = RNA_enum_get(op->ptr, "side"); @@ -2492,7 +2492,7 @@ static int sequencer_swap_exec(bContext *C, wmOperator *op) - sort_seq(scene); + BKE_sequencer_sort(scene); WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene); @@ -2524,7 +2524,7 @@ static int sequencer_rendersize_exec(bContext *C, wmOperator *UNUSED(op)) { int retval = OPERATOR_CANCELLED; Scene *scene = CTX_data_scene(C); - Sequence *active_seq = seq_active_get(scene); + Sequence *active_seq = BKE_sequencer_active_get(scene); StripElem *se = NULL; if (active_seq == NULL) @@ -2596,7 +2596,7 @@ static void seq_copy_del_sound(Scene *scene, Sequence *seq) static int sequencer_copy_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; ListBase nseqbase = {NULL, NULL}; @@ -2660,7 +2660,7 @@ void SEQUENCER_OT_copy(wmOperatorType *ot) static int sequencer_paste_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, TRUE); /* create if needed */ + Editing *ed = BKE_sequencer_editing_get(scene, TRUE); /* create if needed */ ListBase nseqbase = {NULL, NULL}; int ofs; Sequence *iseq; @@ -2716,7 +2716,7 @@ static int sequencer_swap_data_exec(bContext *C, wmOperator *op) Sequence *seq_other; const char *error_msg; - if (seq_active_pair_get(scene, &seq_act, &seq_other) == 0) { + if (BKE_sequencer_active_get_pair(scene, &seq_act, &seq_other) == 0) { BKE_report(op->reports, RPT_ERROR, "Must select 2 strips"); return OPERATOR_CANCELLED; } @@ -2764,7 +2764,7 @@ void SEQUENCER_OT_swap_data(wmOperatorType *ot) static int view_ghost_border_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); View2D *v2d = UI_view2d_fromcontext(C); rctf rect; @@ -2856,8 +2856,8 @@ static EnumPropertyItem prop_change_effect_input_types[] = { static int sequencer_change_effect_input_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = BKE_sequencer_active_get(scene); Sequence **seq_1, **seq_2; @@ -2914,8 +2914,8 @@ void SEQUENCER_OT_change_effect_input(struct wmOperatorType *ot) static int sequencer_change_effect_type_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = BKE_sequencer_active_get(scene); const int new_type = RNA_enum_get(op->ptr, "type"); /* free previous effect and init new effect */ @@ -2975,8 +2975,8 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); - Sequence *seq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); + Sequence *seq = BKE_sequencer_active_get(scene); const int is_relative_path = RNA_boolean_get(op->ptr, "relative_path"); if (seq->type == SEQ_IMAGE) { @@ -3044,7 +3044,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) static int sequencer_change_path_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { Scene *scene = CTX_data_scene(C); - Sequence *seq = seq_active_get(scene); + Sequence *seq = BKE_sequencer_active_get(scene); RNA_string_set(op->ptr, "directory", seq->strip->dir); diff --git a/source/blender/editors/space_sequencer/sequencer_intern.h b/source/blender/editors/space_sequencer/sequencer_intern.h index e63a3052d26..fd536524c11 100644 --- a/source/blender/editors/space_sequencer/sequencer_intern.h +++ b/source/blender/editors/space_sequencer/sequencer_intern.h @@ -145,18 +145,18 @@ void SEQUENCER_OT_effect_strip_add(struct wmOperatorType *ot); /* RNA enums, just to be more readable */ enum { - SEQ_SIDE_NONE=0, + SEQ_SIDE_NONE = 0, SEQ_SIDE_LEFT, SEQ_SIDE_RIGHT, - SEQ_SIDE_BOTH, + SEQ_SIDE_BOTH }; enum { SEQ_CUT_SOFT, - SEQ_CUT_HARD, + SEQ_CUT_HARD }; enum { SEQ_SELECTED, - SEQ_UNSELECTED, + SEQ_UNSELECTED }; /* defines used internally */ diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 2f5dff961fe..5debeaf79ae 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -275,8 +275,8 @@ static ImBuf *make_sep_waveform_view_from_ibuf_byte(ImBuf *ibuf) unsigned char *rgb = src + 4 * (ibuf->x * y + x); for (c = 0; c < 3; c++) { unsigned char *p = tgt; - p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) - + c * sw + x / 3 + 1); + p += 4 * (w * ((rgb[c] * (h - 3)) / 255 + 1) + + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); p += 4 * w; @@ -327,8 +327,8 @@ static ImBuf *make_sep_waveform_view_from_ibuf_float(ImBuf *ibuf) CLAMP(v, 0.0f, 1.0f); - p += 4 * (w * ((int) (v * (h - 3)) + 1) - + c * sw + x / 3 + 1); + p += 4 * (w * ((int) (v * (h - 3)) + 1) + + c * sw + x / 3 + 1); scope_put_pixel_single(wtable, p, c); p += 4 * w; @@ -581,8 +581,8 @@ static void vectorscope_put_cross(unsigned char r, unsigned char g, rgb[2] = (float)b / 255.0f; rgb_to_yuv_normalized(rgb, yuv); - p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) - + (int) ((yuv[1] * (w - 3) + 1))); + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + + (int) ((yuv[1] * (w - 3) + 1))); if (r == 0 && g == 0 && b == 0) { r = 255; @@ -632,8 +632,8 @@ static ImBuf *make_vectorscope_view_from_ibuf_byte(ImBuf *ibuf) rgb[2] = (float)src1[2] / 255.0f; rgb_to_yuv_normalized(rgb, yuv); - p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) - + (int) ((yuv[1] * (w - 3) + 1))); + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + + (int) ((yuv[1] * (w - 3) + 1))); scope_put_pixel(wtable, (unsigned char *)p); } } @@ -682,8 +682,8 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) rgb_to_yuv_normalized(rgb, yuv); - p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) - + (int) ((yuv[1] * (w - 3) + 1))); + p = tgt + 4 * (w * (int) ((yuv[2] * (h - 3) + 1)) + + (int) ((yuv[1] * (w - 3) + 1))); scope_put_pixel(wtable, (unsigned char *)p); } } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 677bab37163..a59570a09e1 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -164,11 +164,11 @@ void select_surround_from_last(Scene *scene) static void UNUSED_FUNCTION(select_single_seq) (Scene * scene, Sequence * seq, int deselect_all) /* BRING BACK */ { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (deselect_all) deselect_all_seq(scene); - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if (seq->strip) @@ -185,7 +185,7 @@ static void UNUSED_FUNCTION(select_single_seq) (Scene * scene, Sequence * seq, i #if 0 static void select_neighbor_from_last(Scene *scene, int lr) { - Sequence *seq = seq_active_get(scene); + Sequence *seq = BKE_sequencer_active_get(scene); Sequence *neighbor; int change = 0; if (seq) { @@ -220,7 +220,7 @@ static int sequencer_de_select_all_exec(bContext *C, wmOperator *op) int action = RNA_enum_get(op->ptr, "action"); Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; if (action == SEL_TOGGLE) { @@ -281,7 +281,7 @@ void SEQUENCER_OT_select_all(struct wmOperatorType *ot) static int sequencer_select_inverse_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; for (seq = ed->seqbasep->first; seq; seq = seq->next) { @@ -318,7 +318,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) { View2D *v2d = UI_view2d_fromcontext(C); Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); short extend = RNA_boolean_get(op->ptr, "extend"); short linked_handle = RNA_boolean_get(op->ptr, "linked_handle"); short left_right = RNA_boolean_get(op->ptr, "left_right"); @@ -406,7 +406,7 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event) deselect_all_seq(scene); if (seq) { - seq_active_set(scene, seq); + BKE_sequencer_active_set(scene, seq); if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) { if (seq->strip) { @@ -557,7 +557,7 @@ void SEQUENCER_OT_select(wmOperatorType *ot) /* run recursively to select linked */ static int select_more_less_seq__internal(Scene *scene, int sel, int linked) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq, *neighbor; int change = 0; int isel; @@ -758,7 +758,7 @@ void SEQUENCER_OT_select_linked(wmOperatorType *ot) static int sequencer_select_handles_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, 0); + Editing *ed = BKE_sequencer_editing_get(scene, 0); Sequence *seq; int sel_side = RNA_enum_get(op->ptr, "side"); @@ -808,8 +808,8 @@ void SEQUENCER_OT_select_handles(wmOperatorType *ot) static int sequencer_select_active_side_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, 0); - Sequence *seq_act = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, 0); + Sequence *seq_act = BKE_sequencer_active_get(scene); if (ed == NULL || seq_act == NULL) return OPERATOR_CANCELLED; @@ -846,7 +846,7 @@ void SEQUENCER_OT_select_active_side(wmOperatorType *ot) static int sequencer_borderselect_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); View2D *v2d = UI_view2d_fromcontext(C); Sequence *seq; @@ -1094,7 +1094,7 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) SEQP_BEGIN (ed, seq) { - seq->tmp= NULL; + seq->tmp = NULL; } SEQ_END; @@ -1150,8 +1150,8 @@ static short select_grouped_effect_link(Editing *ed, Sequence *actseq) static int sequencer_select_grouped_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Editing *ed = seq_give_editing(scene, 0); - Sequence *seq, *actseq = seq_active_get(scene); + Editing *ed = BKE_sequencer_editing_get(scene, 0); + Sequence *seq, *actseq = BKE_sequencer_active_get(scene); int type = RNA_enum_get(op->ptr, "type"); short changed = 0, extend; diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index e421ace75a0..4168cb9ac77 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -186,7 +186,7 @@ static void sequencer_free(SpaceLink *UNUSED(sl)) { // SpaceSeq *sseq= (SpaceSequencer*) sl; -// XXX if (sseq->gpd) free_gpencil_data(sseq->gpd); +// XXX if (sseq->gpd) BKE_gpencil_free(sseq->gpd); } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index a07493ef8fc..04408173928 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -167,7 +167,7 @@ static int text_new_exec(bContext *C, wmOperator *UNUSED(op)) PointerRNA ptr, idptr; PropertyRNA *prop; - text = add_empty_text("Text"); + text = BKE_text_add("Text"); /* hook into UI */ uiIDContextProperty(C, &ptr, &prop); @@ -236,7 +236,7 @@ static int text_open_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", str); - text = add_text(str, G.main->name); + text = BKE_text_load(str, G.main->name); if (!text) { if (op->customdata) MEM_freeN(op->customdata); @@ -320,7 +320,7 @@ static int text_reload_exec(bContext *C, wmOperator *op) { Text *text = CTX_data_edit_text(C); - if (!reopen_text(text)) { + if (!BKE_text_reload(text)) { BKE_report(op->reports, RPT_ERROR, "Could not reopen file"); return OPERATOR_CANCELLED; } @@ -379,8 +379,8 @@ static int text_unlink_exec(bContext *C, wmOperator *UNUSED(op)) } } - unlink_text(bmain, text); - free_libblock(&bmain->text, text); + BKE_text_unlink(bmain, text); + BKE_libblock_free(&bmain->text, text); text_drawcache_tag_update(st, 1); WM_event_add_notifier(C, NC_TEXT | NA_REMOVED, NULL); @@ -1156,7 +1156,7 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) } else { new_line[j] = text_check_line[a]; - ++j; + j++; } } new_line[j] = '\0'; @@ -1208,12 +1208,12 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op) if (!number) { //found all number of space to equal a tab new_line[extra] = '\t'; a = a + (st->tabnumber - 1); - ++extra; + extra++; } else { //not adding a tab new_line[extra] = text_check_line[a]; - ++extra; + extra++; } } new_line[extra] = '\0'; @@ -1361,7 +1361,7 @@ void TEXT_OT_move_lines(wmOperatorType *ot) /* identifiers */ ot->name = "Move Lines"; ot->idname = "TEXT_OT_move_lines"; - ot->description = "Moves the currently selected line(s) up/down"; + ot->description = "Move the currently selected line(s) up/down"; /* api callbacks */ ot->exec = move_lines_exec; diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 43a4a9a1de9..9e44d5207c0 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -73,15 +73,15 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) */ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - glColor4f(0.0f, 0.0f, 0.0f, 0.4f); + glColor4f(0.0f, 0.0f, 0.0f, 0.4f); - if (PSFRA < PEFRA) { - glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); - glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } - else { - glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); - } + if (PSFRA < PEFRA) { + glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)PSFRA, v2d->cur.ymax); + glRectf((float)PEFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } + else { + glRectf(v2d->cur.xmin, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); + } glDisable(GL_BLEND); UI_ThemeColorShade(TH_BACK, -60); @@ -90,14 +90,14 @@ static void time_draw_sfra_efra(Scene *scene, View2D *v2d) fdrawline((float)PEFRA, v2d->cur.ymin, (float)PEFRA, v2d->cur.ymax); } -#define CACHE_DRAW_HEIGHT 3.0f +#define CACHE_DRAW_HEIGHT 3.0f static void time_draw_cache(SpaceTime *stime, Object *ob) { PTCacheID *pid; ListBase pidlist; SpaceTimeCache *stc = stime->caches.first; - float yoffs=0.f; + float yoffs = 0.f; if (!(stime->cache_display & TIME_CACHE_DISPLAY) || (!ob)) return; @@ -106,27 +106,27 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) /* iterate over pointcaches on the active object, * add spacetimecache and vertex array for each */ - for (pid=pidlist.first; pid; pid=pid->next) { + for (pid = pidlist.first; pid; pid = pid->next) { float col[4], *fp; int i, sta = pid->cache->startframe, end = pid->cache->endframe; - int len = (end - sta + 1)*4; + int len = (end - sta + 1) * 4; switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: if (!(stime->cache_display & TIME_CACHE_SOFTBODY)) continue; break; case PTCACHE_TYPE_PARTICLES: - if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; + if (!(stime->cache_display & TIME_CACHE_PARTICLES)) continue; break; case PTCACHE_TYPE_CLOTH: - if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; + if (!(stime->cache_display & TIME_CACHE_CLOTH)) continue; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: - if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; + if (!(stime->cache_display & TIME_CACHE_SMOKE)) continue; break; case PTCACHE_TYPE_DYNAMICPAINT: - if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; + if (!(stime->cache_display & TIME_CACHE_DYNAMICPAINT)) continue; break; } @@ -134,7 +134,7 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) continue; /* make sure we have stc with correct array length */ - if (stc == NULL || MEM_allocN_len(stc->array) != len*2*sizeof(float)) { + if (stc == NULL || MEM_allocN_len(stc->array) != len * 2 * sizeof(float)) { if (stc) { MEM_freeN(stc->array); } @@ -143,59 +143,59 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) BLI_addtail(&stime->caches, stc); } - stc->array = MEM_callocN(len*2*sizeof(float), "SpaceTimeCache array"); + stc->array = MEM_callocN(len * 2 * sizeof(float), "SpaceTimeCache array"); } /* fill the vertex array with a quad for each cached frame */ - for (i=sta, fp=stc->array; i<=end; i++) { - if (pid->cache->cached_frames[i-sta]) { - fp[0] = (float)i-0.5f; + for (i = sta, fp = stc->array; i <= end; i++) { + if (pid->cache->cached_frames[i - sta]) { + fp[0] = (float)i - 0.5f; fp[1] = 0.0; - fp+=2; + fp += 2; - fp[0] = (float)i-0.5f; + fp[0] = (float)i - 0.5f; fp[1] = 1.0; - fp+=2; + fp += 2; - fp[0] = (float)i+0.5f; + fp[0] = (float)i + 0.5f; fp[1] = 1.0; - fp+=2; + fp += 2; - fp[0] = (float)i+0.5f; + fp[0] = (float)i + 0.5f; fp[1] = 0.0; - fp+=2; + fp += 2; } } glPushMatrix(); - glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT+yoffs, 0.0); + glTranslatef(0.0, (float)V2D_SCROLL_HEIGHT + yoffs, 0.0); glScalef(1.0, CACHE_DRAW_HEIGHT, 0.0); switch (pid->type) { case PTCACHE_TYPE_SOFTBODY: - col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; + col[0] = 1.0; col[1] = 0.4; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_PARTICLES: - col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; + col[0] = 1.0; col[1] = 0.1; col[2] = 0.02; col[3] = 0.1; break; case PTCACHE_TYPE_CLOTH: - col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; + col[0] = 0.1; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; case PTCACHE_TYPE_SMOKE_DOMAIN: case PTCACHE_TYPE_SMOKE_HIGHRES: - col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; + col[0] = 0.2; col[1] = 0.2; col[2] = 0.2; col[3] = 0.1; break; case PTCACHE_TYPE_DYNAMICPAINT: - col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; + col[0] = 1.0; col[1] = 0.1; col[2] = 0.75; col[3] = 0.1; break; default: BLI_assert(0); - col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; + col[0] = 1.0; col[1] = 0.0; col[2] = 1.0; col[3] = 0.1; } glColor4fv(col); @@ -206,13 +206,13 @@ static void time_draw_cache(SpaceTime *stime, Object *ob) col[3] = 0.4f; if (pid->cache->flag & PTCACHE_BAKED) { - col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; + col[0] -= 0.4f; col[1] -= 0.4f; col[2] -= 0.4f; } glColor4fv(col); glEnableClientState(GL_VERTEX_ARRAY); glVertexPointer(2, GL_FLOAT, 0, stc->array); - glDrawArrays(GL_QUADS, 0, (fp-stc->array)/2); + glDrawArrays(GL_QUADS, 0, (fp - stc->array) / 2); glDisableClientState(GL_VERTEX_ARRAY); glDisable(GL_BLEND); @@ -240,7 +240,7 @@ static void time_cache_free(SpaceTime *stime) { SpaceTimeCache *stc; - for (stc= stime->caches.first; stc; stc=stc->next) { + for (stc = stime->caches.first; stc; stc = stc->next) { if (stc->array) { MEM_freeN(stc->array); stc->array = NULL; @@ -257,9 +257,9 @@ static void time_cache_refresh(SpaceTime *stime) } /* helper function - find actkeycolumn that occurs on cframe, or the nearest one if not found */ -static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) +static ActKeyColumn *time_cfra_find_ak(ActKeyColumn *ak, float cframe) { - ActKeyColumn *akn= NULL; + ActKeyColumn *akn = NULL; /* sanity checks */ if (ak == NULL) @@ -267,9 +267,9 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) /* check if this is a match, or whether it is in some subtree */ if (cframe < ak->cfra) - akn= time_cfra_find_ak(ak->left, cframe); + akn = time_cfra_find_ak(ak->left, cframe); else if (cframe > ak->cfra) - akn= time_cfra_find_ak(ak->right, cframe); + akn = time_cfra_find_ak(ak->right, cframe); /* if no match found (or found match), just use the current one */ if (akn == NULL) @@ -281,7 +281,7 @@ static ActKeyColumn *time_cfra_find_ak (ActKeyColumn *ak, float cframe) /* helper for time_draw_keyframes() */ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) { - bDopeSheet ads= {NULL}; + bDopeSheet ads = {NULL}; DLRBT_Tree keys; ActKeyColumn *ak; @@ -311,13 +311,13 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) * - draw within a single GL block to be faster */ glBegin(GL_LINES); - for ( ak=time_cfra_find_ak(keys.root, v2d->cur.xmin); - (ak) && (ak->cfra <= v2d->cur.xmax); - ak=ak->next ) - { - glVertex2f(ak->cfra, v2d->tot.ymin); - glVertex2f(ak->cfra, v2d->tot.ymax); - } + for (ak = time_cfra_find_ak(keys.root, v2d->cur.xmin); + (ak) && (ak->cfra <= v2d->cur.xmax); + ak = ak->next) + { + glVertex2f(ak->cfra, v2d->tot.ymin); + glVertex2f(ak->cfra, v2d->tot.ymax); + } glEnd(); // GL_LINES /* free temp stuff */ @@ -327,25 +327,25 @@ static void time_draw_idblock_keyframes(View2D *v2d, ID *id, short onlysel) /* draw keyframe lines for timeline */ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar) { - Scene *scene= CTX_data_scene(C); - Object *ob= CTX_data_active_object(C); - View2D *v2d= &ar->v2d; - short onlysel= (stime->flag & TIME_ONLYACTSEL); + Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + View2D *v2d = &ar->v2d; + short onlysel = (stime->flag & TIME_ONLYACTSEL); /* draw scene keyframes first * - don't try to do this when only drawing active/selected data keyframes, * since this can become quite slow */ - if (scene && onlysel==0) { + if (scene && onlysel == 0) { /* set draw color */ glColor3ub(0xDD, 0xA7, 0x00); time_draw_idblock_keyframes(v2d, (ID *)scene, onlysel); } /* draw keyframes from selected objects - * - only do the active object if in posemode (i.e. showing only keyframes for the bones) - * OR the onlysel flag was set, which means that only active object's keyframes should - * be considered + * - only do the active object if in posemode (i.e. showing only keyframes for the bones) + * OR the onlysel flag was set, which means that only active object's keyframes should + * be considered */ glColor3ub(0xDD, 0xD7, 0x00); @@ -357,14 +357,14 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar short active_done = 0; /* draw keyframes from all selected objects */ - CTX_DATA_BEGIN (C, Object*, obsel, selected_objects) + CTX_DATA_BEGIN (C, Object *, obsel, selected_objects) { /* last arg is 0, since onlysel doesn't apply here... */ time_draw_idblock_keyframes(v2d, (ID *)obsel, 0); /* if this object is the active one, set flag so that we don't draw again */ if (obsel == ob) - active_done= 1; + active_done = 1; } CTX_DATA_END; @@ -379,7 +379,7 @@ static void time_draw_keyframes(const bContext *C, SpaceTime *stime, ARegion *ar static void time_refresh(const bContext *UNUSED(C), ScrArea *sa) { /* find the main timeline region and refresh cache display*/ - ARegion *ar= BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); + ARegion *ar = BKE_area_find_region_type(sa, RGN_TYPE_WINDOW); if (ar) { SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_refresh(stime); @@ -410,19 +410,19 @@ static void time_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_refresh(sa); break; case ND_FRAME_RANGE: - { - ARegion *ar; - Scene *scene = wmn->reference; + { + ARegion *ar; + Scene *scene = wmn->reference; - for (ar= sa->regionbase.first; ar; ar= ar->next) { - if (ar->regiontype==RGN_TYPE_WINDOW) { - ar->v2d.tot.xmin = (float)(SFRA - 4); - ar->v2d.tot.xmax = (float)(EFRA + 4); - break; - } + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar->regiontype == RGN_TYPE_WINDOW) { + ar->v2d.tot.xmin = (float)(SFRA - 4); + ar->v2d.tot.xmax = (float)(EFRA + 4); + break; } } - break; + } + break; } case NC_SPACE: switch (wmn->data) { @@ -456,13 +456,13 @@ static void time_main_area_init(wmWindowManager *wm, ARegion *ar) static void time_main_area_draw(const bContext *C, ARegion *ar) { /* draw entirely, view changes should be handled here */ - Scene *scene= CTX_data_scene(C); - SpaceTime *stime= CTX_wm_space_time(C); + Scene *scene = CTX_data_scene(C); + SpaceTime *stime = CTX_wm_space_time(C); Object *obact = CTX_data_active_object(C); - View2D *v2d= &ar->v2d; + View2D *v2d = &ar->v2d; View2DGrid *grid; View2DScrollers *scrollers; - int unit, flag=0; + int unit, flag = 0; /* clear and setup matrix */ UI_ThemeClearColor(TH_BACK); @@ -471,9 +471,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_ortho(v2d); /* grid */ - unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS; - grid= UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); - UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS)); + unit = (stime->flag & TIME_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS; + grid = UI_view2d_grid_calc(scene, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY, ar->winx, ar->winy); + UI_view2d_grid_draw(v2d, grid, (V2D_VERTICAL_LINES | V2D_VERTICAL_AXIS)); UI_view2d_grid_free(grid); /* start and end frame */ @@ -481,8 +481,8 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) /* current frame */ flag = DRAWCFRA_WIDE; /* this is only really needed on frames where there's a keyframe, but this will do... */ - if ((stime->flag & TIME_DRAWFRAMES)==0) flag |= DRAWCFRA_UNIT_SECONDS; - if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; + if ((stime->flag & TIME_DRAWFRAMES) == 0) flag |= DRAWCFRA_UNIT_SECONDS; + if (stime->flag & TIME_CFRA_NUM) flag |= DRAWCFRA_SHOW_NUMBOX; ANIM_draw_cfra(C, v2d, flag); UI_view2d_view_ortho(v2d); @@ -501,7 +501,7 @@ static void time_main_area_draw(const bContext *C, ARegion *ar) UI_view2d_view_restore(C); /* scrollers */ - scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); + scrollers = UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY); UI_view2d_scrollers_draw(C, v2d, scrollers); UI_view2d_scrollers_free(scrollers); } @@ -528,7 +528,7 @@ static void time_main_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYINGSET: case ND_RENDER_OPTIONS: ED_region_tag_redraw(ar); - break; + break; } } } @@ -551,7 +551,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) /* context changes */ switch (wmn->category) { case NC_SCREEN: - if (wmn->data==ND_ANIMPLAY) + if (wmn->data == ND_ANIMPLAY) ED_region_tag_redraw(ar); break; @@ -563,7 +563,7 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) case ND_KEYINGSET: case ND_RENDER_OPTIONS: ED_region_tag_redraw(ar); - break; + break; } case NC_SPACE: @@ -577,57 +577,57 @@ static void time_header_area_listener(ARegion *ar, wmNotifier *wmn) static SpaceLink *time_new(const bContext *C) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); ARegion *ar; SpaceTime *stime; - stime= MEM_callocN(sizeof(SpaceTime), "inittime"); + stime = MEM_callocN(sizeof(SpaceTime), "inittime"); - stime->spacetype= SPACE_TIME; + stime->spacetype = SPACE_TIME; stime->flag |= TIME_DRAWFRAMES; /* header */ - ar= MEM_callocN(sizeof(ARegion), "header for time"); + ar = MEM_callocN(sizeof(ARegion), "header for time"); BLI_addtail(&stime->regionbase, ar); - ar->regiontype= RGN_TYPE_HEADER; - ar->alignment= RGN_ALIGN_BOTTOM; + ar->regiontype = RGN_TYPE_HEADER; + ar->alignment = RGN_ALIGN_BOTTOM; /* main area */ - ar= MEM_callocN(sizeof(ARegion), "main area for time"); + ar = MEM_callocN(sizeof(ARegion), "main area for time"); BLI_addtail(&stime->regionbase, ar); - ar->regiontype= RGN_TYPE_WINDOW; + ar->regiontype = RGN_TYPE_WINDOW; ar->v2d.tot.xmin = (float)(SFRA - 4); ar->v2d.tot.ymin = 0.0f; ar->v2d.tot.xmax = (float)(EFRA + 4); ar->v2d.tot.ymax = 50.0f; - ar->v2d.cur= ar->v2d.tot; + ar->v2d.cur = ar->v2d.tot; - ar->v2d.min[0]= 1.0f; - ar->v2d.min[1]= 50.0f; + ar->v2d.min[0] = 1.0f; + ar->v2d.min[1] = 50.0f; - ar->v2d.max[0]= MAXFRAMEF; - ar->v2d.max[1]= 50.0; + ar->v2d.max[0] = MAXFRAMEF; + ar->v2d.max[1] = 50.0; - ar->v2d.minzoom= 0.1f; - ar->v2d.maxzoom= 10.0; + ar->v2d.minzoom = 0.1f; + ar->v2d.maxzoom = 10.0; - ar->v2d.scroll |= (V2D_SCROLL_BOTTOM|V2D_SCROLL_SCALE_HORIZONTAL); + ar->v2d.scroll |= (V2D_SCROLL_BOTTOM | V2D_SCROLL_SCALE_HORIZONTAL); ar->v2d.align |= V2D_ALIGN_NO_NEG_Y; ar->v2d.keepofs |= V2D_LOCKOFS_Y; ar->v2d.keepzoom |= V2D_LOCKZOOM_Y; - return (SpaceLink*)stime; + return (SpaceLink *)stime; } /* not spacelink itself */ static void time_free(SpaceLink *sl) { - SpaceTime *stime= (SpaceTime *)sl; + SpaceTime *stime = (SpaceTime *)sl; time_cache_free(stime); } @@ -636,20 +636,20 @@ static void time_free(SpaceLink *sl) /* validate spacedata, add own area level handlers */ static void time_init(wmWindowManager *UNUSED(wm), ScrArea *sa) { - SpaceTime *stime= (SpaceTime *)sa->spacedata.first; + SpaceTime *stime = (SpaceTime *)sa->spacedata.first; time_cache_free(stime); /* enable all cache display */ stime->cache_display |= TIME_CACHE_DISPLAY; - stime->cache_display |= (TIME_CACHE_SOFTBODY|TIME_CACHE_PARTICLES); - stime->cache_display |= (TIME_CACHE_CLOTH|TIME_CACHE_SMOKE|TIME_CACHE_DYNAMICPAINT); + stime->cache_display |= (TIME_CACHE_SOFTBODY | TIME_CACHE_PARTICLES); + stime->cache_display |= (TIME_CACHE_CLOTH | TIME_CACHE_SMOKE | TIME_CACHE_DYNAMICPAINT); } static SpaceLink *time_duplicate(SpaceLink *sl) { - SpaceTime *stime= (SpaceTime *)sl; - SpaceTime *stimen= MEM_dupallocN(stime); + SpaceTime *stime = (SpaceTime *)sl; + SpaceTime *stimen = MEM_dupallocN(stime); stimen->caches.first = stimen->caches.last = NULL; @@ -660,41 +660,41 @@ static SpaceLink *time_duplicate(SpaceLink *sl) /* it defines all callbacks to maintain spaces */ void ED_spacetype_time(void) { - SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time"); + SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype time"); ARegionType *art; - st->spaceid= SPACE_TIME; + st->spaceid = SPACE_TIME; strncpy(st->name, "Timeline", BKE_ST_MAXNAME); - st->new= time_new; - st->free= time_free; - st->init= time_init; - st->duplicate= time_duplicate; - st->operatortypes= time_operatortypes; - st->keymap= NULL; - st->listener= time_listener; - st->refresh= time_refresh; + st->new = time_new; + st->free = time_free; + st->init = time_init; + st->duplicate = time_duplicate; + st->operatortypes = time_operatortypes; + st->keymap = NULL; + st->listener = time_listener; + st->refresh = time_refresh; /* regions: main window */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION|ED_KEYMAP_FRAMES; + art->keymapflag = ED_KEYMAP_VIEW2D | ED_KEYMAP_MARKERS | ED_KEYMAP_ANIMATION | ED_KEYMAP_FRAMES; - art->init= time_main_area_init; - art->draw= time_main_area_draw; - art->listener= time_main_area_listener; - art->keymap= time_keymap; + art->init = time_main_area_init; + art->draw = time_main_area_draw; + art->listener = time_main_area_listener; + art->keymap = time_keymap; BLI_addhead(&st->regiontypes, art); /* regions: header */ - art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); + art = MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_HEADER; - art->prefsizey= HEADERY; - art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER; + art->prefsizey = HEADERY; + art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER; - art->init= time_header_area_init; - art->draw= time_header_area_draw; - art->listener= time_header_area_listener; + art->init = time_header_area_init; + art->draw = time_header_area_draw; + art->listener = time_header_area_listener; BLI_addhead(&st->regiontypes, art); BKE_spacetype_register(st); diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 1c1f7a69865..189c8bfc7d0 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -47,35 +47,35 @@ #include "time_intern.h" /* ****************** Start/End Frame Operators *******************************/ -static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_set_sfra_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int frame; if (scene == NULL) return OPERATOR_CANCELLED; - frame= CFRA; + frame = CFRA; /* if Preview Range is defined, set the 'start' frame for that */ if (PRVRANGEON) - scene->r.psfra= frame; + scene->r.psfra = frame; else - scene->r.sfra= frame; + scene->r.sfra = frame; if (PEFRA < frame) { if (PRVRANGEON) - scene->r.pefra= frame; + scene->r.pefra = frame; else - scene->r.efra= frame; + scene->r.efra = frame; } - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -static void TIME_OT_start_frame_set (wmOperatorType *ot) +static void TIME_OT_start_frame_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set Start Frame"; @@ -87,39 +87,39 @@ static void TIME_OT_start_frame_set (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } -static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_set_efra_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); int frame; if (scene == NULL) return OPERATOR_CANCELLED; - frame= CFRA; + frame = CFRA; /* if Preview Range is defined, set the 'end' frame for that */ if (PRVRANGEON) - scene->r.pefra= frame; + scene->r.pefra = frame; else - scene->r.efra= frame; + scene->r.efra = frame; if (PSFRA > frame) { if (PRVRANGEON) - scene->r.psfra= frame; + scene->r.psfra = frame; else - scene->r.sfra= frame; + scene->r.sfra = frame; } - WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene); + WM_event_add_notifier(C, NC_SCENE | ND_FRAME, scene); return OPERATOR_FINISHED; } -static void TIME_OT_end_frame_set (wmOperatorType *ot) +static void TIME_OT_end_frame_set(wmOperatorType *ot) { /* identifiers */ ot->name = "Set End Frame"; @@ -131,16 +131,16 @@ static void TIME_OT_end_frame_set (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************ View All Operator *******************************/ -static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) +static int time_view_all_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene= CTX_data_scene(C); - ARegion *ar= CTX_wm_region(C); - View2D *v2d= (ar) ? &ar->v2d : NULL; + Scene *scene = CTX_data_scene(C); + ARegion *ar = CTX_wm_region(C); + View2D *v2d = (ar) ? &ar->v2d : NULL; float extra; if (ELEM(NULL, scene, ar)) @@ -151,7 +151,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) v2d->cur.xmax = (float)PEFRA; /* we need an extra "buffer" factor on either side so that the endpoints are visible */ - extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin); + extra = 0.01f * (v2d->cur.xmax - v2d->cur.xmin); v2d->cur.xmin -= extra; v2d->cur.xmax += extra; @@ -161,7 +161,7 @@ static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op)) return OPERATOR_FINISHED; } -static void TIME_OT_view_all (wmOperatorType *ot) +static void TIME_OT_view_all(wmOperatorType *ot) { /* identifiers */ ot->name = "View All"; @@ -173,7 +173,7 @@ static void TIME_OT_view_all (wmOperatorType *ot) ot->poll = ED_operator_timeline_active; /* flags */ - ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ************************** registration **********************************/ diff --git a/source/blender/editors/space_view3d/drawanimviz.c b/source/blender/editors/space_view3d/drawanimviz.c index ca5b21012aa..f8d942b4fd1 100644 --- a/source/blender/editors/space_view3d/drawanimviz.c +++ b/source/blender/editors/space_view3d/drawanimviz.c @@ -88,38 +88,50 @@ void draw_motion_path_instance(Scene *scene, //RegionView3D *rv3d= ar->regiondata; bMotionPathVert *mpv, *mpv_start; int i, stepsize = avs->path_step; - int sfra, efra, len; - + int sfra, efra, sind, len; /* get frame ranges */ if (avs->path_type == MOTIONPATH_TYPE_ACFRA) { - int sind; - /* With "Around Current", we only choose frames from around - * the current frame to draw. However, this range is still - * restricted by the limits of the original path. + * the current frame to draw. */ sfra = CFRA - avs->path_bc; efra = CFRA + avs->path_ac; - if (sfra < mpath->start_frame) sfra = mpath->start_frame; - if (efra > mpath->end_frame) efra = mpath->end_frame; - - len = efra - sfra; - - sind = sfra - mpath->start_frame; - mpv_start = (mpath->points + sind); } else { - sfra = mpath->start_frame; - efra = sfra + mpath->length; - len = mpath->length; - mpv_start = mpath->points; + /* Use the current display range */ + sfra = avs->path_sf; + efra = avs->path_ef; } - + + /* no matter what, we can only show what is in the cache and no more + * - abort if whole range is past ends of path + * - otherwise clamp endpoints to extents of path + */ + if ((sfra > mpath->end_frame) || (efra < mpath->start_frame)) { + /* whole path is out of bounds */ + return; + } + + if (sfra < mpath->start_frame) { + /* start clamp */ + sfra = mpath->start_frame; + } + if (efra > mpath->end_frame) { + /* end clamp */ + efra = mpath->end_frame; + } + + len = efra - sfra; + if (len <= 0) { return; } - + + /* get pointers to parts of path */ + sind = sfra - mpath->start_frame; + mpv_start = (mpath->points + sind); + /* draw curve-line of path */ glShadeModel(GL_SMOOTH); @@ -258,7 +270,7 @@ void draw_motion_path_instance(Scene *scene, * unless an option is set to always use the whole action */ if ((pchan) && (avs->path_viewflag & MOTIONPATH_VIEW_KFACT) == 0) { - bActionGroup *agrp = action_groups_find_named(adt->action, pchan->name); + bActionGroup *agrp = BKE_action_group_find_name(adt->action, pchan->name); if (agrp) { agroup_to_keylist(adt, agrp, &keys, NULL); diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c index 15e6994dfe4..2211b1ddb62 100644 --- a/source/blender/editors/space_view3d/drawarmature.c +++ b/source/blender/editors/space_view3d/drawarmature.c @@ -2338,9 +2338,9 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2352,20 +2352,20 @@ static void draw_ghost_poses_range(Scene *scene, View3D *v3d, ARegion *ar, Base UI_ThemeColorShadeAlpha(TH_WIRE, 0, -128 - (int)(120.0 * sqrt(colfac))); BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; ob->ipoflag = ipoflago; } @@ -2415,9 +2415,9 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2431,7 +2431,7 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * CFRA = (int)ak->cfra; BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } glDisable(GL_BLEND); @@ -2439,13 +2439,13 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, ARegion *ar, Base * ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ BLI_dlrbTree_free(&keys); - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } @@ -2481,9 +2481,9 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) /* copy the pose */ poseo = ob->pose; - copy_pose(&posen, ob->pose, 1); + BKE_pose_copy_data(&posen, ob->pose, 1); ob->pose = posen; - armature_rebuild_pose(ob, ob->data); /* child pointers for IK */ + BKE_pose_rebuild(ob, ob->data); /* child pointers for IK */ ghost_poses_tag_unselected(ob, 0); /* hide unselected bones if need be */ glEnable(GL_BLEND); @@ -2501,7 +2501,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2516,7 +2516,7 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (CFRA != cfrao) { BKE_animsys_evaluate_animdata(scene, &ob->id, adt, (float)CFRA, ADT_RECALC_ALL); - where_is_pose(scene, ob); + BKE_pose_where_is(scene, ob); draw_pose_bones(scene, v3d, ar, base, OB_WIRE, TRUE, FALSE); } } @@ -2525,13 +2525,13 @@ static void draw_ghost_poses(Scene *scene, View3D *v3d, ARegion *ar, Base *base) if (v3d->zbuf) glEnable(GL_DEPTH_TEST); ghost_poses_tag_unselected(ob, 1); /* unhide unselected bones if need be */ - free_pose(posen); + BKE_pose_free(posen); /* restore */ CFRA = cfrao; ob->pose = poseo; arm->flag = flago; - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); ob->mode |= OB_MODE_POSE; } diff --git a/source/blender/editors/space_view3d/drawmesh.c b/source/blender/editors/space_view3d/drawmesh.c index 530b26d566a..b5c44fd1a8c 100644 --- a/source/blender/editors/space_view3d/drawmesh.c +++ b/source/blender/editors/space_view3d/drawmesh.c @@ -926,14 +926,14 @@ static int tex_mat_set_face_editmesh_cb(void *userData, int index) return !BM_elem_flag_test(efa, BM_ELEM_HIDDEN); } -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, const int draw_flags) { - if ((!scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { + if ((!BKE_scene_use_new_shading_nodes(scene)) || (draw_flags & DRAW_MODIFIERS_PREVIEW)) { draw_mesh_textured_old(scene, v3d, rv3d, ob, dm, draw_flags); return; } else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); return; } @@ -1002,51 +1002,79 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, Object *o /* Vertex Paint and Weight Paint */ -void draw_mesh_paint(RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, Object *ob, DerivedMesh *dm, int draw_flags) { DMSetDrawOptions facemask = NULL; Mesh *me = ob->data; + const short do_light = (v3d->drawtype >= OB_SOLID); /* hide faces in face select mode */ if (draw_flags & DRAW_FACE_SELECT) facemask = wpaint__setSolidDrawOptions_facemask; if (ob && ob->mode & OB_MODE_WEIGHT_PAINT) { - /* enforce default material settings */ - GPU_enable_material(0, NULL); - - /* but set default spec */ - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ - glColor3ub(120, 120, 120); - glDisable(GL_COLOR_MATERIAL); - /* diffuse */ - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - glEnable(GL_LIGHTING); - glEnable(GL_COLOR_MATERIAL); + if (do_light) { + /* enforce default material settings */ + GPU_enable_material(0, NULL); + + /* but set default spec */ + glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); + glEnable(GL_COLOR_MATERIAL); /* according manpages needed */ + glColor3ub(120, 120, 120); + glDisable(GL_COLOR_MATERIAL); + + /* diffuse */ + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_LIGHTING); + glEnable(GL_COLOR_MATERIAL); + } dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - glDisable(GL_COLOR_MATERIAL); - glDisable(GL_LIGHTING); + if (do_light) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); - GPU_disable_material(); + GPU_disable_material(); + } } else if (ob->mode & OB_MODE_VERTEX_PAINT) { - if (me->mloopcol) + if (me->mloopcol) { dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); + } else { glColor3f(1.0f, 1.0f, 1.0f); dm->drawMappedFaces(dm, facemask, GPU_enable_material, NULL, me, - DM_DRAW_ALWAYS_SMOOTH); + DM_DRAW_ALWAYS_SMOOTH); } } /* draw face selection on top */ - if (draw_flags & DRAW_FACE_SELECT) + if (draw_flags & DRAW_FACE_SELECT) { draw_mesh_face_select(rv3d, me, dm); + } + else if ((do_light == FALSE) || (ob->dtx & OB_DRAWWIRE)) { + + /* weight paint in solid mode, special case. focus on making the weights clear + * rather than the shading, this is also forced in wire view */ + + bglPolygonOffset(rv3d->dist, 1.0); + glDepthMask(0); // disable write in zbuffer, selected edge wires show better + + glEnable(GL_BLEND); + glColor4ub(255, 255, 255, 96); + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0xAAAA); + + dm->drawEdges(dm, 1, 1); + + bglPolygonOffset(rv3d->dist, 0.0); + glDepthMask(1); + glDisable(GL_LINE_STIPPLE); + glDisable(GL_BLEND); + } } diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index e9b7ef2c6ef..29e6b77e0d4 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -190,7 +190,7 @@ static int check_object_draw_texture(Scene *scene, View3D *v3d, int drawtype) return TRUE; /* textured solid */ - if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !scene_use_new_shading_nodes(scene)) + if (v3d->drawtype == OB_SOLID && (v3d->flag2 & V3D_SOLID_TEX) && !BKE_scene_use_new_shading_nodes(scene)) return TRUE; return FALSE; @@ -332,7 +332,7 @@ int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt) return 0; if (ob == OBACT && (ob && ob->mode & OB_MODE_WEIGHT_PAINT)) return 0; - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) return 0; return (scene->gm.matmode == GAME_MAT_GLSL) && (dt > OB_SOLID); @@ -1740,7 +1740,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base int i; float drawsize; const short is_view = (rv3d->persp == RV3D_CAMOB && ob == v3d->camera); - MovieClip *clip = object_get_movieclip(scene, base->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, base->object, 0); /* draw data for movie clip set as active for scene */ if (clip) { @@ -1763,7 +1763,7 @@ static void drawcamera(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base scale[2] = 1.0f / len_v3(ob->obmat[2]); BKE_camera_view_frame_ex(scene, cam, cam->drawsize, is_view, scale, - asp, shift, &drawsize, vec); + asp, shift, &drawsize, vec); glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); @@ -1924,7 +1924,7 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo Object *obedit = vc->obedit; Lattice *lt = obedit->data; BPoint *bp = lt->editlatt->latt->def; - DispList *dl = find_displist(&obedit->disp, DL_VERTS); + DispList *dl = BKE_displist_find(&obedit->disp, DL_VERTS); float *co = dl ? dl->verts : NULL; int i, N = lt->editlatt->latt->pntsu * lt->editlatt->latt->pntsv * lt->editlatt->latt->pntsw; short s[2] = {IS_CLIPPED, 0}; @@ -1971,8 +1971,8 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob) /* now we default make displist, this will modifiers work for non animated case */ if (ob->disp.first == NULL) - lattice_calc_modifiers(scene, ob); - dl = find_displist(&ob->disp, DL_VERTS); + BKE_lattice_modifiers_calc(scene, ob); + dl = BKE_displist_find(&ob->disp, DL_VERTS); if (is_edit) { lt = lt->editlatt->latt; @@ -2209,9 +2209,9 @@ void mesh_foreachScreenFace( } void nurbs_foreachScreenVert( - ViewContext *vc, - void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), - void *userData) + ViewContext *vc, + void (*func)(void *userData, Nurb *nu, BPoint *bp, BezTriple *bezt, int beztindex, int x, int y), + void *userData) { Curve *cu = vc->obedit->data; short s[2] = {IS_CLIPPED, 0}; @@ -2921,7 +2921,7 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS mul_v3_fl(vmid, 1.0f / (float)n); \ if (unit->system) \ bUnit_AsString(numstr, sizeof(numstr), \ - (double)(area * unit->scale_length), \ + (double)(area * unit->scale_length), \ 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ else \ BLI_snprintf(numstr, sizeof(numstr), conv_float, area); \ @@ -2971,35 +2971,45 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS UI_GetThemeColor3ubv(TH_DRAWEXTRA_FACEANG, col); - for (efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL); - efa; efa = BM_iter_step(&iter)) - { - BMIter liter; - BMLoop *loop; + BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { + const int is_face_sel = BM_elem_flag_test(efa, BM_ELEM_SELECT); - BM_face_calc_center_bounds(efa, vmid); + if (is_face_sel || do_moving) { + BMIter liter; + BMLoop *loop; + int cent_ok = FALSE; - for (loop = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa); - loop; loop = BM_iter_step(&liter)) - { - float v1[3], v2[3], v3[3]; + BM_ITER_ELEM(loop, &liter, efa, BM_LOOPS_OF_FACE) { + if (is_face_sel || (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) { + /* yes, we should avoid triple matrix multiply every vertex for 'global' */ + float angle; - copy_v3_v3(v1, loop->prev->v->co); - copy_v3_v3(v2, loop->v->co); - copy_v3_v3(v3, loop->next->v->co); + /* lazy init center calc */ + if (cent_ok == FALSE) { + BM_face_calc_center_bounds(efa, vmid); + cent_ok = TRUE; + } - if (do_global) { - mul_mat3_m4_v3(ob->obmat, v1); - mul_mat3_m4_v3(ob->obmat, v2); - mul_mat3_m4_v3(ob->obmat, v3); - } + if (do_global) { + copy_v3_v3(v1, loop->prev->v->co); + copy_v3_v3(v2, loop->v->co); + copy_v3_v3(v3, loop->next->v->co); - if ( (BM_elem_flag_test(efa, BM_ELEM_SELECT)) || - (do_moving && BM_elem_flag_test(loop->v, BM_ELEM_SELECT))) - { - BLI_snprintf(numstr, sizeof(numstr), "%.3g", RAD2DEGF(angle_v3v3v3(v1, v2, v3))); - interp_v3_v3v3(fvec, vmid, v2, 0.8f); - view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col); + mul_mat3_m4_v3(ob->obmat, v1); + mul_mat3_m4_v3(ob->obmat, v2); + mul_mat3_m4_v3(ob->obmat, v3); + + angle = angle_v3v3v3(v1, v2, v3); + interp_v3_v3v3(fvec, vmid, v2, 0.8f); + } + else { + angle = angle_v3v3v3(loop->prev->v->co, loop->v->co, loop->v->co); + interp_v3_v3v3(fvec, vmid, loop->v->co, 0.8f); + } + + BLI_snprintf(numstr, sizeof(numstr), "%.3f", RAD2DEGF(angle)); + view3d_cached_text_draw_add(fvec, numstr, 0, txt_flag, col); + } } } } @@ -3387,34 +3397,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_SOLID) { - if (is_obact && ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { - /* weight paint in solid mode, special case. focus on making the weights clear - * rather than the shading, this is also forced in wire view */ - GPU_enable_material(0, NULL); - dm->drawMappedFaces(dm, NULL, GPU_enable_material, NULL, me->mpoly, - DM_DRAW_USE_COLORS | DM_DRAW_ALWAYS_SMOOTH); - - bglPolygonOffset(rv3d->dist, 1.0); - glDepthMask(0); // disable write in zbuffer, selected edge wires show better - - glEnable(GL_BLEND); - glColor4ub(255, 255, 255, 96); - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0xAAAA); - - dm->drawEdges(dm, 1, 1); - - bglPolygonOffset(rv3d->dist, 0.0); - glDepthMask(1); - glDisable(GL_LINE_STIPPLE); - glDisable(GL_BLEND); - - GPU_disable_material(); - - /* since we already draw wire as wp guide, don't draw over the top */ - draw_wire = OBDRAW_WIRE_OFF; - } - else if (draw_flags & DRAW_MODIFIERS_PREVIEW) { + if (draw_flags & DRAW_MODIFIERS_PREVIEW) { /* for object selection draws no shade */ if (flag & (DRAW_PICKING | DRAW_CONSTCOLOR)) { dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material); @@ -3505,7 +3488,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D } } else if (dt == OB_PAINT) { - draw_mesh_paint(rv3d, ob, dm, draw_flags); + draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags); + + /* since we already draw wire as wp guide, don't draw over the top */ + draw_wire = OBDRAW_WIRE_OFF; } /* set default draw color back for wire or for draw-extra later on */ @@ -3629,8 +3615,8 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D finalDM->release(finalDM); } else { - /* don't create boundbox here with mesh_get_bb(), the derived system will make it, puts deformed bb's OK */ - if (me->totpoly <= 4 || ED_view3d_boundbox_clip(rv3d, ob->obmat, (ob->bb) ? ob->bb : me->bb)) { + /* ob->bb was set by derived mesh system, do NULL check just to be sure */ + if (me->totpoly <= 4 || (ob->bb && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb))) { glsl = draw_glsl_material(scene, ob, v3d, dt); check_alpha = check_alpha_pass(base); @@ -3947,10 +3933,10 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); index3_nors_incr = 0; - if (displist_has_faces(lb) == 0) { + if (BKE_displist_has_faces(lb) == 0) { if (!render_only) { draw_index_wire = 0; drawDispListwire(lb); @@ -3978,7 +3964,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas index3_nors_incr = 1; } else { - if (!render_only || (render_only && displist_has_faces(lb))) { + if (!render_only || (render_only && BKE_displist_has_faces(lb))) { draw_index_wire = 0; retval = drawDispListwire(lb); draw_index_wire = 1; @@ -3993,7 +3979,7 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas dl = lb->first; if (dl == NULL) return 1; - if (dl->nors == NULL) addnormalsDispList(lb); + if (dl->nors == NULL) BKE_displist_normals_add(lb); if (draw_glsl_material(scene, ob, v3d, dt)) { GPU_begin_object_materials(v3d, rv3d, scene, ob, 1, NULL); @@ -4012,9 +3998,9 @@ static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *bas break; case OB_MBALL: - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { lb = &ob->disp; - if (lb->first == NULL) makeDispListMBall(scene, ob); + if (lb->first == NULL) BKE_displist_make_mball(scene, ob); if (lb->first == NULL) return 1; if (solid) { @@ -4315,7 +4301,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv totpart = psys->totpart; - cfra = BKE_curframe(scene); + cfra = BKE_scene_frame_get(scene); if (draw_as == PART_DRAW_PATH && psys->pathcache == NULL && psys->childcache == NULL) draw_as = PART_DRAW_DOT; @@ -5530,7 +5516,7 @@ static void draw_editnurb(Object *ob, Nurb *nurb, int sel) } } - ++index; + index++; nu = nu->next; } } @@ -5559,7 +5545,7 @@ static void drawnurb(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base, tekenhandlesN_active(nu); tekenhandlesN(nu, 0, hide_handles); } - ++index; + index++; } draw_editnurb(ob, nurb, 0); draw_editnurb(ob, nurb, 1); @@ -6122,7 +6108,7 @@ static void draw_box(float vec[8][3]) #if 0 static void get_local_bounds(Object *ob, float center[3], float size[3]) { - BoundBox *bb = object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb == NULL) { zero_v3(center); @@ -6183,22 +6169,22 @@ static void draw_bounding_volume(Scene *scene, Object *ob, char type) BoundBox *bb = NULL; if (ob->type == OB_MESH) { - bb = mesh_get_bb(ob); + bb = BKE_mesh_boundbox_get(ob); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { bb = ob->bb ? ob->bb : ( (Curve *)ob->data)->bb; } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { bb = ob->bb; if (bb == NULL) { - makeDispListMBall(scene, ob); + BKE_displist_make_mball(scene, ob); bb = ob->bb; } } } else if (ob->type == OB_ARMATURE) { - bb = BKE_armature_get_bb(ob); + bb = BKE_armature_boundbox_get(ob); } else { drawcube(); @@ -6217,7 +6203,7 @@ static void drawtexspace(Object *ob) float vec[8][3], loc[3], size[3]; if (ob->type == OB_MESH) { - mesh_get_texspace(ob->data, loc, NULL, size); + BKE_mesh_texspace_get(ob->data, loc, NULL, size); } else if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { Curve *cu = ob->data; @@ -6265,7 +6251,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) hasfaces = dm->getNumTessFaces(dm); } else { - hasfaces = displist_has_faces(&ob->disp); + hasfaces = BKE_displist_has_faces(&ob->disp); } if (hasfaces && ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { @@ -6280,7 +6266,7 @@ static void drawObjectSelect(Scene *scene, View3D *v3d, ARegion *ar, Base *base) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { if ((base->flag & OB_FROMDUPLI) == 0) drawDispListwire(&ob->disp); } @@ -6340,7 +6326,7 @@ static void drawWireExtra(Scene *scene, RegionView3D *rv3d, Object *ob) } } else if (ob->type == OB_MBALL) { - if (BKE_metaball_is_basis(ob)) { + if (BKE_mball_is_basis(ob)) { drawDispListwire(&ob->disp); } } @@ -6465,7 +6451,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) view3d_cached_text_draw_begin(); /* patch? children objects with a timeoffs change the parents. How to solve! */ - /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) where_is_object(scene, ob); */ + /* if ( ((int)ob->ctime) != F_(scene->r.cfra)) BKE_object_where_is_calc(scene, ob); */ /* draw motion paths (in view space) */ if (ob->mpath && (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) { @@ -6575,8 +6561,10 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) zbufoff = 1; dt = OB_SOLID; } - else if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) + + if (ob->mode & (OB_MODE_VERTEX_PAINT | OB_MODE_WEIGHT_PAINT)) { dt = OB_PAINT; + } glEnable(GL_DEPTH_TEST); } @@ -6604,7 +6592,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) /* bad exception, solve this! otherwise outline shows too late */ if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) { /* still needed for curves hidden in other layers. depgraph doesnt handle that yet */ - if (ob->disp.first == NULL) makeDispListCurveTypes(scene, ob, 0); + if (ob->disp.first == NULL) BKE_displist_make_curveTypes(scene, ob, 0); } /* draw outline for selected objects, mesh does itself */ @@ -6677,7 +6665,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) setlinestyle(0); - if (BKE_font_getselection(ob, &selstart, &selend) && cu->selboxes) { + if (BKE_vfont_select_get(ob, &selstart, &selend) && cu->selboxes) { float selboxw; cpack(0xffffff); @@ -7171,7 +7159,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) for (ct = targets.first; ct; ct = ct->next) { /* calculate target's matrix */ if (cti->get_target_matrix) - cti->get_target_matrix(curcon, cob, ct, BKE_curframe(scene)); + cti->get_target_matrix(curcon, cob, ct, BKE_scene_frame_get(scene)); else unit_m4(ct->matrix); diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 72b67c2a716..28fd2c8bc74 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1016,7 +1016,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) break; } - // removed since BKE_image_user_calc_frame is now called in draw_bgpic because screen_ops doesnt call the notifier. + // removed since BKE_image_user_frame_calc is now called in draw_bgpic because screen_ops doesnt call the notifier. #if 0 if (wmn->category == NC_SCENE && wmn->data == ND_FRAME) { View3D *v3d = area->spacedata.first; @@ -1025,7 +1025,7 @@ static void space_view3d_listener(struct ScrArea *sa, struct wmNotifier *wmn) for (; bgpic; bgpic = bgpic->next) { if (bgpic->ima) { Scene *scene = wmn->reference; - BKE_image_user_calc_frame(&bgpic->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&bgpic->iuser, scene->r.cfra, 0); } } } @@ -1071,7 +1071,7 @@ static int view3d_context(const bContext *C, const char *member, bContextDataRes for (base = scene->base.first; base; base = base->next) { if ((base->flag & SELECT) && (base->lay & lay)) { if ((base->object->restrictflag & OB_RESTRICT_VIEW) == 0) { - if (0 == object_is_libdata(base->object)) { + if (0 == BKE_object_is_libdata(base->object)) { if (selected_editable_objects) CTX_data_id_list_add(result, &base->object->id); else diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index 13129616843..4a135f91d91 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -83,8 +83,8 @@ /* ******************* view3d space & buttons ************** */ -#define B_NOP 1 -#define B_REDR 2 +#define B_NOP 1 +#define B_REDR 2 #define B_OBJECTPANELMEDIAN 1008 /* temporary struct for storing transform properties */ @@ -595,7 +595,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float } else { bp->weight = scale_w > 0.0f ? bp->weight * scale_w : - 1.0f + ((1.0f - bp->weight) * scale_w); + 1.0f + ((1.0f - bp->weight) * scale_w); CLAMP(bp->weight, 0.0f, 1.0f); } } @@ -939,7 +939,7 @@ static void v3d_posearmature_buts(uiLayout *layout, Object *ob) PointerRNA pchanptr; uiLayout *col; - pchan = get_active_posechannel(ob); + pchan = BKE_pose_channel_active(ob); if (!pchan) { uiItemL(layout, IFACE_("No Bone Active"), ICON_NONE); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index f48b45f9793..682d8950440 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -102,7 +102,7 @@ static void star_stuff_init_func(void) glPointSize(1.0); glBegin(GL_POINTS); } -static void star_stuff_vertex_func(float*i) +static void star_stuff_vertex_func(float *i) { glVertex3fv(i); } @@ -716,7 +716,7 @@ static void draw_rotation_guide(RegionView3D *rv3d) glColor4fv(color); glBegin(GL_LINE_LOOP); for (i = 0, angle = 0.f; i < ROT_AXIS_DETAIL; ++i, angle += step) { - float p[3] = {s * cosf(angle), s * sinf(angle), 0.0f}; + float p[3] = {s *cosf(angle), s * sinf(angle), 0.0f}; if (!upright) { mul_qt_v3(q, p); @@ -847,7 +847,7 @@ static void draw_selected_name(Scene *scene, Object *ob) short offset = 30; /* get name of marker on current frame (if available) */ - markern = scene_find_marker_name(scene, CFRA); + markern = BKE_scene_find_marker_name(scene, CFRA); /* check if there is an object */ if (ob) { @@ -910,7 +910,7 @@ static void draw_selected_name(Scene *scene, Object *ob) } /* color depends on whether there is a keyframe */ - if (id_frame_has_keyframe((ID *)ob, /*BKE_curframe(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) + if (id_frame_has_keyframe((ID *)ob, /*BKE_scene_frame_get(scene)*/ (float)(CFRA), ANIMFILTER_KEYS_LOCAL)) UI_ThemeColor(TH_VERTEX_SELECT); else UI_ThemeColor(TH_TEXT_HI); @@ -1544,7 +1544,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) ima = bgpic->ima; if (ima == NULL) continue; - BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0); + BKE_image_user_frame_calc(&bgpic->iuser, CFRA, 0); ibuf = BKE_image_get_ibuf(ima, &bgpic->iuser); } else { @@ -1552,7 +1552,7 @@ static void draw_bgpic(Scene *scene, ARegion *ar, View3D *v3d, int foreground) if (bgpic->flag & V3D_BGPIC_CAMERACLIP) { if (scene->camera) - clip = object_get_movieclip(scene, scene->camera, 1); + clip = BKE_object_movieclip_get(scene, scene->camera, 1); } else clip = bgpic->clip; @@ -1699,7 +1699,7 @@ static void draw_bgpics(Scene *scene, ARegion *ar, View3D *v3d, int foreground) } } else { - draw_bgpic(scene, ar, v3d, foreground); + draw_bgpic(scene, ar, v3d, foreground); } } @@ -1861,12 +1861,12 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas * offset feature (used in group-duplicate.blend but no longer works in 2.5) * so for now it should be ok to - campbell */ - if (/* if this is the last no need to make a displist */ + if ( /* if this is the last no need to make a displist */ (dob_next == NULL || dob_next->ob != dob->ob) || /* lamp drawing messes with matrices, could be handled smarter... but this works */ (dob->ob->type == OB_LAMP) || (dob->type == OB_DUPLIGROUP && dob->animated) || - !(bb_tmp = object_get_boundbox(dob->ob))) + !(bb_tmp = BKE_object_boundbox_get(dob->ob))) { // printf("draw_dupli_objects_color: skipping displist for %s\n", dob->ob->id.name+2); use_displist = 0; @@ -1876,7 +1876,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas bb = *bb_tmp; /* must make a copy */ /* disable boundbox check for list creation */ - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 1); /* need this for next part of code */ unit_m4(dob->ob->obmat); /* obmat gets restored */ @@ -1886,7 +1886,7 @@ static void draw_dupli_objects_color(Scene *scene, ARegion *ar, View3D *v3d, Bas glEndList(); use_displist = 1; - object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); + BKE_object_boundbox_flag(dob->ob, OB_BB_DISABLED, 0); } } if (use_displist) { @@ -2043,7 +2043,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d) RegionView3D *rv3d = ar->regiondata; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2078,7 +2078,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (*func)(void *)) U.obcenter_dia = 0; setwinmatrixview3d(ar, v3d, NULL); /* 0= no pick rect */ - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); invert_m4_m4(rv3d->persinv, rv3d->persmat); @@ -2297,7 +2297,7 @@ CustomDataMask ED_view3d_datamask(Scene *scene, View3D *v3d) { mask |= CD_MASK_MTFACE | CD_MASK_MCOL; - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { if (v3d->drawtype == OB_MATERIAL) mask |= CD_MASK_ORCO; } @@ -2367,7 +2367,7 @@ void ED_view3d_update_viewmat(Scene *scene, View3D *v3d, ARegion *ar, float view if (viewmat) copy_m4_m4(rv3d->viewmat, viewmat); else - setviewmatrixview3d(scene, v3d, rv3d); /* note: calls where_is_object for camera... */ + setviewmatrixview3d(scene, v3d, rv3d); /* note: calls BKE_object_where_is_calc for camera... */ /* update utilitity matrices */ mult_m4_m4m4(rv3d->persmat, rv3d->winmat, rv3d->viewmat); @@ -2556,7 +2556,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, /* transp and X-ray afterdraw stuff */ if (v3d->afterdraw_transp.first) view3d_draw_transp(scene, ar, v3d); - if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); // clears zbuffer if it is used! + if (v3d->afterdraw_xray.first) view3d_draw_xray(scene, ar, v3d, 1); /* clears zbuffer if it is used! */ if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); if (rv3d->rflag & RV3D_CLIPPING) diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ea4d28ce32f..60a0d3bf12b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -56,6 +56,8 @@ #include "BKE_report.h" #include "BKE_scene.h" #include "BKE_screen.h" +#include "BKE_action.h" +#include "BKE_armature.h" #include "BKE_depsgraph.h" /* for ED_view3d_camera_lock_sync */ @@ -68,6 +70,7 @@ #include "RNA_access.h" #include "RNA_define.h" +#include "ED_armature.h" #include "ED_particle.h" #include "ED_screen.h" #include "ED_transform.h" @@ -121,9 +124,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) mult_m4_m4m4(parent_mat, diff_mat, root_parent->obmat); - object_tfm_protected_backup(root_parent, &obtfm); - object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); - object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); + BKE_object_tfm_protected_backup(root_parent, &obtfm); + BKE_object_apply_mat4(root_parent, parent_mat, TRUE, FALSE); + BKE_object_tfm_protected_restore(root_parent, &obtfm, root_parent->protectflag); ob_update = v3d->camera; while (ob_update) { @@ -133,9 +136,9 @@ int ED_view3d_camera_lock_sync(View3D *v3d, RegionView3D *rv3d) } } else { - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); WM_main_add_notifier(NC_OBJECT | ND_TRANSFORM, v3d->camera); @@ -983,12 +986,12 @@ void VIEW3D_OT_rotate(wmOperatorType *ot) /* NDOF utility functions * (should these functions live in this file?) */ -float ndof_to_axis_angle(struct wmNDOFMotionData*ndof, float axis[3]) +float ndof_to_axis_angle(struct wmNDOFMotionData *ndof, float axis[3]) { return ndof->dt * normalize_v3_v3(axis, ndof->rvec); } -void ndof_to_quat(struct wmNDOFMotionData*ndof, float q[4]) +void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4]) { float axis[3]; float angle; @@ -1007,8 +1010,8 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D*rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -1159,8 +1162,8 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event) return OPERATOR_CANCELLED; else { View3D *v3d = CTX_wm_view3d(C); - RegionView3D*rv3d = CTX_wm_region_view3d(C); - wmNDOFMotionData*ndof = (wmNDOFMotionData *) event->customdata; + RegionView3D *rv3d = CTX_wm_region_view3d(C); + wmNDOFMotionData *ndof = (wmNDOFMotionData *) event->customdata; ED_view3d_camera_lock_init(v3d, rv3d); @@ -2068,7 +2071,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in continue; } - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); } } if (!onedone) { @@ -2214,8 +2217,8 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) } /* account for duplis */ - if (minmax_object_duplis(scene, base->object, min, max) == 0) - minmax_object(base->object, min, max); /* use if duplis not found */ + if (BKE_object_minmax_dupli(scene, base->object, min, max) == 0) + BKE_object_minmax(base->object, min, max); /* use if duplis not found */ ok = 1; } @@ -2236,7 +2239,7 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) size = v3d->near * 1.5f; } } - else /* ortho */ { + else { /* ortho */ if (size < 0.0001f) { /* bounding box was a single point so do not zoom */ ok_dist = 0; @@ -2291,6 +2294,89 @@ void VIEW3D_OT_view_selected(wmOperatorType *ot) ot->flag = 0; } +static int view_lock_clear_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + + if (v3d) { + ED_view3D_lock_clear(v3d); + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_clear(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock Clear"; + ot->description = "Clear all view locking"; + ot->idname = "VIEW3D_OT_view_lock_clear"; + + /* api callbacks */ + ot->exec = view_lock_clear_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + +static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) +{ + View3D *v3d = CTX_wm_view3d(C); + Object *obact = CTX_data_active_object(C); + + if (v3d) { + + ED_view3D_lock_clear(v3d); + + v3d->ob_centre = obact; /* can be NULL */ + + if (obact && obact->type == OB_ARMATURE) { + if (obact->mode & OB_MODE_POSE) { + bPoseChannel *pcham_act = BKE_pose_channel_active(obact); + if (pcham_act) { + BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); + } + } + else { + EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; + if (ebone_act) { + BLI_strncpy(v3d->ob_centre_bone, ebone_act->name, sizeof(v3d->ob_centre_bone)); + } + } + } + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d); + + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +void VIEW3D_OT_view_lock_to_active(wmOperatorType *ot) +{ + + /* identifiers */ + ot->name = "View Lock to Active"; + ot->description = "Lock the view to the active object/bone"; + ot->idname = "VIEW3D_OT_view_lock_to_active"; + + /* api callbacks */ + ot->exec = view_lock_to_active_exec; + ot->poll = ED_operator_region_view3d_active; + + /* flags */ + ot->flag = 0; +} + static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) { View3D *v3d = CTX_wm_view3d(C); @@ -2851,7 +2937,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) v3d->camera = ob; if (v3d->camera == NULL) - v3d->camera = scene_find_camera(scene); + v3d->camera = BKE_scene_camera_find(scene); /* couldnt find any useful camera, bail out */ if (v3d->camera == NULL) @@ -3094,11 +3180,11 @@ static int background_image_add_invoke(bContext *C, wmOperator *op, wmEvent *UNU char path[FILE_MAX]; RNA_string_get(op->ptr, "filepath", path); - ima = BKE_add_image_file(path); + ima = BKE_image_load_exists(path); } else if (RNA_struct_property_is_set(op->ptr, "name")) { RNA_string_get(op->ptr, "name", name); - ima = (Image *)find_id("IM", name); + ima = (Image *)BKE_libblock_find_name(ID_IM, name); } bgpic = background_image_add(C); @@ -3671,7 +3757,7 @@ void ED_view3d_to_object(Object *ob, const float ofs[3], const float quat[4], co { float mat[4][4]; ED_view3d_to_m4(mat, ofs, quat, dist); - object_apply_mat4(ob, mat, TRUE, TRUE); + BKE_object_apply_mat4(ob, mat, TRUE, TRUE); } BGpic *ED_view3D_background_image_new(View3D *v3d) @@ -3709,3 +3795,11 @@ void ED_view3D_background_image_clear(View3D *v3d) bgpic = next_bgpic; } } + +void ED_view3D_lock_clear(View3D *v3d) +{ + v3d->ob_centre = NULL; + v3d->ob_centre_bone[0] = '\0'; + v3d->ob_centre_cursor = FALSE; + v3d->flag2 &= ~V3D_LOCK_CAMERA; +} diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 5b6624889c8..2dab26e7781 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -174,7 +174,7 @@ typedef struct FlyInfo { unsigned char use_freelook; int mval[2]; /* latest 2D mouse values */ - wmNDOFMotionData*ndof; /* latest 3D mouse values */ + wmNDOFMotionData *ndof; /* latest 3D mouse values */ /* fly state state */ float speed; /* the speed the view is moving per redraw */ @@ -366,9 +366,9 @@ static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event /* store the original camera loc and rot */ /* TODO. axis angle etc */ - fly->obtfm = object_tfm_backup(ob_back); + fly->obtfm = BKE_object_tfm_backup(ob_back); - where_is_object(fly->scene, fly->v3d->camera); + BKE_object_where_is_calc(fly->scene, fly->v3d->camera); negate_v3_v3(fly->rv3d->ofs, fly->v3d->camera->obmat[3]); fly->rv3d->dist = 0.0; @@ -429,7 +429,7 @@ static int flyEnd(bContext *C, FlyInfo *fly) ob_back = (fly->root_parent) ? fly->root_parent : fly->v3d->camera; /* store the original camera loc and rot */ - object_tfm_restore(ob_back, fly->obtfm); + BKE_object_tfm_restore(ob_back, fly->obtfm); DAG_id_tag_update(&ob_back->id, OB_RECALC_OB); } @@ -690,7 +690,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien { /* we are in camera view so apply the view ofs and quat to the view matrix and set the camera to the view */ - View3D*v3d = fly->v3d; + View3D *v3d = fly->v3d; Scene *scene = fly->scene; ID *id_key; @@ -709,9 +709,9 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); mult_m4_m4m4(diff_mat, view_mat, prev_view_imat); mult_m4_m4m4(parent_mat, diff_mat, fly->root_parent->obmat); - object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); + BKE_object_apply_mat4(fly->root_parent, parent_mat, TRUE, FALSE); - // where_is_object(scene, fly->root_parent); + // BKE_object_where_is_calc(scene, fly->root_parent); ob_update = v3d->camera->parent; while (ob_update) { @@ -724,7 +724,7 @@ static void move_camera(bContext *C, RegionView3D *rv3d, FlyInfo *fly, int orien else { float view_mat[4][4]; ED_view3d_to_m4(view_mat, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); + BKE_object_apply_mat4(v3d->camera, view_mat, TRUE, FALSE); id_key = &v3d->camera->id; } @@ -1031,7 +1031,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly) /* shorthand for oft-used variables */ wmNDOFMotionData *ndof = fly->ndof; const float dt = ndof->dt; - RegionView3D*rv3d = fly->rv3d; + RegionView3D *rv3d = fly->rv3d; const int flag = U.ndof_flag; #if 0 diff --git a/source/blender/editors/space_view3d/view3d_header.c b/source/blender/editors/space_view3d/view3d_header.c index c4309980b18..a68caeb0719 100644 --- a/source/blender/editors/space_view3d/view3d_header.c +++ b/source/blender/editors/space_view3d/view3d_header.c @@ -431,9 +431,10 @@ static int object_mode_icon(int mode) EnumPropertyItem *item = object_mode_items; while (item->name != NULL) { - if (item->value == mode) + if (item->value == mode) { return item->icon; - ++item; + } + item++; } return ICON_OBJECT_DATAMODE; diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 66b8ceb7a85..f387e1dd844 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -53,9 +53,9 @@ struct wmWindowManager; #define BL_NEAR_CLIP 0.001 /* drawing flags: */ -#define DRAW_PICKING 1 -#define DRAW_CONSTCOLOR 2 -#define DRAW_SCENESET 4 +#define DRAW_PICKING 1 +#define DRAW_CONSTCOLOR 2 +#define DRAW_SCENESET 4 /* draw_mesh_fancy/draw_mesh_textured draw_flags */ #define DRAW_MODIFIERS_PREVIEW 1 @@ -78,6 +78,8 @@ void VIEW3D_OT_ndof_pan(struct wmOperatorType *ot); void VIEW3D_OT_view_all(struct wmOperatorType *ot); void VIEW3D_OT_viewnumpad(struct wmOperatorType *ot); void VIEW3D_OT_view_selected(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_clear(struct wmOperatorType *ot); +void VIEW3D_OT_view_lock_to_active(struct wmOperatorType *ot); void VIEW3D_OT_view_center_cursor(struct wmOperatorType *ot); void VIEW3D_OT_view_center_camera(struct wmOperatorType *ot); void VIEW3D_OT_view_pan(struct wmOperatorType *ot); @@ -93,8 +95,8 @@ void VIEW3D_OT_render_border(struct wmOperatorType *ot); void VIEW3D_OT_zoom_border(struct wmOperatorType *ot); void view3d_boxview_copy(ScrArea *sa, ARegion *ar); -void ndof_to_quat(struct wmNDOFMotionData* ndof, float q[4]); -float ndof_to_axis_angle(struct wmNDOFMotionData* ndof, float axis[3]); +void ndof_to_quat(struct wmNDOFMotionData *ndof, float q[4]); +float ndof_to_axis_angle(struct wmNDOFMotionData *ndof, float axis[3]); /* view3d_fly.c */ void view3d_keymap(struct wmKeyConfig *keyconf); @@ -103,8 +105,8 @@ void VIEW3D_OT_fly(struct wmOperatorType *ot); /* drawanim.c */ void draw_motion_paths_init(View3D *v3d, struct ARegion *ar); void draw_motion_path_instance(Scene *scene, - struct Object *ob, struct bPoseChannel *pchan, - struct bAnimVizSettings *avs, struct bMotionPath *mpath); + struct Object *ob, struct bPoseChannel *pchan, + struct bAnimVizSettings *avs, struct bMotionPath *mpath); void draw_motion_paths_cleanup(View3D *v3d); @@ -118,23 +120,25 @@ void drawaxes(float size, char drawtype); void view3d_cached_text_draw_begin(void); void view3d_cached_text_draw_add(const float co[3], const char *str, short xoffs, short flag, const unsigned char col[4]); -void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, float mat[][4]); -#define V3D_CACHE_TEXT_ZBUF (1<<0) -#define V3D_CACHE_TEXT_WORLDSPACE (1<<1) -#define V3D_CACHE_TEXT_ASCII (1<<2) -#define V3D_CACHE_TEXT_GLOBALSPACE (1<<3) -#define V3D_CACHE_TEXT_LOCALCLIP (1<<4) +void view3d_cached_text_draw_end(View3D * v3d, ARegion * ar, int depth_write, float mat[][4]); +#define V3D_CACHE_TEXT_ZBUF (1 << 0) +#define V3D_CACHE_TEXT_WORLDSPACE (1 << 1) +#define V3D_CACHE_TEXT_ASCII (1 << 2) +#define V3D_CACHE_TEXT_GLOBALSPACE (1 << 3) +#define V3D_CACHE_TEXT_LOCALCLIP (1 << 4) /* drawarmature.c */ int draw_armature(Scene *scene, View3D *v3d, ARegion *ar, Base *base, int dt, int flag, const short is_outline); /* drawmesh.c */ -void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); -void draw_mesh_paint(RegionView3D *rv3d, struct Object *ob, struct DerivedMesh *dm, int faceselect); +void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); +void draw_mesh_paint(View3D *v3d, RegionView3D *rv3d, + struct Object *ob, struct DerivedMesh *dm, const int draw_flags); /* view3d_draw.c */ void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar); -void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (* func)(void *)); +void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (*func)(void *)); void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d); void add_view3d_after(ListBase *lb, Base *base, int flag); @@ -158,12 +162,12 @@ void VIEW3D_OT_localview(struct wmOperatorType *ot); void VIEW3D_OT_game_start(struct wmOperatorType *ot); -int ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[][4], struct BoundBox *bb); +int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[][4], struct BoundBox *bb); void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, float *ofs, float *quat, float *dist, float *lens); -void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ +void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d); void fly_modal_keymap(struct wmKeyConfig *keyconf); diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c index 99da487f923..f760254e8d2 100644 --- a/source/blender/editors/space_view3d/view3d_ops.c +++ b/source/blender/editors/space_view3d/view3d_ops.c @@ -72,6 +72,8 @@ void view3d_operatortypes(void) WM_operatortype_append(VIEW3D_OT_background_image_add); WM_operatortype_append(VIEW3D_OT_background_image_remove); WM_operatortype_append(VIEW3D_OT_view_selected); + WM_operatortype_append(VIEW3D_OT_view_lock_clear); + WM_operatortype_append(VIEW3D_OT_view_lock_to_active); WM_operatortype_append(VIEW3D_OT_view_center_cursor); WM_operatortype_append(VIEW3D_OT_view_center_camera); WM_operatortype_append(VIEW3D_OT_select); @@ -135,7 +137,10 @@ void view3d_keymap(wmKeyConfig *keyconf) WM_keymap_verify_item(keymap, "VIEW3D_OT_dolly", MIDDLEMOUSE, KM_PRESS, KM_CTRL | KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_view_center_cursor", PADPERIOD, KM_PRESS, KM_CTRL, 0); - + + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_to_active", PADPERIOD, KM_PRESS, KM_SHIFT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_view_lock_clear", PADPERIOD, KM_PRESS, KM_ALT, 0); + WM_keymap_verify_item(keymap, "VIEW3D_OT_fly", FKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_verify_item(keymap, "VIEW3D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index f106fcc268e..d7b03447d5b 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1407,7 +1407,7 @@ static int mouse_select(bContext *C, const int mval[2], short extend, short obce /* index of bundle is 1<<16-based. if there's no "bone" index * in hight word, this buffer value belongs to camera,. not to bundle */ if (buffer[4 * i + 3] & 0xFFFF0000) { - MovieClip *clip = object_get_movieclip(scene, basact->object, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, basact->object, 0); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase; MovieTrackingTrack *track; @@ -2055,7 +2055,7 @@ static int vertsel_vert_pick(struct bContext *C, Mesh *me, const int mval[2], un /* gets called via generic mouse select operator */ static int mouse_weight_paint_vertex_select(bContext *C, const int mval[2], short extend, Object *obact) { - Mesh*me = obact->data; /* already checked for NULL */ + Mesh *me = obact->data; /* already checked for NULL */ unsigned int index = 0; MVert *mv; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 87edf6a37a0..367b36db583 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -582,7 +582,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) mul_m4_v3(ob->imat, vec); /* Get location of grid point in pose space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* adjust location */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -613,7 +613,7 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + gridf *floorf(0.5f + ob->obmat[3][2] / gridf); if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -707,7 +707,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) if (pchan->bone->layer & arm->layer) { if ((pchan->bone->flag & BONE_CONNECTED) == 0) { /* Get position in pchan (pose) space. */ - armature_loc_pose_to_bone(pchan, vec, vec); + BKE_armature_loc_pose_to_bone(pchan, vec, vec); /* copy new position */ if ((pchan->protectflag & OB_LOCK_LOCX) == 0) @@ -738,7 +738,7 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) vec[2] = -ob->obmat[3][2] + curs[2]; if (ob->parent) { - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); invert_m3_m3(imat, originmat); mul_m3_v3(imat, vec); @@ -818,7 +818,7 @@ void VIEW3D_OT_snap_cursor_to_grid(wmOperatorType *ot) static void bundle_midpoint(Scene *scene, Object *ob, float vec[3]) { - MovieClip *clip = object_get_movieclip(scene, ob, 0); + MovieClip *clip = BKE_object_movieclip_get(scene, ob, 0); MovieTracking *tracking; MovieTrackingObject *object; int ok = 0; diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 733c5c55bfc..95ae0ac971f 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -358,11 +358,11 @@ static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) rv3d->lpersp = rv3d->persp; } - object_tfm_protected_backup(v3d->camera, &obtfm); + BKE_object_tfm_protected_backup(v3d->camera, &obtfm); ED_view3d_to_object(v3d->camera, rv3d->ofs, rv3d->viewquat, rv3d->dist); - object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); + BKE_object_tfm_protected_restore(v3d->camera, &obtfm, v3d->camera->protectflag); DAG_id_tag_update(&v3d->camera->id, OB_RECALC_OB); rv3d->persp = RV3D_CAMOB; @@ -421,9 +421,9 @@ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *UNUSED(o copy_v3_v3(obmat_new[3], r_co); /* only touch location */ - object_tfm_protected_backup(camera_ob, &obtfm); - object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); - object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); + BKE_object_tfm_protected_backup(camera_ob, &obtfm); + BKE_object_apply_mat4(camera_ob, obmat_new, TRUE, TRUE); + BKE_object_tfm_protected_restore(camera_ob, &obtfm, OB_LOCK_SCALE | OB_LOCK_ROT4D); /* notifiers */ DAG_id_tag_update(&camera_ob->id, OB_RECALC_OB); @@ -567,9 +567,9 @@ void ED_view3d_calc_clipping(BoundBox *bb, float planes[4][4], bglMats *mats, co if (flip_sign) negate_v3(planes[val]); - planes[val][3] = -planes[val][0] * bb->vec[val][0] - - planes[val][1] * bb->vec[val][1] - - planes[val][2] * bb->vec[val][2]; + planes[val][3] = -planes[val][0] * bb->vec[val][0] - + planes[val][1] * bb->vec[val][1] - + planes[val][2] * bb->vec[val][2]; } } @@ -1155,7 +1155,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) { if (rv3d->persp == RV3D_CAMOB) { /* obs/camera */ if (v3d->camera) { - where_is_object(scene, v3d->camera); + BKE_object_where_is_calc(scene, v3d->camera); obmat_to_viewmat(v3d, rv3d, v3d->camera, 0); } else { @@ -1176,7 +1176,7 @@ void setviewmatrixview3d(Scene *scene, View3D *v3d, RegionView3D *rv3d) copy_v3_v3(vec, ob->obmat[3]); if (ob->type == OB_ARMATURE && v3d->ob_centre_bone[0]) { - bPoseChannel *pchan = get_pose_channel(ob->pose, v3d->ob_centre_bone); + bPoseChannel *pchan = BKE_pose_channel_find_name(ob->pose, v3d->ob_centre_bone); if (pchan) { copy_v3_v3(vec, pchan->pose_mat[3]); mul_m4_v3(ob->obmat, vec); @@ -1412,7 +1412,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) } else { if (scene->obedit) { - minmax_object(scene->obedit, min, max); + BKE_object_minmax(scene->obedit, min, max); ok = 1; @@ -1422,7 +1422,7 @@ static void initlocalview(Main *bmain, Scene *scene, ScrArea *sa) else { for (base = FIRSTBASE; base; base = base->next) { if (TESTBASE(v3d, base)) { - minmax_object(base->object, min, max); + BKE_object_minmax(base->object, min, max); base->lay |= locallay; base->object->lay = base->lay; ok = 1; @@ -1799,8 +1799,8 @@ static int game_engine_exec(bContext *C, wmOperator *op) RestoreState(C, prevwin); //XXX restore_all_scene_cfra(scene_cfra_store); - set_scene_bg(CTX_data_main(C), startscene); - //XXX scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_set_background(CTX_data_main(C), startscene); + //XXX BKE_scene_update_for_newframe(bmain, scene, scene->lay); return OPERATOR_FINISHED; #else diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 599d4a559ed..b457d22a712 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -284,7 +284,7 @@ static void createTransTexspace(TransInfo *t) normalize_m3(td->axismtx); invert_m3_m3(td->smtx, td->mtx); - if (give_obdata_texspace(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { + if (BKE_object_obdata_texspace_get(ob, &texflag, &td->loc, &td->ext->size, &td->ext->rot)) { ob->dtx |= OB_TEXSPACE; *texflag &= ~ME_AUTOSPACE; } @@ -424,7 +424,7 @@ static short apply_targetless_ik(Object *ob) bone= parchan->bone; bone->flag |= BONE_TRANSFORM; /* ensures it gets an auto key inserted */ - armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); + BKE_armature_mat_pose_to_bone(parchan, parchan->pose_mat, rmat); /* apply and decompose, doesn't work for constraints or non-uniform scale well */ { @@ -535,11 +535,11 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr /* proper way to get parent transform + own transform + constraints transform */ copy_m3_m4(omat, ob->obmat); - /* New code, using "generic" pchan_to_pose_mat(). */ + /* New code, using "generic" BKE_pchan_to_pose_mat(). */ { float rotscale_mat[4][4], loc_mat[4][4]; - pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); + BKE_pchan_to_pose_mat(pchan, rotscale_mat, loc_mat); if (t->mode == TFM_TRANSLATION) copy_m3_m4(pmat, loc_mat); else @@ -884,7 +884,7 @@ static short pose_grab_with_ik_children(bPose *pose, Bone *bone) } } if (wentdeeper==0) { - bPoseChannel *pchan= get_pose_channel(pose, bone->name); + bPoseChannel *pchan= BKE_pose_channel_find_name(pose, bone->name); if (pchan) added+= pose_grab_with_ik_add(pchan); } @@ -953,7 +953,7 @@ static void createTransPose(TransInfo *t, Object *ob) t->total= 0; /* check validity of state */ - arm= get_armature(ob); + arm= BKE_armature_from_object(ob); if ((arm==NULL) || (ob->pose==NULL)) return; if (arm->flag & ARM_RESTPOS) { @@ -2181,7 +2181,7 @@ void flushTransNodes(TransInfo *t) void flushTransSeq(TransInfo *t) { - ListBase *seqbasep= seq_give_editing(t->scene, FALSE)->seqbasep; /* Editing null check already done */ + ListBase *seqbasep= BKE_sequencer_editing_get(t->scene, FALSE)->seqbasep; /* Editing null check already done */ int a, new_frame, old_start; TransData *td= NULL; TransData2D *td2d= NULL; @@ -3980,7 +3980,7 @@ static int SeqToTransData_Recursive(TransInfo *t, ListBase *seqbase, TransData * static void freeSeqData(TransInfo *t) { - Editing *ed= seq_give_editing(t->scene, FALSE); + Editing *ed= BKE_sequencer_editing_get(t->scene, FALSE); if (ed != NULL) { ListBase *seqbasep= ed->seqbasep; @@ -4086,7 +4086,7 @@ static void freeSeqData(TransInfo *t) } } - sort_seq(t->scene); + BKE_sequencer_sort(t->scene); } else { /* Cancelled, need to update the strips display */ @@ -4116,7 +4116,7 @@ static void createTransSeqData(bContext *C, TransInfo *t) View2D *v2d= UI_view2d_fromcontext(C); Scene *scene= t->scene; - Editing *ed= seq_give_editing(t->scene, FALSE); + Editing *ed= BKE_sequencer_editing_get(t->scene, FALSE); TransData *td = NULL; TransData2D *td2d= NULL; TransDataSeq *tdsq= NULL; @@ -4258,15 +4258,15 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) if (skip_invert == 0 && constinv == 0) { if (constinv == 0) - ob->transflag |= OB_NO_CONSTRAINTS; /* where_is_object_time checks this */ + ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */ - where_is_object(t->scene, ob); + BKE_object_where_is_calc(t->scene, ob); if (constinv == 0) ob->transflag &= ~OB_NO_CONSTRAINTS; } else - where_is_object(t->scene, ob); + BKE_object_where_is_calc(t->scene, ob); td->ob = ob; @@ -4320,7 +4320,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) * NOTE: some Constraints, and also Tracking should never get this * done, as it doesn't work well. */ - object_to_mat3(ob, obmtx); + BKE_object_to_mat3(ob, obmtx); copy_m3_m4(totmat, ob->obmat); invert_m3_m3(obinv, totmat); mul_m3_m3m3(td->smtx, obmtx, obinv); @@ -4357,12 +4357,12 @@ static void set_trans_object_base_flags(TransInfo *t) return; /* makes sure base flags and object flags are identical */ - copy_baseflags(t->scene); + BKE_scene_base_flag_to_objects(t->scene); /* handle pending update events, otherwise they got copied below */ for (base= scene->base.first; base; base= base->next) { if (base->object->recalc) - object_handle_update(t->scene, base->object); + BKE_object_handle_update(t->scene, base->object); } for (base= scene->base.first; base; base= base->next) { @@ -4375,7 +4375,7 @@ static void set_trans_object_base_flags(TransInfo *t) /* if parent selected, deselect */ while (parsel) { if (parsel->flag & SELECT) { - Base *parbase = object_in_scene(parsel, scene); + Base *parbase = BKE_scene_base_find(scene, parsel); if (parbase) { /* in rare cases this can fail */ if (TESTBASELIB_BGMODE(v3d, scene, parbase)) { break; @@ -5046,7 +5046,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * we need to update the pose otherwise no updates get called during * transform and the auto-ik is not applied. see [#26164] */ struct Object *pose_ob=t->poseobj; - where_is_pose(t->scene, pose_ob); + BKE_pose_where_is(t->scene, pose_ob); } /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */ @@ -5141,7 +5141,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* recalculating the frame positions means we loose our original transform if its not auto-keyed [#24451] * this hack re-applies it, which is annoying, only alternatives are... * - don't recalc paths. - * - have an object_handle_update() which gives is the new transform without touching the objects. + * - have an BKE_object_handle_update() which gives is the new transform without touching the objects. * - only recalc paths on auto-keying. * - ED_objects_recalculate_paths could backup/restore transforms. * - re-apply the transform which is simplest in this case. (2 lines below) @@ -5878,7 +5878,7 @@ void createTransData(bContext *C, TransInfo *t) * lines below just check is also visible */ Object *ob_armature= modifiers_isDeformedByArmature(ob); if (ob_armature && ob_armature->mode & OB_MODE_POSE) { - Base *base_arm= object_in_scene(ob_armature, t->scene); + Base *base_arm= BKE_scene_base_find(t->scene, ob_armature); if (base_arm) { View3D *v3d = t->view; if (BASE_VISIBLE(v3d, base_arm)) { diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index bea1002b5c6..b986bda4c13 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -833,7 +833,7 @@ static void recalcData_view3d(TransInfo *t) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ } else - where_is_pose(t->scene, ob); + BKE_pose_where_is(t->scene, ob); } else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { if (t->state != TRANS_CANCEL) { diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index 0f0d1cc8344..b25c76fe193 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -229,8 +229,9 @@ static void InputAngle(TransInfo *UNUSED(t), MouseInput *mi, const int mval[2], double *angle = mi->data; /* use doubles here, to make sure a "1.0" (no rotation) doesnt become 9.999999e-01, which gives 0.02 for acos */ - double deler = ((dx1*dx1+dy1*dy1)+(dx2*dx2+dy2*dy2)-(dx3*dx3+dy3*dy3)) - / (2.0 * ((A*B)?(A*B):1.0)); + double deler = (((dx1 * dx1 + dy1 * dy1) + + (dx2 * dx2 + dy2 * dy2) - + (dx3 * dx3 + dy3 * dy3)) / (2.0 * ((A * B) ? (A * B) : 1.0))); /* ((A*B)?(A*B):1.0) this takes care of potential divide by zero errors */ float dphi; @@ -290,15 +291,12 @@ void initMouseInput(TransInfo *UNUSED(t), MouseInput *mi, int center[2], int mva static void calcSpringFactor(MouseInput *mi) { - mi->factor = (float)sqrt( - ( - ((float)(mi->center[1] - mi->imval[1]))*((float)(mi->center[1] - mi->imval[1])) - + - ((float)(mi->center[0] - mi->imval[0]))*((float)(mi->center[0] - mi->imval[0])) - ) ); + mi->factor = sqrtf(((float)(mi->center[1] - mi->imval[1])) * ((float)(mi->center[1] - mi->imval[1])) + + ((float)(mi->center[0] - mi->imval[0])) * ((float)(mi->center[0] - mi->imval[0]))); - if (mi->factor==0.0f) + if (mi->factor == 0.0f) { mi->factor= 1.0f; /* prevent Inf */ + } } void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode) diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index 093c81c8d37..94f6640ca5b 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -203,7 +203,7 @@ int gimbal_axis(Object *ob, float gmat[][3]) { if (ob) { if (ob->mode & OB_MODE_POSE) { - bPoseChannel *pchan= get_active_posechannel(ob); + bPoseChannel *pchan= BKE_pose_channel_active(ob); if (pchan) { float mat[3][3], tmat[3][3], obmat[3][3]; diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index fa579293a73..b875886e80a 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -284,7 +284,7 @@ void applyProject(TransInfo *t) } else if (t->flag & T_OBJECT) { td->ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; - object_handle_update(t->scene, td->ob); + BKE_object_handle_update(t->scene, td->ob); copy_v3_v3(iloc, td->ob->obmat[3]); } @@ -966,7 +966,7 @@ static void TargetSnapClosest(TransInfo *t) if (t->flag & T_OBJECT) { int i; for (td = t->data, i = 0 ; i < t->total && td->flag & TD_SELECTED ; i++, td++) { - struct BoundBox *bb = object_get_boundbox(td->ob); + struct BoundBox *bb = BKE_object_boundbox_get(td->ob); /* use boundbox if possible */ if (bb) { @@ -1303,8 +1303,8 @@ static int snapDerivedMesh(short snap_mode, ARegion *ar, Object *ob, DerivedMesh * test against boundbox first * */ if (totface > 16) { - struct BoundBox *bb = object_get_boundbox(ob); - test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local); + struct BoundBox *bb = BKE_object_boundbox_get(ob); + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local); } if (test == 1) { @@ -1709,8 +1709,8 @@ static int peelDerivedMesh(Object *ob, DerivedMesh *dm, float obmat[][4], * test against boundbox first * */ if (totface > 16) { - struct BoundBox *bb = object_get_boundbox(ob); - test = ray_hit_boundbox(bb, ray_start_local, ray_normal_local); + struct BoundBox *bb = BKE_object_boundbox_get(ob); + test = BKE_boundbox_ray_hit_check(bb, ray_start_local, ray_normal_local); } if (test == 1) { diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index 5430a9a1c90..b0edc702e48 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -388,7 +388,7 @@ void crazyspace_build_sculpt(Scene *scene, Object *ob, float (**deformmats)[3][3 if (mti->deformMatrices && !deformed) continue; - mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0, 0); + mti->deformVerts(md, ob, NULL, deformedVerts, me->totvert, 0); deformed = 1; } } diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index 1f1d5a0c0c0..91290829662 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -221,7 +221,7 @@ char handleNumInput(NumInput *n, wmEvent *event) break; case MINUSKEY: if (n->flag & NUM_NO_NEGATIVE) - break; + return 0; if (n->ctrl[idx]) { n->ctrl[idx] *= -1; diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index b515f30e150..53bf19c04cc 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -186,7 +186,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im return; } - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { /* new shading system, assign image in material */ int sloppy = 1; BMFace *efa = BM_active_face_get(em->bm, sloppy); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 14c8420a8f5..7c05d08a774 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -402,7 +402,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0); derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd, - 0, NULL, 0, 0, 1); + NULL, SUBSURF_IN_EDIT_MODE); initialDerived->release(initialDerived); @@ -744,6 +744,8 @@ void UV_OT_pack_islands(wmOperatorType *ot) /* identifiers */ ot->name = "Pack Islands"; ot->idname = "UV_OT_pack_islands"; + ot->description = "Transform all islands so that they fill up the UV space as much as possible"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -784,6 +786,8 @@ void UV_OT_average_islands_scale(wmOperatorType *ot) /* identifiers */ ot->name = "Average Islands Scale"; ot->idname = "UV_OT_average_islands_scale"; + ot->description = "Average the size of separate UV islands, based on their area in 3D space"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1178,7 +1182,8 @@ static int unwrap_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_INFO, "Object scale is not 1.0. Unwrap will operate on a non-scaled version of the mesh."); /* remember last method for live unwrap */ - scene->toolsettings->unwrapper = method; + if (RNA_struct_property_is_set(op->ptr, "method")) + scene->toolsettings->unwrapper = method; scene->toolsettings->uv_subsurf_level = subsurf_level; @@ -1205,7 +1210,8 @@ void UV_OT_unwrap(wmOperatorType *ot) static EnumPropertyItem method_items[] = { {0, "ANGLE_BASED", 0, "Angle Based", ""}, {1, "CONFORMAL", 0, "Conformal", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* identifiers */ ot->name = "Unwrap"; @@ -1323,6 +1329,8 @@ void UV_OT_from_view(wmOperatorType *ot) /* identifiers */ ot->name = "Project From View"; ot->idname = "UV_OT_project_from_view"; + ot->description = "Project the UV vertices of the mesh as seen in current 3D view"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1362,6 +1370,8 @@ void UV_OT_reset(wmOperatorType *ot) /* identifiers */ ot->name = "Reset"; ot->idname = "UV_OT_reset"; + ot->description = "Reset UV projection"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1463,6 +1473,8 @@ void UV_OT_sphere_project(wmOperatorType *ot) /* identifiers */ ot->name = "Sphere Projection"; ot->idname = "UV_OT_sphere_project"; + ot->description = "Project the UV vertices of the mesh over the curved surface of a sphere"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1536,6 +1548,8 @@ void UV_OT_cylinder_project(wmOperatorType *ot) /* identifiers */ ot->name = "Cylinder Projection"; ot->idname = "UV_OT_cylinder_project"; + ot->description = "Project the UV vertices of the mesh over the curved wall of a cylinder"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ @@ -1614,6 +1628,8 @@ void UV_OT_cube_project(wmOperatorType *ot) /* identifiers */ ot->name = "Cube Projection"; ot->idname = "UV_OT_cube_project"; + ot->description = "Project the UV vertices of the mesh over the six faces of a cube"; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* api callbacks */ diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index adb46d857ba..f8c87fd0029 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -47,7 +47,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re, int render_count) char name[22]; snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name+2); - freestyle_scene = add_scene(name); + freestyle_scene = BKE_scene_add(name); freestyle_scene->r.cfra = old_scene->r.cfra; freestyle_scene->r.mode= old_scene->r.mode & ~( R_EDGE_FRS | R_SHADOW | R_SSS | R_PANORAMA | R_ENVMAP | R_MBLUR | R_BORDER ); @@ -80,10 +80,10 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re, int render_count) BLI_strncpy(freestyle_scene->r.engine, old_scene->r.engine, sizeof(freestyle_scene->r.engine)); freestyle_scene->r.im_format.planes = R_IMF_PLANES_RGBA; freestyle_scene->r.im_format.imtype = R_IMF_IMTYPE_PNG; - set_scene_bg( G.main, freestyle_scene ); + BKE_scene_set_background( G.main, freestyle_scene ); // Camera - Object* object_camera = add_object(freestyle_scene, OB_CAMERA); + Object* object_camera = BKE_object_add(freestyle_scene, OB_CAMERA); Camera* camera = (Camera *) object_camera->data; camera->type = CAM_ORTHO; @@ -104,7 +104,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render* re, int render_count) freestyle_scene->camera = object_camera; // Material - material = add_material("stroke_material"); + material = BKE_material_add("stroke_material"); material->mode |= MA_VERTEXCOLP; material->mode |= MA_TRANSP; material->mode |= MA_SHLESS; @@ -134,12 +134,12 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer(){ //cout << "removing " << name[0] << name[1] << ":" << (name+2) << endl; switch (ob->type) { case OB_MESH: - free_libblock( &G.main->object, ob ); - free_libblock( &G.main->mesh, data ); + BKE_libblock_free( &G.main->object, ob ); + BKE_libblock_free( &G.main->mesh, data ); break; case OB_CAMERA: - free_libblock( &G.main->object, ob ); - free_libblock( &G.main->camera, data ); + BKE_libblock_free( &G.main->object, ob ); + BKE_libblock_free( &G.main->camera, data ); freestyle_scene->camera = NULL; break; default: @@ -150,9 +150,9 @@ BlenderStrokeRenderer::~BlenderStrokeRenderer(){ BLI_freelistN( &freestyle_scene->base ); // release material - free_libblock( &G.main->mat, material ); + BKE_libblock_free( &G.main->mat, material ); - set_scene_bg( G.main, old_scene ); + BKE_scene_set_background( G.main, old_scene ); } float BlenderStrokeRenderer::get_stroke_vertex_z(void) const { @@ -223,11 +223,11 @@ void BlenderStrokeRenderer::RenderStrokeRepBasic(StrokeRep *iStrokeRep) const{ continue; // me = Mesh.New() - Object* object_mesh = add_object(freestyle_scene, OB_MESH); + Object* object_mesh = BKE_object_add(freestyle_scene, OB_MESH); Mesh* mesh = (Mesh *) object_mesh->data; - MEM_freeN(mesh->bb); - mesh->bb= NULL; - mesh->id.us = 0; + // MEM_freeN(mesh->bb); + // mesh->bb= NULL; + // mesh->id.us = 0; #if 1 // me.materials = [mat] diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h index 27880721762..93b5f694eb6 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h +++ b/source/blender/freestyle/intern/blender_interface/BlenderStyleModule.h @@ -20,8 +20,8 @@ public: } virtual ~BlenderStyleModule() { - unlink_text(G.main, _text); - free_libblock(&G.main->text, _text); + BKE_text_unlink(G.main, _text); + BKE_libblock_free(&G.main->text, _text); } protected: diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp index fbcea9ca164..c9a05019078 100644 --- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp +++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp @@ -172,12 +172,12 @@ extern "C" { { char *s1= escape_quotes(layer_name); char *s2= escape_quotes(lineset_name); - Text *text= add_empty_text(lineset_name); - write_text(text, "import parameter_editor; parameter_editor.process('"); - write_text(text, s1); - write_text(text, "', '"); - write_text(text, s2); - write_text(text, "')\n"); + Text *text= BKE_text_add(lineset_name); + BKE_text_write(text, "import parameter_editor; parameter_editor.process('"); + BKE_text_write(text, s1); + BKE_text_write(text, "', '"); + BKE_text_write(text, s2); + BKE_text_write(text, "')\n"); MEM_freeN(s1); MEM_freeN(s2); return text; diff --git a/source/blender/freestyle/intern/system/PythonInterpreter.h b/source/blender/freestyle/intern/system/PythonInterpreter.h index 24b03bd2dd3..81e2f70c82e 100755 --- a/source/blender/freestyle/intern/system/PythonInterpreter.h +++ b/source/blender/freestyle/intern/system/PythonInterpreter.h @@ -77,11 +77,11 @@ class LIB_SYSTEM_EXPORT PythonInterpreter : public Interpreter int status = BPY_filepath_exec(_context, fn, reports); #else int status; - Text *text = add_text(fn, G.main->name); + Text *text = BKE_text_load(fn, G.main->name); if (text) { status = BPY_text_exec(_context, text, reports, false); - unlink_text(G.main, text); - free_libblock(&G.main->text, text); + BKE_text_unlink(G.main, text); + BKE_libblock_free(&G.main->text, text); } else { BKE_reportf(reports, RPT_ERROR, "Cannot open file: %s", fn); status = 0; @@ -151,7 +151,7 @@ private: vector pathnames; StringUtils::getPathName(_path, "", pathnames); - struct Text *text = add_empty_text("tmp_freestyle_initpath.txt"); + struct Text *text = BKE_text_add("tmp_freestyle_initpath.txt"); string cmd = "import sys\n"; txt_insert_buf(text, const_cast(cmd.c_str())); @@ -166,8 +166,8 @@ private: BPY_text_exec(_context, text, NULL, false); // cleaning up - unlink_text(G.main, text); - free_libblock(&G.main->text, text); + BKE_text_unlink(G.main, text); + BKE_libblock_free(&G.main->text, text); //PyRun_SimpleString("from Freestyle import *"); _initialized = true; diff --git a/source/blender/gpu/GPU_buffers.h b/source/blender/gpu/GPU_buffers.h index cee9039e3f9..629283ce50d 100644 --- a/source/blender/gpu/GPU_buffers.h +++ b/source/blender/gpu/GPU_buffers.h @@ -39,12 +39,11 @@ #define DEBUG_VBO(X) #endif -struct DerivedMesh; -struct DMFlagMat; -struct DMGridData; +struct CCGElem; +struct CCGKey; struct CustomData; -struct GHash; -struct DMGridData; +struct DMFlagMat; +struct DerivedMesh; struct GPUVertPointLink; typedef struct GPUBuffer { @@ -164,14 +163,14 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], int *face_indices, int totface); void GPU_update_mesh_buffers(GPU_Buffers *buffers, struct MVert *mvert, - int *vert_indices, int totvert); + int *vert_indices, int totvert, const float *vmask); GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, unsigned int **grid_hidden, int gridsize); -void GPU_update_grid_buffers(GPU_Buffers *buffers, struct DMGridData **grids, +void GPU_update_grid_buffers(GPU_Buffers *buffers, struct CCGElem **grids, const struct DMFlagMat *grid_flag_mats, - int *grid_indices, int totgrid, int gridsize); + int *grid_indices, int totgrid, const struct CCGKey *key); void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial); diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 0b3ee03c8de..1e1043f1ee7 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -46,6 +46,7 @@ #include "DNA_meshdata_types.h" +#include "BKE_ccg.h" #include "BKE_DerivedMesh.h" #include "BKE_paint.h" #include "BKE_subsurf.h" @@ -104,8 +105,8 @@ static GPUBufferPool *gpu_buffer_pool_new(void) pool = MEM_callocN(sizeof(GPUBufferPool), "GPUBuffer"); pool->maxsize = MAX_FREE_GPU_BUFFERS; - pool->buffers = MEM_callocN(sizeof(GPUBuffer*)*pool->maxsize, - "GPUBuffer.buffers"); + pool->buffers = MEM_callocN(sizeof(GPUBuffer *) * pool->maxsize, + "GPUBuffer.buffers"); return pool; } @@ -120,7 +121,7 @@ static void gpu_buffer_pool_remove_index(GPUBufferPool *pool, int index) /* shift entries down, overwriting the buffer at `index' */ for (i = index; i < pool->totbuf - 1; i++) - pool->buffers[i] = pool->buffers[i+1]; + pool->buffers[i] = pool->buffers[i + 1]; /* clear the last entry */ if (pool->totbuf > 0) @@ -288,13 +289,13 @@ void GPU_buffer_free(GPUBuffer *buffer) if (pool->maxsize == pool->totbuf) { pool->maxsize += MAX_FREE_GPU_BUFFERS; pool->buffers = MEM_reallocN(pool->buffers, - sizeof(GPUBuffer*) * pool->maxsize); + sizeof(GPUBuffer *) * pool->maxsize); } } /* shift pool entries up by one */ for (i = pool->totbuf; i > 0; i--) - pool->buffers[i] = pool->buffers[i-1]; + pool->buffers[i] = pool->buffers[i - 1]; /* insert the buffer into the beginning of the pool */ pool->buffers[0] = buffer; @@ -318,7 +319,7 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in /* if first link is in use, add a new link at the end */ if (lnk->point_index != -1) { /* get last link */ - for (; lnk->next; lnk = lnk->next); + for (; lnk->next; lnk = lnk->next) ; /* add a new link from the pool */ lnk = lnk->next = &gdo->vert_points_mem[gdo->vert_points_usage]; @@ -331,9 +332,9 @@ static void gpu_drawobject_add_vert_point(GPUDrawObject *gdo, int vert_index, in /* update the vert_points and triangle_to_mface fields with a new * triangle */ static void gpu_drawobject_add_triangle(GPUDrawObject *gdo, - int base_point_index, - int face_index, - int v1, int v2, int v3) + int base_point_index, + int face_index, + int v1, int v2, int v3) { int i, v[3] = {v1, v2, v3}; for (i = 0; i < 3; i++) @@ -350,9 +351,9 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to /* allocate the array and space for links */ gdo->vert_points = MEM_callocN(sizeof(GPUVertPointLink) * gdo->totvert, - "GPUDrawObject.vert_points"); + "GPUDrawObject.vert_points"); gdo->vert_points_mem = MEM_callocN(sizeof(GPUVertPointLink) * gdo->tot_triangle_point, - "GPUDrawObject.vert_points_mem"); + "GPUDrawObject.vert_points_mem"); gdo->vert_points_usage = 0; /* build a map from the original material indices to the new @@ -369,13 +370,13 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to /* add triangle */ gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, - i, f->v1, f->v2, f->v3); + i, f->v1, f->v2, f->v3); mat->totpoint += 3; /* add second triangle for quads */ if (f->v4) { gpu_drawobject_add_triangle(gdo, mat->start + mat->totpoint, - i, f->v3, f->v4, f->v1); + i, f->v3, f->v4, f->v1); mat->totpoint += 3; } } @@ -391,7 +392,7 @@ static void gpu_drawobject_init_vert_points(GPUDrawObject *gdo, MFace *f, int to /* see GPUDrawObject's structure definition for a description of the * data being initialized here */ -GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) +GPUDrawObject *GPU_drawobject_new(DerivedMesh *dm) { GPUDrawObject *gdo; MFace *mface; @@ -399,11 +400,11 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) int i, curmat, curpoint, totface; mface = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); /* get the number of points used by each material, treating * each quad as two triangles */ - memset(points_per_mat, 0, sizeof(int)*MAX_MATERIALS); + memset(points_per_mat, 0, sizeof(int) * MAX_MATERIALS); for (i = 0; i < totface; i++) points_per_mat[mface[i].mat_nr] += mface[i].v4 ? 6 : 3; @@ -420,7 +421,7 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) /* allocate an array of materials used by this DerivedMesh */ gdo->materials = MEM_mallocN(sizeof(GPUBufferMaterial) * gdo->totmaterial, - "GPUDrawObject.materials"); + "GPUDrawObject.materials"); /* initialize the materials array */ for (i = 0, curmat = 0, curpoint = 0; i < MAX_MATERIALS; i++) { @@ -438,7 +439,7 @@ GPUDrawObject *GPU_drawobject_new( DerivedMesh *dm ) gdo->tot_triangle_point = curpoint; gdo->triangle_to_mface = MEM_mallocN(sizeof(int) * (gdo->tot_triangle_point / 3), - "GPUDrawObject.triangle_to_mface"); + "GPUDrawObject.triangle_to_mface"); gpu_drawobject_init_vert_points(gdo, mface, totface); @@ -493,8 +494,8 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, if (dm->drawObject->legacy) return NULL; - cur_index_per_mat = MEM_mallocN(sizeof(int)*object->totmaterial, - "GPU_buffer_setup.cur_index_per_mat"); + cur_index_per_mat = MEM_mallocN(sizeof(int) * object->totmaterial, + "GPU_buffer_setup.cur_index_per_mat"); for (i = 0; i < object->totmaterial; i++) { /* for each material, the current index to copy data to */ cur_index_per_mat[i] = object->materials[i].start * vector_size; @@ -518,7 +519,7 @@ static GPUBuffer *gpu_buffer_setup(DerivedMesh *dm, GPUDrawObject *object, /* failed to map the buffer; delete it */ GPU_buffer_free(buffer); gpu_buffer_pool_delete_last(pool); - buffer= NULL; + buffer = NULL; /* try freeing an entry from the pool * and reallocating the buffer */ @@ -578,31 +579,31 @@ static void GPU_buffer_copy_vertex(DerivedMesh *dm, float *varray, int *index, i mvert = dm->getVertArray(dm); f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); for (i = 0; i < totface; i++, f++) { start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ copy_v3_v3(&varray[start], mvert[f->v1].co); - copy_v3_v3(&varray[start+3], mvert[f->v2].co); - copy_v3_v3(&varray[start+6], mvert[f->v3].co); + copy_v3_v3(&varray[start + 3], mvert[f->v2].co); + copy_v3_v3(&varray[start + 6], mvert[f->v3].co); index[mat_orig_to_new[f->mat_nr]] += 9; if (f->v4) { /* v3 v4 v1 */ - copy_v3_v3(&varray[start+9], mvert[f->v3].co); - copy_v3_v3(&varray[start+12], mvert[f->v4].co); - copy_v3_v3(&varray[start+15], mvert[f->v1].co); + copy_v3_v3(&varray[start + 9], mvert[f->v3].co); + copy_v3_v3(&varray[start + 12], mvert[f->v4].co); + copy_v3_v3(&varray[start + 15], mvert[f->v1].co); index[mat_orig_to_new[f->mat_nr]] += 9; } } /* copy loose points */ - j = dm->drawObject->tot_triangle_point*3; + j = dm->drawObject->tot_triangle_point * 3; for (i = 0; i < dm->drawObject->totvert; i++) { if (dm->drawObject->vert_points[i].point_index >= dm->drawObject->tot_triangle_point) { copy_v3_v3(&varray[j], mvert[i].co); - j+=3; + j += 3; } } } @@ -613,11 +614,11 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i int start; float f_no[3]; - float *nors= dm->getTessFaceDataArray(dm, CD_NORMAL); + float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL); MVert *mvert = dm->getVertArray(dm); MFace *f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); + totface = dm->getNumTessFaces(dm); for (i = 0; i < totface; i++, f++) { const int smoothnormal = (f->flag & ME_SMOOTH); @@ -627,25 +628,25 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i if (smoothnormal) { /* copy vertex normal */ normal_short_to_float_v3(&varray[start], mvert[f->v1].no); - normal_short_to_float_v3(&varray[start+3], mvert[f->v2].no); - normal_short_to_float_v3(&varray[start+6], mvert[f->v3].no); + normal_short_to_float_v3(&varray[start + 3], mvert[f->v2].no); + normal_short_to_float_v3(&varray[start + 6], mvert[f->v3].no); if (f->v4) { - normal_short_to_float_v3(&varray[start+9], mvert[f->v3].no); - normal_short_to_float_v3(&varray[start+12], mvert[f->v4].no); - normal_short_to_float_v3(&varray[start+15], mvert[f->v1].no); + normal_short_to_float_v3(&varray[start + 9], mvert[f->v3].no); + normal_short_to_float_v3(&varray[start + 12], mvert[f->v4].no); + normal_short_to_float_v3(&varray[start + 15], mvert[f->v1].no); } } else if (nors) { /* copy cached face normal */ - copy_v3_v3(&varray[start], &nors[i*3]); - copy_v3_v3(&varray[start+3], &nors[i*3]); - copy_v3_v3(&varray[start+6], &nors[i*3]); + copy_v3_v3(&varray[start], &nors[i * 3]); + copy_v3_v3(&varray[start + 3], &nors[i * 3]); + copy_v3_v3(&varray[start + 6], &nors[i * 3]); if (f->v4) { - copy_v3_v3(&varray[start+9], &nors[i*3]); - copy_v3_v3(&varray[start+12], &nors[i*3]); - copy_v3_v3(&varray[start+15], &nors[i*3]); + copy_v3_v3(&varray[start + 9], &nors[i * 3]); + copy_v3_v3(&varray[start + 12], &nors[i * 3]); + copy_v3_v3(&varray[start + 15], &nors[i * 3]); } } else { @@ -656,13 +657,13 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i normal_tri_v3(f_no, mvert[f->v1].co, mvert[f->v2].co, mvert[f->v3].co); copy_v3_v3(&varray[start], f_no); - copy_v3_v3(&varray[start+3], f_no); - copy_v3_v3(&varray[start+6], f_no); + copy_v3_v3(&varray[start + 3], f_no); + copy_v3_v3(&varray[start + 6], f_no); if (f->v4) { - copy_v3_v3(&varray[start+9], f_no); - copy_v3_v3(&varray[start+12], f_no); - copy_v3_v3(&varray[start+15], f_no); + copy_v3_v3(&varray[start + 9], f_no); + copy_v3_v3(&varray[start + 12], f_no); + copy_v3_v3(&varray[start + 15], f_no); } } } @@ -686,15 +687,15 @@ static void GPU_buffer_copy_uv(DerivedMesh *dm, float *varray, int *index, int * /* v1 v2 v3 */ copy_v2_v2(&varray[start], mtface[i].uv[0]); - copy_v2_v2(&varray[start+2], mtface[i].uv[1]); - copy_v2_v2(&varray[start+4], mtface[i].uv[2]); + copy_v2_v2(&varray[start + 2], mtface[i].uv[1]); + copy_v2_v2(&varray[start + 4], mtface[i].uv[2]); index[mat_orig_to_new[f->mat_nr]] += 6; if (f->v4) { /* v3 v4 v1 */ - copy_v2_v2(&varray[start+6], mtface[i].uv[2]); - copy_v2_v2(&varray[start+8], mtface[i].uv[3]); - copy_v2_v2(&varray[start+10], mtface[i].uv[0]); + copy_v2_v2(&varray[start + 6], mtface[i].uv[2]); + copy_v2_v2(&varray[start + 8], mtface[i].uv[3]); + copy_v2_v2(&varray[start + 10], mtface[i].uv[0]); index[mat_orig_to_new[f->mat_nr]] += 6; } } @@ -708,21 +709,21 @@ static void GPU_buffer_copy_color3(DerivedMesh *dm, float *varray_, int *index, char *mcol = (char *)user; MFace *f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); - for (i=0; i < totface; i++, f++) { + totface = dm->getNumTessFaces(dm); + for (i = 0; i < totface; i++, f++) { int start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ - copy_v3_v3_char(&varray[start], &mcol[i*12]); - copy_v3_v3_char(&varray[start+3], &mcol[i*12+3]); - copy_v3_v3_char(&varray[start+6], &mcol[i*12+6]); + copy_v3_v3_char(&varray[start], &mcol[i * 12]); + copy_v3_v3_char(&varray[start + 3], &mcol[i * 12 + 3]); + copy_v3_v3_char(&varray[start + 6], &mcol[i * 12 + 6]); index[mat_orig_to_new[f->mat_nr]] += 9; if (f->v4) { /* v3 v4 v1 */ - copy_v3_v3_char(&varray[start+9], &mcol[i*12+6]); - copy_v3_v3_char(&varray[start+12], &mcol[i*12+9]); - copy_v3_v3_char(&varray[start+15], &mcol[i*12]); + copy_v3_v3_char(&varray[start + 9], &mcol[i * 12 + 6]); + copy_v3_v3_char(&varray[start + 12], &mcol[i * 12 + 9]); + copy_v3_v3_char(&varray[start + 15], &mcol[i * 12]); index[mat_orig_to_new[f->mat_nr]] += 9; } } @@ -743,21 +744,21 @@ static void GPU_buffer_copy_mcol(DerivedMesh *dm, float *varray_, int *index, in unsigned char *mcol = (unsigned char *)user; MFace *f = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); - for (i=0; i < totface; i++, f++) { + totface = dm->getNumTessFaces(dm); + for (i = 0; i < totface; i++, f++) { int start = index[mat_orig_to_new[f->mat_nr]]; /* v1 v2 v3 */ - copy_mcol_uc3(&varray[start], &mcol[i*16]); - copy_mcol_uc3(&varray[start+3], &mcol[i*16+4]); - copy_mcol_uc3(&varray[start+6], &mcol[i*16+8]); + copy_mcol_uc3(&varray[start], &mcol[i * 16]); + copy_mcol_uc3(&varray[start + 3], &mcol[i * 16 + 4]); + copy_mcol_uc3(&varray[start + 6], &mcol[i * 16 + 8]); index[mat_orig_to_new[f->mat_nr]] += 9; if (f->v4) { /* v3 v4 v1 */ - copy_mcol_uc3(&varray[start+9], &mcol[i*16+8]); - copy_mcol_uc3(&varray[start+12], &mcol[i*16+12]); - copy_mcol_uc3(&varray[start+15], &mcol[i*16]); + copy_mcol_uc3(&varray[start + 9], &mcol[i * 16 + 8]); + copy_mcol_uc3(&varray[start + 12], &mcol[i * 16 + 12]); + copy_mcol_uc3(&varray[start + 15], &mcol[i * 16]); index[mat_orig_to_new[f->mat_nr]] += 9; } } @@ -773,15 +774,15 @@ static void GPU_buffer_copy_edge(DerivedMesh *dm, float *varray_, int *UNUSED(in totedge = dm->getNumEdges(dm); for (i = 0; i < totedge; i++, medge++) { - varray[i*2] = dm->drawObject->vert_points[medge->v1].point_index; - varray[i*2+1] = dm->drawObject->vert_points[medge->v2].point_index; + varray[i * 2] = dm->drawObject->vert_points[medge->v1].point_index; + varray[i * 2 + 1] = dm->drawObject->vert_points[medge->v2].point_index; } } static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(index), int *UNUSED(mat_orig_to_new), void *UNUSED(user)) { MTFace *tf = DM_get_tessface_data_layer(dm, CD_MTFACE); - int i, j=0; + int i, j = 0; if (!tf) return; @@ -791,23 +792,23 @@ static void GPU_buffer_copy_uvedge(DerivedMesh *dm, float *varray, int *UNUSED(i dm->getTessFace(dm, i, &mf); copy_v2_v2(&varray[j], tf->uv[0]); - copy_v2_v2(&varray[j+2], tf->uv[1]); + copy_v2_v2(&varray[j + 2], tf->uv[1]); - copy_v2_v2(&varray[j+4], tf->uv[1]); - copy_v2_v2(&varray[j+6], tf->uv[2]); + copy_v2_v2(&varray[j + 4], tf->uv[1]); + copy_v2_v2(&varray[j + 6], tf->uv[2]); if (!mf.v4) { - copy_v2_v2(&varray[j+8], tf->uv[2]); - copy_v2_v2(&varray[j+10], tf->uv[0]); - j+=12; + copy_v2_v2(&varray[j + 8], tf->uv[2]); + copy_v2_v2(&varray[j + 10], tf->uv[0]); + j += 12; } else { - copy_v2_v2(&varray[j+8], tf->uv[2]); - copy_v2_v2(&varray[j+10], tf->uv[3]); + copy_v2_v2(&varray[j + 8], tf->uv[2]); + copy_v2_v2(&varray[j + 10], tf->uv[3]); - copy_v2_v2(&varray[j+12], tf->uv[3]); - copy_v2_v2(&varray[j+14], tf->uv[0]); - j+=16; + copy_v2_v2(&varray[j + 12], tf->uv[3]); + copy_v2_v2(&varray[j + 14], tf->uv[0]); + j += 16; } } } @@ -862,20 +863,20 @@ const GPUBufferTypeSettings gpu_buffer_type_settings[] = { static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBufferType type) { switch (type) { - case GPU_BUFFER_VERTEX: - return &gdo->points; - case GPU_BUFFER_NORMAL: - return &gdo->normals; - case GPU_BUFFER_COLOR: - return &gdo->colors; - case GPU_BUFFER_UV: - return &gdo->uv; - case GPU_BUFFER_EDGE: - return &gdo->edges; - case GPU_BUFFER_UVEDGE: - return &gdo->uvedges; - default: - return NULL; + case GPU_BUFFER_VERTEX: + return &gdo->points; + case GPU_BUFFER_NORMAL: + return &gdo->normals; + case GPU_BUFFER_COLOR: + return &gdo->colors; + case GPU_BUFFER_UV: + return &gdo->uv; + case GPU_BUFFER_EDGE: + return &gdo->edges; + case GPU_BUFFER_UVEDGE: + return &gdo->uvedges; + default: + return NULL; } } @@ -883,25 +884,25 @@ static GPUBuffer **gpu_drawobject_buffer_from_type(GPUDrawObject *gdo, GPUBuffer static int gpu_buffer_size_from_type(DerivedMesh *dm, GPUBufferType type) { switch (type) { - case GPU_BUFFER_VERTEX: - return sizeof(float)*3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); - case GPU_BUFFER_NORMAL: - return sizeof(float)*3*dm->drawObject->tot_triangle_point; - case GPU_BUFFER_COLOR: - return sizeof(char)*3*dm->drawObject->tot_triangle_point; - case GPU_BUFFER_UV: - return sizeof(float)*2*dm->drawObject->tot_triangle_point; - case GPU_BUFFER_EDGE: - return sizeof(int)*2*dm->drawObject->totedge; - case GPU_BUFFER_UVEDGE: - /* each face gets 3 points, 3 edges per triangle, and - * each edge has its own, non-shared coords, so each - * tri corner needs minimum of 4 floats, quads used - * less so here we can over allocate and assume all - * tris. */ - return sizeof(float) * 4 * dm->drawObject->tot_triangle_point; - default: - return -1; + case GPU_BUFFER_VERTEX: + return sizeof(float) * 3 * (dm->drawObject->tot_triangle_point + dm->drawObject->tot_loose_point); + case GPU_BUFFER_NORMAL: + return sizeof(float) * 3 * dm->drawObject->tot_triangle_point; + case GPU_BUFFER_COLOR: + return sizeof(char) * 3 * dm->drawObject->tot_triangle_point; + case GPU_BUFFER_UV: + return sizeof(float) * 2 * dm->drawObject->tot_triangle_point; + case GPU_BUFFER_EDGE: + return sizeof(int) * 2 * dm->drawObject->totedge; + case GPU_BUFFER_UVEDGE: + /* each face gets 3 points, 3 edges per triangle, and + * each edge has its own, non-shared coords, so each + * tri corner needs minimum of 4 floats, quads used + * less so here we can over allocate and assume all + * tris. */ + return sizeof(float) * 4 * dm->drawObject->tot_triangle_point; + default: + return -1; } } @@ -1060,18 +1061,18 @@ void GPU_uvedge_setup(DerivedMesh *dm) static int GPU_typesize(int type) { switch (type) { - case GL_FLOAT: - return sizeof(float); - case GL_INT: - return sizeof(int); - case GL_UNSIGNED_INT: - return sizeof(unsigned int); - case GL_BYTE: - return sizeof(char); - case GL_UNSIGNED_BYTE: - return sizeof(unsigned char); - default: - return 0; + case GL_FLOAT: + return sizeof(float); + case GL_INT: + return sizeof(int); + case GL_UNSIGNED_INT: + return sizeof(unsigned int); + case GL_BYTE: + return sizeof(char); + case GL_UNSIGNED_BYTE: + return sizeof(unsigned char); + default: + return 0; } } @@ -1082,7 +1083,7 @@ int GPU_attrib_element_size(GPUAttrib data[], int numdata) for (i = 0; i < numdata; i++) { int typesize = GPU_typesize(data[i].type); if (typesize != 0) - elementsize += typesize*data[i].size; + elementsize += typesize * data[i].size; } return elementsize; } @@ -1107,8 +1108,8 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda for (i = 0; i < numdata; i++) { glEnableVertexAttribArrayARB(data[i].index); glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, - GL_FALSE, elementsize, (void *)offset); - offset += data[i].size*GPU_typesize(data[i].type); + GL_FALSE, elementsize, (void *)offset); + offset += data[i].size * GPU_typesize(data[i].type); attribData[i].index = data[i].index; attribData[i].size = data[i].size; @@ -1120,8 +1121,8 @@ void GPU_interleaved_attrib_setup(GPUBuffer *buffer, GPUAttrib data[], int numda for (i = 0; i < numdata; i++) { glEnableVertexAttribArrayARB(data[i].index); glVertexAttribPointerARB(data[i].index, data[i].size, data[i].type, - GL_FALSE, elementsize, (char *)buffer->pointer + offset); - offset += data[i].size*GPU_typesize(data[i].type); + GL_FALSE, elementsize, (char *)buffer->pointer + offset); + offset += data[i].size * GPU_typesize(data[i].type); } } } @@ -1170,8 +1171,8 @@ void GPU_color3_upload(DerivedMesh *dm, unsigned char *data) GPU_buffer_free(dm->drawObject->colors); dm->drawObject->colors = gpu_buffer_setup(dm, dm->drawObject, 3, - sizeof(char)*3*dm->drawObject->tot_triangle_point, - GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3); + sizeof(char) * 3 * dm->drawObject->tot_triangle_point, + GL_ARRAY_BUFFER_ARB, data, GPU_buffer_copy_color3); } void GPU_color_switch(int mode) @@ -1192,7 +1193,7 @@ void GPU_color_switch(int mode) * code, 0 otherwise */ int GPU_buffer_legacy(DerivedMesh *dm) { - int test= (U.gameflags & USER_DISABLE_VBO); + int test = (U.gameflags & USER_DISABLE_VBO); if (test) return 1; @@ -1253,9 +1254,9 @@ void GPU_buffer_unlock(GPUBuffer *buffer) void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, int count) { glDrawElements(mode, count, GL_UNSIGNED_INT, - (useVBOs ? - (void*)(start * sizeof(unsigned int)) : - ((int*)elements->pointer) + start)); + (useVBOs ? + (void *)(start * sizeof(unsigned int)) : + ((int *)elements->pointer) + start)); } @@ -1266,6 +1267,13 @@ void GPU_buffer_draw_elements(GPUBuffer *elements, unsigned int mode, int start, typedef struct { float co[3]; short no[3]; + + /* inserting this to align the 'color' field to a four-byte + boundary; drastically increases viewport performance on my + drivers (Gallium/Radeon) --nicholasbishop */ + char pad[2]; + + unsigned char color[3]; } VertexBufferFormat; struct GPU_Buffers { @@ -1278,25 +1286,103 @@ struct GPU_Buffers { MVert *mvert; int *face_indices; int totface; + const float *vmask; /* grid pointers */ - DMGridData **grids; + CCGKey gridkey; + CCGElem **grids; const DMFlagMat *grid_flag_mats; const BLI_bitmap *grid_hidden; int *grid_indices; int totgrid; - int gridsize; int has_hidden; unsigned int tot_tri, tot_quad; }; +typedef enum { + VBO_ENABLED, + VBO_DISABLED +} VBO_State; + +static void gpu_colors_enable(VBO_State vbo_state) +{ + glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); + glEnable(GL_COLOR_MATERIAL); + if (vbo_state == VBO_ENABLED) + glEnableClientState(GL_COLOR_ARRAY); +} + +static void gpu_colors_disable(VBO_State vbo_state) +{ + glDisable(GL_COLOR_MATERIAL); + if (vbo_state == VBO_ENABLED) + glDisableClientState(GL_COLOR_ARRAY); +} + +static float gpu_color_from_mask(float mask) +{ + return (1.0f - mask) * 0.5f + 0.25f; +} + +static void gpu_color_from_mask_copy(float mask, unsigned char out[3]) +{ + unsigned char color; + + color = gpu_color_from_mask(mask) * 255.0f; + + out[0] = color; + out[1] = color; + out[2] = color; +} + +static void gpu_color_from_mask_set(float mask) +{ + float color = gpu_color_from_mask(mask); + glColor3f(color, color, color); +} + +static float gpu_color_from_mask_quad(const CCGKey *key, + CCGElem *a, CCGElem *b, + CCGElem *c, CCGElem *d) +{ + return gpu_color_from_mask((*CCG_elem_mask(key, a) + + *CCG_elem_mask(key, b) + + *CCG_elem_mask(key, c) + + *CCG_elem_mask(key, d)) * 0.25f); +} + +static void gpu_color_from_mask_quad_copy(const CCGKey *key, + CCGElem *a, CCGElem *b, + CCGElem *c, CCGElem *d, + unsigned char out[3]) +{ + unsigned char color = + gpu_color_from_mask((*CCG_elem_mask(key, a) + + *CCG_elem_mask(key, b) + + *CCG_elem_mask(key, c) + + *CCG_elem_mask(key, d)) * 0.25f) * 255.0f; + + out[0] = color; + out[1] = color; + out[2] = color; +} + +static void gpu_color_from_mask_quad_set(const CCGKey *key, + CCGElem *a, CCGElem *b, + CCGElem *c, CCGElem *d) +{ + float color = gpu_color_from_mask_quad(key, a, b, c, d); + glColor3f(color, color, color); +} void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, - int *vert_indices, int totvert) + int *vert_indices, int totvert, const float *vmask) { VertexBufferFormat *vert_data; int i; + buffers->vmask = vmask; + if (buffers->vert_buf) { /* Build VBO */ glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); @@ -1312,6 +1398,8 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, copy_v3_v3(out->co, v->co); memcpy(out->no, v->no, sizeof(short) * 3); + gpu_color_from_mask_copy(vmask[vert_indices[i]], + out->color); } glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); @@ -1328,9 +1416,9 @@ void GPU_update_mesh_buffers(GPU_Buffers *buffers, MVert *mvert, } GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], - MFace *mface, MVert *mvert, - int *face_indices, - int totface) + MFace *mface, MVert *mvert, + int *face_indices, + int totface) { GPU_Buffers *buffers; unsigned short *tri_data; @@ -1366,14 +1454,14 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], if (paint_is_face_hidden(f, mvert)) continue; - v[0]= 0; - v[1]= 1; - v[2]= 2; + v[0] = 0; + v[1] = 1; + v[2] = 2; for (j = 0; j < (f->v4 ? 2 : 1); ++j) { for (k = 0; k < 3; ++k) { *tri_data = face_vert_indices[i][v[k]]; - ++tri_data; + tri_data++; } v[0] = 3; v[1] = 0; @@ -1402,47 +1490,77 @@ GPU_Buffers *GPU_build_mesh_buffers(int (*face_vert_indices)[4], return buffers; } -void GPU_update_grid_buffers(GPU_Buffers *buffers, DMGridData **grids, - const DMFlagMat *grid_flag_mats, int *grid_indices, int totgrid, int gridsize) +void GPU_update_grid_buffers(GPU_Buffers *buffers, CCGElem **grids, + const DMFlagMat *grid_flag_mats, int *grid_indices, + int totgrid, const CCGKey *key) { - DMGridData *vert_data; - int i, j, k, totvert; - - totvert= gridsize*gridsize*totgrid; + VertexBufferFormat *vert_data; + int i, j, k, x, y; /* Build VBO */ if (buffers->vert_buf) { + int totvert = key->grid_area * totgrid; int smooth = grid_flag_mats[grid_indices[0]].flag & ME_SMOOTH; glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBufferDataARB(GL_ARRAY_BUFFER_ARB, - sizeof(DMGridData) * totvert, + sizeof(VertexBufferFormat) * totvert, NULL, GL_STATIC_DRAW_ARB); vert_data = glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB); if (vert_data) { for (i = 0; i < totgrid; ++i) { - DMGridData *grid= grids[grid_indices[i]]; - memcpy(vert_data, grid, sizeof(DMGridData)*gridsize*gridsize); + VertexBufferFormat *vd = vert_data; + CCGElem *grid = grids[grid_indices[i]]; + for (y = 0; y < key->grid_size; y++) { + for (x = 0; x < key->grid_size; x++) { + CCGElem *elem = CCG_grid_elem(key, grid, x, y); + + copy_v3_v3(vd->co, CCG_elem_co(key, elem)); + if (smooth) { + normal_float_to_short_v3(vd->no, + CCG_elem_no(key, elem)); + + gpu_color_from_mask_copy(*CCG_elem_mask(key, elem), + vd->color); + } + vd++; + } + } + if (!smooth) { /* for flat shading, recalc normals and set the last vertex of * each quad in the index buffer to have the flat normal as * that is what opengl will use */ - for (j = 0; j < gridsize-1; ++j) { - for (k = 0; k < gridsize-1; ++k) { + for (j = 0; j < key->grid_size - 1; j++) { + for (k = 0; k < key->grid_size - 1; k++) { + CCGElem *elems[4] = { + CCG_grid_elem(key, grid, k, j + 1), + CCG_grid_elem(key, grid, k + 1, j + 1), + CCG_grid_elem(key, grid, k + 1, j), + CCG_grid_elem(key, grid, k, j) + }; float fno[3]; - normal_quad_v3(fno, - grid[(j+1)*gridsize + k].co, - grid[(j+1)*gridsize + k+1].co, - grid[j*gridsize + k+1].co, - grid[j*gridsize + k].co); - copy_v3_v3(vert_data[(j+1)*gridsize + (k+1)].no, fno); + normal_quad_v3(fno, + CCG_elem_co(key, elems[0]), + CCG_elem_co(key, elems[1]), + CCG_elem_co(key, elems[2]), + CCG_elem_co(key, elems[3])); + + vd = vert_data + (j + 1) * key->grid_size + (k + 1); + normal_float_to_short_v3(vd->no, fno); + gpu_color_from_mask_quad_copy(key, + elems[0], + elems[1], + elems[2], + elems[3], + vd->color); } } } - vert_data += gridsize*gridsize; + vert_data += key->grid_area; } glUnmapBufferARB(GL_ARRAY_BUFFER_ARB); } @@ -1456,18 +1574,18 @@ void GPU_update_grid_buffers(GPU_Buffers *buffers, DMGridData **grids, buffers->grids = grids; buffers->grid_indices = grid_indices; buffers->totgrid = totgrid; - buffers->gridsize = gridsize; buffers->grid_flag_mats = grid_flag_mats; + buffers->gridkey = *key; //printf("node updated %p\n", buffers); } /* Returns the number of visible quads in the nodes' grids. */ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, - int *grid_indices, int totgrid, - int gridsize) + int *grid_indices, int totgrid, + int gridsize) { - int gridarea = (gridsize-1) * (gridsize-1); + int gridarea = (gridsize - 1) * (gridsize - 1); int i, x, y, totquad; /* grid hidden layer is present, so have to check each grid for @@ -1478,8 +1596,8 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, if (gh) { /* grid hidden are present, have to check each element */ - for (y = 0; y < gridsize-1; y++) { - for (x = 0; x < gridsize-1; x++) { + for (y = 0; y < gridsize - 1; y++) { + for (x = 0; x < gridsize - 1; x++) { if (!paint_is_grid_face_hidden(gh, gridsize, x, y)) totquad++; } @@ -1501,40 +1619,40 @@ static int gpu_count_grid_quads(BLI_bitmap *grid_hidden, int i, j, k; \ \ glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ - sizeof(type_) * (tot_quad_) * 4, NULL, \ - GL_STATIC_DRAW_ARB); \ + sizeof(type_) * (tot_quad_) * 4, NULL, \ + GL_STATIC_DRAW_ARB); \ \ /* Fill the quad buffer */ \ quad_data = glMapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, \ - GL_WRITE_ONLY_ARB); \ + GL_WRITE_ONLY_ARB); \ if (quad_data) { \ - for (i = 0; i < totgrid; ++i) { \ - BLI_bitmap gh = NULL; \ - if (grid_hidden) \ - gh = grid_hidden[(grid_indices)[i]]; \ + for (i = 0; i < totgrid; ++i) { \ + BLI_bitmap gh = NULL; \ + if (grid_hidden) \ + gh = grid_hidden[(grid_indices)[i]]; \ \ - for (j = 0; j < gridsize-1; ++j) { \ - for (k = 0; k < gridsize-1; ++k) { \ - /* Skip hidden grid face */ \ - if (gh && \ - paint_is_grid_face_hidden(gh, \ - gridsize, k, j)) \ - continue; \ + for (j = 0; j < gridsize - 1; ++j) { \ + for (k = 0; k < gridsize - 1; ++k) { \ + /* Skip hidden grid face */ \ + if (gh && \ + paint_is_grid_face_hidden(gh, \ + gridsize, k, j)) \ + continue; \ \ - *(quad_data++)= offset + j*gridsize + k+1; \ - *(quad_data++)= offset + j*gridsize + k; \ - *(quad_data++)= offset + (j+1)*gridsize + k; \ - *(quad_data++)= offset + (j+1)*gridsize + k+1; \ + *(quad_data++) = offset + j * gridsize + k + 1; \ + *(quad_data++) = offset + j * gridsize + k; \ + *(quad_data++) = offset + (j + 1) * gridsize + k; \ + *(quad_data++) = offset + (j + 1) * gridsize + k + 1; \ } \ } \ \ - offset += gridsize*gridsize; \ + offset += gridsize * gridsize; \ } \ glUnmapBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB); \ } \ else { \ - glDeleteBuffersARB(1, &(buffer_)); \ - (buffer_) = 0; \ + glDeleteBuffersARB(1, &(buffer_)); \ + (buffer_) = 0; \ } \ } /* end FILL_QUAD_BUFFER */ @@ -1569,7 +1687,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to /* Build new VBO */ glGenBuffersARB(1, &buffer); if (buffer) { - *totquad= (gridsize-1)*(gridsize-1); + *totquad = (gridsize - 1) * (gridsize - 1); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffer); @@ -1592,19 +1710,18 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to } GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, - BLI_bitmap *grid_hidden, int gridsize) + BLI_bitmap *grid_hidden, int gridsize) { GPU_Buffers *buffers; int totquad; - int fully_visible_totquad = (gridsize-1) * (gridsize-1) * totgrid; + int fully_visible_totquad = (gridsize - 1) * (gridsize - 1) * totgrid; buffers = MEM_callocN(sizeof(GPU_Buffers), "GPU_Buffers"); buffers->grid_hidden = grid_hidden; - buffers->gridsize = gridsize; buffers->totgrid = totgrid; /* Count the number of quads */ - totquad= gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); + totquad = gpu_count_grid_quads(grid_hidden, grid_indices, totgrid, gridsize); if (totquad == fully_visible_totquad) { buffers->index_buf = gpu_get_grid_buffer(gridsize, &buffers->index_type, &buffers->tot_quad); @@ -1614,7 +1731,7 @@ GPU_Buffers *GPU_build_grid_buffers(int *grid_indices, int totgrid, /* Build new VBO */ glGenBuffersARB(1, &buffers->index_buf); if (buffers->index_buf) { - buffers->tot_quad= totquad; + buffers->tot_quad = totquad; glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); @@ -1647,6 +1764,8 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) const MVert *mvert = buffers->mvert; int i, j; + gpu_colors_enable(VBO_DISABLED); + for (i = 0; i < buffers->totface; ++i) { MFace *f = buffers->mface + buffers->face_indices[i]; int S = f->v4 ? 4 : 3; @@ -1655,25 +1774,36 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) if (paint_is_face_hidden(f, buffers->mvert)) continue; - glBegin((f->v4)? GL_QUADS: GL_TRIANGLES); + glBegin((f->v4) ? GL_QUADS : GL_TRIANGLES); if (smooth) { for (j = 0; j < S; j++) { + gpu_color_from_mask_set(buffers->vmask[fv[j]]); glNormal3sv(mvert[fv[j]].no); glVertex3fv(mvert[fv[j]].co); } } else { - float fno[3]; + float fmask, fno[3]; /* calculate face normal */ if (f->v4) { normal_quad_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, - mvert[fv[2]].co, mvert[fv[3]].co); + mvert[fv[2]].co, mvert[fv[3]].co); } else normal_tri_v3(fno, mvert[fv[0]].co, mvert[fv[1]].co, mvert[fv[2]].co); glNormal3fv(fno); + + /* calculate face mask color */ + fmask = (buffers->vmask[fv[0]] + + buffers->vmask[fv[1]] + + buffers->vmask[fv[2]]); + if (f->v4) + fmask = (fmask + buffers->vmask[fv[3]]) * 0.25; + else + fmask /= 3.0f; + gpu_color_from_mask_set(fmask); for (j = 0; j < S; j++) glVertex3fv(mvert[fv[j]].co); @@ -1681,15 +1811,20 @@ static void gpu_draw_buffers_legacy_mesh(GPU_Buffers *buffers, int smooth) glEnd(); } + + gpu_colors_disable(VBO_DISABLED); } static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) { - int i, j, x, y, gridsize = buffers->gridsize; + const CCGKey *key = &buffers->gridkey; + int i, j, x, y, gridsize = buffers->gridkey.grid_size; + + gpu_colors_enable(VBO_DISABLED); for (i = 0; i < buffers->totgrid; ++i) { int g = buffers->grid_indices[i]; - const DMGridData *grid = buffers->grids[g]; + CCGElem *grid = buffers->grids[g]; BLI_bitmap gh = buffers->grid_hidden[g]; /* TODO: could use strips with hiding as well */ @@ -1697,13 +1832,13 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) if (gh) { glBegin(GL_QUADS); - for (y = 0; y < gridsize-1; y++) { - for (x = 0; x < gridsize-1; x++) { - const DMGridData *e[4] = { - &grid[y*gridsize + x], - &grid[(y+1)*gridsize + x], - &grid[(y+1)*gridsize + x+1], - &grid[y*gridsize + x+1] + for (y = 0; y < gridsize - 1; y++) { + for (x = 0; x < gridsize - 1; x++) { + CCGElem *e[4] = { + CCG_grid_elem(key, grid, x + 1, y + 1), + CCG_grid_elem(key, grid, x + 1, y), + CCG_grid_elem(key, grid, x, y), + CCG_grid_elem(key, grid, x, y + 1) }; /* skip face if any of its corners are hidden */ @@ -1712,17 +1847,23 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) if (smooth) { for (j = 0; j < 4; j++) { - glNormal3fv(e[j]->no); - glVertex3fv(e[j]->co); + gpu_color_from_mask_set(*CCG_elem_mask(key, e[j])); + glNormal3fv(CCG_elem_no(key, e[j])); + glVertex3fv(CCG_elem_co(key, e[j])); } } else { float fno[3]; - normal_quad_v3(fno, e[0]->co, e[1]->co, e[2]->co, e[3]->co); + normal_quad_v3(fno, + CCG_elem_co(key, e[0]), + CCG_elem_co(key, e[1]), + CCG_elem_co(key, e[2]), + CCG_elem_co(key, e[3])); glNormal3fv(fno); + gpu_color_from_mask_quad_set(key, e[0], e[1], e[2], e[3]); for (j = 0; j < 4; j++) - glVertex3fv(e[j]->co); + glVertex3fv(CCG_elem_co(key, e[j])); } } } @@ -1730,42 +1871,53 @@ static void gpu_draw_buffers_legacy_grids(GPU_Buffers *buffers, int smooth) glEnd(); } else if (smooth) { - for (y = 0; y < gridsize-1; y++) { + for (y = 0; y < gridsize - 1; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridsize; x++) { - const DMGridData *a = &grid[y*gridsize + x]; - const DMGridData *b = &grid[(y+1)*gridsize + x]; + CCGElem *a = CCG_grid_elem(key, grid, x, y); + CCGElem *b = CCG_grid_elem(key, grid, x, y + 1); - glNormal3fv(a->no); - glVertex3fv(a->co); - glNormal3fv(b->no); - glVertex3fv(b->co); + gpu_color_from_mask_set(*CCG_elem_mask(key, a)); + glNormal3fv(CCG_elem_no(key, a)); + glVertex3fv(CCG_elem_co(key, a)); + gpu_color_from_mask_set(*CCG_elem_mask(key, b)); + glNormal3fv(CCG_elem_no(key, b)); + glVertex3fv(CCG_elem_co(key, b)); } glEnd(); } } else { - for (y = 0; y < gridsize-1; y++) { + for (y = 0; y < gridsize - 1; y++) { glBegin(GL_QUAD_STRIP); for (x = 0; x < gridsize; x++) { - const DMGridData *a = &grid[y*gridsize + x]; - const DMGridData *b = &grid[(y+1)*gridsize + x]; + CCGElem *a = CCG_grid_elem(key, grid, x, y); + CCGElem *b = CCG_grid_elem(key, grid, x, y + 1); if (x > 0) { - const DMGridData *c = &grid[y*gridsize + x-1]; - const DMGridData *d = &grid[(y+1)*gridsize + x-1]; + CCGElem *c = CCG_grid_elem(key, grid, x - 1, y); + CCGElem *d = CCG_grid_elem(key, grid, x - 1, y + 1); + float fno[3]; - normal_quad_v3(fno, d->co, b->co, a->co, c->co); + normal_quad_v3(fno, + CCG_elem_co(key, d), + CCG_elem_co(key, b), + CCG_elem_co(key, a), + CCG_elem_co(key, c)); glNormal3fv(fno); + + gpu_color_from_mask_quad_set(key, a, b, c, d); } - glVertex3fv(a->co); - glVertex3fv(b->co); + glVertex3fv(CCG_elem_co(key, a)); + glVertex3fv(CCG_elem_co(key, b)); } glEnd(); } } } + + gpu_colors_disable(VBO_DISABLED); } void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) @@ -1778,7 +1930,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) return; smooth = f->flag & ME_SMOOTH; - glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); + glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); } else if (buffers->totgrid) { const DMFlagMat *f = &buffers->grid_flag_mats[buffers->grid_indices[0]]; @@ -1786,31 +1938,40 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) return; smooth = f->flag & ME_SMOOTH; - glShadeModel(smooth ? GL_SMOOTH: GL_FLAT); + glShadeModel(smooth ? GL_SMOOTH : GL_FLAT); } if (buffers->vert_buf && buffers->index_buf) { glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); + gpu_colors_enable(VBO_ENABLED); glBindBufferARB(GL_ARRAY_BUFFER_ARB, buffers->vert_buf); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, buffers->index_buf); if (buffers->tot_quad) { - unsigned offset = 0; + char *offset = 0; int i, last = buffers->has_hidden ? 1 : buffers->totgrid; for (i = 0; i < last; i++) { - glVertexPointer(3, GL_FLOAT, sizeof(DMGridData), offset + (char*)offsetof(DMGridData, co)); - glNormalPointer(GL_FLOAT, sizeof(DMGridData), offset + (char*)offsetof(DMGridData, no)); + glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), + offset + offsetof(VertexBufferFormat, co)); + glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), + offset + offsetof(VertexBufferFormat, no)); + glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), + offset + offsetof(VertexBufferFormat, color)); glDrawElements(GL_QUADS, buffers->tot_quad * 4, buffers->index_type, 0); - offset += buffers->gridsize * buffers->gridsize * sizeof(DMGridData); + offset += buffers->gridkey.grid_area * sizeof(VertexBufferFormat); } } else { - glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), (void*)offsetof(VertexBufferFormat, co)); - glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), (void*)offsetof(VertexBufferFormat, no)); + glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat), + (void *)offsetof(VertexBufferFormat, co)); + glNormalPointer(GL_SHORT, sizeof(VertexBufferFormat), + (void *)offsetof(VertexBufferFormat, no)); + glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VertexBufferFormat), + (void *)offsetof(VertexBufferFormat, color)); glDrawElements(GL_TRIANGLES, buffers->tot_tri * 3, buffers->index_type, 0); } @@ -1820,6 +1981,7 @@ void GPU_draw_buffers(GPU_Buffers *buffers, DMSetMaterial setMaterial) glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); + gpu_colors_disable(VBO_ENABLED); } /* fallbacks if we are out of memory or VBO is disabled */ else if (buffers->totface) { diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index b2c2bc092b2..ebfedea3968 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -714,7 +714,7 @@ int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend) gpu_verify_repeat(ima); /* Did this get lost in the image recode? */ - /* tag_image_time(ima);*/ + /* BKE_image_tag_time(ima);*/ return 1; } @@ -1076,7 +1076,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O GPUBlendMode alphablend; int a; int gamma = scene->r.color_mgt_flag & R_COLOR_MANAGEMENT; - int new_shading_nodes = scene_use_new_shading_nodes(scene); + int new_shading_nodes = BKE_scene_use_new_shading_nodes(scene); /* initialize state */ memset(&GMS, 0, sizeof(GMS)); @@ -1410,7 +1410,7 @@ int GPU_scene_object_lights(Scene *scene, Object *ob, int lay, float viewmat[][4 glPushMatrix(); glLoadMatrixf((float *)viewmat); - where_is_object_simul(scene, base->object); + BKE_object_where_is_calc_simul(scene, base->object); if (la->type==LA_SUN) { /* sun lamp */ diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 383dd6b8f2f..f75c1576fb9 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -1501,7 +1501,7 @@ GPUMaterial *GPU_material_from_blender(Scene *scene, Material *ma) GPU_material_output_link(mat, outlink); } - if (!scene_use_new_shading_nodes(scene)) { + if (!BKE_scene_use_new_shading_nodes(scene)) { if (gpu_do_color_management(mat)) if (mat->outlink) GPU_link(mat, "linearrgb_to_srgb", mat->outlink, &mat->outlink); diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 5500e6bf171..9498bf92446 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2188,6 +2188,13 @@ void node_light_path( is_transmission_ray = 0.0; } +void node_light_falloff(float strength, float tsmooth, out float quadratic, out float linear, out float constant) +{ + quadratic = strength; + linear = strength; + constant = strength; +} + /* output */ void node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 result) diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl.c b/source/blender/gpu/shaders/gpu_shader_material.glsl.c index b8086ed9c0a..6d08d4c8cec 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl.c +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl.c @@ -1,1658 +1,1595 @@ /* DataToC output of file */ -int datatoc_gpu_shader_material_glsl_size = 52836; +int datatoc_gpu_shader_material_glsl_size = 50823; char datatoc_gpu_shader_material_glsl[] = { - 13, 10,102,108, -111, 97,116, 32,101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 13, 10,123, 13, 10, 9,114,101, -116,117,114,110, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,102, 41, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,114,103, 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32, -118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109, -105,110, 44, 32,104, 44, 32,115, 44, 32,118, 44, 32, 99,100,101,108,116, 97, 59, 13, 10, 9,118,101, 99, 51, 32, 99, 59, 13, 10, - 13, 10, 9, 99,109, 97,120, 32, 61, 32,109, 97,120, 40,114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, - 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 13, 10, 9, 99,109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, - 32,109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 13, 10, 9, 99,100,101,108,116, 97, 32, - 61, 32, 99,109, 97,120, 45, 99,109,105,110, 59, 13, 10, 13, 10, 9,118, 32, 61, 32, 99,109, 97,120, 59, 13, 10, 9,105,102, 32, - 40, 99,109, 97,120, 33, 61, 48, 46, 48, 41, 13, 10, 9, 9,115, 32, 61, 32, 99,100,101,108,116, 97, 47, 99,109, 97,120, 59, 13, - 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, - 13, 10, 9,125, 13, 10, 13, 10, 9,105,102, 32, 40,115, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,104, 32, 61, 32, - 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 99, 32, 61, 32, 40,118,101, 99, 51, 40, 99, -109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,114,103, 98, 46,120,121,122, 41, 47, 99,100,101,108, -116, 97, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,114,103, 98, 46,120, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, 91, - 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,114,103, 98, 46,121, 61, 61, 99,109, - 97,120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32, 45, 32, 32, 99, 91, 50, 93, 59, 13, 10, 9, 9,101, -108,115,101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45, 32, 99, 91, 48, 93, 59, 13, 10, 13, 10, 9, 9, -104, 32, 47, 61, 32, 54, 46, 48, 59, 13, 10, 13, 10, 9, 9,105,102, 32, 40,104, 60, 48, 46, 48, 41, 13, 10, 9, 9, 9,104, 32, - 43, 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,104, 44, - 32,115, 44, 32,118, 44, 32,114,103, 98, 46,119, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,104,115,118, 95,116,111, - 95,114,103, 98, 40,118,101, 99, 52, 32,104,115,118, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,105, 44, 32,102, 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32, -118, 59, 13, 10, 9,118,101, 99, 51, 32,114,103, 98, 59, 13, 10, 13, 10, 9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 13, 10, - 9,115, 32, 61, 32,104,115,118, 91, 49, 93, 59, 13, 10, 9,118, 32, 61, 32,104,115,118, 91, 50, 93, 59, 13, 10, 13, 10, 9,105, -102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,118, 44, 32, -118, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,105,102, 40,104, 61, 61, 49, 46, 48, 41, 13, 10, - 9, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9, 13, 10, 9, 9,104, 32, 42, 61, 32, 54, 46, 48, 59, 13, 10, 9, 9, -105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 13, 10, 9, 9,102, 32, 61, 32,104, 32, 45, 32,105, 59, 13, 10, 9, 9,114, -103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 13, 10, 9, 9,112, 32, 61, 32,118, 42, 40, 49, 46, - 48, 45,115, 41, 59, 13, 10, 9, 9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42,102, 41, 41, 59, 13, 10, 9, 9,116, - 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41, 41, 59, 13, 10, 9, 9, 13, 10, 9, 9,105, -102, 32, 40,105, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,116, 44, 32,112, 41, - 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, - 99, 51, 40,113, 44, 32,118, 44, 32,112, 41, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 50, 46, - 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 13, 10, 9, 9,101,108,115,101, 32, -105,102, 32, 40,105, 32, 61, 61, 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,113, 44, 32,118, - 41, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118, -101, 99, 51, 40,116, 44, 32,112, 44, 32,118, 41, 59, 13, 10, 9, 9,101,108,115,101, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, - 40,118, 44, 32,112, 44, 32,113, 41, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, - 40,114,103, 98, 44, 32,104,115,118, 46,119, 41, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,115,114,103, 98, 95,116, -111, 95,108,105,110,101, 97,114,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 13, 10,123, 13, 10, 9,105,102, 40, 99, 32, 60, - 32, 48, 46, 48, 52, 48, 52, 53, 41, 13, 10, 9, 9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, - 46, 48, 58, 32, 99, 32, 42, 32, 40, 49, 46, 48, 47, 49, 50, 46, 57, 50, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,114, -101,116,117,114,110, 32,112,111,119, 40, 40, 99, 32, 43, 32, 48, 46, 48, 53, 53, 41, 42, 40, 49, 46, 48, 47, 49, 46, 48, 53, 53, - 41, 44, 32, 50, 46, 52, 41, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,108,105,110,101, 97,114,114,103, 98, 95,116, -111, 95,115,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 13, 10,123, 13, 10, 9,105,102, 40, 99, 32, 60, 32, 48, 46, 48, 48, - 51, 49, 51, 48, 56, 41, 13, 10, 9, 9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, 46, 48, 58, - 32, 99, 32, 42, 32, 49, 50, 46, 57, 50, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,114,101,116,117,114,110, 32, 49, 46, 48, - 53, 53, 32, 42, 32,112,111,119, 40, 99, 44, 32, 49, 46, 48, 47, 50, 46, 52, 41, 32, 45, 32, 48, 46, 48, 53, 53, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40,118,101, 99, 52, 32, - 99,111,108, 95,102,114,111,109, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 13, 10,123, 13, 10, 9, - 99,111,108, 95,116,111, 46,114, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, - 95,102,114,111,109, 46,114, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46,103, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108, -105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,103, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46, 98, - 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, - 59, 13, 10, 9, 99,111,108, 95,116,111, 46, 97, 32, 61, 32, 99,111,108, 95,102,114,111,109, 46, 97, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, - 95,102,114,111,109, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 13, 10,123, 13, 10, 9, 99,111,108, - 95,116,111, 46,114, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114, -111,109, 46,114, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46,103, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, - 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,103, 41, 59, 13, 10, 9, 99,111,108, 95,116,111, 46, 98, 32, 61, 32, -108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, 59, 13, 10, - 9, 99,111,108, 95,116,111, 46, 97, 32, 61, 32, 99,111,108, 95,102,114,111,109, 46, 97, 59, 13, 10,125, 13, 10, 13, 10, 35,100, -101,102,105,110,101, 32, 77, 95, 80, 73, 32, 51, 46, 49, 52, 49, 53, 57, 50, 54, 53, 51, 53, 56, 57, 55, 57, 51, 50, 51, 56, 52, - 54, 13, 10, 35,100,101,102,105,110,101, 32, 77, 95, 49, 95, 80, 73, 32, 48, 46, 51, 49, 56, 51, 48, 57, 56, 56, 54, 49, 56, 51, - 55, 57, 48, 54, 57, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, - 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,118, 99,111,108, - 95, 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 52, 32, 97,116,116,118, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, - 52, 32,118, 99,111,108, 41, 13, 10,123, 13, 10, 9,118, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 97,116,116,118, 99,111,108, - 46,120, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,121, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99, -111,108, 46,122, 47, 50, 53, 53, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,117,118, 95, - 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 50, 32, 97,116,116,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117, -118, 41, 13, 10,123, 13, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, - 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,103, -101,111,109, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,109, 97,116, 52, 32,118,105,101,119, -105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 97,116,116,111,114, 99,111, 44, 32,118,101, 99, 50, 32, 97,116,116,117,118, - 44, 32,118,101, 99, 52, 32, 97,116,116,118, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 44, - 32,111,117,116, 32,118,101, 99, 51, 32,108,111, 99, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32, -111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117,116, 32, -118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,118, 99,111,108, 95, 97,108,112,104, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102,114,111,110, -116, 98, 97, 99,107, 41, 13, 10,123, 13, 10, 9,108,111, 99, 97,108, 32, 61, 32, 99,111, 59, 13, 10, 9,118,105,101,119, 32, 61, - 32,110,111,114,109, 97,108,105,122,101, 40,108,111, 99, 97,108, 41, 59, 13, 10, 9,103,108,111, 98, 97,108, 32, 61, 32, 40,118, -105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40,108,111, 99, 97,108, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, - 13, 10, 9,111,114, 99,111, 32, 61, 32, 97,116,116,111,114, 99,111, 59, 13, 10, 9,117,118, 95, 97,116,116,114,105, 98,117,116, -101, 40, 97,116,116,117,118, 44, 32,117,118, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108, -105,122,101, 40,110,111,114, 41, 59, 9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, - 97,108, 32,105,115, 32,110,101,103, 97,116,101,100, 32, 42, 47, 13, 10, 9,118, 99,111,108, 95, 97,116,116,114,105, 98,117,116, -101, 40, 97,116,116,118, 99,111,108, 44, 32,118, 99,111,108, 41, 59, 13, 10, 9,118, 99,111,108, 95, 97,108,112,104, 97, 32, 61, - 32, 97,116,116,118, 99,111,108, 46, 97, 59, 13, 10, 9,102,114,111,110,116, 98, 97, 99,107, 32, 61, 32, 49, 46, 48, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,109, 97,116, 52, - 32,109, 97,116, 44, 32,118,101, 99, 51, 32,109,105,110,118,101, 99, 44, 32,118,101, 99, 51, 32,109, 97,120,118,101, 99, 44, 32, -102,108,111, 97,116, 32,100,111,109,105,110, 44, 32,102,108,111, 97,116, 32,100,111,109, 97,120, 44, 32,111,117,116, 32,118,101, - 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32, 40,109, 97,116, 32, 42, 32, -118,101, 99, 52, 40,118,101, 99, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10, 9,105,102, 40,100,111,109,105,110, 32, - 61, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32,109, 97,120, 40,111,117,116,118,101, 99, 44, 32, -109,105,110,118,101, 99, 41, 59, 13, 10, 9,105,102, 40,100,111,109, 97,120, 32, 61, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111, -117,116,118,101, 99, 32, 61, 32,109,105,110, 40,111,117,116,118,101, 99, 44, 32,109, 97,120,118,101, 99, 41, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32, 99, 97,109,101,114, 97, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, - 32,111,117,116,118,105,101,119, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,101,112,116,104, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,111,117,116,100,105,115,116, 41, 13, 10,123, 13, 10, 9,111,117,116,100,101,112,116,104, 32, 61, - 32, 97, 98,115, 40, 99,111, 46,122, 41, 59, 13, 10, 9,111,117,116,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40, 99, -111, 41, 59, 13, 10, 9,111,117,116,118,105,101,119, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 41, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,100,100, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102, -108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, - 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 43, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111, -105,100, 32,109, 97,116,104, 95,115,117, 98,116,114, 97, 99,116, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, - 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9, -111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 45, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,109, 97,116,104, 95,109,117,108,116,105,112,108,121, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, - 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117, -116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 42, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, - 97,116,104, 95,100,105,118,105,100,101, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, - 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, 97, -108, 50, 32, 61, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108, -115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 47, 32,118, 97,108, 50, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,109, 97,116,104, 95,115,105,110,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,115,105,110, 40, -118, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 99,111,115,105,110,101, 40,102,108,111, - 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111, -117,116,118, 97,108, 32, 61, 32, 99,111,115, 40,118, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116, -104, 95,116, 97,110,103,101,110,116, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111, -117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,116, 97,110, 40,118, 97,108, 41, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,115,105,110, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111, -117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, 97,108, 32, 60, 61, - 32, 49, 46, 48, 32, 38, 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, - 32, 97,115,105,110, 40,118, 97,108, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, - 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97, 99,111,115, 40,102,108,111, 97,116, 32,118, - 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, - 97,108, 32, 60, 61, 32, 49, 46, 48, 32, 38, 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, -118, 97,108, 32, 61, 32, 97, 99,111,115, 40,118, 97,108, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97, -108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,116, 97,110, 40,102,108, -111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9, -111,117,116,118, 97,108, 32, 61, 32, 97,116, 97,110, 40,118, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, - 97,116,104, 95,112,111,119, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32, -111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 32, 40,118, 97,108, 49, 32, - 62, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,112,111,119, 40,118, 97,108, 49, 44, 32,118, 97, -108, 50, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95,108,111,103, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, - 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9, -105,102, 40,118, 97,108, 49, 32, 62, 32, 48, 46, 48, 32, 32, 38, 38, 32,118, 97,108, 50, 32, 62, 32, 48, 46, 48, 41, 13, 10, 9, - 9,111,117,116,118, 97,108, 61, 32,108,111,103, 50, 40,118, 97,108, 49, 41, 32, 47, 32,108,111,103, 50, 40,118, 97,108, 50, 41, - 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109, 97,116,104, 95,109, 97,120, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, - 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, - 97,108, 32, 61, 32,109, 97,120, 40,118, 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,109, 97,116,104, 95,109,105,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, - 61, 32,109,105,110, 40,118, 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97, -116,104, 95,114,111,117,110,100, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117, -116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 61, 32,102,108,111,111,114, 40,118, 97,108, 32, 43, 32, 48, - 46, 53, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95,108,101,115,115, 95,116,104, 97,110, 40,102, -108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, - 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 40,118, 97,108, 49, 32, 60, 32,118, 97,108, 50, 41, 13, 10, 9, - 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,118, 97,108, 32, - 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, 97,116,104, 95,103,114,101, 97,116,101,114, 95,116, -104, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,105,102, 40,118, 97,108, 49, 32, 62, 32,118, 97,108, - 50, 41, 13, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117, -116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,113,117,101,101,122,101, 40,102, -108,111, 97,116, 32,118, 97,108, 44, 32,102,108,111, 97,116, 32,119,105,100,116,104, 44, 32,102,108,111, 97,116, 32, 99,101,110, -116,101,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, - 97,108, 32, 61, 32, 49, 46, 48, 47, 40, 49, 46, 48, 32, 43, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 51, 44, 32, - 45, 40, 40,118, 97,108, 45, 99,101,110,116,101,114, 41, 42,119,105,100,116,104, 41, 41, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 97,100,100, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, - 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117, -116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 13, 10, 9,111, -117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40,111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117, -116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, 41, 47, 51, 46, 48, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,115,117, 98, 40,118,101, 99, 51, 32,118, 49, 44, - 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 45, 32, -118, 50, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40,111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, - 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, - 41, 47, 51, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 97,118,101,114, 97, -103,101, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117, -116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116, -118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,108,101,110,103,116,104, - 40,111,117,116,118,101, 99, 41, 59, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,111, -117,116,118,101, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,100,111,116, 40, + 10,102,108,111, 97,116, 32, +101,120,112, 95, 98,108,101,110,100,101,114, 40,102,108,111, 97,116, 32,102, 41, 10,123, 10, 9,114,101,116,117,114,110, 32,112, +111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 50, 56, 52, 54, 44, 32,102, 41, 59, 10,125, 10, 10,118,111,105,100, 32,114,103, + 98, 95,116,111, 95,104,115,118, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99, +111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32, 99,109, 97,120, 44, 32, 99,109,105,110, 44, 32,104, 44, 32,115, 44, 32,118, + 44, 32, 99,100,101,108,116, 97, 59, 10, 9,118,101, 99, 51, 32, 99, 59, 10, 10, 9, 99,109, 97,120, 32, 61, 32,109, 97,120, 40, +114,103, 98, 91, 48, 93, 44, 32,109, 97,120, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, 98, 91, 50, 93, 41, 41, 59, 10, 9, 99, +109,105,110, 32, 61, 32,109,105,110, 40,114,103, 98, 91, 48, 93, 44, 32,109,105,110, 40,114,103, 98, 91, 49, 93, 44, 32,114,103, + 98, 91, 50, 93, 41, 41, 59, 10, 9, 99,100,101,108,116, 97, 32, 61, 32, 99,109, 97,120, 45, 99,109,105,110, 59, 10, 10, 9,118, + 32, 61, 32, 99,109, 97,120, 59, 10, 9,105,102, 32, 40, 99,109, 97,120, 33, 61, 48, 46, 48, 41, 10, 9, 9,115, 32, 61, 32, 99, +100,101,108,116, 97, 47, 99,109, 97,120, 59, 10, 9,101,108,115,101, 32,123, 10, 9, 9,115, 32, 61, 32, 48, 46, 48, 59, 10, 9, + 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 10, 9,105,102, 32, 40,115, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, + 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9, 99, 32, 61, 32, 40,118,101, 99, 51, + 40, 99,109, 97,120, 44, 32, 99,109, 97,120, 44, 32, 99,109, 97,120, 41, 32, 45, 32,114,103, 98, 46,120,121,122, 41, 47, 99,100, +101,108,116, 97, 59, 10, 10, 9, 9,105,102, 32, 40,114,103, 98, 46,120, 61, 61, 99,109, 97,120, 41, 32,104, 32, 61, 32, 99, 91, + 50, 93, 32, 45, 32, 99, 91, 49, 93, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,114,103, 98, 46,121, 61, 61, 99,109, 97, +120, 41, 32,104, 32, 61, 32, 50, 46, 48, 32, 43, 32, 99, 91, 48, 93, 32, 45, 32, 32, 99, 91, 50, 93, 59, 10, 9, 9,101,108,115, +101, 32,104, 32, 61, 32, 52, 46, 48, 32, 43, 32, 99, 91, 49, 93, 32, 45, 32, 99, 91, 48, 93, 59, 10, 10, 9, 9,104, 32, 47, 61, + 32, 54, 46, 48, 59, 10, 10, 9, 9,105,102, 32, 40,104, 60, 48, 46, 48, 41, 10, 9, 9, 9,104, 32, 43, 61, 32, 49, 46, 48, 59, + 10, 9,125, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,104, 44, 32,115, 44, 32,118, 44, 32,114,103, 98, + 46,119, 41, 59, 10,125, 10, 10,118,111,105,100, 32,104,115,118, 95,116,111, 95,114,103, 98, 40,118,101, 99, 52, 32,104,115,118, + 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,105, 44, 32,102, + 44, 32,112, 44, 32,113, 44, 32,116, 44, 32,104, 44, 32,115, 44, 32,118, 59, 10, 9,118,101, 99, 51, 32,114,103, 98, 59, 10, 10, + 9,104, 32, 61, 32,104,115,118, 91, 48, 93, 59, 10, 9,115, 32, 61, 32,104,115,118, 91, 49, 93, 59, 10, 9,118, 32, 61, 32,104, +115,118, 91, 50, 93, 59, 10, 10, 9,105,102, 40,115, 61, 61, 48, 46, 48, 41, 32,123, 10, 9, 9,114,103, 98, 32, 61, 32,118,101, + 99, 51, 40,118, 44, 32,118, 44, 32,118, 41, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,105,102, 40,104, 61, 61, + 49, 46, 48, 41, 10, 9, 9, 9,104, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 10, 9, 9,104, 32, 42, 61, 32, 54, 46, 48, 59, 10, + 9, 9,105, 32, 61, 32,102,108,111,111,114, 40,104, 41, 59, 10, 9, 9,102, 32, 61, 32,104, 32, 45, 32,105, 59, 10, 9, 9,114, +103, 98, 32, 61, 32,118,101, 99, 51, 40,102, 44, 32,102, 44, 32,102, 41, 59, 10, 9, 9,112, 32, 61, 32,118, 42, 40, 49, 46, 48, + 45,115, 41, 59, 10, 9, 9,113, 32, 61, 32,118, 42, 40, 49, 46, 48, 45, 40,115, 42,102, 41, 41, 59, 10, 9, 9,116, 32, 61, 32, +118, 42, 40, 49, 46, 48, 45, 40,115, 42, 40, 49, 46, 48, 45,102, 41, 41, 41, 59, 10, 9, 9, 10, 9, 9,105,102, 32, 40,105, 32, + 61, 61, 32, 48, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,116, 44, 32,112, 41, 59, 10, 9, 9,101, +108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 49, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,113, 44, 32, +118, 44, 32,112, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 50, 46, 48, 41, 32,114,103, 98, 32, + 61, 32,118,101, 99, 51, 40,112, 44, 32,118, 44, 32,116, 41, 59, 10, 9, 9,101,108,115,101, 32,105,102, 32, 40,105, 32, 61, 61, + 32, 51, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,112, 44, 32,113, 44, 32,118, 41, 59, 10, 9, 9,101,108,115, +101, 32,105,102, 32, 40,105, 32, 61, 61, 32, 52, 46, 48, 41, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,116, 44, 32,112, 44, + 32,118, 41, 59, 10, 9, 9,101,108,115,101, 32,114,103, 98, 32, 61, 32,118,101, 99, 51, 40,118, 44, 32,112, 44, 32,113, 41, 59, + 10, 9,125, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 44, 32,104,115,118, 46,119, 41, 59, + 10,125, 10, 10,102,108,111, 97,116, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40,102,108,111, 97, +116, 32, 99, 41, 10,123, 10, 9,105,102, 40, 99, 32, 60, 32, 48, 46, 48, 52, 48, 52, 53, 41, 10, 9, 9,114,101,116,117,114,110, + 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, 32, 48, 46, 48, 58, 32, 99, 32, 42, 32, 40, 49, 46, 48, 47, 49, 50, 46, 57, 50, 41, + 59, 10, 9,101,108,115,101, 10, 9, 9,114,101,116,117,114,110, 32,112,111,119, 40, 40, 99, 32, 43, 32, 48, 46, 48, 53, 53, 41, + 42, 40, 49, 46, 48, 47, 49, 46, 48, 53, 53, 41, 44, 32, 50, 46, 52, 41, 59, 10,125, 10, 10,102,108,111, 97,116, 32,108,105,110, +101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40,102,108,111, 97,116, 32, 99, 41, 10,123, 10, 9,105,102, 40, 99, 32, + 60, 32, 48, 46, 48, 48, 51, 49, 51, 48, 56, 41, 10, 9, 9,114,101,116,117,114,110, 32, 40, 99, 32, 60, 32, 48, 46, 48, 41, 63, + 32, 48, 46, 48, 58, 32, 99, 32, 42, 32, 49, 50, 46, 57, 50, 59, 10, 9,101,108,115,101, 10, 9, 9,114,101,116,117,114,110, 32, + 49, 46, 48, 53, 53, 32, 42, 32,112,111,119, 40, 99, 44, 32, 49, 46, 48, 47, 50, 46, 52, 41, 32, 45, 32, 48, 46, 48, 53, 53, 59, + 10,125, 10, 10,118,111,105,100, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40,118,101, 99, 52, 32, + 99,111,108, 95,102,114,111,109, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 10,123, 10, 9, 99,111, +108, 95,116,111, 46,114, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102, +114,111,109, 46,114, 41, 59, 10, 9, 99,111,108, 95,116,111, 46,103, 32, 61, 32,115,114,103, 98, 95,116,111, 95,108,105,110,101, + 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,103, 41, 59, 10, 9, 99,111,108, 95,116,111, 46, 98, 32, 61, 32,115, +114,103, 98, 95,116,111, 95,108,105,110,101, 97,114,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, 59, 10, 9, 99, +111,108, 95,116,111, 46, 97, 32, 61, 32, 99,111,108, 95,102,114,111,109, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,108,105, +110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, 95,102,114,111,109, 44, 32,111, +117,116, 32,118,101, 99, 52, 32, 99,111,108, 95,116,111, 41, 10,123, 10, 9, 99,111,108, 95,116,111, 46,114, 32, 61, 32,108,105, +110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46,114, 41, 59, 10, 9, 99,111, +108, 95,116,111, 46,103, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, 95,115,114,103, 98, 40, 99,111,108, 95,102, +114,111,109, 46,103, 41, 59, 10, 9, 99,111,108, 95,116,111, 46, 98, 32, 61, 32,108,105,110,101, 97,114,114,103, 98, 95,116,111, + 95,115,114,103, 98, 40, 99,111,108, 95,102,114,111,109, 46, 98, 41, 59, 10, 9, 99,111,108, 95,116,111, 46, 97, 32, 61, 32, 99, +111,108, 95,102,114,111,109, 46, 97, 59, 10,125, 10, 10, 35,100,101,102,105,110,101, 32, 77, 95, 80, 73, 32, 51, 46, 49, 52, 49, + 53, 57, 50, 54, 53, 51, 53, 56, 57, 55, 57, 51, 50, 51, 56, 52, 54, 10, 35,100,101,102,105,110,101, 32, 77, 95, 49, 95, 80, 73, + 32, 48, 46, 51, 49, 56, 51, 48, 57, 56, 56, 54, 49, 56, 51, 55, 57, 48, 54, 57, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, + 10, 10,118,111,105,100, 32,118, 99,111,108, 95, 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 52, 32, 97,116,116,118, 99, +111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 41, 10,123, 10, 9,118, 99,111,108, 32, 61, 32,118,101, 99, + 52, 40, 97,116,116,118, 99,111,108, 46,120, 47, 50, 53, 53, 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,121, 47, 50, 53, 53, + 46, 48, 44, 32, 97,116,116,118, 99,111,108, 46,122, 47, 50, 53, 53, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111, +105,100, 32,117,118, 95, 97,116,116,114,105, 98,117,116,101, 40,118,101, 99, 50, 32, 97,116,116,117,118, 44, 32,111,117,116, 32, +118,101, 99, 51, 32,117,118, 41, 10,123, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, + 45, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32, +103,101,111,109, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,109, 97,116, 52, 32,118,105,101, +119,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 97,116,116,111,114, 99,111, 44, 32,118,101, 99, 50, 32, 97,116,116,117, +118, 44, 32,118,101, 99, 52, 32, 97,116,116,118, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, + 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,111, 99, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117,116, + 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,118, 99,111,108, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,118, 99,111,108, 95, 97,108,112,104, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102,114,111, +110,116, 98, 97, 99,107, 41, 10,123, 10, 9,108,111, 99, 97,108, 32, 61, 32, 99,111, 59, 10, 9,118,105,101,119, 32, 61, 32,110, +111,114,109, 97,108,105,122,101, 40,108,111, 99, 97,108, 41, 59, 10, 9,103,108,111, 98, 97,108, 32, 61, 32, 40,118,105,101,119, +105,110,118,109, 97,116, 42,118,101, 99, 52, 40,108,111, 99, 97,108, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 10, 9,111, +114, 99,111, 32, 61, 32, 97,116,116,111,114, 99,111, 59, 10, 9,117,118, 95, 97,116,116,114,105, 98,117,116,101, 40, 97,116,116, +117,118, 44, 32,117,118, 41, 59, 10, 9,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108,105,122,101, 40,110,111, +114, 41, 59, 9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,105,115, 32, +110,101,103, 97,116,101,100, 32, 42, 47, 10, 9,118, 99,111,108, 95, 97,116,116,114,105, 98,117,116,101, 40, 97,116,116,118, 99, +111,108, 44, 32,118, 99,111,108, 41, 59, 10, 9,118, 99,111,108, 95, 97,108,112,104, 97, 32, 61, 32, 97,116,116,118, 99,111,108, + 46, 97, 59, 10, 9,102,114,111,110,116, 98, 97, 99,107, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97, +112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,109, 97,116, 52, 32,109, 97,116, 44, 32,118,101, 99, 51, 32,109, +105,110,118,101, 99, 44, 32,118,101, 99, 51, 32,109, 97,120,118,101, 99, 44, 32,102,108,111, 97,116, 32,100,111,109,105,110, 44, + 32,102,108,111, 97,116, 32,100,111,109, 97,120, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, + 10, 9,111,117,116,118,101, 99, 32, 61, 32, 40,109, 97,116, 32, 42, 32,118,101, 99, 52, 40,118,101, 99, 44, 32, 49, 46, 48, 41, + 41, 46,120,121,122, 59, 10, 9,105,102, 40,100,111,109,105,110, 32, 61, 61, 32, 49, 46, 48, 41, 10, 9, 9,111,117,116,118,101, + 99, 32, 61, 32,109, 97,120, 40,111,117,116,118,101, 99, 44, 32,109,105,110,118,101, 99, 41, 59, 10, 9,105,102, 40,100,111,109, + 97,120, 32, 61, 61, 32, 49, 46, 48, 41, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32,109,105,110, 40,111,117,116,118,101, 99, + 44, 32,109, 97,120,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32, 99, 97,109,101,114, 97, 40,118,101, 99, 51, 32, 99, +111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,105,101,119, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111, +117,116,100,101,112,116,104, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,105,115,116, 41, 10,123, 10, 9,111, +117,116,100,101,112,116,104, 32, 61, 32, 97, 98,115, 40, 99,111, 46,122, 41, 59, 10, 9,111,117,116,100,105,115,116, 32, 61, 32, +108,101,110,103,116,104, 40, 99,111, 41, 59, 10, 9,111,117,116,118,105,101,119, 32, 61, 32,110,111,114,109, 97,108,105,122,101, + 40, 99,111, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,100,100, 40,102,108,111, 97,116, 32,118, 97,108, + 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, + 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 43, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105, +100, 32,109, 97,116,104, 95,115,117, 98,116,114, 97, 99,116, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97, +116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116, +118, 97,108, 32, 61, 32,118, 97,108, 49, 32, 45, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, +109,117,108,116,105,112,108,121, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, + 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, + 97,108, 49, 32, 42, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,100,105,118,105,100,101, 40, +102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 32, 40,118, 97,108, 50, 32, 61, 61, 32, 48, 46, 48, 41, 10, 9, 9, +111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,118, + 97,108, 49, 32, 47, 32,118, 97,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,115,105,110,101, 40,102,108, +111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117, +116,118, 97,108, 32, 61, 32,115,105,110, 40,118, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, 99,111, +115,105,110,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, + 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 99,111,115, 40,118, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32, +109, 97,116,104, 95,116, 97,110,103,101,110,116, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,116, 97,110, 40,118, 97,108, 41, 59, 10, +125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95, 97,115,105,110, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 32, 40,118, 97,108, 32, 60, 61, 32, 49, 46, 48, + 32, 38, 38, 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 97,115,105,110, + 40,118, 97,108, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10, +118,111,105,100, 32,109, 97,116,104, 95, 97, 99,111,115, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 32, 40,118, 97,108, 32, 60, 61, 32, 49, 46, 48, 32, 38, 38, + 32,118, 97,108, 32, 62, 61, 32, 45, 49, 46, 48, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 97, 99,111,115, 40,118, 97, +108, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105, +100, 32,109, 97,116,104, 95, 97,116, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, + 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 97,116, 97,110, 40,118, 97,108, 41, 59, 10, +125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,112,111,119, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, + 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, + 32, 40,118, 97,108, 49, 32, 62, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32,112,111,119, 40,118, 97, +108, 49, 44, 32,118, 97,108, 50, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, + 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,108,111,103, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108, +111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105, +102, 40,118, 97,108, 49, 32, 62, 32, 48, 46, 48, 32, 32, 38, 38, 32,118, 97,108, 50, 32, 62, 32, 48, 46, 48, 41, 10, 9, 9,111, +117,116,118, 97,108, 61, 32,108,111,103, 50, 40,118, 97,108, 49, 41, 32, 47, 32,108,111,103, 50, 40,118, 97,108, 50, 41, 59, 10, + 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97,108, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116, +104, 95,109, 97,120, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,109, 97,120, 40, +118, 97,108, 49, 44, 32,118, 97,108, 50, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,109,105,110, 40,102,108, +111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, +111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,109,105,110, 40,118, 97,108, 49, 44, 32,118, 97, +108, 50, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,114,111,117,110,100, 40,102,108,111, 97,116, 32,118, 97, +108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 61, 32, +102,108,111,111,114, 40,118, 97,108, 32, 43, 32, 48, 46, 53, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,108, +101,115,115, 95,116,104, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, + 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 40,118, 97,108, 49, 32, 60, 32, +118, 97,108, 50, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117, +116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109, 97,116,104, 95,103,114,101, 97,116,101,114, + 95,116,104, 97,110, 40,102,108,111, 97,116, 32,118, 97,108, 49, 44, 32,102,108,111, 97,116, 32,118, 97,108, 50, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,105,102, 40,118, 97,108, 49, 32, 62, 32,118, 97,108, + 50, 41, 10, 9, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,118, 97, +108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,115,113,117,101,101,122,101, 40,102,108,111, 97,116, 32,118, + 97,108, 44, 32,102,108,111, 97,116, 32,119,105,100,116,104, 44, 32,102,108,111, 97,116, 32, 99,101,110,116,101,114, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, + 47, 40, 49, 46, 48, 32, 43, 32,112,111,119, 40, 50, 46, 55, 49, 56, 50, 56, 49, 56, 51, 44, 32, 45, 40, 40,118, 97,108, 45, 99, +101,110,116,101,114, 41, 42,119,105,100,116,104, 41, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116, +104, 95, 97,100,100, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, + 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117, +116,118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40,111, +117,116,118,101, 99, 91, 48, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98,115, + 40,111,117,116,118,101, 99, 91, 50, 93, 41, 41, 47, 51, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97, +116,104, 95,115,117, 98, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111, +117,116,118,101, 99, 32, 61, 32,118, 49, 32, 45, 32,118, 50, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 97, 98,115, 40, +111,117,116,118,101, 99, 91, 48, 93, 41, 32, 43, 32, 97, 98,115, 40,111,117,116,118,101, 99, 91, 49, 93, 41, 32, 43, 32, 97, 98, +115, 40,111,117,116,118,101, 99, 91, 50, 93, 41, 41, 47, 51, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, + 97,116,104, 95, 97,118,101,114, 97,103,101, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117, +116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, + 10,123, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118, 49, 32, 43, 32,118, 50, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32, +108,101,110,103,116,104, 40,111,117,116,118,101, 99, 41, 59, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111,114,109, 97,108, +105,122,101, 40,111,117,116,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,100,111, +116, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, +118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118,101, 99, + 32, 61, 32,118,101, 99, 51, 40, 48, 44, 32, 48, 44, 32, 48, 41, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32,100,111,116, 40, +118, 49, 44, 32,118, 50, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 99,114,111,115,115, 40, 118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, - 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, - 32, 61, 32,118,101, 99, 51, 40, 48, 44, 32, 48, 44, 32, 48, 41, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,100,111,116, - 40,118, 49, 44, 32,118, 50, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, 99,114, -111,115,115, 40,118,101, 99, 51, 32,118, 49, 44, 32,118,101, 99, 51, 32,118, 50, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, -117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117, -116,118,101, 99, 32, 61, 32, 99,114,111,115,115, 40,118, 49, 44, 32,118, 50, 41, 59, 13, 10, 9,111,117,116,118, 97,108, 32, 61, - 32,108,101,110,103,116,104, 40,111,117,116,118,101, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95, -109, 97,116,104, 95,110,111,114,109, 97,108,105,122,101, 40,118,101, 99, 51, 32,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32, -111,117,116,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111, -117,116,118, 97,108, 32, 61, 32,108,101,110,103,116,104, 40,118, 41, 59, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111, -114,109, 97,108,105,122,101, 40,118, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95, -110,101,103, 97,116,101, 40,118,101, 99, 51, 32,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 41, 13, 10,123, - 13, 10, 9,111,117,116,118, 32, 61, 32, 45,118, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,114,109, 97,108, 40, -118,101, 99, 51, 32,100,105,114, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, -110,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,111,116, 41, 13, 10,123, 13, 10, 9,111,117,116,110, -111,114, 32, 61, 32,110,111,114, 59, 13, 10, 9,111,117,116,100,111,116, 32, 61, 32, 45,100,111,116, 40,100,105,114, 44, 32,110, -111,114, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,118,101, 99, 40,102,108,111, 97,116, - 32,102, 97, 99, 44, 32,118,101, 99, 51, 32,118,101, 99, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, - 97,112, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, - 46,120, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, 40,118, -101, 99, 46,120, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 13, 10, 9,111,117,116,118, -101, 99, 46,121, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, - 40,118,101, 99, 46,121, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,121, 59, 13, 10, 9,111,117, -116,118,101, 99, 46,122, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, - 50, 40, 40,118,101, 99, 46,122, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,122, 59, 13, 10, 13, - 10, 9,105,102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32, 40,111, -117,116,118,101, 99, 42,102, 97, 99, 41, 32, 43, 32, 40,118,101, 99, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 13, 10, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, - 32,118,101, 99, 52, 32, 99,111,108, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, 44, 32,111, -117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, -116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, - 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46,114, 44, 32, 48, 46, 48, 41, 41, 46, 97, - 44, 32, 48, 46, 48, 41, 41, 46,114, 59, 13, 10, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,101,120,116,117,114,101, 50, + 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118,101, 99, 32, 61, + 32, 99,114,111,115,115, 40,118, 49, 44, 32,118, 50, 41, 59, 10, 9,111,117,116,118, 97,108, 32, 61, 32,108,101,110,103,116,104, + 40,111,117,116,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,110,111,114,109, 97, +108,105,122,101, 40,118,101, 99, 51, 32,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,108,101,110,103, +116,104, 40,118, 41, 59, 10, 9,111,117,116,118,101, 99, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 41, 59, 10,125, + 10, 10,118,111,105,100, 32,118,101, 99, 95,109, 97,116,104, 95,110,101,103, 97,116,101, 40,118,101, 99, 51, 32,118, 44, 32,111, +117,116, 32,118,101, 99, 51, 32,111,117,116,118, 41, 10,123, 10, 9,111,117,116,118, 32, 61, 32, 45,118, 59, 10,125, 10, 10,118, +111,105,100, 32,110,111,114,109, 97,108, 40,118,101, 99, 51, 32,100,105,114, 44, 32,118,101, 99, 51, 32,110,111,114, 44, 32,111, +117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,100,111,116, + 41, 10,123, 10, 9,111,117,116,110,111,114, 32, 61, 32,110,111,114, 59, 10, 9,111,117,116,100,111,116, 32, 61, 32, 45,100,111, +116, 40,100,105,114, 44, 32,110,111,114, 41, 59, 10,125, 10, 10,118,111,105,100, 32, 99,117,114,118,101,115, 95,118,101, 99, 40, +102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 51, 32,118,101, 99, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99, +117,114,118,101,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10, 9,111,117,116, +118,101, 99, 46,120, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, + 40, 40,118,101, 99, 46,120, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 10, 9,111,117, +116,118,101, 99, 46,121, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, + 50, 40, 40,118,101, 99, 46,121, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,121, 59, 10, 9,111, +117,116,118,101, 99, 46,122, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, + 99, 50, 40, 40,118,101, 99, 46,122, 32, 43, 32, 49, 46, 48, 41, 42, 48, 46, 53, 44, 32, 48, 46, 48, 41, 41, 46,122, 59, 10, 10, + 9,105,102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, 48, 41, 10, 9, 9,111,117,116,118,101, 99, 32, 61, 32, 40,111,117,116, +118,101, 99, 42,102, 97, 99, 41, 32, 43, 32, 40,118,101, 99, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 10, 10,125, 10, 10, +118,111,105,100, 32, 99,117,114,118,101,115, 95,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, + 99,111,108, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, + 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101, -109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46,103, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, -103, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, - 97,112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, - 50, 40, 99,111,108, 46, 98, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, 98, 59, 13, 10, 13, 10, 9,105, -102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32, 40,111,117,116, 99, -111,108, 42,102, 97, 99, 41, 32, 43, 32, 40, 99,111,108, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 13, 10, 13, 10, 9,111, -117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,101,116, 95, -118, 97,108,117,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97, -108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,101,116, 95,114,103, 98, 40,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99, -111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,115,101,116, 95,114,103, 98, 97, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117, -116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,115,101,116, 95,118, 97,108,117,101, 95,122,101,114,111, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, -118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111, -105,100, 32,115,101,116, 95,118, 97,108,117,101, 95,111,110,101, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97, -108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,101,116, 95,114,103, 98, 95,122,101,114,111, 40,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 97,108, 41, 13, 10, -123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111, -105,100, 32,115,101,116, 95,114,103, 98, 97, 95,122,101,114,111, 40,111,117,116, 32,118,101, 99, 52, 32,111,117,116,118, 97,108, - 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118,101, 99, 52, 40, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,109,105,120, 95, 98,108,101,110,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, - 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, - 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, - 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 50, 44, 32,102, 97, - 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109,105,120, 95, 97,100,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, - 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, - 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, - 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, 44, - 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,109,105,120, 95,109,117,108,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, - 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, - 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, - 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 42, 32, 99, -111,108, 50, 44, 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115, 99,114,101,101,110, 40,102,108,111, 97,116, 32,102, 97, 99, 44, - 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, - 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, - 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 40,118,101, 99, - 52, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99, 42, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 50, 41, - 41, 42, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 49, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, - 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,111,118,101,114,108, 97, -121, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, - 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99, -108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99, -109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, - 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, 99, -111,108, 46,114, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 13, 10, - 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, - 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46,114, 41, 41, 42, 40, 49, 46, 48, 32, 45, - 32,111,117,116, 99,111,108, 46,114, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, 32, 60, 32, 48, 46, - 53, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, - 42, 99,111,108, 50, 46,103, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, - 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46, -103, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, - 99,111,108, 46, 98, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 42, 61, 32,102, 97, 99,109, - 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, - 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, - 46, 48, 32, 45, 32, 99,111,108, 50, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, 41, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115,117, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, - 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, - 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, - 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, - 45, 32, 99,111,108, 50, 44, 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, - 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100,105,118, 40,102,108,111, 97,116, 32,102, 97, 99, 44, - 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, - 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, - 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,105,102, 40, 99,111,108, - 50, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,114, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99, -111,108, 46,114, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,114, 47, 99,111,108, 50, 46,114, 59, 13, 10, 9,105,102, - 40, 99,111,108, 50, 46,103, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,103, 32, 61, 32,102, 97, 99,109, 42, -111,117,116, 99,111,108, 46,103, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,103, 47, 99,111,108, 50, 46,103, 59, 13, - 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46, 98, 32, 61, 32,102, - 97, 99,109, 42,111,117,116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46, 98, 47, 99,111,108, 50, - 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100,105,102,102, 40,102,108,111, 97,116, 32,102, 97, - 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, - 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, - 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, - 97, 98,115, 40, 99,111,108, 49, 32, 45, 32, 99,111,108, 50, 41, 44, 32,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, - 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100, 97,114,107, - 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, - 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, - 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46,114,103, 98, - 32, 61, 32,109,105,110, 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114,103, 98, 42,102, 97, 99, 41, 59, 13, - 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, -109,105,120, 95,108,105,103,104,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32, -118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, - 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111, -117,116, 99,111,108, 46,114,103, 98, 32, 61, 32,109, 97,120, 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114, -103, 98, 42,102, 97, 99, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,100,111,100,103,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, - 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, - 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, - 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,105,102, 40,111,117, -116, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, - 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 13, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, - 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32, -105,102, 40, 40,116,109,112, 32, 61, 32,111,117,116, 99,111,108, 46,114, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 13, 10, - 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,111, -117,116, 99,111,108, 46,114, 32, 61, 32,116,109,112, 59, 13, 10, 9,125, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, - 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32, -102, 97, 99, 42, 99,111,108, 50, 46,103, 59, 13, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, - 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109, -112, 32, 61, 32,111,117,116, 99,111,108, 46,103, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, - 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46, -103, 32, 61, 32,116,109,112, 59, 13, 10, 9,125, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, - 48, 41, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111, -108, 50, 46, 98, 59, 13, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, 99, -111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32,111,117, -116, 99,111,108, 46, 98, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, - 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116,109, -112, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95, 98,117,114,110, 40,102,108,111, 97,116, +109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46,114, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, +114, 59, 10, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97, +112, 44, 32,118,101, 99, 50, 40,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, + 40, 99,111,108, 46,103, 44, 32, 48, 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46,103, 59, 10, 9,111,117,116, 99,111, +108, 46, 98, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,116, +101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40, 99,111,108, 46, 98, 44, 32, 48, + 46, 48, 41, 41, 46, 97, 44, 32, 48, 46, 48, 41, 41, 46, 98, 59, 10, 10, 9,105,102, 32, 40,102, 97, 99, 32, 33, 61, 32, 49, 46, + 48, 41, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32, 40,111,117,116, 99,111,108, 42,102, 97, 99, 41, 32, 43, 32, 40, 99,111, +108, 42, 40, 49, 46, 48, 45,102, 97, 99, 41, 41, 59, 10, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 46, 97, + 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,118, 97,108,117,101, 40,102,108,111, 97,116, 32,118, 97,108, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118, 97,108, + 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 40,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32, +118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 10,125, 10, + 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 97, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, + 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 59, 10,125, 10, 10,118,111, +105,100, 32,115,101,116, 95,118, 97,108,117,101, 95,122,101,114,111, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, + 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, + 95,118, 97,108,117,101, 95,111,110,101, 40,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9, +111,117,116,118, 97,108, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 95,122,101, +114,111, 40,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, +118,101, 99, 51, 40, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,116, 95,114,103, 98, 97, 95,122,101,114,111, + 40,111,117,116, 32,118,101, 99, 52, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32,118,101, + 99, 52, 40, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95, 98,108,101,110,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32, -118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, - 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,116,109,112, 44, 32,102, 97, 99,109, 32, - 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, - 10, 13, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 13, 10, 9,105, -102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 48, 46, 48, 59, - 13, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, 45, 32, -111,117,116, 99,111,108, 46,114, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, - 46,114, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, 13, 10, - 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99, -111,108, 46,114, 32, 61, 32,116,109,112, 59, 13, 10, 13, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, - 42, 99,111,108, 50, 46,103, 59, 13, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, - 99,111,108, 46,103, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, - 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, - 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, -116,109,112, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, -101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,109,112, 59, 13, 10, 13, 10, 9,116,109,112, 32, - 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 13, 10, 9,105,102, 40,116,109,112, 32, 60, 61, - 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32, -105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, - 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 48, 46, 48, - 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, - 46, 98, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116, -109,112, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,104,117,101, 40,102,108,111, 97,116, 32,102, 97, 99, - 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, - 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, - 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, - 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32, -104,115,118, 44, 32,104,115,118, 50, 44, 32,116,109,112, 59, 13, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, - 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, 10, 9,105,102, 40,104,115,118, 50, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, 32, -123, 13, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 13, 10, 9, - 9,104,115,118, 46,120, 32, 61, 32,104,115,118, 50, 46,120, 59, 13, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104, -115,118, 44, 32,116,109,112, 41, 59, 32, 13, 10, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, - 99,111,108, 44, 32,116,109,112, 44, 32,102, 97, 99, 41, 59, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111, -108, 49, 46, 97, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115, 97,116, 40,102,108,111, +118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, + 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, + 99,111,108, 50, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10, +125, 10, 10,118,111,105,100, 32,109,105,120, 95, 97,100,100, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, + 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, + 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, + 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, + 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118, +111,105,100, 32,109,105,120, 95,109,117,108,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, + 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, + 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111, +117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 42, 32, 99,111,108, 50, 44, 32,102, + 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, + 32,109,105,120, 95,115, 99,114,101,101,110, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, + 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, + 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108, +111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, + 32,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 40,118,101, 99, 52, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99, 42, 40, +118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 50, 41, 41, 42, 40,118,101, 99, 52, 40, 49, 46, 48, 41, 32, 45, 32, + 99,111,108, 49, 41, 59, 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111, +105,100, 32,109,105,120, 95,111,118,101,114,108, 97,121, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99, +111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, + 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, + 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111, +108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, 53, 41, 10, 9, + 9,111,117,116, 99,111,108, 46,114, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 99,111,108, 50, + 46,114, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, + 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46,114, 41, 41, 42, 40, 49, 46, + 48, 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, 32, 60, 32, 48, + 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, + 42, 99,111,108, 50, 46,103, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 32, + 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111,108, 50, 46,103, 41, + 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, + 98, 32, 60, 32, 48, 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 42, 61, 32,102, 97, 99,109, 32, 43, 32, 50, 46, + 48, 42,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, + 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32, 99,111, +108, 50, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, 41, 59, 10,125, 10, 10,118,111,105,100, + 32,109,105,120, 95,115,117, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118, +101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, + 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111, +108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, 99,111,108, 49, 32, 45, 32, 99,111,108, 50, 44, 32,102, 97, 99, 41, 59, + 10, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, + 95,100,105,118, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, + 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, + 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99, +109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, + 10, 9,105,102, 40, 99,111,108, 50, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,114, 32, 61, 32,102, + 97, 99,109, 42,111,117,116, 99,111,108, 46,114, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,114, 47, 99,111,108, 50, + 46,114, 59, 10, 9,105,102, 40, 99,111,108, 50, 46,103, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, 46,103, 32, + 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,103, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46,103, 47, 99, +111,108, 50, 46,103, 59, 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,111,117,116, 99,111,108, + 46, 98, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99, 42,111,117,116, 99,111,108, 46, + 98, 47, 99,111,108, 50, 46, 98, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,100,105,102,102, 40,102,108,111, 97,116, + 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32, +118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, + 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40, 99,111,108, 49, 44, 32, + 97, 98,115, 40, 99,111,108, 49, 32, 45, 32, 99,111,108, 50, 41, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46, + 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,100, 97,114,107, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, -102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, - 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, - 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 13, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117, -116, 99,111,108, 44, 32,104,115,118, 41, 59, 13, 10, 13, 10, 9,105,102, 40,104,115,118, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, - 32,123, 13, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, - 10, 9, 9,104,115,118, 46,121, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46,121, 32, 43, 32,102, 97, 99, 42,104,115,118, 50, - 46,121, 59, 13, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, 13, - 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,118, 97,108, 40,102,108,111, 97,116, 32,102, 97, 99, +116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, + 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 46,114,103, 98, 32, 61, 32,109,105,110, 40, + 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114,103, 98, 42,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, + 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,108,105,103,104,116, 40,102, +108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32, +111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, +102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 46,114,103, 98, 32, 61, 32,109, 97, +120, 40, 99,111,108, 49, 46,114,103, 98, 44, 32, 99,111,108, 50, 46,114,103, 98, 42,102, 97, 99, 41, 59, 10, 9,111,117,116, 99, +111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,100,111,100,103,101, + 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, + 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109, +112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, + 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108,111, 97, +116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, 59, 10, 9, 9,105,102, 40,116, +109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9, +101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32,111,117,116, 99,111,108, 46,114, 47,116,109,112, 41, 32, 62, 32, 49, + 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, + 9,111,117,116, 99,111,108, 46,114, 32, 61, 32,116,109,112, 59, 10, 9,125, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, + 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108,111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, + 97, 99, 42, 99,111,108, 50, 46,103, 59, 10, 9, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,111, +117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, +111,117,116, 99,111,108, 46,103, 47,116,109,112, 41, 32, 62, 32, 49, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46,103, + 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32,116,109,112, + 59, 10, 9,125, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108, +111, 97,116, 32,116,109,112, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 42, 99,111,108, 50, 46, 98, 59, 10, 9, 9,105,102, + 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 10, + 9, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 47,116,109,112, 41, 32, 62, + 32, 49, 46, 48, 41, 10, 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 10, + 9, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32,116,109,112, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,105, +120, 95, 98,117,114,110, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, + 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, + 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,116, +109,112, 44, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, + 32, 99,111,108, 49, 59, 10, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, 46,114, + 59, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 48, + 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 32, + 45, 32,111,117,116, 99,111,108, 46,114, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111, +108, 46,114, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, 10, 9, + 9,111,117,116, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46, +114, 32, 61, 32,116,109,112, 59, 10, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111,108, 50, + 46,103, 59, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, + 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, 49, 46, + 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, + 99,111,108, 46,103, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, 48, 41, + 10, 9, 9,111,117,116, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111, +108, 46,103, 32, 61, 32,116,109,112, 59, 10, 10, 9,116,109,112, 32, 61, 32,102, 97, 99,109, 32, 43, 32,102, 97, 99, 42, 99,111, +108, 50, 46, 98, 59, 10, 9,105,102, 40,116,109,112, 32, 60, 61, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46, 98, + 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, 40,116,109,112, 32, 61, 32, 40, 49, 46, 48, 32, 45, 32, 40, + 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, 98, 41, 47,116,109,112, 41, 41, 32, 60, 32, 48, 46, 48, 41, 10, 9, 9,111, +117,116, 99,111,108, 46, 98, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40,116,109,112, 32, 62, 32, 49, 46, + 48, 41, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, + 99,111,108, 46, 98, 32, 61, 32,116,109,112, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,104,117,101, 40,102,108,111, + 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117, +116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, + 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, + 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,118,101, 99, 52, 32,104, +115,118, 44, 32,104,115,118, 50, 44, 32,116,109,112, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, + 32,104,115,118, 50, 41, 59, 10, 10, 9,105,102, 40,104,115,118, 50, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9, +114,103, 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 10, 9, 9,104,115,118, 46,120, + 32, 61, 32,104,115,118, 50, 46,120, 59, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,116,109,112, + 41, 59, 32, 10, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, 99,111,108, 44, 32,116,109,112, 44, + 32,102, 97, 99, 41, 59, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, 59, 10, 9,125, 10,125, + 10, 10,118,111,105,100, 32,109,105,120, 95,115, 97,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99, +111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, + 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, + 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111,117,116, 99,111, +108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 10, 9,114,103, 98, + 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 10, 10, 9,105,102, 40,104,115,118, 46,121, + 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115, +118, 50, 41, 59, 10, 10, 9, 9,104,115,118, 46,121, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46,121, 32, 43, 32,102, 97, 99, + 42,104,115,118, 50, 46,121, 59, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111, +108, 41, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,118, 97,108, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, - 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, - 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, - 97, 99, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 13, 10, 9,114,103, 98, 95,116,111, - 95,104,115,118, 40, 99,111,108, 49, 44, 32,104,115,118, 41, 59, 13, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111, -108, 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, 10, 9,104,115,118, 46,122, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46, -122, 32, 43, 32,102, 97, 99, 42,104,115,118, 50, 46,122, 59, 13, 10, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, - 44, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95, 99,111,108,111,114, 40, -102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, - 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97, -109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, - 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 13, - 10, 13, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 44, 32,116,109,112, 59, 13, 10, 9,114,103, 98, 95,116, -111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, 50, 41, 59, 13, 10, 13, 10, 9,105,102, 40,104,115,118, 50, 46,121, - 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, 40,111,117,116, 99,111,108, 44, - 32,104,115,118, 41, 59, 13, 10, 9, 9,104,115,118, 46,120, 32, 61, 32,104,115,118, 50, 46,120, 59, 13, 10, 9, 9,104,115,118, - 46,121, 32, 61, 32,104,115,118, 50, 46,121, 59, 13, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32, -116,109,112, 41, 59, 32, 13, 10, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, 99,111,108, 44, - 32,116,109,112, 44, 32,102, 97, 99, 41, 59, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, 46, 97, - 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,115,111,102,116, 40,102,108,111, 97,116, 32, -102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118, -101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, - 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, - 45, 32,102, 97, 99, 59, 13, 10, 13, 10, 9,118,101, 99, 52, 32,111,110,101, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, - 10, 9,118,101, 99, 52, 32,115, 99,114, 61, 32,111,110,101, 32, 45, 32, 40,111,110,101, 32, 45, 32, 99,111,108, 50, 41, 42, 40, -111,110,101, 32, 45, 32, 99,111,108, 49, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,102, 97, 99,109, 42, 99,111,108, - 49, 32, 43, 32,102, 97, 99, 42, 40, 40,111,110,101, 32, 45, 32, 99,111,108, 49, 41, 42, 99,111,108, 50, 42, 99,111,108, 49, 32, - 43, 32, 99,111,108, 49, 42,115, 99,114, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,105,120, 95,108,105,110,101, - 97,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111, -108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,102, 97, 99, 32, 61, 32, - 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, - 32, 61, 32, 99,111,108, 49, 59, 13, 10, 13, 10, 9,105,102, 40, 99,111,108, 50, 46,114, 32, 62, 32, 48, 46, 53, 41, 13, 10, 9, - 9,111,117,116, 99,111,108, 46,114, 61, 32, 99,111,108, 49, 46,114, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111, -108, 50, 46,114, 32, 45, 32, 48, 46, 53, 41, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,114, - 61, 32, 99,111,108, 49, 46,114, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,114, 41, 32, 45, 32, 49, - 46, 48, 41, 59, 13, 10, 13, 10, 9,105,102, 40, 99,111,108, 50, 46,103, 32, 62, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, - 99,111,108, 46,103, 61, 32, 99,111,108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,103, - 32, 45, 32, 48, 46, 53, 41, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46,103, 61, 32, 99,111, -108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,103, 41, 32, 45, 32, 49, 46, 48, 41, 59, - 13, 10, 13, 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 62, 32, 48, 46, 53, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 46, - 98, 61, 32, 99,111,108, 49, 46, 98, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 32, 45, 32, 48, - 46, 53, 41, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 61, 32, 99,111,108, 49, 46, 98, - 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 41, 32, 45, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,118, 97,108,116,111,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,115, 97,109,112, -108,101,114, 50, 68, 32, 99,111,108,111,114,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, 97,108,112,104, 97, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, - 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,111,108,111,114,109, 97,112, 44, 32,118,101, 99, 50, 40,102, 97, 99, 44, - 32, 48, 46, 48, 41, 41, 59, 13, 10, 9,111,117,116, 97,108,112,104, 97, 32, 61, 32,111,117,116, 99,111,108, 46, 97, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,114,103, 98,116,111, 98,119, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 32, 32, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, - 99,111,108,111,114, 46,114, 42, 48, 46, 51, 53, 32, 43, 32, 99,111,108,111,114, 46,103, 42, 48, 46, 52, 53, 32, 43, 32, 99,111, -108,111,114, 46, 98, 42, 48, 46, 50, 59, 32, 47, 42, 32,107,101,101,112, 32,116,104,101,115,101, 32,102, 97, 99,116,111,114,115, - 32,105,110, 32,115,121,110, 99, 32,119,105,116,104, 32,116,101,120,116,117,114,101, 46,104, 58, 82, 71, 66, 84, 79, 66, 87, 32, - 42, 47, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,105,110,118,101,114,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32, -118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9, -111,117,116, 99,111,108, 46,120,121,122, 32, 61, 32,109,105,120, 40, 99,111,108, 46,120,121,122, 44, 32,118,101, 99, 51, 40, 49, - 46, 48, 44, 32, 49, 46, 48, 44, 32, 49, 46, 48, 41, 32, 45, 32, 99,111,108, 46,120,121,122, 44, 32,102, 97, 99, 41, 59, 13, 10, - 9,111,117,116, 99,111,108, 46,119, 32, 61, 32, 99,111,108, 46,119, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,104,117, -101, 95,115, 97,116, 40,102,108,111, 97,116, 32,104,117,101, 44, 32,102,108,111, 97,116, 32,115, 97,116, 44, 32,102,108,111, 97, -116, 32,118, 97,108,117,101, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32,104,115,118, 59, 13, 10, 13, - 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 44, 32,104,115,118, 41, 59, 13, 10, 13, 10, 9,104,115,118, 91, - 48, 93, 32, 43, 61, 32, 40,104,117,101, 32, 45, 32, 48, 46, 53, 41, 59, 13, 10, 9,105,102, 40,104,115,118, 91, 48, 93, 62, 49, - 46, 48, 41, 32,104,115,118, 91, 48, 93, 45, 61, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, 48, 93, 60, - 48, 46, 48, 41, 32,104,115,118, 91, 48, 93, 43, 61, 32, 49, 46, 48, 59, 13, 10, 9,104,115,118, 91, 49, 93, 32, 42, 61, 32,115, - 97,116, 59, 13, 10, 9,105,102, 40,104,115,118, 91, 49, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 49, 93, 61, 32, 49, 46, 48, - 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, 49, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 49, 93, 61, 32, 48, 46, - 48, 59, 13, 10, 9,104,115,118, 91, 50, 93, 32, 42, 61, 32,118, 97,108,117,101, 59, 13, 10, 9,105,102, 40,104,115,118, 91, 50, - 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, - 50, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 48, 46, 48, 59, 13, 10, 13, 10, 9,104,115,118, 95,116,111, 95, -114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, 13, 10, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109, -105,120, 40, 99,111,108, 44, 32,111,117,116, 99,111,108, 44, 32,102, 97, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,101,112, 97,114, 97,116,101, 95,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 98, 41, 13, 10, -123, 13, 10, 9,114, 32, 61, 32, 99,111,108, 46,114, 59, 13, 10, 9,103, 32, 61, 32, 99,111,108, 46,103, 59, 13, 10, 9, 98, 32, - 61, 32, 99,111,108, 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, 99,111,109, 98,105,110,101, 95,114,103, 98, 40, -102,108,111, 97,116, 32,114, 44, 32,102,108,111, 97,116, 32,103, 44, 32,102,108,111, 97,116, 32, 98, 44, 32,111,117,116, 32,118, -101, 99, 52, 32, 99,111,108, 41, 13, 10,123, 13, 10, 9, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114, 44, 32,103, 44, 32, 98, - 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,111,117,116,112,117,116, 95,110,111,100,101, 40,118, -101, 99, 52, 32,114,103, 98, 44, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, -117,116,114,103, 98, 41, 13, 10,123, 13, 10, 9,111,117,116,114,103, 98, 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 46,114,103, - 98, 44, 32, 97,108,112,104, 97, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 84, 69, - 88, 84, 85, 82, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10,118,111,105,100, 32, -116,101,120,116,117,114,101, 95,102,108,105,112, 95, 98,108,101,110,100, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118,101, 99, 46, -121,120,122, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, 95,108,105, -110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, - 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, 95,113,117, 97,100, 40,118,101, 99, 51, 32, -118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,118, - 97,108, 32, 61, 32,109, 97,120, 40, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 44, 32, 48, 46, 48, 41, 59, 13, - 10, 9,111,117,116,118, 97,108, 32, 42, 61, 32,111,117,116,118, 97,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116, -101,120,116,117,114,101, 95,119,111,111,100, 95,115,105,110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108, -111, 97,116, 32,118, 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118, -101, 99, 51, 32,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, 97, 32, 61, 32,115,113,114,116, 40, -118,101, 99, 46,120, 42,118,101, 99, 46,120, 32, 43, 32,118,101, 99, 46,121, 42,118,101, 99, 46,121, 32, 43, 32,118,101, 99, 46, -122, 42,118,101, 99, 46,122, 41, 42, 50, 48, 46, 48, 59, 13, 10, 9,102,108,111, 97,116, 32,119,105, 32, 61, 32, 48, 46, 53, 32, - 43, 32, 48, 46, 53, 42,115,105,110, 40, 97, 41, 59, 13, 10, 13, 10, 9,118, 97,108,117,101, 32, 61, 32,119,105, 59, 13, 10, 9, - 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40,119,105, 44, 32,119,105, 44, 32,119,105, 44, 32, 49, 46, 48, 41, 59, 13, 10, - 9,110,111,114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95,105,109, 97,103,101, 40,118,101, 99, 51, 32,118,101, 99, - 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118, 97,108,117,101, - 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97, -108, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 40, -118,101, 99, 46,120,121, 32, 43, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, 48, 41, 41, 42, 48, 46, 53, 41, 59, 13, 10, - 9,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 59, 13, 10, 13, 10, 9,110,111,114,109, 97,108, 46,120, 32, 61, 32, 50, 46, 48, - 42, 40, 99,111,108,111,114, 46,114, 32, 45, 32, 48, 46, 53, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 46,121, 32, 61, 32, 50, - 46, 48, 42, 40, 48, 46, 53, 32, 45, 32, 99,111,108,111,114, 46,103, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 46,122, 32, 61, - 32, 50, 46, 48, 42, 40, 99,111,108,111,114, 46, 98, 32, 45, 32, 48, 46, 53, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 77, 84, 69, 88, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 47, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111,114, 99,111, 40,118,101, 99, 51, 32, 97,116,116,111,114, - 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 41, 13, 10,123, 13, 10, 9,111,114, 99,111, 32, 61, 32, 97, -116,116,111,114, 99,111, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,117,118, 40,118,101, 99, 50, - 32, 97,116,116,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 41, 13, 10,123, 13, 10, 9, 47, 42, 32,100,105,115, - 97, 98,108,101,100, 32,102,111,114, 32,110,111,119, 44, 32,119,111,114,107,115, 32,116,111,103,101,116,104,101,114, 32,119,105, -116,104, 32,108,101, 97,118,105,110,103, 32,111,117,116, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 13, 10, - 9, 32, 32, 32,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, 99, 50, 40, 49, - 46, 48, 44, 32, 49, 46, 48, 41, 44, 32, 48, 46, 48, 41, 59, 32, 42, 47, 13, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97, -116,116,117,118, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,110,111,114, -109, 40,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97, -108, 41, 13, 10,123, 13, 10, 9, 47, 42, 32, 99,111,114,114,101,115,112,111,110,100,115, 32,116,111, 32,115,104,105, 45, 62,111, -114,110, 44, 32,119,104,105, 99,104, 32,105,115, 32,110,101,103, 97,116,101,100, 32,115,111, 32, 99, 97,110, 99,101,108,115, 13, - 10, 9, 32, 32, 32,111,117,116, 32, 98,108,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,110,101,103, 97,116,105,111,110, - 32, 42, 47, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,110,111,114,109, - 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,116, 97,110,103,101,110,116, 40,118,101, - 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116, 97,110,103,101,110,116, 41, - 13, 10,123, 13, 10, 9,111,117,116,116, 97,110,103,101,110,116, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,116, 97,110, -103,101,110,116, 46,120,121,122, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,103,108,111, 98, - 97,108, 40,109, 97,116, 52, 32,118,105,101,119,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 41, 13, 10,123, 13, 10, 9,103,108,111, 98, 97,108, 32, 61, 32, 40,118,105,101, -119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111, 98,106,101, 99,116, 40,109, 97,116, 52, 32,118,105,101,119,105,110,118, -109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 41, 13, 10,123, 13, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, 40,111, 98,105, -110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, 48, 41, 41, - 41, 46,120,121,122, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,120, 99,111, 95,114,101,102,108, 40,118,101, 99, - 51, 32,118,110, 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,114,101,102, 41, 13, 10, -123, 13, 10, 9,114,101,102, 32, 61, 32,118,105,101,119, 32, 45, 32, 50, 46, 48, 42,100,111,116, 40,118,110, 44, 32,118,105,101, -119, 41, 42,118,110, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,110,111,114,109, 40,118,101, 99, - 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, - 13, 10, 9, 47, 42, 32, 98,108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,105,115, 32,110, -101,103, 97,116,101,100, 32, 42, 47, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108,105, -122,101, 40,110,111,114,109, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, - 98,108,101,110,100, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32, -102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, - 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99, -116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 13, 10, 13, - 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, - 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,109,117,108, 40,118,101, 99, - 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10, -123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, - 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, - 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 41, 42,111,117,116, 99,111,108, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 99,114,101,101,110, 40,118,101, 99, 51, 32,111,117, -116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9, -102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9, -102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,118,101, 99, - 51, 40, 49, 46, 48, 41, 32, 45, 32, 40,118,101, 99, 51, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99,116, 42, 40,118,101, 99, - 51, 40, 49, 46, 48, 41, 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,111, -117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,111,118,101,114, -108, 97,121, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108, -111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105, -110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, - 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 13, 10, 13, 10, 9, -105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,105,110, 99,111,108, 46,114, 32, 61, 32, -111,117,116, 99,111,108, 46,114, 42, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, - 46,114, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105,110, 99,111,108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, -102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,114, 41, - 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111, -108, 46,103, 32, 60, 32, 48, 46, 53, 41, 13, 10, 9, 9,105,110, 99,111,108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, - 42, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 41, 59, 13, 10, 9,101, -108,115,101, 13, 10, 9, 9,105,110, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, - 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,103, 41, 41, 42, 40, 49, 46, 48, 32, 45, - 32,111,117,116, 99,111,108, 46,103, 41, 59, 13, 10, 13, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, 98, 32, 60, 32, 48, 46, - 53, 41, 13, 10, 9, 9,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 42, 40,102, 97, 99,109, 32, 43, - 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46, 98, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105, -110, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, - 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46, - 98, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115,117, 98, 40,118,101, 99, 51, + 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, + 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, + 10, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99, +111,108, 49, 44, 32,104,115,118, 41, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, + 50, 41, 59, 10, 10, 9,104,115,118, 46,122, 32, 61, 32,102, 97, 99,109, 42,104,115,118, 46,122, 32, 43, 32,102, 97, 99, 42,104, +115,118, 50, 46,122, 59, 10, 9,104,115,118, 95,116,111, 95,114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95, 99,111,108,111,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, + 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, + 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, + 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, 59, 10, 10, 9,111, +117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,118,101, 99, 52, 32,104,115,118, 44, 32,104,115,118, 50, 44, 32, +116,109,112, 59, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 50, 44, 32,104,115,118, 50, 41, 59, 10, 10, 9, +105,102, 40,104,115,118, 50, 46,121, 32, 33, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,114,103, 98, 95,116,111, 95,104,115,118, + 40,111,117,116, 99,111,108, 44, 32,104,115,118, 41, 59, 10, 9, 9,104,115,118, 46,120, 32, 61, 32,104,115,118, 50, 46,120, 59, + 10, 9, 9,104,115,118, 46,121, 32, 61, 32,104,115,118, 50, 46,121, 59, 10, 9, 9,104,115,118, 95,116,111, 95,114,103, 98, 40, +104,115,118, 44, 32,116,109,112, 41, 59, 32, 10, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, 40,111,117,116, 99, +111,108, 44, 32,116,109,112, 44, 32,102, 97, 99, 41, 59, 10, 9, 9,111,117,116, 99,111,108, 46, 97, 32, 61, 32, 99,111,108, 49, + 46, 97, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,115,111,102,116, 40,102,108,111, 97,116, 32,102, 97, + 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, + 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, + 48, 44, 32, 49, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99, + 59, 10, 10, 9,118,101, 99, 52, 32,111,110,101, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,118,101, 99, 52, 32,115, + 99,114, 61, 32,111,110,101, 32, 45, 32, 40,111,110,101, 32, 45, 32, 99,111,108, 50, 41, 42, 40,111,110,101, 32, 45, 32, 99,111, +108, 49, 41, 59, 10, 9,111,117,116, 99,111,108, 32, 61, 32,102, 97, 99,109, 42, 99,111,108, 49, 32, 43, 32,102, 97, 99, 42, 40, + 40,111,110,101, 32, 45, 32, 99,111,108, 49, 41, 42, 99,111,108, 50, 42, 99,111,108, 49, 32, 43, 32, 99,111,108, 49, 42,115, 99, +114, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,105,120, 95,108,105,110,101, 97,114, 40,102,108,111, 97,116, 32,102, 97, 99, + 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, + 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, + 44, 32, 49, 46, 48, 41, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 59, 10, 10, 9,105,102, 40, 99,111, +108, 50, 46,114, 32, 62, 32, 48, 46, 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46,114, 61, 32, 99,111,108, 49, 46,114, 32, 43, + 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,114, 32, 45, 32, 48, 46, 53, 41, 41, 59, 10, 9,101,108,115,101, + 10, 9, 9,111,117,116, 99,111,108, 46,114, 61, 32, 99,111,108, 49, 46,114, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, + 99,111,108, 50, 46,114, 41, 32, 45, 32, 49, 46, 48, 41, 59, 10, 10, 9,105,102, 40, 99,111,108, 50, 46,103, 32, 62, 32, 48, 46, + 53, 41, 10, 9, 9,111,117,116, 99,111,108, 46,103, 61, 32, 99,111,108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, + 42, 40, 99,111,108, 50, 46,103, 32, 45, 32, 48, 46, 53, 41, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, + 46,103, 61, 32, 99,111,108, 49, 46,103, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46,103, 41, 32, 45, + 32, 49, 46, 48, 41, 59, 10, 10, 9,105,102, 40, 99,111,108, 50, 46, 98, 32, 62, 32, 48, 46, 53, 41, 10, 9, 9,111,117,116, 99, +111,108, 46, 98, 61, 32, 99,111,108, 49, 46, 98, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 32, + 45, 32, 48, 46, 53, 41, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 46, 98, 61, 32, 99,111,108, 49, 46, + 98, 32, 43, 32,102, 97, 99, 42, 40, 50, 46, 48, 42, 40, 99,111,108, 50, 46, 98, 41, 32, 45, 32, 49, 46, 48, 41, 59, 10,125, 10, + 10,118,111,105,100, 32,118, 97,108,116,111,114,103, 98, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,115, 97,109,112,108,101, +114, 50, 68, 32, 99,111,108,111,114,109, 97,112, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,111,117,116, 97,108,112,104, 97, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,116, +101,120,116,117,114,101, 50, 68, 40, 99,111,108,111,114,109, 97,112, 44, 32,118,101, 99, 50, 40,102, 97, 99, 44, 32, 48, 46, 48, + 41, 41, 59, 10, 9,111,117,116, 97,108,112,104, 97, 32, 61, 32,111,117,116, 99,111,108, 46, 97, 59, 10,125, 10, 10,118,111,105, +100, 32,114,103, 98,116,111, 98,119, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, +111,117,116,118, 97,108, 41, 32, 32, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 99,111,108,111,114, 46,114, 42, 48, 46, + 51, 53, 32, 43, 32, 99,111,108,111,114, 46,103, 42, 48, 46, 52, 53, 32, 43, 32, 99,111,108,111,114, 46, 98, 42, 48, 46, 50, 59, + 32, 47, 42, 32,107,101,101,112, 32,116,104,101,115,101, 32,102, 97, 99,116,111,114,115, 32,105,110, 32,115,121,110, 99, 32,119, +105,116,104, 32,116,101,120,116,117,114,101, 46,104, 58, 82, 71, 66, 84, 79, 66, 87, 32, 42, 47, 10,125, 10, 10,118,111,105,100, + 32,105,110,118,101,114,116, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, + 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 46,120,121,122, 32, 61, 32,109,105, +120, 40, 99,111,108, 46,120,121,122, 44, 32,118,101, 99, 51, 40, 49, 46, 48, 44, 32, 49, 46, 48, 44, 32, 49, 46, 48, 41, 32, 45, + 32, 99,111,108, 46,120,121,122, 44, 32,102, 97, 99, 41, 59, 10, 9,111,117,116, 99,111,108, 46,119, 32, 61, 32, 99,111,108, 46, +119, 59, 10,125, 10, 10,118,111,105,100, 32,104,117,101, 95,115, 97,116, 40,102,108,111, 97,116, 32,104,117,101, 44, 32,102,108, +111, 97,116, 32,115, 97,116, 44, 32,102,108,111, 97,116, 32,118, 97,108,117,101, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 44, + 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,118, +101, 99, 52, 32,104,115,118, 59, 10, 10, 9,114,103, 98, 95,116,111, 95,104,115,118, 40, 99,111,108, 44, 32,104,115,118, 41, 59, + 10, 10, 9,104,115,118, 91, 48, 93, 32, 43, 61, 32, 40,104,117,101, 32, 45, 32, 48, 46, 53, 41, 59, 10, 9,105,102, 40,104,115, +118, 91, 48, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 48, 93, 45, 61, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104, +115,118, 91, 48, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 48, 93, 43, 61, 32, 49, 46, 48, 59, 10, 9,104,115,118, 91, 49, 93, + 32, 42, 61, 32,115, 97,116, 59, 10, 9,105,102, 40,104,115,118, 91, 49, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 49, 93, 61, + 32, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115,118, 91, 49, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 49, 93, + 61, 32, 48, 46, 48, 59, 10, 9,104,115,118, 91, 50, 93, 32, 42, 61, 32,118, 97,108,117,101, 59, 10, 9,105,102, 40,104,115,118, + 91, 50, 93, 62, 49, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 49, 46, 48, 59, 32,101,108,115,101, 32,105,102, 40,104,115, +118, 91, 50, 93, 60, 48, 46, 48, 41, 32,104,115,118, 91, 50, 93, 61, 32, 48, 46, 48, 59, 10, 10, 9,104,115,118, 95,116,111, 95, +114,103, 98, 40,104,115,118, 44, 32,111,117,116, 99,111,108, 41, 59, 10, 10, 9,111,117,116, 99,111,108, 32, 61, 32,109,105,120, + 40, 99,111,108, 44, 32,111,117,116, 99,111,108, 44, 32,102, 97, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,101,112, 97, +114, 97,116,101, 95,114,103, 98, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 98, 41, 10,123, 10, 9,114, 32, 61, + 32, 99,111,108, 46,114, 59, 10, 9,103, 32, 61, 32, 99,111,108, 46,103, 59, 10, 9, 98, 32, 61, 32, 99,111,108, 46, 98, 59, 10, +125, 10, 10,118,111,105,100, 32, 99,111,109, 98,105,110,101, 95,114,103, 98, 40,102,108,111, 97,116, 32,114, 44, 32,102,108,111, + 97,116, 32,103, 44, 32,102,108,111, 97,116, 32, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108, 41, 10,123, 10, 9, + 99,111,108, 32, 61, 32,118,101, 99, 52, 40,114, 44, 32,103, 44, 32, 98, 44, 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105, +100, 32,111,117,116,112,117,116, 95,110,111,100,101, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,102,108,111, 97,116, 32, 97,108, +112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 10,123, 10, 9,111,117,116,114,103, 98, 32, + 61, 32,118,101, 99, 52, 40,114,103, 98, 46,114,103, 98, 44, 32, 97,108,112,104, 97, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 32, 84, 69, 88, 84, 85, 82, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 47, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95,102,108,105,112, 95, 98,108,101,110,100, 40,118,101, 99, 51, 32, +118,101, 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10, 9,111,117,116,118,101, 99, 32, + 61, 32,118,101, 99, 46,121,120,122, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, + 95,108,105,110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, + 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 59, 10,125, 10, + 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, 98,108,101,110,100, 95,113,117, 97,100, 40,118,101, 99, 51, 32,118,101, + 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, 97,108, 32, 61, + 32,109, 97,120, 40, 40, 49, 46, 48, 43,118,101, 99, 46,120, 41, 47, 50, 46, 48, 44, 32, 48, 46, 48, 41, 59, 10, 9,111,117,116, +118, 97,108, 32, 42, 61, 32,111,117,116,118, 97,108, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95,119, +111,111,100, 95,115,105,110, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118, 97,108,117, +101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, + 97,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32, 97, 32, 61, 32,115,113,114,116, 40,118,101, 99, 46,120, 42,118,101, 99, 46, +120, 32, 43, 32,118,101, 99, 46,121, 42,118,101, 99, 46,121, 32, 43, 32,118,101, 99, 46,122, 42,118,101, 99, 46,122, 41, 42, 50, + 48, 46, 48, 59, 10, 9,102,108,111, 97,116, 32,119,105, 32, 61, 32, 48, 46, 53, 32, 43, 32, 48, 46, 53, 42,115,105,110, 40, 97, + 41, 59, 10, 10, 9,118, 97,108,117,101, 32, 61, 32,119,105, 59, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40,119, +105, 44, 32,119,105, 44, 32,119,105, 44, 32, 49, 46, 48, 41, 59, 10, 9,110,111,114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, + 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120,116,117,114,101, 95, +105,109, 97,103,101, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,118, 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32, +111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116, +117,114,101, 50, 68, 40,105,109, 97, 44, 32, 40,118,101, 99, 46,120,121, 32, 43, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, + 46, 48, 41, 41, 42, 48, 46, 53, 41, 59, 10, 9,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 59, 10, 10, 9,110,111,114,109, 97, +108, 46,120, 32, 61, 32, 50, 46, 48, 42, 40, 99,111,108,111,114, 46,114, 32, 45, 32, 48, 46, 53, 41, 59, 10, 9,110,111,114,109, + 97,108, 46,121, 32, 61, 32, 50, 46, 48, 42, 40, 48, 46, 53, 32, 45, 32, 99,111,108,111,114, 46,103, 41, 59, 10, 9,110,111,114, +109, 97,108, 46,122, 32, 61, 32, 50, 46, 48, 42, 40, 99,111,108,111,114, 46, 98, 32, 45, 32, 48, 46, 53, 41, 59, 10,125, 10, 10, + 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 77, 84, 69, 88, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 47, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111,114, 99,111, 40,118,101, 99, 51, 32, 97,116,116, +111,114, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,114, 99,111, 41, 10,123, 10, 9,111,114, 99,111, 32, 61, 32, 97, +116,116,111,114, 99,111, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,117,118, 40,118,101, 99, 50, 32, 97,116, +116,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 41, 10,123, 10, 9, 47, 42, 32,100,105,115, 97, 98,108,101,100, + 32,102,111,114, 32,110,111,119, 44, 32,119,111,114,107,115, 32,116,111,103,101,116,104,101,114, 32,119,105,116,104, 32,108,101, + 97,118,105,110,103, 32,111,117,116, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 10, 9, 32, 32, 32,117,118, + 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 42, 50, 46, 48, 32, 45, 32,118,101, 99, 50, 40, 49, 46, 48, 44, 32, 49, 46, + 48, 41, 44, 32, 48, 46, 48, 41, 59, 32, 42, 47, 10, 9,117,118, 32, 61, 32,118,101, 99, 51, 40, 97,116,116,117,118, 44, 32, 48, + 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,110,111,114,109, 40,118,101, 99, 51, 32,110,111,114, +109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9, 47, 42, 32, 99, +111,114,114,101,115,112,111,110,100,115, 32,116,111, 32,115,104,105, 45, 62,111,114,110, 44, 32,119,104,105, 99,104, 32,105,115, + 32,110,101,103, 97,116,101,100, 32,115,111, 32, 99, 97,110, 99,101,108,115, 10, 9, 32, 32, 32,111,117,116, 32, 98,108,101,110, +100,101,114, 32,110,111,114,109, 97,108, 32,110,101,103, 97,116,105,111,110, 32, 42, 47, 10, 9,111,117,116,110,111,114,109, 97, +108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,110,111,114,109, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,116, +101,120, 99,111, 95,116, 97,110,103,101,110,116, 40,118,101, 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,111,117,116, 32,118, +101, 99, 51, 32,111,117,116,116, 97,110,103,101,110,116, 41, 10,123, 10, 9,111,117,116,116, 97,110,103,101,110,116, 32, 61, 32, +110,111,114,109, 97,108,105,122,101, 40,116, 97,110,103,101,110,116, 46,120,121,122, 41, 59, 10,125, 10, 10,118,111,105,100, 32, +116,101,120, 99,111, 95,103,108,111, 98, 97,108, 40,109, 97,116, 52, 32,118,105,101,119,105,110,118,109, 97,116, 44, 32,118,101, + 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,103,108,111, 98, 97,108, 41, 10,123, 10, 9,103,108,111, 98, 97, +108, 32, 61, 32, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, 48, 41, 41, 46,120, +121,122, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,111, 98,106,101, 99,116, 40,109, 97,116, 52, 32,118,105, +101,119,105,110,118,109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 32,118,101, 99, 51, 32, 99,111, + 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 41, 10,123, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, 40, +111, 98,105,110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 99,111, 44, 32, 49, 46, + 48, 41, 41, 41, 46,120,121,122, 59, 10,125, 10, 10,118,111,105,100, 32,116,101,120, 99,111, 95,114,101,102,108, 40,118,101, 99, + 51, 32,118,110, 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,114,101,102, 41, 10,123, + 10, 9,114,101,102, 32, 61, 32,118,105,101,119, 32, 45, 32, 50, 46, 48, 42,100,111,116, 40,118,110, 44, 32,118,105,101,119, 41, + 42,118,110, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,110,111,114,109, 40,118,101, 99, 51, 32,110,111,114, +109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9, 47, 42, 32, 98, +108,101,110,100,101,114, 32,114,101,110,100,101,114, 32,110,111,114,109, 97,108, 32,105,115, 32,110,101,103, 97,116,101,100, 32, + 42, 47, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, 45,110,111,114,109, 97,108,105,122,101, 40,110,111,114,109, 97, +108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 98,108,101,110,100, 40,118,101, 99, 51, 32, +111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9, +102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99, +109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, + 99,111,108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, +114,103, 98, 95,109,117,108, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, + 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, + 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 10, 10, 9,105,110, 99, +111,108, 32, 61, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 41, 42,111,117,116, 99,111,108, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 99,114,101,101,110, 40,118,101, 99, 51, 32,111, +117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32, +102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102, +108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, + 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 10, 10, 9,105,110, 99,111,108, 32, 61, 32,118,101, 99, 51, 40, 49, 46, 48, 41, + 32, 45, 32, 40,118,101, 99, 51, 40,102, 97, 99,109, 41, 32, 43, 32,102, 97, 99,116, 42, 40,118,101, 99, 51, 40, 49, 46, 48, 41, + 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,111,117,116, 99,111,108, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,111,118,101,114,108, 97,121, 40,118,101, 99, 51, 32, +111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9, +102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99, +109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,103, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,114, 32, 60, 32, 48, 46, + 53, 41, 10, 9, 9,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46,114, 42, 40,102, 97, 99,109, 32, 43, 32, + 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,114, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,105,110, 99,111, +108, 46,114, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, + 48, 32, 45, 32,116,101,120, 99,111,108, 46,114, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,114, 41, 59, + 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46,103, 32, 60, 32, 48, 46, 53, 41, 10, 9, 9,105,110, 99,111,108, 46,103, 32, + 61, 32,111,117,116, 99,111,108, 46,103, 42, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99, +111,108, 46,103, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,105,110, 99,111,108, 46,103, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, +102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46,103, 41, + 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 46,103, 41, 59, 10, 10, 9,105,102, 40,111,117,116, 99,111,108, 46, + 98, 32, 60, 32, 48, 46, 53, 41, 10, 9, 9,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 42, 40,102, + 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, 99,116, 42,116,101,120, 99,111,108, 46, 98, 41, 59, 10, 9,101,108,115,101, 10, + 9, 9,105,110, 99,111,108, 46, 98, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32, 50, 46, 48, 42,102, 97, + 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 46, 98, 41, 41, 42, 40, 49, 46, 48, 32, 45, 32,111,117,116, 99, +111,108, 46, 98, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115,117, 98, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, - 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, - 13, 10, 9,105,110, 99,111,108, 32, 61, 32, 45,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, 32,111, -117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 97,100,100, 40,118, -101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, - 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, - 13, 10,123, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, - 32,111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100,105,118, - 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, - 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111, -108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32, -102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 13, 10, 13, 10, 9,105,102, 40, -116,101,120, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46,114, 32, 61, 32,102, 97, 99,109, 42, -111,117,116, 99,111,108, 46,114, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46,114, 47,116,101,120, 99,111,108, 46, -114, 59, 13, 10, 9,105,102, 40,116,101,120, 99,111,108, 46,103, 32, 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46,103, - 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,103, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46,103, - 47,116,101,120, 99,111,108, 46,103, 59, 13, 10, 9,105,102, 40,116,101,120, 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, - 32,105,110, 99,111,108, 46, 98, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46, 98, 32, 43, 32,102, 97, 99,116, 42, -111,117,116, 99,111,108, 46, 98, 47,116,101,120, 99,111,108, 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116, -101,120, 95,114,103, 98, 95,100,105,102,102, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101, -120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117, -116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, - 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, - 99,116, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, 32,102, 97, - 99,116, 42, 97, 98,115, 40,116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, + 9,105,110, 99,111,108, 32, 61, 32, 45,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, + 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 97,100,100, 40,118,101, 99, 51, 32,111, +117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32, +102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,105, +110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,102, 97, 99,103, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, 99,111,108, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100,105,118, 40,118,101, 99, 51, 32,111,117,116, 99, +111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, + 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97, +116, 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, 32, + 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9,105,102, 40,116,101,120, 99,111,108, 46,114, 32, 33, 61, 32, 48, 46, 48, 41, 32, +105,110, 99,111,108, 46,114, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,114, 32, 43, 32,102, 97, 99,116, 42,111, +117,116, 99,111,108, 46,114, 47,116,101,120, 99,111,108, 46,114, 59, 10, 9,105,102, 40,116,101,120, 99,111,108, 46,103, 32, 33, + 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 46,103, 32, 43, + 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46,103, 47,116,101,120, 99,111,108, 46,103, 59, 10, 9,105,102, 40,116,101,120, + 99,111,108, 46, 98, 32, 33, 61, 32, 48, 46, 48, 41, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,102, 97, 99,109, 42,111,117,116, + 99,111,108, 46, 98, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 46, 98, 47,116,101,120, 99,111,108, 46, 98, 59, 10, +125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100,105,102,102, 40,118,101, 99, 51, 32,111,117,116, 99,111, +108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97, +116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, + 32,102, 97, 99,109, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, 32, 49, + 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, + 32,102, 97, 99,116, 42, 97, 98,115, 40,116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 10,125, 10, 10,118, 111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,100, 97,114,107, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118, 101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, - 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, - 97, 99,109, 44, 32, 99,111,108, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, - 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 13, 10, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101, -120, 99,111,108, 46,114, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99, -111,108, 46,114, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111, -108, 46,114, 59, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 13, 10, 9,105,102, - 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32, -101,108,115,101, 32,105,110, 99,111,108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 13, 10, 9, 99,111,108, 32, 61, - 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46, 98, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111, -108, 46, 98, 41, 32,105,110, 99,111,108, 46, 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, - 32, 61, 32,111,117,116, 99,111,108, 46, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, - 95,108,105,103,104,116, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, - 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, - 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 44, 32, 99,111,108, 59, 13, 10, - 13, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, - 99,116, 59, 13, 10, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,114, 59, 13, 10, 9,105, -102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99,111,108, 46,114, 32, 61, 32, 99,111,108, 59, - 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46,114, 59, 13, 10, 9, 99,111,108, 32, - 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99, -111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, -103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 13, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111, -108, 46, 98, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46, 98, 41, 32,105,110, 99,111,108, 46, - 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,104,117,101, 40,118,101, 99, 51, 32,111, -117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32, -102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, - 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95,104,117,101, 40,102, 97, 99,116, 42,102, 97, 99,103, - 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, - 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46, -114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 97,116, 40,118,101, 99, - 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 13, 10, -123, 13, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95,115, 97,116, 40,102, 97, 99,116, 42,102, - 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, - 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99, -111,108, 46,114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,118, 97,108, 40, -118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32, -102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, - 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95,118, 97,108, 40,102, 97, 99, -116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40, -116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, - 61, 32, 99,111,108, 46,114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95, 99, -111,108,111,114, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32, -105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 13, 10, 13, 10, 9,109,105,120, 95, 99,111, -108,111,114, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, - 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 13, 10, 9,105,110, 99, -111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101, -120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,105,110,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,109, 41, 13, 10,123, 13, 10, 9, -102, 97, 99,116, 32, 42, 61, 32, 97, 98,115, 40,102, 97, 99,103, 41, 59, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45, -102, 97, 99,116, 59, 13, 10, 13, 10, 9,105,102, 40,102, 97, 99,103, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,102,108, -111, 97,116, 32,116,109,112, 32, 61, 32,102, 97, 99,116, 59, 13, 10, 9, 9,102, 97, 99,116, 32, 61, 32,102, 97, 99,109, 59, 13, - 10, 9, 9,102, 97, 99,109, 32, 61, 32,116,109,112, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116, -101,120, 95,118, 97,108,117,101, 95, 98,108,101,110,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, - 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, - 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99, -103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111, -108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, - 95,118, 97,108,117,101, 95,109,117,108, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116, -101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111, -117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, - 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, - 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99,103, 59, 13, 10, 9,105, -110, 99,111,108, 32, 61, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 41, 42,111,117,116, 99, -111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,115, 99,114,101,101,110, + 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99, +109, 44, 32, 99,111,108, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, 97, 99,109, 32, 61, 32, + 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,114, 59, + 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99,111,108, 46,114, 32, 61, 32, 99, +111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46,114, 59, 10, 9, 99,111, +108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, + 99,111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, + 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111, +108, 46, 98, 59, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 46, 98, 41, 32,105,110, 99,111,108, 46, 98, + 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, 99,111,108, 46, 98, 59, + 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,108,105,103,104,116, 40,118,101, 99, 51, 32,111,117,116, + 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108, +111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, + 97,116, 32,102, 97, 99,109, 44, 32, 99,111,108, 59, 10, 10, 9,102, 97, 99,116, 32, 42, 61, 32,102, 97, 99,103, 59, 10, 9,102, + 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, 97, 99,116, 59, 10, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, + 99,111,108, 46,114, 59, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46,114, 41, 32,105,110, 99,111,108, + 46,114, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46,114, 32, 61, 32,111,117,116, 99,111,108, 46, +114, 59, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 46,103, 59, 10, 9,105,102, 40, 99,111,108, + 32, 62, 32,111,117,116, 99,111,108, 46,103, 41, 32,105,110, 99,111,108, 46,103, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, + 32,105,110, 99,111,108, 46,103, 32, 61, 32,111,117,116, 99,111,108, 46,103, 59, 10, 9, 99,111,108, 32, 61, 32,102, 97, 99,116, + 42,116,101,120, 99,111,108, 46, 98, 59, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 46, 98, 41, 32,105, +110, 99,111,108, 46, 98, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 46, 98, 32, 61, 32,111,117,116, + 99,111,108, 46, 98, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,104,117,101, 40,118,101, 99, 51, + 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, + 9,118,101, 99, 52, 32, 99,111,108, 59, 10, 10, 9,109,105,120, 95,104,117,101, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32, +118,101, 99, 52, 40,111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, + 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, 97,116, 40,118,101, 99, 51, 32,111,117,116, 99, +111,108, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, + 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,118,101, 99, 52, + 32, 99,111,108, 59, 10, 10, 9,109,105,120, 95,115, 97,116, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40, +111,117,116, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, + 32, 99,111,108, 41, 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 10,125, 10, 10, +118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,118, 97,108, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118, +101, 99, 51, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, + 99,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, + 10, 10, 9,109,105,120, 95,118, 97,108, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111, +108, 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, + 59, 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 10,125, 10, 10,118,111,105,100, 32, +109,116,101,120, 95,114,103, 98, 95, 99,111,108,111,114, 40,118,101, 99, 51, 32,111,117,116, 99,111,108, 44, 32,118,101, 99, 51, + 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,108, 41, 10,123, 10, 9,118,101, 99, 52, 32, 99,111,108, 59, 10, 10, 9, +109,105,120, 95, 99,111,108,111,114, 40,102, 97, 99,116, 42,102, 97, 99,103, 44, 32,118,101, 99, 52, 40,111,117,116, 99,111,108, + 44, 32, 49, 46, 48, 41, 44, 32,118,101, 99, 52, 40,116,101,120, 99,111,108, 44, 32, 49, 46, 48, 41, 44, 32, 99,111,108, 41, 59, + 10, 9,105,110, 99,111,108, 46,114,103, 98, 32, 61, 32, 99,111,108, 46,114,103, 98, 59, 10,125, 10, 10,118,111,105,100, 32,109, +116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,105,110,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99,109, 41, 10,123, 10, 9, +102, 97, 99,116, 32, 42, 61, 32, 97, 98,115, 40,102, 97, 99,103, 41, 59, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 45,102, + 97, 99,116, 59, 10, 10, 9,105,102, 40,102, 97, 99,103, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,102,108,111, 97,116, 32, +116,109,112, 32, 61, 32,102, 97, 99,116, 59, 10, 9, 9,102, 97, 99,116, 32, 61, 32,102, 97, 99,109, 59, 10, 9, 9,102, 97, 99, +109, 32, 61, 32,116,109,112, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 98, +108,101,110,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, + 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,105, +110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,109,117,108, 40,102,108,111, 97,116, 32,111, +117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, + 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, + 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, + 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32, +102, 97, 99,103, 59, 10, 9,105,110, 99,111,108, 32, 61, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42,116,101,120, 99, +111,108, 41, 42,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,115, + 99,114,101,101,110, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95, +118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9, +102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99,103, 59, 10, 9,105,110, 99,111,108, 32, 61, 32, 49, 46, 48, 32, + 45, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, 40, + 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117, +101, 95,115,117, 98, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95, +118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9, +102, 97, 99,116, 32, 61, 32, 45,102, 97, 99,116, 59, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99, +111,108, 32, 43, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, + 97,100,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32, +102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, 97, +108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,102, 97, + 99,116, 32, 61, 32,102, 97, 99,116, 59, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, + 43, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,100,105,118, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105, -110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97, -108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9, -102, 97, 99,109, 32, 61, 32, 49, 46, 48, 32, 45, 32,102, 97, 99,103, 59, 13, 10, 9,105,110, 99,111,108, 32, 61, 32, 49, 46, 48, - 32, 45, 32, 40,102, 97, 99,109, 32, 43, 32,102, 97, 99,116, 42, 40, 49, 46, 48, 32, 45, 32,116,101,120, 99,111,108, 41, 41, 42, - 40, 49, 46, 48, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, -118, 97,108,117,101, 95,115,117, 98, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101, -120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, - 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, - 99,109, 41, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 61, 32, 45,102, 97, 99,116, 59, 13, 10, 9,105,110, 99,111,108, 32, 61, - 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 97,100,100, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102, -108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, - 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, - 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, - 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102, 97, 99,116, 32, 61, 32,102, 97, 99,116, 59, 13, 10, 9,105, -110, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 32, 43, 32,111,117,116, 99,111,108, 59, 13, 10,125, 13, - 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,100,105,118, 40,102,108,111, 97,116, 32,111,117,116, - 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102, -108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, - 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, - 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,105,102, 40,116,101,120, 99,111,108, 32, - 33, 61, 32, 48, 46, 48, 41, 13, 10, 9, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, - 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 47,116,101,120, 99,111,108, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105, -110, 99,111,108, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117, -101, 95,100,105,102,102, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111, -108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109, -116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, - 59, 13, 10, 13, 10, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, 32,102, 97, 99,116, - 42, 97, 98,115, 40,116,101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,100, 97,114,107, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32, -102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32, -102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, 10,123, 13, 10, 9,102,108,111, 97, -116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32, -102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102,108,111, 97,116, 32, 99,111,108, 32, 61, 32,102, 97, 99, -116, 42,116,101,120, 99,111,108, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 41, 32,105,110, 99, -111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 32, 61, 32,111,117,116, 99,111,108, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,108,105,103,104,116, 40,102,108,111, 97,116, - 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99, -116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 13, 10, 9,109,116,101,120, 95,118, 97,108,117,101, 95,118, 97, -114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 13, 10, 13, 10, 9,102,108,111, 97,116, 32, - 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 59, 13, 10, 9,105,102, 40, 99,111,108, 32, 62, 32,111,117, -116, 99,111,108, 41, 32,105,110, 99,111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32,105,110, 99,111,108, 32, 61, 32, -111,117,116, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 99,108, - 97,109,112, 95,112,111,115,105,116,105,118,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,111,117,116,102, 97, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,102, 97, 99, 32, 61, 32,109, 97,120, 40,102, 97, 99, 44, - 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 99,108, 97, -109,112, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 13, - 10,123, 13, 10, 9,111,117,116,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, - 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,104, 97,114, 95,100,105,118,105,100,101, 40,102, -108,111, 97,116, 32,104, 97,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,104, 97,114, 41, 13, 10,123, 13, 10, - 9,111,117,116,104, 97,114, 32, 61, 32,104, 97,114, 47, 49, 50, 56, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, -109,116,101,120, 95,104, 97,114, 95,109,117,108,116,105,112,108,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32,104, 97, -114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,104, 97,114, 41, 13, 10,123, 13, 10, 9,104, 97,114, 32, 42, 61, - 32, 49, 50, 56, 46, 48, 59, 13, 10, 13, 10, 9,105,102, 40,104, 97,114, 32, 60, 32, 49, 46, 48, 41, 32,111,117,116,104, 97,114, - 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,104, 97,114, 32, 62, 32, 53, 49, 49, 46, 48, 41, 32,111, -117,116,104, 97,114, 32, 61, 32, 53, 49, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,111,117,116,104, 97,114, 32, 61, 32,104, - 97,114, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 97,108,112,104, 97, 95,102,114,111,109, 95, 99, -111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 41, 13, 10,123, - 13, 10, 9, 97,108,112,104, 97, 32, 61, 32, 99,111,108, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101, -120, 95, 97,108,112,104, 97, 95,116,111, 95, 99,111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32, 97, -108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99, -111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 97,108,112,104, 97, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98,116,111,105,110,116, 40,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,105,110,116,101,110,115,105,116,121, 41, 13, 10,123, 13, 10, 9,105,110,116,101,110,115,105,116, -121, 32, 61, 32,100,111,116, 40,118,101, 99, 51, 40, 48, 46, 51, 53, 44, 32, 48, 46, 52, 53, 44, 32, 48, 46, 50, 41, 44, 32,114, -103, 98, 46,114,103, 98, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,105, -110,118,101,114,116, 40,102,108,111, 97,116, 32,105,110,118, 97,108,117,101, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111, -117,116,118, 97,108,117,101, 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 32, 45, 32,105, -110,118, 97,108,117,101, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,105,110,118,101, -114,116, 40,118,101, 99, 52, 32,105,110,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 13, - 10,123, 13, 10, 9,111,117,116,114,103, 98, 32, 61, 32,118,101, 99, 52, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,105, -110,114,103, 98, 46,114,103, 98, 44, 32,105,110,114,103, 98, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, -116,101,120, 95,118, 97,108,117,101, 95,115,116,101,110, 99,105,108, 40,102,108,111, 97,116, 32,115,116,101,110, 99,105,108, 44, - 32,102,108,111, 97,116, 32,105,110,116,101,110,115,105,116,121, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115, -116,101,110, 99,105,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105,110,116,101,110,115,105,116,121, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99,116, 32, 61, 32,105,110,116,101,110,115,105,116,121, 59, 13, 10, 9,111, -117,116,105,110,116,101,110,115,105,116,121, 32, 61, 32,105,110,116,101,110,115,105,116,121, 42,115,116,101,110, 99,105,108, 59, - 13, 10, 9,111,117,116,115,116,101,110, 99,105,108, 32, 61, 32,115,116,101,110, 99,105,108, 42,102, 97, 99,116, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115,116,101,110, 99,105,108, 40,102,108,111, 97,116, 32, -115,116,101,110, 99,105,108, 44, 32,118,101, 99, 52, 32,114,103, 98, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, -115,116,101,110, 99,105,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 13, 10,123, 13, 10, 9,102, -108,111, 97,116, 32,102, 97, 99,116, 32, 61, 32,114,103, 98, 46, 97, 59, 13, 10, 9,111,117,116,114,103, 98, 32, 61, 32,118,101, - 99, 52, 40,114,103, 98, 46,114,103, 98, 44, 32,114,103, 98, 46, 97, 42,115,116,101,110, 99,105,108, 41, 59, 13, 10, 9,111,117, -116,115,116,101,110, 99,105,108, 32, 61, 32,115,116,101,110, 99,105,108, 42,102, 97, 99,116, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,111,102,115, 40,118,101, 99, 51, 32,116,101,120, 99,111, 44, - 32,118,101, 99, 51, 32,111,102,115, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, 99,111, 41, 13, 10,123, - 13, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,116,101,120, 99,111, 32, 43, 32,111,102,115, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,115,105,122,101, 40,118,101, 99, 51, 32,116,101,120, - 99,111, 44, 32,118,101, 99, 51, 32,115,105,122,101, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, 99,111, - 41, 13, 10,123, 13, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,115,105,122,101, 42,116,101,120, 99,111, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, - 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,118,101, 99, 32, - 61, 32,118,101, 99, 51, 40,118,101, 99, 46,120,121, 42, 48, 46, 53, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 32, 48, 46, - 53, 41, 44, 32,118,101, 99, 46,122, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,105,109, 97,103, -101, 40,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, - 32,102,108,111, 97,116, 32,118, 97,108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 13, 10,123, - 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46, -120,121, 41, 59, 13, 10, 9,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, -116,101,120, 95,110,111,114,109, 97,108, 40,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, - 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9, 47, 47, 32, 84, -104,101, 32,105,110,118,101,114,116, 32,111,102, 32,116,104,101, 32,114,101,100, 32, 99,104, 97,110,110,101,108, 32,105,115, 32, -116,111, 32,109, 97,107,101, 13, 10, 9, 47, 47, 32,116,104,101, 32,110,111,114,109, 97,108, 32,109, 97,112, 32, 99,111,109,112, -108,105, 97,110,116, 32,119,105,116,104, 32,116,104,101, 32,111,117,116,115,105,100,101, 32,119,111,114,108,100, 46, 13, 10, 9, - 47, 47, 32, 73,116, 32,110,101,101,100,115, 32,116,111, 32, 98,101, 32,100,111,110,101, 32, 98,101, 99, 97,117,115,101, 32,105, -110, 32, 66,108,101,110,100,101,114, 13, 10, 9, 47, 47, 32,116,104,101, 32,110,111,114,109, 97,108, 32,117,115,101,100, 32,112, -111,105,110,116,115, 32,105,110,119, 97,114,100, 46, 13, 10, 9, 47, 47, 32, 83,104,111,117,108,100, 32,116,104,105,115, 32,101, -118,101,114, 32, 99,104, 97,110,103,101, 32,116,104,105,115, 32,110,101,103, 97,116,101, 32,109,117,115,116, 32, 98,101, 32,114, -101,109,111,118,101,100, 46, 13, 10, 32, 32, 32, 32,118,101, 99, 52, 32, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114, -101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 59, 13, 10, 9,110,111,114,109, 97,108, 32, 61, 32, 50, - 46, 48, 42, 40,118,101, 99, 51, 40, 45, 99,111,108,111,114, 46,114, 44, 32, 99,111,108,111,114, 46,103, 44, 32, 99,111,108,111, -114, 46, 98, 41, 32, 45, 32,118,101, 99, 51, 40, 45, 48, 46, 53, 44, 32, 48, 46, 53, 44, 32, 48, 46, 53, 41, 41, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,110,111,114,109, 97,108,115, 95,105,110,105,116, 40, - 32,118,101, 99, 51, 32,118, 78, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78,111,114,103, 44, 32,111,117,116, 32,118,101, - 99, 51, 32,118, 78, 97, 99, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117, -100,101, 32, 41, 13, 10,123, 13, 10, 9,118, 78,111,114,103, 32, 61, 32,118, 78, 59, 13, 10, 9,118, 78, 97, 99, 99, 32, 61, 32, -118, 78, 59, 13, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, - 13, 10, 47, 42, 42, 32,104,101,108,112,101,114, 32,109,101,116,104,111,100, 32,116,111, 32,101,120,116,114, 97, 99,116, 32,116, -104,101, 32,117,112,112,101,114, 32,108,101,102,116, 32, 51,120, 51, 32,109, 97,116,114,105,120, 32,102,114,111,109, 32, 97, 32, - 52,120, 52, 32,109, 97,116,114,105,120, 32, 42, 47, 13, 10,109, 97,116, 51, 32,116,111, 95,109, 97,116, 51, 40,109, 97,116, 52, - 32,109, 52, 41, 13, 10,123, 13, 10, 9,109, 97,116, 51, 32,109, 51, 59, 13, 10, 9,109, 51, 91, 48, 93, 32, 61, 32,109, 52, 91, - 48, 93, 46,120,121,122, 59, 13, 10, 9,109, 51, 91, 49, 93, 32, 61, 32,109, 52, 91, 49, 93, 46,120,121,122, 59, 13, 10, 9,109, - 51, 91, 50, 93, 32, 61, 32,109, 52, 91, 50, 93, 46,120,121,122, 59, 13, 10, 9,114,101,116,117,114,110, 32,109, 51, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,111, 98,106,115,112, 97, 99, -101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, - 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,109, 97,116, 52, 32,109, 86,105,101,119, 44, 32,109, 97,116, 52, 32,109, 86,105, -101,119, 73,110,118, 44, 32,109, 97,116, 52, 32,109, 79, 98,106, 44, 32,109, 97,116, 52, 32,109, 79, 98,106, 73,110,118, 44, 32, - 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95, -105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, - 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, 32,118, -101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, - 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, -102, 68,101,116, 32, 41, 32, 13, 10,123, 13, 10, 9,109, 97,116, 51, 32,111, 98,106, 50,118,105,101,119, 32, 61, 32,116,111, 95, -109, 97,116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, 77, 97,116,114,105,120, 41, 59, 13, 10, 9,109, 97,116, 51, - 32,118,105,101,119, 50,111, 98,106, 32, 61, 32,116,111, 95,109, 97,116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, - 77, 97,116,114,105,120, 73,110,118,101,114,115,101, 41, 59, 13, 10, 9, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, - 83, 32, 61, 32,118,105,101,119, 50,111, 98,106, 32, 42, 32,100, 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, - 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, 61, 32,118,105,101,119, 50,111, 98,106, 32, 42, 32,100, 70,100, -121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, 32,110,111,114,109, 97, -108,105,122,101, 40, 32,115,117,114,102, 95,110,111,114,109, 32, 42, 32,111, 98,106, 50,118,105,101,119, 32, 41, 59, 13, 10, 13, - 10, 9,118, 82, 49, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 59, 13, 10, 9, -118, 82, 50, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 59, 13, 10, 9,102, - 68,101,116, 32, 61, 32,100,111,116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, 59, 13, 10, 9, 13, 10, - 9, 47, 42, 32,112,114,101,116,114, 97,110,115,102,111,114,109, 32,118, 78, 97, 99, 99, 32, 40,105,110, 32,109,116,101,120, 95, - 98,117,109,112, 95, 97,112,112,108,121, 41, 32,117,115,105,110,103, 32,116,104,101, 32,105,110,118,101,114,115,101, 32,116,114, - 97,110,115,112,111,115,101,100, 32, 42, 47, 13, 10, 9,118, 82, 49, 32, 61, 32,118, 82, 49, 32, 42, 32,118,105,101,119, 50,111, - 98,106, 59, 13, 10, 9,118, 82, 50, 32, 61, 32,118, 82, 50, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 13, 10, 9,118, 78, - 32, 61, 32,118, 78, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 13, 10, 9, 13, 10, 9,102,108,111, 97,116, 32,102, 77, 97, -103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 32, 42, 32,108,101,110,103,116,104, 40,118, 78, 41, - 59, 13, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103, -110,105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 13, 10, 9,102, - 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,116,101,120,116,117,114, -101,115,112, 97, 99,101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, - 95,110,111,114,109, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97, -103,110,105,116,117,100,101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, - 9, 9, 9, 9, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111, -117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, - 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32, -111,117,116, 32,102,108,111, 97,116, 32,102, 68,101,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103, -109, 97, 83, 32, 61, 32,100, 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, - 83,105,103,109, 97, 84, 32, 61, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, - 51, 32,118, 78, 32, 61, 32,115,117,114,102, 95,110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32, -105,110,116,101,114,112,111,108, 97,116,101,100, 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 13, 10, 9, - 13, 10, 9,118, 82, 49, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, - 97, 84, 44, 32,118, 78, 32, 41, 32, 41, 59, 13, 10, 9,118, 82, 50, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32, 99, -114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 41, 59, 13, 10, 9,102, 68,101,116, 32, 61, 32, -115,105,103,110, 40, 32,100,111,116, 40,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 41, 32, 41, 59, 13, 10, 9, 13, 10, 9, -102,108,111, 97,116, 32,102, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 13, 10, 9, -118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117, -100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 13, 10, 9,102, 80,114,101,118, - 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,118,105,101,119,115,112, 97, 99,101, 40, - 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, 44, 32, - 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, - 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111, -117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, - 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111,117,116, - 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, - 97,116, 32,102, 68,101,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, 61, 32,100, - 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, - 61, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, 32, -115,117,114,102, 95,110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32,105,110,116,101,114,112,111, -108, 97,116,101,100, 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 13, 10, 9, 13, 10, 9,118, 82, 49, 32, - 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 59, 13, 10, 9,118, 82, 50, 32, 61, 32, - 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 59, 13, 10, 9,102, 68,101,116, 32, 61, 32, -100,111,116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, 59, 13, 10, 9, 13, 10, 9,102,108,111, 97,116, - 32,102, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 13, 10, 9,118, 78, 97, 99, 99, - 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117,100,101, 32, 47, 32, -102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 13, 10, 9,102, 80,114,101,118, 77, 97,103,110,105, -116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,109,116,101,120, 95, 98,117,109,112, 95,116, 97,112, 51, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97, -109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 50, 32, 83, 84,108,108, - 32, 61, 32,116,101,120, 99,111, 46,120,121, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,108,114, 32, 61, 32,116,101,120, 99,111, - 46,120,121, 32, 43, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84, -117,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 32, 59, - 13, 10, 9, 13, 10, 9,102,108,111, 97,116, 32, 72,108,108, 44, 72,108,114, 44, 72,117,108, 59, 13, 10, 9,114,103, 98,116,111, - 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108,108, 41, 44, 32, 72,108,108, 32, 41, 59, - 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108,114, 41, - 44, 32, 72,108,114, 32, 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, - 97, 44, 32, 83, 84,117,108, 41, 44, 32, 72,117,108, 32, 41, 59, 13, 10, 9, 13, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97, -108,101, 32, 42, 32, 40, 72,108,114, 32, 45, 32, 72,108,108, 41, 59, 13, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, - 32, 42, 32, 40, 72,117,108, 32, 45, 32, 72,108,108, 41, 59, 13, 10,125, 13, 10, 13, 10, 35,105,102,100,101,102, 32, 66, 85, 77, - 80, 95, 66, 73, 67, 85, 66, 73, 67, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 98,105, 99,117, - 98,105, 99, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32, -102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66, -116, 32, 41, 32, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, 72,108, 59, 13, 10, 9,102,108,111, 97,116, 32, 72,114, 59, 13, - 10, 9,102,108,111, 97,116, 32, 72,100, 59, 13, 10, 9,102,108,111, 97,116, 32, 72,117, 59, 13, 10, 9, 13, 10, 9,118,101, 99, - 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 13, 10, 9,118,101, 99, 50, - 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 13, 10, 32, 13, 10, 9,118,101, - 99, 50, 32, 83, 84,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, - 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, - 84,101,120, 68,120, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, - 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, 32,116,101,120, 99,111, - 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9, 13, 10, 9,114,103, 98,116,111, 98,119, - 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 41, 59, 13, 10, 9,114,103, 98, -116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, 32, 72,114, 41, 59, 13, 10, - 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,100, 41, 44, 32, 72,100, - 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, - 44, 32, 72,117, 41, 59, 13, 10, 9, 13, 10, 9,118,101, 99, 50, 32,100, 72,100,120,121, 32, 61, 32,118,101, 99, 50, 40, 72,114, - 32, 45, 32, 72,108, 44, 32, 72,117, 32, 45, 32, 72,100, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,102, 66,108,101,110,100, 32, - 61, 32, 99,108, 97,109,112, 40, 49, 46, 48, 45,116,101,120,116,117,114,101, 81,117,101,114,121, 76, 79, 68, 40,105,109, 97, 44, - 32,116,101,120, 99,111, 46,120,121, 41, 46,120, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,105,102, 40,102, 66, -108,101,110,100, 33, 61, 48, 46, 48, 41, 13, 10, 9,123, 13, 10, 9, 9, 47, 47, 32,116,104,101, 32,100,101,114,105,118, 97,116, -105,118,101, 32,111,102, 32,116,104,101, 32, 98,105, 99,117, 98,105, 99, 32,115, 97,109,112,108,105,110,103, 32,111,102, 32,108, -101,118,101,108, 32, 48, 13, 10, 9, 9,105,118,101, 99, 50, 32,118, 68,105,109, 59, 13, 10, 9, 9,118, 68,105,109, 32, 61, 32, -116,101,120,116,117,114,101, 83,105,122,101, 40,105,109, 97, 44, 32, 48, 41, 59, 13, 10, 13, 10, 9, 9, 47, 47, 32,116, 97,107, -105,110,103, 32,116,104,101, 32,102,114, 97, 99,116, 32,112, 97,114,116, 32,111,102, 32,116,104,101, 32,116,101,120,116,117,114, -101, 32, 99,111,111,114,100,105,110, 97,116,101, 32,105,115, 32, 97, 32,104, 97,114,100, 99,111,100,101,100, 32,119,114, 97,112, - 32,109,111,100,101, 46, 13, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32, 97, 99, 99,101,112,116, 97, 98,108,101, 32, - 97,115, 32,116,101,120,116,117,114,101,115, 32,117,115,101, 32,119,114, 97,112, 32,109,111,100,101, 32,101,120, 99,108,117,115, -105,118,101,108,121, 32,105,110, 32, 51, 68, 32,118,105,101,119, 32,101,108,115,101,119,104,101,114,101, 32,105,110, 32, 98,108, -101,110,100,101,114, 46, 32, 13, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32,100,111,110,101, 32,115,111, 32,116,104, - 97,116, 32,119,101, 32, 99, 97,110, 32,115,116,105,108,108, 32,103,101,116, 32, 97, 32,118, 97,108,105,100, 32,116,101,120,101, -108, 32,119,105,116,104, 32,117,118,115, 32,111,117,116,115,105,100,101, 32,116,104,101, 32, 48, 44, 49, 32,114, 97,110,103,101, - 13, 10, 9, 9, 47, 47, 32, 98,121, 32,116,101,120,101,108, 70,101,116, 99,104, 32, 98,101,108,111,119, 44, 32, 97,115, 32, 99, -111,111,114,100,105,110, 97,116,101,115, 32, 97,114,101, 32, 99,108, 97,109,112,101,100, 32,119,104,101,110, 32,117,115,105,110, -103, 32,116,104,105,115, 32,102,117,110, 99,116,105,111,110, 46, 13, 10, 9, 9,118,101, 99, 50, 32,102, 84,101,120, 76,111, 99, - 32, 61, 32,118, 68,105,109, 42,102,114, 97, 99,116, 40,116,101,120, 99,111, 46,120,121, 41, 32, 45, 32,118,101, 99, 50, 40, 48, - 46, 53, 44, 32, 48, 46, 53, 41, 59, 13, 10, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, 99, 32, 61, 32,105,118,101, - 99, 50, 40,102,108,111,111,114, 40,102, 84,101,120, 76,111, 99, 41, 41, 59, 13, 10, 9, 9,118,101, 99, 50, 32,116, 32, 61, 32, - 99,108, 97,109,112, 40,102, 84,101,120, 76,111, 99, 32, 45, 32,105, 84,101,120, 76,111, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, - 48, 41, 59, 9, 9, 47, 47, 32,115, 97,116, 32,106,117,115,116, 32,116,111, 32, 98,101, 32,112,101,100, 97,110,116,105, 99, 13, - 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 13, - 10, 32, 42, 32, 84,104,105,115, 32, 98,108,111, 99,107, 32,119,105,108,108, 32,114,101,112,108, 97, 99,101, 32,116,104,101, 32, -111,110,101, 32, 98,101,108,111,119, 32,119,104,101,110, 32,111,110,101, 32, 99,104, 97,110,110,101,108, 32,116,101,120,116,117, -114,101,115, 32, 97,114,101, 32,112,114,111,112,101,114,108,121, 32,115,117,112,112,111,114,116,101,100, 46, 32, 42, 13, 10, 32, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 13, 10, 9, 9,118, -101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 85, 76, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105, -109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 45, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, - 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 13, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112, -108,101,115, 85, 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, - 76,111, 99, 43,105,118,101, 99, 50, 40, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, - 47,118, 68,105,109, 32, 41, 59, 13, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 76, 76, 32, 61, 32,116,101, -120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, - 45, 49, 44, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 13, 10, - 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 76, 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101, -114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 49, 44, 49, 41, 32, 43, 32,118,101, 99, - 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 13, 10, 13, 10, 9, 9,109, 97,116, 52, 32, 72, 32, - 61, 32,109, 97,116, 52, 40,118, 83, 97,109,112,108,101,115, 85, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46, -120, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,120, 44, 13, 10, - 9, 9, 9, 9, 9,118, 83, 97,109,112,108,101,115, 85, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46,121, 44, - 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,121, 44, 13, 10, 9, 9, - 9, 9, 9,118, 83, 97,109,112,108,101,115, 85, 82, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,120, 44, 32,118, - 83, 97,109,112,108,101,115, 76, 82, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,120, 44, 13, 10, 9, 9, 9, 9, - 9,118, 83, 97,109,112,108,101,115, 85, 82, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,121, 44, 32,118, 83, 97, -109,112,108,101,115, 76, 82, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,121, 41, 59, 13, 10, 42, 47, 9, 13, 10, - 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, 99, 77,111,100, 32, 61, 32,105, 84,101,120, 76,111, 99, 32, 43, 32,105, -118,101, 99, 50, 40, 45, 49, 44, 32, 45, 49, 41, 59, 13, 10, 13, 10, 9, 9,109, 97,116, 52, 32, 72, 59, 13, 10, 9, 9, 13, 10, - 9, 9,102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 52, 59, 32,105, 43, 43, 41,123, 13, 10, 9, - 9, 9,102,111,114, 40,105,110,116, 32,106, 32, 61, 32, 48, 59, 32,106, 32, 60, 32, 52, 59, 32,106, 43, 43, 41,123, 13, 10, 9, - 9, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 84,109,112, 32, 61, 32,105, 84,101,120, 76,111, 99, 77,111,100, 32, 43, 32, -105,118,101, 99, 50, 40,105, 44,106, 41, 59, 13, 10, 9, 9, 9, 9, 13, 10, 9, 9, 9, 9, 47, 47, 32,119,114, 97,112, 32,116, -101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32,109, 97,110,117, 97,108,108,121, 32,102,111,114, 32, -116,101,120,101,108, 70,101,116, 99,104, 32,116,111, 32,119,111,114,107, 32,111,110, 32,117,118,115, 32,111,105,116,115,105,100, -101, 32,116,104,101, 32, 48, 44, 49, 32,114, 97,110,103,101, 46, 13, 10, 9, 9, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, - 32,103,117, 97,114, 97,110,116,101,101,100, 32,116,111, 32,119,111,114,107, 32,115,105,110, 99,101, 32,119,101, 32,116, 97,107, -101, 32,116,104,101, 32,102,114, 97, 99,116,105,111,110, 97,108, 32,112, 97,114,116, 32,111,102, 32,116,104,101, 32,117,118, 32, - 97, 98,111,118,101, 46, 13, 10, 9, 9, 9, 9,105, 84,101,120, 84,109,112, 46,120, 32, 61, 32, 40,105, 84,101,120, 84,109,112, - 46,120, 32, 60, 32, 48, 41, 63, 32,105, 84,101,120, 84,109,112, 46,120, 32, 43, 32,118, 68,105,109, 46,120, 32, 58, 32, 40, 40, -105, 84,101,120, 84,109,112, 46,120, 32, 62, 61, 32,118, 68,105,109, 46,120, 41, 63, 32,105, 84,101,120, 84,109,112, 46,120, 32, - 45, 32,118, 68,105,109, 46,120, 32, 58, 32,105, 84,101,120, 84,109,112, 46,120, 41, 59, 13, 10, 9, 9, 9, 9,105, 84,101,120, - 84,109,112, 46,121, 32, 61, 32, 40,105, 84,101,120, 84,109,112, 46,121, 32, 60, 32, 48, 41, 63, 32,105, 84,101,120, 84,109,112, - 46,121, 32, 43, 32,118, 68,105,109, 46,121, 32, 58, 32, 40, 40,105, 84,101,120, 84,109,112, 46,121, 32, 62, 61, 32,118, 68,105, -109, 46,121, 41, 63, 32,105, 84,101,120, 84,109,112, 46,121, 32, 45, 32,118, 68,105,109, 46,121, 32, 58, 32,105, 84,101,120, 84, -109,112, 46,121, 41, 59, 13, 10, 13, 10, 9, 9, 9, 9,114,103, 98,116,111, 98,119, 40,116,101,120,101,108, 70,101,116, 99,104, - 40,105,109, 97, 44, 32,105, 84,101,120, 84,109,112, 44, 32, 48, 41, 44, 32, 72, 91,105, 93, 91,106, 93, 41, 59, 13, 10, 9, 9, - 9,125, 13, 10, 9, 9,125, 13, 10, 9, 9, 13, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,116, 46,120, 44, 32,121, 32, - 61, 32,116, 46,121, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,120, 50, 32, 61, 32,120, 32, 42, 32,120, 44, 32,120, 51, 32, 61, - 32,120, 50, 32, 42, 32,120, 44, 32,121, 50, 32, 61, 32,121, 32, 42, 32,121, 44, 32,121, 51, 32, 61, 32,121, 50, 32, 42, 32,121, - 59, 13, 10, 13, 10, 9, 9,118,101, 99, 52, 32, 88, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,120, 51, 43,120, 41, - 43,120, 50, 44, 9, 9, 49, 46, 53, 42,120, 51, 45, 50, 46, 53, 42,120, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,120, 51, 43, 50, - 42,120, 50, 43, 48, 46, 53, 42,120, 44, 9, 9, 48, 46, 53, 42, 40,120, 51, 45,120, 50, 41, 41, 59, 13, 10, 9, 9,118,101, 99, - 52, 32, 89, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,121, 51, 43,121, 41, 43,121, 50, 44, 9, 9, 49, 46, 53, 42, -121, 51, 45, 50, 46, 53, 42,121, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,121, 51, 43, 50, 42,121, 50, 43, 48, 46, 53, 42,121, 44, - 9, 9, 48, 46, 53, 42, 40,121, 51, 45,121, 50, 41, 41, 59, 13, 10, 9, 9,118,101, 99, 52, 32,100, 88, 32, 61, 32,118,101, 99, - 52, 40, 45, 49, 46, 53, 42,120, 50, 43, 50, 42,120, 45, 48, 46, 53, 44, 9, 9, 52, 46, 53, 42,120, 50, 45, 53, 42,120, 44, 9, - 9, 9, 45, 52, 46, 53, 42,120, 50, 43, 52, 42,120, 43, 48, 46, 53, 44, 9, 9, 49, 46, 53, 42,120, 50, 45,120, 41, 59, 13, 10, - 9, 9,118,101, 99, 52, 32,100, 89, 32, 61, 32,118,101, 99, 52, 40, 45, 49, 46, 53, 42,121, 50, 43, 50, 42,121, 45, 48, 46, 53, - 44, 9, 9, 52, 46, 53, 42,121, 50, 45, 53, 42,121, 44, 9, 9, 9, 45, 52, 46, 53, 42,121, 50, 43, 52, 42,121, 43, 48, 46, 53, - 44, 9, 9, 49, 46, 53, 42,121, 50, 45,121, 41, 59, 13, 10, 9, 13, 10, 9, 9, 47, 47, 32, 99,111,109,112,108,101,116,101, 32, -100,101,114,105,118, 97,116,105,118,101, 32,105,110, 32,110,111,114,109, 97,108,105,122,101,100, 32, 99,111,111,114,100,105,110, - 97,116,101,115, 32, 40,109,117,108, 32, 98,121, 32,118, 68,105,109, 41, 13, 10, 9, 9,118,101, 99, 50, 32,100, 72,100, 83, 84, - 32, 61, 32,118, 68,105,109, 32, 42, 32,118,101, 99, 50, 40,100,111,116, 40, 89, 44, 32, 72, 32, 42, 32,100, 88, 41, 44, 32,100, -111,116, 40,100, 89, 44, 32, 72, 32, 42, 32, 88, 41, 41, 59, 13, 10, 13, 10, 9, 9, 47, 47, 32,116,114, 97,110,115,102,111,114, -109, 32,100,101,114,105,118, 97,116,105,118,101, 32,116,111, 32,115, 99,114,101,101,110, 45,115,112, 97, 99,101, 13, 10, 9, 9, -118,101, 99, 50, 32,100, 72,100,120,121, 95, 98,105, 99,117, 98,105, 99, 32, 61, 32,118,101, 99, 50, 40, 32,100, 72,100, 83, 84, - 46,120, 32, 42, 32, 84,101,120, 68,120, 46,120, 32, 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, 84,101,120, 68,120, 46,121, - 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,100, 72,100, 83, 84, 46,120, 32, 42, 32, 84,101,120, 68,121, 46,120, 32, - 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, 84,101,120, 68,121, 46,121, 32, 41, 59, 13, 10, 13, 10, 9, 9, 47, 47, 32, 98, -108,101,110,100, 32, 98,101,116,119,101,101,110, 32,116,104,101, 32,116,119,111, 13, 10, 9, 9,100, 72,100,120,121, 32, 61, 32, -100, 72,100,120,121, 42, 40, 49, 45,102, 66,108,101,110,100, 41, 32, 43, 32,100, 72,100,120,121, 95, 98,105, 99,117, 98,105, 99, - 42,102, 66,108,101,110,100, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, -100, 72,100,120,121, 46,120, 59, 13, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32,100, 72,100,120,121, 46, -121, 59, 13, 10,125, 13, 10, 13, 10, 35,101,110,100,105,102, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109, -112, 95,116, 97,112, 53, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, - 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, +110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95,118, 97,108,117,101, + 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9,105,102, 40,116,101, +120, 99,111,108, 32, 33, 61, 32, 48, 46, 48, 41, 10, 9, 9,105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99, +111,108, 32, 43, 32,102, 97, 99,116, 42,111,117,116, 99,111,108, 47,116,101,120, 99,111,108, 59, 10, 9,101,108,115,101, 10, 9, + 9,105,110, 99,111,108, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, + 95,100,105,102,102, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, 99,111,108, + 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116,101,120, 95, +118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, 10, 10, 9, +105,110, 99,111,108, 32, 61, 32,102, 97, 99,109, 42,111,117,116, 99,111,108, 32, 43, 32,102, 97, 99,116, 42, 97, 98,115, 40,116, +101,120, 99,111,108, 32, 45, 32,111,117,116, 99,111,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97, +108,117,101, 95,100, 97,114,107, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, + 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116, +101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, + 10, 10, 9,102,108,111, 97,116, 32, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 59, 10, 9,105,102, 40, + 99,111,108, 32, 60, 32,111,117,116, 99,111,108, 41, 32,105,110, 99,111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32, +105,110, 99,111,108, 32, 61, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108, +117,101, 95,108,105,103,104,116, 40,102,108,111, 97,116, 32,111,117,116, 99,111,108, 44, 32,102,108,111, 97,116, 32,116,101,120, + 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 97, 99,116, 44, 32,102,108,111, 97,116, 32,102, 97, 99,103, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,105,110, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,109, 59, 10, 9,109,116, +101,120, 95,118, 97,108,117,101, 95,118, 97,114,115, 40,102, 97, 99,116, 44, 32,102, 97, 99,103, 44, 32,102, 97, 99,109, 41, 59, + 10, 10, 9,102,108,111, 97,116, 32, 99,111,108, 32, 61, 32,102, 97, 99,116, 42,116,101,120, 99,111,108, 59, 10, 9,105,102, 40, + 99,111,108, 32, 62, 32,111,117,116, 99,111,108, 41, 32,105,110, 99,111,108, 32, 61, 32, 99,111,108, 59, 32,101,108,115,101, 32, +105,110, 99,111,108, 32, 61, 32,111,117,116, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108, +117,101, 95, 99,108, 97,109,112, 95,112,111,115,105,116,105,118,101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 10,123, 10, 9,111,117,116,102, 97, 99, 32, 61, 32,109, 97,120, 40,102, + 97, 99, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95, 99,108, 97, +109,112, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 10, +123, 10, 9,111,117,116,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40,102, 97, 99, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,104, 97,114, 95,100,105,118,105,100,101, 40,102,108,111, 97,116, 32, +104, 97,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,104, 97,114, 41, 10,123, 10, 9,111,117,116,104, 97,114, + 32, 61, 32,104, 97,114, 47, 49, 50, 56, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,104, 97,114, 95,109, +117,108,116,105,112,108,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32,104, 97,114, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,111,117,116,104, 97,114, 41, 10,123, 10, 9,104, 97,114, 32, 42, 61, 32, 49, 50, 56, 46, 48, 59, 10, 10, 9,105,102, + 40,104, 97,114, 32, 60, 32, 49, 46, 48, 41, 32,111,117,116,104, 97,114, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 32, +105,102, 40,104, 97,114, 32, 62, 32, 53, 49, 49, 46, 48, 41, 32,111,117,116,104, 97,114, 32, 61, 32, 53, 49, 49, 46, 48, 59, 10, + 9,101,108,115,101, 32,111,117,116,104, 97,114, 32, 61, 32,104, 97,114, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, + 95, 97,108,112,104, 97, 95,102,114,111,109, 95, 99,111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,102,108, +111, 97,116, 32, 97,108,112,104, 97, 41, 10,123, 10, 9, 97,108,112,104, 97, 32, 61, 32, 99,111,108, 46, 97, 59, 10,125, 10, 10, +118,111,105,100, 32,109,116,101,120, 95, 97,108,112,104, 97, 95,116,111, 95, 99,111,108, 40,118,101, 99, 52, 32, 99,111,108, 44, + 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, + 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 97,108,112,104, 97, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98,116,111,105,110,116, 40,118,101, 99, 52, 32,114,103, 98, 44, + 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,116,101,110,115,105,116,121, 41, 10,123, 10, 9,105,110,116,101,110,115,105, +116,121, 32, 61, 32,100,111,116, 40,118,101, 99, 51, 40, 48, 46, 51, 53, 44, 32, 48, 46, 52, 53, 44, 32, 48, 46, 50, 41, 44, 32, +114,103, 98, 46,114,103, 98, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,105,110,118, +101,114,116, 40,102,108,111, 97,116, 32,105,110,118, 97,108,117,101, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116, +118, 97,108,117,101, 41, 10,123, 10, 9,111,117,116,118, 97,108,117,101, 32, 61, 32, 49, 46, 48, 32, 45, 32,105,110,118, 97,108, +117,101, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,105,110,118,101,114,116, 40,118,101, 99, 52, + 32,105,110,114,103, 98, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,114,103, 98, 41, 10,123, 10, 9,111,117,116,114, +103, 98, 32, 61, 32,118,101, 99, 52, 40,118,101, 99, 51, 40, 49, 46, 48, 41, 32, 45, 32,105,110,114,103, 98, 46,114,103, 98, 44, + 32,105,110,114,103, 98, 46, 97, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,118, 97,108,117,101, 95,115,116, +101,110, 99,105,108, 40,102,108,111, 97,116, 32,115,116,101,110, 99,105,108, 44, 32,102,108,111, 97,116, 32,105,110,116,101,110, +115,105,116,121, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,116,101,110, 99,105,108, 44, 32,111,117,116, 32, +102,108,111, 97,116, 32,111,117,116,105,110,116,101,110,115,105,116,121, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99, +116, 32, 61, 32,105,110,116,101,110,115,105,116,121, 59, 10, 9,111,117,116,105,110,116,101,110,115,105,116,121, 32, 61, 32,105, +110,116,101,110,115,105,116,121, 42,115,116,101,110, 99,105,108, 59, 10, 9,111,117,116,115,116,101,110, 99,105,108, 32, 61, 32, +115,116,101,110, 99,105,108, 42,102, 97, 99,116, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,114,103, 98, 95,115, +116,101,110, 99,105,108, 40,102,108,111, 97,116, 32,115,116,101,110, 99,105,108, 44, 32,118,101, 99, 52, 32,114,103, 98, 44, 32, +111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,116,101,110, 99,105,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, +117,116,114,103, 98, 41, 10,123, 10, 9,102,108,111, 97,116, 32,102, 97, 99,116, 32, 61, 32,114,103, 98, 46, 97, 59, 10, 9,111, +117,116,114,103, 98, 32, 61, 32,118,101, 99, 52, 40,114,103, 98, 46,114,103, 98, 44, 32,114,103, 98, 46, 97, 42,115,116,101,110, + 99,105,108, 41, 59, 10, 9,111,117,116,115,116,101,110, 99,105,108, 32, 61, 32,115,116,101,110, 99,105,108, 42,102, 97, 99,116, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,111,102,115, 40,118,101, 99, 51, 32, +116,101,120, 99,111, 44, 32,118,101, 99, 51, 32,111,102,115, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, + 99,111, 41, 10,123, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,116,101,120, 99,111, 32, 43, 32,111,102,115, 59, 10,125, + 10, 10,118,111,105,100, 32,109,116,101,120, 95,109, 97,112,112,105,110,103, 95,115,105,122,101, 40,118,101, 99, 51, 32,116,101, +120, 99,111, 44, 32,118,101, 99, 51, 32,115,105,122,101, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,116,101,120, 99, +111, 41, 10,123, 10, 9,111,117,116,116,101,120, 99,111, 32, 61, 32,115,105,122,101, 42,116,101,120, 99,111, 59, 10,125, 10, 10, +118,111,105,100, 32,109,116,101,120, 95, 50,100, 95,109, 97,112,112,105,110,103, 40,118,101, 99, 51, 32,118,101, 99, 44, 32,111, +117,116, 32,118,101, 99, 51, 32,111,117,116,118,101, 99, 41, 10,123, 10, 9,111,117,116,118,101, 99, 32, 61, 32,118,101, 99, 51, + 40,118,101, 99, 46,120,121, 42, 48, 46, 53, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 32, 48, 46, 53, 41, 44, 32,118,101, + 99, 46,122, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,105,109, 97,103,101, 40,118,101, 99, 51, 32,116,101, +120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118, 97, +108,117,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32, +116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118, 97,108,117,101, + 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,110,111,114,109, 97,108, 40,118,101, 99, 51, + 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32, +110,111,114,109, 97,108, 41, 10,123, 10, 9, 47, 47, 32, 84,104,101, 32,105,110,118,101,114,116, 32,111,102, 32,116,104,101, 32, +114,101,100, 32, 99,104, 97,110,110,101,108, 32,105,115, 32,116,111, 32,109, 97,107,101, 10, 9, 47, 47, 32,116,104,101, 32,110, +111,114,109, 97,108, 32,109, 97,112, 32, 99,111,109,112,108,105, 97,110,116, 32,119,105,116,104, 32,116,104,101, 32,111,117,116, +115,105,100,101, 32,119,111,114,108,100, 46, 10, 9, 47, 47, 32, 73,116, 32,110,101,101,100,115, 32,116,111, 32, 98,101, 32,100, +111,110,101, 32, 98,101, 99, 97,117,115,101, 32,105,110, 32, 66,108,101,110,100,101,114, 10, 9, 47, 47, 32,116,104,101, 32,110, +111,114,109, 97,108, 32,117,115,101,100, 32,112,111,105,110,116,115, 32,105,110,119, 97,114,100, 46, 10, 9, 47, 47, 32, 83,104, +111,117,108,100, 32,116,104,105,115, 32,101,118,101,114, 32, 99,104, 97,110,103,101, 32,116,104,105,115, 32,110,101,103, 97,116, +101, 32,109,117,115,116, 32, 98,101, 32,114,101,109,111,118,101,100, 46, 10, 32, 32, 32, 32,118,101, 99, 52, 32, 99,111,108,111, +114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,110, +111,114,109, 97,108, 32, 61, 32, 50, 46, 48, 42, 40,118,101, 99, 51, 40, 45, 99,111,108,111,114, 46,114, 44, 32, 99,111,108,111, +114, 46,103, 44, 32, 99,111,108,111,114, 46, 98, 41, 32, 45, 32,118,101, 99, 51, 40, 45, 48, 46, 53, 44, 32, 48, 46, 53, 44, 32, + 48, 46, 53, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,110,111,114,109, 97,108,115, + 95,105,110,105,116, 40, 32,118,101, 99, 51, 32,118, 78, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78,111,114,103, 44, 32, +111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, + 97,103,110,105,116,117,100,101, 32, 41, 10,123, 10, 9,118, 78,111,114,103, 32, 61, 32,118, 78, 59, 10, 9,118, 78, 97, 99, 99, + 32, 61, 32,118, 78, 59, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, + 10, 47, 42, 42, 32,104,101,108,112,101,114, 32,109,101,116,104,111,100, 32,116,111, 32,101,120,116,114, 97, 99,116, 32,116,104, +101, 32,117,112,112,101,114, 32,108,101,102,116, 32, 51,120, 51, 32,109, 97,116,114,105,120, 32,102,114,111,109, 32, 97, 32, 52, +120, 52, 32,109, 97,116,114,105,120, 32, 42, 47, 10,109, 97,116, 51, 32,116,111, 95,109, 97,116, 51, 40,109, 97,116, 52, 32,109, + 52, 41, 10,123, 10, 9,109, 97,116, 51, 32,109, 51, 59, 10, 9,109, 51, 91, 48, 93, 32, 61, 32,109, 52, 91, 48, 93, 46,120,121, +122, 59, 10, 9,109, 51, 91, 49, 93, 32, 61, 32,109, 52, 91, 49, 93, 46,120,121,122, 59, 10, 9,109, 51, 91, 50, 93, 32, 61, 32, +109, 52, 91, 50, 93, 46,120,121,122, 59, 10, 9,114,101,116,117,114,110, 32,109, 51, 59, 10,125, 10, 10,118,111,105,100, 32,109, +116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,111, 98,106,115,112, 97, 99,101, 40, 32,118,101, 99, 51, 32,115,117,114, +102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, 44, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, +109, 97,116, 52, 32,109, 86,105,101,119, 44, 32,109, 97,116, 52, 32,109, 86,105,101,119, 73,110,118, 44, 32,109, 97,116, 52, 32, +109, 79, 98,106, 44, 32,109, 97,116, 52, 32,109, 79, 98,106, 73,110,118, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108, +111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, + 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97, +103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, + 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 68,101,116, 32, 41, 32, 10,123, 10, 9,109, 97,116, 51, + 32,111, 98,106, 50,118,105,101,119, 32, 61, 32,116,111, 95,109, 97,116, 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, + 77, 97,116,114,105,120, 41, 59, 10, 9,109, 97,116, 51, 32,118,105,101,119, 50,111, 98,106, 32, 61, 32,116,111, 95,109, 97,116, + 51, 40,103,108, 95, 77,111,100,101,108, 86,105,101,119, 77, 97,116,114,105,120, 73,110,118,101,114,115,101, 41, 59, 10, 9, 10, + 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, 61, 32,118,105,101,119, 50,111, 98,106, 32, 42, 32,100, 70,100,120, 40, + 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, 61, 32,118,105,101, +119, 50,111, 98,106, 32, 42, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32, +118, 78, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,115,117,114,102, 95,110,111,114,109, 32, 42, 32,111, 98,106, 50, +118,105,101,119, 32, 41, 59, 10, 10, 9,118, 82, 49, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32, +118, 78, 32, 41, 59, 10, 9,118, 82, 50, 32, 61, 32, 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, + 41, 32, 59, 10, 9,102, 68,101,116, 32, 61, 32,100,111,116, 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, + 59, 10, 9, 10, 9, 47, 42, 32,112,114,101,116,114, 97,110,115,102,111,114,109, 32,118, 78, 97, 99, 99, 32, 40,105,110, 32,109, +116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 41, 32,117,115,105,110,103, 32,116,104,101, 32,105,110,118,101,114,115, +101, 32,116,114, 97,110,115,112,111,115,101,100, 32, 42, 47, 10, 9,118, 82, 49, 32, 61, 32,118, 82, 49, 32, 42, 32,118,105,101, +119, 50,111, 98,106, 59, 10, 9,118, 82, 50, 32, 61, 32,118, 82, 50, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 10, 9,118, + 78, 32, 61, 32,118, 78, 32, 42, 32,118,105,101,119, 50,111, 98,106, 59, 10, 9, 10, 9,102,108,111, 97,116, 32,102, 77, 97,103, +110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 32, 42, 32,108,101,110,103,116,104, 40,118, 78, 41, 59, + 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105, +116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 10, 9,102, 80,114,101, +118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 10,125, 10, 10, +118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,116,101,120,116,117,114,101,115,112, 97, 99,101, + 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114,102, 95,110,111,114,109, 44, + 32, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, + 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117, +116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 44, 32,111,117,116, 32, +118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118, +101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117,116, 32,102,108,111, 97,116, + 32,102, 68,101,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, 61, 32,100, 70,100,120, 40, + 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 84, 32, 61, 32,100, 70,100, +121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, 32,115,117,114,102, 95,110, +111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32,105,110,116,101,114,112,111,108, 97,116,101,100, 32, +118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 10, 9, 10, 9,118, 82, 49, 32, 61, 32,110,111,114,109, 97,108, +105,122,101, 40, 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 32, 41, 59, 10, 9,118, 82, + 50, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32, 99,114,111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, + 83, 32, 41, 32, 41, 59, 10, 9,102, 68,101,116, 32, 61, 32,115,105,103,110, 40, 32,100,111,116, 40,118, 83,105,103,109, 97, 83, + 44, 32,118, 82, 49, 41, 32, 41, 59, 10, 9, 10, 9,102,108,111, 97,116, 32,102, 77, 97,103,110,105,116,117,100,101, 32, 61, 32, + 97, 98,115, 40,102, 68,101,116, 41, 59, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, + 32, 42, 32, 40,102, 77, 97,103,110,105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95, +105,110, 41, 59, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117,116, 32, 61, 32,102, 77, 97,103,110, +105,116,117,100,101, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,105,110,105,116, 95,118,105, +101,119,115,112, 97, 99,101, 40, 32,118,101, 99, 51, 32,115,117,114,102, 95,112,111,115, 44, 32,118,101, 99, 51, 32,115,117,114, +102, 95,110,111,114,109, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97, +103,110,105,116,117,100,101, 95,105,110, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, + 9, 9, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117, +116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, 10, 9, 9, 9, 9, 9, 9, 9, 32, + 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,102, 68,101,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, 83, 32, + 61, 32,100, 70,100,120, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 83,105,103,109, 97, + 84, 32, 61, 32,100, 70,100,121, 40, 32,115,117,114,102, 95,112,111,115, 32, 41, 59, 10, 9,118,101, 99, 51, 32,118, 78, 32, 61, + 32,115,117,114,102, 95,110,111,114,109, 59, 32, 47, 42, 32,110,111,114,109, 97,108,105,122,101,100, 32,105,110,116,101,114,112, +111,108, 97,116,101,100, 32,118,101,114,116,101,120, 32,110,111,114,109, 97,108, 32, 42, 47, 10, 9, 10, 9,118, 82, 49, 32, 61, + 32, 99,114,111,115,115, 40, 32,118, 83,105,103,109, 97, 84, 44, 32,118, 78, 32, 41, 59, 10, 9,118, 82, 50, 32, 61, 32, 99,114, +111,115,115, 40, 32,118, 78, 44, 32,118, 83,105,103,109, 97, 83, 32, 41, 32, 59, 10, 9,102, 68,101,116, 32, 61, 32,100,111,116, + 32, 40, 32,118, 83,105,103,109, 97, 83, 44, 32,118, 82, 49, 32, 41, 59, 10, 9, 10, 9,102,108,111, 97,116, 32,102, 77, 97,103, +110,105,116,117,100,101, 32, 61, 32, 97, 98,115, 40,102, 68,101,116, 41, 59, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, + 32,118, 78, 97, 99, 99, 95,105,110, 32, 42, 32, 40,102, 77, 97,103,110,105,116,117,100,101, 32, 47, 32,102, 80,114,101,118, 77, + 97,103,110,105,116,117,100,101, 95,105,110, 41, 59, 10, 9,102, 80,114,101,118, 77, 97,103,110,105,116,117,100,101, 95,111,117, +116, 32, 61, 32,102, 77, 97,103,110,105,116,117,100,101, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109, +112, 95,116, 97,112, 51, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, + 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, +100, 66,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 50, 32, 83, 84,108,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 59, 10, + 9,118,101, 99, 50, 32, 83, 84,108,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32,100, 70,100,120, 40,116,101,120, + 99,111, 46,120,121, 41, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,117,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, + 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 32, 59, 10, 9, 10, 9,102,108,111, 97,116, 32, 72,108,108, 44, 72, +108,114, 44, 72,117,108, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, + 32, 83, 84,108,108, 41, 44, 32, 72,108,108, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, + 50, 68, 40,105,109, 97, 44, 32, 83, 84,108,114, 41, 44, 32, 72,108,114, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32, +116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117,108, 41, 44, 32, 72,117,108, 32, 41, 59, 10, 9, 10, 9, +100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,108,114, 32, 45, 32, 72,108,108, 41, 59, 10, 9,100, 66,116, + 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,117,108, 32, 45, 32, 72,108,108, 41, 59, 10,125, 10, 10, 35,105,102,100, +101,102, 32, 66, 85, 77, 80, 95, 66, 73, 67, 85, 66, 73, 67, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, + 98,105, 99,117, 98,105, 99, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105, +109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, - 32,100, 66,116, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116, -101,120, 99,111, 46,120,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101, -120, 99,111, 46,120,121, 41, 59, 13, 10, 13, 10, 9,118,101, 99, 50, 32, 83, 84, 99, 32, 61, 32,116,101,120, 99,111, 46,120,121, - 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, - 84,101,120, 68,120, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, - 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, - 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, - 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 13, 10, 9, 13, 10, 9,102, -108,111, 97,116, 32, 72, 99, 44, 72,108, 44, 72,114, 44, 72,100, 44, 72,117, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32, -116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84, 99, 41, 44, 32, 72, 99, 32, 41, 59, 13, 10, 9,114,103, 98, -116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 32, 41, 59, - 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, - 32, 72,114, 32, 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, - 32, 83, 84,100, 41, 44, 32, 72,100, 32, 41, 59, 13, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, - 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, 44, 32, 72,117, 32, 41, 59, 13, 10, 9, 13, 10, 9,100, 66,115, 32, 61, 32,104, 83, - 99, 97,108,101, 32, 42, 32, 40, 72,114, 32, 45, 32, 72,108, 41, 59, 13, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, - 32, 42, 32, 40, 72,117, 32, 45, 32, 72,100, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117, -109,112, 95,100,101,114,105,118, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, -105,109, 97, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,102, -108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,116, - 32, 41, 32, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,115, 32, 61, 32, 49, 46, 48, 59, 9, 9, 47, 47, 32,110,101,103, 97, -116,101, 32,116,104,105,115, 32,105,102, 32,102,108,105,112,112,101,100, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100, -105,110, 97,116,101, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46, -120,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120, -121, 41, 59, 13, 10, 9, 13, 10, 9, 47, 47, 32,116,104,105,115, 32,118, 97,114,105, 97,110,116, 32,117,115,105,110,103, 32, 97, - 32,100,101,114,105,118, 97,116,105,118,101, 32,109, 97,112, 32,105,115, 32,100,101,115, 99,114,105, 98,101,100, 32,104,101,114, -101, 13, 10, 9, 47, 47, 32,104,116,116,112, 58, 47, 47,109,109,105,107,107,101,108,115,101,110, 51,100, 46, 98,108,111,103,115, -112,111,116, 46, 99,111,109, 47, 50, 48, 49, 49, 47, 48, 55, 47,100,101,114,105,118, 97,116,105,118,101, 45,109, 97,112,115, 46, -104,116,109,108, 13, 10, 9,118,101, 99, 50, 32,100,105,109, 32, 61, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 44, 32,105,109, - 97, 95,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32,100, 66,100,117,118, 32, 61, 32,104, 83, 99, 97,108,101, 42,100,105,109, 42, - 40, 50, 46, 48, 42,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 46,120,121, - 45, 49, 46, 48, 41, 59, 13, 10, 9, 13, 10, 9,100, 66,115, 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84,101,120, 68,120, 46, -120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,120, 46,121, 59, 13, 10, 9,100, 66,116, 32, 61, 32,100, - 66,100,117,118, 46,120, 42, 84,101,120, 68,121, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,121, - 46,121, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 40, 32, -102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, 66,116, - 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, - 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, - 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 41, 32, 13, 10,123, 13, 10, - 9,118,101, 99, 51, 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40,102, 68,101,116, 41, 32, 42, 32, 40, - 32,100, 66,115, 32, 42, 32,118, 82, 49, 32, 43, 32,100, 66,116, 32, 42, 32,118, 82, 50, 32, 41, 59, 13, 10, 9, 13, 10, 9,118, - 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83,117,114,102, 71,114, 97,100, 59, - 13, 10, 9,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,118, - 78, 97, 99, 99, 95,111,117,116, 32, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, - 95, 97,112,112,108,121, 95,116,101,120,115,112, 97, 99,101, 40, 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, - 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, 66,116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, - 51, 32,118, 82, 50, 44, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32, 32, 32, 32, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111, - 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,118,101, 99, 51, - 32,118, 78, 97, 99, 99, 95,105,110, 44, 13, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, - 78, 97, 99, 99, 95,111,117,116, 44, 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114, -109, 32, 41, 32, 13, 10,123, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99, -111, 46,120,121, 41, 59, 13, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, - 46,120,121, 41, 59, 13, 10, 13, 10, 9,118,101, 99, 51, 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40, -102, 68,101,116, 41, 32, 42, 32, 40, 32, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,100, 66,115, 32, 47, 32,108, -101,110,103,116,104, 40, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 42, 84,101,120, 68,120, 46,120, 44, 32,105,109, 97, 95,121, - 42, 84,101,120, 68,120, 46,121, 41, 32, 41, 32, 42, 32,118, 82, 49, 32, 43, 32, 13, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, - 32, 32, 32,100, 66,116, 32, 47, 32,108,101,110,103,116,104, 40, 32,118,101, 99, 50, 40,105,109, 97, 95,120, 42, 84,101,120, 68, -121, 46,120, 44, 32,105,109, 97, 95,121, 42, 84,101,120, 68,121, 46,121, 41, 32, 41, 32, 42, 32,118, 82, 50, 32, 41, 59, 13, 10, - 9, 9, 9, 9, 13, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83, -117,114,102, 71,114, 97,100, 59, 13, 10, 9,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, - 97,108,105,122,101, 40, 32,118, 78, 97, 99, 99, 95,111,117,116, 32, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109, -116,101,120, 95,110,101,103, 97,116,101, 95,116,101,120,110,111,114,109, 97,108, 40,118,101, 99, 51, 32,110,111,114,109, 97,108, - 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,110,111, -114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, 45,110,111,114,109, 97,108, 46,120, 44, 32, 45,110,111,114,109, 97,108, 46,121, - 44, 32,110,111,114,109, 97,108, 46,122, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116,101,120, 95,110,115,112, - 97, 99,101, 95,116, 97,110,103,101,110,116, 40,118,101, 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,118,101, 99, 51, 32,110, -111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,116,101,120,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32, -111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 66, 32, 61, 32,116, 97,110,103,101,110,116, - 46,119, 32, 42, 32, 99,114,111,115,115, 40,110,111,114,109, 97,108, 44, 32,116, 97,110,103,101,110,116, 46,120,121,122, 41, 59, - 13, 10, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,116,101,120,110,111,114,109, 97,108, 46,120, 42,116, 97,110, + 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,102,108,111, 97,116, 32, 72,108, 59, 10, 9,102,108,111, 97,116, 32, 72,114, 59, 10, + 9,102,108,111, 97,116, 32, 72,100, 59, 10, 9,102,108,111, 97,116, 32, 72,117, 59, 10, 9, 10, 9,118,101, 99, 50, 32, 84,101, +120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, 68, +121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 32, 10, 9,118,101, 99, 50, 32, 83, 84,108, 32, + 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 10, 9,118,101, 99, 50, + 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 10, + 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, + 68,121, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, + 42, 32, 84,101,120, 68,121, 32, 59, 10, 9, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, 68, 40,105, +109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117,114,101, 50, + 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, 32, 72,114, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40,116,101,120,116,117, +114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,100, 41, 44, 32, 72,100, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40,116,101, +120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,117, 41, 44, 32, 72,117, 41, 59, 10, 9, 10, 9,118,101, 99, 50, 32, +100, 72,100,120,121, 32, 61, 32,118,101, 99, 50, 40, 72,114, 32, 45, 32, 72,108, 44, 32, 72,117, 32, 45, 32, 72,100, 41, 59, 10, + 9,102,108,111, 97,116, 32,102, 66,108,101,110,100, 32, 61, 32, 99,108, 97,109,112, 40, 49, 46, 48, 45,116,101,120,116,117,114, +101, 81,117,101,114,121, 76, 79, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, 46,120,121, 41, 46,120, 44, 32, 48, 46, 48, 44, + 32, 49, 46, 48, 41, 59, 10, 9,105,102, 40,102, 66,108,101,110,100, 33, 61, 48, 46, 48, 41, 10, 9,123, 10, 9, 9, 47, 47, 32, +116,104,101, 32,100,101,114,105,118, 97,116,105,118,101, 32,111,102, 32,116,104,101, 32, 98,105, 99,117, 98,105, 99, 32,115, 97, +109,112,108,105,110,103, 32,111,102, 32,108,101,118,101,108, 32, 48, 10, 9, 9,105,118,101, 99, 50, 32,118, 68,105,109, 59, 10, + 9, 9,118, 68,105,109, 32, 61, 32,116,101,120,116,117,114,101, 83,105,122,101, 40,105,109, 97, 44, 32, 48, 41, 59, 10, 10, 9, + 9, 47, 47, 32,116, 97,107,105,110,103, 32,116,104,101, 32,102,114, 97, 99,116, 32,112, 97,114,116, 32,111,102, 32,116,104,101, + 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101, 32,105,115, 32, 97, 32,104, 97,114,100, 99,111,100, +101,100, 32,119,114, 97,112, 32,109,111,100,101, 46, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32, 97, 99, 99,101,112, +116, 97, 98,108,101, 32, 97,115, 32,116,101,120,116,117,114,101,115, 32,117,115,101, 32,119,114, 97,112, 32,109,111,100,101, 32, +101,120, 99,108,117,115,105,118,101,108,121, 32,105,110, 32, 51, 68, 32,118,105,101,119, 32,101,108,115,101,119,104,101,114,101, + 32,105,110, 32, 98,108,101,110,100,101,114, 46, 32, 10, 9, 9, 47, 47, 32,116,104,105,115, 32,105,115, 32,100,111,110,101, 32, +115,111, 32,116,104, 97,116, 32,119,101, 32, 99, 97,110, 32,115,116,105,108,108, 32,103,101,116, 32, 97, 32,118, 97,108,105,100, + 32,116,101,120,101,108, 32,119,105,116,104, 32,117,118,115, 32,111,117,116,115,105,100,101, 32,116,104,101, 32, 48, 44, 49, 32, +114, 97,110,103,101, 10, 9, 9, 47, 47, 32, 98,121, 32,116,101,120,101,108, 70,101,116, 99,104, 32, 98,101,108,111,119, 44, 32, + 97,115, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32, 97,114,101, 32, 99,108, 97,109,112,101,100, 32,119,104,101,110, 32, +117,115,105,110,103, 32,116,104,105,115, 32,102,117,110, 99,116,105,111,110, 46, 10, 9, 9,118,101, 99, 50, 32,102, 84,101,120, + 76,111, 99, 32, 61, 32,118, 68,105,109, 42,102,114, 97, 99,116, 40,116,101,120, 99,111, 46,120,121, 41, 32, 45, 32,118,101, 99, + 50, 40, 48, 46, 53, 44, 32, 48, 46, 53, 41, 59, 10, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, 99, 32, 61, 32,105, +118,101, 99, 50, 40,102,108,111,111,114, 40,102, 84,101,120, 76,111, 99, 41, 41, 59, 10, 9, 9,118,101, 99, 50, 32,116, 32, 61, + 32, 99,108, 97,109,112, 40,102, 84,101,120, 76,111, 99, 32, 45, 32,105, 84,101,120, 76,111, 99, 44, 32, 48, 46, 48, 44, 32, 49, + 46, 48, 41, 59, 9, 9, 47, 47, 32,115, 97,116, 32,106,117,115,116, 32,116,111, 32, 98,101, 32,112,101,100, 97,110,116,105, 99, + 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 10, 32, + 42, 32, 84,104,105,115, 32, 98,108,111, 99,107, 32,119,105,108,108, 32,114,101,112,108, 97, 99,101, 32,116,104,101, 32,111,110, +101, 32, 98,101,108,111,119, 32,119,104,101,110, 32,111,110,101, 32, 99,104, 97,110,110,101,108, 32,116,101,120,116,117,114,101, +115, 32, 97,114,101, 32,112,114,111,112,101,114,108,121, 32,115,117,112,112,111,114,116,101,100, 46, 32, 42, 10, 32, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 10, 9, 9,118,101, 99, 52, 32, +118, 83, 97,109,112,108,101,115, 85, 76, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, + 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 45, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, + 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 85, 82, + 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105, +118,101, 99, 50, 40, 49, 44, 45, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, + 32, 41, 59, 10, 9, 9,118,101, 99, 52, 32,118, 83, 97,109,112,108,101,115, 76, 76, 32, 61, 32,116,101,120,116,117,114,101, 71, + 97,116,104,101,114, 40,105,109, 97, 44, 32, 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 45, 49, 44, 49, 41, 32, + 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 10, 9, 9,118,101, 99, 52, 32, +118, 83, 97,109,112,108,101,115, 76, 82, 32, 61, 32,116,101,120,116,117,114,101, 71, 97,116,104,101,114, 40,105,109, 97, 44, 32, + 40,105, 84,101,120, 76,111, 99, 43,105,118,101, 99, 50, 40, 49, 44, 49, 41, 32, 43, 32,118,101, 99, 50, 40, 48, 46, 53, 44, 48, + 46, 53, 41, 41, 47,118, 68,105,109, 32, 41, 59, 10, 10, 9, 9,109, 97,116, 52, 32, 72, 32, 61, 32,109, 97,116, 52, 40,118, 83, + 97,109,112,108,101,115, 85, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46,120, 44, 32,118, 83, 97,109,112,108, +101,115, 76, 76, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,120, 44, 10, 9, 9, 9, 9, 9,118, 83, 97,109,112, +108,101,115, 85, 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 76, 46,121, 44, 32,118, 83, 97,109,112,108,101,115, 76, + 76, 46,122, 44, 32,118, 83, 97,109,112,108,101,115, 76, 76, 46,121, 44, 10, 9, 9, 9, 9, 9,118, 83, 97,109,112,108,101,115, + 85, 82, 46,119, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,120, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,119, + 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,120, 44, 10, 9, 9, 9, 9, 9,118, 83, 97,109,112,108,101,115, 85, 82, 46, +122, 44, 32,118, 83, 97,109,112,108,101,115, 85, 82, 46,121, 44, 32,118, 83, 97,109,112,108,101,115, 76, 82, 46,122, 44, 32,118, + 83, 97,109,112,108,101,115, 76, 82, 46,121, 41, 59, 10, 42, 47, 9, 10, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 76,111, + 99, 77,111,100, 32, 61, 32,105, 84,101,120, 76,111, 99, 32, 43, 32,105,118,101, 99, 50, 40, 45, 49, 44, 32, 45, 49, 41, 59, 10, + 10, 9, 9,109, 97,116, 52, 32, 72, 59, 10, 9, 9, 10, 9, 9,102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, + 32, 60, 32, 52, 59, 32,105, 43, 43, 41,123, 10, 9, 9, 9,102,111,114, 40,105,110,116, 32,106, 32, 61, 32, 48, 59, 32,106, 32, + 60, 32, 52, 59, 32,106, 43, 43, 41,123, 10, 9, 9, 9, 9,105,118,101, 99, 50, 32,105, 84,101,120, 84,109,112, 32, 61, 32,105, + 84,101,120, 76,111, 99, 77,111,100, 32, 43, 32,105,118,101, 99, 50, 40,105, 44,106, 41, 59, 10, 9, 9, 9, 9, 10, 9, 9, 9, + 9, 47, 47, 32,119,114, 97,112, 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32,109, 97,110, +117, 97,108,108,121, 32,102,111,114, 32,116,101,120,101,108, 70,101,116, 99,104, 32,116,111, 32,119,111,114,107, 32,111,110, 32, +117,118,115, 32,111,105,116,115,105,100,101, 32,116,104,101, 32, 48, 44, 49, 32,114, 97,110,103,101, 46, 10, 9, 9, 9, 9, 47, + 47, 32,116,104,105,115, 32,105,115, 32,103,117, 97,114, 97,110,116,101,101,100, 32,116,111, 32,119,111,114,107, 32,115,105,110, + 99,101, 32,119,101, 32,116, 97,107,101, 32,116,104,101, 32,102,114, 97, 99,116,105,111,110, 97,108, 32,112, 97,114,116, 32,111, +102, 32,116,104,101, 32,117,118, 32, 97, 98,111,118,101, 46, 10, 9, 9, 9, 9,105, 84,101,120, 84,109,112, 46,120, 32, 61, 32, + 40,105, 84,101,120, 84,109,112, 46,120, 32, 60, 32, 48, 41, 63, 32,105, 84,101,120, 84,109,112, 46,120, 32, 43, 32,118, 68,105, +109, 46,120, 32, 58, 32, 40, 40,105, 84,101,120, 84,109,112, 46,120, 32, 62, 61, 32,118, 68,105,109, 46,120, 41, 63, 32,105, 84, +101,120, 84,109,112, 46,120, 32, 45, 32,118, 68,105,109, 46,120, 32, 58, 32,105, 84,101,120, 84,109,112, 46,120, 41, 59, 10, 9, + 9, 9, 9,105, 84,101,120, 84,109,112, 46,121, 32, 61, 32, 40,105, 84,101,120, 84,109,112, 46,121, 32, 60, 32, 48, 41, 63, 32, +105, 84,101,120, 84,109,112, 46,121, 32, 43, 32,118, 68,105,109, 46,121, 32, 58, 32, 40, 40,105, 84,101,120, 84,109,112, 46,121, + 32, 62, 61, 32,118, 68,105,109, 46,121, 41, 63, 32,105, 84,101,120, 84,109,112, 46,121, 32, 45, 32,118, 68,105,109, 46,121, 32, + 58, 32,105, 84,101,120, 84,109,112, 46,121, 41, 59, 10, 10, 9, 9, 9, 9,114,103, 98,116,111, 98,119, 40,116,101,120,101,108, + 70,101,116, 99,104, 40,105,109, 97, 44, 32,105, 84,101,120, 84,109,112, 44, 32, 48, 41, 44, 32, 72, 91,105, 93, 91,106, 93, 41, + 59, 10, 9, 9, 9,125, 10, 9, 9,125, 10, 9, 9, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,116, 46,120, 44, 32,121, + 32, 61, 32,116, 46,121, 59, 10, 9, 9,102,108,111, 97,116, 32,120, 50, 32, 61, 32,120, 32, 42, 32,120, 44, 32,120, 51, 32, 61, + 32,120, 50, 32, 42, 32,120, 44, 32,121, 50, 32, 61, 32,121, 32, 42, 32,121, 44, 32,121, 51, 32, 61, 32,121, 50, 32, 42, 32,121, + 59, 10, 10, 9, 9,118,101, 99, 52, 32, 88, 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,120, 51, 43,120, 41, 43,120, + 50, 44, 9, 9, 49, 46, 53, 42,120, 51, 45, 50, 46, 53, 42,120, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,120, 51, 43, 50, 42,120, + 50, 43, 48, 46, 53, 42,120, 44, 9, 9, 48, 46, 53, 42, 40,120, 51, 45,120, 50, 41, 41, 59, 10, 9, 9,118,101, 99, 52, 32, 89, + 32, 61, 32,118,101, 99, 52, 40, 45, 48, 46, 53, 42, 40,121, 51, 43,121, 41, 43,121, 50, 44, 9, 9, 49, 46, 53, 42,121, 51, 45, + 50, 46, 53, 42,121, 50, 43, 49, 44, 9, 45, 49, 46, 53, 42,121, 51, 43, 50, 42,121, 50, 43, 48, 46, 53, 42,121, 44, 9, 9, 48, + 46, 53, 42, 40,121, 51, 45,121, 50, 41, 41, 59, 10, 9, 9,118,101, 99, 52, 32,100, 88, 32, 61, 32,118,101, 99, 52, 40, 45, 49, + 46, 53, 42,120, 50, 43, 50, 42,120, 45, 48, 46, 53, 44, 9, 9, 52, 46, 53, 42,120, 50, 45, 53, 42,120, 44, 9, 9, 9, 45, 52, + 46, 53, 42,120, 50, 43, 52, 42,120, 43, 48, 46, 53, 44, 9, 9, 49, 46, 53, 42,120, 50, 45,120, 41, 59, 10, 9, 9,118,101, 99, + 52, 32,100, 89, 32, 61, 32,118,101, 99, 52, 40, 45, 49, 46, 53, 42,121, 50, 43, 50, 42,121, 45, 48, 46, 53, 44, 9, 9, 52, 46, + 53, 42,121, 50, 45, 53, 42,121, 44, 9, 9, 9, 45, 52, 46, 53, 42,121, 50, 43, 52, 42,121, 43, 48, 46, 53, 44, 9, 9, 49, 46, + 53, 42,121, 50, 45,121, 41, 59, 10, 9, 10, 9, 9, 47, 47, 32, 99,111,109,112,108,101,116,101, 32,100,101,114,105,118, 97,116, +105,118,101, 32,105,110, 32,110,111,114,109, 97,108,105,122,101,100, 32, 99,111,111,114,100,105,110, 97,116,101,115, 32, 40,109, +117,108, 32, 98,121, 32,118, 68,105,109, 41, 10, 9, 9,118,101, 99, 50, 32,100, 72,100, 83, 84, 32, 61, 32,118, 68,105,109, 32, + 42, 32,118,101, 99, 50, 40,100,111,116, 40, 89, 44, 32, 72, 32, 42, 32,100, 88, 41, 44, 32,100,111,116, 40,100, 89, 44, 32, 72, + 32, 42, 32, 88, 41, 41, 59, 10, 10, 9, 9, 47, 47, 32,116,114, 97,110,115,102,111,114,109, 32,100,101,114,105,118, 97,116,105, +118,101, 32,116,111, 32,115, 99,114,101,101,110, 45,115,112, 97, 99,101, 10, 9, 9,118,101, 99, 50, 32,100, 72,100,120,121, 95, + 98,105, 99,117, 98,105, 99, 32, 61, 32,118,101, 99, 50, 40, 32,100, 72,100, 83, 84, 46,120, 32, 42, 32, 84,101,120, 68,120, 46, +120, 32, 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, 84,101,120, 68,120, 46,121, 44, 10, 9, 9, 9, 9, 9, 9, 9, 9, 32, + 32, 32,100, 72,100, 83, 84, 46,120, 32, 42, 32, 84,101,120, 68,121, 46,120, 32, 43, 32,100, 72,100, 83, 84, 46,121, 32, 42, 32, + 84,101,120, 68,121, 46,121, 32, 41, 59, 10, 10, 9, 9, 47, 47, 32, 98,108,101,110,100, 32, 98,101,116,119,101,101,110, 32,116, +104,101, 32,116,119,111, 10, 9, 9,100, 72,100,120,121, 32, 61, 32,100, 72,100,120,121, 42, 40, 49, 45,102, 66,108,101,110,100, + 41, 32, 43, 32,100, 72,100,120,121, 95, 98,105, 99,117, 98,105, 99, 42,102, 66,108,101,110,100, 59, 10, 9,125, 10, 10, 9,100, + 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32,100, 72,100,120,121, 46,120, 59, 10, 9,100, 66,116, 32, 61, 32,104, 83, + 99, 97,108,101, 32, 42, 32,100, 72,100,120,121, 46,121, 59, 10,125, 10, 10, 35,101,110,100,105,102, 10, 10,118,111,105,100, 32, +109,116,101,120, 95, 98,117,109,112, 95,116, 97,112, 53, 40, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,115, 97,109,112, +108,101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, 32, 32, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, + 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100, +121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 10, 9,118,101, 99, 50, 32, 83, 84, 99, 32, 61, 32,116,101,120, 99,111, 46, +120,121, 59, 10, 9,118,101, 99, 50, 32, 83, 84,108, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 45, 32, 48, 46, 53, 32, 42, + 32, 84,101,120, 68,120, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,114, 32, 61, 32,116,101,120, 99,111, 46,120,121, 32, 43, 32, + 48, 46, 53, 32, 42, 32, 84,101,120, 68,120, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,100, 32, 61, 32,116,101,120, 99,111, 46, +120,121, 32, 45, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 10, 9,118,101, 99, 50, 32, 83, 84,117, 32, 61, 32,116, +101,120, 99,111, 46,120,121, 32, 43, 32, 48, 46, 53, 32, 42, 32, 84,101,120, 68,121, 32, 59, 10, 9, 10, 9,102,108,111, 97,116, + 32, 72, 99, 44, 72,108, 44, 72,114, 44, 72,100, 44, 72,117, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117, +114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84, 99, 41, 44, 32, 72, 99, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32, +116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,108, 41, 44, 32, 72,108, 32, 41, 59, 10, 9,114,103, 98,116, +111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,114, 41, 44, 32, 72,114, 32, 41, 59, 10, + 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84,100, 41, 44, 32, 72, +100, 32, 41, 59, 10, 9,114,103, 98,116,111, 98,119, 40, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 83, 84, +117, 41, 44, 32, 72,117, 32, 41, 59, 10, 9, 10, 9,100, 66,115, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,114, 32, + 45, 32, 72,108, 41, 59, 10, 9,100, 66,116, 32, 61, 32,104, 83, 99, 97,108,101, 32, 42, 32, 40, 72,117, 32, 45, 32, 72,100, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95,100,101,114,105,118, 40, 32,118,101, 99, 51, 32, +116,101,120, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95, +120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,102,108,111, 97,116, 32,104, 83, 99, 97,108,101, 44, 32, 10, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66, +115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100, 66,116, 32, 41, 32, 10,123, 10, 9,102,108,111, 97,116, 32,115, 32, 61, + 32, 49, 46, 48, 59, 9, 9, 47, 47, 32,110,101,103, 97,116,101, 32,116,104,105,115, 32,105,102, 32,102,108,105,112,112,101,100, + 32,116,101,120,116,117,114,101, 32, 99,111,111,114,100,105,110, 97,116,101, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,120, 32, + 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, 32, 84,101,120, 68,121, 32, 61, 32, +100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9, 10, 9, 47, 47, 32,116,104,105,115, 32,118, 97,114,105, 97, +110,116, 32,117,115,105,110,103, 32, 97, 32,100,101,114,105,118, 97,116,105,118,101, 32,109, 97,112, 32,105,115, 32,100,101,115, + 99,114,105, 98,101,100, 32,104,101,114,101, 10, 9, 47, 47, 32,104,116,116,112, 58, 47, 47,109,109,105,107,107,101,108,115,101, +110, 51,100, 46, 98,108,111,103,115,112,111,116, 46, 99,111,109, 47, 50, 48, 49, 49, 47, 48, 55, 47,100,101,114,105,118, 97,116, +105,118,101, 45,109, 97,112,115, 46,104,116,109,108, 10, 9,118,101, 99, 50, 32,100,105,109, 32, 61, 32,118,101, 99, 50, 40,105, +109, 97, 95,120, 44, 32,105,109, 97, 95,121, 41, 59, 10, 9,118,101, 99, 50, 32,100, 66,100,117,118, 32, 61, 32,104, 83, 99, 97, +108,101, 42,100,105,109, 42, 40, 50, 46, 48, 42,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,116,101,120, 99,111, + 46,120,121, 41, 46,120,121, 45, 49, 46, 48, 41, 59, 10, 9, 10, 9,100, 66,115, 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84, +101,120, 68,120, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84,101,120, 68,120, 46,121, 59, 10, 9,100, 66,116, + 32, 61, 32,100, 66,100,117,118, 46,120, 42, 84,101,120, 68,121, 46,120, 32, 43, 32,115, 42,100, 66,100,117,118, 46,121, 42, 84, +101,120, 68,121, 46,121, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 40, + 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32,102,108,111, 97,116, 32,100, 66, +116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32,118, 82, 50, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, + 99, 95,105,110, 44, 10, 9, 9, 9, 9, 9, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 41, 32, 10,123, 10, 9,118, +101, 99, 51, 32,118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40,102, 68,101,116, 41, 32, 42, 32, 40, 32,100, + 66,115, 32, 42, 32,118, 82, 49, 32, 43, 32,100, 66,116, 32, 42, 32,118, 82, 50, 32, 41, 59, 10, 9, 10, 9,118, 78, 97, 99, 99, + 95,111,117,116, 32, 61, 32,118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83,117,114,102, 71,114, 97,100, 59, 10, 9,112,101, +114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,118, 78, 97, 99, 99, 95, +111,117,116, 32, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98,117,109,112, 95, 97,112,112,108,121, 95,116, +101,120,115,112, 97, 99,101, 40, 32,102,108,111, 97,116, 32,102, 68,101,116, 44, 32,102,108,111, 97,116, 32,100, 66,115, 44, 32, +102,108,111, 97,116, 32,100, 66,116, 44, 32,118,101, 99, 51, 32,118, 82, 49, 44, 32,118,101, 99, 51, 32,118, 82, 50, 44, 10, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,115, 97, +109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,118,101, 99, 51, 32,116,101,120, 99,111, 44, 32,102,108,111, 97,116, 32,105, +109, 97, 95,120, 44, 32,102,108,111, 97,116, 32,105,109, 97, 95,121, 44, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,105,110, + 44, 10, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32,111,117,116, 32,118,101, 99, 51, 32,118, 78, 97, 99, 99, 95,111,117,116, 44, 32, +111,117,116, 32,118,101, 99, 51, 32,112,101,114,116,117,114, 98,101,100, 95,110,111,114,109, 32, 41, 32, 10,123, 10, 9,118,101, + 99, 50, 32, 84,101,120, 68,120, 32, 61, 32,100, 70,100,120, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 9,118,101, 99, 50, + 32, 84,101,120, 68,121, 32, 61, 32,100, 70,100,121, 40,116,101,120, 99,111, 46,120,121, 41, 59, 10, 10, 9,118,101, 99, 51, 32, +118, 83,117,114,102, 71,114, 97,100, 32, 61, 32,115,105,103,110, 40,102, 68,101,116, 41, 32, 42, 32, 40, 32, 10, 9, 32, 32, 32, + 32, 32, 32, 32, 32, 32, 32, 32, 32,100, 66,115, 32, 47, 32,108,101,110,103,116,104, 40, 32,118,101, 99, 50, 40,105,109, 97, 95, +120, 42, 84,101,120, 68,120, 46,120, 44, 32,105,109, 97, 95,121, 42, 84,101,120, 68,120, 46,121, 41, 32, 41, 32, 42, 32,118, 82, + 49, 32, 43, 32, 10, 9, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,100, 66,116, 32, 47, 32,108,101,110,103,116,104, 40, 32, +118,101, 99, 50, 40,105,109, 97, 95,120, 42, 84,101,120, 68,121, 46,120, 44, 32,105,109, 97, 95,121, 42, 84,101,120, 68,121, 46, +121, 41, 32, 41, 32, 42, 32,118, 82, 50, 32, 41, 59, 10, 9, 9, 9, 9, 10, 9,118, 78, 97, 99, 99, 95,111,117,116, 32, 61, 32, +118, 78, 97, 99, 99, 95,105,110, 32, 45, 32,118, 83,117,114,102, 71,114, 97,100, 59, 10, 9,112,101,114,116,117,114, 98,101,100, + 95,110,111,114,109, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 32,118, 78, 97, 99, 99, 95,111,117,116, 32, 41, 59, 10, +125, 10, 10,118,111,105,100, 32,109,116,101,120, 95,110,101,103, 97,116,101, 95,116,101,120,110,111,114,109, 97,108, 40,118,101, + 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, + 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,118,101, 99, 51, 40, 45,110,111,114,109, 97,108, 46,120, 44, 32, 45,110, +111,114,109, 97,108, 46,121, 44, 32,110,111,114,109, 97,108, 46,122, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, + 95,110,115,112, 97, 99,101, 95,116, 97,110,103,101,110,116, 40,118,101, 99, 52, 32,116, 97,110,103,101,110,116, 44, 32,118,101, + 99, 51, 32,110,111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,116,101,120,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118, +101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9,118,101, 99, 51, 32, 66, 32, 61, 32,116, 97,110,103,101, +110,116, 46,119, 32, 42, 32, 99,114,111,115,115, 40,110,111,114,109, 97,108, 44, 32,116, 97,110,103,101,110,116, 46,120,121,122, + 41, 59, 10, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,116,101,120,110,111,114,109, 97,108, 46,120, 42,116, 97,110, 103,101,110,116, 46,120,121,122, 32, 43, 32,116,101,120,110,111,114,109, 97,108, 46,121, 42, 66, 32, 43, 32,116,101,120,110,111, -114,109, 97,108, 46,122, 42,110,111,114,109, 97,108, 59, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114, -109, 97,108,105,122,101, 40,111,117,116,110,111,114,109, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,109,116, -101,120, 95, 98,108,101,110,100, 95,110,111,114,109, 97,108, 40,102,108,111, 97,116, 32,110,111,114,102, 97, 99, 44, 32,118,101, - 99, 51, 32,110,111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,110,101,119,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118, -101, 99, 51, 32,111,117,116,110,111,114,109, 97,108, 41, 13, 10,123, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, - 40, 49, 46, 48, 32, 45, 32,110,111,114,102, 97, 99, 41, 42,110,111,114,109, 97,108, 32, 43, 32,110,111,114,102, 97, 99, 42,110, -101,119,110,111,114,109, 97,108, 59, 13, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122, -101, 40,111,117,116,110,111,114,109, 97,108, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 32, 77, 65, 84, - 69, 82, 73, 65, 76, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105, -115,105, 98,105,108,105,116,121, 95,115,117,110, 95,104,101,109,105, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32, -111,117,116, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, - 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,108,118, 32, 61, 32,108, 97,109,112,118,101, - 99, 59, 13, 10, 9,100,105,115,116, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, 46, 48, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,111,116,104, -101,114, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,108, 97,109,112, 99,111, 44, 32,111,117,116, 32,118,101, 99, - 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, -118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,108,118, 32, 61, 32, 99,111, 32, 45, 32,108, 97,109,112, 99,111, 59, 13, - 10, 9,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40,108,118, 41, 59, 13, 10, 9,108,118, 32, 61, 32,110,111,114,109, - 97,108,105,122,101, 40,108,118, 41, 59, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,108,105,110,101, 97,114, 40,102,108, -111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108, -111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112, -100,105,115,116, 47, 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111, +114,109, 97,108, 46,122, 42,110,111,114,109, 97,108, 59, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, + 97,108,105,122,101, 40,111,117,116,110,111,114,109, 97,108, 41, 59, 10,125, 10, 10,118,111,105,100, 32,109,116,101,120, 95, 98, +108,101,110,100, 95,110,111,114,109, 97,108, 40,102,108,111, 97,116, 32,110,111,114,102, 97, 99, 44, 32,118,101, 99, 51, 32,110, +111,114,109, 97,108, 44, 32,118,101, 99, 51, 32,110,101,119,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32, +111,117,116,110,111,114,109, 97,108, 41, 10,123, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32, 40, 49, 46, 48, 32, 45, + 32,110,111,114,102, 97, 99, 41, 42,110,111,114,109, 97,108, 32, 43, 32,110,111,114,102, 97, 99, 42,110,101,119,110,111,114,109, + 97,108, 59, 10, 9,111,117,116,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,111,117,116,110,111, +114,109, 97,108, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 32, 77, 65, 84, 69, 82, 73, 65, 76, 32, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 47, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,117,110, + 95,104,101,109,105, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,118, 44, + 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, + 97, 99, 41, 10,123, 10, 9,108,118, 32, 61, 32,108, 97,109,112,118,101, 99, 59, 10, 9,100,105,115,116, 32, 61, 32, 49, 46, 48, + 59, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118, +105,115,105, 98,105,108,105,116,121, 95,111,116,104,101,114, 40,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,108, 97, +109,112, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,100,105,115, +116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,108,118, 32, 61, 32, 99,111, + 32, 45, 32,108, 97,109,112, 99,111, 59, 10, 9,100,105,115,116, 32, 61, 32,108,101,110,103,116,104, 40,108,118, 41, 59, 10, 9, +108,118, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108,118, 41, 59, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32, 49, + 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,108,105,110,101, + 97,114, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, + 97,109,112,100,105,115,116, 47, 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 41, 59, 10,125, 10, 10,118,111, 105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,105,110,118,115,113,117, 97,114,101, 40,102,108,111, 97,116, 32, 108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, -118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, - 47, 40,108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 42,100,105,115,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95,115,108,105,100,101,114,115, 40,102,108,111, 97,116, 32,108, - 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,108,100, 49, 44, 32,102,108,111, 97,116, 32,108,100, 50, 44, 32,102, -108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, - 13, 10, 9,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116,107,119, 32, 61, 32,108, 97,109,112,100,105,115,116, 42,108, - 97,109,112,100,105,115,116, 59, 13, 10, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, 47, - 40,108, 97,109,112,100,105,115,116, 32, 43, 32,108,100, 49, 42,100,105,115,116, 41, 59, 13, 10, 9,118,105,115,105,102, 97, 99, - 32, 42, 61, 32,108, 97,109,112,100,105,115,116,107,119, 47, 40,108, 97,109,112,100,105,115,116,107,119, 32, 43, 32,108,100, 50, - 42,100,105,115,116, 42,100,105,115,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108, -108,111,102,102, 95, 99,117,114,118,101, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,115, 97,109,112,108, -101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,116,101,120, -116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, 44, 32,118,101, 99, 50, 40,100,105,115,116, 47,108, 97,109,112,100, -105,115,116, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105, -115,105, 98,105,108,105,116,121, 95,115,112,104,101,114,101, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32, -102,108,111, 97,116, 32,100,105,115,116, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,116, 61, 32,108, - 97,109,112,100,105,115,116, 32, 45, 32,100,105,115,116, 59, 13, 10, 13, 10, 9,111,117,116,118,105,115,105,102, 97, 99, 61, 32, -118,105,115,105,102, 97, 99, 42,109, 97,120, 40,116, 44, 32, 48, 46, 48, 41, 47,108, 97,109,112,100,105,115,116, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,112,111,116, 95,115,113, -117, 97,114,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,109, 97,116, 52, 32,108, 97,109,112,105,109, 97,116, - 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112,114, 41, 13, 10,123, 13, 10, 9, -105,102, 40,100,111,116, 40,108,118, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 62, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, -118,101, 99, 51, 32,108,118,114,111,116, 32, 61, 32, 40,108, 97,109,112,105,109, 97,116, 42,118,101, 99, 52, 40,108,118, 44, 32, - 48, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,109, 97,120, 40, 97, 98,115, 40, -108,118,114,111,116, 46,120, 47,108,118,114,111,116, 46,122, 41, 44, 32, 97, 98,115, 40,108,118,114,111,116, 46,121, 47,108,118, -114,111,116, 46,122, 41, 41, 59, 13, 10, 13, 10, 9, 9,105,110,112,114, 32, 61, 32, 49, 46, 48, 47,115,113,114,116, 40, 49, 46, - 48, 32, 43, 32,120, 42,120, 41, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,105,110,112,114, 32, 61, 32, 48, - 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115, -112,111,116, 95, 99,105,114, 99,108,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,108,118, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112,114, 41, 13, 10,123, 13, 10, 9,105,110,112,114, 32, 61, 32,100,111, -116, 40,108,118, 44, 32,108, 97,109,112,118,101, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,108, 97,109,112, 95, -118,105,115,105, 98,105,108,105,116,121, 95,115,112,111,116, 40,102,108,111, 97,116, 32,115,112,111,116,115,105, 44, 32,102,108, -111, 97,116, 32,115,112,111,116, 98,108, 44, 32,102,108,111, 97,116, 32,105,110,112,114, 44, 32,102,108,111, 97,116, 32,118,105, -115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, - 10, 9,102,108,111, 97,116, 32,116, 32, 61, 32,115,112,111,116,115,105, 59, 13, 10, 13, 10, 9,105,102, 40,105,110,112,114, 32, - 60, 61, 32,116, 41, 32,123, 13, 10, 9, 9,111,117,116,118,105,115,105,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, - 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,116, 32, 61, 32,105,110,112,114, 32, 45, 32,116, 59, 13, 10, 13, 10, 9, 9, - 47, 42, 32,115,111,102,116, 32, 97,114,101, 97, 32, 42, 47, 13, 10, 9, 9,105,102, 40,115,112,111,116, 98,108, 32, 33, 61, 32, - 48, 46, 48, 41, 13, 10, 9, 9, 9,105,110,112,114, 32, 42, 61, 32,115,109,111,111,116,104,115,116,101,112, 40, 48, 46, 48, 44, - 32, 49, 46, 48, 44, 32,116, 47,115,112,111,116, 98,108, 41, 59, 13, 10, 13, 10, 9, 9,111,117,116,118,105,115,105,102, 97, 99, - 32, 61, 32,118,105,115,105,102, 97, 99, 42,105,110,112,114, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32, -108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32,118,105,115,105, -102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 13, 10,123, 13, 10, 9, -111,117,116,118,105,115,105,102, 97, 99, 32, 61, 32, 40,118,105,115,105,102, 97, 99, 32, 60, 32, 48, 46, 48, 48, 49, 41, 63, 32, - 48, 46, 48, 58, 32,118,105,115,105,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,118, -105,101,119, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 41, 13, 10,123, 13, 10, - 9, 47, 42, 32,104, 97,110,100,108,101, 32,112,101,114,115,112,101, 99,116,105,118,101, 47,111,114,116,104,111,103,114, 97,112, -104,105, 99, 32, 42, 47, 13, 10, 9,118,105,101,119, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99,116,105,111,110, 77, 97, -116,114,105,120, 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, - 41, 58, 32,118,101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 45, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118, -111,105,100, 32,115,104, 97,100,101, 95,116, 97,110,103,101,110,116, 95,118, 40,118,101, 99, 51, 32,108,118, 44, 32,118,101, 99, - 51, 32,116, 97,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,110, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 99, - 32, 61, 32, 99,114,111,115,115, 40,108,118, 44, 32,116, 97,110,103, 41, 59, 13, 10, 9,118,101, 99, 51, 32,118,110,111,114, 32, - 61, 32, 99,114,111,115,115, 40, 99, 44, 32,116, 97,110,103, 41, 59, 13, 10, 13, 10, 9,118,110, 32, 61, 32, 45,110,111,114,109, - 97,108,105,122,101, 40,118,110,111,114, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,110, -112, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110, -112, 41, 13, 10,123, 13, 10, 9,105,110,112, 32, 61, 32,100,111,116, 40,118,110, 44, 32,108,118, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,115, 95,110,111, 95,100,105,102,102,117,115,101, 40,111,117,116, 32,102,108, -111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105, -100, 32,115,104, 97,100,101, 95,105,115, 95,104,101,109,105, 40,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102, -108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,115, 32, 61, 32, 48, 46, 53, 42,105,110,112, 32, 43, 32, 48, 46, 53, - 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, 40,109, - 97,116, 52, 32, 97,114,101, 97, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,118,110, 41, 13, 10,123, 13, 10, - 9,118,101, 99, 51, 32,118,101, 99, 91, 52, 93, 44, 32, 99, 91, 52, 93, 59, 13, 10, 9,102,108,111, 97,116, 32,114, 97,100, 91, - 52, 93, 44, 32,102, 97, 99, 59, 13, 10, 9, 13, 10, 9,118,101, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, - 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 48, 93, 46,120,121,122, 41, 59, 13, 10, 9,118,101, 99, 91, 49, 93, 32, 61, 32,110, -111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 49, 93, 46,120,121,122, 41, 59, 13, 10, 9,118,101, - 99, 91, 50, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 50, 93, 46,120,121, -122, 41, 59, 13, 10, 9,118,101, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114, -101, 97, 91, 51, 93, 46,120,121,122, 41, 59, 13, 10, 13, 10, 9, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, - 40, 99,114,111,115,115, 40,118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, 59, 13, 10, 9, 99, 91, 49, 93, 32, - 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, 99, 91, 50, 93, - 41, 41, 59, 13, 10, 9, 99, 91, 50, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, - 91, 50, 93, 44, 32,118,101, 99, 91, 51, 93, 41, 41, 59, 13, 10, 9, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122, -101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, 41, 41, 59, 13, 10, 13, 10, 9,114, 97, -100, 91, 48, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, - 59, 13, 10, 9,114, 97,100, 91, 49, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, - 99, 91, 50, 93, 41, 41, 59, 13, 10, 9,114, 97,100, 91, 50, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, - 50, 93, 44, 32,118,101, 99, 91, 51, 93, 41, 41, 59, 13, 10, 9,114, 97,100, 91, 51, 93, 32, 61, 32, 97, 99,111,115, 40,100,111, -116, 40,118,101, 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, 41, 41, 59, 13, 10, 13, 10, 9,102, 97, 99, 61, 32, 32,114, 97, -100, 91, 48, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 48, 93, 41, 59, 13, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, - 49, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 49, 93, 41, 59, 13, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 50, 93, - 42,100,111,116, 40,118,110, 44, 32, 99, 91, 50, 93, 41, 59, 13, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 51, 93, 42,100, -111,116, 40,118,110, 44, 32, 99, 91, 51, 93, 41, 59, 13, 10, 13, 10, 9,114,101,116,117,114,110, 32,109, 97,120, 40,102, 97, 99, - 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,110,112, 95, 97,114,101, - 97, 40,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,118,101, 99, 51, 32,108, 97,109,112, 99,111, 44, 32,118,101, - 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,109, 97,116, 52, 32, 97,114,101, 97, 44, 32, -102,108,111, 97,116, 32, 97,114,101, 97,115,105,122,101, 44, 32,102,108,111, 97,116, 32,107, 44, 32,111,117,116, 32,102,108,111, - 97,116, 32,105,110,112, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32, 99,111, 32, 61, 32,112,111,115,105,116,105,111,110, 59, - 13, 10, 9,118,101, 99, 51, 32,118,101, 99, 32, 61, 32, 99,111, 32, 45, 32,108, 97,109,112, 99,111, 59, 13, 10, 13, 10, 9,105, -102, 40,100,111,116, 40,118,101, 99, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, -105,110,112, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, - 32,105,110,116,101,110,115, 32, 61, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, 40, 97,114,101, 97, 44, - 32, 99,111, 44, 32,118,110, 41, 59, 13, 10, 13, 10, 9, 9,105,110,112, 32, 61, 32,112,111,119, 40,105,110,116,101,110,115, 42, - 97,114,101, 97,115,105,122,101, 44, 32,107, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97, -100,101, 95,100,105,102,102,117,115,101, 95,111,114,101,110, 95,110, 97,121,101,114, 40,102,108,111, 97,116, 32,110,108, 44, 32, -118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,114,111, -117,103,104, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,104, 32, 61, - 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32, -109, 97,120, 40,100,111,116, 40,110, 44, 32,104, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,110,118, 32, - 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,114, -101, 97,108,110,108, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 13, 10, 13, 10, 9,105,102, 40,114,101, 97,108,110,108, - 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115, -101, 32,105,102, 40,110,108, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, -125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,118,104, 32, 61, 32,109, 97,120, 40,100,111,116, - 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32, 76,105,116, 95, 65, 32, 61, 32, 97, - 99,111,115, 40,114,101, 97,108,110,108, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32, 86,105,101,119, 95, 65, 32, 61, 32, 97, - 99,111,115, 40,110,118, 41, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32, 76,105,116, 95, 66, 32, 61, 32,110,111,114,109, 97, -108,105,122,101, 40,108, 32, 45, 32,114,101, 97,108,110,108, 42,110, 41, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 86,105,101,119, - 95, 66, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 45, 32,110,118, 42,110, 41, 59, 13, 10, 13, 10, 9, 9,102, -108,111, 97,116, 32,116, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 76,105,116, 95, 66, 44, 32, 86,105,101,119, 95, 66, 41, 44, - 32, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9,102,108,111, 97,116, 32, 97, 44, 32, 98, 59, 13, 10, 13, 10, 9, 9,105,102, 40, - 76,105,116, 95, 65, 32, 62, 32, 86,105,101,119, 95, 65, 41, 32,123, 13, 10, 9, 9, 9, 97, 32, 61, 32, 76,105,116, 95, 65, 59, - 13, 10, 9, 9, 9, 98, 32, 61, 32, 86,105,101,119, 95, 65, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, - 10, 9, 9, 9, 97, 32, 61, 32, 86,105,101,119, 95, 65, 59, 13, 10, 9, 9, 9, 98, 32, 61, 32, 76,105,116, 95, 65, 59, 13, 10, - 9, 9,125, 13, 10, 13, 10, 9, 9,102,108,111, 97,116, 32, 65, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 48, 46, 53, 42, 40, 40, -114,111,117,103,104, 42,114,111,117,103,104, 41, 47, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, - 51, 51, 41, 41, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32, 66, 32, 61, 32, 48, 46, 52, 53, 42, 40, 40,114,111,117,103,104, - 42,114,111,117,103,104, 41, 47, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, 48, 57, 41, 41, 59, - 13, 10, 13, 10, 9, 9, 98, 32, 42, 61, 32, 48, 46, 57, 53, 59, 13, 10, 9, 9,105,115, 32, 61, 32,110,108, 42, 40, 65, 32, 43, - 32, 40, 66, 32, 42, 32,116, 32, 42, 32,115,105,110, 40, 97, 41, 32, 42, 32,116, 97,110, 40, 98, 41, 41, 41, 59, 13, 10, 9,125, - 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115,101, 95,116,111,111,110, 40,118, -101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,115,105,122, -101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, - 10,123, 13, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 13, 10, 9,102, -108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, 41, 59, 13, 10, 13, 10, 9,105,102, 40, 97,110, -103, 32, 60, 32,115,105,122,101, 41, 32,105,115, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, 97,110, -103, 32, 62, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111,116,104, 41, 32,124,124, 32,116,115,109,111,111,116,104, 32, - 61, 61, 32, 48, 46, 48, 41, 32,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,101,108,115,101, 32,105,115, 32, 61, 32, 49, 46, - 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115,105,122,101, 41, 47,116,115,109,111,111,116,104, 41, 59, 13, 10,125, 13, 10, - 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115,101, 95,109,105,110,110, 97,101,114,116, 40,102,108, -111, 97,116, 32,110,108, 44, 32,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,100, 97, -114,107,110,101,115,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,102, 40,110,108, - 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108, -115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, - 44, 32, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9,105,102, 40,100, 97,114,107,110,101,115,115, 32, 60, 61, 32, 49, 46, 48, 41, - 13, 10, 9, 9, 9,105,115, 32, 61, 32,110,108, 42,112,111,119, 40,109, 97,120, 40,110,118, 42,110,108, 44, 32, 48, 46, 49, 41, - 44, 32,100, 97,114,107,110,101,115,115, 32, 45, 32, 49, 46, 48, 41, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,105, -115, 32, 61, 32,110,108, 42,112,111,119, 40, 49, 46, 48, 48, 48, 49, 32, 45, 32,110,118, 44, 32,100, 97,114,107,110,101,115,115, - 32, 45, 32, 49, 46, 48, 41, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, - 95,102, 97, 99, 40,118,101, 99, 51, 32,118,105,101,119, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,102,108,111, 97,116, 32,103, -114, 97,100, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,116, 49, 44, 32,116, - 50, 59, 13, 10, 9,102,108,111, 97,116, 32,102,102, 97, 99, 59, 13, 10, 13, 10, 9,105,102, 40,102, 97, 99, 61, 61, 48, 46, 48, - 41, 32,123, 13, 10, 9, 9,102,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, - 10, 9, 9,116, 49, 61, 32,100,111,116, 40,118,105,101,119, 44, 32,118,110, 41, 59, 13, 10, 9, 9,105,102, 40,116, 49, 62, 48, - 46, 48, 41, 32, 32,116, 50, 61, 32, 49, 46, 48, 43,116, 49, 59, 13, 10, 9, 9,101,108,115,101, 32,116, 50, 61, 32, 49, 46, 48, - 45,116, 49, 59, 13, 10, 13, 10, 9, 9,116, 50, 61, 32,103,114, 97,100, 32, 43, 32, 40, 49, 46, 48, 45,103,114, 97,100, 41, 42, -112,111,119, 40,116, 50, 44, 32,102, 97, 99, 41, 59, 13, 10, 13, 10, 9, 9,105,102, 40,116, 50, 60, 48, 46, 48, 41, 32,102,102, - 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,105,102, 40,116, 50, 62, 49, 46, 48, 41, 32,102,102, 97, - 99, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,101,108,115,101, 32,102,102, 97, 99, 32, 61, 32,116, 50, 59, 13, 10, 9,125, 13, - 10, 13, 10, 9,114,101,116,117,114,110, 32,102,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,100,105,102,102,117,115,101, 95,102,114,101,115,110,101,108, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32, -108,118, 44, 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 95,105, 44, 32,102,108,111, 97, -116, 32,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 13, 10,123, 13, 10, 9,105,115, 32, 61, 32,102, -114,101,115,110,101,108, 95,102, 97, 99, 40,108,118, 44, 32,118,110, 44, 32,102, 97, 99, 95,105, 44, 32,102, 97, 99, 41, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 99,117, 98,105, 99, 40,102,108,111, 97,116, 32,105,115, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105,115, 41, 13, 10,123, 13, 10, 9,105,102, 40,105,115, 62, 48, 46, 48, - 32, 38, 38, 32,105,115, 60, 49, 46, 48, 41, 13, 10, 9, 9,111,117,116,105,115, 61, 32,115,109,111,111,116,104,115,116,101,112, - 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, 32,105,115, 41, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116,105,115, 61, - 32,105,115, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,118,105,115,105,102, 97, 99, 40,102,108, -111, 97,116, 32,105, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,102,108,111, 97,116, 32,114,101,102,108, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105, 41, 13, 10,123, 13, 10, 9, 47, 42,105,102, 40,105, 32, 62, 32, - 48, 46, 48, 41, 42, 47, 13, 10, 9, 9,111,117,116,105, 32, 61, 32,109, 97,120, 40,105, 42,118,105,115,105,102, 97, 99, 42,114, -101,102,108, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 47, 42,101,108,115,101, 13, 10, 9, 9,111,117,116,105, 32, 61, 32,105, 59, - 42, 47, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116, 97,110,103,101,110,116, 95,118, 95,115,112, -101, 99, 40,118,101, 99, 51, 32,116, 97,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,110, 41, 13, 10,123, 13, 10, 9, -118,110, 32, 61, 32,116, 97,110,103, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95, -116,111, 95,100,105,102,102,117,115,101, 40,102,108,111, 97,116, 32,105, 44, 32,118,101, 99, 51, 32,108, 97,109,112, 99,111,108, - 44, 32,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, - 10, 9,105,102, 40,105, 32, 62, 32, 48, 46, 48, 41, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,105, 42,108, 97,109,112, - 99,111,108, 42, 99,111,108, 59, 13, 10, 9,101,108,115,101, 13, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 51, - 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,104,101,109,105, 95,115,112,101, 99, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,118,101, - 99, 51, 32,118,105,101,119, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, - 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 13, 10,123, 13, - 10, 9,108,118, 32, 43, 61, 32,118,105,101,119, 59, 13, 10, 9,108,118, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, -118, 41, 59, 13, 10, 13, 10, 9,116, 32, 61, 32,100,111,116, 40,118,110, 44, 32,108,118, 41, 59, 13, 10, 9,116, 32, 61, 32, 48, - 46, 53, 42,116, 32, 43, 32, 48, 46, 53, 59, 13, 10, 13, 10, 9,116, 32, 61, 32,118,105,115,105,102, 97, 99, 42,115,112,101, 99, - 42,112,111,119, 40,116, 44, 32,104, 97,114,100, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, -112,104,111,110,103, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32, -118, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, - 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, - 59, 13, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,109, 97,120, 40,100,111,116, 40,104, 44, 32,110, 41, 44, 32, - 48, 46, 48, 41, 59, 13, 10, 13, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,112,111,119, 40,114,115,108,116, 44, 32,104, 97, -114,100, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 99,111,111,107,116,111,114,114, 95,115, +118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, 47, 40, +108, 97,109,112,100,105,115,116, 32, 43, 32,100,105,115,116, 42,100,105,115,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,108, + 97,109,112, 95,102, 97,108,108,111,102,102, 95,115,108,105,100,101,114,115, 40,102,108,111, 97,116, 32,108, 97,109,112,100,105, +115,116, 44, 32,102,108,111, 97,116, 32,108,100, 49, 44, 32,102,108,111, 97,116, 32,108,100, 50, 44, 32,102,108,111, 97,116, 32, +100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,102,108,111, 97, +116, 32,108, 97,109,112,100,105,115,116,107,119, 32, 61, 32,108, 97,109,112,100,105,115,116, 42,108, 97,109,112,100,105,115,116, + 59, 10, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,108, 97,109,112,100,105,115,116, 47, 40,108, 97,109,112,100,105,115,116, + 32, 43, 32,108,100, 49, 42,100,105,115,116, 41, 59, 10, 9,118,105,115,105,102, 97, 99, 32, 42, 61, 32,108, 97,109,112,100,105, +115,116,107,119, 47, 40,108, 97,109,112,100,105,115,116,107,119, 32, 43, 32,108,100, 50, 42,100,105,115,116, 42,100,105,115,116, + 41, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,102, 97,108,108,111,102,102, 95, 99,117,114,118,101, 40,102,108, +111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,117,114,118,101,109, 97,112, + 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 41, + 10,123, 10, 9,118,105,115,105,102, 97, 99, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40, 99,117,114,118,101,109, 97,112, + 44, 32,118,101, 99, 50, 40,100,105,115,116, 47,108, 97,109,112,100,105,115,116, 44, 32, 48, 46, 48, 41, 41, 46,120, 59, 10,125, + 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,112,104,101,114,101, 40,102,108, +111, 97,116, 32,108, 97,109,112,100,105,115,116, 44, 32,102,108,111, 97,116, 32,100,105,115,116, 44, 32,102,108,111, 97,116, 32, +118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 10,123, + 10, 9,102,108,111, 97,116, 32,116, 61, 32,108, 97,109,112,100,105,115,116, 32, 45, 32,100,105,115,116, 59, 10, 10, 9,111,117, +116,118,105,115,105,102, 97, 99, 61, 32,118,105,115,105,102, 97, 99, 42,109, 97,120, 40,116, 44, 32, 48, 46, 48, 41, 47,108, 97, +109,112,100,105,115,116, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95, +115,112,111,116, 95,115,113,117, 97,114,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,109, 97,116, 52, 32,108, + 97,109,112,105,109, 97,116, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112,114, + 41, 10,123, 10, 9,105,102, 40,100,111,116, 40,108,118, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 62, 32, 48, 46, 48, 41, 32, +123, 10, 9, 9,118,101, 99, 51, 32,108,118,114,111,116, 32, 61, 32, 40,108, 97,109,112,105,109, 97,116, 42,118,101, 99, 52, 40, +108,118, 44, 32, 48, 46, 48, 41, 41, 46,120,121,122, 59, 10, 9, 9,102,108,111, 97,116, 32,120, 32, 61, 32,109, 97,120, 40, 97, + 98,115, 40,108,118,114,111,116, 46,120, 47,108,118,114,111,116, 46,122, 41, 44, 32, 97, 98,115, 40,108,118,114,111,116, 46,121, + 47,108,118,114,111,116, 46,122, 41, 41, 59, 10, 10, 9, 9,105,110,112,114, 32, 61, 32, 49, 46, 48, 47,115,113,114,116, 40, 49, + 46, 48, 32, 43, 32,120, 42,120, 41, 59, 10, 9,125, 10, 9,101,108,115,101, 10, 9, 9,105,110,112,114, 32, 61, 32, 48, 46, 48, + 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95,115,112,111,116, 95, 99, +105,114, 99,108,101, 40,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,105,110,112,114, 41, 10,123, 10, 9,105,110,112,114, 32, 61, 32,100,111,116, 40,108,118, 44, 32,108, + 97,109,112,118,101, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, + 95,115,112,111,116, 40,102,108,111, 97,116, 32,115,112,111,116,115,105, 44, 32,102,108,111, 97,116, 32,115,112,111,116, 98,108, + 44, 32,102,108,111, 97,116, 32,105,110,112,114, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 10,123, 10, 9,102,108,111, 97,116, 32,116, 32, 61, 32, +115,112,111,116,115,105, 59, 10, 10, 9,105,102, 40,105,110,112,114, 32, 60, 61, 32,116, 41, 32,123, 10, 9, 9,111,117,116,118, +105,115,105,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,116, 32, 61, 32,105, +110,112,114, 32, 45, 32,116, 59, 10, 10, 9, 9, 47, 42, 32,115,111,102,116, 32, 97,114,101, 97, 32, 42, 47, 10, 9, 9,105,102, + 40,115,112,111,116, 98,108, 32, 33, 61, 32, 48, 46, 48, 41, 10, 9, 9, 9,105,110,112,114, 32, 42, 61, 32,115,109,111,111,116, +104,115,116,101,112, 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, 32,116, 47,115,112,111,116, 98,108, 41, 59, 10, 10, 9, 9,111,117, +116,118,105,115,105,102, 97, 99, 32, 61, 32,118,105,115,105,102, 97, 99, 42,105,110,112,114, 59, 10, 9,125, 10,125, 10, 10,118, +111,105,100, 32,108, 97,109,112, 95,118,105,115,105, 98,105,108,105,116,121, 95, 99,108, 97,109,112, 40,102,108,111, 97,116, 32, +118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118,105,115,105,102, 97, 99, 41, 10,123, + 10, 9,111,117,116,118,105,115,105,102, 97, 99, 32, 61, 32, 40,118,105,115,105,102, 97, 99, 32, 60, 32, 48, 46, 48, 48, 49, 41, + 63, 32, 48, 46, 48, 58, 32,118,105,115,105,102, 97, 99, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,118,105, +101,119, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118,105,101,119, 41, 10,123, 10, 9, 47, 42, + 32,104, 97,110,100,108,101, 32,112,101,114,115,112,101, 99,116,105,118,101, 47,111,114,116,104,111,103,114, 97,112,104,105, 99, + 32, 42, 47, 10, 9,118,105,101,119, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99,116,105,111,110, 77, 97,116,114,105,120, + 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 41, 58, 32,118, +101, 99, 51, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 45, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97, +100,101, 95,116, 97,110,103,101,110,116, 95,118, 40,118,101, 99, 51, 32,108,118, 44, 32,118,101, 99, 51, 32,116, 97,110,103, 44, + 32,111,117,116, 32,118,101, 99, 51, 32,118,110, 41, 10,123, 10, 9,118,101, 99, 51, 32, 99, 32, 61, 32, 99,114,111,115,115, 40, +108,118, 44, 32,116, 97,110,103, 41, 59, 10, 9,118,101, 99, 51, 32,118,110,111,114, 32, 61, 32, 99,114,111,115,115, 40, 99, 44, + 32,116, 97,110,103, 41, 59, 10, 10, 9,118,110, 32, 61, 32, 45,110,111,114,109, 97,108,105,122,101, 40,118,110,111,114, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,110,112, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, + 32,108,118, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,110,112, 41, 10,123, 10, 9,105,110,112, 32, 61, 32,100,111,116, + 40,118,110, 44, 32,108,118, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,115, 95,110,111, 95,100,105, +102,102,117,115,101, 40,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,115, 32, 61, 32, 48, 46, 48, 59, + 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105,115, 95,104,101,109,105, 40,102,108,111, 97,116, 32,105,110,112, + 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,115, 32, 61, 32, 48, 46, 53, 42,105,110,112, 32, + 43, 32, 48, 46, 53, 59, 10,125, 10, 10,102,108,111, 97,116, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, + 40,109, 97,116, 52, 32, 97,114,101, 97, 44, 32,118,101, 99, 51, 32, 99,111, 44, 32,118,101, 99, 51, 32,118,110, 41, 10,123, 10, + 9,118,101, 99, 51, 32,118,101, 99, 91, 52, 93, 44, 32, 99, 91, 52, 93, 59, 10, 9,102,108,111, 97,116, 32,114, 97,100, 91, 52, + 93, 44, 32,102, 97, 99, 59, 10, 9, 10, 9,118,101, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, + 32, 45, 32, 97,114,101, 97, 91, 48, 93, 46,120,121,122, 41, 59, 10, 9,118,101, 99, 91, 49, 93, 32, 61, 32,110,111,114,109, 97, +108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 49, 93, 46,120,121,122, 41, 59, 10, 9,118,101, 99, 91, 50, 93, 32, + 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 50, 93, 46,120,121,122, 41, 59, 10, 9, +118,101, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,111, 32, 45, 32, 97,114,101, 97, 91, 51, 93, 46, +120,121,122, 41, 59, 10, 10, 9, 99, 91, 48, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118, +101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, 59, 10, 9, 99, 91, 49, 93, 32, 61, 32,110,111,114,109, 97,108,105, +122,101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, 99, 91, 50, 93, 41, 41, 59, 10, 9, 99, 91, 50, 93, + 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, 91, 50, 93, 44, 32,118,101, 99, 91, 51, + 93, 41, 41, 59, 10, 9, 99, 91, 51, 93, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 99,114,111,115,115, 40,118,101, 99, + 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, 41, 41, 59, 10, 10, 9,114, 97,100, 91, 48, 93, 32, 61, 32, 97, 99,111,115, 40,100, +111,116, 40,118,101, 99, 91, 48, 93, 44, 32,118,101, 99, 91, 49, 93, 41, 41, 59, 10, 9,114, 97,100, 91, 49, 93, 32, 61, 32, 97, + 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 49, 93, 44, 32,118,101, 99, 91, 50, 93, 41, 41, 59, 10, 9,114, 97,100, 91, 50, + 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 50, 93, 44, 32,118,101, 99, 91, 51, 93, 41, 41, 59, 10, 9, +114, 97,100, 91, 51, 93, 32, 61, 32, 97, 99,111,115, 40,100,111,116, 40,118,101, 99, 91, 51, 93, 44, 32,118,101, 99, 91, 48, 93, + 41, 41, 59, 10, 10, 9,102, 97, 99, 61, 32, 32,114, 97,100, 91, 48, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 48, 93, 41, + 59, 10, 9,102, 97, 99, 43, 61, 32,114, 97,100, 91, 49, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 49, 93, 41, 59, 10, 9, +102, 97, 99, 43, 61, 32,114, 97,100, 91, 50, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 50, 93, 41, 59, 10, 9,102, 97, 99, + 43, 61, 32,114, 97,100, 91, 51, 93, 42,100,111,116, 40,118,110, 44, 32, 99, 91, 51, 93, 41, 59, 10, 10, 9,114,101,116,117,114, +110, 32,109, 97,120, 40,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,105, +110,112, 95, 97,114,101, 97, 40,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,118,101, 99, 51, 32,108, 97,109,112, + 99,111, 44, 32,118,101, 99, 51, 32,108, 97,109,112,118,101, 99, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,109, 97,116, 52, 32, + 97,114,101, 97, 44, 32,102,108,111, 97,116, 32, 97,114,101, 97,115,105,122,101, 44, 32,102,108,111, 97,116, 32,107, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,105,110,112, 41, 10,123, 10, 9,118,101, 99, 51, 32, 99,111, 32, 61, 32,112,111,115,105,116, +105,111,110, 59, 10, 9,118,101, 99, 51, 32,118,101, 99, 32, 61, 32, 99,111, 32, 45, 32,108, 97,109,112, 99,111, 59, 10, 10, 9, +105,102, 40,100,111,116, 40,118,101, 99, 44, 32,108, 97,109,112,118,101, 99, 41, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9, +105,110,112, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,105,110, +116,101,110,115, 32, 61, 32, 97,114,101, 97, 95,108, 97,109,112, 95,101,110,101,114,103,121, 40, 97,114,101, 97, 44, 32, 99,111, + 44, 32,118,110, 41, 59, 10, 10, 9, 9,105,110,112, 32, 61, 32,112,111,119, 40,105,110,116,101,110,115, 42, 97,114,101, 97,115, +105,122,101, 44, 32,107, 41, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115, +101, 95,111,114,101,110, 95,110, 97,121,101,114, 40,102,108,111, 97,116, 32,110,108, 44, 32,118,101, 99, 51, 32,110, 44, 32,118, +101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104, 44, 32,111,117,116, 32, +102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, +118, 32, 43, 32,108, 41, 59, 10, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,104, + 41, 44, 32, 48, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32, +118, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9,102,108,111, 97,116, 32,114,101, 97,108,110,108, 32, 61, 32,100,111,116, 40,110, 44, + 32,108, 41, 59, 10, 10, 9,105,102, 40,114,101, 97,108,110,108, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,105,115, 32, 61, + 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,105,102, 40,110,108, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9, +105,115, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,118,104, 32, + 61, 32,109, 97,120, 40,100,111,116, 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9, 9,102,108,111, 97,116, 32, 76, +105,116, 95, 65, 32, 61, 32, 97, 99,111,115, 40,114,101, 97,108,110,108, 41, 59, 10, 9, 9,102,108,111, 97,116, 32, 86,105,101, +119, 95, 65, 32, 61, 32, 97, 99,111,115, 40,110,118, 41, 59, 10, 10, 9, 9,118,101, 99, 51, 32, 76,105,116, 95, 66, 32, 61, 32, +110,111,114,109, 97,108,105,122,101, 40,108, 32, 45, 32,114,101, 97,108,110,108, 42,110, 41, 59, 10, 9, 9,118,101, 99, 51, 32, + 86,105,101,119, 95, 66, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 45, 32,110,118, 42,110, 41, 59, 10, 10, 9, + 9,102,108,111, 97,116, 32,116, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 76,105,116, 95, 66, 44, 32, 86,105,101,119, 95, 66, + 41, 44, 32, 48, 46, 48, 41, 59, 10, 10, 9, 9,102,108,111, 97,116, 32, 97, 44, 32, 98, 59, 10, 10, 9, 9,105,102, 40, 76,105, +116, 95, 65, 32, 62, 32, 86,105,101,119, 95, 65, 41, 32,123, 10, 9, 9, 9, 97, 32, 61, 32, 76,105,116, 95, 65, 59, 10, 9, 9, + 9, 98, 32, 61, 32, 86,105,101,119, 95, 65, 59, 10, 9, 9,125, 10, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9, 97, 32, 61, + 32, 86,105,101,119, 95, 65, 59, 10, 9, 9, 9, 98, 32, 61, 32, 76,105,116, 95, 65, 59, 10, 9, 9,125, 10, 10, 9, 9,102,108, +111, 97,116, 32, 65, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 48, 46, 53, 42, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, + 41, 47, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, 51, 51, 41, 41, 41, 59, 10, 9, 9,102,108, +111, 97,116, 32, 66, 32, 61, 32, 48, 46, 52, 53, 42, 40, 40,114,111,117,103,104, 42,114,111,117,103,104, 41, 47, 40, 40,114,111, +117,103,104, 42,114,111,117,103,104, 41, 32, 43, 32, 48, 46, 48, 57, 41, 41, 59, 10, 10, 9, 9, 98, 32, 42, 61, 32, 48, 46, 57, + 53, 59, 10, 9, 9,105,115, 32, 61, 32,110,108, 42, 40, 65, 32, 43, 32, 40, 66, 32, 42, 32,116, 32, 42, 32,115,105,110, 40, 97, + 41, 32, 42, 32,116, 97,110, 40, 98, 41, 41, 41, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100, +105,102,102,117,115,101, 95,116,111,111,110, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, + 32,118, 44, 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111,116, + 40,110, 44, 32,108, 41, 59, 10, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, 41, 59, + 10, 10, 9,105,102, 40, 97,110,103, 32, 60, 32,115,105,122,101, 41, 32,105,115, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115, +101, 32,105,102, 40, 97,110,103, 32, 62, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111,116,104, 41, 32,124,124, 32,116, +115,109,111,111,116,104, 32, 61, 61, 32, 48, 46, 48, 41, 32,105,115, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,105, +115, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115,105,122,101, 41, 47,116,115,109,111,111,116,104, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100,105,102,102,117,115,101, 95,109,105,110,110, 97,101,114,116, + 40,102,108,111, 97,116, 32,110,108, 44, 32,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, + 32,100, 97,114,107,110,101,115,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,102, 40,110, +108, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,105,115, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, + 32,123, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, + 46, 48, 41, 59, 10, 10, 9, 9,105,102, 40,100, 97,114,107,110,101,115,115, 32, 60, 61, 32, 49, 46, 48, 41, 10, 9, 9, 9,105, +115, 32, 61, 32,110,108, 42,112,111,119, 40,109, 97,120, 40,110,118, 42,110,108, 44, 32, 48, 46, 49, 41, 44, 32,100, 97,114,107, +110,101,115,115, 32, 45, 32, 49, 46, 48, 41, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,105,115, 32, 61, 32,110,108, 42,112, +111,119, 40, 49, 46, 48, 48, 48, 49, 32, 45, 32,110,118, 44, 32,100, 97,114,107,110,101,115,115, 32, 45, 32, 49, 46, 48, 41, 59, + 10, 9,125, 10,125, 10, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, 95,102, 97, 99, 40,118,101, 99, 51, 32,118,105, +101,119, 44, 32,118,101, 99, 51, 32,118,110, 44, 32,102,108,111, 97,116, 32,103,114, 97,100, 44, 32,102,108,111, 97,116, 32,102, + 97, 99, 41, 10,123, 10, 9,102,108,111, 97,116, 32,116, 49, 44, 32,116, 50, 59, 10, 9,102,108,111, 97,116, 32,102,102, 97, 99, + 59, 10, 10, 9,105,102, 40,102, 97, 99, 61, 61, 48, 46, 48, 41, 32,123, 10, 9, 9,102,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, + 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,116, 49, 61, 32,100,111,116, 40,118,105,101,119, 44, 32,118,110, 41, 59, + 10, 9, 9,105,102, 40,116, 49, 62, 48, 46, 48, 41, 32, 32,116, 50, 61, 32, 49, 46, 48, 43,116, 49, 59, 10, 9, 9,101,108,115, +101, 32,116, 50, 61, 32, 49, 46, 48, 45,116, 49, 59, 10, 10, 9, 9,116, 50, 61, 32,103,114, 97,100, 32, 43, 32, 40, 49, 46, 48, + 45,103,114, 97,100, 41, 42,112,111,119, 40,116, 50, 44, 32,102, 97, 99, 41, 59, 10, 10, 9, 9,105,102, 40,116, 50, 60, 48, 46, + 48, 41, 32,102,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9,101,108,115,101, 32,105,102, 40,116, 50, 62, 49, 46, 48, 41, + 32,102,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,101,108,115,101, 32,102,102, 97, 99, 32, 61, 32,116, 50, 59, 10, 9, +125, 10, 10, 9,114,101,116,117,114,110, 32,102,102, 97, 99, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,100, +105,102,102,117,115,101, 95,102,114,101,115,110,101,108, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, + 32,118,101, 99, 51, 32,118,105,101,119, 44, 32,102,108,111, 97,116, 32,102, 97, 99, 95,105, 44, 32,102,108,111, 97,116, 32,102, + 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,105,115, 41, 10,123, 10, 9,105,115, 32, 61, 32,102,114,101,115,110,101, +108, 95,102, 97, 99, 40,108,118, 44, 32,118,110, 44, 32,102, 97, 99, 95,105, 44, 32,102, 97, 99, 41, 59, 10,125, 10, 10,118,111, +105,100, 32,115,104, 97,100,101, 95, 99,117, 98,105, 99, 40,102,108,111, 97,116, 32,105,115, 44, 32,111,117,116, 32,102,108,111, + 97,116, 32,111,117,116,105,115, 41, 10,123, 10, 9,105,102, 40,105,115, 62, 48, 46, 48, 32, 38, 38, 32,105,115, 60, 49, 46, 48, + 41, 10, 9, 9,111,117,116,105,115, 61, 32,115,109,111,111,116,104,115,116,101,112, 40, 48, 46, 48, 44, 32, 49, 46, 48, 44, 32, +105,115, 41, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116,105,115, 61, 32,105,115, 59, 10,125, 10, 10,118,111,105,100, 32, +115,104, 97,100,101, 95,118,105,115,105,102, 97, 99, 40,102,108,111, 97,116, 32,105, 44, 32,102,108,111, 97,116, 32,118,105,115, +105,102, 97, 99, 44, 32,102,108,111, 97,116, 32,114,101,102,108, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,105, + 41, 10,123, 10, 9, 47, 42,105,102, 40,105, 32, 62, 32, 48, 46, 48, 41, 42, 47, 10, 9, 9,111,117,116,105, 32, 61, 32,109, 97, +120, 40,105, 42,118,105,115,105,102, 97, 99, 42,114,101,102,108, 44, 32, 48, 46, 48, 41, 59, 10, 9, 47, 42,101,108,115,101, 10, + 9, 9,111,117,116,105, 32, 61, 32,105, 59, 42, 47, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116, 97,110,103, +101,110,116, 95,118, 95,115,112,101, 99, 40,118,101, 99, 51, 32,116, 97,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,118, +110, 41, 10,123, 10, 9,118,110, 32, 61, 32,116, 97,110,103, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97, +100,100, 95,116,111, 95,100,105,102,102,117,115,101, 40,102,108,111, 97,116, 32,105, 44, 32,118,101, 99, 51, 32,108, 97,109,112, + 99,111,108, 44, 32,118,101, 99, 51, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 10, +123, 10, 9,105,102, 40,105, 32, 62, 32, 48, 46, 48, 41, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,105, 42,108, 97,109,112, + 99,111,108, 42, 99,111,108, 59, 10, 9,101,108,115,101, 10, 9, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 51, 40, 48, + 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,104,101,109, +105, 95,115,112,101, 99, 40,118,101, 99, 51, 32,118,110, 44, 32,118,101, 99, 51, 32,108,118, 44, 32,118,101, 99, 51, 32,118,105, +101,119, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,102,108,111, 97, +116, 32,118,105,115,105,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 10,123, 10, 9,108,118, 32, 43, 61, + 32,118,105,101,119, 59, 10, 9,108,118, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108,118, 41, 59, 10, 10, 9,116, 32, + 61, 32,100,111,116, 40,118,110, 44, 32,108,118, 41, 59, 10, 9,116, 32, 61, 32, 48, 46, 53, 42,116, 32, 43, 32, 48, 46, 53, 59, + 10, 10, 9,116, 32, 61, 32,118,105,115,105,102, 97, 99, 42,115,112,101, 99, 42,112,111,119, 40,116, 44, 32,104, 97,114,100, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,112,104,111,110,103, 95,115,112,101, 99, 40,118,101, 99, 51, 32, +110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111, +114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,109, 97, +120, 40,100,111,116, 40,104, 44, 32,110, 41, 44, 32, 48, 46, 48, 41, 59, 10, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,112, +111,119, 40,114,115,108,116, 44, 32,104, 97,114,100, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 99,111, +111,107,116,111,114,114, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, + 32,118, 44, 32,102,108,111, 97,116, 32,104, 97,114,100, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, + 99, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, + 10, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,100,111,116, 40,110, 44, 32,104, 41, 59, 10, 10, 9,105,102, 40,110,104, 32, + 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108, +115,101, 32,123, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, + 32, 48, 46, 48, 41, 59, 10, 9, 9,102,108,111, 97,116, 32,105, 32, 61, 32,112,111,119, 40,110,104, 44, 32,104, 97,114,100, 41, + 59, 10, 10, 9, 9,105, 32, 61, 32,105, 47, 40, 48, 46, 49, 43,110,118, 41, 59, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, + 32,105, 59, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 98,108,105,110,110, 95,115,112,101, 99, 40, +118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32,114,101, +102,114, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 95,112,111,119,101,114, 44, 32,111,117,116, 32,102,108,111, 97, +116, 32,115,112,101, 99,102, 97, 99, 41, 10,123, 10, 9,105,102, 40,114,101,102,114, 97, 99, 32, 60, 32, 49, 46, 48, 41, 32,123, + 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,105,102, 40,115,112, +101, 99, 95,112,111,119,101,114, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, + 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,105,102, 40,115,112,101, 99, 95,112,111,119,101,114, 60, 49, + 48, 48, 46, 48, 41, 10, 9, 9, 9,115,112,101, 99, 95,112,111,119,101,114, 61, 32,115,113,114,116, 40, 49, 46, 48, 47,115,112, +101, 99, 95,112,111,119,101,114, 41, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,115,112,101, 99, 95,112,111,119,101,114, 61, + 32, 49, 48, 46, 48, 47,115,112,101, 99, 95,112,111,119,101,114, 59, 10, 10, 9, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111, +114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, 10, 9, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,100,111,116, + 40,110, 44, 32,104, 41, 59, 10, 9, 9,105,102, 40,110,104, 32, 60, 32, 48, 46, 48, 41, 32,123, 10, 9, 9, 9,115,112,101, 99, +102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9,125, 10, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9,102,108,111, 97,116, + 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 49, 41, 59, 10, 9, 9, 9,102, +108,111, 97,116, 32,110,108, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 10, 9, 9, 9,105,102, 40,110,108, 32, 60, 61, + 32, 48, 46, 48, 49, 41, 32,123, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 9,125, + 10, 9, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,118,104, 32, 61, 32,109, 97,120, 40,100,111, +116, 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 49, 41, 59, 10, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 97, 32, 61, 32, 49, + 46, 48, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 98, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42,110,118, 41, 47,118,104, + 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 99, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42,110,108, 41, 47,118,104, 59, 10, + 10, 9, 9, 9, 9,102,108,111, 97,116, 32,103, 32, 61, 32, 48, 46, 48, 59, 10, 10, 9, 9, 9, 9,105,102, 40, 97, 32, 60, 32, + 98, 32, 38, 38, 32, 97, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 97, 59, 10, 9, 9, 9, 9,101,108,115,101, 32,105,102, 40, 98, + 32, 60, 32, 97, 32, 38, 38, 32, 98, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 98, 59, 10, 9, 9, 9, 9,101,108,115,101, 32,105, +102, 40, 99, 32, 60, 32, 97, 32, 38, 38, 32, 99, 32, 60, 32, 98, 41, 32,103, 32, 61, 32, 99, 59, 10, 10, 9, 9, 9, 9,102,108, +111, 97,116, 32,112, 32, 61, 32,115,113,114,116, 40, 40, 40,114,101,102,114, 97, 99, 32, 42, 32,114,101,102,114, 97, 99, 41, 43, + 40,118,104, 42,118,104, 41, 45, 49, 46, 48, 41, 41, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,102, 32, 61, 32, 40, 40, 40, +112, 45,118,104, 41, 42, 40,112, 45,118,104, 41, 41, 47, 40, 40,112, 43,118,104, 41, 42, 40,112, 43,118,104, 41, 41, 41, 42, 40, + 49, 46, 48, 43, 40, 40, 40, 40,118,104, 42, 40,112, 43,118,104, 41, 41, 45, 49, 46, 48, 41, 42, 40, 40,118,104, 42, 40,112, 43, +118,104, 41, 41, 45, 49, 46, 48, 41, 41, 47, 40, 40, 40,118,104, 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 42, 40, 40, +118,104, 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 41, 41, 41, 59, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 97,110, +103, 32, 61, 32, 97, 99,111,115, 40,110,104, 41, 59, 10, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,109, 97,120, + 40,102, 42,103, 42,101,120,112, 95, 98,108,101,110,100,101,114, 40, 40, 45, 40, 97,110,103, 42, 97,110,103, 41, 47, 40, 50, 46, + 48, 42,115,112,101, 99, 95,112,111,119,101,114, 42,115,112,101, 99, 95,112,111,119,101,114, 41, 41, 41, 44, 32, 48, 46, 48, 41, + 59, 10, 9, 9, 9,125, 10, 9, 9,125, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,119, 97,114,100, +105,115,111, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, + 32,102,108,111, 97,116, 32,114,109,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 10,123, + 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 10, 9,102,108, +111, 97,116, 32,110,104, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,104, 41, 44, 32, 48, 46, 48, 48, 49, 41, 59, 10, + 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 48, 49, + 41, 59, 10, 9,102,108,111, 97,116, 32,110,108, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,108, 41, 44, 32, 48, 46, + 48, 48, 49, 41, 59, 10, 9,102,108,111, 97,116, 32, 97,110,103,108,101, 32, 61, 32,116, 97,110, 40, 97, 99,111,115, 40,110,104, + 41, 41, 59, 10, 9,102,108,111, 97,116, 32, 97,108,112,104, 97, 32, 61, 32,109, 97,120, 40,114,109,115, 44, 32, 48, 46, 48, 48, + 49, 41, 59, 10, 10, 9,115,112,101, 99,102, 97, 99, 61, 32,110,108, 32, 42, 32, 40, 49, 46, 48, 47, 40, 52, 46, 48, 42, 77, 95, + 80, 73, 42, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 42, 40,101,120,112, 95, 98,108,101,110,100,101,114, 40, 45, 40, + 97,110,103,108,101, 42, 97,110,103,108,101, 41, 47, 40, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 47, 40,115,113,114, +116, 40,110,118, 42,110,108, 41, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116,111,111,110, 95,115, 112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97, -116, 32,104, 97,114,100, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9, -118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, 32, 43, 32,108, 41, 59, 13, 10, 9,102,108,111, - 97,116, 32,110,104, 32, 61, 32,100,111,116, 40,110, 44, 32,104, 41, 59, 13, 10, 13, 10, 9,105,102, 40,110,104, 32, 60, 32, 48, - 46, 48, 41, 32,123, 13, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108, -115,101, 32,123, 13, 10, 9, 9,102,108,111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, - 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,105, 32, 61, 32,112,111,119, 40,110,104, 44, 32,104, 97,114, -100, 41, 59, 13, 10, 13, 10, 9, 9,105, 32, 61, 32,105, 47, 40, 48, 46, 49, 43,110,118, 41, 59, 13, 10, 9, 9,115,112,101, 99, -102, 97, 99, 32, 61, 32,105, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 98,108, -105,110,110, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, - 32,102,108,111, 97,116, 32,114,101,102,114, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112,101, 99, 95,112,111,119,101,114, 44, - 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,105,102, 40,114,101,102,114, - 97, 99, 32, 60, 32, 49, 46, 48, 41, 32,123, 13, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, -125, 13, 10, 9,101,108,115,101, 32,105,102, 40,115,112,101, 99, 95,112,111,119,101,114, 32, 61, 61, 32, 48, 46, 48, 41, 32,123, - 13, 10, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, - 10, 9, 9,105,102, 40,115,112,101, 99, 95,112,111,119,101,114, 60, 49, 48, 48, 46, 48, 41, 13, 10, 9, 9, 9,115,112,101, 99, - 95,112,111,119,101,114, 61, 32,115,113,114,116, 40, 49, 46, 48, 47,115,112,101, 99, 95,112,111,119,101,114, 41, 59, 13, 10, 9, - 9,101,108,115,101, 13, 10, 9, 9, 9,115,112,101, 99, 95,112,111,119,101,114, 61, 32, 49, 48, 46, 48, 47,115,112,101, 99, 95, -112,111,119,101,114, 59, 13, 10, 13, 10, 9, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,118, - 32, 43, 32,108, 41, 59, 13, 10, 9, 9,102,108,111, 97,116, 32,110,104, 32, 61, 32,100,111,116, 40,110, 44, 32,104, 41, 59, 13, - 10, 9, 9,105,102, 40,110,104, 32, 60, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, - 48, 46, 48, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,110,118, - 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 49, 41, 59, 13, 10, 9, 9, 9,102,108,111, - 97,116, 32,110,108, 32, 61, 32,100,111,116, 40,110, 44, 32,108, 41, 59, 13, 10, 9, 9, 9,105,102, 40,110,108, 32, 60, 61, 32, - 48, 46, 48, 49, 41, 32,123, 13, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9, 9, -125, 13, 10, 9, 9, 9,101,108,115,101, 32,123, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,118,104, 32, 61, 32,109, 97,120, - 40,100,111,116, 40,118, 44, 32,104, 41, 44, 32, 48, 46, 48, 49, 41, 59, 13, 10, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, - 97, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 98, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42, -110,118, 41, 47,118,104, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 99, 32, 61, 32, 40, 50, 46, 48, 42,110,104, 42,110, -108, 41, 47,118,104, 59, 13, 10, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,103, 32, 61, 32, 48, 46, 48, 59, 13, 10, 13, 10, - 9, 9, 9, 9,105,102, 40, 97, 32, 60, 32, 98, 32, 38, 38, 32, 97, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 97, 59, 13, 10, 9, - 9, 9, 9,101,108,115,101, 32,105,102, 40, 98, 32, 60, 32, 97, 32, 38, 38, 32, 98, 32, 60, 32, 99, 41, 32,103, 32, 61, 32, 98, - 59, 13, 10, 9, 9, 9, 9,101,108,115,101, 32,105,102, 40, 99, 32, 60, 32, 97, 32, 38, 38, 32, 99, 32, 60, 32, 98, 41, 32,103, - 32, 61, 32, 99, 59, 13, 10, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32,112, 32, 61, 32,115,113,114,116, 40, 40, 40,114,101, -102,114, 97, 99, 32, 42, 32,114,101,102,114, 97, 99, 41, 43, 40,118,104, 42,118,104, 41, 45, 49, 46, 48, 41, 41, 59, 13, 10, 9, - 9, 9, 9,102,108,111, 97,116, 32,102, 32, 61, 32, 40, 40, 40,112, 45,118,104, 41, 42, 40,112, 45,118,104, 41, 41, 47, 40, 40, -112, 43,118,104, 41, 42, 40,112, 43,118,104, 41, 41, 41, 42, 40, 49, 46, 48, 43, 40, 40, 40, 40,118,104, 42, 40,112, 43,118,104, - 41, 41, 45, 49, 46, 48, 41, 42, 40, 40,118,104, 42, 40,112, 43,118,104, 41, 41, 45, 49, 46, 48, 41, 41, 47, 40, 40, 40,118,104, - 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 42, 40, 40,118,104, 42, 40,112, 45,118,104, 41, 41, 43, 49, 46, 48, 41, 41, - 41, 41, 59, 13, 10, 9, 9, 9, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,110,104, 41, 59, 13, 10, - 13, 10, 9, 9, 9, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,109, 97,120, 40,102, 42,103, 42,101,120,112, 95, 98,108,101,110, -100,101,114, 40, 40, 45, 40, 97,110,103, 42, 97,110,103, 41, 47, 40, 50, 46, 48, 42,115,112,101, 99, 95,112,111,119,101,114, 42, -115,112,101, 99, 95,112,111,119,101,114, 41, 41, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9, 9,125, 13, 10, 9, 9,125, 13, - 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,119, 97,114,100,105,115,111, 95,115,112,101, - 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, 32,102,108,111, 97,116, 32, -114,109,115, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,101, 99, - 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 13, 10, 9,102,108,111, 97,116, 32, -110,104, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,104, 41, 44, 32, 48, 46, 48, 48, 49, 41, 59, 13, 10, 9,102,108, -111, 97,116, 32,110,118, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,118, 41, 44, 32, 48, 46, 48, 48, 49, 41, 59, 13, - 10, 9,102,108,111, 97,116, 32,110,108, 32, 61, 32,109, 97,120, 40,100,111,116, 40,110, 44, 32,108, 41, 44, 32, 48, 46, 48, 48, - 49, 41, 59, 13, 10, 9,102,108,111, 97,116, 32, 97,110,103,108,101, 32, 61, 32,116, 97,110, 40, 97, 99,111,115, 40,110,104, 41, - 41, 59, 13, 10, 9,102,108,111, 97,116, 32, 97,108,112,104, 97, 32, 61, 32,109, 97,120, 40,114,109,115, 44, 32, 48, 46, 48, 48, - 49, 41, 59, 13, 10, 13, 10, 9,115,112,101, 99,102, 97, 99, 61, 32,110,108, 32, 42, 32, 40, 49, 46, 48, 47, 40, 52, 46, 48, 42, - 77, 95, 80, 73, 42, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 42, 40,101,120,112, 95, 98,108,101,110,100,101,114, 40, - 45, 40, 97,110,103,108,101, 42, 97,110,103,108,101, 41, 47, 40, 97,108,112,104, 97, 42, 97,108,112,104, 97, 41, 41, 47, 40,115, -113,114,116, 40,110,118, 42,110,108, 41, 41, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,116, -111,111,110, 95,115,112,101, 99, 40,118,101, 99, 51, 32,110, 44, 32,118,101, 99, 51, 32,108, 44, 32,118,101, 99, 51, 32,118, 44, - 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114, -109, 97,108,105,122,101, 40,108, 32, 43, 32,118, 41, 59, 13, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111, -116, 40,104, 44, 32,110, 41, 59, 13, 10, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, - 41, 59, 13, 10, 13, 10, 9,105,102, 40, 97,110,103, 32, 60, 32,115,105,122,101, 41, 32,114,115,108,116, 32, 61, 32, 49, 46, 48, - 59, 13, 10, 9,101,108,115,101, 32,105,102, 40, 97,110,103, 32, 62, 61, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111, -116,104, 41, 32,124,124, 32,116,115,109,111,111,116,104, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,115,108,116, 32, 61, 32, 48, 46, - 48, 59, 13, 10, 9,101,108,115,101, 32,114,115,108,116, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115, -105,122,101, 41, 47,116,115,109,111,111,116,104, 41, 59, 13, 10, 13, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,114,115,108, -116, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,115,112,101, 99, 95, 97,114,101, 97, 95,105,110, -112, 40,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 44, 32,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32,111,117,116,115,112,101, 99,102, 97, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,115,112,101, 99,102, 97, - 99, 32, 61, 32,115,112,101, 99,102, 97, 99, 42,105,110,112, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,115,112,101, 99, 95,116, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112, -101, 99, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, - 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 13, 10,123, 13, 10, 9,116, 32, 61, 32,115,104, 97,100,102, 97, 99, 42, -115,112,101, 99, 42,118,105,115,105,102, 97, 99, 42,115,112,101, 99,102, 97, 99, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,104, 97,100,101, 95, 97,100,100, 95,115,112,101, 99, 40,102,108,111, 97,116, 32,116, 44, 32,118,101, 99, 51, 32,108, 97, -109,112, 99,111,108, 44, 32,118,101, 99, 51, 32,115,112,101, 99, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117, -116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,116, 42,108, 97,109,112, 99,111,108, 42,115,112, -101, 99, 99,111,108, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 40,118,101, 99, 52, - 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111, -108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, - 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, - 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32, 99,111,108, 49, 42, 99,111, -108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95, 99,108, 97,109,112,101,100, - 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32,109, 97,120, - 40, 99,111,108, 50, 44, 32,118,101, 99, 52, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100, 95, 99,108, 97,109,112,101,100, 40, -118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32, -111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99, -111,108, 32, 43, 32,109, 97,120, 40, 99,111,108, 49, 42, 99,111,108, 50, 44, 32,118,101, 99, 52, 40, 48, 46, 48, 44, 32, 48, 46, - 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95, -109, 97,100,100,102, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32,102, 44, 32,118,101, 99, 52, 32, 99,111, -108, 49, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, - 32, 61, 32, 99,111,108, 32, 43, 32,102, 42, 99,111,108, 49, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100, -101, 95,109,117,108, 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32, -118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 42, - 99,111,108, 50, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,117,108, 95,118, 97,108,117,101, - 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, -117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 42,102, 97, 99, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111, 98, 99,111,108,111,114, 40,118,101, 99, 52, 32, 99,111,108, 44, - 32,118,101, 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, - 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 42,111, 98, 99,111,108, 46,114, -103, 98, 44, 32, 99,111,108, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,114, 97,109,112, 95,114,103, 98,116, -111, 98,119, 40,118,101, 99, 51, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, - 41, 13, 10,123, 13, 10, 9,111,117,116,118, 97,108, 32, 61, 32, 99,111,108,111,114, 46,114, 42, 48, 46, 51, 32, 43, 32, 99,111, -108,111,114, 46,103, 42, 48, 46, 53, 56, 32, 43, 32, 99,111,108,111,114, 46, 98, 42, 48, 46, 49, 50, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110,108,121, 95,115,104, 97,100,111,119, 40,102,108,111, 97,116, 32,105, 44, - 32,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,102,108,111, 97,116, 32,101,110,101,114,103,121, 44, 32,111,117, -116, 32,102,108,111, 97,116, 32,111,117,116,115,104, 97,100,102, 97, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,115,104, 97,100, -102, 97, 99, 32, 61, 32,105, 42,101,110,101,114,103,121, 42, 40, 49, 46, 48, 32, 45, 32,115,104, 97,100,102, 97, 99, 41, 59, 13, - 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110,108,121, 95,115,104, 97,100,111,119, 95,100,105,102, -102,117,115,101, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,118,101, 99, 51, 32,114,103, 98, 44, 32,118,101, - 99, 52, 32,100,105,102,102, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116,100,105,102,102, 41, 13, 10,123, 13, 10, 9, -111,117,116,100,105,102,102, 32, 61, 32,100,105,102,102, 32, 45, 32,118,101, 99, 52, 40,114,103, 98, 42,115,104, 97,100,102, 97, - 99, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110,108,121, 95,115, -104, 97,100,111,119, 95,115,112,101, 99,117,108, 97,114, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, 32,118,101, - 99, 51, 32,115,112,101, 99,114,103, 98, 44, 32,118,101, 99, 52, 32,115,112,101, 99, 44, 32,111,117,116, 32,118,101, 99, 52, 32, -111,117,116,115,112,101, 99, 41, 13, 10,123, 13, 10, 9,111,117,116,115,112,101, 99, 32, 61, 32,115,112,101, 99, 32, 45, 32,118, -101, 99, 52, 40,115,112,101, 99,114,103, 98, 42,115,104, 97,100,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111,119, 98,117,102, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, - 97,109,112,108,101,114, 50, 68, 83,104, 97,100,111,119, 32,115,104, 97,100,111,119,109, 97,112, 44, 32,109, 97,116, 52, 32,115, -104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,111,119, 98,105, 97,115, 44, 32, -102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, - 10, 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, - 46, 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, - 97,100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9, - 9, 47, 47,102,108,111, 97,116, 32, 98,105, 97,115, 32, 61, 32, 40, 49, 46, 53, 32, 45, 32,105,110,112, 42,105,110,112, 41, 42, -115,104, 97,100,111,119, 98,105, 97,115, 59, 13, 10, 9, 9, 99,111, 46,122, 32, 45, 61, 32,115,104, 97,100,111,119, 98,105, 97, -115, 42, 99,111, 46,119, 59, 13, 10, 9, 9, 13, 10, 9, 9,105,102, 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, - 32, 99,111, 46,120, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, - 38, 32, 99,111, 46,121, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, - 13, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, 32,115,104, 97,100,111,119, 50, 68, 80,114,111,106, 40,115,104, 97,100,111, -119,109, 97,112, 44, 32, 99,111, 41, 46,120, 59, 13, 10, 9, 9,101,108,115,101, 13, 10, 9, 9, 9,114,101,115,117,108,116, 32, - 61, 32, 49, 46, 48, 59, 13, 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111, -119, 98,117,102, 95,118,115,109, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,115,104, 97, -100,111,119,109, 97,112, 44, 32,109, 97,116, 52, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97, -116, 32,115,104, 97,100,111,119, 98,105, 97,115, 44, 32,102,108,111, 97,116, 32, 98,108,101,101,100, 98,105, 97,115, 44, 32,102, -108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, - 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 13, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, 46, - 48, 59, 13, 10, 9,125, 13, 10, 9,101,108,115,101, 32,123, 13, 10, 9, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97, -100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9, 9,105,102, - 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, - 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99, -111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, 32,123, 13, 10, 9, 9, 9,118,101, 99, 50, 32,109,111,109,101,110, -116,115, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40,115,104, 97,100,111,119,109, 97,112, 44, 32, 99,111, - 41, 46,114,103, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32, 99,111, 46,122, 47, 99,111, 46,119, - 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9, 9, 9, 13, 10, 9, 9, 9,105,102, - 40,100,105,115,116, 32, 60, 61, 32,109,111,109,101,110,116,115, 46,120, 41, 13, 10, 9, 9, 9, 9,112, 32, 61, 32, 49, 46, 48, - 59, 13, 10, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109,111,109,101,110,116,115, - 46,121, 32, 45, 32, 40,109,111,109,101,110,116,115, 46,120, 42,109,111,109,101,110,116,115, 46,120, 41, 59, 13, 10, 9, 9, 9, -118, 97,114,105, 97,110, 99,101, 32, 61, 32,109, 97,120, 40,118, 97,114,105, 97,110, 99,101, 44, 32,115,104, 97,100,111,119, 98, -105, 97,115, 47, 49, 48, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,100, 32, 61, 32,109,111,109,101,110, -116,115, 46,120, 32, 45, 32,100,105,115,116, 59, 13, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 95,109, 97,120, 32, 61, 32,118, - 97,114,105, 97,110, 99,101, 32, 47, 32, 40,118, 97,114,105, 97,110, 99,101, 32, 43, 32,100, 42,100, 41, 59, 13, 10, 13, 10, 9, - 9, 9, 47, 47, 32, 78,111,119, 32,114,101,100,117, 99,101, 32,108,105,103,104,116, 45, 98,108,101,101,100,105,110,103, 32, 98, -121, 32,114,101,109,111,118,105,110,103, 32,116,104,101, 32, 91, 48, 44, 32,120, 93, 32,116, 97,105,108, 32, 97,110,100, 32,108, -105,110,101, 97,114,108,121, 32,114,101,115, 99, 97,108,105,110,103, 32, 40,120, 44, 32, 49, 93, 13, 10, 9, 9, 9,112, 95,109, - 97,120, 32, 61, 32, 99,108, 97,109,112, 40, 40,112, 95,109, 97,120, 45, 98,108,101,101,100, 98,105, 97,115, 41, 47, 40, 49, 46, - 48, 45, 98,108,101,101,100, 98,105, 97,115, 41, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9, 9, 9,114, -101,115,117,108,116, 32, 61, 32,109, 97,120, 40,112, 44, 32,112, 95,109, 97,120, 41, 59, 13, 10, 9, 9,125, 13, 10, 9, 9,101, -108,115,101, 32,123, 13, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9, 9,125, 9, 9, 9, 13, - 10, 9,125, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,108,105,103,104,116, 95,116,101,120,116,117, -114,101, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32, 99,111,111,107,105,101, 44, 32,109, - 97,116, 52, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117, -108,116, 41, 13, 10,123, 13, 10, 13, 10, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97,100,111,119,112,101,114,115,109, - 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 13, 10, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32, -116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40, 99,111,111,107,105,101, 44, 32, 99,111, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95,101,120,112,111,115,117,114,101, 95, 99,111,114,114,101, 99,116, 40,118,101, 99, - 51, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32,108,105,110,102, 97, 99, 44, 32,102,108,111, 97,116, 32,108,111,103,102, 97, - 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, - 61, 32,108,105,110,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32,101,120,112, 40, 99,111,108, 42,108,111,103,102, 97, 99, 41, 41, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,105,115,116, 95,102, 97, 99,116,111,114, 40,118, -101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,109,105,115,116,115,116, 97, 44, 32,102,108,111, 97,116, 32,109,105,115, -116,100,105,115,116, 44, 32,102,108,111, 97,116, 32,109,105,115,116,116,121,112,101, 44, 32,102,108,111, 97,116, 32,109,105,115, -105, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32, -102, 97, 99, 44, 32,122, 99,111,114, 59, 13, 10, 13, 10, 9,122, 99,111,114, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99, +116, 32,115,105,122,101, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111,117,116, 32,102,108,111, 97,116, + 32,115,112,101, 99,102, 97, 99, 41, 10,123, 10, 9,118,101, 99, 51, 32,104, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, +108, 32, 43, 32,118, 41, 59, 10, 9,102,108,111, 97,116, 32,114,115,108,116, 32, 61, 32,100,111,116, 40,104, 44, 32,110, 41, 59, + 10, 9,102,108,111, 97,116, 32, 97,110,103, 32, 61, 32, 97, 99,111,115, 40,114,115,108,116, 41, 59, 10, 10, 9,105,102, 40, 97, +110,103, 32, 60, 32,115,105,122,101, 41, 32,114,115,108,116, 32, 61, 32, 49, 46, 48, 59, 10, 9,101,108,115,101, 32,105,102, 40, + 97,110,103, 32, 62, 61, 32, 40,115,105,122,101, 32, 43, 32,116,115,109,111,111,116,104, 41, 32,124,124, 32,116,115,109,111,111, +116,104, 32, 61, 61, 32, 48, 46, 48, 41, 32,114,115,108,116, 32, 61, 32, 48, 46, 48, 59, 10, 9,101,108,115,101, 32,114,115,108, +116, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 40, 97,110,103, 32, 45, 32,115,105,122,101, 41, 47,116,115,109,111,111,116,104, 41, + 59, 10, 10, 9,115,112,101, 99,102, 97, 99, 32, 61, 32,114,115,108,116, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100, +101, 95,115,112,101, 99, 95, 97,114,101, 97, 95,105,110,112, 40,102,108,111, 97,116, 32,115,112,101, 99,102, 97, 99, 44, 32,102, +108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,112,101, 99,102, 97, 99, 41, 10, +123, 10, 9,111,117,116,115,112,101, 99,102, 97, 99, 32, 61, 32,115,112,101, 99,102, 97, 99, 42,105,110,112, 59, 10,125, 10, 10, +118,111,105,100, 32,115,104, 97,100,101, 95,115,112,101, 99, 95,116, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, + 32,102,108,111, 97,116, 32,115,112,101, 99, 44, 32,102,108,111, 97,116, 32,118,105,115,105,102, 97, 99, 44, 32,102,108,111, 97, +116, 32,115,112,101, 99,102, 97, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,116, 41, 10,123, 10, 9,116, 32, 61, 32,115, +104, 97,100,102, 97, 99, 42,115,112,101, 99, 42,118,105,115,105,102, 97, 99, 42,115,112,101, 99,102, 97, 99, 59, 10,125, 10, 10, +118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95,115,112,101, 99, 40,102,108,111, 97,116, 32,116, 44, 32,118,101, 99, + 51, 32,108, 97,109,112, 99,111,108, 44, 32,118,101, 99, 51, 32,115,112,101, 99, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,116, 42,108, 97,109,112, 99,111,108, 42, +115,112,101, 99, 99,111,108, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 40,118,101, 99, 52, 32, + 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, + 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32, 99,111,108, 50, 59, 10,125, 10, 10,118,111, +105,100, 32,115,104, 97,100,101, 95,109, 97,100,100, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32, 99,111,108, + 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, + 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32, 99,111,108, 49, 42, 99,111,108, 50, 59, 10,125, 10, 10,118, +111,105,100, 32,115,104, 97,100,101, 95, 97,100,100, 95, 99,108, 97,109,112,101,100, 40,118,101, 99, 52, 32, 99,111,108, 49, 44, + 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9, +111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 49, 32, 43, 32,109, 97,120, 40, 99,111,108, 50, 44, 32,118,101, 99, 52, 40, 48, + 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97, +100,101, 95,109, 97,100,100, 95, 99,108, 97,109,112,101,100, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32, 99, +111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, + 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32,109, 97,120, 40, 99,111,108, 49, 42, 99,111,108, 50, + 44, 32,118,101, 99, 52, 40, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 44, 32, 48, 46, 48, 41, 41, 59, 10,125, 10, 10, +118,111,105,100, 32,115,104, 97,100,101, 95,109, 97,100,100,102, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,102,108,111, 97,116, + 32,102, 44, 32,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10, +123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 32, 43, 32,102, 42, 99,111,108, 49, 59, 10,125, 10, 10,118,111,105, +100, 32,115,104, 97,100,101, 95,109,117,108, 40,118,101, 99, 52, 32, 99,111,108, 49, 44, 32,118,101, 99, 52, 32, 99,111,108, 50, + 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99, +111,108, 49, 42, 99,111,108, 50, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,117,108, 95,118, 97,108,117, +101, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32, 99,111,108, 42,102, 97, 99, 59, 10,125, 10, 10, +118,111,105,100, 32,115,104, 97,100,101, 95,111, 98, 99,111,108,111,114, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, + 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, + 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 42,111, 98, 99,111,108, 46,114,103, 98, 44, 32, 99,111, +108, 46, 97, 41, 59, 10,125, 10, 10,118,111,105,100, 32,114, 97,109,112, 95,114,103, 98,116,111, 98,119, 40,118,101, 99, 51, 32, + 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,118, 97,108, 41, 10,123, 10, 9,111,117,116,118, + 97,108, 32, 61, 32, 99,111,108,111,114, 46,114, 42, 48, 46, 51, 32, 43, 32, 99,111,108,111,114, 46,103, 42, 48, 46, 53, 56, 32, + 43, 32, 99,111,108,111,114, 46, 98, 42, 48, 46, 49, 50, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110, +108,121, 95,115,104, 97,100,111,119, 40,102,108,111, 97,116, 32,105, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, + 44, 32,102,108,111, 97,116, 32,101,110,101,114,103,121, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,115,104, 97, +100,102, 97, 99, 41, 10,123, 10, 9,111,117,116,115,104, 97,100,102, 97, 99, 32, 61, 32,105, 42,101,110,101,114,103,121, 42, 40, + 49, 46, 48, 32, 45, 32,115,104, 97,100,102, 97, 99, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,111,110, +108,121, 95,115,104, 97,100,111,119, 95,100,105,102,102,117,115,101, 40,102,108,111, 97,116, 32,115,104, 97,100,102, 97, 99, 44, + 32,118,101, 99, 51, 32,114,103, 98, 44, 32,118,101, 99, 52, 32,100,105,102,102, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, +117,116,100,105,102,102, 41, 10,123, 10, 9,111,117,116,100,105,102,102, 32, 61, 32,100,105,102,102, 32, 45, 32,118,101, 99, 52, + 40,114,103, 98, 42,115,104, 97,100,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100, +101, 95,111,110,108,121, 95,115,104, 97,100,111,119, 95,115,112,101, 99,117,108, 97,114, 40,102,108,111, 97,116, 32,115,104, 97, +100,102, 97, 99, 44, 32,118,101, 99, 51, 32,115,112,101, 99,114,103, 98, 44, 32,118,101, 99, 52, 32,115,112,101, 99, 44, 32,111, +117,116, 32,118,101, 99, 52, 32,111,117,116,115,112,101, 99, 41, 10,123, 10, 9,111,117,116,115,112,101, 99, 32, 61, 32,115,112, +101, 99, 32, 45, 32,118,101, 99, 52, 40,115,112,101, 99,114,103, 98, 42,115,104, 97,100,102, 97, 99, 44, 32, 48, 46, 48, 41, 59, + 10,125, 10, 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111,119, 98,117,102, 40,118,101, 99, 51, 32,114, 99,111, + 44, 32,115, 97,109,112,108,101,114, 50, 68, 83,104, 97,100,111,119, 32,115,104, 97,100,111,119,109, 97,112, 44, 32,109, 97,116, + 52, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,111,119, 98,105, 97, +115, 44, 32,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 10, +123, 10, 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, + 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,118,101, 99, 52, 32, 99,111, 32, 61, 32,115,104, 97,100,111, +119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, 10, 10, 9, 9, 47, 47,102,108, +111, 97,116, 32, 98,105, 97,115, 32, 61, 32, 40, 49, 46, 53, 32, 45, 32,105,110,112, 42,105,110,112, 41, 42,115,104, 97,100,111, +119, 98,105, 97,115, 59, 10, 9, 9, 99,111, 46,122, 32, 45, 61, 32,115,104, 97,100,111,119, 98,105, 97,115, 42, 99,111, 46,119, + 59, 10, 9, 9, 10, 9, 9,105,102, 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 32, 62, 32, + 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 32, 62, + 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, 10, 9, 9, 9,114,101,115,117, +108,116, 32, 61, 32,115,104, 97,100,111,119, 50, 68, 80,114,111,106, 40,115,104, 97,100,111,119,109, 97,112, 44, 32, 99,111, 41, + 46,120, 59, 10, 9, 9,101,108,115,101, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 10, 9,125, 10,125, + 10, 10,118,111,105,100, 32,116,101,115,116, 95,115,104, 97,100,111,119, 98,117,102, 95,118,115,109, 40,118,101, 99, 51, 32,114, + 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,115,104, 97,100,111,119,109, 97,112, 44, 32,109, 97,116, 52, 32,115,104, + 97,100,111,119,112,101,114,115,109, 97,116, 44, 32,102,108,111, 97,116, 32,115,104, 97,100,111,119, 98,105, 97,115, 44, 32,102, +108,111, 97,116, 32, 98,108,101,101,100, 98,105, 97,115, 44, 32,102,108,111, 97,116, 32,105,110,112, 44, 32,111,117,116, 32,102, +108,111, 97,116, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,105,102, 40,105,110,112, 32, 60, 61, 32, 48, 46, 48, 41, 32,123, + 10, 9, 9,114,101,115,117,108,116, 32, 61, 32, 48, 46, 48, 59, 10, 9,125, 10, 9,101,108,115,101, 32,123, 10, 9, 9,118,101, + 99, 52, 32, 99,111, 32, 61, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, + 49, 46, 48, 41, 59, 10, 9, 9,105,102, 32, 40, 99,111, 46,119, 32, 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 32, 62, + 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,120, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 32, + 62, 32, 48, 46, 48, 32, 38, 38, 32, 99,111, 46,121, 47, 99,111, 46,119, 32, 60, 32, 49, 46, 48, 41, 32,123, 10, 9, 9, 9,118, +101, 99, 50, 32,109,111,109,101,110,116,115, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40,115,104, 97,100, +111,119,109, 97,112, 44, 32, 99,111, 41, 46,114,103, 59, 10, 9, 9, 9,102,108,111, 97,116, 32,100,105,115,116, 32, 61, 32, 99, +111, 46,122, 47, 99,111, 46,119, 59, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 32, 61, 32, 48, 46, 48, 59, 10, 9, 9, 9, 10, + 9, 9, 9,105,102, 40,100,105,115,116, 32, 60, 61, 32,109,111,109,101,110,116,115, 46,120, 41, 10, 9, 9, 9, 9,112, 32, 61, + 32, 49, 46, 48, 59, 10, 10, 9, 9, 9,102,108,111, 97,116, 32,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109,111,109,101,110, +116,115, 46,121, 32, 45, 32, 40,109,111,109,101,110,116,115, 46,120, 42,109,111,109,101,110,116,115, 46,120, 41, 59, 10, 9, 9, + 9,118, 97,114,105, 97,110, 99,101, 32, 61, 32,109, 97,120, 40,118, 97,114,105, 97,110, 99,101, 44, 32,115,104, 97,100,111,119, + 98,105, 97,115, 47, 49, 48, 46, 48, 41, 59, 10, 10, 9, 9, 9,102,108,111, 97,116, 32,100, 32, 61, 32,109,111,109,101,110,116, +115, 46,120, 32, 45, 32,100,105,115,116, 59, 10, 9, 9, 9,102,108,111, 97,116, 32,112, 95,109, 97,120, 32, 61, 32,118, 97,114, +105, 97,110, 99,101, 32, 47, 32, 40,118, 97,114,105, 97,110, 99,101, 32, 43, 32,100, 42,100, 41, 59, 10, 10, 9, 9, 9, 47, 47, + 32, 78,111,119, 32,114,101,100,117, 99,101, 32,108,105,103,104,116, 45, 98,108,101,101,100,105,110,103, 32, 98,121, 32,114,101, +109,111,118,105,110,103, 32,116,104,101, 32, 91, 48, 44, 32,120, 93, 32,116, 97,105,108, 32, 97,110,100, 32,108,105,110,101, 97, +114,108,121, 32,114,101,115, 99, 97,108,105,110,103, 32, 40,120, 44, 32, 49, 93, 10, 9, 9, 9,112, 95,109, 97,120, 32, 61, 32, + 99,108, 97,109,112, 40, 40,112, 95,109, 97,120, 45, 98,108,101,101,100, 98,105, 97,115, 41, 47, 40, 49, 46, 48, 45, 98,108,101, +101,100, 98,105, 97,115, 41, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 10, 9, 9, 9,114,101,115,117,108,116, 32, 61, + 32,109, 97,120, 40,112, 44, 32,112, 95,109, 97,120, 41, 59, 10, 9, 9,125, 10, 9, 9,101,108,115,101, 32,123, 10, 9, 9, 9, +114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 10, 9, 9,125, 9, 9, 9, 10, 9,125, 10,125, 10, 10,118,111,105,100, 32, +115,104, 97,100,101, 95,108,105,103,104,116, 95,116,101,120,116,117,114,101, 40,118,101, 99, 51, 32,114, 99,111, 44, 32,115, 97, +109,112,108,101,114, 50, 68, 32, 99,111,111,107,105,101, 44, 32,109, 97,116, 52, 32,115,104, 97,100,111,119,112,101,114,115,109, + 97,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 10, 9,118,101, 99, 52, 32, 99,111, + 32, 61, 32,115,104, 97,100,111,119,112,101,114,115,109, 97,116, 42,118,101, 99, 52, 40,114, 99,111, 44, 32, 49, 46, 48, 41, 59, + 10, 10, 9,114,101,115,117,108,116, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 80,114,111,106, 40, 99,111,111,107,105,101, + 44, 32, 99,111, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,101,120,112,111,115,117,114,101, 95, 99,111, +114,114,101, 99,116, 40,118,101, 99, 51, 32, 99,111,108, 44, 32,102,108,111, 97,116, 32,108,105,110,102, 97, 99, 44, 32,102,108, +111, 97,116, 32,108,111,103,102, 97, 99, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9, +111,117,116, 99,111,108, 32, 61, 32,108,105,110,102, 97, 99, 42, 40, 49, 46, 48, 32, 45, 32,101,120,112, 40, 99,111,108, 42,108, +111,103,102, 97, 99, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95,109,105,115,116, 95,102, 97, 99,116, +111,114, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,109,105,115,116,115,116, 97, 44, 32,102,108,111, 97,116, + 32,109,105,115,116,100,105,115,116, 44, 32,102,108,111, 97,116, 32,109,105,115,116,116,121,112,101, 44, 32,102,108,111, 97,116, + 32,109,105,115,105, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,111,117,116,102, 97, 99, 41, 10,123, 10, 9,102,108,111, 97, +116, 32,102, 97, 99, 44, 32,122, 99,111,114, 59, 10, 10, 9,122, 99,111,114, 32, 61, 32, 40,103,108, 95, 80,114,111,106,101, 99, 116,105,111,110, 77, 97,116,114,105,120, 91, 51, 93, 91, 51, 93, 32, 61, 61, 32, 48, 46, 48, 41, 63, 32,108,101,110,103,116,104, - 40, 99,111, 41, 58, 32, 45, 99,111, 91, 50, 93, 59, 13, 10, 9, 13, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 40, -122, 99,111,114, 45,109,105,115,116,115,116, 97, 41, 47,109,105,115,116,100,105,115,116, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, - 41, 59, 13, 10, 9,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 48, 46, 48, 41, 32,102, 97, 99, 32, 42, 61, 32, -102, 97, 99, 59, 13, 10, 9,101,108,115,101, 32,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 49, 46, 48, 41, 59, - 13, 10, 9,101,108,115,101, 32,102, 97, 99, 32, 61, 32,115,113,114,116, 40,102, 97, 99, 41, 59, 13, 10, 13, 10, 9,111,117,116, -102, 97, 99, 32, 61, 32, 49, 46, 48, 32, 45, 32, 40, 49, 46, 48, 45,102, 97, 99, 41, 42, 40, 49, 46, 48, 45,109,105,115,105, 41, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,115,104, 97,100,101, 95,119,111,114,108,100, 95,109,105,120, 40,118,101, 99, - 51, 32,104,111,114, 44, 32,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, - 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 99,111,108, 46, 97, 44, 32, - 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 13, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,109,105,120, 40,104, -111,114, 44, 32, 99,111,108, 46,114,103, 98, 44, 32,102, 97, 99, 41, 44, 32, 99,111,108, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, - 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,108,112,104, 97, 95,111,112, 97,113,117,101, 40,118,101, 99, 52, 32, 99,111, -108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, 9,111,117,116, 99,111,108, 32, - 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, - 32,115,104, 97,100,101, 95, 97,108,112,104, 97, 95,111, 98, 99,111,108,111,114, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,118, -101, 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 13, 10,123, 13, 10, - 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 99,111,108, 46, 97, 42,111, 98, - 99,111,108, 46, 97, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 78, 69, 87, 32, 83, - 72, 65, 68, 69, 82, 32, 85, 84, 73, 76, 73, 84, 73, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, - 10, 13, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, 95,100,105,101,108,101, 99,116,114,105, 99, 40,118,101, 99, 51, - 32, 73,110, 99,111,109,105,110,103, 44, 32,118,101, 99, 51, 32, 78,111,114,109, 97,108, 44, 32,102,108,111, 97,116, 32,101,116, - 97, 41, 13, 10,123, 13, 10, 32, 32, 32, 32, 47, 42, 32, 99,111,109,112,117,116,101, 32,102,114,101,115,110,101,108, 32,114,101, -102,108,101, 99,116, 97,110, 99,101, 32,119,105,116,104,111,117,116, 32,101,120,112,108,105, 99,105,116,108,121, 32, 99,111,109, -112,117,116,105,110,103, 13, 10, 32, 32, 32, 32, 32, 32, 32,116,104,101, 32,114,101,102,114, 97, 99,116,101,100, 32,100,105,114, -101, 99,116,105,111,110, 32, 42, 47, 13, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, 99, 32, 61, 32, 97, 98,115, 40,100,111,116, - 40, 73,110, 99,111,109,105,110,103, 44, 32, 78,111,114,109, 97,108, 41, 41, 59, 13, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, -103, 32, 61, 32,101,116, 97, 32, 42, 32,101,116, 97, 32, 45, 32, 49, 46, 48, 32, 43, 32, 99, 32, 42, 32, 99, 59, 13, 10, 32, 32, - 32, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 59, 13, 10, 13, 10, 32, 32, 32, 32,105,102, 40,103, 32, 62, 32, 48, 46, - 48, 41, 32,123, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32,103, 32, 61, 32,115,113,114,116, 40,103, 41, 59, 13, 10, 32, 32, 32, 32, - 32, 32, 32, 32,102,108,111, 97,116, 32, 65, 32, 61, 40,103, 32, 45, 32, 99, 41, 47, 40,103, 32, 43, 32, 99, 41, 59, 13, 10, 32, - 32, 32, 32, 32, 32, 32, 32,102,108,111, 97,116, 32, 66, 32, 61, 40, 99, 32, 42, 40,103, 32, 43, 32, 99, 41, 45, 32, 49, 46, 48, - 41, 47, 40, 99, 32, 42, 40,103, 32, 45, 32, 99, 41, 43, 32, 49, 46, 48, 41, 59, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101, -115,117,108,116, 32, 61, 32, 48, 46, 53, 32, 42, 32, 65, 32, 42, 32, 65, 32, 42, 40, 49, 46, 48, 32, 43, 32, 66, 32, 42, 32, 66, - 41, 59, 13, 10, 32, 32, 32, 32,125, 13, 10, 32, 32, 32, 32,101,108,115,101, 13, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,115, -117,108,116, 32, 61, 32, 49, 46, 48, 59, 32, 32, 47, 42, 32, 84, 73, 82, 32, 40,110,111, 32,114,101,102,114, 97, 99,116,101,100, - 32, 99,111,109,112,111,110,101,110,116, 41, 32, 42, 47, 13, 10, 13, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,114,101,115, -117,108,116, 59, 13, 10,125, 13, 10, 13, 10,102,108,111, 97,116, 32,104,121,112,111,116, 40,102,108,111, 97,116, 32,120, 44, 32, -102,108,111, 97,116, 32,121, 41, 13, 10,123, 13, 10, 9,114,101,116,117,114,110, 32,115,113,114,116, 40,120, 42,120, 32, 43, 32, -121, 42,121, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 32, 78, 69, 87, 32, 83, 72, 65, - 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 47, 13, 10, 13, 10, 35,100, -101,102,105,110,101, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 32, 51, 13, 10, 13, 10, 47, 42, 32, 98,115,100,102,115, 32, 42, - 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40,118,101, 99, 52, - 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,118,101, 99, 51, 32, 78, 44, - 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9, 47, 42, 32, 97,109, 98,105,101,110, -116, 32,108,105,103,104,116, 32, 42, 47, 13, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 50, 41, 59, - 13, 10, 13, 10, 9, 47, 42, 32,100,105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, 32, 42, 47, 13, 10, 9, -102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 59, 32,105, - 43, 43, 41, 32,123, 13, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 32, 61, 32,103, -108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 13, 10, - 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83, -111,117,114, 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, 46,114,103, 98, 59, 13, 10, 13, 10, 9, 9,102,108,111, 97,116, - 32, 98,115,100,102, 32, 61, 32,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111, -110, 41, 44, 32, 48, 46, 48, 41, 59, 13, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 42, - 98,115,100,102, 59, 13, 10, 9,125, 13, 10, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111, -108,111,114, 46,114,103, 98, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98, -115,100,102, 95,103,108,111,115,115,121, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117, -103,104,110,101,115,115, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, - 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9, 47, 42, 32, 97,109, 98,105,101,110,116, 32,108,105,103,104,116, 32, 42, - 47, 13, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 50, 41, 59, 13, 10, 13, 10, 9, 47, 42, 32,100, -105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, 32, 42, 47, 13, 10, 9,102,111,114, 40,105,110,116, 32,105, - 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 59, 32,105, 43, 43, 41, 32,123, 13, 10, 9, 9, -118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111, -117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 13, 10, 9, 9,118,101, 99, 51, 32, 72, 32, - 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,104, 97,108,102, 86,101, 99,116,111,114, 46,120, -121,122, 59, 13, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 32, 61, 32,103,108, 95, 76, -105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, 46,114,103, 98, 59, 13, 10, 9, 9,118,101, - 99, 51, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, - 99,101, 91,105, 93, 46,115,112,101, 99,117,108, 97,114, 46,114,103, 98, 59, 13, 10, 13, 10, 9, 9, 47, 42, 32,119,101, 32,109, -105,120, 32,105,110, 32,115,111,109,101, 32,100,105,102,102,117,115,101, 32,115,111, 32,108,111,119, 32,114,111,117,103,104,110, -101,115,115, 32,115,116,105,108,108, 32,115,104,111,119,115, 32,117,112, 32, 42, 47, 13, 10, 9, 9,102,108,111, 97,116, 32, 98, -115,100,102, 32, 61, 32, 48, 46, 53, 42,112,111,119, 40,109, 97,120, 40,100,111,116, 40, 78, 44, 32, 72, 41, 44, 32, 48, 46, 48, - 41, 44, 32, 49, 46, 48, 47,114,111,117,103,104,110,101,115,115, 41, 59, 13, 10, 9, 9, 98,115,100,102, 32, 43, 61, 32, 48, 46, - 53, 42,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 41, 44, 32, 48, 46, - 48, 41, 59, 13, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 42, 98,115,100,102, 59, - 13, 10, 9,125, 13, 10, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111,108,111,114, 46,114, -103, 98, 44, 32, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95, 97, -110,105,115,111,116,114,111,112,105, 99, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117, -103,104,110,101,115,115, 85, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 86, 44, 32,118,101, 99, 51, 32, - 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, - 9,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, - 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95, -103,108, 97,115,115, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115, -115, 44, 32,102,108,111, 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105, -102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, - 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,108,117, 99,101,110,116, 40,118, -101, 99, 52, 32, 99,111,108,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117, -108,116, 41, 13, 10,123, 13, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, - 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111, -100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,112, 97,114,101,110,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32, -111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9, 47, 42, 32,116,104,105,115, 32,105,115, -110, 39,116, 32,114,105,103,104,116, 32, 42, 47, 13, 10, 9,114,101,115,117,108,116, 46,114, 32, 61, 32, 99,111,108,111,114, 46, -114, 59, 13, 10, 9,114,101,115,117,108,116, 46,103, 32, 61, 32, 99,111,108,111,114, 46,103, 59, 13, 10, 9,114,101,115,117,108, -116, 46, 98, 32, 61, 32, 99,111,108,111,114, 46, 98, 59, 13, 10, 9,114,101,115,117,108,116, 46, 97, 32, 61, 32, 48, 46, 48, 59, - 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,118,101,108,118,101,116, 40,118,101, 99, - 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,105,103,109, 97, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117, -116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105, -102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 13, 10,125, - 13, 10, 13, 10, 47, 42, 32,101,109,105,115,115,105,111,110, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, + 40, 99,111, 41, 58, 32, 45, 99,111, 91, 50, 93, 59, 10, 9, 10, 9,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 40,122, 99, +111,114, 45,109,105,115,116,115,116, 97, 41, 47,109,105,115,116,100,105,115,116, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, + 10, 9,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 48, 46, 48, 41, 32,102, 97, 99, 32, 42, 61, 32,102, 97, 99, + 59, 10, 9,101,108,115,101, 32,105,102, 40,109,105,115,116,116,121,112,101, 32, 61, 61, 32, 49, 46, 48, 41, 59, 10, 9,101,108, +115,101, 32,102, 97, 99, 32, 61, 32,115,113,114,116, 40,102, 97, 99, 41, 59, 10, 10, 9,111,117,116,102, 97, 99, 32, 61, 32, 49, + 46, 48, 32, 45, 32, 40, 49, 46, 48, 45,102, 97, 99, 41, 42, 40, 49, 46, 48, 45,109,105,115,105, 41, 59, 10,125, 10, 10,118,111, +105,100, 32,115,104, 97,100,101, 95,119,111,114,108,100, 95,109,105,120, 40,118,101, 99, 51, 32,104,111,114, 44, 32,118,101, 99, + 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99,111,108, 41, 10,123, 10, 9,102,108,111, 97,116, + 32,102, 97, 99, 32, 61, 32, 99,108, 97,109,112, 40, 99,111,108, 46, 97, 44, 32, 48, 46, 48, 44, 32, 49, 46, 48, 41, 59, 10, 9, +111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40,109,105,120, 40,104,111,114, 44, 32, 99,111,108, 46,114,103, 98, 44, 32, +102, 97, 99, 41, 44, 32, 99,111,108, 46, 97, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,108,112,104, + 97, 95,111,112, 97,113,117,101, 40,118,101, 99, 52, 32, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111,117,116, 99, +111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, 32, 49, 46, + 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,115,104, 97,100,101, 95, 97,108,112,104, 97, 95,111, 98, 99,111,108,111,114, 40, +118,101, 99, 52, 32, 99,111,108, 44, 32,118,101, 99, 52, 32,111, 98, 99,111,108, 44, 32,111,117,116, 32,118,101, 99, 52, 32,111, +117,116, 99,111,108, 41, 10,123, 10, 9,111,117,116, 99,111,108, 32, 61, 32,118,101, 99, 52, 40, 99,111,108, 46,114,103, 98, 44, + 32, 99,111,108, 46, 97, 42,111, 98, 99,111,108, 46, 97, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 32, 78, 69, 87, 32, 83, 72, 65, 68, 69, 82, 32, 85, 84, 73, 76, 73, 84, 73, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 47, 10, 10,102,108,111, 97,116, 32,102,114,101,115,110,101,108, 95,100,105,101,108,101, 99,116,114,105, 99, 40, +118,101, 99, 51, 32, 73,110, 99,111,109,105,110,103, 44, 32,118,101, 99, 51, 32, 78,111,114,109, 97,108, 44, 32,102,108,111, 97, +116, 32,101,116, 97, 41, 10,123, 10, 32, 32, 32, 32, 47, 42, 32, 99,111,109,112,117,116,101, 32,102,114,101,115,110,101,108, 32, +114,101,102,108,101, 99,116, 97,110, 99,101, 32,119,105,116,104,111,117,116, 32,101,120,112,108,105, 99,105,116,108,121, 32, 99, +111,109,112,117,116,105,110,103, 10, 32, 32, 32, 32, 32, 32, 32,116,104,101, 32,114,101,102,114, 97, 99,116,101,100, 32,100,105, +114,101, 99,116,105,111,110, 32, 42, 47, 10, 32, 32, 32, 32,102,108,111, 97,116, 32, 99, 32, 61, 32, 97, 98,115, 40,100,111,116, + 40, 73,110, 99,111,109,105,110,103, 44, 32, 78,111,114,109, 97,108, 41, 41, 59, 10, 32, 32, 32, 32,102,108,111, 97,116, 32,103, + 32, 61, 32,101,116, 97, 32, 42, 32,101,116, 97, 32, 45, 32, 49, 46, 48, 32, 43, 32, 99, 32, 42, 32, 99, 59, 10, 32, 32, 32, 32, +102,108,111, 97,116, 32,114,101,115,117,108,116, 59, 10, 10, 32, 32, 32, 32,105,102, 40,103, 32, 62, 32, 48, 46, 48, 41, 32,123, + 10, 32, 32, 32, 32, 32, 32, 32, 32,103, 32, 61, 32,115,113,114,116, 40,103, 41, 59, 10, 32, 32, 32, 32, 32, 32, 32, 32,102,108, +111, 97,116, 32, 65, 32, 61, 40,103, 32, 45, 32, 99, 41, 47, 40,103, 32, 43, 32, 99, 41, 59, 10, 32, 32, 32, 32, 32, 32, 32, 32, +102,108,111, 97,116, 32, 66, 32, 61, 40, 99, 32, 42, 40,103, 32, 43, 32, 99, 41, 45, 32, 49, 46, 48, 41, 47, 40, 99, 32, 42, 40, +103, 32, 45, 32, 99, 41, 43, 32, 49, 46, 48, 41, 59, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,115,117,108,116, 32, 61, 32, 48, + 46, 53, 32, 42, 32, 65, 32, 42, 32, 65, 32, 42, 40, 49, 46, 48, 32, 43, 32, 66, 32, 42, 32, 66, 41, 59, 10, 32, 32, 32, 32,125, + 10, 32, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32, 32, 32, 32, 32,114,101,115,117,108,116, 32, 61, 32, 49, 46, 48, 59, 32, + 32, 47, 42, 32, 84, 73, 82, 32, 40,110,111, 32,114,101,102,114, 97, 99,116,101,100, 32, 99,111,109,112,111,110,101,110,116, 41, + 32, 42, 47, 10, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,114,101,115,117,108,116, 59, 10,125, 10, 10,102,108,111, 97,116, + 32,104,121,112,111,116, 40,102,108,111, 97,116, 32,120, 44, 32,102,108,111, 97,116, 32,121, 41, 10,123, 10, 9,114,101,116,117, +114,110, 32,115,113,114,116, 40,120, 42,120, 32, 43, 32,121, 42,121, 41, 59, 10,125, 10, 10, 47, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 32, 78, 69, 87, 32, 83, 72, 65, 68, 69, 82, 32, 78, 79, 68, 69, 83, 32, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 47, 10, 10, 35,100,101,102,105,110,101, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 32, 51, 10, 10, 47, 42, 32, + 98,115,100,102,115, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, + 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,118,101, + 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9, 47, 42, 32, 97,109, 98, +105,101,110,116, 32,108,105,103,104,116, 32, 42, 47, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 50, + 41, 59, 10, 10, 9, 47, 42, 32,100,105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, 32, 42, 47, 10, 9,102, +111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, 72, 84, 83, 59, 32,105, 43, + 43, 41, 32,123, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 32, 61, 32,103,108, 95, + 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121,122, 59, 10, 9, 9,118, +101, 99, 51, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, + 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, 46,114,103, 98, 59, 10, 10, 9, 9,102,108,111, 97,116, 32, 98,115,100,102, + 32, 61, 32,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, 41, 44, 32, 48, + 46, 48, 41, 59, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,100,105,102,102,117,115,101, 42, 98,115,100,102, 59, 10, + 9,125, 10, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111,108,111,114, 46,114,103, 98, 44, 32, + 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,103,108,111,115,115,121, 40,118, +101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,118,101, 99, 51, + 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9, + 47, 42, 32, 97,109, 98,105,101,110,116, 32,108,105,103,104,116, 32, 42, 47, 10, 9,118,101, 99, 51, 32, 76, 32, 61, 32,118,101, + 99, 51, 40, 48, 46, 50, 41, 59, 10, 10, 9, 47, 42, 32,100,105,114,101, 99,116,105,111,110, 97,108, 32,108,105,103,104,116,115, + 32, 42, 47, 10, 9,102,111,114, 40,105,110,116, 32,105, 32, 61, 32, 48, 59, 32,105, 32, 60, 32, 78, 85, 77, 95, 76, 73, 71, 72, + 84, 83, 59, 32,105, 43, 43, 41, 32,123, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111,110, + 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,112,111,115,105,116,105,111,110, 46,120,121, +122, 59, 10, 9, 9,118,101, 99, 51, 32, 72, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46, +104, 97,108,102, 86,101, 99,116,111,114, 46,120,121,122, 59, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,100,105,102, +102,117,115,101, 32, 61, 32,103,108, 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,100,105,102,102,117,115,101, + 46,114,103, 98, 59, 10, 9, 9,118,101, 99, 51, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 32, 61, 32,103,108, + 95, 76,105,103,104,116, 83,111,117,114, 99,101, 91,105, 93, 46,115,112,101, 99,117,108, 97,114, 46,114,103, 98, 59, 10, 10, 9, + 9, 47, 42, 32,119,101, 32,109,105,120, 32,105,110, 32,115,111,109,101, 32,100,105,102,102,117,115,101, 32,115,111, 32,108,111, +119, 32,114,111,117,103,104,110,101,115,115, 32,115,116,105,108,108, 32,115,104,111,119,115, 32,117,112, 32, 42, 47, 10, 9, 9, +102,108,111, 97,116, 32, 98,115,100,102, 32, 61, 32, 48, 46, 53, 42,112,111,119, 40,109, 97,120, 40,100,111,116, 40, 78, 44, 32, + 72, 41, 44, 32, 48, 46, 48, 41, 44, 32, 49, 46, 48, 47,114,111,117,103,104,110,101,115,115, 41, 59, 10, 9, 9, 98,115,100,102, + 32, 43, 61, 32, 48, 46, 53, 42,109, 97,120, 40,100,111,116, 40, 78, 44, 32,108,105,103,104,116, 95,112,111,115,105,116,105,111, +110, 41, 44, 32, 48, 46, 48, 41, 59, 10, 9, 9, 76, 32, 43, 61, 32,108,105,103,104,116, 95,115,112,101, 99,117,108, 97,114, 42, + 98,115,100,102, 59, 10, 9,125, 10, 10, 9,114,101,115,117,108,116, 32, 61, 32,118,101, 99, 52, 40, 76, 42, 99,111,108,111,114, + 46,114,103, 98, 44, 32, 49, 46, 48, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95, 97,110, +105,115,111,116,114,111,112,105, 99, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103, +104,110,101,115,115, 85, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 86, 44, 32,118,101, 99, 51, 32, 78, + 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111, +100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114, +101,115,117,108,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,103,108, 97,115,115, 40, +118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,114,111,117,103,104,110,101,115,115, 44, 32,102,108,111, + 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,118,101, 99, 52, + 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111,100,101, 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111, +108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111, +100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,108,117, 99,101,110,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32, +118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111,100,101, + 95, 98,115,100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115, +117,108,116, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,116,114, 97,110,115,112, 97,114, +101,110,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, + 10,123, 10, 9, 47, 42, 32,116,104,105,115, 32,105,115,110, 39,116, 32,114,105,103,104,116, 32, 42, 47, 10, 9,114,101,115,117, +108,116, 46,114, 32, 61, 32, 99,111,108,111,114, 46,114, 59, 10, 9,114,101,115,117,108,116, 46,103, 32, 61, 32, 99,111,108,111, +114, 46,103, 59, 10, 9,114,101,115,117,108,116, 46, 98, 32, 61, 32, 99,111,108,111,114, 46, 98, 59, 10, 9,114,101,115,117,108, +116, 46, 97, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 98,115,100,102, 95,118,101,108, +118,101,116, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,105,103,109, 97, 44, 32,118,101, 99, + 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,110,111,100,101, 95, 98,115, +100,102, 95,100,105,102,102,117,115,101, 40, 99,111,108,111,114, 44, 32, 48, 46, 48, 44, 32, 78, 44, 32,114,101,115,117,108,116, + 41, 59, 10,125, 10, 10, 47, 42, 32,101,109,105,115,115,105,111,110, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 101,109,105,115,115,105,111,110, 40,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,102,108,111, 97,116, 32,115,116,114,101,110, -103,116,104, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 13, 10,123, - 13, 10, 9,114,101,115,117,108,116, 32, 61, 32, 99,111,108,111,114, 42,115,116,114,101,110,103,116,104, 59, 13, 10,125, 13, 10, - 13, 10, 47, 42, 32, 99,108,111,115,117,114,101,115, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,109,105, -120, 95,115,104, 97,100,101,114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 49, - 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 41, - 13, 10,123, 13, 10, 9,115,104, 97,100,101,114, 32, 61, 32,109,105,120, 40,115,104, 97,100,101,114, 49, 44, 32,115,104, 97,100, -101,114, 50, 44, 32,102, 97, 99, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95, 97,100,100, 95,115, -104, 97,100,101,114, 40,118,101, 99, 52, 32,115,104, 97,100,101,114, 49, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 50, - 44, 32,111,117,116, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 41, 13, 10,123, 13, 10, 9,115,104, 97,100,101,114, 32, 61, - 32,115,104, 97,100,101,114, 49, 32, 43, 32,115,104, 97,100,101,114, 50, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32,102,114,101, -115,110,101,108, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,102,114,101,115,110,101,108, 40,102,108,111, - 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, 51, 32, 73, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,114,101,115,117,108,116, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,101,116, 97, 32, 61, 32,109, 97,120, 40,105, -111,114, 44, 32, 48, 46, 48, 48, 48, 48, 49, 41, 59, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,102,114,101,115,110,101,108, - 95,100,105,101,108,101, 99,116,114,105, 99, 40, 73, 44, 32, 78, 44, 32,101,116, 97, 41, 59, 32, 47, 47, 98, 97, 99,107,102, 97, - 99,105,110,103, 40, 41, 63, 32, 49, 46, 48, 47,101,116, 97, 58, 32,101,116, 97, 41, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32, -103,101,111,109,101,116,114,121, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,103,101,111,109,101,116,114, -121, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, 32,116,111,119,111,114,108,100, 44, 13, - 10, 9,111,117,116, 32,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111, -114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,116, 97,110,103,101,110,116, 44, 13, 10, 9,111,117,116, 32,118,101, - 99, 51, 32,116,114,117,101, 95,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111,109,105,110, -103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,112, 97,114, 97,109,101,116,114,105, 99, 44, 13, 10, 9,111,117,116, 32,102,108, -111, 97,116, 32, 98, 97, 99,107,102, 97, 99,105,110,103, 41, 13, 10,123, 13, 10, 9,112,111,115,105,116,105,111,110, 32, 61, 32, - 40,116,111,119,111,114,108,100, 42,118,101, 99, 52, 40, 73, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 13, 10, 9,110,111, -114,109, 97,108, 32, 61, 32, 78, 59, 13, 10, 9,116, 97,110,103,101,110,116, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, - 13, 10, 9,116,114,117,101, 95,110,111,114,109, 97,108, 32, 61, 32, 78, 59, 13, 10, 9,105,110, 99,111,109,105,110,103, 32, 61, - 32, 73, 59, 13, 10, 9,112, 97,114, 97,109,101,116,114,105, 99, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 13, 10, 9, - 98, 97, 99,107,102, 97, 99,105,110,103, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100, -101, 95,116,101,120, 95, 99,111,111,114,100, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, - 32,118,105,101,119,105,110,118,109, 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 13, 10, 9,118,101, - 99, 51, 32, 97,116,116,114, 95,111,114, 99,111, 44, 32,118,101, 99, 51, 32, 97,116,116,114, 95,117,118, 44, 13, 10, 9,111,117, -116, 32,118,101, 99, 51, 32,103,101,110,101,114, 97,116,101,100, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97, -108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 44, - 13, 10, 9,111,117,116, 32,118,101, 99, 51, 32, 99, 97,109,101,114, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32,119,105,110, -100,111,119, 44, 32,111,117,116, 32,118,101, 99, 51, 32,114,101,102,108,101, 99,116,105,111,110, 41, 13, 10,123, 13, 10, 9,103, -101,110,101,114, 97,116,101,100, 32, 61, 32, 97,116,116,114, 95,111,114, 99,111, 59, 13, 10, 9,110,111,114,109, 97,108, 32, 61, - 32,110,111,114,109, 97,108,105,122,101, 40, 40,111, 98,105,110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, - 42,118,101, 99, 52, 40, 78, 44, 32, 48, 46, 48, 41, 41, 41, 46,120,121,122, 41, 59, 13, 10, 9,117,118, 32, 61, 32, 97,116,116, -114, 95,117,118, 59, 13, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, 73, 59, 13, 10, 9, 99, 97,109,101,114, 97, 32, 61, 32, 73, - 59, 13, 10, 9,119,105,110,100,111,119, 32, 61, 32,103,108, 95, 70,114, 97,103, 67,111,111,114,100, 46,120,121,122, 59, 13, 10, - 9,114,101,102,108,101, 99,116,105,111,110, 32, 61, 32,114,101,102,108,101, 99,116, 40, 78, 44, 32, 73, 41, 59, 13, 10, 13, 10, -125, 13, 10, 13, 10, 47, 42, 32,116,101,120,116,117,114,101,115, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, - 95,116,101,120, 95,103,114, 97,100,105,101,110,116, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 52, 32, - 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, - 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, +103,116,104, 44, 32,118,101, 99, 51, 32, 78, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108,116, 41, 10,123, 10, + 9,114,101,115,117,108,116, 32, 61, 32, 99,111,108,111,114, 42,115,116,114,101,110,103,116,104, 59, 10,125, 10, 10, 47, 42, 32, + 99,108,111,115,117,114,101,115, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,109,105,120, 95,115,104, 97,100,101, +114, 40,102,108,111, 97,116, 32,102, 97, 99, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 49, 44, 32,118,101, 99, 52, 32, +115,104, 97,100,101,114, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 41, 10,123, 10, 9,115,104, 97, +100,101,114, 32, 61, 32,109,105,120, 40,115,104, 97,100,101,114, 49, 44, 32,115,104, 97,100,101,114, 50, 44, 32,102, 97, 99, 41, + 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95, 97,100,100, 95,115,104, 97,100,101,114, 40,118,101, 99, 52, 32,115, +104, 97,100,101,114, 49, 44, 32,118,101, 99, 52, 32,115,104, 97,100,101,114, 50, 44, 32,111,117,116, 32,118,101, 99, 52, 32,115, +104, 97,100,101,114, 41, 10,123, 10, 9,115,104, 97,100,101,114, 32, 61, 32,115,104, 97,100,101,114, 49, 32, 43, 32,115,104, 97, +100,101,114, 50, 59, 10,125, 10, 10, 47, 42, 32,102,114,101,115,110,101,108, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100, +101, 95,102,114,101,115,110,101,108, 40,102,108,111, 97,116, 32,105,111,114, 44, 32,118,101, 99, 51, 32, 78, 44, 32,118,101, 99, + 51, 32, 73, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,114,101,115,117,108,116, 41, 10,123, 10, 9,102,108,111, 97,116, 32, +101,116, 97, 32, 61, 32,109, 97,120, 40,105,111,114, 44, 32, 48, 46, 48, 48, 48, 48, 49, 41, 59, 10, 9,114,101,115,117,108,116, + 32, 61, 32,102,114,101,115,110,101,108, 95,100,105,101,108,101, 99,116,114,105, 99, 40, 73, 44, 32, 78, 44, 32,101,116, 97, 41, + 59, 32, 47, 47, 98, 97, 99,107,102, 97, 99,105,110,103, 40, 41, 63, 32, 49, 46, 48, 47,101,116, 97, 58, 32,101,116, 97, 41, 59, + 10,125, 10, 10, 47, 42, 32,103,101,111,109,101,116,114,121, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,103,101, +111,109,101,116,114,121, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, 32,116,111,119,111, +114,108,100, 44, 10, 9,111,117,116, 32,118,101, 99, 51, 32,112,111,115,105,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,116, 97,110,103,101,110,116, 44, 10, 9,111,117,116, + 32,118,101, 99, 51, 32,116,114,117,101, 95,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, 32,105,110, 99,111, +109,105,110,103, 44, 32,111,117,116, 32,118,101, 99, 51, 32,112, 97,114, 97,109,101,116,114,105, 99, 44, 10, 9,111,117,116, 32, +102,108,111, 97,116, 32, 98, 97, 99,107,102, 97, 99,105,110,103, 41, 10,123, 10, 9,112,111,115,105,116,105,111,110, 32, 61, 32, + 40,116,111,119,111,114,108,100, 42,118,101, 99, 52, 40, 73, 44, 32, 49, 46, 48, 41, 41, 46,120,121,122, 59, 10, 9,110,111,114, +109, 97,108, 32, 61, 32, 78, 59, 10, 9,116, 97,110,103,101,110,116, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 10, 9, +116,114,117,101, 95,110,111,114,109, 97,108, 32, 61, 32, 78, 59, 10, 9,105,110, 99,111,109,105,110,103, 32, 61, 32, 73, 59, 10, + 9,112, 97,114, 97,109,101,116,114,105, 99, 32, 61, 32,118,101, 99, 51, 40, 48, 46, 48, 41, 59, 10, 9, 98, 97, 99,107,102, 97, + 99,105,110,103, 32, 61, 32, 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,111,111, +114,100, 40,118,101, 99, 51, 32, 73, 44, 32,118,101, 99, 51, 32, 78, 44, 32,109, 97,116, 52, 32,118,105,101,119,105,110,118,109, + 97,116, 44, 32,109, 97,116, 52, 32,111, 98,105,110,118,109, 97,116, 44, 10, 9,118,101, 99, 51, 32, 97,116,116,114, 95,111,114, + 99,111, 44, 32,118,101, 99, 51, 32, 97,116,116,114, 95,117,118, 44, 10, 9,111,117,116, 32,118,101, 99, 51, 32,103,101,110,101, +114, 97,116,101,100, 44, 32,111,117,116, 32,118,101, 99, 51, 32,110,111,114,109, 97,108, 44, 32,111,117,116, 32,118,101, 99, 51, + 32,117,118, 44, 32,111,117,116, 32,118,101, 99, 51, 32,111, 98,106,101, 99,116, 44, 10, 9,111,117,116, 32,118,101, 99, 51, 32, + 99, 97,109,101,114, 97, 44, 32,111,117,116, 32,118,101, 99, 51, 32,119,105,110,100,111,119, 44, 32,111,117,116, 32,118,101, 99, + 51, 32,114,101,102,108,101, 99,116,105,111,110, 41, 10,123, 10, 9,103,101,110,101,114, 97,116,101,100, 32, 61, 32, 97,116,116, +114, 95,111,114, 99,111, 59, 10, 9,110,111,114,109, 97,108, 32, 61, 32,110,111,114,109, 97,108,105,122,101, 40, 40,111, 98,105, +110,118,109, 97,116, 42, 40,118,105,101,119,105,110,118,109, 97,116, 42,118,101, 99, 52, 40, 78, 44, 32, 48, 46, 48, 41, 41, 41, + 46,120,121,122, 41, 59, 10, 9,117,118, 32, 61, 32, 97,116,116,114, 95,117,118, 59, 10, 9,111, 98,106,101, 99,116, 32, 61, 32, + 73, 59, 10, 9, 99, 97,109,101,114, 97, 32, 61, 32, 73, 59, 10, 9,119,105,110,100,111,119, 32, 61, 32,103,108, 95, 70,114, 97, +103, 67,111,111,114,100, 46,120,121,122, 59, 10, 9,114,101,102,108,101, 99,116,105,111,110, 32, 61, 32,114,101,102,108,101, 99, +116, 40, 78, 44, 32, 73, 41, 59, 10, 10,125, 10, 10, 47, 42, 32,116,101,120,116,117,114,101,115, 32, 42, 47, 10, 10,118,111,105, +100, 32,110,111,100,101, 95,116,101,120, 95,103,114, 97,100,105,101,110,116, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, + 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99, +111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,104,101, 99,107,101,114, 40,118,101, 99, 51, 32, 99,111, 44, 32, 118,101, 99, 52, 32, 99,111,108,111,114, 49, 44, 32,118,101, 99, 52, 32, 99,111,108,111,114, 50, 44, 32,102,108,111, 97,116, 32, 115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, - 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9, -102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99, -108,111,117,100,115, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,111,117,116, 32,118, -101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99, -111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10, -125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,101,110,118,105,114,111,110,109,101,110,116, 40,118, -101, 99, 51, 32, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32, - 99,111,108,111,114, 41, 13, 10,123, 13, 10, 9,102,108,111, 97,116, 32,117, 32, 61, 32, 40, 97,116, 97,110, 40, 99,111, 46,121, - 44, 32, 99,111, 46,120, 41, 32, 43, 32, 77, 95, 80, 73, 41, 47, 40, 50, 46, 48, 42, 77, 95, 80, 73, 41, 59, 13, 10, 9,102,108, -111, 97,116, 32,118, 32, 61, 32, 97,116, 97,110, 40, 99,111, 46,122, 44, 32,104,121,112,111,116, 40, 99,111, 46,120, 44, 32, 99, -111, 46,121, 41, 41, 47, 77, 95, 80, 73, 32, 43, 32, 48, 46, 53, 59, 13, 10, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101, -120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,118,101, 99, 50, 40,117, 44, 32,118, 41, 41, 59, 13, 10,125, 13, 10, 13, 10, -118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,105,109, 97,103,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,115, 97,109, -112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32, -102,108,111, 97,116, 32, 97,108,112,104, 97, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114, -101, 50, 68, 40,105,109, 97, 44, 32, 99,111, 46,120,121, 41, 59, 13, 10, 32, 32, 32, 32, 97,108,112,104, 97, 32, 61, 32, 99,111, -108,111,114, 46, 97, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,109, 97,103,105, 99, - 40,118,101, 99, 51, 32,112, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100,105,115,116, -111,114,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97, -116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, - 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, + 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, + 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 99,108,111,117,100,115, 40, +118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115,105,122,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111, +108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118, +101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111, +100,101, 95,116,101,120, 95,101,110,118,105,114,111,110,109,101,110,116, 40,118,101, 99, 51, 32, 99,111, 44, 32,115, 97,109,112, +108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 10,123, 10, 9,102,108, +111, 97,116, 32,117, 32, 61, 32, 40, 97,116, 97,110, 40, 99,111, 46,121, 44, 32, 99,111, 46,120, 41, 32, 43, 32, 77, 95, 80, 73, + 41, 47, 40, 50, 46, 48, 42, 77, 95, 80, 73, 41, 59, 10, 9,102,108,111, 97,116, 32,118, 32, 61, 32, 97,116, 97,110, 40, 99,111, + 46,122, 44, 32,104,121,112,111,116, 40, 99,111, 46,120, 44, 32, 99,111, 46,121, 41, 41, 47, 77, 95, 80, 73, 32, 43, 32, 48, 46, + 53, 59, 10, 10, 9, 99,111,108,111,114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32,118,101, 99, 50, + 40,117, 44, 32,118, 41, 41, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,105,109, 97,103,101, 40, +118,101, 99, 51, 32, 99,111, 44, 32,115, 97,109,112,108,101,114, 50, 68, 32,105,109, 97, 44, 32,111,117,116, 32,118,101, 99, 52, + 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 97,108,112,104, 97, 41, 10,123, 10, 9, 99,111,108,111, +114, 32, 61, 32,116,101,120,116,117,114,101, 50, 68, 40,105,109, 97, 44, 32, 99,111, 46,120,121, 41, 59, 10, 32, 32, 32, 32, 97, +108,112,104, 97, 32, 61, 32, 99,111,108,111,114, 46, 97, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, + 95,109, 97,103,105, 99, 40,118,101, 99, 51, 32,112, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97, +116, 32,100,105,115,116,111,114,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117, +116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, + 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95, 109,117,115,103,114, 97,118,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102, 108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,109,101,110,115,105,111,110, 44, 32,102,108, 111, 97,116, 32,108, 97, 99,117,110, 97,114,105,116,121, 44, 32,102,108,111, 97,116, 32,111,102,102,115,101,116, 44, 32,102,108, 111, 97,116, 32,103, 97,105,110, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108, -111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, - 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101, -120, 95,110,111,105,115,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108, -111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,115,116,111,114,116,105,111,110, 44, 32,111,117, -116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, - 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, - 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,115,107,121, 40,118,101, 99, 51, 32, 99, -111, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32, -118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,118, -111,114,111,110,111,105, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,111,117,116, - 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 13, 10,123, 13, 10, - 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, - 13, 10,125, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,119, 97,118,101, 40,118,101, 99, 51, 32, 99, -111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100,105,115,116,111,114,116,105,111,110, - 44, 32,102,108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,101,116, 97,105,108, 95,115, 99, 97, -108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, - 99, 41, 13, 10,123, 13, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 13, 10, 9,102, 97, 99, - 32, 61, 32, 49, 46, 48, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32,108,105,103,104,116, 32,112, 97,116,104, 32, 42, 47, 13, 10, - 13, 10,118,111,105,100, 32,110,111,100,101, 95,108,105,103,104,116, 95,112, 97,116,104, 40, 13, 10, 9,111,117,116, 32,102,108, -111, 97,116, 32,105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105, -115, 95,115,104, 97,100,111,119, 95,114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,100,105,102, -102,117,115,101, 95,114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,103,108,111,115,115,121, 95, -114, 97,121, 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,115,105,110,103,117,108, 97,114, 95,114, 97,121, - 44, 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,114,101,102,108,101, 99,116,105,111,110, 95,114, 97,121, 44, - 13, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,116,114, 97,110,115,109,105,115,115,105,111,110, 95,114, 97,121, - 41, 13, 10,123, 13, 10, 9,105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 32, 61, 32, 49, 46, 48, 59, 13, 10, 9,105,115, - 95,115,104, 97,100,111,119, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95,100,105,102,102,117,115,101, 95, -114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95,103,108,111,115,115,121, 95,114, 97,121, 32, 61, 32, 48, 46, 48, - 59, 13, 10, 9,105,115, 95,115,105,110,103,117,108, 97,114, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95, -114,101,102,108,101, 99,116,105,111,110, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10, 9,105,115, 95,116,114, 97,110,115, -109,105,115,115,105,111,110, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 13, 10,125, 13, 10, 13, 10, 47, 42, 32,111,117,116,112, -117,116, 32, 42, 47, 13, 10, 13, 10,118,111,105,100, 32,110,111,100,101, 95,111,117,116,112,117,116, 95,109, 97,116,101,114,105, - 97,108, 40,118,101, 99, 52, 32,115,117,114,102, 97, 99,101, 44, 32,118,101, 99, 52, 32,118,111,108,117,109,101, 44, 32,102,108, -111, 97,116, 32,100,105,115,112,108, 97, 99,101,109,101,110,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32,114,101,115,117,108, -116, 41, 13, 10,123, 13, 10, 9,114,101,115,117,108,116, 32, 61, 32,115,117,114,102, 97, 99,101, 59, 13, 10,125, 13, 10, 13, 10, +111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9, +102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,110,111,105,115, +101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100,101, +116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100,105,115,116,111,114,116,105,111,110, 44, 32,111,117,116, 32,118,101, 99, 52, + 32, 99,111,108,111,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, + 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, + 32,110,111,100,101, 95,116,101,120, 95,115,107,121, 40,118,101, 99, 51, 32, 99,111, 44, 32,111,117,116, 32,118,101, 99, 52, 32, + 99,111,108,111,114, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, 10,125, 10, 10, +118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,118,111,114,111,110,111,105, 40,118,101, 99, 51, 32, 99,111, 44, 32,102, +108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, 32, +102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, 59, + 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,116,101,120, 95,119, 97, +118,101, 40,118,101, 99, 51, 32, 99,111, 44, 32,102,108,111, 97,116, 32,115, 99, 97,108,101, 44, 32,102,108,111, 97,116, 32,100, +105,115,116,111,114,116,105,111,110, 44, 32,102,108,111, 97,116, 32,100,101,116, 97,105,108, 44, 32,102,108,111, 97,116, 32,100, +101,116, 97,105,108, 95,115, 99, 97,108,101, 44, 32,111,117,116, 32,118,101, 99, 52, 32, 99,111,108,111,114, 44, 32,111,117,116, + 32,102,108,111, 97,116, 32,102, 97, 99, 41, 10,123, 10, 9, 99,111,108,111,114, 32, 61, 32,118,101, 99, 52, 40, 49, 46, 48, 41, + 59, 10, 9,102, 97, 99, 32, 61, 32, 49, 46, 48, 59, 10,125, 10, 10, 47, 42, 32,108,105,103,104,116, 32,112, 97,116,104, 32, 42, + 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,108,105,103,104,116, 95,112, 97,116,104, 40, 10, 9,111,117,116, 32,102,108, +111, 97,116, 32,105,115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, + 95,115,104, 97,100,111,119, 95,114, 97,121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,100,105,102,102,117, +115,101, 95,114, 97,121, 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,103,108,111,115,115,121, 95,114, 97,121, + 44, 10, 9,111,117,116, 32,102,108,111, 97,116, 32,105,115, 95,115,105,110,103,117,108, 97,114, 95,114, 97,121, 44, 10, 9,111, +117,116, 32,102,108,111, 97,116, 32,105,115, 95,114,101,102,108,101, 99,116,105,111,110, 95,114, 97,121, 44, 10, 9,111,117,116, + 32,102,108,111, 97,116, 32,105,115, 95,116,114, 97,110,115,109,105,115,115,105,111,110, 95,114, 97,121, 41, 10,123, 10, 9,105, +115, 95, 99, 97,109,101,114, 97, 95,114, 97,121, 32, 61, 32, 49, 46, 48, 59, 10, 9,105,115, 95,115,104, 97,100,111,119, 95,114, + 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,100,105,102,102,117,115,101, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, + 10, 9,105,115, 95,103,108,111,115,115,121, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,115,105,110,103,117, +108, 97,114, 95,114, 97,121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,114,101,102,108,101, 99,116,105,111,110, 95,114, 97, +121, 32, 61, 32, 48, 46, 48, 59, 10, 9,105,115, 95,116,114, 97,110,115,109,105,115,115,105,111,110, 95,114, 97,121, 32, 61, 32, + 48, 46, 48, 59, 10,125, 10, 10,118,111,105,100, 32,110,111,100,101, 95,108,105,103,104,116, 95,102, 97,108,108,111,102,102, 40, +102,108,111, 97,116, 32,115,116,114,101,110,103,116,104, 44, 32,102,108,111, 97,116, 32,116,115,109,111,111,116,104, 44, 32,111, +117,116, 32,102,108,111, 97,116, 32,113,117, 97,100,114, 97,116,105, 99, 44, 32,111,117,116, 32,102,108,111, 97,116, 32,108,105, +110,101, 97,114, 44, 32,111,117,116, 32,102,108,111, 97,116, 32, 99,111,110,115,116, 97,110,116, 41, 10,123, 10, 9,113,117, 97, +100,114, 97,116,105, 99, 32, 61, 32,115,116,114,101,110,103,116,104, 59, 10, 9,108,105,110,101, 97,114, 32, 61, 32,115,116,114, +101,110,103,116,104, 59, 10, 9, 99,111,110,115,116, 97,110,116, 32, 61, 32,115,116,114,101,110,103,116,104, 59, 10,125, 10, 10, + 47, 42, 32,111,117,116,112,117,116, 32, 42, 47, 10, 10,118,111,105,100, 32,110,111,100,101, 95,111,117,116,112,117,116, 95,109, + 97,116,101,114,105, 97,108, 40,118,101, 99, 52, 32,115,117,114,102, 97, 99,101, 44, 32,118,101, 99, 52, 32,118,111,108,117,109, +101, 44, 32,102,108,111, 97,116, 32,100,105,115,112,108, 97, 99,101,109,101,110,116, 44, 32,111,117,116, 32,118,101, 99, 52, 32, +114,101,115,117,108,116, 41, 10,123, 10, 9,114,101,115,117,108,116, 32, 61, 32,115,117,114,102, 97, 99,101, 59, 10,125, 10, 10, 0}; diff --git a/source/blender/ikplugin/intern/iksolver_plugin.c b/source/blender/ikplugin/intern/iksolver_plugin.c index 08c5e24aca6..c726102247a 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.c +++ b/source/blender/ikplugin/intern/iksolver_plugin.c @@ -229,7 +229,7 @@ static void where_is_ik_bone(bPoseChannel *pchan, float ik_mat[][3]) // nr = t } -/* called from within the core where_is_pose loop, all animsystems and constraints +/* called from within the core BKE_pose_where_is loop, all animsystems and constraints * were executed & assigned. Now as last we do an IK pass */ static void execute_posetree(struct Scene *scene, Object *ob, PoseTree *tree) { @@ -535,8 +535,8 @@ void iksolver_execute_tree(struct Scene *scene, struct Object *ob, struct bPose /* 4. walk over the tree for regular solving */ for (a=0; atotchannel; a++) { if (!(tree->pchan[a]->flag & POSE_DONE)) // successive trees can set the flag - where_is_pose_bone(scene, ob, tree->pchan[a], ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each where_is_pose() + BKE_pose_where_is_bone(scene, ob, tree->pchan[a], ctime, 1); + // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() tree->pchan[a]->flag |= POSE_CHAIN; } /* 5. execute the IK solver */ diff --git a/source/blender/ikplugin/intern/itasc_plugin.cpp b/source/blender/ikplugin/intern/itasc_plugin.cpp index 2e437c627a2..d94529b6104 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cpp +++ b/source/blender/ikplugin/intern/itasc_plugin.cpp @@ -418,7 +418,7 @@ static IK_Data* get_ikdata(bPose *pose) // here init ikdata if needed // now that we have scene, make sure the default param are initialized if (!DefIKParam.iksolver) - init_pose_itasc(&DefIKParam); + BKE_pose_itasc_init(&DefIKParam); return (IK_Data*)pose->ikdata; } @@ -1023,7 +1023,7 @@ static void convert_pose(IK_Scene *ikscene) } // compute array of joint value corresponding to current pose -static void rest_pose(IK_Scene *ikscene) +static void BKE_pose_rest(IK_Scene *ikscene) { bPoseChannel *pchan; IK_Channel *ikchan; @@ -1133,7 +1133,7 @@ static IK_Scene* convert_tree(Scene *blscene, Object *ob, bPoseChannel *pchan) } else { // in Blender, the rest pose is always 0 for joints - rest_pose(ikscene); + BKE_pose_rest(ikscene); } rot = &ikscene->jointArray(0); for (a=0, ikchan = ikscene->channels; atotchannel; ++a, ++ikchan) { @@ -1545,7 +1545,7 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl if (ikparam->flag & ITASC_SIMULATION) { for (i=0, ikchan=ikscene->channels; inumchan; i++, ++ikchan) { // In simulation mode we don't allow external contraint to change our bones, mark the channel done - // also tell Blender that this channel is part of IK tree (cleared on each where_is_pose() + // also tell Blender that this channel is part of IK tree (cleared on each BKE_pose_where_is() ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); ikchan->jointValid = 0; } @@ -1554,8 +1554,8 @@ static void execute_scene(Scene* blscene, IK_Scene* ikscene, bItasc* ikparam, fl // in animation mode, we must get the bone position from action and constraints for (i=0, ikchan=ikscene->channels; inumchan; i++, ++ikchan) { if (!(ikchan->pchan->flag & POSE_DONE)) - where_is_pose_bone(blscene, ikscene->blArmature, ikchan->pchan, ctime, 1); - // tell blender that this channel was controlled by IK, it's cleared on each where_is_pose() + BKE_pose_where_is_bone(blscene, ikscene->blArmature, ikchan->pchan, ctime, 1); + // tell blender that this channel was controlled by IK, it's cleared on each BKE_pose_where_is() ikchan->pchan->flag |= (POSE_DONE|POSE_CHAIN); ikchan->jointValid = 0; } diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 9f3ed6797be..5d8c65f7971 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -471,8 +471,7 @@ static int startffmpeg(struct anim * anim) videoStream = -1; for (i = 0; i < pFormatCtx->nb_streams; i++) - if (pFormatCtx->streams[i]->codec->codec_type - == AVMEDIA_TYPE_VIDEO) { + if (pFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (streamcount > 0) { streamcount--; continue; @@ -502,9 +501,9 @@ static int startffmpeg(struct anim * anim) return -1; } - anim->duration = ceil(pFormatCtx->duration - * av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate) - / AV_TIME_BASE); + anim->duration = ceil(pFormatCtx->duration * + av_q2d(pFormatCtx->streams[videoStream]->r_frame_rate) / + AV_TIME_BASE); frs_num = pFormatCtx->streams[videoStream]->r_frame_rate.num; frs_den = pFormatCtx->streams[videoStream]->r_frame_rate.den; @@ -658,8 +657,8 @@ static void ffmpeg_postprocess(struct anim * anim) anim->pFrame, anim->pCodecCtx->pix_fmt, anim->pCodecCtx->width, - anim->pCodecCtx->height) - < 0) { + anim->pCodecCtx->height) < 0) + { filter_y = TRUE; } else { @@ -785,8 +784,7 @@ static int ffmpeg_decode_video_frame(struct anim * anim) "pkt_pts=%lld, guessed_pts=%lld\n", (anim->pFrame->pts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->pFrame->pts, - (anim->pFrame->pkt_pts - == AV_NOPTS_VALUE) ? + (anim->pFrame->pkt_pts == AV_NOPTS_VALUE) ? -1 : (long long int)anim->pFrame->pkt_pts, (long long int)anim->next_pts); break; @@ -921,12 +919,11 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, } else { pts_to_search = (long long) - floor(((double) position) - / pts_time_base / frame_rate + 0.5); + floor(((double) position) / + pts_time_base / frame_rate + 0.5); if (st_time != AV_NOPTS_VALUE) { - pts_to_search += st_time / pts_time_base - / AV_TIME_BASE; + pts_to_search += st_time / pts_time_base / AV_TIME_BASE; } } @@ -1001,8 +998,8 @@ static ImBuf * ffmpeg_fetchibuf(struct anim * anim, int position, } } else { - pos = (long long) (position - anim->preseek) - * AV_TIME_BASE / frame_rate; + pos = (long long) (position - anim->preseek) * + AV_TIME_BASE / frame_rate; av_log(anim->pFormatCtx, AV_LOG_DEBUG, "NO INDEX seek pos = %lld, st_time = %lld\n", diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 3095f5639fe..d823df11e36 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -68,9 +68,8 @@ static int tc_types[] = { IMB_TC_RECORD_RUN, anim_index_builder * IMB_index_builder_create(const char * name) { - anim_index_builder * rv - = MEM_callocN(sizeof(struct anim_index_builder), - "index builder"); + anim_index_builder * rv = MEM_callocN(sizeof(struct anim_index_builder), + "index builder"); fprintf(stderr, "Starting work on index: %s\n", name); @@ -182,17 +181,17 @@ struct anim_index * IMB_indexer_open(const char * name) fseek(fp, 0, SEEK_END); - idx->num_entries = (ftell(fp) - 12) - / (sizeof(int) // framepos - + sizeof(unsigned long long) // seek_pos - + sizeof(unsigned long long) // seek_pos_dts - + sizeof(unsigned long long) // pts - ); + idx->num_entries = (ftell(fp) - 12) / + (sizeof(int) + // framepos + sizeof(unsigned long long) + // seek_pos + sizeof(unsigned long long) + // seek_pos_dts + sizeof(unsigned long long) // pts + ); fseek(fp, 12, SEEK_SET); - idx->entries = MEM_callocN(sizeof(struct anim_index_entry) - * idx->num_entries, "anim_index_entries"); + idx->entries = MEM_callocN(sizeof(struct anim_index_entry) * + idx->num_entries, "anim_index_entries"); for (i = 0; i < idx->num_entries; i++) { fread(&idx->entries[i].frameno, @@ -260,7 +259,7 @@ int IMB_indexer_get_frame_index(struct anim_index * idx, int frameno) if (idx->entries[middle].frameno < frameno) { first = middle; - ++first; + first++; len = len - half - 1; } else { @@ -301,9 +300,8 @@ int IMB_indexer_can_scan(struct anim_index * idx, { /* makes only sense, if it is the same I-Frame and we are not * trying to run backwards in time... */ - return (IMB_indexer_get_seek_pos(idx, old_frame_index) - == IMB_indexer_get_seek_pos(idx, new_frame_index) && - old_frame_index < new_frame_index); + return (IMB_indexer_get_seek_pos(idx, old_frame_index) == IMB_indexer_get_seek_pos(idx, new_frame_index) && + old_frame_index < new_frame_index); } void IMB_indexer_close(struct anim_index * idx) @@ -515,9 +513,9 @@ static struct proxy_output_ctx * alloc_proxy_output_ffmpeg( rv->c->pix_fmt = PIX_FMT_YUVJ420P; } - rv->c->sample_aspect_ratio - = rv->st->sample_aspect_ratio - = st->codec->sample_aspect_ratio; + rv->c->sample_aspect_ratio = + rv->st->sample_aspect_ratio = + st->codec->sample_aspect_ratio; rv->c->time_base.den = 25; rv->c->time_base.num = 1; @@ -755,8 +753,7 @@ static IndexBuildContext *index_ffmpeg_create_context(struct anim *anim, IMB_Tim /* Find the video stream */ context->videoStream = -1; for (i = 0; i < context->iFormatCtx->nb_streams; i++) - if (context->iFormatCtx->streams[i]->codec->codec_type - == AVMEDIA_TYPE_VIDEO) { + if (context->iFormatCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (streamcount > 0) { streamcount--; continue; @@ -895,8 +892,7 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, if (frame_finished) { unsigned long long s_pos = seek_pos; unsigned long long s_dts = seek_pos_dts; - unsigned long long pts - = av_get_pts_from_frame(context->iFormatCtx, in_frame); + unsigned long long pts = av_get_pts_from_frame(context->iFormatCtx, in_frame); for (i = 0; i < context->num_proxy_sizes; i++) { add_to_proxy_output_ffmpeg( @@ -908,8 +904,8 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context, start_pts_set = TRUE; } - frameno = floor((pts - start_pts) - * pts_time_base * frame_rate + 0.5f); + frameno = floor((pts - start_pts) * + pts_time_base * frame_rate + 0.5f); /* decoding starts *always* on I-Frames, so: P-Frames won't work, even if all the diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 50bc55da412..93a5f8eca7c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -719,41 +719,55 @@ void IMB_exr_close(void *handle) /* ********* */ +/* get a substring from the end of the name, separated by '.' */ +static int imb_exr_split_token(const char *str, const char *end, const char **token) +{ + int maxlen = end-str; + int len = 0; + while (len < maxlen && *(end-len-1) != '.') + ++len; + + *token = end-len; + return len; +} + static int imb_exr_split_channel_name(ExrChannel *echan, char *layname, char *passname) { - int plen, len= strlen(echan->name); + const char *name = echan->name; + const char *end = name + strlen(name); + const char *token; + char tokenbuf[EXR_TOT_MAXNAME]; + int len; - if (len < 4) { - printf("multilayer read: name too short: %s\n", echan->name); + /* last token is single character channel identifier */ + len = imb_exr_split_token(name, end, &token); + if (len == 0) { + printf("multilayer read: bad channel name: %s\n", name); return 0; } - if (echan->name[len-2]!='.') { - printf("multilayer read: name has no Channel: %s\n", echan->name); + else if (len > 1) { + BLI_strncpy(tokenbuf, token, len); + printf("multilayer read: channel token too long: %s\n", tokenbuf); return 0; } - echan->chan_id= echan->name[len-1]; + echan->chan_id = token[0]; + end -= len + 1; /* +1 to skip '.' separator */ - len-= 3; - while (len>=0) { - if (echan->name[len]=='.') - break; - len--; - } - BLI_strncpy(passname, echan->name+len+1, EXR_PASS_MAXNAME); - plen= strlen(passname); - if (plen < 3) { - printf("multilayer read: should not happen: %s\n", echan->name); + /* second token is pass name */ + len = imb_exr_split_token(name, end, &token); + if (len == 0) { + printf("multilayer read: bad channel name: %s\n", name); return 0; } - passname[plen-2]= 0; + BLI_strncpy(passname, token, len+1); + end -= len + 1; /* +1 to skip '.' separator */ + + /* all preceding tokens combined as layer name */ + if (end > name) + BLI_strncpy(layname, name, (int)(end-name)+1); + else + layname[0] = '\0'; - if (len<1) - layname[0]= 0; - else { - BLI_strncpy(layname, echan->name, EXR_LAY_MAXNAME); - layname[len]= 0; - } - // printf("found lay %s pass %s chan %c\n", layname, passname, echan->chan_id); return 1; } diff --git a/source/blender/imbuf/intern/png.c b/source/blender/imbuf/intern/png.c index 0a19bf1280b..35a44635727 100644 --- a/source/blender/imbuf/intern/png.c +++ b/source/blender/imbuf/intern/png.c @@ -27,13 +27,14 @@ /** \file blender/imbuf/intern/png.c * \ingroup imbuf + * + * \todo Save floats as 16 bits per channel, currently readonly. */ - - #include "png.h" #include "BLI_blenlib.h" +#include "BLI_math.h" #include "MEM_guardedalloc.h" #include "imbuf.h" @@ -83,7 +84,7 @@ static void WriteData(png_structp png_ptr, png_bytep data, png_size_t length) static void ReadData(png_structp png_ptr, png_bytep data, png_size_t length) { - PNGReadStruct *rs= (PNGReadStruct *) png_get_io_ptr(png_ptr); + PNGReadStruct *rs = (PNGReadStruct *) png_get_io_ptr(png_ptr); if (rs) { if (length <= rs->size - rs->seek) { @@ -110,12 +111,12 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) /* use the jpeg quality setting for compression */ int compression; - compression= (int)(((float)(ibuf->ftype & 0xff) / 11.1111f)); - compression= compression < 0 ? 0 : (compression > 9 ? 9 : compression); + compression = (int)(((float)(ibuf->ftype & 0xff) / 11.1111f)); + compression = compression < 0 ? 0 : (compression > 9 ? 9 : compression); /* for prints */ if (flags & IB_mem) - name= ""; + name = ""; bytesperpixel = (ibuf->planes + 7) >> 3; if ((bytesperpixel > 4) || (bytesperpixel == 2)) { @@ -124,7 +125,7 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) } png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); + NULL, NULL, NULL); if (png_ptr == NULL) { printf("imb_savepng: Cannot png_create_write_struct for file: '%s'\n", name); return 0; @@ -156,32 +157,32 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) to = pixels; switch (bytesperpixel) { - case 4: - color_type = PNG_COLOR_TYPE_RGBA; - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - to[3] = from[3]; - to += 4; from += 4; - } - break; - case 3: - color_type = PNG_COLOR_TYPE_RGB; - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - to += 3; from += 4; - } - break; - case 1: - color_type = PNG_COLOR_TYPE_GRAY; - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = from[0]; - to++; from += 4; - } - break; + case 4: + color_type = PNG_COLOR_TYPE_RGBA; + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + to[3] = from[3]; + to += 4; from += 4; + } + break; + case 3: + color_type = PNG_COLOR_TYPE_RGB; + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + to += 3; from += 4; + } + break; + case 1: + color_type = PNG_COLOR_TYPE_GRAY; + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = from[0]; + to++; from += 4; + } + break; } if (flags & IB_mem) { @@ -207,11 +208,11 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) #if 0 png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| + PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | + PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | + PNG_FILTER_UP | PNG_FILTER_VALUE_UP | + PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | + PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH | PNG_ALL_FILTERS); #endif @@ -230,16 +231,16 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) /* image text info */ if (ibuf->metadata) { - png_text* metadata; - ImMetaData* iptr; - int num_text = 0; + png_text *metadata; + ImMetaData *iptr; + int num_text = 0; iptr = ibuf->metadata; while (iptr) { num_text++; iptr = iptr->next; } - metadata = MEM_callocN(num_text*sizeof(png_text), "png_metadata"); + metadata = MEM_callocN(num_text * sizeof(png_text), "png_metadata"); iptr = ibuf->metadata; num_text = 0; while (iptr) { @@ -277,8 +278,8 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) // set the individual row-pointers to point at the correct offsets for (i = 0; i < ibuf->y; i++) { - row_pointers[ibuf->y-1-i] = (png_bytep) - ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); + row_pointers[ibuf->y - 1 - i] = (png_bytep) + ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } // write out the entire image data in one call @@ -300,24 +301,27 @@ int imb_savepng(struct ImBuf *ibuf, const char *name, int flags) return(1); } -struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) -{ +struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags){ struct ImBuf *ibuf = NULL; png_structp png_ptr; png_infop info_ptr; unsigned char *pixels = NULL; + unsigned short *pixels16 = NULL; png_bytepp row_pointers = NULL; png_uint_32 width, height; int bit_depth, color_type; PNGReadStruct ps; unsigned char *from, *to; + unsigned short *from16; + float *to_float; + float tmp[4]; int i, bytesperpixel; if (imb_is_a_png(mem) == 0) return(NULL); png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, - NULL, NULL, NULL); + NULL, NULL, NULL); if (png_ptr == NULL) { printf("Cannot png_create_read_struct\n"); return NULL; @@ -326,7 +330,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) info_ptr = png_create_info_struct(png_ptr); if (info_ptr == NULL) { png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); + (png_infopp)NULL); printf("Cannot png_create_info_struct\n"); return NULL; } @@ -340,6 +344,7 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); if (pixels) MEM_freeN(pixels); + if (pixels16) MEM_freeN(pixels16); if (row_pointers) MEM_freeN(row_pointers); if (ibuf) IMB_freeImBuf(ibuf); return NULL; @@ -349,55 +354,53 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) png_read_info(png_ptr, info_ptr); png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, - &color_type, NULL, NULL, NULL); - - if (bit_depth == 16) { - png_set_strip_16(png_ptr); - bit_depth = 8; - } + &color_type, NULL, NULL, NULL); bytesperpixel = png_get_channels(png_ptr, info_ptr); switch (color_type) { - case PNG_COLOR_TYPE_RGB: - case PNG_COLOR_TYPE_RGB_ALPHA: - break; - case PNG_COLOR_TYPE_PALETTE: - png_set_palette_to_rgb(png_ptr); - if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { - bytesperpixel = 4; - } - else { - bytesperpixel = 3; - } - break; - case PNG_COLOR_TYPE_GRAY: - case PNG_COLOR_TYPE_GRAY_ALPHA: - if (bit_depth < 8) { - png_set_expand(png_ptr); - bit_depth = 8; - } - break; - default: - printf("PNG format not supported\n"); - longjmp(png_jmpbuf(png_ptr), 1); + case PNG_COLOR_TYPE_RGB: + case PNG_COLOR_TYPE_RGB_ALPHA: + break; + case PNG_COLOR_TYPE_PALETTE: + png_set_palette_to_rgb(png_ptr); + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) { + bytesperpixel = 4; + } + else { + bytesperpixel = 3; + } + break; + case PNG_COLOR_TYPE_GRAY: + case PNG_COLOR_TYPE_GRAY_ALPHA: + if (bit_depth < 8) { + png_set_expand(png_ptr); + bit_depth = 8; + } + break; + default: + printf("PNG format not supported\n"); + longjmp(png_jmpbuf(png_ptr), 1); } ibuf = IMB_allocImBuf(width, height, 8 * bytesperpixel, 0); if (ibuf) { ibuf->ftype = PNG; - ibuf->profile = IB_PROFILE_SRGB; + if (bit_depth == 16) + ibuf->profile = IB_PROFILE_LINEAR_RGB; + else + ibuf->profile = IB_PROFILE_SRGB; - if (png_get_valid (png_ptr, info_ptr, PNG_INFO_pHYs)) { + if (png_get_valid(png_ptr, info_ptr, PNG_INFO_pHYs)) { int unit_type; png_uint_32 xres, yres; if (png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type)) - if (unit_type == PNG_RESOLUTION_METER) { - ibuf->ppm[0]= xres; - ibuf->ppm[1]= yres; - } + if (unit_type == PNG_RESOLUTION_METER) { + ibuf->ppm[0] = xres; + ibuf->ppm[1] = yres; + } } } else { @@ -405,83 +408,157 @@ struct ImBuf *imb_loadpng(unsigned char *mem, size_t size, int flags) } if (ibuf && ((flags & IB_test) == 0)) { - imb_addrectImBuf(ibuf); + if (bit_depth == 16) { + imb_addrectfloatImBuf(ibuf); + png_set_swap(png_ptr); - pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); - if (pixels == NULL) { - printf("Cannot allocate pixels array\n"); - longjmp(png_jmpbuf(png_ptr), 1); + pixels16 = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(png_uint_16), "pixels"); + if (pixels16 == NULL) { + printf("Cannot allocate pixels array\n"); + longjmp(png_jmpbuf(png_ptr), 1); + } + + // allocate memory for an array of row-pointers + row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_uint_16p), "row_pointers"); + if (row_pointers == NULL) { + printf("Cannot allocate row-pointers array\n"); + longjmp(png_jmpbuf(png_ptr), 1); + } + + // set the individual row-pointers to point at the correct offsets + for (i = 0; i < ibuf->y; i++) { + row_pointers[ibuf->y - 1 - i] = (png_bytep) + ((png_uint_16 *)pixels16 + (i * ibuf->x) * bytesperpixel); + } + + png_read_image(png_ptr, row_pointers); + + // copy image data + + to_float = ibuf->rect_float; + from16 = pixels16; + + switch (bytesperpixel) { + case 4: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + tmp[0] = from16[0] / 65535.0; + tmp[1] = from16[1] / 65535.0; + tmp[2] = from16[2] / 65535.0; + tmp[3] = from16[3] / 65535.0; + srgb_to_linearrgb_v4(to_float, tmp); + to_float += 4; from16 += 4; + } + break; + case 3: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + tmp[0] = from16[0] / 65535.0; + tmp[1] = from16[1] / 65535.0; + tmp[2] = from16[2] / 65535.0; + tmp[3] = 1.0; + srgb_to_linearrgb_v4(to_float, tmp); + to_float += 4; from16 += 3; + } + break; + case 2: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0; + tmp[3] = from16[1] / 65535.0; + srgb_to_linearrgb_v4(to_float, tmp); + to_float += 4; from16 += 2; + } + break; + case 1: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + tmp[0] = tmp[1] = tmp[2] = from16[0] / 65535.0; + tmp[3] = 1.0; + srgb_to_linearrgb_v4(to_float, tmp); + to_float += 4; from16++; + } + break; + } } + else { + imb_addrectImBuf(ibuf); - // allocate memory for an array of row-pointers - row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); - if (row_pointers == NULL) { - printf("Cannot allocate row-pointers array\n"); - longjmp(png_jmpbuf(png_ptr), 1); - } - - // set the individual row-pointers to point at the correct offsets - for (i = 0; i < ibuf->y; i++) { - row_pointers[ibuf->y-1-i] = (png_bytep) - ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); - } - - png_read_image(png_ptr, row_pointers); - - // copy image data - - to = (unsigned char *) ibuf->rect; - from = pixels; - - switch (bytesperpixel) { - case 4: - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - to[3] = from[3]; - to += 4; from += 4; + pixels = MEM_mallocN(ibuf->x * ibuf->y * bytesperpixel * sizeof(unsigned char), "pixels"); + if (pixels == NULL) { + printf("Cannot allocate pixels array\n"); + longjmp(png_jmpbuf(png_ptr), 1); } - break; - case 3: - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = from[0]; - to[1] = from[1]; - to[2] = from[2]; - to[3] = 0xff; - to += 4; from += 3; + + // allocate memory for an array of row-pointers + row_pointers = (png_bytepp) MEM_mallocN(ibuf->y * sizeof(png_bytep), "row_pointers"); + if (row_pointers == NULL) { + printf("Cannot allocate row-pointers array\n"); + longjmp(png_jmpbuf(png_ptr), 1); } - break; - case 2: - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = to[1] = to[2] = from[0]; - to[3] = from[1]; - to += 4; from += 2; + + // set the individual row-pointers to point at the correct offsets + for (i = 0; i < ibuf->y; i++) { + row_pointers[ibuf->y - 1 - i] = (png_bytep) + ((unsigned char *)pixels + (i * ibuf->x) * bytesperpixel * sizeof(unsigned char)); } - break; - case 1: - for (i = ibuf->x * ibuf->y; i > 0; i--) { - to[0] = to[1] = to[2] = from[0]; - to[3] = 0xff; - to += 4; from++; + + png_read_image(png_ptr, row_pointers); + + // copy image data + + to = (unsigned char *) ibuf->rect; + from = pixels; + + switch (bytesperpixel) { + case 4: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + to[3] = from[3]; + to += 4; from += 4; + } + break; + case 3: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = from[0]; + to[1] = from[1]; + to[2] = from[2]; + to[3] = 0xff; + to += 4; from += 3; + } + break; + case 2: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = to[1] = to[2] = from[0]; + to[3] = from[1]; + to += 4; from += 2; + } + break; + case 1: + for (i = ibuf->x * ibuf->y; i > 0; i--) { + to[0] = to[1] = to[2] = from[0]; + to[3] = 0xff; + to += 4; from++; + } + break; } - break; } if (flags & IB_metadata) { - png_text* text_chunks; + png_text *text_chunks; int count = png_get_text(png_ptr, info_ptr, &text_chunks, NULL); for (i = 0; i < count; i++) { IMB_metadata_add_field(ibuf, text_chunks[i].key, text_chunks[i].text); - ibuf->flags |= IB_metadata; - } + ibuf->flags |= IB_metadata; + } } png_read_end(png_ptr, info_ptr); } // clean up - MEM_freeN(pixels); + if (pixels) + MEM_freeN(pixels); + if (pixels16) + MEM_freeN(pixels16); MEM_freeN(row_pointers); png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL); diff --git a/source/blender/imbuf/intern/rectop.c b/source/blender/imbuf/intern/rectop.c index 9f025803c2e..2d765c7d6a1 100644 --- a/source/blender/imbuf/intern/rectop.c +++ b/source/blender/imbuf/intern/rectop.c @@ -49,55 +49,55 @@ static void blend_color_mix(char *cp, char *cp1, char *cp2, int fac) /* this and other blending modes previously used >>8 instead of /255. both * are not equivalent (>>8 is /256), and the former results in rounding * errors that can turn colors black fast after repeated blending */ - int mfac= 255-fac; + int mfac = 255 - fac; - cp[0]= (mfac*cp1[0]+fac*cp2[0])/255; - cp[1]= (mfac*cp1[1]+fac*cp2[1])/255; - cp[2]= (mfac*cp1[2]+fac*cp2[2])/255; + cp[0] = (mfac * cp1[0] + fac * cp2[0]) / 255; + cp[1] = (mfac * cp1[1] + fac * cp2[1]) / 255; + cp[2] = (mfac * cp1[2] + fac * cp2[2]) / 255; } static void blend_color_add(char *cp, char *cp1, char *cp2, int fac) { int temp; - temp= cp1[0] + ((fac*cp2[0])/255); - if (temp>254) cp[0]= 255; else cp[0]= temp; - temp= cp1[1] + ((fac*cp2[1])/255); - if (temp>254) cp[1]= 255; else cp[1]= temp; - temp= cp1[2] + ((fac*cp2[2])/255); - if (temp>254) cp[2]= 255; else cp[2]= temp; + temp = cp1[0] + ((fac * cp2[0]) / 255); + if (temp > 254) cp[0] = 255; else cp[0] = temp; + temp = cp1[1] + ((fac * cp2[1]) / 255); + if (temp > 254) cp[1] = 255; else cp[1] = temp; + temp = cp1[2] + ((fac * cp2[2]) / 255); + if (temp > 254) cp[2] = 255; else cp[2] = temp; } static void blend_color_sub(char *cp, char *cp1, char *cp2, int fac) { int temp; - temp= cp1[0] - ((fac*cp2[0])/255); - if (temp<0) cp[0]= 0; else cp[0]= temp; - temp= cp1[1] - ((fac*cp2[1])/255); - if (temp<0) cp[1]= 0; else cp[1]= temp; - temp= cp1[2] - ((fac*cp2[2])/255); - if (temp<0) cp[2]= 0; else cp[2]= temp; + temp = cp1[0] - ((fac * cp2[0]) / 255); + if (temp < 0) cp[0] = 0; else cp[0] = temp; + temp = cp1[1] - ((fac * cp2[1]) / 255); + if (temp < 0) cp[1] = 0; else cp[1] = temp; + temp = cp1[2] - ((fac * cp2[2]) / 255); + if (temp < 0) cp[2] = 0; else cp[2] = temp; } static void blend_color_mul(char *cp, char *cp1, char *cp2, int fac) { - int mfac= 255-fac; + int mfac = 255 - fac; /* first mul, then blend the fac */ - cp[0]= (mfac*cp1[0] + fac*((cp1[0]*cp2[0])/255))/255; - cp[1]= (mfac*cp1[1] + fac*((cp1[1]*cp2[1])/255))/255; - cp[2]= (mfac*cp1[2] + fac*((cp1[2]*cp2[2])/255))/255; + cp[0] = (mfac * cp1[0] + fac * ((cp1[0] * cp2[0]) / 255)) / 255; + cp[1] = (mfac * cp1[1] + fac * ((cp1[1] * cp2[1]) / 255)) / 255; + cp[2] = (mfac * cp1[2] + fac * ((cp1[2] * cp2[2]) / 255)) / 255; } static void blend_color_lighten(char *cp, char *cp1, char *cp2, int fac) { /* See if are lighter, if so mix, else don't do anything. * if the paint col is darker then the original, then ignore */ - if (cp1[0]+cp1[1]+cp1[2] > cp2[0]+cp2[1]+cp2[2]) { - cp[0]= cp1[0]; - cp[1]= cp1[1]; - cp[2]= cp1[2]; + if (cp1[0] + cp1[1] + cp1[2] > cp2[0] + cp2[1] + cp2[2]) { + cp[0] = cp1[0]; + cp[1] = cp1[1]; + cp[2] = cp1[2]; } else blend_color_mix(cp, cp1, cp2, fac); @@ -107,10 +107,10 @@ static void blend_color_darken(char *cp, char *cp1, char *cp2, int fac) { /* See if were darker, if so mix, else don't do anything. * if the paint col is brighter then the original, then ignore */ - if (cp1[0]+cp1[1]+cp1[2] < cp2[0]+cp2[1]+cp2[2]) { - cp[0]= cp1[0]; - cp[1]= cp1[1]; - cp[2]= cp1[2]; + if (cp1[0] + cp1[1] + cp1[2] < cp2[0] + cp2[1] + cp2[2]) { + cp[0] = cp1[0]; + cp[1] = cp1[1]; + cp[2] = cp1[2]; } else blend_color_mix(cp, cp1, cp2, fac); @@ -122,12 +122,12 @@ unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, IMB_ int temp; char *cp, *cp1, *cp2; - if (fac==0) + if (fac == 0) return src1; - cp = (char*)&dst; - cp1 = (char*)&src1; - cp2 = (char*)&src2; + cp = (char *)&dst; + cp1 = (char *)&src1; + cp2 = (char *)&src2; switch (mode) { case IMB_BLEND_MIX: @@ -143,18 +143,18 @@ unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, IMB_ case IMB_BLEND_DARKEN: blend_color_darken(cp, cp1, cp2, fac); break; default: - cp[0]= cp1[0]; - cp[1]= cp1[1]; - cp[2]= cp1[2]; + cp[0] = cp1[0]; + cp[1] = cp1[1]; + cp[2] = cp1[2]; } if (mode == IMB_BLEND_ERASE_ALPHA) { - temp= (cp1[3] - fac*cp2[3]/255); - cp[3]= (temp < 0)? 0: temp; + temp = (cp1[3] - fac * cp2[3] / 255); + cp[3] = (temp < 0) ? 0 : temp; } else { /* this does ADD_ALPHA also */ - temp= (cp1[3] + fac*cp2[3]/255); - cp[3]= (temp > 255)? 255: temp; + temp = (cp1[3] + fac * cp2[3] / 255); + cp[3] = (temp > 255) ? 255 : temp; } return dst; @@ -162,51 +162,51 @@ unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, IMB_ static void blend_color_mix_float(float *cp, float *cp1, float *cp2, float fac) { - float mfac= 1.0f-fac; - cp[0]= mfac*cp1[0] + fac*cp2[0]; - cp[1]= mfac*cp1[1] + fac*cp2[1]; - cp[2]= mfac*cp1[2] + fac*cp2[2]; + float mfac = 1.0f - fac; + cp[0] = mfac * cp1[0] + fac * cp2[0]; + cp[1] = mfac * cp1[1] + fac * cp2[1]; + cp[2] = mfac * cp1[2] + fac * cp2[2]; } static void blend_color_add_float(float *cp, float *cp1, float *cp2, float fac) { - cp[0] = cp1[0] + fac*cp2[0]; - cp[1] = cp1[1] + fac*cp2[1]; - cp[2] = cp1[2] + fac*cp2[2]; + cp[0] = cp1[0] + fac * cp2[0]; + cp[1] = cp1[1] + fac * cp2[1]; + cp[2] = cp1[2] + fac * cp2[2]; - if (cp[0] > 1.0f) cp[0]= 1.0f; - if (cp[1] > 1.0f) cp[1]= 1.0f; - if (cp[2] > 1.0f) cp[2]= 1.0f; + if (cp[0] > 1.0f) cp[0] = 1.0f; + if (cp[1] > 1.0f) cp[1] = 1.0f; + if (cp[2] > 1.0f) cp[2] = 1.0f; } static void blend_color_sub_float(float *cp, float *cp1, float *cp2, float fac) { - cp[0] = cp1[0] - fac*cp2[0]; - cp[1] = cp1[1] - fac*cp2[1]; - cp[2] = cp1[2] - fac*cp2[2]; + cp[0] = cp1[0] - fac * cp2[0]; + cp[1] = cp1[1] - fac * cp2[1]; + cp[2] = cp1[2] - fac * cp2[2]; - if (cp[0] < 0.0f) cp[0]= 0.0f; - if (cp[1] < 0.0f) cp[1]= 0.0f; - if (cp[2] < 0.0f) cp[2]= 0.0f; + if (cp[0] < 0.0f) cp[0] = 0.0f; + if (cp[1] < 0.0f) cp[1] = 0.0f; + if (cp[2] < 0.0f) cp[2] = 0.0f; } static void blend_color_mul_float(float *cp, float *cp1, float *cp2, float fac) { - float mfac= 1.0f-fac; + float mfac = 1.0f - fac; - cp[0]= mfac*cp1[0] + fac*(cp1[0]*cp2[0]); - cp[1]= mfac*cp1[1] + fac*(cp1[1]*cp2[1]); - cp[2]= mfac*cp1[2] + fac*(cp1[2]*cp2[2]); + cp[0] = mfac * cp1[0] + fac * (cp1[0] * cp2[0]); + cp[1] = mfac * cp1[1] + fac * (cp1[1] * cp2[1]); + cp[2] = mfac * cp1[2] + fac * (cp1[2] * cp2[2]); } static void blend_color_lighten_float(float *cp, float *cp1, float *cp2, float fac) { /* See if are lighter, if so mix, else don't do anything. * if the pafloat col is darker then the original, then ignore */ - if (cp1[0]+cp1[1]+cp1[2] > cp2[0]+cp2[1]+cp2[2]) { - cp[0]= cp1[0]; - cp[1]= cp1[1]; - cp[2]= cp1[2]; + if (cp1[0] + cp1[1] + cp1[2] > cp2[0] + cp2[1] + cp2[2]) { + cp[0] = cp1[0]; + cp[1] = cp1[1]; + cp[2] = cp1[2]; } else blend_color_mix_float(cp, cp1, cp2, fac); @@ -216,10 +216,10 @@ static void blend_color_darken_float(float *cp, float *cp1, float *cp2, float fa { /* See if were darker, if so mix, else don't do anything. * if the pafloat col is brighter then the original, then ignore */ - if (cp1[0]+cp1[1]+cp1[2] < cp2[0]+cp2[1]+cp2[2]) { - cp[0]= cp1[0]; - cp[1]= cp1[1]; - cp[2]= cp1[2]; + if (cp1[0] + cp1[1] + cp1[2] < cp2[0] + cp2[1] + cp2[2]) { + cp[0] = cp1[0]; + cp[1] = cp1[1]; + cp[2] = cp1[2]; } else blend_color_mix_float(cp, cp1, cp2, fac); @@ -227,11 +227,11 @@ static void blend_color_darken_float(float *cp, float *cp1, float *cp2, float fa void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac, IMB_BlendMode mode) { - if (fac==0) { - dst[0]= src1[0]; - dst[1]= src1[1]; - dst[2]= src1[2]; - dst[3]= src1[3]; + if (fac == 0) { + dst[0] = src1[0]; + dst[1] = src1[1]; + dst[2] = src1[2]; + dst[3] = src1[3]; return; } @@ -249,17 +249,17 @@ void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac, IMB_ case IMB_BLEND_DARKEN: blend_color_darken_float(dst, src1, src2, fac); break; default: - dst[0]= src1[0]; - dst[1]= src1[1]; - dst[2]= src1[2]; + dst[0] = src1[0]; + dst[1] = src1[1]; + dst[2] = src1[2]; } if (mode == IMB_BLEND_ERASE_ALPHA) { - dst[3]= (src1[3] - fac*src2[3]); + dst[3] = (src1[3] - fac * src2[3]); if (dst[3] < 0.0f) dst[3] = 0.0f; } else { /* this does ADD_ALPHA also */ - dst[3]= (src1[3] + fac*src2[3]); + dst[3] = (src1[3] + fac * src2[3]); if (dst[3] > 1.0f) dst[3] = 1.0f; } } @@ -267,7 +267,7 @@ void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac, IMB_ /* clipping */ void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx, - int *desty, int *srcx, int *srcy, int *width, int *height) + int *desty, int *srcx, int *srcy, int *width, int *height) { int tmp; @@ -315,14 +315,14 @@ void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx, /* copy and blend */ void IMB_rectcpy(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, - int desty, int srcx, int srcy, int width, int height) + int desty, int srcx, int srcy, int width, int height) { IMB_rectblend(dbuf, sbuf, destx, desty, srcx, srcy, width, height, - IMB_BLEND_COPY); + IMB_BLEND_COPY); } void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, - int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode) + int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode) { unsigned int *drect = NULL, *srect = NULL, *dr, *sr; float *drectf = NULL, *srectf = NULL, *drf, *srf; @@ -333,20 +333,20 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, IMB_rectclip(dbuf, sbuf, &destx, &desty, &srcx, &srcy, &width, &height); if (width == 0 || height == 0) return; - if (sbuf && sbuf->channels!=4) return; - if (dbuf->channels!=4) return; + if (sbuf && sbuf->channels != 4) return; + if (dbuf->channels != 4) return; do_char = (sbuf && sbuf->rect && dbuf->rect); do_float = (sbuf && sbuf->rect_float && dbuf->rect_float); if (do_char) drect = dbuf->rect + desty * dbuf->x + destx; - if (do_float) drectf = dbuf->rect_float + (desty * dbuf->x + destx)*4; + if (do_float) drectf = dbuf->rect_float + (desty * dbuf->x + destx) * 4; destskip = dbuf->x; if (sbuf) { if (do_char) srect = sbuf->rect + srcy * sbuf->x + srcx; - if (do_float) srectf = sbuf->rect_float + (srcy * sbuf->x + srcx)*4; + if (do_float) srectf = sbuf->rect_float + (srcy * sbuf->x + srcx) * 4; srcskip = sbuf->x; } else { @@ -357,7 +357,7 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, if (mode == IMB_BLEND_COPY) { /* copy */ - for (;height > 0; height--) { + for (; height > 0; height--) { if (do_char) { memcpy(drect, srect, width * sizeof(int)); drect += destskip; @@ -366,21 +366,21 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, if (do_float) { memcpy(drectf, srectf, width * sizeof(float) * 4); - drectf += destskip*4; - srectf += srcskip*4; + drectf += destskip * 4; + srectf += srcskip * 4; } } } else if (mode == IMB_BLEND_COPY_RGB) { /* copy rgb only */ - for (;height > 0; height--) { + for (; height > 0; height--) { if (do_char) { dr = drect; sr = srect; - for (x=width; x > 0; x--, dr++, sr++) { - ((char*)dr)[0]= ((char*)sr)[0]; - ((char*)dr)[1]= ((char*)sr)[1]; - ((char*)dr)[2]= ((char*)sr)[2]; + for (x = width; x > 0; x--, dr++, sr++) { + ((char *)dr)[0] = ((char *)sr)[0]; + ((char *)dr)[1] = ((char *)sr)[1]; + ((char *)dr)[2] = ((char *)sr)[2]; } drect += destskip; srect += srcskip; @@ -389,24 +389,24 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, if (do_float) { drf = drectf; srf = srectf; - for (x=width; x > 0; x--, drf+=4, srf+=4) { - drf[0]= srf[0]; - drf[1]= srf[1]; - drf[2]= srf[2]; + for (x = width; x > 0; x--, drf += 4, srf += 4) { + drf[0] = srf[0]; + drf[1] = srf[1]; + drf[2] = srf[2]; } - drectf += destskip*4; - srectf += srcskip*4; + drectf += destskip * 4; + srectf += srcskip * 4; } } } else if (mode == IMB_BLEND_COPY_ALPHA) { /* copy alpha only */ - for (;height > 0; height--) { + for (; height > 0; height--) { if (do_char) { dr = drect; sr = srect; - for (x=width; x > 0; x--, dr++, sr++) - ((char*)dr)[3]= ((char*)sr)[3]; + for (x = width; x > 0; x--, dr++, sr++) + ((char *)dr)[3] = ((char *)sr)[3]; drect += destskip; srect += srcskip; } @@ -414,21 +414,21 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, if (do_float) { drf = drectf; srf = srectf; - for (x=width; x > 0; x--, drf+=4, srf+=4) - drf[3]= srf[3]; - drectf += destskip*4; - srectf += srcskip*4; + for (x = width; x > 0; x--, drf += 4, srf += 4) + drf[3] = srf[3]; + drectf += destskip * 4; + srectf += srcskip * 4; } } } else { /* blend */ - for (;height > 0; height--) { + for (; height > 0; height--) { if (do_char) { dr = drect; sr = srect; - for (x=width; x > 0; x--, dr++, sr++) - *dr = IMB_blend_color(*dr, *sr, ((char*)sr)[3], mode); + for (x = width; x > 0; x--, dr++, sr++) + *dr = IMB_blend_color(*dr, *sr, ((char *)sr)[3], mode); drect += destskip; srect += srcskip; @@ -437,11 +437,11 @@ void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, if (do_float) { drf = drectf; srf = srectf; - for (x=width; x > 0; x--, drf+=4, srf+=4) + for (x = width; x > 0; x--, drf += 4, srf += 4) IMB_blend_color_float(drf, drf, srf, srf[3], mode); - drectf += destskip*4; - srectf += srcskip*4; + drectf += destskip * 4; + srectf += srcskip * 4; } } } @@ -457,21 +457,21 @@ void IMB_rectfill(struct ImBuf *drect, const float col[4]) unsigned int *rrect = drect->rect; char ccol[4]; - ccol[0]= (int)(col[0]*255); - ccol[1]= (int)(col[1]*255); - ccol[2]= (int)(col[2]*255); - ccol[3]= (int)(col[3]*255); + ccol[0] = (int)(col[0] * 255); + ccol[1] = (int)(col[1] * 255); + ccol[2] = (int)(col[2] * 255); + ccol[3] = (int)(col[3] * 255); num = drect->x * drect->y; - for (;num > 0; num--) - *rrect++ = *((unsigned int*)ccol); + for (; num > 0; num--) + *rrect++ = *((unsigned int *)ccol); } if (drect->rect_float) { float *rrectf = drect->rect_float; num = drect->x * drect->y; - for (;num > 0; num--) { + for (; num > 0; num--) { *rrectf++ = col[0]; *rrectf++ = col[1]; *rrectf++ = col[2]; @@ -487,7 +487,7 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float a; /* alpha */ float ai; /* alpha inverted */ float aich; /* alpha, inverted, ai/255.0 - Convert char to float at the same time */ - if ((!rect && !rectf) || (!col) || col[3]==0.0f) + if ((!rect && !rectf) || (!col) || col[3] == 0.0f) return; /* sanity checks for coords */ @@ -496,20 +496,20 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, CLAMP(y1, 0, height); CLAMP(y2, 0, height); - if (x1>x2) SWAP(int, x1, x2); - if (y1>y2) SWAP(int, y1, y2); - if (x1==x2 || y1==y2) return; + if (x1 > x2) SWAP(int, x1, x2); + if (y1 > y2) SWAP(int, y1, y2); + if (x1 == x2 || y1 == y2) return; a = col[3]; - ai = 1-a; - aich = ai/255.0f; + ai = 1 - a; + aich = ai / 255.0f; if (rect) { unsigned char *pixel; - unsigned char chr=0, chg=0, chb=0; - float fr=0, fg=0, fb=0; + unsigned char chr = 0, chg = 0, chb = 0; + float fr = 0, fg = 0, fb = 0; - const int alphaint= FTOCHAR(a); + const int alphaint = FTOCHAR(a); if (a == 1.0f) { chr = FTOCHAR(col[0]); @@ -517,14 +517,14 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, chb = FTOCHAR(col[2]); } else { - fr = col[0]*a; - fg = col[1]*a; - fb = col[2]*a; + fr = col[0] * a; + fg = col[1] * a; + fb = col[2] * a; } - for (j = 0; j < y2-y1; j++) { - for (i = 0; i < x2-x1; i++) { + for (j = 0; j < y2 - y1; j++) { + for (i = 0; i < x2 - x1; i++) { pixel = rect + 4 * (((y1 + j) * width) + (x1 + i)); - if (pixel >= rect && pixel < rect+ (4 * (width * height))) { + if (pixel >= rect && pixel < rect + (4 * (width * height))) { if (a == 1.0f) { pixel[0] = chr; pixel[1] = chg; @@ -533,10 +533,10 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, } else { int alphatest; - pixel[0] = (char)((fr + ((float)pixel[0]*aich))*255.0f); - pixel[1] = (char)((fg + ((float)pixel[1]*aich))*255.0f); - pixel[2] = (char)((fb + ((float)pixel[2]*aich))*255.0f); - pixel[3] = (char)((alphatest= ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255); + pixel[0] = (char)((fr + ((float)pixel[0] * aich)) * 255.0f); + pixel[1] = (char)((fg + ((float)pixel[1] * aich)) * 255.0f); + pixel[2] = (char)((fb + ((float)pixel[2] * aich)) * 255.0f); + pixel[3] = (char)((alphatest = ((int)pixel[3] + alphaint)) < 255 ? alphatest : 255); } } } @@ -545,8 +545,8 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, if (rectf) { float *pixel; - for (j = 0; j < y2-y1; j++) { - for (i = 0; i < x2-x1; i++) { + for (j = 0; j < y2 - y1; j++) { + for (i = 0; i < x2 - x1; i++) { pixel = rectf + 4 * (((y1 + j) * width) + (x1 + i)); if (a == 1.0f) { pixel[0] = col[0]; @@ -556,10 +556,10 @@ void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, } else { float alphatest; - pixel[0] = (col[0]*a) + (pixel[0]*ai); - pixel[1] = (col[1]*a) + (pixel[1]*ai); - pixel[2] = (col[2]*a) + (pixel[2]*ai); - pixel[3] = (alphatest= (pixel[3] + a)) < 1.0f ? alphatest : 1.0f; + pixel[0] = (col[0] * a) + (pixel[0] * ai); + pixel[1] = (col[1] * a) + (pixel[1] * ai); + pixel[2] = (col[2] * a) + (pixel[2] * ai); + pixel[3] = (alphatest = (pixel[3] + a)) < 1.0f ? alphatest : 1.0f; } } } @@ -577,12 +577,12 @@ void IMB_rectfill_alpha(ImBuf *ibuf, const float value) { int i; if (ibuf->rect_float) { - float *fbuf= ibuf->rect_float + 3; - for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf+= 4) { *fbuf = value; } + float *fbuf = ibuf->rect_float + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, fbuf += 4) { *fbuf = value; } } else { - const unsigned char cvalue= value * 255; - unsigned char *cbuf= ((unsigned char *)ibuf->rect) + 3; - for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf+= 4) { *cbuf = cvalue; } + const unsigned char cvalue = value * 255; + unsigned char *cbuf = ((unsigned char *)ibuf->rect) + 3; + for (i = ibuf->x * ibuf->y; i > 0; i--, cbuf += 4) { *cbuf = cvalue; } } } diff --git a/source/blender/imbuf/intern/scaling.c b/source/blender/imbuf/intern/scaling.c index 7f5430dad8a..3ccb6739beb 100644 --- a/source/blender/imbuf/intern/scaling.c +++ b/source/blender/imbuf/intern/scaling.c @@ -367,10 +367,8 @@ static void enlarge_picture_byte( unsigned char* src, unsigned char* dst, int src_width, int src_height, int dst_width, int dst_height) { - double ratiox = (double) (dst_width - 1.0) - / (double) (src_width - 1.001); - double ratioy = (double) (dst_height - 1.0) - / (double) (src_height - 1.001); + double ratiox = (double) (dst_width - 1.0) / (double) (src_width - 1.001); + double ratioy = (double) (dst_height - 1.0) / (double) (src_height - 1.001); uintptr_t x_src, dx_src, x_dst; uintptr_t y_src, dy_src, y_dst; @@ -395,41 +393,25 @@ static void enlarge_picture_byte( unsigned long x = (x_src >> 16) * 4; - *dst++ = ((((line1[x] * weight1y) >> 16) - * weight1x) >> 16) - + ((((line2[x] * weight2y) >> 16) - * weight1x) >> 16) - + ((((line1[4 + x] * weight1y) >> 16) - * weight2x) >> 16) - + ((((line2[4 + x] * weight2y) >> 16) - * weight2x) >> 16); + *dst++ = ((((line1[x] * weight1y) >> 16) * weight1x) >> 16) + + ((((line2[x] * weight2y) >> 16) * weight1x) >> 16) + + ((((line1[4 + x] * weight1y) >> 16) * weight2x) >> 16) + + ((((line2[4 + x] * weight2y) >> 16) * weight2x) >> 16); - *dst++ = ((((line1[x + 1] * weight1y) >> 16) - * weight1x) >> 16) - + ((((line2[x + 1] * weight2y) >> 16) - * weight1x) >> 16) - + ((((line1[4 + x + 1] * weight1y) >> 16) - * weight2x) >> 16) - + ((((line2[4 + x + 1] * weight2y) >> 16) - * weight2x) >> 16); + *dst++ = ((((line1[x + 1] * weight1y) >> 16) * weight1x) >> 16) + + ((((line2[x + 1] * weight2y) >> 16) * weight1x) >> 16) + + ((((line1[4 + x + 1] * weight1y) >> 16) * weight2x) >> 16) + + ((((line2[4 + x + 1] * weight2y) >> 16) * weight2x) >> 16); - *dst++ = ((((line1[x + 2] * weight1y) >> 16) - * weight1x) >> 16) - + ((((line2[x + 2] * weight2y) >> 16) - * weight1x) >> 16) - + ((((line1[4 + x + 2] * weight1y) >> 16) - * weight2x) >> 16) - + ((((line2[4 + x + 2] * weight2y) >> 16) - * weight2x) >> 16); + *dst++ = ((((line1[x + 2] * weight1y) >> 16) * weight1x) >> 16) + + ((((line2[x + 2] * weight2y) >> 16) * weight1x) >> 16) + + ((((line1[4 + x + 2] * weight1y) >> 16) * weight2x) >> 16) + + ((((line2[4 + x + 2] * weight2y) >> 16) * weight2x) >> 16); - *dst++ = ((((line1[x + 3] * weight1y) >> 16) - * weight1x) >> 16) - + ((((line2[x + 3] * weight2y) >> 16) - * weight1x) >> 16) - + ((((line1[4 + x + 3] * weight1y) >> 16) - * weight2x) >> 16) - + ((((line2[4 + x + 3] * weight2y) >> 16) - * weight2x) >> 16); + *dst++ = ((((line1[x + 3] * weight1y) >> 16) * weight1x) >> 16) + + ((((line2[x + 3] * weight2y) >> 16) * weight1x) >> 16) + + ((((line1[4 + x + 3] * weight1y) >> 16) * weight2x) >> 16) + + ((((line2[4 + x + 3] * weight2y) >> 16) * weight2x) >> 16); x_src += dx_src; } @@ -578,10 +560,8 @@ static void enlarge_picture_float( float* src, float* dst, int src_width, int src_height, int dst_width, int dst_height) { - double ratiox = (double) (dst_width - 1.0) - / (double) (src_width - 1.001); - double ratioy = (double) (dst_height - 1.0) - / (double) (src_height - 1.001); + double ratiox = (double) (dst_width - 1.0) / (double) (src_width - 1.001); + double ratioy = (double) (dst_height - 1.0) / (double) (src_height - 1.001); uintptr_t x_dst; uintptr_t y_dst; double x_src, dx_src; @@ -613,25 +593,25 @@ static void enlarge_picture_float( uintptr_t x = ((int) x_src) * 4; - *dst++ = line1[x] * w11 - + line2[x] * w21 - + line1[4 + x] * w12 - + line2[4 + x] * w22; + *dst++ = line1[x] * w11 + + line2[x] * w21 + + line1[4 + x] * w12 + + line2[4 + x] * w22; - *dst++ = line1[x + 1] * w11 - + line2[x + 1] * w21 - + line1[4 + x + 1] * w12 - + line2[4 + x + 1] * w22; + *dst++ = line1[x + 1] * w11 + + line2[x + 1] * w21 + + line1[4 + x + 1] * w12 + + line2[4 + x + 1] * w22; - *dst++ = line1[x + 2] * w11 - + line2[x + 2] * w21 - + line1[4 + x + 2] * w12 - + line2[4 + x + 2] * w22; + *dst++ = line1[x + 2] * w11 + + line2[x + 2] * w21 + + line1[4 + x + 2] * w12 + + line2[4 + x + 2] * w22; - *dst++ = line1[x + 3] * w11 - + line2[x + 3] * w21 - + line1[4 + x + 3] * w12 - + line2[4 + x + 3] * w22; + *dst++ = line1[x + 3] * w11 + + line2[x + 3] * w21 + + line1[4 + x + 3] * w12 + + line2[4 + x + 3] * w22; x_src += dx_src; } diff --git a/source/blender/makesdna/DNA_action_types.h b/source/blender/makesdna/DNA_action_types.h index 9ca67372703..889f9cf47eb 100644 --- a/source/blender/makesdna/DNA_action_types.h +++ b/source/blender/makesdna/DNA_action_types.h @@ -335,7 +335,7 @@ typedef struct bPose { float ctime; /* local action time of this pose */ float stride_offset[3]; /* applied to object */ - float cyclic_offset[3]; /* result of match and cycles, applied in where_is_pose() */ + float cyclic_offset[3]; /* result of match and cycles, applied in BKE_pose_where_is() */ ListBase agroups; /* list of bActionGroups */ @@ -352,7 +352,7 @@ typedef struct bPose { /* Pose->flag */ typedef enum ePose_Flags { - /* results in armature_rebuild_pose being called */ + /* results in BKE_pose_rebuild being called */ POSE_RECALC = (1<<0), /* prevents any channel from getting overridden by anim from IPO */ POSE_LOCKED = (1<<1), @@ -362,7 +362,7 @@ typedef enum ePose_Flags { POSE_CONSTRAINTS_TIMEDEPEND = (1<<3), /* recalculate bone paths */ POSE_RECALCPATHS = (1<<4), - /* set by armature_rebuild_pose to give a chance to the IK solver to rebuild IK tree */ + /* set by BKE_pose_rebuild to give a chance to the IK solver to rebuild IK tree */ POSE_WAS_REBUILT = (1<<5), /* set by game_copy_pose to indicate that this pose is used in the game engine */ POSE_GAME_ENGINE = (1<<6) diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index c531225775a..0cef9aa03b7 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -45,56 +45,58 @@ struct MTex; struct Image; typedef struct BrushClone { - struct Image *image; /* image for clone tool */ - float offset[2]; /* offset of clone image from canvas */ - float alpha, pad; /* transparency for drawing of clone image */ + struct Image *image; /* image for clone tool */ + float offset[2]; /* offset of clone image from canvas */ + float alpha, pad; /* transparency for drawing of clone image */ } BrushClone; typedef struct Brush { ID id; struct BrushClone clone; - struct CurveMapping *curve; /* falloff curve */ + struct CurveMapping *curve; /* falloff curve */ struct MTex mtex; + struct Brush *toggle_brush; + struct ImBuf *icon_imbuf; PreviewImage *preview; char icon_filepath[1024]; /* 1024 = FILE_MAX */ float normal_weight; - short blend; /* blend mode */ - short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */ - float weight; /* brush weight */ - int size; /* brush diameter */ - int flag; /* general purpose flag */ - float jitter; /* jitter the position of the brush */ - int spacing; /* spacing of paint operations */ - int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ - float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ - float rate; /* paint operations / second (airbrush) */ + short blend; /* blend mode */ + short ob_mode; /* & with ob->mode to see if the brush is compatible, use for display only. */ + float weight; /* brush weight */ + int size; /* brush diameter */ + int flag; /* general purpose flag */ + float jitter; /* jitter the position of the brush */ + int spacing; /* spacing of paint operations */ + int smooth_stroke_radius; /* turning radius (in pixels) for smooth stroke */ + float smooth_stroke_factor; /* higher values limit fast changes in the stroke direction */ + float rate; /* paint operations / second (airbrush) */ - float rgb[3]; /* color */ - float alpha; /* opacity */ + float rgb[3]; /* color */ + float alpha; /* opacity */ - int sculpt_plane; /* the direction of movement for sculpt vertices */ + int sculpt_plane; /* the direction of movement for sculpt vertices */ - float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape) */ + float plane_offset; /* offset for plane brushes (clay, flatten, fill, scrape) */ - char sculpt_tool; /* active sculpt tool */ - char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */ - char imagepaint_tool; /* active image paint tool */ - char pad; + char sculpt_tool; /* active sculpt tool */ + char vertexpaint_tool; /* active vertex/weight paint blend mode (poorly named) */ + char imagepaint_tool; /* active image paint tool */ + char mask_tool; /* enum BrushMaskTool, only used if sculpt_tool is SCULPT_TOOL_MASK */ float autosmooth_factor; float crease_pinch_factor; float plane_trim; - float height; /* affectable height of brush (layer height for layer tool, i.e.) */ + float height; /* affectable height of brush (layer height for layer tool, i.e.) */ float texture_sample_bias; - int texture_overlay_alpha; + int texture_overlay_alpha; float unprojected_radius; @@ -104,38 +106,38 @@ typedef struct Brush { /* Brush.flag */ typedef enum BrushFlags { - BRUSH_AIRBRUSH = (1<<0), - BRUSH_TORUS = (1<<1), - BRUSH_ALPHA_PRESSURE = (1<<2), - BRUSH_SIZE_PRESSURE = (1<<3), - BRUSH_JITTER_PRESSURE = (1<<4), - BRUSH_SPACING_PRESSURE = (1<<5), - BRUSH_FIXED_TEX = (1<<6), - BRUSH_RAKE = (1<<7), - BRUSH_ANCHORED = (1<<8), - BRUSH_DIR_IN = (1<<9), - BRUSH_SPACE = (1<<10), - BRUSH_SMOOTH_STROKE = (1<<11), - BRUSH_PERSISTENT = (1<<12), - BRUSH_ACCUMULATE = (1<<13), - BRUSH_LOCK_ALPHA = (1<<14), - BRUSH_ORIGINAL_NORMAL = (1<<15), - BRUSH_OFFSET_PRESSURE = (1<<16), - BRUSH_SPACE_ATTEN = (1<<18), - BRUSH_ADAPTIVE_SPACE = (1<<19), - BRUSH_LOCK_SIZE = (1<<20), - BRUSH_TEXTURE_OVERLAY = (1<<21), - BRUSH_EDGE_TO_EDGE = (1<<22), - BRUSH_RESTORE_MESH = (1<<23), - BRUSH_INVERSE_SMOOTH_PRESSURE = (1<<24), - BRUSH_RANDOM_ROTATION = (1<<25), - BRUSH_PLANE_TRIM = (1<<26), - BRUSH_FRONTFACE = (1<<27), - BRUSH_CUSTOM_ICON = (1<<28), + BRUSH_AIRBRUSH = (1 << 0), + BRUSH_TORUS = (1 << 1), + BRUSH_ALPHA_PRESSURE = (1 << 2), + BRUSH_SIZE_PRESSURE = (1 << 3), + BRUSH_JITTER_PRESSURE = (1 << 4), + BRUSH_SPACING_PRESSURE = (1 << 5), + BRUSH_FIXED_TEX = (1 << 6), + BRUSH_RAKE = (1 << 7), + BRUSH_ANCHORED = (1 << 8), + BRUSH_DIR_IN = (1 << 9), + BRUSH_SPACE = (1 << 10), + BRUSH_SMOOTH_STROKE = (1 << 11), + BRUSH_PERSISTENT = (1 << 12), + BRUSH_ACCUMULATE = (1 << 13), + BRUSH_LOCK_ALPHA = (1 << 14), + BRUSH_ORIGINAL_NORMAL = (1 << 15), + BRUSH_OFFSET_PRESSURE = (1 << 16), + BRUSH_SPACE_ATTEN = (1 << 18), + BRUSH_ADAPTIVE_SPACE = (1 << 19), + BRUSH_LOCK_SIZE = (1 << 20), + BRUSH_TEXTURE_OVERLAY = (1 << 21), + BRUSH_EDGE_TO_EDGE = (1 << 22), + BRUSH_RESTORE_MESH = (1 << 23), + BRUSH_INVERSE_SMOOTH_PRESSURE = (1 << 24), + BRUSH_RANDOM_ROTATION = (1 << 25), + BRUSH_PLANE_TRIM = (1 << 26), + BRUSH_FRONTFACE = (1 << 27), + BRUSH_CUSTOM_ICON = (1 << 28), /* temporary flag which sets up automatically for correct brush * drawing when inverted modal operator is running */ - BRUSH_INVERTED = (1<<29) + BRUSH_INVERTED = (1 << 29) } BrushFlags; /* Brush.sculpt_tool */ @@ -160,14 +162,15 @@ typedef enum BrushSculptTool { SCULPT_TOOL_CREASE = 16, SCULPT_TOOL_BLOB = 17, - SCULPT_TOOL_CLAY_STRIPS = 18 + SCULPT_TOOL_CLAY_STRIPS = 18, + SCULPT_TOOL_MASK = 19 } BrushSculptTool; /* ImagePaintSettings.tool */ -#define PAINT_TOOL_DRAW 0 -#define PAINT_TOOL_SOFTEN 1 -#define PAINT_TOOL_SMEAR 2 -#define PAINT_TOOL_CLONE 3 +#define PAINT_TOOL_DRAW 0 +#define PAINT_TOOL_SOFTEN 1 +#define PAINT_TOOL_SMEAR 2 +#define PAINT_TOOL_CLONE 3 /* direction that the brush displaces along */ enum { @@ -188,6 +191,10 @@ enum { PAINT_BLEND_DARKEN }; +typedef enum { + BRUSH_MASK_DRAW, + BRUSH_MASK_SMOOTH +} BrushMaskTool; #define MAX_BRUSH_PIXEL_RADIUS 200 diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index acdd25a101e..da8458d587e 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -190,7 +190,7 @@ typedef struct Curve { short type; /* creation-time type of curve datablock */ - short texflag; /* keep a short because of give_obdata_texspace() */ + short texflag; /* keep a short because of BKE_object_obdata_texspace_get() */ short drawflag, twist_mode; float twist_smooth, smallcaps_scale; diff --git a/source/blender/makesdna/DNA_customdata_types.h b/source/blender/makesdna/DNA_customdata_types.h index 9898f9715a0..5792953fe49 100644 --- a/source/blender/makesdna/DNA_customdata_types.h +++ b/source/blender/makesdna/DNA_customdata_types.h @@ -63,7 +63,7 @@ typedef struct CustomDataExternal { * layers, each with a data type (e.g. MTFace, MDeformVert, etc.). */ typedef struct CustomData { CustomDataLayer *layers; /* CustomDataLayers, ordered by type */ - int typemap[34]; /* runtime only! - maps types to indices of first layer of that type, + int typemap[36]; /* runtime only! - maps types to indices of first layer of that type, * MUST be >= CD_NUMTYPES, but we cant use a define here. * Correct size is ensured in CustomData_update_typemap assert() */ @@ -112,7 +112,10 @@ typedef struct CustomData { #define CD_BM_ELEM_PYPTR 33 /* BMESH ONLY END */ -#define CD_NUMTYPES 34 +#define CD_PAINT_MASK 34 +#define CD_GRID_PAINT_MASK 35 + +#define CD_NUMTYPES 36 /* Bits for CustomDataMask */ #define CD_MASK_MVERT (1 << CD_MVERT) @@ -151,6 +154,9 @@ typedef struct CustomData { #define CD_MASK_BM_ELEM_PYPTR (1LL << CD_BM_ELEM_PYPTR) /* BMESH ONLY END */ +#define CD_MASK_PAINT_MASK (1LL << CD_PAINT_MASK) +#define CD_MASK_GRID_PAINT_MASK (1LL << CD_GRID_PAINT_MASK) + /* CustomData.flag */ /* indicates layer should not be copied by CustomData_from_template or diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 94bfe722abe..b0a1d23f166 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -247,6 +247,16 @@ typedef struct MRecast { int i; } MRecast; +typedef struct GridPaintMask { + /* The data array contains gridsize*gridsize elements */ + float *data; + + /* The maximum multires level associated with this grid */ + unsigned int level; + + int pad; +} GridPaintMask; + /* mvert->flag (1=SELECT) */ #define ME_SPHERETEST 2 #define ME_VERT_TMP_TAG 4 diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 6874e8de4f1..6fbaf1723bc 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -324,6 +324,14 @@ typedef struct NodeImageAnim { short pad; } NodeImageAnim; +/* layer info for image node outputs */ +typedef struct NodeImageLayer { + /* index in the Image->layers and Image->layers->passes lists */ + int layer_index, pass_index; + /* render pass flag, in case this is an original render pass */ + int pass_flag; +} NodeImageLayer; + typedef struct NodeBlurData { short sizex, sizey; short samples, maxspeed, minspeed, relative, aspect; @@ -364,11 +372,16 @@ typedef struct NodeImageMultiFile { int pad; } NodeImageMultiFile; typedef struct NodeImageMultiFileSocket { + /* single layer file output */ short use_render_format DNA_DEPRECATED; short use_node_format; /* use overall node image format */ - int pad2; - char path[1024]; /* 1024 = FILE_MAX */ + int pad1; + char path[1024]; /* 1024 = FILE_MAX */ ImageFormatData format; + + /* multilayer output */ + char layer[30]; /* EXR_TOT_MAXNAME-2 ('.' and channel char are appended) */ + char pad2[2]; } NodeImageMultiFileSocket; typedef struct NodeChroma { diff --git a/source/blender/makesdna/DNA_object_types.h b/source/blender/makesdna/DNA_object_types.h index 05a96ef2f35..1e428bb96e0 100644 --- a/source/blender/makesdna/DNA_object_types.h +++ b/source/blender/makesdna/DNA_object_types.h @@ -153,6 +153,9 @@ typedef struct Object { float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */ float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */ float imat[4][4]; /* inverse matrix of 'obmat' for any other use than rendering! */ + /* note: this isn't assured to be valid as with 'obmat', + * before using this value you should do... + * invert_m4_m4(ob->imat, ob->obmat); */ /* Previously 'imat' was used at render time, but as other places use it too * the interactive ui of 2.5 creates problems. So now only 'imat_ren' should diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 58ffcf6480e..f5d525d47b5 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -236,7 +236,7 @@ typedef struct ParticleSettings { typedef struct ParticleSystem { /* note1: make sure all (runtime) are NULL's in 'copy_particlesystem' XXX, this function is no more! - need to invstigate */ - /* note2: make sure any uses of this struct in DNA are accounted for in 'copy_object_particlesystems' */ + /* note2: make sure any uses of this struct in DNA are accounted for in 'BKE_object_copy_particlesystems' */ struct ParticleSystem *next, *prev; diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index c78d08e944d..85016256129 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -1128,7 +1128,7 @@ typedef struct Scene { /* Movie Tracking */ struct MovieClip *clip; /* active movie clip */ - uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by object_handle_update() */ + uint64_t customdata_mask; /* XXX. runtime flag for drawing, actually belongs in the window, only used by BKE_object_handle_update() */ uint64_t customdata_mask_modal; /* XXX. same as above but for temp operator use (gl renders) */ } Scene; @@ -1412,7 +1412,7 @@ typedef struct Scene { #define SCE_FRAME_DROP (1<<3) - /* return flag next_object function */ + /* return flag BKE_scene_base_iter_next function */ #define F_ERROR -1 #define F_START 0 #define F_SCENE 1 diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h index 3e20b353856..50e48a13835 100644 --- a/source/blender/makesdna/DNA_smoke_types.h +++ b/source/blender/makesdna/DNA_smoke_types.h @@ -115,8 +115,6 @@ typedef struct SmokeDomainSettings { /* flags */ #define MOD_SMOKE_FLOW_ABSOLUTE (1<<1) /*old style emission*/ #define MOD_SMOKE_FLOW_INITVELOCITY (1<<2) /* passes particles speed to the smoke */ -#define MOD_SMOKE_FLOW_INIT (1 << 3) /* is the flow object already initialized? */ - typedef struct SmokeFlowSettings { struct SmokeModifierData *smd; /* for fast RNA access */ diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index acd375d15a9..cf4c8a4c394 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -384,10 +384,10 @@ extern StructRNA RNA_NlaTrack; extern StructRNA RNA_Node; extern StructRNA RNA_NodeForLoop; extern StructRNA RNA_NodeGroup; -extern StructRNA RNA_NodeImageFileSocket; +extern StructRNA RNA_NodeOutputFileSlotFile; +extern StructRNA RNA_NodeOutputFileSlotLayer; extern StructRNA RNA_NodeLink; extern StructRNA RNA_NodeSocket; -extern StructRNA RNA_NodeSocketPanel; extern StructRNA RNA_NodeTree; extern StructRNA RNA_NodeWhileLoop; extern StructRNA RNA_NoiseTexture; @@ -916,6 +916,7 @@ int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, con int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value); int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier); int RNA_enum_icon_from_value(EnumPropertyItem *item, int value, int *icon); +int RNA_enum_name_from_value(EnumPropertyItem *item, int value, const char **name); void RNA_string_get(PointerRNA *ptr, const char *name, char *value); char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen); diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 1669972320d..e5b2d38de53 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -272,7 +272,7 @@ static void rna_ID_update_tag(ID *id, ReportList *reports, int flag) if (ob->type == OB_FONT) { Curve *cu = ob->data; freedisplist(&cu->disp); - BKE_text_to_curve(sce, ob, CU_LEFT); + BKE_vfont_to_curve(sce, ob, CU_LEFT); } #endif diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 73e046f0d63..573d7216114 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1853,6 +1853,8 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value) IDPropertyTemplate val = {0}; IDProperty *group; + RNA_property_int_clamp(ptr, prop, &value); + val.i = value; group = RNA_struct_idprops(ptr, 1); @@ -1970,6 +1972,8 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v IDPropertyTemplate val = {0}; IDProperty *group; + /* TODO: RNA_property_int_clamp_array(ptr, prop, &value); */ + val.array.len = prop->totarraylength; val.array.type = IDP_INT; @@ -2093,6 +2097,8 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value) IDPropertyTemplate val = {0}; IDProperty *group; + RNA_property_float_clamp(ptr, prop, &value); + val.f = value; group = RNA_struct_idprops(ptr, 1); @@ -2228,6 +2234,8 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa IDPropertyTemplate val = {0}; IDProperty *group; + /* TODO: RNA_property_float_clamp_array(ptr, prop, &value); */ + val.array.len = prop->totarraylength; val.array.type = IDP_FLOAT; @@ -4332,6 +4340,18 @@ int RNA_enum_icon_from_value(EnumPropertyItem *item, int value, int *icon) return 0; } +int RNA_enum_name_from_value(EnumPropertyItem *item, int value, const char **name) +{ + for( ; item->identifier; item++) { + if(item->value==value) { + *name = item->name; + return 1; + } + } + + return 0; +} + void RNA_string_get(PointerRNA *ptr, const char *name, char *value) { PropertyRNA *prop = RNA_struct_find_property(ptr, name); diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 94ea79099c2..7f52456355c 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -201,7 +201,7 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, v } /* check if we have registered this info before, and remove it */ - ksi = ANIM_keyingset_info_find_named(dummyksi.idname); + ksi = ANIM_keyingset_info_find_name(dummyksi.idname); if (ksi && ksi->ext.srna) rna_KeyingSetInfo_unregister(bmain, ksi->ext.srna); @@ -337,7 +337,7 @@ static PointerRNA rna_KeyingSet_typeinfo_get(PointerRNA *ptr) /* keying set info is only for builtin Keying Sets */ if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) - ksi = ANIM_keyingset_info_find_named(ks->typeinfo); + ksi = ANIM_keyingset_info_find_name(ks->typeinfo); return rna_pointer_inherit_refine(ptr, &RNA_KeyingSetInfo, ksi); } @@ -837,7 +837,7 @@ void rna_def_animdata(BlenderRNA *brna) /* Active Action */ prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); /* this flag as well as the dynamic test must be defined for this to be editable... */ - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_pointer_funcs(prop, NULL, "rna_AnimData_action_set", NULL, "rna_Action_id_poll"); RNA_def_property_editable_func(prop, "rna_AnimData_action_editable"); RNA_def_property_ui_text(prop, "Action", "Active Action for this datablock"); diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 79b776572cf..c97a4751135 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -894,7 +894,7 @@ static void rna_def_armature(BlenderRNA *brna) prop = RNA_def_property(srna, "deform_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "gevertdeformer"); RNA_def_property_enum_items(prop, prop_vdeformer); - RNA_def_property_ui_text(prop, "Vertex Deformer", ""); + RNA_def_property_ui_text(prop, "Vertex Deformer", "Vertex Deformer Method (Game Engine only)"); RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); @@ -973,30 +973,6 @@ static void rna_def_armature(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Armature_redraw_data"); RNA_def_property_flag(prop, PROP_LIB_EXCEPTION); /* XXX depreceated ....... old animviz for armatures only */ - - /* deformflag */ - prop = RNA_def_property(srna, "use_deform_vertex_groups", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); - RNA_def_property_ui_text(prop, "Deform Vertex Groups", "Enable Vertex Groups when defining deform"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - - prop = RNA_def_property(srna, "use_deform_envelopes", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_ENVELOPE); - RNA_def_property_ui_text(prop, "Deform Envelopes", "Enable Bone Envelopes when defining deform"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - - prop = RNA_def_property(srna, "use_deform_preserve_volume", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_QUATERNION); - RNA_def_property_ui_text(prop, "Use Dual Quaternion Deformation", "Enable deform rotation with Quaternions"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); - -#if 0 - prop = RNA_def_property(srna, "deform_invert_vertexgroups", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "deformflag", ARM_DEF_INVERT_VGROUP); - RNA_def_property_ui_text(prop, "Invert Vertex Group Influence", - "Invert Vertex Group influence (only for Modifiers)"); - RNA_def_property_update(prop, 0, "rna_Armature_update_data"); -#endif /* Number fields */ /* XXX depreceated ....... old animviz for armatures only */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index ee4b34508d1..893dd7a9707 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -46,7 +46,8 @@ static EnumPropertyItem prop_direction_items[] = { {0, "ADD", 0, "Add", "Add effect of brush"}, {BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem brush_sculpt_tool_items[] = { {SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""}, @@ -59,6 +60,7 @@ EnumPropertyItem brush_sculpt_tool_items[] = { {SCULPT_TOOL_GRAB, "GRAB", ICON_BRUSH_GRAB, "Grab", ""}, {SCULPT_TOOL_INFLATE, "INFLATE", ICON_BRUSH_INFLATE, "Inflate", ""}, {SCULPT_TOOL_LAYER, "LAYER", ICON_BRUSH_LAYER, "Layer", ""}, + {SCULPT_TOOL_MASK, "MASK", ICON_BRUSH_MASK, "Mask", ""}, {SCULPT_TOOL_NUDGE, "NUDGE", ICON_BRUSH_NUDGE, "Nudge", ""}, {SCULPT_TOOL_PINCH, "PINCH", ICON_BRUSH_PINCH, "Pinch", ""}, {SCULPT_TOOL_ROTATE, "ROTATE", ICON_BRUSH_ROTATE, "Rotate", ""}, @@ -66,7 +68,8 @@ EnumPropertyItem brush_sculpt_tool_items[] = { {SCULPT_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_SMOOTH, "Smooth", ""}, {SCULPT_TOOL_SNAKE_HOOK, "SNAKE_HOOK", ICON_BRUSH_SNAKE_HOOK, "Snake Hook", ""}, {SCULPT_TOOL_THUMB, "THUMB", ICON_BRUSH_THUMB, "Thumb", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem brush_vertex_tool_items[] = { @@ -77,14 +80,16 @@ EnumPropertyItem brush_vertex_tool_items[] = { {PAINT_BLEND_BLUR, "BLUR", ICON_BRUSH_BLUR, "Blur", "Blur the color with surrounding values"}, {PAINT_BLEND_LIGHTEN, "LIGHTEN", ICON_BRUSH_LIGHTEN, "Lighten", "Use lighten blending mode while painting"}, {PAINT_BLEND_DARKEN, "DARKEN", ICON_BRUSH_DARKEN, "Darken", "Use darken blending mode while painting"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem brush_image_tool_items[] = { {PAINT_TOOL_DRAW, "DRAW", ICON_BRUSH_TEXDRAW, "Draw", ""}, {PAINT_TOOL_SOFTEN, "SOFTEN", ICON_BRUSH_SOFTEN, "Soften", ""}, {PAINT_TOOL_SMEAR, "SMEAR", ICON_BRUSH_SMEAR, "Smear", ""}, {PAINT_TOOL_CLONE, "CLONE", ICON_BRUSH_CLONE, "Clone", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; #ifdef RNA_RUNTIME @@ -103,116 +108,117 @@ EnumPropertyItem brush_image_tool_items[] = { static int rna_SculptCapabilities_has_accumulate_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ELEM6(br->sculpt_tool, - SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, - SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER); + SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CREASE, + SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_LAYER); } static int rna_SculptCapabilities_has_auto_smooth_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; - return br->sculpt_tool != SCULPT_TOOL_SMOOTH; + Brush *br = (Brush *)ptr->data; + return !ELEM(br->sculpt_tool, SCULPT_TOOL_MASK, SCULPT_TOOL_SMOOTH); } static int rna_SculptCapabilities_has_height_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return br->sculpt_tool == SCULPT_TOOL_LAYER; } static int rna_SculptCapabilities_has_jitter_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && - !(br->flag & BRUSH_RESTORE_MESH) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !(br->flag & BRUSH_RESTORE_MESH) && + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } static int rna_SculptCapabilities_has_normal_weight_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); } static int rna_SculptCapabilities_has_persistence_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return br->sculpt_tool == SCULPT_TOOL_LAYER; } static int rna_SculptCapabilities_has_pinch_factor_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ELEM(br->sculpt_tool, SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE); } static int rna_SculptCapabilities_has_plane_offset_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ELEM5(br->sculpt_tool, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, - SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE); + SCULPT_TOOL_FILL, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_SCRAPE); } static int rna_SculptCapabilities_has_random_texture_angle_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ((br->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) && - !(br->flag & BRUSH_ANCHORED) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !(br->flag & BRUSH_ANCHORED) && + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } static int rna_SculptCapabilities_has_sculpt_plane_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; - return !ELEM3(br->sculpt_tool, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, - SCULPT_TOOL_SMOOTH); + Brush *br = (Brush *)ptr->data; + return !ELEM4(br->sculpt_tool, SCULPT_TOOL_INFLATE, + SCULPT_TOOL_MASK, SCULPT_TOOL_PINCH, + SCULPT_TOOL_SMOOTH); } static int rna_SculptCapabilities_has_secondary_color_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ELEM10(br->sculpt_tool, - SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, - SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL, - SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, - SCULPT_TOOL_SCRAPE); + SCULPT_TOOL_BLOB, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, + SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, SCULPT_TOOL_FILL, + SCULPT_TOOL_FLATTEN, SCULPT_TOOL_INFLATE, SCULPT_TOOL_PINCH, + SCULPT_TOOL_SCRAPE); } static int rna_SculptCapabilities_has_smooth_stroke_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && - !(br->flag & BRUSH_RESTORE_MESH) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !(br->flag & BRUSH_RESTORE_MESH) && + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } static int rna_SculptCapabilities_has_space_attenuation_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return ((br->flag & BRUSH_SPACE) && - !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); + !ELEM4(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SMOOTH, SCULPT_TOOL_SNAKE_HOOK)); } static int rna_SculptCapabilities_has_spacing_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return (!(br->flag & BRUSH_ANCHORED) && - !ELEM4(br->sculpt_tool, - SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, - SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); + !ELEM4(br->sculpt_tool, + SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, + SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)); } static int rna_SculptCapabilities_has_strength_get(PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; return !ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK); } @@ -238,35 +244,35 @@ static void rna_Brush_reset_icon(Brush *br, const char *UNUSED(type)) static void rna_Brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; - WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); + Brush *br = (Brush *)ptr->data; + WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); /*WM_main_add_notifier(NC_SPACE|ND_SPACE_VIEW3D, NULL); */ } static void rna_Brush_sculpt_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; rna_Brush_reset_icon(br, "sculpt"); rna_Brush_update(bmain, scene, ptr); } static void rna_Brush_vertex_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; rna_Brush_reset_icon(br, "vertex_paint"); rna_Brush_update(bmain, scene, ptr); } static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; rna_Brush_reset_icon(br, "image_paint"); rna_Brush_update(bmain, scene, ptr); } static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Brush *br = (Brush*)ptr->data; + Brush *br = (Brush *)ptr->data; if (br->icon_imbuf) { IMB_freeImBuf(br->icon_imbuf); @@ -280,22 +286,22 @@ static void rna_Brush_icon_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi BKE_icon_changed(BKE_icon_getid(&br->id)); } - WM_main_add_notifier(NC_BRUSH|NA_EDITED, br); + WM_main_add_notifier(NC_BRUSH | NA_EDITED, br); } static void rna_Brush_set_size(PointerRNA *ptr, int value) { - Brush* brush = ptr->data; + Brush *brush = ptr->data; /* scale unprojected radius so it stays consistent with brush size */ BKE_brush_scale_unprojected_radius(&brush->unprojected_radius, - value, brush->size); + value, brush->size); brush->size = value; } static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value) { - Brush* brush = ptr->data; + Brush *brush = ptr->data; /* scale brush size so it stays consistent with unprojected_radius */ BKE_brush_scale_size(&brush->size, value, brush->unprojected_radius); @@ -306,34 +312,40 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerR PropertyRNA *UNUSED(prop), int *UNUSED(free)) { static EnumPropertyItem prop_default_items[] = { - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem prop_flatten_contrast_items[] = { {0, "FLATTEN", 0, "Flatten", "Add effect of brush"}, {BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem prop_fill_deepen_items[] = { {0, "FILL", 0, "Fill", "Add effect of brush"}, {BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem prop_scrape_peaks_items[] = { {0, "SCRAPE", 0, "Scrape", "Add effect of brush"}, {BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem prop_pinch_magnify_items[] = { {0, "PINCH", 0, "Pinch", "Add effect of brush"}, {BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem prop_inflate_deflate_items[] = { {0, "INFLATE", 0, "Inflate", "Add effect of brush"}, {BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; - Brush *me = (Brush*)(ptr->data); + Brush *me = (Brush *)(ptr->data); switch (me->sculpt_tool) { case SCULPT_TOOL_DRAW: @@ -343,6 +355,16 @@ static EnumPropertyItem *rna_Brush_direction_itemf(bContext *UNUSED(C), PointerR case SCULPT_TOOL_CLAY: return prop_direction_items; + case SCULPT_TOOL_MASK: + switch ((BrushMaskTool)me->mask_tool) { + case BRUSH_MASK_DRAW: + return prop_direction_items; + break; + case BRUSH_MASK_SMOOTH: + return prop_default_items; + break; + } + case SCULPT_TOOL_FLATTEN: return prop_flatten_contrast_items; @@ -374,7 +396,8 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna) {MTEX_MAP_MODE_FIXED, "FIXED", 0, "Fixed", ""}, {MTEX_MAP_MODE_TILED, "TILED", 0, "Tiled", ""}, {MTEX_MAP_MODE_3D, "3D", 0, "3D", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "BrushTextureSlot", "TextureSlot"); RNA_def_struct_sdna(srna, "MTex"); @@ -382,7 +405,7 @@ static void rna_def_brush_texture_slot(BlenderRNA *brna) prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "rot"); - RNA_def_property_range(prop, 0, M_PI*2); + RNA_def_property_range(prop, 0, M_PI * 2); RNA_def_property_ui_text(prop, "Angle", "Brush texture rotation"); RNA_def_property_update(prop, 0, "rna_TextureSlot_update"); @@ -402,15 +425,15 @@ static void rna_def_sculpt_capabilities(BlenderRNA *brna) RNA_def_struct_sdna(srna, "Brush"); RNA_def_struct_nested(brna, srna, "Brush"); RNA_def_struct_ui_text(srna, "Sculpt Capabilities", - "Read-only indications of which brush operations " - "are supported by the current sculpt tool"); + "Read-only indications of which brush operations " + "are supported by the current sculpt tool"); -#define BRUSH_CAPABILITY(prop_name_, ui_name_) \ - prop = RNA_def_property(srna, #prop_name_, \ - PROP_BOOLEAN, PROP_NONE); \ - RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ - RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_" \ - #prop_name_ "_get", NULL); \ +#define BRUSH_CAPABILITY(prop_name_, ui_name_) \ + prop = RNA_def_property(srna, #prop_name_, \ + PROP_BOOLEAN, PROP_NONE); \ + RNA_def_property_clear_flag(prop, PROP_EDITABLE); \ + RNA_def_property_boolean_funcs(prop, "rna_SculptCapabilities_" \ + #prop_name_ "_get", NULL); \ RNA_def_property_ui_text(prop, ui_name_, NULL) BRUSH_CAPABILITY(has_accumulate, "Has Accumulate"); @@ -446,7 +469,8 @@ static void rna_def_brush(BlenderRNA *brna) {IMB_BLEND_DARKEN, "DARKEN", 0, "Darken", "Use darken blending mode while painting"}, {IMB_BLEND_ERASE_ALPHA, "ERASE_ALPHA", 0, "Erase Alpha", "Erase alpha while painting"}, {IMB_BLEND_ADD_ALPHA, "ADD_ALPHA", 0, "Add Alpha", "Add alpha while painting"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem brush_stroke_method_items[] = { {0, "DOTS", 0, "Dots", "Apply paint on each mouse move step"}, @@ -454,18 +478,21 @@ static void rna_def_brush(BlenderRNA *brna) {BRUSH_SPACE, "SPACE", 0, "Space", "Limit brush application to the distance specified by spacing"}, {BRUSH_ANCHORED, "ANCHORED", 0, "Anchored", "Keep the brush anchored to the initial location"}, {BRUSH_AIRBRUSH, "AIRBRUSH", 0, "Airbrush", "Keep applying paint effect while holding mouse (spray)"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem texture_angle_source_items[] = { {0, "USER", 0, "User", "Rotate the brush texture by given angle"}, {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, {BRUSH_RANDOM_ROTATION, "RANDOM", 0, "Random", "Rotate the brush texture at random"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem texture_angle_source_no_random_items[] = { {0, "USER", 0, "User", "Rotate the brush texture by given angle"}, {BRUSH_RAKE, "RAKE", 0, "Rake", "Rotate the brush texture to match the stroke direction"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem brush_sculpt_plane_items[] = { {SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""}, @@ -473,7 +500,14 @@ static void rna_def_brush(BlenderRNA *brna) {SCULPT_DISP_DIR_X, "X", 0, "X Plane", ""}, {SCULPT_DISP_DIR_Y, "Y", 0, "Y Plane", ""}, {SCULPT_DISP_DIR_Z, "Z", 0, "Z Plane", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem brush_mask_tool_items[] = { + {BRUSH_MASK_DRAW, "DRAW", 0, "Draw", ""}, + {BRUSH_MASK_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "Brush", "ID"); RNA_def_struct_ui_text(srna, "Brush", "Brush datablock for storing brush settings for painting and sculpting"); @@ -500,7 +534,7 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "imagepaint_tool"); RNA_def_property_enum_items(prop, brush_image_tool_items); RNA_def_property_ui_text(prop, "Image Paint Tool", ""); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); @@ -531,11 +565,16 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_enum_items(prop, brush_sculpt_plane_items); RNA_def_property_ui_text(prop, "Sculpt Plane", ""); RNA_def_property_update(prop, 0, "rna_Brush_update"); + + prop = RNA_def_property(srna, "mask_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, brush_mask_tool_items); + RNA_def_property_ui_text(prop, "Mask Tool", ""); + RNA_def_property_update(prop, 0, "rna_Brush_update"); /* number values */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); RNA_def_property_int_funcs(prop, NULL, "rna_Brush_set_size", NULL); - RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10); + RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); RNA_def_property_update(prop, 0, "rna_Brush_update"); @@ -638,7 +677,7 @@ static void rna_def_brush(BlenderRNA *brna) prop = RNA_def_property(srna, "crease_pinch_factor", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "crease_pinch_factor"); - RNA_def_property_float_default(prop, 2.0f/3.0f); + RNA_def_property_float_default(prop, 2.0f / 3.0f); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Crease Brush Pinch Factor", "How much the crease brush pinches"); RNA_def_property_update(prop, 0, "rna_Brush_update"); @@ -863,19 +902,19 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "clone.image"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Clone Image", "Image for clone tool"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update"); prop = RNA_def_property(srna, "clone_alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "clone.alpha"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clone Alpha", "Opacity of clone image display"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update"); prop = RNA_def_property(srna, "clone_offset", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "clone.offset"); RNA_def_property_ui_text(prop, "Clone Offset", ""); RNA_def_property_ui_range(prop, -1.0f, 1.0f, 10.0f, 3); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_Brush_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_update"); /* brush capabilities (mode-dependent) */ prop = RNA_def_property(srna, "sculpt_capabilities", PROP_POINTER, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index e321e83dd61..b812c574a01 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -562,7 +562,7 @@ static void rna_def_constraint_python(BlenderRNA *brna) prop = RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Script", "The text object that contains the Python script"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "use_targets", PROP_BOOLEAN, PROP_NONE); @@ -1097,7 +1097,7 @@ static void rna_def_constraint_action(BlenderRNA *brna) prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); RNA_def_property_ui_text(prop, "Action", "The constraining action"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_update(prop, NC_OBJECT|ND_CONSTRAINT, "rna_Constraint_update"); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index a62ee6d78d1..96ec37d8fa0 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -205,7 +205,7 @@ static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), Po Curve *cu = (Curve*)ptr->data; if (cu->texflag & CU_AUTOSPACE) - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); } static int rna_Curve_texspace_editable(PointerRNA *ptr) @@ -219,7 +219,7 @@ static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values) Curve *cu = (Curve *)ptr->data; if (!cu->bb) - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); copy_v3_v3(values, cu->loc); } @@ -236,7 +236,7 @@ static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values) Curve *cu = (Curve *)ptr->data; if (!cu->bb) - BKE_curve_tex_space_calc(cu); + BKE_curve_texspace_calc(cu); copy_v3_v3(values, cu->size); } diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index f7e7435598b..7052bfa8225 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -134,7 +134,7 @@ static void rna_ImageUser_update(Main *UNUSED(bmain), Scene *scene, PointerRNA * { ImageUser *iuser = ptr->data; - BKE_image_user_calc_frame(iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(iuser, scene->r.cfra, 0); } diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c index ff717635250..84321809ae9 100644 --- a/source/blender/makesrna/intern/rna_image_api.c +++ b/source/blender/makesrna/intern/rna_image_api.c @@ -85,7 +85,7 @@ static void rna_Image_save_render(Image *image, bContext *C, ReportList *reports const float dither_back = ibuf->dither; ibuf->planes = scene->r.im_format.planes; ibuf->dither = scene->r.dither_intensity; - if (!BKE_write_ibuf(ibuf, path, &scene->r.im_format)) { + if (!BKE_imbuf_write(ibuf, path, &scene->r.im_format)) { BKE_reportf(reports, RPT_ERROR, "Couldn't write image: %s", path); } ibuf->planes = imb_planes_back; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 493b246e8d7..62feda4053b 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -205,7 +205,7 @@ void rna_PropertyGroup_unregister(struct Main *bmain, struct StructRNA *type); struct StructRNA *rna_PropertyGroup_register(struct Main *bmain, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); -struct StructRNA* rna_PropertyGroup_refine(struct PointerRNA *ptr); +struct StructRNA *rna_PropertyGroup_refine(struct PointerRNA *ptr); void rna_object_vgroup_name_index_get(struct PointerRNA *ptr, char *value, int index); int rna_object_vgroup_name_index_length(struct PointerRNA *ptr, int index); @@ -268,6 +268,8 @@ void RNA_api_controller(struct StructRNA *srna); void RNA_api_actuator(struct StructRNA *srna); void RNA_api_texture(struct StructRNA *srna); void RNA_api_environment_map(struct StructRNA *srna); +void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop); /* main collection functions */ void RNA_def_main_cameras(BlenderRNA *brna, PropertyRNA *cprop); @@ -343,7 +345,7 @@ PointerRNA rna_listbase_lookup_int(PointerRNA *ptr, StructRNA *type, struct List typedef struct ArrayIterator { char *ptr; - char *endptr; /* past the last valid pointer, only for comparisons, ignores skipped values */ + char *endptr; /* past the last valid pointer, only for comparisons, ignores skipped values */ void *free_ptr; /* will be freed if set */ int itemsize; diff --git a/source/blender/makesrna/intern/rna_lamp.c b/source/blender/makesrna/intern/rna_lamp.c index fef362c8f10..e1cb714c68d 100644 --- a/source/blender/makesrna/intern/rna_lamp.c +++ b/source/blender/makesrna/intern/rna_lamp.c @@ -507,8 +507,8 @@ static void rna_def_lamp_shadow(StructRNA *srna, int spot, int area) static EnumPropertyItem prop_numbuffer_items[] = { {1, "BUFFERS_1", 0, "1", "Only one buffer rendered"}, - {4, "BUFFERS_4", 0, "4", "Renders 4 buffers for better AA, this quadruples memory usage"}, - {9, "BUFFERS_9", 0, "9", "Renders 9 buffers for better AA, this uses nine times more memory"}, + {4, "BUFFERS_4", 0, "4", "Render 4 buffers for better AA, this quadruples memory usage"}, + {9, "BUFFERS_9", 0, "9", "Render 9 buffers for better AA, this uses nine times more memory"}, {0, NULL, 0, NULL, NULL}}; /* GE only */ diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index 5d8d8c7bd02..d919406a14d 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -109,21 +109,21 @@ static void rna_Lattice_update_size(Main *bmain, Scene *scene, PointerRNA *ptr) newv = (lt->opntsv > 0)? lt->opntsv: lt->pntsv; neww = (lt->opntsw > 0)? lt->opntsw: lt->pntsw; - /* resizelattice needs an object, any object will have the same result */ + /* BKE_lattice_resize needs an object, any object will have the same result */ for (ob = bmain->object.first; ob; ob = ob->id.next) { if (ob->data == lt) { - resizelattice(lt, newu, newv, neww, ob); + BKE_lattice_resize(lt, newu, newv, neww, ob); if (lt->editlatt) - resizelattice(lt->editlatt->latt, newu, newv, neww, ob); + BKE_lattice_resize(lt->editlatt->latt, newu, newv, neww, ob); break; } } /* otherwise without, means old points are not repositioned */ if (!ob) { - resizelattice(lt, newu, newv, neww, NULL); + BKE_lattice_resize(lt, newu, newv, neww, NULL); if (lt->editlatt) - resizelattice(lt->editlatt->latt, newu, newv, neww, NULL); + BKE_lattice_resize(lt->editlatt->latt, newu, newv, neww, NULL); } rna_Lattice_update_data(bmain, scene, ptr); diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 8faf5823927..fe9ad47a30f 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -100,7 +100,7 @@ Camera *rna_Main_cameras_new(Main *UNUSED(bmain), const char *name) void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *camera) { if (ID_REAL_USERS(camera) <= 0) - free_libblock(&bmain->camera, camera); + BKE_libblock_free(&bmain->camera, camera); else BKE_reportf(reports, RPT_ERROR, "Camera \"%s\" must have zero users to be removed, found %d", camera->id.name+2, ID_REAL_USERS(camera)); @@ -110,11 +110,11 @@ void rna_Main_cameras_remove(Main *bmain, ReportList *reports, struct Camera *ca Scene *rna_Main_scenes_new(Main *UNUSED(bmain), const char *name) { - return add_scene(name); + return BKE_scene_add(name); } void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struct Scene *scene) { - /* don't call free_libblock(...) directly */ + /* don't call BKE_libblock_free(...) directly */ Scene *newscene; if (scene->id.prev) @@ -129,7 +129,7 @@ void rna_Main_scenes_remove(Main *bmain, bContext *C, ReportList *reports, struc if (CTX_wm_screen(C)->scene == scene) ED_screen_set_scene(C, CTX_wm_screen(C), newscene); - unlink_scene(bmain, scene, newscene); + BKE_scene_unlink(bmain, scene, newscene); } Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const char *name, ID *data) @@ -176,7 +176,7 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha id_us_plus(data); } - ob = add_only_object(type, name); + ob = BKE_object_add_only_object(type, name); id_us_min(&ob->id); ob->data = data; @@ -188,8 +188,8 @@ Object *rna_Main_objects_new(Main *UNUSED(bmain), ReportList *reports, const cha void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *object) { if (ID_REAL_USERS(object) <= 0) { - unlink_object(object); /* needed or ID pointers to this are not cleared */ - free_libblock(&bmain->object, object); + BKE_object_unlink(object); /* needed or ID pointers to this are not cleared */ + BKE_libblock_free(&bmain->object, object); } else { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" must have zero users to be removed, found %d", @@ -199,14 +199,14 @@ void rna_Main_objects_remove(Main *bmain, ReportList *reports, struct Object *ob struct Material *rna_Main_materials_new(Main *UNUSED(bmain), const char *name) { - ID *id = (ID *)add_material(name); + ID *id = (ID *)BKE_material_add(name); id_us_min(id); return (Material *)id; } void rna_Main_materials_remove(Main *bmain, ReportList *reports, struct Material *material) { if (ID_REAL_USERS(material) <= 0) - free_libblock(&bmain->mat, material); + BKE_libblock_free(&bmain->mat, material); else BKE_reportf(reports, RPT_ERROR, "Material \"%s\" must have zero users to be removed, found %d", material->id.name+2, ID_REAL_USERS(material)); @@ -224,7 +224,7 @@ struct bNodeTree *rna_Main_nodetree_new(Main *UNUSED(bmain), const char *name, i void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree *tree) { if (ID_REAL_USERS(tree) <= 0) - free_libblock(&bmain->nodetree, tree); + BKE_libblock_free(&bmain->nodetree, tree); else BKE_reportf(reports, RPT_ERROR, "Node Tree \"%s\" must have zero users to be removed, found %d", tree->id.name+2, ID_REAL_USERS(tree)); @@ -234,14 +234,14 @@ void rna_Main_nodetree_remove(Main *bmain, ReportList *reports, struct bNodeTree Mesh *rna_Main_meshes_new(Main *UNUSED(bmain), const char *name) { - Mesh *me = add_mesh(name); + Mesh *me = BKE_mesh_add(name); id_us_min(&me->id); return me; } void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) { if (ID_REAL_USERS(mesh) <= 0) - free_libblock(&bmain->mesh, mesh); + BKE_libblock_free(&bmain->mesh, mesh); else BKE_reportf(reports, RPT_ERROR, "Mesh \"%s\" must have zero users to be removed, found %d", mesh->id.name+2, ID_REAL_USERS(mesh)); @@ -251,7 +251,7 @@ void rna_Main_meshes_remove(Main *bmain, ReportList *reports, Mesh *mesh) Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) { - Lamp *lamp = add_lamp(name); + Lamp *lamp = BKE_lamp_add(name); lamp->type = type; id_us_min(&lamp->id); return lamp; @@ -259,7 +259,7 @@ Lamp *rna_Main_lamps_new(Main *UNUSED(bmain), const char *name, int type) void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) { if (ID_REAL_USERS(lamp) <= 0) - free_libblock(&bmain->lamp, lamp); + BKE_libblock_free(&bmain->lamp, lamp); else BKE_reportf(reports, RPT_ERROR, "Lamp \"%s\" must have zero users to be removed, found %d", lamp->id.name+2, ID_REAL_USERS(lamp)); @@ -270,7 +270,7 @@ void rna_Main_lamps_remove(Main *bmain, ReportList *reports, Lamp *lamp) Image *rna_Main_images_new(Main *UNUSED(bmain), const char *name, int width, int height, int alpha, int float_buffer) { float color[4] = {0.0, 0.0, 0.0, 1.0}; - Image *image = BKE_add_image_size(width, height, name, alpha ? 32:24, float_buffer, 0, color); + Image *image = BKE_image_add_generated(width, height, name, alpha ? 32:24, float_buffer, 0, color); id_us_min(&image->id); return image; } @@ -279,7 +279,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char Image *ima; errno = 0; - ima = BKE_add_image_file(filepath); + ima = BKE_image_load(filepath); if (!ima) BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, @@ -290,7 +290,7 @@ Image *rna_Main_images_load(Main *UNUSED(bmain), ReportList *reports, const char void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) { if (ID_REAL_USERS(image) <= 0) - free_libblock(&bmain->image, image); + BKE_libblock_free(&bmain->image, image); else BKE_reportf(reports, RPT_ERROR, "Image \"%s\" must have zero users to be removed, found %d", image->id.name+2, ID_REAL_USERS(image)); @@ -300,14 +300,14 @@ void rna_Main_images_remove(Main *bmain, ReportList *reports, Image *image) Lattice *rna_Main_lattices_new(Main *UNUSED(bmain), const char *name) { - Lattice *lt = add_lattice(name); + Lattice *lt = BKE_lattice_add(name); id_us_min(<->id); return lt; } void rna_Main_lattices_remove(Main *bmain, ReportList *reports, struct Lattice *lt) { if (ID_REAL_USERS(lt) <= 0) - free_libblock(&bmain->latt, lt); + BKE_libblock_free(&bmain->latt, lt); else BKE_reportf(reports, RPT_ERROR, "Lattice \"%s\" must have zero users to be removed, found %d", lt->id.name+2, ID_REAL_USERS(lt)); @@ -322,7 +322,7 @@ Curve *rna_Main_curves_new(Main *UNUSED(bmain), const char *name, int type) void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) { if (ID_REAL_USERS(cu) <= 0) - free_libblock(&bmain->curve, cu); + BKE_libblock_free(&bmain->curve, cu); else BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" must have zero users to be removed, found %d", cu->id.name+2, ID_REAL_USERS(cu)); @@ -330,14 +330,14 @@ void rna_Main_curves_remove(Main *bmain, ReportList *reports, struct Curve *cu) MetaBall *rna_Main_metaballs_new(Main *UNUSED(bmain), const char *name) { - MetaBall *mb = BKE_metaball_add(name); + MetaBall *mb = BKE_mball_add(name); id_us_min(&mb->id); return mb; } void rna_Main_metaballs_remove(Main *bmain, ReportList *reports, struct MetaBall *mb) { if (ID_REAL_USERS(mb) <= 0) - free_libblock(&bmain->mball, mb); + BKE_libblock_free(&bmain->mball, mb); else BKE_reportf(reports, RPT_ERROR, "Metaball \"%s\" must have zero users to be removed, found %d", mb->id.name+2, ID_REAL_USERS(mb)); @@ -348,7 +348,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat VFont *font; errno = 0; - font = load_vfont(bmain, filepath); + font = BKE_vfont_load(bmain, filepath); if (!font) BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, @@ -360,7 +360,7 @@ VFont *rna_Main_fonts_load(Main *bmain, ReportList *reports, const char *filepat void rna_Main_fonts_remove(Main *bmain, ReportList *reports, VFont *vfont) { if (ID_REAL_USERS(vfont) <= 0) - free_libblock(&bmain->vfont, vfont); + BKE_libblock_free(&bmain->vfont, vfont); else BKE_reportf(reports, RPT_ERROR, "Font \"%s\" must have zero users to be removed, found %d", vfont->id.name+2, ID_REAL_USERS(vfont)); @@ -378,7 +378,7 @@ Tex *rna_Main_textures_new(Main *UNUSED(bmain), const char *name, int type) void rna_Main_textures_remove(Main *bmain, ReportList *reports, struct Tex *tex) { if (ID_REAL_USERS(tex) <= 0) - free_libblock(&bmain->tex, tex); + BKE_libblock_free(&bmain->tex, tex); else BKE_reportf(reports, RPT_ERROR, "Texture \"%s\" must have zero users to be removed, found %d", tex->id.name+2, ID_REAL_USERS(tex)); @@ -393,7 +393,7 @@ Brush *rna_Main_brushes_new(Main *UNUSED(bmain), const char *name) void rna_Main_brushes_remove(Main *bmain, ReportList *reports, struct Brush *brush) { if (ID_REAL_USERS(brush) <= 0) - free_libblock(&bmain->brush, brush); + BKE_libblock_free(&bmain->brush, brush); else BKE_reportf(reports, RPT_ERROR, "Brush \"%s\" must have zero users to be removed, found %d", brush->id.name+2, ID_REAL_USERS(brush)); @@ -408,7 +408,7 @@ World *rna_Main_worlds_new(Main *UNUSED(bmain), const char *name) void rna_Main_worlds_remove(Main *bmain, ReportList *reports, struct World *world) { if (ID_REAL_USERS(world) <= 0) - free_libblock(&bmain->world, world); + BKE_libblock_free(&bmain->world, world); else BKE_reportf(reports, RPT_ERROR, "World \"%s\" must have zero users to be removed, found %d", world->id.name+2, ID_REAL_USERS(world)); @@ -420,21 +420,21 @@ Group *rna_Main_groups_new(Main *UNUSED(bmain), const char *name) } void rna_Main_groups_remove(Main *bmain, Group *group) { - unlink_group(group); - free_libblock(&bmain->group, group); + BKE_group_unlink(group); + BKE_libblock_free(&bmain->group, group); /* XXX python now has invalid pointer? */ } Speaker *rna_Main_speakers_new(Main *UNUSED(bmain), const char *name) { - Speaker *speaker = add_speaker(name); + Speaker *speaker = BKE_speaker_add(name); id_us_min(&speaker->id); return speaker; } void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker) { if (ID_REAL_USERS(speaker) <= 0) - free_libblock(&bmain->speaker, speaker); + BKE_libblock_free(&bmain->speaker, speaker); else BKE_reportf(reports, RPT_ERROR, "Speaker \"%s\" must have zero users to be removed, found %d", speaker->id.name+2, ID_REAL_USERS(speaker)); @@ -444,12 +444,12 @@ void rna_Main_speakers_remove(Main *bmain, ReportList *reports, Speaker *speaker Text *rna_Main_texts_new(Main *UNUSED(bmain), const char *name) { - return add_empty_text(name); + return BKE_text_add(name); } void rna_Main_texts_remove(Main *bmain, Text *text) { - unlink_text(bmain, text); - free_libblock(&bmain->text, text); + BKE_text_unlink(bmain, text); + BKE_libblock_free(&bmain->text, text); /* XXX python now has invalid pointer? */ } @@ -458,7 +458,7 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath Text *txt; errno = 0; - txt = add_text(filepath, bmain->name); + txt = BKE_text_load(filepath, bmain->name); if (!txt) BKE_reportf(reports, RPT_ERROR, "Can't read: \"%s\", %s", filepath, @@ -469,14 +469,14 @@ Text *rna_Main_texts_load(Main *bmain, ReportList *reports, const char *filepath bArmature *rna_Main_armatures_new(Main *UNUSED(bmain), const char *name) { - bArmature *arm = add_armature(name); + bArmature *arm = BKE_armature_add(name); id_us_min(&arm->id); return arm; } void rna_Main_armatures_remove(Main *bmain, ReportList *reports, bArmature *arm) { if (ID_REAL_USERS(arm) <= 0) - free_libblock(&bmain->armature, arm); + BKE_libblock_free(&bmain->armature, arm); else BKE_reportf(reports, RPT_ERROR, "Armature \"%s\" must have zero users to be removed, found %d", arm->id.name+2, ID_REAL_USERS(arm)); @@ -494,7 +494,7 @@ bAction *rna_Main_actions_new(Main *UNUSED(bmain), const char *name) void rna_Main_actions_remove(Main *bmain, ReportList *reports, bAction *act) { if (ID_REAL_USERS(act) <= 0) - free_libblock(&bmain->action, act); + BKE_libblock_free(&bmain->action, act); else BKE_reportf(reports, RPT_ERROR, "Action \"%s\" must have zero users to be removed, found %d", act->id.name+2, ID_REAL_USERS(act)); @@ -511,7 +511,7 @@ ParticleSettings *rna_Main_particles_new(Main *bmain, const char *name) void rna_Main_particles_remove(Main *bmain, ReportList *reports, ParticleSettings *part) { if (ID_REAL_USERS(part) <= 0) - free_libblock(&bmain->particle, part); + BKE_libblock_free(&bmain->particle, part); else BKE_reportf(reports, RPT_ERROR, "Particle Settings \"%s\" must have zero users to be removed, found %d", part->id.name+2, ID_REAL_USERS(part)); @@ -536,7 +536,7 @@ MovieClip *rna_Main_movieclip_load(Main *UNUSED(bmain), ReportList *reports, con void rna_Main_movieclips_remove(Main *bmain, MovieClip *clip) { BKE_movieclip_unlink(bmain, clip); - free_libblock(&bmain->movieclip, clip); + BKE_libblock_free(&bmain->movieclip, clip); /* XXX python now has invalid pointer? */ } @@ -550,7 +550,7 @@ FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char* name) void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, FreestyleLineStyle *linestyle) { if(ID_REAL_USERS(linestyle) <= 0) - free_libblock(&bmain->linestyle, linestyle); + BKE_libblock_free(&bmain->linestyle, linestyle); else BKE_reportf(reports, RPT_ERROR, "Line style \"%s\" must have zero users to be removed, found %d.", linestyle->id.name+2, ID_REAL_USERS(linestyle)); diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index f29fe01b227..530f7d91561 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -222,7 +222,7 @@ static float rna_MeshPolygon_area_get(PointerRNA *ptr) Mesh *me = (Mesh*)ptr->id.data; MPoly *mp = (MPoly*)ptr->data; - return mesh_calc_poly_area(mp, me->mloop+mp->loopstart, me->mvert, NULL); + return BKE_mesh_calc_poly_area(mp, me->mloop+mp->loopstart, me->mvert, NULL); } static void rna_MeshTessFace_normal_get(PointerRNA *ptr, float *values) @@ -452,6 +452,26 @@ static int rna_Mesh_texspace_editable(PointerRNA *ptr) return (me->texflag & ME_AUTOSPACE)? 0: PROP_EDITABLE; } +static void rna_Mesh_texspace_size_get(PointerRNA *ptr, float values[3]) +{ + Mesh *me= (Mesh*)ptr->data; + + if(!me->bb) + BKE_mesh_texspace_calc(me); + + copy_v3_v3(values, me->size); +} + +static void rna_Mesh_texspace_loc_get(PointerRNA *ptr, float values[3]) +{ + Mesh *me= (Mesh*)ptr->data; + + if(!me->bb) + BKE_mesh_texspace_calc(me); + + copy_v3_v3(values, me->loc); +} + static void rna_MeshVertex_groups_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { Mesh *me = rna_mesh(ptr); @@ -2081,12 +2101,14 @@ void rna_def_texmat_common(StructRNA *srna, const char *texspace_editable) prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION); RNA_def_property_float_sdna(prop, NULL, "loc"); RNA_def_property_ui_text(prop, "Texure Space Location", "Texture space location"); + RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_loc_get", NULL, NULL); RNA_def_property_editable_func(prop, texspace_editable); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); RNA_def_property_float_sdna(prop, NULL, "size"); RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size"); + RNA_def_property_float_funcs(prop, "rna_Mesh_texspace_size_get", NULL, NULL); RNA_def_property_editable_func(prop, texspace_editable); RNA_def_property_update(prop, 0, "rna_Mesh_update_draw"); diff --git a/source/blender/makesrna/intern/rna_mesh_api.c b/source/blender/makesrna/intern/rna_mesh_api.c index 41b232fdf8b..c0a9d19360d 100644 --- a/source/blender/makesrna/intern/rna_mesh_api.c +++ b/source/blender/makesrna/intern/rna_mesh_api.c @@ -42,7 +42,7 @@ #ifdef RNA_RUNTIME const char *rna_Mesh_unit_test_compare(struct Mesh *mesh, bContext *C, struct Mesh *mesh2) { - const char *ret = mesh_cmp(mesh, mesh2, FLT_EPSILON*60); + const char *ret = BKE_mesh_cmp(mesh, mesh2, FLT_EPSILON*60); if (!ret) ret = "Same"; diff --git a/source/blender/makesrna/intern/rna_meta.c b/source/blender/makesrna/intern/rna_meta.c index f7ef0c5c89a..eda38a43d54 100644 --- a/source/blender/makesrna/intern/rna_meta.c +++ b/source/blender/makesrna/intern/rna_meta.c @@ -99,7 +99,7 @@ static void rna_MetaBall_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) if (mb->id.us > 0) { for (ob = bmain->object.first; ob; ob = ob->id.next) if (ob->data == mb) - BKE_metaball_properties_copy(scene, ob); + BKE_mball_properties_copy(scene, ob); DAG_id_tag_update(&mb->id, 0); WM_main_add_notifier(NC_GEOM|ND_DATA, mb); @@ -115,7 +115,7 @@ static void rna_MetaBall_update_rotation(Main *bmain, Scene *scene, PointerRNA * static MetaElem *rna_MetaBall_elements_new(MetaBall *mb, int type) { - MetaElem *ml = BKE_metaball_element_add(mb, type); + MetaElem *ml = BKE_mball_element_add(mb, type); /* cheating way for importers to avoid slow updates */ if (mb->id.us > 0) { diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 8c000e522ba..4f045788561 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -282,6 +282,7 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr) part->sta = 1.0f; part->end = 250.0f; part->ren_as = PART_DRAW_NOT; + part->flag |= PART_UNBORN; part->draw_as = PART_DRAW_DOT; BLI_strncpy(psys->name, "SmokeParticles", sizeof(psys->name)); psys->recalc |= (PSYS_RECALC_RESET|PSYS_RECALC_PHYS); diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 8d262c58f9b..7ad13b8a6d1 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -459,7 +459,7 @@ static void rna_def_nlastrip(BlenderRNA *brna) prop = RNA_def_property(srna, "action", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act"); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Action_id_poll"); - RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_REFCOUNT); RNA_def_property_editable_func(prop, "rna_NlaStrip_action_editable"); RNA_def_property_ui_text(prop, "Action", "Action referenced by this strip"); RNA_def_property_update(prop, NC_ANIMATION|ND_NLA, NULL); /* this will do? */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index cffcca177b3..bb1c50d8c13 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -487,18 +487,6 @@ static void rna_NodeSocketVector_range(PointerRNA *ptr, float *min, float *max, *softmax = val->max; } -static void rna_Node_image_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) -{ - bNode *node = (bNode*)ptr->data; - Image *ima = (Image *)node->id; - ImageUser *iuser = node->storage; - - BKE_image_multilayer_index(ima->rr, iuser); - BKE_image_signal(ima, iuser, IMA_SIGNAL_SRC_CHANGE); - - rna_Node_update(bmain, scene, ptr); -} - static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl) { EnumPropertyItem *item = NULL; @@ -518,24 +506,6 @@ static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl) return item; } -static EnumPropertyItem *rna_Node_image_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, - PropertyRNA *UNUSED(prop), int *free) -{ - bNode *node = (bNode*)ptr->data; - Image *ima = (Image *)node->id; - EnumPropertyItem *item = NULL; - RenderLayer *rl; - - if (!ima || !(ima->rr)) return NULL; - - rl = ima->rr->layers.first; - item = renderresult_layers_add_enum(rl); - - *free = 1; - - return item; -} - static EnumPropertyItem *rna_Node_scene_layer_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *free) { @@ -736,7 +706,8 @@ static bNodeLink *rna_NodeTree_link_new(bNodeTree *ntree, ReportList *reports, ret = nodeAddLink(ntree, fromnode, fromsock, tonode, tosock); if (ret) { - nodeUpdate(ntree, tonode); + if (tonode) + nodeUpdate(ntree, tonode); ntreeUpdateTree(ntree); @@ -852,25 +823,74 @@ static void rna_Mapping_Node_update(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Node_update(bmain, scene, ptr); } -static void rna_NodeOutputFile_file_inputs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +static void rna_NodeOutputFile_slots_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { bNode *node = ptr->data; rna_iterator_listbase_begin(iter, &node->inputs, NULL); } -static PointerRNA rna_NodeOutputFile_file_inputs_get(CollectionPropertyIterator *iter) +static PointerRNA rna_NodeOutputFile_slot_file_get(CollectionPropertyIterator *iter) { PointerRNA ptr; bNodeSocket *sock = rna_iterator_listbase_get(iter); - RNA_pointer_create(iter->ptr.id.data, &RNA_NodeImageFileSocket, sock->storage, &ptr); + RNA_pointer_create(iter->ptr.id.data, &RNA_NodeOutputFileSlotFile, sock->storage, &ptr); return ptr; } -#else +static PointerRNA rna_NodeOutputFile_slot_layer_get(CollectionPropertyIterator *iter) +{ + PointerRNA ptr; + bNodeSocket *sock = rna_iterator_listbase_get(iter); + RNA_pointer_create(iter->ptr.id.data, &RNA_NodeOutputFileSlotLayer, sock->storage, &ptr); + return ptr; +} -static EnumPropertyItem prop_image_layer_items[] = { -{ 0, "PLACEHOLDER", 0, "Placeholder", ""}, -{0, NULL, 0, NULL, NULL}}; +static int rna_NodeOutputFileSocket_find_node(bNodeTree *ntree, NodeImageMultiFileSocket *data, bNode **nodep, bNodeSocket **sockp) +{ + bNode *node; + bNodeSocket *sock; + + for (node= ntree->nodes.first; node; node= node->next) { + for (sock= node->inputs.first; sock; sock= sock->next) { + NodeImageMultiFileSocket *sockdata = sock->storage; + if (sockdata==data) { + *nodep = node; + *sockp = sock; + return 1; + } + } + } + + *nodep= NULL; + *sockp= NULL; + return 0; +} + +static void rna_NodeOutputFileSlotFile_path_set(PointerRNA *ptr, const char *value) +{ + bNodeTree *ntree = ptr->id.data; + NodeImageMultiFileSocket *sockdata = ptr->data; + bNode *node; + bNodeSocket *sock; + + if (rna_NodeOutputFileSocket_find_node(ntree, sockdata, &node, &sock)) { + ntreeCompositOutputFileSetPath(node, sock, value); + } +} + +static void rna_NodeOutputFileSlotLayer_name_set(PointerRNA *ptr, const char *value) +{ + bNodeTree *ntree = ptr->id.data; + NodeImageMultiFileSocket *sockdata = ptr->data; + bNode *node; + bNodeSocket *sock; + + if (rna_NodeOutputFileSocket_find_node(ntree, sockdata, &node, &sock)) { + ntreeCompositOutputFileSetLayer(node, sock, value); + } +} + +#else static EnumPropertyItem prop_scene_layer_items[] = { { 0, "PLACEHOLDER", 0, "Placeholder", ""}, @@ -1791,13 +1811,6 @@ static void def_cmp_image(StructRNA *srna) /* copied from the rna_image.c */ RNA_def_property_ui_text(prop, "Auto-Refresh", "Always refresh image on frame changes"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); - - prop = RNA_def_property(srna, "layer", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "layer"); - RNA_def_property_enum_items(prop, prop_image_layer_items); - RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Node_image_layer_itemf"); - RNA_def_property_ui_text(prop, "Layer", ""); - RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_image_layer_update"); } static void def_cmp_render_layers(StructRNA *srna) @@ -1820,14 +1833,14 @@ static void def_cmp_render_layers(StructRNA *srna) RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update"); } -static void rna_def_cmp_output_file_socket(BlenderRNA *brna) +static void rna_def_cmp_output_file_slot_file(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "NodeImageFileSocket", NULL); + srna = RNA_def_struct(brna, "NodeOutputFileSlotFile", NULL); RNA_def_struct_sdna(srna, "NodeImageMultiFileSocket"); - RNA_def_struct_ui_text(srna, "Node Image File Socket", "Socket data of file output node"); + RNA_def_struct_ui_text(srna, "Output File Slot", "Single layer file slot of the file output node"); prop = RNA_def_property(srna, "use_node_format", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_node_format", 1); @@ -1839,8 +1852,25 @@ static void rna_def_cmp_output_file_socket(BlenderRNA *brna) prop = RNA_def_property(srna, "path", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "path"); - RNA_def_property_ui_text(prop, "Path", "Subpath used for this input"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NodeOutputFileSlotFile_path_set"); RNA_def_struct_name_property(srna, prop); + RNA_def_property_ui_text(prop, "Path", "Subpath used for this slot"); + RNA_def_property_update(prop, NC_NODE|NA_EDITED, NULL); +} +static void rna_def_cmp_output_file_slot_layer(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "NodeOutputFileSlotLayer", NULL); + RNA_def_struct_sdna(srna, "NodeImageMultiFileSocket"); + RNA_def_struct_ui_text(srna, "Output File Layer Slot", "Multilayer slot of the file output node"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "layer"); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_NodeOutputFileSlotLayer_name_set"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_ui_text(prop, "Name", "OpenEXR layer name used for this slot"); RNA_def_property_update(prop, NC_NODE|NA_EDITED, NULL); } static void def_cmp_output_file(StructRNA *srna) @@ -1862,11 +1892,21 @@ static void def_cmp_output_file(StructRNA *srna) prop = RNA_def_property(srna, "format", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ImageFormatSettings"); - prop = RNA_def_property(srna, "file_inputs", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_NodeOutputFile_file_inputs_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", - "rna_NodeOutputFile_file_inputs_get", NULL, NULL, NULL, NULL); - RNA_def_property_struct_type(prop, "NodeImageFileSocket"); - RNA_def_property_ui_text(prop, "File Inputs", ""); + /* XXX using two different collections here for the same basic DNA list! + * Details of the output slots depend on whether the node is in Multilayer EXR mode. + */ + + prop = RNA_def_property(srna, "file_slots", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_NodeOutputFile_slots_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", + "rna_NodeOutputFile_slot_file_get", NULL, NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "NodeOutputFileSlotFile"); + RNA_def_property_ui_text(prop, "File Slots", ""); + + prop = RNA_def_property(srna, "layer_slots", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_NodeOutputFile_slots_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", + "rna_NodeOutputFile_slot_layer_get", NULL, NULL, NULL, NULL); + RNA_def_property_struct_type(prop, "NodeOutputFileSlotLayer"); + RNA_def_property_ui_text(prop, "EXR Layer Slots", ""); } static void def_cmp_dilate_erode(StructRNA *srna) @@ -3535,7 +3575,8 @@ void RNA_def_nodetree(BlenderRNA *brna) define_specific_node(brna, NODE_FRAME, def_frame); /* special socket types */ - rna_def_cmp_output_file_socket(brna); + rna_def_cmp_output_file_slot_file(brna); + rna_def_cmp_output_file_slot_layer(brna); } /* clean up macro definition */ diff --git a/source/blender/makesrna/intern/rna_nodetree_types.h b/source/blender/makesrna/intern/rna_nodetree_types.h index 5352bbd0e0f..d7e55ae27df 100644 --- a/source/blender/makesrna/intern/rna_nodetree_types.h +++ b/source/blender/makesrna/intern/rna_nodetree_types.h @@ -77,7 +77,8 @@ DefNode( ShaderNode, SH_NODE_VOLUME_TRANSPARENT, 0, "VO DefNode( ShaderNode, SH_NODE_VOLUME_ISOTROPIC, 0, "VOLUME_ISOTROPIC", VolumeIsotropic, "Isotropic Volume", "" ) DefNode( ShaderNode, SH_NODE_EMISSION, 0, "EMISSION", Emission, "Emission", "" ) DefNode( ShaderNode, SH_NODE_NEW_GEOMETRY, 0, "NEW_GEOMETRY", NewGeometry, "Geometry", "" ) -DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", Light_path, "Light Path", "" ) +DefNode( ShaderNode, SH_NODE_LIGHT_PATH, 0, "LIGHT_PATH", LightPath, "Light Path", "" ) +DefNode( ShaderNode, SH_NODE_LIGHT_FALLOFF, 0, "LIGHT_FALLOFF", LightFalloff, "Light Falloff", "" ) DefNode( ShaderNode, SH_NODE_TEX_IMAGE, def_sh_tex_image, "TEX_IMAGE", TexImage, "Image Texture", "" ) DefNode( ShaderNode, SH_NODE_TEX_ENVIRONMENT, def_sh_tex_environment, "TEX_ENVIRONMENT", TexEnvironment, "Environment Texture","" ) DefNode( ShaderNode, SH_NODE_TEX_SKY, def_sh_tex_sky, "TEX_SKY", TexSky, "Sky Texture", "" ) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 6a4809e54e5..2472e7613ad 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -164,7 +164,7 @@ static void rna_Object_internal_update(Main *UNUSED(bmain), Scene *UNUSED(scene) static void rna_Object_matrix_world_update(Main *bmain, Scene *scene, PointerRNA *ptr) { /* don't use compat so we get predictable rotation */ - object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE); + BKE_object_apply_mat4(ptr->id.data, ((Object *)ptr->id.data)->obmat, FALSE, TRUE); rna_Object_internal_update(bmain, scene, ptr); } @@ -199,19 +199,19 @@ static void rna_Object_matrix_local_set(PointerRNA *ptr, const float values[16]) } /* don't use compat so we get predictable rotation */ - object_apply_mat4(ob, ob->obmat, FALSE, FALSE); + BKE_object_apply_mat4(ob, ob->obmat, FALSE, FALSE); } static void rna_Object_matrix_basis_get(PointerRNA *ptr, float values[16]) { Object *ob = ptr->id.data; - object_to_mat4(ob, (float(*)[4])values); + BKE_object_to_mat4(ob, (float(*)[4])values); } static void rna_Object_matrix_basis_set(PointerRNA *ptr, const float values[16]) { Object *ob = ptr->id.data; - object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE); + BKE_object_apply_mat4(ob, (float(*)[4])values, FALSE, FALSE); } void rna_Object_internal_update_data(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) @@ -263,7 +263,7 @@ static void rna_Object_select_update(Main *UNUSED(bmain), Scene *scene, PointerR if (scene) { Object *ob = (Object*)ptr->id.data; short mode = ob->flag & SELECT ? BA_SELECT : BA_DESELECT; - ED_base_object_select(object_in_scene(ob, scene), mode); + ED_base_object_select(BKE_scene_base_find(scene, ob), mode); } } @@ -298,7 +298,7 @@ static void rna_Object_layer_update(Main *bmain, Scene *scene, PointerRNA *ptr) Object *ob = (Object*)ptr->id.data; Base *base; - base = scene ? object_in_scene(ob, scene) : NULL; + base = scene ? BKE_scene_base_find(scene, ob) : NULL; if (!base) return; @@ -355,7 +355,7 @@ static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value) if (GS(id->name) == ID_CU) BKE_curve_type_test(ob); else if (ob->type == OB_ARMATURE) - armature_rebuild_pose(ob, ob->data); + BKE_pose_rebuild(ob, ob->data); } } @@ -383,8 +383,14 @@ static void rna_Object_parent_set(PointerRNA *ptr, PointerRNA value) { Object *ob = (Object*)ptr->data; Object *par = (Object*)value.data; - - ED_object_parent(ob, par, ob->partype, ob->parsubstr); + +#ifdef FREE_WINDOWS + /* NOTE: this dummy check here prevents this method causing weird runtime errors on mingw 4.6.2 */ + if (ob) +#endif + { + ED_object_parent(ob, par, ob->partype, ob->parsubstr); + } } static void rna_Object_parent_type_set(PointerRNA *ptr, int value) @@ -708,13 +714,13 @@ static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value) static void rna_Object_dimensions_get(PointerRNA *ptr, float *value) { Object *ob = ptr->data; - object_get_dimensions(ob, value); + BKE_object_dimensions_get(ob, value); } static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value) { Object *ob = ptr->data; - object_set_dimensions(ob, value); + BKE_object_dimensions_set(ob, value); } static int rna_Object_location_editable(PointerRNA *ptr, int index) @@ -909,9 +915,9 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value) switch (ob->body_type) { case OB_BODY_TYPE_SENSOR: - ob->gameflag |= OB_SENSOR|OB_COLLISION|OB_GHOST; - ob->gameflag &= ~(OB_OCCLUDER|OB_DYNAMIC|OB_RIGID_BODY|OB_SOFT_BODY|OB_ACTOR|OB_ANISOTROPIC_FRICTION - |OB_DO_FH|OB_ROT_FH|OB_COLLISION_RESPONSE|OB_NAVMESH); + ob->gameflag |= OB_SENSOR | OB_COLLISION | OB_GHOST; + ob->gameflag &= ~(OB_OCCLUDER | OB_DYNAMIC | OB_RIGID_BODY | OB_SOFT_BODY | OB_ACTOR | + OB_ANISOTROPIC_FRICTION | OB_DO_FH | OB_ROT_FH | OB_COLLISION_RESPONSE | OB_NAVMESH); break; case OB_BODY_TYPE_OCCLUDER: ob->gameflag |= OB_OCCLUDER; @@ -1202,7 +1208,7 @@ static void rna_Object_modifier_clear(Object *object, bContext *C) static void rna_Object_boundbox_get(PointerRNA *ptr, float *values) { Object *ob = (Object*)ptr->id.data; - BoundBox *bb = object_get_boundbox(ob); + BoundBox *bb = BKE_object_boundbox_get(ob); if (bb) { memcpy(values, bb->vec, sizeof(bb->vec)); } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index cb0f1d307aa..7ed0304ebb4 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -87,13 +87,13 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ case OB_SURF: /* copies object and modifiers (but not the data) */ - tmpobj = copy_object(ob); + tmpobj = BKE_object_copy(ob); tmpcu = (Curve *)tmpobj->data; tmpcu->id.us--; /* if getting the original caged mesh, delete object modifiers */ if ( cage ) - object_free_modifiers(tmpobj); + BKE_object_free_modifiers(tmpobj); /* copies the data */ copycu = tmpobj->data = BKE_curve_copy((Curve *) ob->data ); @@ -105,42 +105,42 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ copycu->editnurb = tmpcu->editnurb; /* get updated display list, and convert to a mesh */ - makeDispListCurveTypes(sce, tmpobj, 0); + BKE_displist_make_curveTypes(sce, tmpobj, 0); copycu->editfont = NULL; copycu->editnurb = NULL; - nurbs_to_mesh(tmpobj); + BKE_mesh_from_nurbs(tmpobj); - /* nurbs_to_mesh changes the type to a mesh, check it worked */ + /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked */ if (tmpobj->type != OB_MESH) { - free_libblock_us(&(G.main->object), tmpobj); + BKE_libblock_free_us(&(G.main->object), tmpobj); BKE_report(reports, RPT_ERROR, "cant convert curve to mesh. Does the curve have any segments?"); return NULL; } tmpmesh = tmpobj->data; - free_libblock_us(&G.main->object, tmpobj); + BKE_libblock_free_us(&G.main->object, tmpobj); break; case OB_MBALL: { /* metaballs don't have modifiers, so just convert to mesh */ - Object *basis_ob = BKE_metaball_basis_find(sce, ob); + Object *basis_ob = BKE_mball_basis_find(sce, ob); /* todo, re-generatre for render-res */ /* metaball_polygonize(scene, ob) */ if (ob != basis_ob) return NULL; /* only do basis metaball */ - tmpmesh = add_mesh("Mesh"); + tmpmesh = BKE_mesh_add("Mesh"); if (render) { ListBase disp = {NULL, NULL}; - makeDispListMBall_forRender(sce, ob, &disp); - mball_to_mesh(&disp, tmpmesh); - freedisplist(&disp); + BKE_displist_make_mball_forRender(sce, ob, &disp); + BKE_mesh_from_metaball(&disp, tmpmesh); + BKE_displist_free(&disp); } else - mball_to_mesh(&ob->disp, tmpmesh); + BKE_mesh_from_metaball(&ob->disp, tmpmesh); break; } @@ -148,7 +148,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ /* copies object and modifiers (but not the data) */ if (cage) { /* copies the data */ - tmpmesh = copy_mesh( ob->data ); + tmpmesh = BKE_mesh_copy( ob->data ); /* if not getting the original caged mesh, get final derived mesh */ } else { @@ -164,7 +164,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_ else dm = mesh_create_derived_view(sce, ob, mask); - tmpmesh = add_mesh("Mesh"); + tmpmesh = BKE_mesh_add("Mesh"); DM_to_mesh(dm, tmpmesh, ob); dm->release(dm); } @@ -328,7 +328,7 @@ static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList * Scene *scene = CTX_data_scene(C); KeyBlock *kb = NULL; - if ((kb = object_insert_shape_key(scene, ob, name, from_mix))) { + if ((kb = BKE_object_insert_shape_key(scene, ob, name, from_mix))) { PointerRNA keyptr; RNA_pointer_create((ID *)ob->data, &RNA_ShapeKey, kb, &keyptr); @@ -473,12 +473,12 @@ void rna_ObjectBase_layers_from_view(Base *base, View3D *v3d) int rna_Object_is_modified(Object *ob, Scene *scene, int settings) { - return object_is_modified(scene, ob) & settings; + return BKE_object_is_modified(scene, ob) & settings; } int rna_Object_is_deform_modified(Object *ob, Scene *scene, int settings) { - return object_is_deform_modified(scene, ob) & settings; + return BKE_object_is_deform_modified(scene, ob) & settings; } #ifndef NDEBUG diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index ceace424f35..c87dabf46ca 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -173,7 +173,7 @@ static void rna_Pose_ik_solver_set(struct PointerRNA *ptr, int value) pose->ikparam = NULL; } pose->iksolver = value; - init_pose_ikparam(pose); + BKE_pose_ikparam_init(pose); } } @@ -185,7 +185,7 @@ static void rna_Pose_ik_solver_update(Main *bmain, Scene *scene, PointerRNA *ptr pose->flag |= POSE_RECALC; /* checks & sorts pose channels */ DAG_scene_sort(bmain, scene); - update_pose_constraint_flags(pose); + BKE_pose_update_constraint_flags(pose); object_test_constraints(ob); @@ -586,7 +586,7 @@ static int rna_PoseChannel_rotation_4d_editable(PointerRNA *ptr, int index) int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { bPose *pose = (bPose*)ptr->data; - bPoseChannel *pchan = get_pose_channel(pose, key); + bPoseChannel *pchan = BKE_pose_channel_find_name(pose, key); if (pchan) { RNA_pointer_create(ptr->id.data, &RNA_PoseBone, pchan, r_ptr); return TRUE; @@ -599,13 +599,13 @@ int rna_PoseBones_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ static void rna_PoseChannel_matrix_basis_get(PointerRNA *ptr, float *values) { bPoseChannel *pchan = (bPoseChannel*)ptr->data; - pchan_to_mat4(pchan, (float (*)[4])values); + BKE_pchan_to_mat4(pchan, (float (*)[4])values); } static void rna_PoseChannel_matrix_basis_set(PointerRNA *ptr, const float *values) { bPoseChannel *pchan = (bPoseChannel*)ptr->data; - pchan_apply_mat4(pchan, (float (*)[4])values, FALSE); /* no compat for predictable result */ + BKE_pchan_apply_mat4(pchan, (float (*)[4])values, FALSE); /* no compat for predictable result */ } static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) @@ -614,9 +614,9 @@ static void rna_PoseChannel_matrix_set(PointerRNA *ptr, const float *values) Object *ob = (Object*)ptr->id.data; float tmat[4][4]; - armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat); + BKE_armature_mat_pose_to_bone_ex(ob, pchan, (float (*)[4])values, tmat); - pchan_apply_mat4(pchan, tmat, FALSE); /* no compat for predictable result */ + BKE_pchan_apply_mat4(pchan, tmat, FALSE); /* no compat for predictable result */ } #else diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7247ee6f0e0..c26620168ff 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -72,13 +72,15 @@ EnumPropertyItem uv_sculpt_relaxation_items[] = { {UV_SCULPT_TOOL_RELAX_LAPLACIAN, "LAPLACIAN", 0, "Laplacian", "Use Laplacian method for relaxation"}, {UV_SCULPT_TOOL_RELAX_HC, "HC", 0, "HC", "Use HC method for relaxation"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem uv_sculpt_tool_items[] = { {UV_SCULPT_TOOL_PINCH, "PINCH", 0, "Pinch", "Pinch UVs"}, {UV_SCULPT_TOOL_RELAX, "RELAX", 0, "Relax", "Relax UVs"}, {UV_SCULPT_TOOL_GRAB, "GRAB", 0, "Grab", "Grab UVs"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem snap_target_items[] = { @@ -86,7 +88,8 @@ EnumPropertyItem snap_target_items[] = { {SCE_SNAP_TARGET_CENTER, "CENTER", 0, "Center", "Snap center onto target"}, {SCE_SNAP_TARGET_MEDIAN, "MEDIAN", 0, "Median", "Snap median onto target"}, {SCE_SNAP_TARGET_ACTIVE, "ACTIVE", 0, "Active", "Snap active onto target"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem proportional_falloff_items[] = { {PROP_SMOOTH, "SMOOTH", ICON_SMOOTHCURVE, "Smooth", "Smooth falloff"}, @@ -96,22 +99,24 @@ EnumPropertyItem proportional_falloff_items[] = { {PROP_LIN, "LINEAR", ICON_LINCURVE, "Linear", "Linear falloff"}, {PROP_CONST, "CONSTANT", ICON_NOCURVE, "Constant", "Constant falloff"}, {PROP_RANDOM, "RANDOM", ICON_RNDCURVE, "Random", "Random falloff"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem proportional_editing_items[] = { {PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"}, {PROP_EDIT_ON, "ENABLED", ICON_PROP_ON, "Enable", "Proportional Editing enabled"}, - {PROP_EDIT_CONNECTED, "CONNECTED", ICON_PROP_CON, "Connected", - "Proportional Editing using connected geometry only"}, - {0, NULL, 0, NULL, NULL}}; + {PROP_EDIT_CONNECTED, "CONNECTED", ICON_PROP_CON, "Connected", "Proportional Editing using connected geometry only"}, + {0, NULL, 0, NULL, NULL} +}; /* keep for operators, not used here */ EnumPropertyItem mesh_select_mode_items[] = { {SCE_SELECT_VERTEX, "VERTEX", ICON_VERTEXSEL, "Vertex", "Vertex selection mode"}, {SCE_SELECT_EDGE, "EDGE", ICON_EDGESEL, "Edge", "Edge selection mode"}, {SCE_SELECT_FACE, "FACE", ICON_FACESEL, "Face", "Face selection mode"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem snap_element_items[] = { {SCE_SNAP_MODE_INCREMENT, "INCREMENT", ICON_SNAP_INCREMENT, "Increment", "Snap to increments of grid"}, @@ -119,7 +124,8 @@ EnumPropertyItem snap_element_items[] = { {SCE_SNAP_MODE_EDGE, "EDGE", ICON_SNAP_EDGE, "Edge", "Snap to edges"}, {SCE_SNAP_MODE_FACE, "FACE", ICON_SNAP_FACE, "Face", "Snap to faces"}, {SCE_SNAP_MODE_VOLUME, "VOLUME", ICON_SNAP_VOLUME, "Volume", "Snap to volume"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; /* workaround for duplice enums, @@ -205,7 +211,8 @@ EnumPropertyItem image_only_type_items[] = { IMAGE_TYPE_ITEMS_IMAGE_ONLY - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem image_type_items[] = { {0, "", 0, N_("Image"), NULL}, @@ -214,7 +221,7 @@ EnumPropertyItem image_type_items[] = { {0, "", 0, N_("Movie"), NULL}, #ifdef _WIN32 - /* XXX Missing codec menu */ + /* XXX Missing codec menu */ {R_IMF_IMTYPE_AVICODEC, "AVICODEC", ICON_FILE_MOVIE, "AVI Codec", "Output video in AVI format"}, #endif {R_IMF_IMTYPE_AVIJPEG, "AVI_JPEG", ICON_FILE_MOVIE, "AVI JPEG", "Output video in AVI JPEG format"}, @@ -237,13 +244,15 @@ EnumPropertyItem image_type_items[] = { #ifdef WITH_FFMPEG {R_IMF_IMTYPE_XVID, "XVID", ICON_FILE_MOVIE, "Xvid", "Output video in Xvid format"}, #endif - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; EnumPropertyItem image_color_mode_items[] = { {R_IMF_PLANES_BW, "BW", 0, "BW", "Images get saved in 8 bits grayscale (only PNG, JPEG, TGA, TIF)"}, {R_IMF_PLANES_RGB, "RGB", 0, "RGB", "Images are saved with RGB (color) data"}, {R_IMF_PLANES_RGBA, "RGBA", 0, "RGBA", "Images are saved with RGB and Alpha data (if supported)"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; #define IMAGE_COLOR_MODE_BW image_color_mode_items[0] #define IMAGE_COLOR_MODE_RGB image_color_mode_items[1] @@ -256,7 +265,8 @@ EnumPropertyItem image_color_depth_items[] = { {R_IMF_CHAN_DEPTH_16, "16", 0, "16", "16 bit color channels"}, /* 24 not used */ {R_IMF_CHAN_DEPTH_32, "32", 0, "32", "32 bit color channels"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} +}; #ifdef RNA_RUNTIME @@ -307,11 +317,11 @@ static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, Poi static int rna_Scene_object_bases_lookup_string(PointerRNA *ptr, const char *key, PointerRNA *r_ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; Base *base; for (base = scene->base.first; base; base = base->next) { - if (strncmp(base->object->id.name+2, key, sizeof(base->object->id.name)-2) == 0) { + if (strncmp(base->object->id.name + 2, key, sizeof(base->object->id.name) - 2) == 0) { *r_ptr = rna_pointer_inherit_refine(ptr, &RNA_ObjectBase, base); return TRUE; } @@ -325,7 +335,7 @@ static PointerRNA rna_Scene_objects_get(CollectionPropertyIterator *iter) ListBaseIterator *internal = iter->internal; /* we are actually iterating a Base list, so override get */ - return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base*)internal->link)->object); + return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((Base *)internal->link)->object); } static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *reports, Object *ob) @@ -333,40 +343,40 @@ static Base *rna_Scene_object_link(Scene *scene, bContext *C, ReportList *report Scene *scene_act = CTX_data_scene(C); Base *base; - if (object_in_scene(ob, scene)) { - BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\"", ob->id.name+2, scene->id.name+2); + if (BKE_scene_base_find(scene, ob)) { + BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is already in scene \"%s\"", ob->id.name + 2, scene->id.name + 2); return NULL; } - base = scene_add_base(scene, ob); + base = BKE_scene_base_add(scene, ob); id_us_plus(&ob->id); - /* this is similar to what object_add_type and add_object do */ + /* this is similar to what object_add_type and BKE_object_add do */ base->lay = scene->lay; /* when linking to an inactive scene don't touch the layer */ if (scene == scene_act) ob->lay = base->lay; - ob->recalc |= OB_RECALC_OB|OB_RECALC_DATA|OB_RECALC_TIME; + ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; /* slows down importers too much, run scene.update() */ /* DAG_scene_sort(G.main, scene); */ - WM_main_add_notifier(NC_SCENE|ND_OB_ACTIVE, scene); + WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); return base; } static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *ob) { - Base *base = object_in_scene(ob, scene); + Base *base = BKE_scene_base_find(scene, ob); if (!base) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in this scene '%s'", ob->id.name+2, scene->id.name+2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' is not in this scene '%s'", ob->id.name + 2, scene->id.name + 2); return; } if (base == scene->basact && ob->mode != OB_MODE_OBJECT) { - BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in 'Object Mode' to unlink", ob->id.name+2); + BKE_reportf(reports, RPT_ERROR, "Object '%s' must be in 'Object Mode' to unlink", ob->id.name + 2); return; } if (scene->basact == base) { @@ -382,13 +392,13 @@ static void rna_Scene_object_unlink(Scene *scene, ReportList *reports, Object *o DAG_scene_sort(G.main, scene); DAG_ids_flush_update(G.main, 0); - WM_main_add_notifier(NC_SCENE|ND_OB_ACTIVE, scene); + WM_main_add_notifier(NC_SCENE | ND_OB_ACTIVE, scene); } static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value) { - ToolSettings *ts = (ToolSettings*)ptr->data; - if (value.data && ((Object*)value.data)->type == OB_ARMATURE) + ToolSettings *ts = (ToolSettings *)ptr->data; + if (value.data && ((Object *)value.data)->type == OB_ARMATURE) ts->skgen_template = value.data; else ts->skgen_template = NULL; @@ -396,23 +406,23 @@ static void rna_Scene_skgen_etch_template_set(PointerRNA *ptr, PointerRNA value) static PointerRNA rna_Scene_active_object_get(PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; return rna_pointer_inherit_refine(ptr, &RNA_Object, scene->basact ? scene->basact->object : NULL); } static void rna_Scene_active_object_set(PointerRNA *ptr, PointerRNA value) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; if (value.data) - scene->basact = object_in_scene((Object*)value.data, scene); + scene->basact = BKE_scene_base_find(scene, (Object *)value.data); else scene->basact = NULL; } static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value) { - Scene *scene = (Scene*)ptr->data; - Scene *set = (Scene*)value.data; + Scene *scene = (Scene *)ptr->data; + Scene *set = (Scene *)value.data; Scene *nested_set; for (nested_set = set; nested_set; nested_set = nested_set->set) { @@ -425,21 +435,21 @@ static void rna_Scene_set_set(PointerRNA *ptr, PointerRNA value) static void rna_Scene_layer_set(PointerRNA *ptr, const int *values) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; scene->lay = ED_view3d_scene_layer_set(scene->lay, values, &scene->layact); } static int rna_Scene_active_layer_get(PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; - return (int)(log(scene->layact)/M_LN2); + return (int)(log(scene->layact) / M_LN2); } static void rna_Scene_view3d_update(Main *bmain, Scene *UNUSED(scene_unused), PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; BKE_screen_view3d_main_sync(&bmain->screen, scene); } @@ -463,7 +473,7 @@ static void rna_Scene_listener_update(Main *UNUSED(bmain), Scene *scene, Pointer static void rna_Scene_volume_set(PointerRNA *ptr, float value) { - Scene *scene = (Scene*)(ptr->data); + Scene *scene = (Scene *)(ptr->data); scene->audio.volume = value; if (scene->sound_scene) @@ -472,13 +482,13 @@ static void rna_Scene_volume_set(PointerRNA *ptr, float value) static void rna_Scene_framelen_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { - scene->r.framelen = (float)scene->r.framapto/(float)scene->r.images; + scene->r.framelen = (float)scene->r.framapto / (float)scene->r.images; } static void rna_Scene_current_frame_set(PointerRNA *ptr, int value) { - Scene *data = (Scene*)ptr->data; + Scene *data = (Scene *)ptr->data; /* if negative frames aren't allowed, then we can't use them */ FRAMENUMBER_MIN_CLAMP(value); @@ -487,7 +497,7 @@ static void rna_Scene_current_frame_set(PointerRNA *ptr, int value) static void rna_Scene_start_frame_set(PointerRNA *ptr, int value) { - Scene *data = (Scene*)ptr->data; + Scene *data = (Scene *)ptr->data; /* MINFRAME not MINAFRAME, since some output formats can't taken negative frames */ CLAMP(value, MINFRAME, MAXFRAME); data->r.sfra = value; @@ -499,7 +509,7 @@ static void rna_Scene_start_frame_set(PointerRNA *ptr, int value) static void rna_Scene_end_frame_set(PointerRNA *ptr, int value) { - Scene *data = (Scene*)ptr->data; + Scene *data = (Scene *)ptr->data; CLAMP(value, MINFRAME, MAXFRAME); data->r.efra = value; @@ -510,7 +520,7 @@ static void rna_Scene_end_frame_set(PointerRNA *ptr, int value) static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value) { - Scene *data = (Scene*)ptr->data; + Scene *data = (Scene *)ptr->data; if (value) { /* copy range from scene if not set before */ @@ -528,7 +538,7 @@ static void rna_Scene_use_preview_range_set(PointerRNA *ptr, int value) static void rna_Scene_preview_range_start_frame_set(PointerRNA *ptr, int value) { - Scene *data = (Scene*)ptr->data; + Scene *data = (Scene *)ptr->data; /* check if enabled already */ if ((data->r.flag & SCER_PRV_RANGE) == 0) { @@ -544,7 +554,7 @@ static void rna_Scene_preview_range_start_frame_set(PointerRNA *ptr, int value) static void rna_Scene_preview_range_end_frame_set(PointerRNA *ptr, int value) { - Scene *data = (Scene*)ptr->data; + Scene *data = (Scene *)ptr->data; /* check if enabled already */ if ((data->r.flag & SCER_PRV_RANGE) == 0) { @@ -560,7 +570,7 @@ static void rna_Scene_preview_range_end_frame_set(PointerRNA *ptr, int value) static void rna_Scene_frame_update(Main *bmain, Scene *UNUSED(current_scene), PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; + Scene *scene = (Scene *)ptr->id.data; sound_seek_scene(bmain, scene); } @@ -573,7 +583,7 @@ static PointerRNA rna_Scene_active_keying_set_get(PointerRNA *ptr) static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value) { Scene *scene = (Scene *)ptr->data; - KeyingSet *ks = (KeyingSet*)value.data; + KeyingSet *ks = (KeyingSet *)value.data; scene->active_keyingset = ANIM_scene_get_keyingset_index(scene, ks); } @@ -585,7 +595,7 @@ static void rna_Scene_active_keying_set_set(PointerRNA *ptr, PointerRNA value) static int rna_Scene_active_keying_set_index_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->data; - return scene->active_keyingset-1; + return scene->active_keyingset - 1; } /* get KeyingSet index stuff for list of Keying Sets editing UI @@ -594,7 +604,7 @@ static int rna_Scene_active_keying_set_index_get(PointerRNA *ptr) static void rna_Scene_active_keying_set_index_set(PointerRNA *ptr, int value) { Scene *scene = (Scene *)ptr->data; - scene->active_keyingset = value+1; + scene->active_keyingset = value + 1; } /* XXX: evil... builtin_keyingsets is defined in keyingsets.c! */ @@ -603,7 +613,7 @@ extern ListBase builtin_keyingsets; static void rna_Scene_all_keyingsets_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; /* start going over the scene KeyingSets first, while we still have pointer to it * but only if we have any Keying Sets to use... @@ -617,18 +627,17 @@ static void rna_Scene_all_keyingsets_begin(CollectionPropertyIterator *iter, Poi static void rna_Scene_all_keyingsets_next(CollectionPropertyIterator *iter) { ListBaseIterator *internal = iter->internal; - KeyingSet *ks = (KeyingSet*)internal->link; + KeyingSet *ks = (KeyingSet *)internal->link; /* if we've run out of links in Scene list, jump over to the builtins list unless we're there already */ if ((ks->next == NULL) && (ks != builtin_keyingsets.last)) - internal->link = (Link*)builtin_keyingsets.first; + internal->link = (Link *)builtin_keyingsets.first; else - internal->link = (Link*)ks->next; + internal->link = (Link *)ks->next; iter->valid = (internal->link != NULL); } - static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr)) { return BLI_sprintfN("render"); @@ -636,7 +645,7 @@ static char *rna_RenderSettings_path(PointerRNA *UNUSED(ptr)) static int rna_RenderSettings_threads_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; if (rd->mode & R_FIXED_THREADS) return rd->threads; @@ -646,22 +655,22 @@ static int rna_RenderSettings_threads_get(PointerRNA *ptr) static int rna_RenderSettings_is_movie_fomat_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; return BKE_imtype_is_movie(rd->im_format.imtype); } static int rna_RenderSettings_save_buffers_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; if (rd->mode & R_BORDER) return 0; else - return (rd->scemode & (R_EXR_TILE_FILE|R_FULL_SAMPLE)) != 0; + return (rd->scemode & (R_EXR_TILE_FILE | R_FULL_SAMPLE)) != 0; } static int rna_RenderSettings_full_sample_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; return (rd->scemode & R_FULL_SAMPLE) && !(rd->mode & R_BORDER); } @@ -689,12 +698,12 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) if ((imf->depth & depth_ok) == 0) { /* set first available depth */ char depth_ls[] = {R_IMF_CHAN_DEPTH_32, - R_IMF_CHAN_DEPTH_24, - R_IMF_CHAN_DEPTH_16, - R_IMF_CHAN_DEPTH_12, - R_IMF_CHAN_DEPTH_8, - R_IMF_CHAN_DEPTH_1, - 0}; + R_IMF_CHAN_DEPTH_24, + R_IMF_CHAN_DEPTH_16, + R_IMF_CHAN_DEPTH_12, + R_IMF_CHAN_DEPTH_8, + R_IMF_CHAN_DEPTH_1, + 0}; int i; for (i = 0; depth_ls[i]; i++) { @@ -710,7 +719,7 @@ static void rna_ImageFormatSettings_file_format_set(PointerRNA *ptr, int value) Scene *scene = ptr->id.data; RenderData *rd = &scene->r; #ifdef WITH_FFMPEG - ffmpeg_verify_image_type(rd, imf); + BKE_ffmpeg_image_type_verify(rd, imf); #endif #ifdef WITH_QUICKTIME quicktime_verify_image_type(rd, imf); @@ -753,12 +762,12 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P Scene *scene = ptr->id.data; RenderData *rd = &scene->r; - if (ffmpeg_alpha_channel_supported(rd)) + if (BKE_ffmpeg_alpha_channel_is_supported(rd)) chan_flag |= IMA_CHAN_FLAG_ALPHA; } #endif - if (chan_flag == (IMA_CHAN_FLAG_BW|IMA_CHAN_FLAG_RGB|IMA_CHAN_FLAG_ALPHA)) { + if (chan_flag == (IMA_CHAN_FLAG_BW | IMA_CHAN_FLAG_RGB | IMA_CHAN_FLAG_ALPHA)) { return image_color_mode_items; } else { @@ -777,7 +786,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_mode_itemf(bContext *C, P } static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, PointerRNA *ptr, - PropertyRNA *UNUSED(prop), int *free) + PropertyRNA *UNUSED(prop), int *free) { ImageFormatData *imf = (ImageFormatData *)ptr->data; @@ -836,7 +845,7 @@ static EnumPropertyItem *rna_ImageFormatSettings_color_depth_itemf(bContext *C, static int rna_SceneRender_file_ext_length(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; char ext[8]; ext[0] = '\0'; BKE_add_image_extension(ext, rd->im_format.imtype); @@ -845,7 +854,7 @@ static int rna_SceneRender_file_ext_length(PointerRNA *ptr) static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; str[0] = '\0'; BKE_add_image_extension(str, rd->im_format.imtype); } @@ -853,14 +862,14 @@ static void rna_SceneRender_file_ext_get(PointerRNA *ptr, char *str) #ifdef WITH_QUICKTIME static int rna_RenderSettings_qtcodecsettings_codecType_get(PointerRNA *ptr) { - QuicktimeCodecSettings *settings = (QuicktimeCodecSettings*)ptr->data; + QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data; return quicktime_rnatmpvalue_from_videocodectype(settings->codecType); } static void rna_RenderSettings_qtcodecsettings_codecType_set(PointerRNA *ptr, int value) { - QuicktimeCodecSettings *settings = (QuicktimeCodecSettings*)ptr->data; + QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data; settings->codecType = quicktime_videocodecType_from_rnatmpvalue(value); } @@ -874,12 +883,12 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(bCon int i = 1, totitem = 0; char id[5]; - for (i = 0;irnatmpvalue; - *((int*)id) = codecTypeDesc->codecType; + *((int *)id) = codecTypeDesc->codecType; id[4] = 0; tmp.identifier = id; tmp.name = codecTypeDesc->codecName; @@ -895,14 +904,14 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_codecType_itemf(bCon #ifdef USE_QTKIT static int rna_RenderSettings_qtcodecsettings_audiocodecType_get(PointerRNA *ptr) { - QuicktimeCodecSettings *settings = (QuicktimeCodecSettings*)ptr->data; + QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data; return quicktime_rnatmpvalue_from_audiocodectype(settings->audiocodecType); } static void rna_RenderSettings_qtcodecsettings_audiocodecType_set(PointerRNA *ptr, int value) { - QuicktimeCodecSettings *settings = (QuicktimeCodecSettings*)ptr->data; + QuicktimeCodecSettings *settings = (QuicktimeCodecSettings *)ptr->data; settings->audiocodecType = quicktime_audiocodecType_from_rnatmpvalue(value); } @@ -915,7 +924,7 @@ static EnumPropertyItem *rna_RenderSettings_qtcodecsettings_audiocodecType_itemf QuicktimeCodecTypeDesc *codecTypeDesc; int i = 1, totitem = 0; - for (i = 0;iffcodecdata.flags &= ~FFMPEG_LOSSLESS_OUTPUT; - ffmpeg_verify_codec_settings(rd); + BKE_ffmpeg_codec_settings_verify(rd); } static void rna_FFmpegSettings_codec_settings_update(Main *UNUSED(bmain), Scene *UNUSED(scene_unused), PointerRNA *ptr) @@ -952,34 +961,34 @@ static void rna_FFmpegSettings_codec_settings_update(Main *UNUSED(bmain), Scene Scene *scene = (Scene *) ptr->id.data; RenderData *rd = &scene->r; - ffmpeg_verify_codec_settings(rd); + BKE_ffmpeg_codec_settings_verify(rd); } #endif static int rna_RenderSettings_active_layer_index_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; return rd->actlay; } static void rna_RenderSettings_active_layer_index_set(PointerRNA *ptr, int value) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; rd->actlay = value; } static void rna_RenderSettings_active_layer_index_range(PointerRNA *ptr, int *min, int *max, int *softmin, int *softmax) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; *min = 0; - *max = BLI_countlist(&rd->layers)-1; + *max = BLI_countlist(&rd->layers) - 1; *max = MAX2(0, *max); } static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; SceneRenderLayer *srl = BLI_findlink(&rd->layers, rd->actlay); return rna_pointer_inherit_refine(ptr, &RNA_SceneRenderLayer, srl); @@ -987,8 +996,8 @@ static PointerRNA rna_RenderSettings_active_layer_get(PointerRNA *ptr) static void rna_RenderSettings_active_layer_set(PointerRNA *ptr, PointerRNA value) { - RenderData *rd = (RenderData*)ptr->data; - SceneRenderLayer *srl = (SceneRenderLayer*)value.data; + RenderData *rd = (RenderData *)ptr->data; + SceneRenderLayer *srl = (SceneRenderLayer *)value.data; const int index = BLI_findindex(&rd->layers, srl); if (index != -1) rd->actlay = index; } @@ -996,9 +1005,9 @@ static void rna_RenderSettings_active_layer_set(PointerRNA *ptr, PointerRNA valu static SceneRenderLayer *rna_RenderLayer_new(ID *id, RenderData *UNUSED(rd), const char *name) { Scene *scene = (Scene *)id; - SceneRenderLayer *srl = scene_add_render_layer(scene, name); + SceneRenderLayer *srl = BKE_scene_add_render_layer(scene, name); - WM_main_add_notifier(NC_SCENE|ND_RENDER_OPTIONS, NULL); + WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); return srl; } @@ -1008,18 +1017,18 @@ static void rna_RenderLayer_remove(ID *id, RenderData *UNUSED(rd), Main *bmain, { Scene *scene = (Scene *)id; - if (!scene_remove_render_layer(bmain, scene, srl)) { + if (!BKE_scene_remove_render_layer(bmain, scene, srl)) { BKE_reportf(reports, RPT_ERROR, "RenderLayer '%s' could not be removed from scene '%s'", - srl->name, scene->id.name+2); + srl->name, scene->id.name + 2); } else { - WM_main_add_notifier(NC_SCENE|ND_RENDER_OPTIONS, NULL); + WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } } static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; RenderEngineType *type = BLI_findlink(&R_engines, value); if (type) @@ -1049,7 +1058,7 @@ static EnumPropertyItem *rna_RenderSettings_engine_itemf(bContext *UNUSED(C), Po static int rna_RenderSettings_engine_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; RenderEngineType *type; int a = 0; @@ -1067,7 +1076,7 @@ static void rna_RenderSettings_engine_update(Main *bmain, Scene *UNUSED(unused), static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; + Scene *scene = (Scene *)ptr->id.data; DAG_id_tag_update(&scene->id, 0); } @@ -1075,7 +1084,7 @@ static void rna_Scene_glsl_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Poi static void rna_RenderSettings_color_management_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { /* reset image nodes */ - Scene *scene = (Scene*)ptr->id.data; + Scene *scene = (Scene *)ptr->id.data; bNodeTree *ntree = scene->nodetree; bNode *node; @@ -1083,13 +1092,13 @@ static void rna_RenderSettings_color_management_update(Main *bmain, Scene *UNUSE /* images are freed here, stop render and preview threads, until * Image is threadsafe. when we are changing this propery from a * python script in the render thread, don't stop own thread */ - if(BLI_thread_is_main()) + if (BLI_thread_is_main()) WM_jobs_stop_all(bmain->wm.first); for (node = ntree->nodes.first; node; node = node->next) { if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_IMAGE)) { ED_node_changed_update(&scene->id, node); - WM_main_add_notifier(NC_NODE|NA_EDITED, node); + WM_main_add_notifier(NC_NODE | NA_EDITED, node); if (node->type == CMP_NODE_IMAGE) BKE_image_signal((Image *)node->id, NULL, IMA_SIGNAL_FREE); @@ -1102,8 +1111,8 @@ static void rna_RenderSettings_color_management_update(Main *bmain, Scene *UNUSE static void rna_SceneRenderLayer_name_set(PointerRNA *ptr, const char *value) { - Scene *scene = (Scene*)ptr->id.data; - SceneRenderLayer *rl = (SceneRenderLayer*)ptr->data; + Scene *scene = (Scene *)ptr->id.data; + SceneRenderLayer *rl = (SceneRenderLayer *)ptr->data; BLI_strncpy_utf8(rl->name, value, sizeof(rl->name)); BLI_uniquename(&scene->r.layers, rl, "RenderLayer", '.', offsetof(SceneRenderLayer, name), sizeof(rl->name)); @@ -1127,13 +1136,13 @@ static int rna_RenderSettings_multiple_engines_get(PointerRNA *UNUSED(ptr)) static int rna_RenderSettings_use_shading_nodes_get(PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; - return scene_use_new_shading_nodes(scene); + Scene *scene = (Scene *)ptr->id.data; + return BKE_scene_use_new_shading_nodes(scene); } static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) { - RenderData *rd = (RenderData*)ptr->data; + RenderData *rd = (RenderData *)ptr->data; RenderEngineType *type; for (type = R_engines.first; type; type = type->next) @@ -1145,13 +1154,13 @@ static int rna_RenderSettings_use_game_engine_get(PointerRNA *ptr) static void rna_SceneRenderLayer_layer_set(PointerRNA *ptr, const int *values) { - SceneRenderLayer *rl = (SceneRenderLayer*)ptr->data; + SceneRenderLayer *rl = (SceneRenderLayer *)ptr->data; rl->lay = ED_view3d_scene_layer_set(rl->lay, values, NULL); } static void rna_SceneRenderLayer_pass_update(Main *bmain, Scene *activescene, PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; + Scene *scene = (Scene *)ptr->id.data; if (scene->nodetree) ntreeCompositForceHidden(scene->nodetree, scene); @@ -1161,7 +1170,7 @@ static void rna_SceneRenderLayer_pass_update(Main *bmain, Scene *activescene, Po static void rna_Scene_use_nodes_set(PointerRNA *ptr, int value) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; scene->use_nodes = value; if (scene->use_nodes && scene->nodetree == NULL) @@ -1170,7 +1179,7 @@ static void rna_Scene_use_nodes_set(PointerRNA *ptr, int value) static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; + Scene *scene = (Scene *)ptr->id.data; Base *base; for (base = scene->base.first; base; base = base->next) @@ -1179,15 +1188,15 @@ static void rna_Physics_update(Main *UNUSED(bmain), Scene *UNUSED(scene), Pointe static void rna_Scene_editmesh_select_mode_set(PointerRNA *ptr, const int *value) { - Scene *scene = (Scene*)ptr->id.data; - ToolSettings *ts = (ToolSettings*)ptr->data; - int flag = (value[0] ? SCE_SELECT_VERTEX:0) | (value[1] ? SCE_SELECT_EDGE:0) | (value[2] ? SCE_SELECT_FACE : 0); + Scene *scene = (Scene *)ptr->id.data; + ToolSettings *ts = (ToolSettings *)ptr->data; + int flag = (value[0] ? SCE_SELECT_VERTEX : 0) | (value[1] ? SCE_SELECT_EDGE : 0) | (value[2] ? SCE_SELECT_FACE : 0); if (flag) { ts->selectmode = flag; if (scene->basact) { - Mesh *me = get_mesh(scene->basact->object); + Mesh *me = BKE_mesh_from_object(scene->basact->object); if (me && me->edit_btmesh && me->edit_btmesh->selectmode != flag) { me->edit_btmesh->selectmode = flag; EDBM_selectmode_set(me->edit_btmesh); @@ -1201,13 +1210,13 @@ static void rna_Scene_editmesh_select_mode_update(Main *UNUSED(bmain), Scene *sc Mesh *me = NULL; if (scene->basact) { - me = get_mesh(scene->basact->object); + me = BKE_mesh_from_object(scene->basact->object); if (me && me->edit_btmesh == NULL) me = NULL; } - WM_main_add_notifier(NC_GEOM|ND_SELECT, me); - WM_main_add_notifier(NC_SCENE|ND_TOOLSETTINGS, NULL); + WM_main_add_notifier(NC_GEOM | ND_SELECT, me); + WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, NULL); } static void object_simplify_update(Object *ob) @@ -1217,7 +1226,7 @@ static void object_simplify_update(Object *ob) for (md = ob->modifiers.first; md; md = md->next) if (ELEM3(md->type, eModifierType_Subsurf, eModifierType_Multires, eModifierType_ParticleSystem)) - ob->recalc |= OB_RECALC_DATA|PSYS_RECALC_CHILD; + ob->recalc |= OB_RECALC_DATA | PSYS_RECALC_CHILD; for (psys = ob->particlesystem.first; psys; psys = psys->next) psys->recalc |= PSYS_RECALC_CHILD; @@ -1239,7 +1248,7 @@ static void rna_Scene_use_simplify_update(Main *bmain, Scene *scene, PointerRNA object_simplify_update(base->object); DAG_ids_flush_update(bmain, 0); - WM_main_add_notifier(NC_GEOM|ND_DATA, NULL); + WM_main_add_notifier(NC_GEOM | ND_DATA, NULL); } static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr) @@ -1250,13 +1259,13 @@ static void rna_Scene_simplify_update(Main *bmain, Scene *scene, PointerRNA *ptr static int rna_Scene_use_audio_get(PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; return scene->audio.flag & AUDIO_MUTE; } static void rna_Scene_use_audio_set(PointerRNA *ptr, int value) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; if (value) scene->audio.flag |= AUDIO_MUTE; @@ -1268,7 +1277,7 @@ static void rna_Scene_use_audio_set(PointerRNA *ptr, int value) static int rna_Scene_sync_mode_get(PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; if (scene->audio.flag & AUDIO_SYNC) return AUDIO_SYNC; return scene->flag & SCE_FRAME_DROP; @@ -1276,7 +1285,7 @@ static int rna_Scene_sync_mode_get(PointerRNA *ptr) static void rna_Scene_sync_mode_set(PointerRNA *ptr, int value) { - Scene *scene = (Scene*)ptr->data; + Scene *scene = (Scene *)ptr->data; if (value == AUDIO_SYNC) { scene->audio.flag |= AUDIO_SYNC; @@ -1309,7 +1318,7 @@ static void rna_GameSettings_auto_start_set(PointerRNA *UNUSED(ptr), int value) static void rna_GameSettings_exit_key_set(PointerRNA *ptr, int value) { - GameData *gm = (GameData*)ptr->data; + GameData *gm = (GameData *)ptr->data; if (ISKEYBOARD(value)) gm->exitkey = value; @@ -1323,8 +1332,8 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); BLI_addtail(&scene->markers, marker); - WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); - WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); + WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_MARKERS, NULL); return marker; } @@ -1332,23 +1341,23 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[]) static void rna_TimeLine_remove(Scene *scene, ReportList *reports, TimeMarker *marker) { if (!BLI_remlink_safe(&scene->markers, marker)) { - BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in scene '%s'", marker->name, scene->id.name+2); + BKE_reportf(reports, RPT_ERROR, "TimelineMarker '%s' not found in scene '%s'", marker->name, scene->id.name + 2); return; } /* XXX, invalidates PyObject */ MEM_freeN(marker); - WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); - WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); + WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_MARKERS, NULL); } static void rna_TimeLine_clear(Scene *scene) { BLI_freelistN(&scene->markers); - WM_main_add_notifier(NC_SCENE|ND_MARKERS, NULL); - WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); + WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL); + WM_main_add_notifier(NC_ANIMATION | ND_MARKERS, NULL); } static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char idname[], const char name[]) @@ -1370,17 +1379,17 @@ static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, cons static void rna_UnifiedPaintSettings_size_set(PointerRNA *ptr, int value) { - UnifiedPaintSettings* ups = ptr->data; + UnifiedPaintSettings *ups = ptr->data; /* scale unprojected radius so it stays consistent with brush size */ BKE_brush_scale_unprojected_radius(&ups->unprojected_radius, - value, ups->size); + value, ups->size); ups->size = value; } static void rna_UnifiedPaintSettings_unprojected_radius_set(PointerRNA *ptr, float value) { - UnifiedPaintSettings* ups = ptr->data; + UnifiedPaintSettings *ups = ptr->data; /* scale brush size so it stays consistent with unprojected_radius */ BKE_brush_scale_size(&ups->size, value, ups->unprojected_radius); @@ -1397,13 +1406,13 @@ static void rna_Scene_update_active_object_data(Main *UNUSED(bmain), Scene *scen Object *ob = OBACT; if (ob) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_main_add_notifier(NC_OBJECT|ND_DRAW, &ob->id); + WM_main_add_notifier(NC_OBJECT | ND_DRAW, &ob->id); } } static void rna_SceneCamera_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; + Scene *scene = (Scene *)ptr->id.data; Object *camera = scene->camera; if (camera) @@ -1467,12 +1476,12 @@ static void rna_def_transform_orientation(BlenderRNA *brna) prop = RNA_def_property(srna, "matrix", PROP_FLOAT, PROP_MATRIX); RNA_def_property_float_sdna(prop, NULL, "mat"); RNA_def_property_multi_array(prop, 2, matrix_dimsize); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_struct_name_property(srna, prop); RNA_def_property_ui_text(prop, "Name", "Name of the custom transform orientation"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); } static void rna_def_tool_settings(BlenderRNA *brna) @@ -1485,7 +1494,8 @@ static void rna_def_tool_settings(BlenderRNA *brna) {UV_SELECT_EDGE, "EDGE", ICON_UV_EDGESEL, "Edge", "Edge selection mode"}, {UV_SELECT_FACE, "FACE", ICON_UV_FACESEL, "Face", "Face selection mode"}, {UV_SELECT_ISLAND, "ISLAND", ICON_UV_ISLANDSEL, "Island", "Island selection mode"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* the construction of this enum is quite special - everything is stored as bitflags, * with 1st position only for for on/off (and exposed as boolean), while others are mutually @@ -1494,21 +1504,24 @@ static void rna_def_tool_settings(BlenderRNA *brna) static EnumPropertyItem auto_key_items[] = { {AUTOKEY_MODE_NORMAL & ~AUTOKEY_ON, "ADD_REPLACE_KEYS", 0, "Add & Replace", ""}, {AUTOKEY_MODE_EDITKEYS & ~AUTOKEY_ON, "REPLACE_KEYS", 0, "Replace", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem retarget_roll_items[] = { {SK_RETARGET_ROLL_NONE, "NONE", 0, "None", "Don't adjust roll"}, {SK_RETARGET_ROLL_VIEW, "VIEW", 0, "View", "Roll bones to face the view"}, {SK_RETARGET_ROLL_JOINT, "JOINT", 0, "Joint", "Roll bone to original joint plane offset"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem sketch_convert_items[] = { {SK_CONVERT_CUT_FIXED, "FIXED", 0, "Fixed", "Subdivide stroke in fixed number of bones"}, {SK_CONVERT_CUT_LENGTH, "LENGTH", 0, "Length", "Subdivide stroke in bones of specific length"}, {SK_CONVERT_CUT_ADAPTATIVE, "ADAPTIVE", 0, "Adaptive", - "Subdivide stroke adaptively, with more subdivision in curvier parts"}, + "Subdivide stroke adaptively, with more subdivision in curvier parts"}, {SK_CONVERT_RETARGET, "RETARGET", 0, "Retarget", "Retarget template bone chain to stroke"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem edge_tag_items[] = { {EDGE_MODE_SELECT, "SELECT", 0, "Select", ""}, @@ -1517,7 +1530,8 @@ static void rna_def_tool_settings(BlenderRNA *brna) {EDGE_MODE_TAG_CREASE, "CREASE", 0, "Tag Crease", ""}, {EDGE_MODE_TAG_BEVEL, "BEVEL", 0, "Tag Bevel", ""}, {EDGE_MODE_TAG_FREESTYLE, "FREESTYLE", 0, "Tag Freestyle Edge Mark", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "ToolSettings", NULL); RNA_def_struct_ui_text(srna, "Tool Settings", ""); @@ -1564,7 +1578,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1); RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting"); RNA_def_property_ui_icon(prop, ICON_TPAINT_HLT, 0); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, "rna_SpaceImageEditor_uv_sculpt_update"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_SpaceImageEditor_uv_sculpt_update"); prop = RNA_def_property(srna, "uv_sculpt_lock_borders", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_sculpt_settings", UV_SCULPT_LOCK_BORDERS); @@ -1590,19 +1604,19 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, proportional_editing_items); RNA_def_property_ui_text(prop, "Proportional Editing", "Proportional Editing mode, allows transforms with distance fall-off"); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_proportional_edit_objects", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "proportional_objects", 0); RNA_def_property_ui_text(prop, "Proportional Editing Objects", "Proportional editing object mode"); RNA_def_property_ui_icon(prop, ICON_PROP_OFF, 1); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "proportional_edit_falloff", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "prop_mode"); RNA_def_property_enum_items(prop, proportional_falloff_items); RNA_def_property_ui_text(prop, "Proportional Editing Falloff", "Falloff type for proportional editing mode"); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "proportional_size", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "proportional_size"); @@ -1614,7 +1628,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Normal Size", "Display size for normals in the 3D view"); RNA_def_property_range(prop, 0.00001, 1000.0); RNA_def_property_ui_range(prop, 0.01, 10.0, 10.0, 2); - RNA_def_property_update(prop, NC_GEOM|ND_DATA, NULL); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL); prop = RNA_def_property(srna, "double_threshold", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "doublimit"); @@ -1630,51 +1644,51 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP); RNA_def_property_ui_text(prop, "Snap", "Snap during transform"); RNA_def_property_ui_icon(prop, ICON_SNAP_OFF, 1); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_align_rotation", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_ROTATE); RNA_def_property_ui_text(prop, "Snap Align Rotation", "Align rotation with the snapping target"); RNA_def_property_ui_icon(prop, ICON_SNAP_NORMAL, 0); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "snap_element", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "snap_mode"); RNA_def_property_enum_items(prop, snap_element_items); RNA_def_property_ui_text(prop, "Snap Element", "Type of element to snap to"); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "snap_target", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "snap_target"); RNA_def_property_enum_items(prop, snap_target_items); RNA_def_property_ui_text(prop, "Snap Target", "Which part to snap onto the target"); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_peel_object", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PEEL_OBJECT); RNA_def_property_ui_text(prop, "Snap Peel Object", "Consider objects as whole when finding volume center"); RNA_def_property_ui_icon(prop, ICON_SNAP_PEEL_OBJECT, 0); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_project", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "snap_flag", SCE_SNAP_PROJECT); RNA_def_property_ui_text(prop, "Project Individual Elements", "Project individual elements on the surface of other objects"); RNA_def_property_ui_icon(prop, ICON_RETOPO, 0); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ prop = RNA_def_property(srna, "use_snap_self", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "snap_flag", SCE_SNAP_NO_SELF); RNA_def_property_ui_text(prop, "Project to Self", "Snap onto itself (editmode)"); RNA_def_property_ui_icon(prop, ICON_ORTHO, 0); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* header redraw */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */ /* Grease Pencil */ prop = RNA_def_property(srna, "use_grease_pencil_sessions", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_PAINTSESSIONS_ON); RNA_def_property_ui_text(prop, "Use Sketching Sessions", "Allow drawing multiple strokes at a time with Grease Pencil"); - RNA_def_property_update(prop, NC_SCENE|ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */ + RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* xxx: need toolbar to be redrawn... */ /* Auto Keying */ prop = RNA_def_property(srna, "use_keyframe_insert_auto", PROP_BOOLEAN, PROP_NONE); @@ -1704,18 +1718,18 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "uv_selectmode"); RNA_def_property_enum_items(prop, uv_select_mode_items); RNA_def_property_ui_text(prop, "UV Selection Mode", "UV selection and display mode"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "use_uv_select_sync", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_flag", UV_SYNC_SELECTION); RNA_def_property_ui_text(prop, "UV Sync Selection", "Keep UV and edit mode mesh selection in sync"); RNA_def_property_ui_icon(prop, ICON_EDIT, 0); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); prop = RNA_def_property(srna, "show_uv_local_view", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uv_flag", UV_SHOW_SAME_IMAGE); RNA_def_property_ui_text(prop, "UV Local View", "Draw only faces with the currently displayed image assigned"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL); /* Mesh */ prop = RNA_def_property(srna, "mesh_select_mode", PROP_BOOLEAN, PROP_NONE); @@ -1776,21 +1790,21 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "skgen_subdivision_number"); RNA_def_property_range(prop, 1, 255); RNA_def_property_ui_text(prop, "Subdivisions", "Number of bones in the subdivided stroke"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "etch_adaptive_limit", PROP_FLOAT, PROP_FACTOR); RNA_def_property_float_sdna(prop, NULL, "skgen_correlation_limit"); RNA_def_property_range(prop, 0.00001, 1.0); RNA_def_property_ui_range(prop, 0.01, 1.0, 0.01, 2); RNA_def_property_ui_text(prop, "Limit", "Number of bones in the subdivided stroke"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "etch_length_limit", PROP_FLOAT, PROP_DISTANCE); RNA_def_property_float_sdna(prop, NULL, "skgen_length_limit"); RNA_def_property_range(prop, 0.00001, 100000.0); RNA_def_property_ui_range(prop, 0.001, 100.0, 0.1, 3); RNA_def_property_ui_text(prop, "Length", "Number of bones in the subdivided stroke"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); prop = RNA_def_property(srna, "etch_roll_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "skgen_retarget_roll"); @@ -1801,7 +1815,7 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "bone_sketching_convert"); RNA_def_property_enum_items(prop, sketch_convert_items); RNA_def_property_ui_text(prop, "Stroke conversion method", "Method used to convert stroke to bones"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* Unified Paint Settings */ prop = RNA_def_property(srna, "unified_paint_settings", PROP_POINTER, PROP_NONE); @@ -1838,7 +1852,7 @@ static void rna_def_unified_paint_settings(BlenderRNA *brna) * from the active brush */ prop = RNA_def_property(srna, "size", PROP_INT, PROP_DISTANCE); RNA_def_property_int_funcs(prop, NULL, "rna_UnifiedPaintSettings_size_set", NULL); - RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS*10); + RNA_def_property_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS * 10); RNA_def_property_ui_range(prop, 1, MAX_BRUSH_PIXEL_RADIUS, 1, 0); RNA_def_property_ui_text(prop, "Radius", "Radius of the brush in pixels"); @@ -1888,12 +1902,14 @@ static void rna_def_unit_settings(BlenderRNA *brna) {USER_UNIT_NONE, "NONE", 0, "None", ""}, {USER_UNIT_METRIC, "METRIC", 0, "Metric", ""}, {USER_UNIT_IMPERIAL, "IMPERIAL", 0, "Imperial", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem rotation_units[] = { {0, "DEGREES", 0, "Degrees", "Use degrees for measuring angles and rotations"}, {USER_UNIT_ROT_RADIANS, "RADIANS", 0, "Radians", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "UnitSettings", NULL); RNA_def_struct_ui_text(srna, "Unit Settings", ""); @@ -1930,7 +1946,7 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) else RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Name", "Render layer name"); RNA_def_struct_name_property(srna, prop); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "material_override", PROP_POINTER, PROP_NONE); @@ -1939,7 +1955,7 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Material Override", "Material to override all other materials in this render layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "light_override", PROP_POINTER, PROP_NONE); @@ -1947,7 +1963,7 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) RNA_def_property_struct_type(prop, "Group"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Light Override", "Group to override all other lights in this render layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* layers */ @@ -1957,89 +1973,89 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) RNA_def_property_ui_text(prop, "Visible Layers", "Scene layers included in this render layer"); if (scene) RNA_def_property_boolean_funcs(prop, NULL, "rna_SceneRenderLayer_layer_set"); else RNA_def_property_boolean_funcs(prop, NULL, "rna_RenderLayer_layer_set"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "layers_zmask", PROP_BOOLEAN, PROP_LAYER); RNA_def_property_boolean_sdna(prop, NULL, "lay_zmask", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Zmask Layers", "Zmask scene layers for solid faces"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "layers_exclude", PROP_BOOLEAN, PROP_LAYER); RNA_def_property_boolean_sdna(prop, NULL, "lay_exclude", 1); RNA_def_property_array(prop, 20); RNA_def_property_ui_text(prop, "Exclude Layers", "Exclude scene layers from having any influence"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); if (scene) { prop = RNA_def_property(srna, "samples", PROP_INT, PROP_UNSIGNED); RNA_def_property_ui_text(prop, "Samples", "Override number of render samples for this render layer, 0 will use the scene setting"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); } /* layer options */ prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "layflag", SCE_LAY_DISABLE); RNA_def_property_ui_text(prop, "Enabled", "Disable or enable the render layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_zmask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ZMASK); RNA_def_property_ui_text(prop, "Zmask", "Only render what's in front of the solid z values"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "invert_zmask", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_NEG_ZMASK); RNA_def_property_ui_text(prop, "Zmask Negate", "For Zmask, only render what is behind solid z values instead of in front"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_all_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ALL_Z); RNA_def_property_ui_text(prop, "All Z", "Fill in Z values for solid faces in invisible layers, for masking"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_solid", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_SOLID); RNA_def_property_ui_text(prop, "Solid", "Render Solid faces in this Layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_halo", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_HALO); RNA_def_property_ui_text(prop, "Halo", "Render Halos in this Layer (on top of Solid)"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_ztransp", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_ZTRA); RNA_def_property_ui_text(prop, "ZTransp", "Render Z-Transparent faces in this Layer (on top of Solid and Halos)"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_sky", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_SKY); RNA_def_property_ui_text(prop, "Sky", "Render Sky in this Layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_EDGE); RNA_def_property_ui_text(prop, "Edge", "Render Edge-enhance in this Layer (only works for Solid faces)"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_strand", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "layflag", SCE_LAY_STRAND); RNA_def_property_ui_text(prop, "Strand", "Render Strands in this Layer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop= RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE); @@ -2052,219 +2068,219 @@ void rna_def_render_layer_common(StructRNA *srna, int scene) prop = RNA_def_property(srna, "use_pass_combined", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_COMBINED); RNA_def_property_ui_text(prop, "Combined", "Deliver full combined RGBA buffer"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_z", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_Z); RNA_def_property_ui_text(prop, "Z", "Deliver Z values pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_vector", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_VECTOR); RNA_def_property_ui_text(prop, "Vector", "Deliver speed vector pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_NORMAL); RNA_def_property_ui_text(prop, "Normal", "Deliver normal pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_uv", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_UV); RNA_def_property_ui_text(prop, "UV", "Deliver texture UV pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_mist", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_MIST); RNA_def_property_ui_text(prop, "Mist", "Deliver mist factor pass (0.0-1.0)"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_object_index", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXOB); RNA_def_property_ui_text(prop, "Object Index", "Deliver object index pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_material_index", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDEXMA); RNA_def_property_ui_text(prop, "Material Index", "Deliver material index pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_RGBA); RNA_def_property_ui_text(prop, "Color", "Deliver shade-less color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE); RNA_def_property_ui_text(prop, "Diffuse", "Deliver diffuse pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_specular", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SPEC); RNA_def_property_ui_text(prop, "Specular", "Deliver specular pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_SHADOW); RNA_def_property_ui_text(prop, "Shadow", "Deliver shadow pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_ambient_occlusion", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_AO); RNA_def_property_ui_text(prop, "AO", "Deliver AO pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_reflection", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_REFLECT); RNA_def_property_ui_text(prop, "Reflection", "Deliver raytraced reflection pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_refraction", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_REFRACT); RNA_def_property_ui_text(prop, "Refraction", "Deliver raytraced refraction pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_emit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_EMIT); RNA_def_property_ui_text(prop, "Emit", "Deliver emission pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_environment", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_ENVIRONMENT); RNA_def_property_ui_text(prop, "Environment", "Deliver environment lighting pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_INDIRECT); RNA_def_property_ui_text(prop, "Indirect", "Deliver indirect lighting pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_specular", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_SPEC); RNA_def_property_ui_text(prop, "Specular Exclude", "Exclude specular pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_shadow", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_SHADOW); RNA_def_property_ui_text(prop, "Shadow Exclude", "Exclude shadow pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_ambient_occlusion", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_AO); RNA_def_property_ui_text(prop, "AO Exclude", "Exclude AO pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_reflection", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_REFLECT); RNA_def_property_ui_text(prop, "Reflection Exclude", "Exclude raytraced reflection pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_refraction", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_REFRACT); RNA_def_property_ui_text(prop, "Refraction Exclude", "Exclude raytraced refraction pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_emit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_EMIT); RNA_def_property_ui_text(prop, "Emit Exclude", "Exclude emission pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_environment", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_ENVIRONMENT); RNA_def_property_ui_text(prop, "Environment Exclude", "Exclude environment pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "exclude_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "pass_xor", SCE_PASS_INDIRECT); RNA_def_property_ui_text(prop, "Indirect Exclude", "Exclude indirect pass from combined"); RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, 1); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_DIRECT); RNA_def_property_ui_text(prop, "Diffuse Direct", "Deliver diffuse direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_INDIRECT); RNA_def_property_ui_text(prop, "Diffuse Indirect", "Deliver diffuse indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_diffuse_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_DIFFUSE_COLOR); RNA_def_property_ui_text(prop, "Diffuse Color", "Deliver diffuse color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_glossy_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_DIRECT); RNA_def_property_ui_text(prop, "Glossy Direct", "Deliver glossy direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_glossy_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_INDIRECT); RNA_def_property_ui_text(prop, "Glossy Indirect", "Deliver glossy indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_glossy_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_GLOSSY_COLOR); RNA_def_property_ui_text(prop, "Glossy Color", "Deliver glossy color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_transmission_direct", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_DIRECT); RNA_def_property_ui_text(prop, "Transmission Direct", "Deliver transmission direct pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_transmission_indirect", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_INDIRECT); RNA_def_property_ui_text(prop, "Transmission Indirect", "Deliver transmission indirect pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); prop = RNA_def_property(srna, "use_pass_transmission_color", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "passflag", SCE_PASS_TRANSM_COLOR); RNA_def_property_ui_text(prop, "Transmission Color", "Deliver transmission color pass"); - if (scene) RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); + if (scene) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneRenderLayer_pass_update"); else RNA_def_property_clear_flag(prop, PROP_EDITABLE); } @@ -2678,7 +2694,7 @@ static void rna_def_scene_game_recast_data(BlenderRNA *brna) prop = RNA_def_property(srna, "slope_max", PROP_FLOAT, PROP_ANGLE); RNA_def_property_float_sdna(prop, NULL, "agentmaxslope"); - RNA_def_property_range(prop, 0, M_PI/2); + RNA_def_property_range(prop, 0, M_PI / 2); RNA_def_property_ui_text(prop, "Max Slope", "Maximum walkable slope angle in degrees"); RNA_def_property_update(prop, NC_SCENE, NULL); @@ -2737,7 +2753,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna) {4, "SAMPLES_4", 0, "4x", ""}, {8, "SAMPLES_8", 0, "8x", ""}, {16, "SAMPLES_16", 0, "16x", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem framing_types_items[] = { {SCE_GAMEFRAMING_BARS, "LETTERBOX", 0, "Letterbox", @@ -2746,7 +2763,8 @@ static void rna_def_scene_game_data(BlenderRNA *brna) "Show the entire viewport in the display window, viewing more horizontally " "or vertically"}, {SCE_GAMEFRAMING_SCALE, "SCALE", 0, "Scale", "Stretch or squeeze the viewport to fill the display window"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem dome_modes_items[] = { {DOME_FISHEYE, "FISHEYE", 0, "Fisheye", ""}, @@ -2754,22 +2772,25 @@ static void rna_def_scene_game_data(BlenderRNA *brna) {DOME_TRUNCATED_REAR, "TRUNCATED_REAR", 0, "Rear-Truncated", ""}, {DOME_ENVMAP, "ENVMAP", 0, "Cube Map", ""}, {DOME_PANORAM_SPH, "PANORAM_SPH", 0, "Spherical Panoramic", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; - static EnumPropertyItem stereo_modes_items[] = { + static EnumPropertyItem stereo_modes_items[] = { {STEREO_QUADBUFFERED, "QUADBUFFERED", 0, "Quad-Buffer", ""}, {STEREO_ABOVEBELOW, "ABOVEBELOW", 0, "Above-Below", ""}, {STEREO_INTERLACED, "INTERLACED", 0, "Interlaced", ""}, {STEREO_ANAGLYPH, "ANAGLYPH", 0, "Anaglyph", ""}, {STEREO_SIDEBYSIDE, "SIDEBYSIDE", 0, "Side-by-side", ""}, {STEREO_VINTERLACE, "VINTERLACE", 0, "Vinterlace", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; - static EnumPropertyItem stereo_items[] = { + static EnumPropertyItem stereo_items[] = { {STEREO_NOSTEREO, "NONE", 0, "None", "Disable Stereo and Dome environments"}, {STEREO_ENABLED, "STEREO", 0, "Stereo", "Enable Stereo environment"}, {STEREO_DOME, "DOME", 0, "Dome", "Enable Dome environment"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem physics_engine_items[] = { {WOPHY_NONE, "NONE", 0, "None", "Don't use a physics engine"}, @@ -2778,19 +2799,22 @@ static void rna_def_scene_game_data(BlenderRNA *brna) /*{WOPHY_DYNAMO, "DYNAMO", 0, "Dynamo", ""}, */ /*{WOPHY_ODE, "ODE", 0, "ODE", ""}, */ {WOPHY_BULLET, "BULLET", 0, "Bullet", "Use the Bullet physics engine"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem material_items[] = { {GAME_MAT_TEXFACE, "SINGLETEXTURE", 0, "Singletexture", "Singletexture face materials"}, {GAME_MAT_MULTITEX, "MULTITEXTURE", 0, "Multitexture", "Multitexture materials"}, {GAME_MAT_GLSL, "GLSL", 0, "GLSL", "OpenGL shading language shaders"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem obstacle_simulation_items[] = { {OBSTSIMULATION_NONE, "NONE", 0, "None", ""}, {OBSTSIMULATION_TOI_rays, "RVO_RAYS", 0, "RVO (rays)", ""}, {OBSTSIMULATION_TOI_cells, "RVO_CELLS", 0, "RVO (cells)", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "SceneGameData", NULL); RNA_def_struct_sdna(srna, "GameData"); @@ -3047,43 +3071,43 @@ static void rna_def_scene_game_data(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "matmode"); RNA_def_property_enum_items(prop, material_items); RNA_def_property_ui_text(prop, "Material Mode", "Material mode to use for rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, NULL); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, NULL); prop = RNA_def_property(srna, "use_glsl_lights", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_LIGHTS); RNA_def_property_ui_text(prop, "GLSL Lights", "Use lights for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_glsl_shaders", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADERS); RNA_def_property_ui_text(prop, "GLSL Shaders", "Use shaders for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_glsl_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_SHADOWS); RNA_def_property_ui_text(prop, "GLSL Shadows", "Use shadows for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_glsl_ramps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_RAMPS); RNA_def_property_ui_text(prop, "GLSL Ramps", "Use ramps for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_glsl_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_NODES); RNA_def_property_ui_text(prop, "GLSL Nodes", "Use nodes for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_glsl_color_management", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_COLOR_MANAGEMENT); RNA_def_property_ui_text(prop, "GLSL Color Management", "Use color management for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "use_glsl_extra_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GAME_GLSL_NO_EXTRA_TEX); RNA_def_property_ui_text(prop, "GLSL Extra Textures", "Use extra textures like normal or specular maps for GLSL rendering"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_glsl_update"); /* obstacle simulation */ prop = RNA_def_property(srna, "obstacle_simulation", PROP_ENUM, PROP_NONE); @@ -3156,15 +3180,15 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) "rna_RenderSettings_active_layer_index_set", "rna_RenderSettings_active_layer_index_range"); RNA_def_property_ui_text(prop, "Active Layer Index", "Active index in render layer array"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_UNSIGNED); RNA_def_property_struct_type(prop, "SceneRenderLayer"); RNA_def_property_pointer_funcs(prop, "rna_RenderSettings_active_layer_get", "rna_RenderSettings_active_layer_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "Active Render Layer", "Active Render Layer"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_glsl_update"); func = RNA_def_function(srna, "new", "rna_RenderLayer_new"); RNA_def_function_ui_description(func, "Add a render layer to scene"); @@ -3176,9 +3200,9 @@ static void rna_def_render_layers(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "remove", "rna_RenderLayer_remove"); RNA_def_function_ui_description(func, "Remove a render layer"); - RNA_def_function_flag(func, FUNC_USE_MAIN|FUNC_USE_REPORTS|FUNC_USE_SELF_ID); + RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS | FUNC_USE_SELF_ID); parm = RNA_def_pointer(func, "layer", "SceneRenderLayer", "", "Timeline marker to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); } /* use for render output and image save operator, @@ -3195,7 +3219,8 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) {R_IMF_EXR_CODEC_ZIP, "ZIP", 0, "ZIP (lossless)", ""}, {R_IMF_EXR_CODEC_PIZ, "PIZ", 0, "PIZ (lossless)", ""}, {R_IMF_EXR_CODEC_RLE, "RLE", 0, "RLE (lossless)", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; #endif StructRNA *srna; @@ -3213,7 +3238,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_enum_funcs(prop, NULL, "rna_ImageFormatSettings_file_format_set", "rna_ImageFormatSettings_file_format_itemf"); RNA_def_property_ui_text(prop, "File Format", "File format to save the rendered images as"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "color_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "planes"); @@ -3222,39 +3247,39 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Color Mode", "Choose BW for saving greyscale images, RGB for saving red, green and blue channels, " "and RGBA for saving red, green, blue and alpha channels"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "color_depth", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "depth"); RNA_def_property_enum_items(prop, image_color_depth_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_ImageFormatSettings_color_depth_itemf"); RNA_def_property_ui_text(prop, "Color Depth", "Bit depth per channel"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* was 'file_quality' */ prop = RNA_def_property(srna, "quality", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "quality"); RNA_def_property_range(prop, 0, 100); /* 0 is needed for compression. */ RNA_def_property_ui_text(prop, "Quality", "Quality for image formats that support lossy compression"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* was shared with file_quality */ prop = RNA_def_property(srna, "compression", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "compress"); RNA_def_property_range(prop, 0, 100); /* 0 is needed for compression. */ RNA_def_property_ui_text(prop, "Compression", "Compression level for formats that support lossless compression"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* flag */ prop = RNA_def_property(srna, "use_zbuffer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", R_IMF_FLAG_ZBUF); RNA_def_property_ui_text(prop, "Z Buffer", "Save the z-depth per pixel (32 bit unsigned int z-buffer)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_preview", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", R_IMF_FLAG_PREVIEW_JPG); RNA_def_property_ui_text(prop, "Preview", "When rendering animations, save JPG preview images in same directory"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* format specific */ @@ -3265,7 +3290,7 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "exr_codec"); RNA_def_property_enum_items(prop, exr_codec_items); RNA_def_property_ui_text(prop, "Codec", "Codec settings for OpenEXR"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif @@ -3275,17 +3300,17 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_jpeg2k_ycc", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "jp2_flag", R_IMF_JP2_FLAG_YCC); RNA_def_property_ui_text(prop, "YCC", "Save luminance-chrominance-chrominance channels instead of RGB colors"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_jpeg2k_cinema_preset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "jp2_flag", R_IMF_JP2_FLAG_CINE_PRESET); RNA_def_property_ui_text(prop, "Cinema", "Use Openjpeg Cinema Preset"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_jpeg2k_cinema_48", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "jp2_flag", R_IMF_JP2_FLAG_CINE_48); RNA_def_property_ui_text(prop, "Cinema (48)", "Use Openjpeg Cinema Preset (48fps)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif /* Cineon and DPX */ @@ -3293,25 +3318,25 @@ static void rna_def_scene_image_format_data(BlenderRNA *brna) prop = RNA_def_property(srna, "use_cineon_log", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "cineon_flag", R_CINEON_LOG); RNA_def_property_ui_text(prop, "Log", "Convert to logarithmic color space"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "cineon_black", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "cineon_black"); RNA_def_property_range(prop, 0, 1024); RNA_def_property_ui_text(prop, "B", "Log conversion reference blackpoint"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "cineon_white", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "cineon_white"); RNA_def_property_range(prop, 0, 1024); RNA_def_property_ui_text(prop, "W", "Log conversion reference whitepoint"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "cineon_gamma", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "cineon_gamma"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "G", "Log conversion gamma"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); } static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) @@ -3334,7 +3359,8 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {FFMPEG_FLV, "FLASH", 0, "Flash", ""}, {FFMPEG_WAV, "WAV", 0, "Wav", ""}, {FFMPEG_MP3, "MP3", 0, "Mp3", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem ffmpeg_codec_items[] = { {CODEC_ID_NONE, "NONE", 0, "None", ""}, @@ -3349,7 +3375,8 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""}, {CODEC_ID_QTRLE, "QTRLE", 0, "QTRLE", ""}, /* {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, */ /* disabled for after release */ - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem ffmpeg_audio_codec_items[] = { {CODEC_ID_NONE, "NONE", 0, "None", ""}, @@ -3360,7 +3387,8 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {CODEC_ID_VORBIS, "VORBIS", 0, "Vorbis", ""}, {CODEC_ID_FLAC, "FLAC", 0, "FLAC", ""}, {CODEC_ID_PCM_S16LE, "PCM", 0, "PCM", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; #endif static EnumPropertyItem audio_channel_items[] = { @@ -3369,7 +3397,8 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) {4, "SURROUND4", 0, "4 Channels", "Set audio channels to 4 channels"}, {6, "SURROUND51", 0, "5.1 Surround", "Set audio channels to 5.1 surround sound"}, {8, "SURROUND71", 0, "7.1 Surround", "Set audio channels to 7.1 surround sound"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "FFmpegSettings", NULL); RNA_def_struct_sdna(srna, "FFMpegCodecData"); @@ -3381,76 +3410,76 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, ffmpeg_format_items); RNA_def_property_ui_text(prop, "Format", "Output file format"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); prop = RNA_def_property(srna, "codec", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "codec"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, ffmpeg_codec_items); RNA_def_property_ui_text(prop, "Codec", "FFmpeg codec to use"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_FFmpegSettings_codec_settings_update"); prop = RNA_def_property(srna, "video_bitrate", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "video_bitrate"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1, 14000); RNA_def_property_ui_text(prop, "Bitrate", "Video bitrate (kb/s)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "minrate", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "rc_min_rate"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 9000); RNA_def_property_ui_text(prop, "Min Rate", "Rate control: min rate (kb/s)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "maxrate", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "rc_max_rate"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1, 14000); RNA_def_property_ui_text(prop, "Max Rate", "Rate control: max rate (kb/s)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "muxrate", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "mux_rate"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 100000000); RNA_def_property_ui_text(prop, "Mux Rate", "Mux rate (bits/s(!))"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "gopsize", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "gop_size"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "GOP Size", "Distance between key frames"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "buffersize", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "rc_buffer_size"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 2000); RNA_def_property_ui_text(prop, "Buffersize", "Rate control: buffer size (kb)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "packetsize", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "mux_packet_size"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0, 16384); RNA_def_property_ui_text(prop, "Mux Packet Size", "Mux packet size (byte)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_autosplit", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FFMPEG_AUTOSPLIT_OUTPUT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Autosplit Output", "Autosplit output at 2GB boundary"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_lossless_output", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", FFMPEG_LOSSLESS_OUTPUT); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_funcs(prop, NULL, "rna_FFmpegSettings_lossless_output_set"); RNA_def_property_ui_text(prop, "Lossless Output", "Use lossless output for video streams"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* FFMPEG Audio*/ prop = RNA_def_property(srna, "audio_codec", PROP_ENUM, PROP_NONE); @@ -3458,21 +3487,21 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_enum_items(prop, ffmpeg_audio_codec_items); RNA_def_property_ui_text(prop, "Audio Codec", "FFmpeg audio codec to use"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_bitrate", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "audio_bitrate"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 32, 384); RNA_def_property_ui_text(prop, "Bitrate", "Audio bitrate (kb/s)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_volume", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "audio_volume"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Volume", "Audio volume"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif /* the following two "ffmpeg" settings are general audio settings */ @@ -3481,7 +3510,7 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 8000, 192000); RNA_def_property_ui_text(prop, "Samplerate", "Audio samplerate(samples/s)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "audio_channels"); @@ -3498,7 +3527,8 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) static EnumPropertyItem quicktime_codec_type_items[] = { {0, "codec", 0, "codec", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; #ifdef USE_QTKIT static EnumPropertyItem quicktime_audio_samplerate_items[] = { @@ -3508,7 +3538,8 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) {88200, "88200", 0, "88.2kHz", ""}, {96000, "96000", 0, "96kHz", ""}, {192000, "192000", 0, "192kHz", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem quicktime_audio_bitdepth_items[] = { {AUD_FORMAT_U8, "8BIT", 0, "8bit", ""}, @@ -3517,7 +3548,8 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) {AUD_FORMAT_S32, "32BIT", 0, "32bit", ""}, {AUD_FORMAT_FLOAT32, "FLOAT32", 0, "float32", ""}, {AUD_FORMAT_FLOAT64, "FLOAT64", 0, "float64", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem quicktime_audio_bitrate_items[] = { {64000, "64000", 0, "64kbps", ""}, @@ -3526,7 +3558,8 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) {192000, "192000", 0, "192kbps", ""}, {256000, "256000", 0, "256kbps", ""}, {320000, "320000", 0, "320kbps", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; #endif /* QuickTime */ @@ -3538,54 +3571,54 @@ static void rna_def_scene_quicktime_settings(BlenderRNA *brna) RNA_def_property_enum_bitflag_sdna(prop, NULL, "codecType"); RNA_def_property_enum_items(prop, quicktime_codec_type_items); RNA_def_property_enum_funcs(prop, "rna_RenderSettings_qtcodecsettings_codecType_get", - "rna_RenderSettings_qtcodecsettings_codecType_set", - "rna_RenderSettings_qtcodecsettings_codecType_itemf"); + "rna_RenderSettings_qtcodecsettings_codecType_set", + "rna_RenderSettings_qtcodecsettings_codecType_itemf"); RNA_def_property_ui_text(prop, "Codec", "QuickTime codec type"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "codec_spatial_quality", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "codecSpatialQuality"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Spatial quality", "Intra-frame spatial quality level"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #ifdef USE_QTKIT prop = RNA_def_property(srna, "audiocodec_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "audiocodecType"); RNA_def_property_enum_items(prop, quicktime_codec_type_items); RNA_def_property_enum_funcs(prop, "rna_RenderSettings_qtcodecsettings_audiocodecType_get", - "rna_RenderSettings_qtcodecsettings_audiocodecType_set", - "rna_RenderSettings_qtcodecsettings_audiocodecType_itemf"); + "rna_RenderSettings_qtcodecsettings_audiocodecType_set", + "rna_RenderSettings_qtcodecsettings_audiocodecType_itemf"); RNA_def_property_ui_text(prop, "Audio Codec", "QuickTime audio codec type"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_samplerate", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "audioSampleRate"); RNA_def_property_enum_items(prop, quicktime_audio_samplerate_items); RNA_def_property_ui_text(prop, "Smp Rate", "Sample Rate"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_bitdepth", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "audioBitDepth"); RNA_def_property_enum_items(prop, quicktime_audio_bitdepth_items); RNA_def_property_ui_text(prop, "Bit Depth", "Bit Depth"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_resampling_hq", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "audioCodecFlags", QTAUDIO_FLAG_RESAMPLE_NOHQ); RNA_def_property_ui_text(prop, "HQ", "Use High Quality resampling algorithm"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_codec_isvbr", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "audioCodecFlags", QTAUDIO_FLAG_CODEC_ISCBR); RNA_def_property_ui_text(prop, "VBR", "Use Variable Bit Rate compression (improves quality at same bitrate)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "audio_bitrate", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "audioBitRate"); RNA_def_property_enum_items(prop, quicktime_audio_bitrate_items); RNA_def_property_ui_text(prop, "Bitrate", "Compressed audio bitrate"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif } #endif @@ -3603,20 +3636,23 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {R_FILTER_CATROM, "CATMULLROM", 0, "Catmull-Rom", "Use a Catmull-Rom filter for anti-aliasing"}, {R_FILTER_GAUSS, "GAUSSIAN", 0, "Gaussian", "Use a Gaussian filter for anti-aliasing"}, {R_FILTER_MITCH, "MITCHELL", 0, "Mitchell-Netravali", "Use a Mitchell-Netravali filter for anti-aliasing"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem alpha_mode_items[] = { {R_ADDSKY, "SKY", 0, "Sky", "Transparent pixels are filled with sky color"}, {R_ALPHAPREMUL, "PREMUL", 0, "Premultiplied", "Transparent RGB pixels are multiplied by the alpha channel"}, {R_ALPHAKEY, "STRAIGHT", 0, "Straight Alpha", "Transparent RGB and alpha pixels are unmodified"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem display_mode_items[] = { {R_OUTPUT_SCREEN, "SCREEN", 0, "Full Screen", "Images are rendered in full Screen"}, {R_OUTPUT_AREA, "AREA", 0, "Image Editor", "Images are rendered in Image Editor"}, {R_OUTPUT_WINDOW, "WINDOW", 0, "New Window", "Images are rendered in new Window"}, {R_OUTPUT_NONE, "NONE", 0, "Keep UI", "Images are rendered without forcing UI changes"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* Bake */ static EnumPropertyItem bake_mode_items[] = { @@ -3632,27 +3668,31 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {RE_BAKE_MIRROR_COLOR, "MIRROR_COLOR", 0, "Mirror Colors", "Bake Mirror colors"}, {RE_BAKE_SPEC_INTENSITY, "SPEC_INTENSITY", 0, "Specular Intensity", "Bake Specular values"}, {RE_BAKE_SPEC_COLOR, "SPEC_COLOR", 0, "Specular Colors", "Bake Specular colors"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem bake_normal_space_items[] = { {R_BAKE_SPACE_CAMERA, "CAMERA", 0, "Camera", "Bake the normals in camera space"}, {R_BAKE_SPACE_WORLD, "WORLD", 0, "World", "Bake the normals in world space"}, {R_BAKE_SPACE_OBJECT, "OBJECT", 0, "Object", "Bake the normals in object space"}, {R_BAKE_SPACE_TANGENT, "TANGENT", 0, "Tangent", "Bake the normals in tangent space"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem bake_qyad_split_items[] = { {0, "AUTO", 0, "Automatic", "Split quads to give the least distortion while baking"}, {1, "FIXED", 0, "Fixed", "Split quads predictably (0,1,2) (0,2,3)"}, {2, "FIXED_ALT", 0, "Fixed Alternate", "Split quads predictably (1,2,3) (1,3,0)"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem octree_resolution_items[] = { {64, "64", 0, "64", ""}, {128, "128", 0, "128", ""}, {256, "256", 0, "256", ""}, {512, "512", 0, "512", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem raytrace_structure_items[] = { {R_RAYSTRUCTURE_AUTO, "AUTO", 0, "Auto", "Automatically select acceleration structure"}, @@ -3662,28 +3702,32 @@ static void rna_def_scene_render_data(BlenderRNA *brna) {R_RAYSTRUCTURE_SIMD_SVBVH, "SIMD_SVBVH", 0, "SIMD SVBVH", "Use SIMD SVBVH"}, {R_RAYSTRUCTURE_SIMD_QBVH, "SIMD_QBVH", 0, "SIMD QBVH", "Use SIMD QBVH"}, {0, NULL, 0, NULL, NULL} - }; + }; static EnumPropertyItem fixed_oversample_items[] = { {5, "5", 0, "5", ""}, {8, "8", 0, "8", ""}, {11, "11", 0, "11", ""}, {16, "16", 0, "16", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem field_order_items[] = { {0, "EVEN_FIRST", 0, "Upper First", "Upper field first"}, {R_ODDFIELD, "ODD_FIRST", 0, "Lower First", "Lower field first"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem threads_mode_items[] = { {0, "AUTO", 0, "Auto-detect", "Automatically determine the number of threads, based on CPUs"}, {R_FIXED_THREADS, "FIXED", 0, "Fixed", "Manually determine the number of threads"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem engine_items[] = { {0, "BLENDER_RENDER", 0, "Blender Render", "Use the Blender internal rendering engine for rendering"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem freestyle_thickness_items[] = { {R_LINE_THICKNESS_ABSOLUTE, "ABSOLUTE", 0, "Absolute", "Specify unit line thickness in pixels"}, @@ -3713,14 +3757,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 10000); RNA_def_property_ui_text(prop, "Resolution X", "Number of horizontal pixels in the rendered image"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update"); prop = RNA_def_property(srna, "resolution_y", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "ysch"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 4, 10000); RNA_def_property_ui_text(prop, "Resolution Y", "Number of vertical pixels in the rendered image"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update"); prop = RNA_def_property(srna, "resolution_percentage", PROP_INT, PROP_PERCENTAGE); RNA_def_property_int_sdna(prop, NULL, "size"); @@ -3728,19 +3772,19 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_range(prop, 1, 100, 10, 1); RNA_def_property_ui_text(prop, "Resolution %", "Percentage scale for render resolution"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "parts_x", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "xparts"); RNA_def_property_range(prop, 1, 512); RNA_def_property_ui_text(prop, "Parts X", "Number of horizontal tiles to use while rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "parts_y", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "yparts"); RNA_def_property_range(prop, 1, 512); RNA_def_property_ui_text(prop, "Parts Y", "Number of vertical tiles to use while rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "pixel_aspect_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xasp"); @@ -3748,7 +3792,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect X", "Horizontal aspect ratio - for anamorphic or non-square pixel output"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update"); prop = RNA_def_property(srna, "pixel_aspect_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yasp"); @@ -3756,7 +3800,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_range(prop, 1.0f, 200.0f); RNA_def_property_ui_text(prop, "Pixel Aspect Y", "Vertical aspect ratio - for anamorphic or non-square pixel output"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_SceneCamera_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_SceneCamera_update"); #ifdef WITH_QUICKTIME prop = RNA_def_property(srna, "quicktime", PROP_POINTER, PROP_NONE); @@ -3777,14 +3821,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1, 120); RNA_def_property_ui_text(prop, "FPS", "Framerate, expressed in frames per second"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_fps_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_fps_update"); prop = RNA_def_property(srna, "fps_base", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "frs_sec_base"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 0.1f, 120.0f); RNA_def_property_ui_text(prop, "FPS Base", "Framerate base"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_Scene_fps_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_Scene_fps_update"); /* frame mapping */ prop = RNA_def_property(srna, "frame_map_old", PROP_INT, PROP_NONE); @@ -3792,14 +3836,14 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1, 900); RNA_def_property_ui_text(prop, "Frame Map Old", "Old mapping value in frames"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_framelen_update"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_framelen_update"); prop = RNA_def_property(srna, "frame_map_new", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "images"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_range(prop, 1, 900); RNA_def_property_ui_text(prop, "Frame Map New", "How many frames the Map Old will last"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_framelen_update"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_framelen_update"); prop = RNA_def_property(srna, "dither_intensity", PROP_FLOAT, PROP_NONE); @@ -3807,68 +3851,68 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 2.0f); RNA_def_property_ui_text(prop, "Dither Intensity", "Amount of dithering noise added to the rendered image to break up banding"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "pixel_filter_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "filtertype"); RNA_def_property_enum_items(prop, pixel_filter_items); RNA_def_property_ui_text(prop, "Pixel Filter", "Reconstruction filter used for combining anti-aliasing samples"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "filter_size", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "gauss"); RNA_def_property_range(prop, 0.5f, 1.5f); RNA_def_property_ui_text(prop, "Filter Size", "Pixel width over which the reconstruction filter combines samples"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "alpha_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "alphamode"); RNA_def_property_enum_items(prop, alpha_mode_items); RNA_def_property_ui_text(prop, "Alpha Mode", "Representation of alpha information in the RGBA pixels"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "octree_resolution", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "ocres"); RNA_def_property_enum_items(prop, octree_resolution_items); RNA_def_property_ui_text(prop, "Octree Resolution", "Resolution of raytrace accelerator, use higher resolutions for larger scenes"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "raytrace_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "raytrace_structure"); RNA_def_property_enum_items(prop, raytrace_structure_items); RNA_def_property_ui_text(prop, "Raytrace Acceleration Structure", "Type of raytrace accelerator structure"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_instances", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "raytrace_options", R_RAYTRACE_USE_INSTANCES); RNA_def_property_ui_text(prop, "Use Instances", "Instance support leads to effective memory reduction when using duplicates"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_local_coords", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "raytrace_options", R_RAYTRACE_USE_LOCAL_COORDS); RNA_def_property_ui_text(prop, "Use Local Coords", "Vertex coordinates are stored locally on each primitive " "(increases memory usage, but may have impact on speed)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_antialiasing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_OSA); RNA_def_property_ui_text(prop, "Anti-Aliasing", "Render and combine multiple samples per pixel to prevent jagged edges"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "antialiasing_samples", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "osa"); RNA_def_property_enum_items(prop, fixed_oversample_items); RNA_def_property_ui_text(prop, "Anti-Aliasing Samples", "Amount of anti-aliasing samples per pixel"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_fields", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDS); RNA_def_property_ui_text(prop, "Fields", "Render image to two fields per frame, for interlaced TV output"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "field_order", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); @@ -3876,61 +3920,61 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Field Order", "Order of video fields (select which lines get rendered first, " "to create smooth motion for TV output)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_fields_still", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_FIELDSTILL); RNA_def_property_ui_text(prop, "Fields Still", "Disable the time difference between fields"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* rendering features */ prop = RNA_def_property(srna, "use_shadows", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SHADOW); RNA_def_property_ui_text(prop, "Shadows", "Calculate shadows while rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_envmaps", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_ENVMAP); RNA_def_property_ui_text(prop, "Environment Maps", "Calculate environment maps while rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_radiosity", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_RADIO); RNA_def_property_ui_text(prop, "Radiosity", "Calculate radiosity in a pre-process before rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_sss", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_SSS); RNA_def_property_ui_text(prop, "Subsurface Scattering", "Calculate sub-surface scattering in materials rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_raytrace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_RAYTRACE); RNA_def_property_ui_text(prop, "Raytracing", "Pre-calculate the raytrace accelerator and render raytracing effects"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_textures", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "scemode", R_NO_TEX); RNA_def_property_ui_text(prop, "Textures", "Use textures to affect material properties"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_edge_enhance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE); RNA_def_property_ui_text(prop, "Edge", "Create a toon outline around the edges of geometry"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "edge_threshold", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "edgeint"); RNA_def_property_range(prop, 0, 255); RNA_def_property_ui_text(prop, "Edge Threshold", "Threshold for drawing outlines on geometry edges"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "edge_color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "edgeR"); RNA_def_property_array(prop, 3); RNA_def_property_ui_text(prop, "Edge Color", "Edge color"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop= RNA_def_property(srna, "use_freestyle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_EDGE_FRS); @@ -3945,27 +3989,27 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Threads", "Number of CPU threads to use simultaneously while rendering " "(for multi-core/CPU systems)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "threads_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "mode"); RNA_def_property_enum_items(prop, threads_mode_items); RNA_def_property_ui_text(prop, "Threads Mode", "Determine the amount of render threads used"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* motion blur */ prop = RNA_def_property(srna, "use_motion_blur", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_MBLUR); RNA_def_property_ui_text(prop, "Motion Blur", "Use multi-sampled 3D scene motion blur"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "motion_blur_samples", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "mblur_samples"); RNA_def_property_range(prop, 1, 32); RNA_def_property_ui_text(prop, "Motion Samples", "Number of scene samples to take with motion blur"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "motion_blur_shutter", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "blurfac"); @@ -3973,7 +4017,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.01, 2.0f, 1, 0); RNA_def_property_ui_text(prop, "Shutter", "Time taken in frames between shutter open and close"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* border */ prop = RNA_def_property(srna, "use_border", PROP_BOOLEAN, PROP_NONE); @@ -3982,80 +4026,80 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Border", "Render a user-defined border region, within the frame size " "(note that this disables save_buffers and full_sample)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "border_min_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "border.xmin"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Border Minimum X", "Minimum X value to for the render border"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "border_min_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "border.ymin"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Border Minimum Y", "Minimum Y value for the render border"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "border_max_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "border.xmax"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Border Maximum X", "Maximum X value for the render border"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "border_max_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "border.ymax"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Border Maximum Y", "Maximum Y value for the render border"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_crop_to_border", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_CROP); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Crop to Border", "Crop the rendered frame to the defined border size"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_placeholder", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "mode", R_TOUCH); RNA_def_property_ui_text(prop, "Placeholders", "Create empty placeholder files while rendering frames (similar to Unix 'touch')"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_overwrite", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "mode", R_NO_OVERWRITE); RNA_def_property_ui_text(prop, "Overwrite", "Overwrite existing files while rendering"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_compositing", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_DOCOMP); RNA_def_property_ui_text(prop, "Compositing", "Process the render result through the compositing pipeline, " "if compositing nodes are enabled"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_sequencer", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_DOSEQ); RNA_def_property_ui_text(prop, "Sequencer", "Process the render (and composited) result through the video sequence " "editor pipeline, if sequencer strips exist"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_color_management", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT); RNA_def_property_ui_text(prop, "Color Management", "Use linear workflow - gamma corrected imaging pipeline"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, "rna_RenderSettings_color_management_update"); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, "rna_RenderSettings_color_management_update"); prop = RNA_def_property(srna, "use_color_unpremultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "color_mgt_flag", R_COLOR_MANAGEMENT_PREDIVIDE); RNA_def_property_ui_text(prop, "Color Unpremultiply", "For premultiplied alpha render output, do color space conversion on " "colors without alpha, to avoid fringing on light backgrounds"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_file_extension", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXTENSION); RNA_def_property_ui_text(prop, "File Extensions", "Add the file format extensions to the rendered file name (eg: filename + .jpg)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #if 0 /* moved */ prop = RNA_def_property(srna, "file_format", PROP_ENUM, PROP_NONE); @@ -4063,7 +4107,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_enum_items(prop, image_type_items); RNA_def_property_enum_funcs(prop, NULL, "rna_RenderSettings_file_format_set", NULL); RNA_def_property_ui_text(prop, "File Format", "File format to save the rendered images as"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); #endif prop = RNA_def_property(srna, "file_extension", PROP_STRING, PROP_NONE); @@ -4080,13 +4124,13 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FREE_IMAGE); RNA_def_property_ui_text(prop, "Free Image Textures", "Free all image textures from memory after render, to save memory before compositing"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_free_unused_nodes", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_COMP_FREE); RNA_def_property_ui_text(prop, "Free Unused Nodes", "Free Nodes that are not used while compositing, to save memory"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_save_buffers", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_EXR_TILE_FILE); @@ -4094,7 +4138,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Save Buffers", "Save tiles for all RenderLayers and SceneNodes to files in the temp directory " "(saves memory, required for Full Sample)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_full_sample", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_FULL_SAMPLE); @@ -4102,20 +4146,20 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Full Sample", "Save for every anti-aliasing sample the entire RenderLayer results " "(this solves anti-aliasing issues with compositing)"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "displaymode"); RNA_def_property_enum_items(prop, display_mode_items); RNA_def_property_ui_text(prop, "Display", "Select where rendered images will be displayed"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_string_sdna(prop, NULL, "pic"); RNA_def_property_ui_text(prop, "Output Path", "Directory/name to save animations, # characters defines the position " "and length of frame numbers"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* Bake */ @@ -4189,88 +4233,88 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_TIME); RNA_def_property_ui_text(prop, "Stamp Time", "Include the rendered frame timecode as HH:MM:SS.FF in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_date", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_DATE); RNA_def_property_ui_text(prop, "Stamp Date", "Include the current date in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_frame", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_FRAME); RNA_def_property_ui_text(prop, "Stamp Frame", "Include the frame number in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_camera", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_CAMERA); RNA_def_property_ui_text(prop, "Stamp Camera", "Include the name of the active camera in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_lens", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_CAMERALENS); RNA_def_property_ui_text(prop, "Stamp Lens", "Include the active camera's lens in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_scene", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_SCENE); RNA_def_property_ui_text(prop, "Stamp Scene", "Include the name of the active scene in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_note", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_NOTE); RNA_def_property_ui_text(prop, "Stamp Note", "Include a custom note in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_marker", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_MARKER); RNA_def_property_ui_text(prop, "Stamp Marker", "Include the name of the last marker in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_filename", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_FILENAME); RNA_def_property_ui_text(prop, "Stamp Filename", "Include the .blend filename in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_sequencer_strip", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_SEQSTRIP); RNA_def_property_ui_text(prop, "Stamp Sequence Strip", "Include the name of the foreground sequence strip in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp_render_time", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_RENDERTIME); RNA_def_property_ui_text(prop, "Stamp Render Time", "Include the render time in image metadata"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "stamp_note_text", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "stamp_udata"); RNA_def_property_ui_text(prop, "Stamp Note Text", "Custom text to appear in the stamp note"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "use_stamp", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "stamp", R_STAMP_DRAW); RNA_def_property_ui_text(prop, "Render Stamp", "Render the stamp info text in the rendered image"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "stamp_font_size", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "stamp_font_id"); RNA_def_property_range(prop, 8, 64); RNA_def_property_ui_text(prop, "Font Size", "Size of the font used when rendering stamp text"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "stamp_foreground", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "fg_stamp"); RNA_def_property_array(prop, 4); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Text Color", "Color to use for stamp text"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); prop = RNA_def_property(srna, "stamp_background", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "bg_stamp"); RNA_def_property_array(prop, 4); RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Background", "Color to use behind stamp text"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* sequencer draw options */ @@ -4305,7 +4349,7 @@ static void rna_def_scene_render_data(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "scemode", R_SINGLE_LAYER); RNA_def_property_ui_text(prop, "Single Layer", "Only render the active layer"); RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* engine */ prop = RNA_def_property(srna, "engine", PROP_ENUM, PROP_NONE); @@ -4393,9 +4437,9 @@ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) func = RNA_def_function(srna, "link", "rna_Scene_object_link"); RNA_def_function_ui_description(func, "Link object to scene, run scene.update() after"); - RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "object", "Object", "", "Object to add to scene"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); parm = RNA_def_pointer(func, "base", "ObjectBase", "", "The newly created base"); RNA_def_function_return(func, parm); @@ -4403,16 +4447,16 @@ static void rna_def_scene_objects(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Unlink object from scene"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "object", "Object", "", "Object to remove from scene"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_funcs(prop, "rna_Scene_active_object_get", "rna_Scene_active_object_set", NULL, NULL); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_UNLINK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Active Object", "Active object for this scene"); /* Could call: ED_base_object_activate(C, scene->basact); * but would be a bad level call and it seems the notifier is enough */ - RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL); } @@ -4435,7 +4479,7 @@ static void rna_def_scene_bases(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_sdna(prop, NULL, "basact"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Active Base", "Active object base in the scene"); - RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL); } /* scene.timeline_markers */ @@ -4464,7 +4508,7 @@ static void rna_def_timeline_markers(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Remove a timeline marker"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "marker", "TimelineMarker", "", "Timeline marker to remove"); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); func = RNA_def_function(srna, "clear", "rna_TimeLine_clear"); RNA_def_function_ui_description(func, "Remove all timeline markers"); @@ -4502,7 +4546,7 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_funcs(prop, "rna_Scene_active_keying_set_get", "rna_Scene_active_keying_set_set", NULL, NULL); RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes"); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "active_keyingset"); @@ -4510,7 +4554,7 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop) "rna_Scene_active_keying_set_index_set", NULL); RNA_def_property_ui_text(prop, "Active Keying Set Index", "Current Keying Set index (negative for 'builtin' and positive for 'absolute')"); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL); } static void rna_def_scene_keying_sets_all(BlenderRNA *brna, PropertyRNA *cprop) @@ -4531,7 +4575,7 @@ static void rna_def_scene_keying_sets_all(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_pointer_funcs(prop, "rna_Scene_active_keying_set_get", "rna_Scene_active_keying_set_set", NULL, NULL); RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes"); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL); prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "active_keyingset"); @@ -4539,7 +4583,7 @@ static void rna_def_scene_keying_sets_all(BlenderRNA *brna, PropertyRNA *cprop) "rna_Scene_active_keying_set_index_set", NULL); RNA_def_property_ui_text(prop, "Active Keying Set Index", "Current Keying Set index (negative for 'builtin' and positive for 'absolute')"); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL); } /* Runtime property, used to remember uv indices, used only in UV stitch for now. @@ -4568,7 +4612,9 @@ void RNA_def_scene(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; + PropertyRNA *parm; static EnumPropertyItem audio_distance_model_items[] = { {0, "NONE", 0, "None", "No distance attenuation"}, @@ -4578,13 +4624,15 @@ void RNA_def_scene(BlenderRNA *brna) {4, "LINEAR_CLAMPED", 0, "Linear Clamped", "Linear distance model with clamping"}, {5, "EXPONENT", 0, "Exponent", "Exponent distance model"}, {6, "EXPONENT_CLAMPED", 0, "Exponent Clamped", "Exponent distance model with clamping"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; static EnumPropertyItem sync_mode_items[] = { {0, "NONE", 0, "No Sync", "Do not sync, play every frame"}, {SCE_FRAME_DROP, "FRAME_DROP", 0, "Frame Dropping", "Drop frames if playback is too slow"}, {AUDIO_SYNC, "AUDIO_SYNC", 0, "AV-sync", "Sync to audio playback, dropping frames"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; /* Struct definition */ srna = RNA_def_struct(brna, "Scene", "ID"); @@ -4598,20 +4646,20 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); RNA_def_property_ui_text(prop, "Camera", "Active camera, used for rendering the scene"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, "rna_Scene_view3d_update"); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, "rna_Scene_view3d_update"); prop = RNA_def_property(srna, "background_set", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "set"); RNA_def_property_struct_type(prop, "Scene"); - RNA_def_property_flag(prop, PROP_EDITABLE|PROP_ID_SELF_CHECK); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_pointer_funcs(prop, NULL, "rna_Scene_set_set", NULL, NULL); RNA_def_property_ui_text(prop, "Background Scene", "Background set scene"); - RNA_def_property_update(prop, NC_SCENE|NA_EDITED, NULL); + RNA_def_property_update(prop, NC_SCENE | NA_EDITED, NULL); prop = RNA_def_property(srna, "world", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "World", "World used for rendering the scene"); - RNA_def_property_update(prop, NC_SCENE|ND_WORLD, "rna_Scene_glsl_update"); + RNA_def_property_update(prop, NC_SCENE | ND_WORLD, "rna_Scene_glsl_update"); prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ_LENGTH); RNA_def_property_float_sdna(prop, NULL, "cursor"); @@ -4637,17 +4685,17 @@ void RNA_def_scene(BlenderRNA *brna) /* Layers */ prop = RNA_def_property(srna, "layers", PROP_BOOLEAN, PROP_LAYER_MEMBER); - /* this seems to be too much trouble with depsgraph updates/etc. currently (20110420) */ + /* this seems to be too much trouble with depsgraph updates/etc. currently (20110420) */ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_boolean_sdna(prop, NULL, "lay", 1); RNA_def_property_array(prop, 20); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_layer_set"); RNA_def_property_ui_text(prop, "Layers", "Visible layers - Shift-Click to select multiple layers"); - RNA_def_property_update(prop, NC_SCENE|ND_LAYER, "rna_Scene_layer_update"); + RNA_def_property_update(prop, NC_SCENE | ND_LAYER, "rna_Scene_layer_update"); /* active layer */ prop = RNA_def_property(srna, "active_layer", PROP_INT, PROP_NONE); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_int_funcs(prop, "rna_Scene_active_layer_get", NULL, NULL); RNA_def_property_ui_text(prop, "Active Layer", "Active scene layer index"); @@ -4659,12 +4707,12 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Scene_current_frame_set", NULL); RNA_def_property_ui_text(prop, "Current Frame", "Current Frame, to update animation data from python frame_set() instead"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, "rna_Scene_frame_update"); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, "rna_Scene_frame_update"); prop = RNA_def_property(srna, "frame_subframe", PROP_FLOAT, PROP_TIME); RNA_def_property_float_sdna(prop, NULL, "r.subframe"); RNA_def_property_ui_text(prop, "Current Sub-Frame", ""); - RNA_def_property_clear_flag(prop, PROP_ANIMATABLE|PROP_EDITABLE); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -4672,7 +4720,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Scene_start_frame_set", NULL); RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "Start Frame", "First frame of the playback/rendering range"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME_RANGE, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -4680,7 +4728,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_funcs(prop, NULL, "rna_Scene_end_frame_set", NULL); RNA_def_property_range(prop, MINFRAME, MAXFRAME); RNA_def_property_ui_text(prop, "End Frame", "Final frame of the playback/rendering range"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME_RANGE, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME_RANGE, NULL); prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); @@ -4689,7 +4737,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_range(prop, 1, 100, 1, 0); RNA_def_property_ui_text(prop, "Frame Step", "Number of frames to skip forward while rendering/playing back each frame"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); /* Preview Range (frame-range for UI playback) */ prop = RNA_def_property(srna, "use_preview_range", PROP_BOOLEAN, PROP_NONE); @@ -4699,7 +4747,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Preview Range", "Use an alternative start/end frame for UI playback, " "rather than the scene start/end frame"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); RNA_def_property_ui_icon(prop, ICON_PREVIEW_RANGE, 0); prop = RNA_def_property(srna, "frame_preview_start", PROP_INT, PROP_TIME); @@ -4707,20 +4755,20 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "r.psfra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_start_frame_set", NULL); RNA_def_property_ui_text(prop, "Preview Range Start Frame", "Alternative start frame for UI playback"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); prop = RNA_def_property(srna, "frame_preview_end", PROP_INT, PROP_TIME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_sdna(prop, NULL, "r.pefra"); RNA_def_property_int_funcs(prop, NULL, "rna_Scene_preview_range_end_frame_set", NULL); RNA_def_property_ui_text(prop, "Preview Range End Frame", "Alternative end frame for UI playback"); - RNA_def_property_update(prop, NC_SCENE|ND_FRAME, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_FRAME, NULL); /* Stamp */ prop = RNA_def_property(srna, "use_stamp_note", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "r.stamp_udata"); RNA_def_property_ui_text(prop, "Stamp Note", "User defined note for the render stamping"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* Animation Data (for Scene) */ rna_def_animdata_common(srna); @@ -4731,7 +4779,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* DO NOT MAKE THIS EDITABLE, OR NLA EDITOR BREAKS */ RNA_def_property_ui_text(prop, "NLA TweakMode", "Whether there is any action referenced by NLA being edited (strictly read-only)"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_GRAPH, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); /* Frame dropping flag for playback and sync enum */ prop = RNA_def_property(srna, "use_frame_drop", PROP_BOOLEAN, PROP_NONE); @@ -4755,7 +4803,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1); RNA_def_property_boolean_funcs(prop, NULL, "rna_Scene_use_nodes_set"); RNA_def_property_ui_text(prop, "Use Nodes", "Enable the compositing node tree"); - RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* Sequencer */ prop = RNA_def_property(srna, "sequence_editor", PROP_POINTER, PROP_NONE); @@ -4763,12 +4811,20 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "SequenceEditor"); RNA_def_property_ui_text(prop, "Sequence Editor", ""); + func = RNA_def_function(srna, "sequence_editor_create", "BKE_sequencer_editing_ensure"); + RNA_def_function_ui_description(func, "Ensure sequence editor is valid in this scene"); + parm = RNA_def_pointer(func, "sequence_editor", "SequenceEditor", "", "New sequence editor data or NULL"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "sequence_editor_clear", "BKE_sequencer_editing_free"); + RNA_def_function_ui_description(func, "Clear sequence editor in this scene"); + /* Keying Sets */ prop = RNA_def_property(srna, "keying_sets", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "keyingsets", NULL); RNA_def_property_struct_type(prop, "KeyingSet"); RNA_def_property_ui_text(prop, "Absolute Keying Sets", "Absolute Keying Sets for this Scene"); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL); rna_def_scene_keying_sets(brna, prop); prop = RNA_def_property(srna, "keying_sets_all", PROP_COLLECTION, PROP_NONE); @@ -4778,7 +4834,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_struct_type(prop, "KeyingSet"); RNA_def_property_ui_text(prop, "All Keying Sets", "All Keying Sets available for use (Builtins and Absolute Keying Sets for this Scene)"); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_KEYINGSET, NULL); rna_def_scene_keying_sets_all(brna, prop); /* Tool Settings */ @@ -4899,7 +4955,7 @@ void RNA_def_scene(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_struct_type(prop, "MovieClip"); RNA_def_property_ui_text(prop, "Active Movie Clip", "Active movie clip used for constraints and viewport drawing"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_VIEW3D, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); /* Nestled Data */ rna_def_tool_settings(brna); diff --git a/source/blender/makesrna/intern/rna_scene_api.c b/source/blender/makesrna/intern/rna_scene_api.c index c92a29cec3c..ca01d61f630 100644 --- a/source/blender/makesrna/intern/rna_scene_api.c +++ b/source/blender/makesrna/intern/rna_scene_api.c @@ -56,11 +56,11 @@ void rna_Scene_frame_set(Scene *scene, int frame, float subframe) scene->r.subframe = subframe; CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME); - scene_update_for_newframe(G.main, scene, (1<<20) - 1); - scene_camera_switch_update(scene); + BKE_scene_update_for_newframe(G.main, scene, (1<<20) - 1); + BKE_scene_camera_switch_update(scene); /* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call - * scene_update_for_newframe which will loose any un-keyed changes [#24690] */ + * BKE_scene_update_for_newframe which will loose any un-keyed changes [#24690] */ /* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */ /* instead just redraw the views */ @@ -69,13 +69,13 @@ void rna_Scene_frame_set(Scene *scene, int frame, float subframe) static void rna_Scene_update_tagged(Scene *scene) { - scene_update_tagged(G.main, scene); + BKE_scene_update_tagged(G.main, scene); } static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) { if (BKE_imtype_is_movie(rd->im_format.imtype)) - BKE_makeanimstring(name, rd); + BKE_movie_filepath_get(name, rd); else BKE_makepicstring(name, rd->pic, G.main->name, (frame == INT_MIN) ? rd->cfra : frame, rd->im_format.imtype, rd->scemode & R_EXTENSION, TRUE); @@ -85,9 +85,9 @@ static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ #include "../../collada/collada.h" -static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int second_life) +static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected, int apply_modifiers, int second_life) { - collada_export(scene, filepath, selected, second_life); + collada_export(scene, filepath, selected, apply_modifiers, second_life); } #endif @@ -115,7 +115,8 @@ void RNA_api_scene(StructRNA *srna) parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file"); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ - parm = RNA_def_boolean(func, "selected", 0, "Export only selected", "Export only selected elements"); + parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements"); + parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers (in Preview resolution)"); parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); RNA_def_function_ui_description(func, "Export to collada file"); #endif diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index 775e943b9a2..d64dd1a626e 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -49,6 +49,14 @@ #include "WM_types.h" #include "BLI_math.h" +typedef struct EffectInfo { + const char *struct_name; + const char *ui_name; + const char *ui_desc; + void (*func)(StructRNA *); + int inputs; +} EffectInfo; + #ifdef RNA_RUNTIME /* build a temp referene to the parent */ @@ -64,8 +72,8 @@ static void meta_tmp_ref(Sequence *seq_par, Sequence *seq) static void rna_SequenceEditor_sequences_all_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Scene *scene = (Scene*)ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Scene *scene = (Scene *)ptr->id.data; + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); meta_tmp_ref(NULL, ed->seqbase.first); @@ -75,19 +83,19 @@ static void rna_SequenceEditor_sequences_all_begin(CollectionPropertyIterator *i static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *iter) { ListBaseIterator *internal = iter->internal; - Sequence *seq = (Sequence*)internal->link; + Sequence *seq = (Sequence *)internal->link; if (seq->seqbase.first) - internal->link = (Link*)seq->seqbase.first; + internal->link = (Link *)seq->seqbase.first; else if (seq->next) - internal->link = (Link*)seq->next; + internal->link = (Link *)seq->next; else { internal->link = NULL; do { seq = seq->tmp; /* XXX - seq's don't reference their parents! */ if (seq && seq->next) { - internal->link = (Link*)seq->next; + internal->link = (Link *)seq->next; break; } } while (seq); @@ -99,10 +107,10 @@ static void rna_SequenceEditor_sequences_all_next(CollectionPropertyIterator *it /* internal use */ static int rna_SequenceEditor_elements_length(PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; /* Hack? copied from sequencer.c::reload_sequence_new_file() */ - size_t olen = MEM_allocN_len(seq->strip->stripdata)/sizeof(struct StripElem); + size_t olen = MEM_allocN_len(seq->strip->stripdata) / sizeof(struct StripElem); /* the problem with seq->strip->len and seq->len is that it's discounted from the offset (hard cut trim) */ return (int) olen; @@ -110,27 +118,27 @@ static int rna_SequenceEditor_elements_length(PointerRNA *ptr) static void rna_SequenceEditor_elements_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; - rna_iterator_array_begin(iter, (void*)seq->strip->stripdata, sizeof(StripElem), + Sequence *seq = (Sequence *)ptr->data; + rna_iterator_array_begin(iter, (void *)seq->strip->stripdata, sizeof(StripElem), rna_SequenceEditor_elements_length(ptr), 0, NULL); } static void rna_Sequence_frame_change_update(Scene *scene, Sequence *seq) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); ListBase *seqbase = seq_seqbase(&ed->seqbase, seq); calc_sequence_disp(scene, seq); if (seq_test_overlap(seqbase, seq)) { shuffle_seq(seqbase, seq, scene); /* XXX - BROKEN!, uses context seqbasep */ } - sort_seq(scene); + BKE_sequencer_sort(scene); } static void rna_Sequence_start_frame_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; seq_translate(scene, seq, value - seq->start); rna_Sequence_frame_change_update(scene, seq); @@ -138,8 +146,8 @@ static void rna_Sequence_start_frame_set(PointerRNA *ptr, int value) static void rna_Sequence_start_frame_final_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; seq_tx_set_final_left(seq, value); seq_single_fix(seq); @@ -148,8 +156,8 @@ static void rna_Sequence_start_frame_final_set(PointerRNA *ptr, int value) static void rna_Sequence_end_frame_final_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; seq_tx_set_final_right(seq, value); seq_single_fix(seq); @@ -158,8 +166,8 @@ static void rna_Sequence_end_frame_final_set(PointerRNA *ptr, int value) static void rna_Sequence_anim_startofs_final_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; seq->anim_startofs = MIN2(value, seq->len + seq->anim_startofs); @@ -169,8 +177,8 @@ static void rna_Sequence_anim_startofs_final_set(PointerRNA *ptr, int value) static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; seq->anim_endofs = MIN2(value, seq->len + seq->anim_endofs); @@ -180,52 +188,52 @@ static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value) static void rna_Sequence_frame_length_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; - seq_tx_set_final_right(seq, seq->start+value); + seq_tx_set_final_right(seq, seq->start + value); rna_Sequence_frame_change_update(scene, seq); } static int rna_Sequence_frame_length_get(PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; - return seq_tx_get_final_right(seq, 0)-seq_tx_get_final_left(seq, 0); + Sequence *seq = (Sequence *)ptr->data; + return seq_tx_get_final_right(seq, 0) - seq_tx_get_final_left(seq, 0); } static int rna_Sequence_frame_editable(PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; /* Effect sequences' start frame and length must be readonly! */ - return (get_sequence_effect_num_inputs(seq->type))? 0: PROP_EDITABLE; + return (get_sequence_effect_num_inputs(seq->type)) ? 0 : PROP_EDITABLE; } static void rna_Sequence_channel_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; - Scene *scene = (Scene*)ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Sequence *seq = (Sequence *)ptr->data; + Scene *scene = (Scene *)ptr->id.data; + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); ListBase *seqbase = seq_seqbase(&ed->seqbase, seq); seq->machine = value; - if ( seq_test_overlap(seqbase, seq) ) { + if (seq_test_overlap(seqbase, seq) ) { shuffle_seq(seqbase, seq, scene); /* XXX - BROKEN!, uses context seqbasep */ } - sort_seq(scene); + BKE_sequencer_sort(scene); } /* properties that need to allocate structs */ static void rna_Sequence_use_color_balance_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; int c; if (value) { seq->flag |= SEQ_USE_COLOR_BALANCE; if (seq->strip->color_balance == NULL) { seq->strip->color_balance = MEM_callocN(sizeof(struct StripColorBalance), "StripColorBalance"); - for (c = 0; c<3; c++) { + for (c = 0; c < 3; c++) { seq->strip->color_balance->lift[c] = 1.0f; seq->strip->color_balance->gamma[c] = 1.0f; seq->strip->color_balance->gain[c] = 1.0f; @@ -239,15 +247,14 @@ static void rna_Sequence_use_color_balance_set(PointerRNA *ptr, int value) static void rna_Sequence_use_proxy_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; if (value) { seq->flag |= SEQ_USE_PROXY; if (seq->strip->proxy == NULL) { seq->strip->proxy = MEM_callocN(sizeof(struct StripProxy), "StripProxy"); seq->strip->proxy->quality = 90; seq->strip->proxy->build_tc_flags = SEQ_PROXY_TC_ALL; - seq->strip->proxy->build_size_flags - = SEQ_PROXY_IMAGE_SIZE_25; + seq->strip->proxy->build_size_flags = SEQ_PROXY_IMAGE_SIZE_25; } } else { @@ -257,7 +264,7 @@ static void rna_Sequence_use_proxy_set(PointerRNA *ptr, int value) static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; if (value) { seq->flag |= SEQ_USE_TRANSFORM; if (seq->strip->transform == NULL) { @@ -271,7 +278,7 @@ static void rna_Sequence_use_translation_set(PointerRNA *ptr, int value) static void rna_Sequence_use_crop_set(PointerRNA *ptr, int value) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; if (value) { seq->flag |= SEQ_USE_CROP; if (seq->strip->crop == NULL) { @@ -297,7 +304,7 @@ static int transform_seq_cmp_cb(Sequence *seq, void *arg_pt) static char *rna_SequenceTransform_path(PointerRNA *ptr) { Scene *scene = ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; struct { Sequence *seq; void *transform; } data; @@ -308,8 +315,8 @@ static char *rna_SequenceTransform_path(PointerRNA *ptr) seqbase_recursive_apply(&ed->seqbase, transform_seq_cmp_cb, &data); seq = data.seq; - if (seq && seq->name+2) - return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform", seq->name+2); + if (seq && seq->name + 2) + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].transform", seq->name + 2); else return BLI_strdup(""); } @@ -328,7 +335,7 @@ static int crop_seq_cmp_cb(Sequence *seq, void *arg_pt) static char *rna_SequenceCrop_path(PointerRNA *ptr) { Scene *scene = ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; struct { Sequence *seq; void *crop; } data; @@ -339,8 +346,8 @@ static char *rna_SequenceCrop_path(PointerRNA *ptr) seqbase_recursive_apply(&ed->seqbase, crop_seq_cmp_cb, &data); seq = data.seq; - if (seq && seq->name+2) - return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop", seq->name+2); + if (seq && seq->name + 2) + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].crop", seq->name + 2); else return BLI_strdup(""); } @@ -349,28 +356,28 @@ static char *rna_SequenceCrop_path(PointerRNA *ptr) /* name functions that ignore the first two characters */ static void rna_Sequence_name_get(PointerRNA *ptr, char *value) { - Sequence *seq = (Sequence*)ptr->data; - BLI_strncpy(value, seq->name+2, sizeof(seq->name)-2); + Sequence *seq = (Sequence *)ptr->data; + BLI_strncpy(value, seq->name + 2, sizeof(seq->name) - 2); } static int rna_Sequence_name_length(PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; - return strlen(seq->name+2); + Sequence *seq = (Sequence *)ptr->data; + return strlen(seq->name + 2); } static void rna_Sequence_name_set(PointerRNA *ptr, const char *value) { - Scene *scene = (Scene*)ptr->id.data; - Sequence *seq = (Sequence*)ptr->data; + Scene *scene = (Scene *)ptr->id.data; + Sequence *seq = (Sequence *)ptr->data; char oldname[sizeof(seq->name)]; AnimData *adt; /* make a copy of the old name first */ - BLI_strncpy(oldname, seq->name+2, sizeof(seq->name)-2); + BLI_strncpy(oldname, seq->name + 2, sizeof(seq->name) - 2); /* copy the new name into the name slot */ - BLI_strncpy_utf8(seq->name+2, value, sizeof(seq->name)-2); + BLI_strncpy_utf8(seq->name + 2, value, sizeof(seq->name) - 2); /* make sure the name is unique */ seqbase_unique_name_recursive(&scene->ed->seqbase, seq); @@ -381,12 +388,12 @@ static void rna_Sequence_name_set(PointerRNA *ptr, const char *value) /* BKE_all_animdata_fix_paths_rename(NULL, "sequence_editor.sequences_all", oldname, seq->name+2); */ adt = BKE_animdata_from_id(&scene->id); if (adt) - BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, "sequence_editor.sequences_all", oldname, seq->name+2, 0, 0, 1); + BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, "sequence_editor.sequences_all", oldname, seq->name + 2, 0, 0, 1); } -static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) +static StructRNA *rna_Sequence_refine(struct PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; switch (seq->type) { case SEQ_IMAGE: @@ -402,14 +409,21 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) case SEQ_SOUND: return &RNA_SoundSequence; case SEQ_CROSS: + return &RNA_CrossSequence; case SEQ_ADD: + return &RNA_AddSequence; case SEQ_SUB: + return &RNA_SubtractSequence; case SEQ_ALPHAOVER: + return &RNA_AlphaOverSequence; case SEQ_ALPHAUNDER: + return &RNA_AlphaUnderSequence; case SEQ_GAMCROSS: + return &RNA_GammaCrossSequence; case SEQ_MUL: + return &RNA_MultiplySequence; case SEQ_OVERDROP: - return &RNA_EffectSequence; + return &RNA_OverDropSequence; case SEQ_MULTICAM: return &RNA_MulticamSequence; case SEQ_ADJUSTMENT: @@ -431,13 +445,13 @@ static StructRNA* rna_Sequence_refine(struct PointerRNA *ptr) static char *rna_Sequence_path(PointerRNA *ptr) { - Sequence *seq = (Sequence*)ptr->data; + Sequence *seq = (Sequence *)ptr->data; /* sequencer data comes from scene... * TODO: would be nice to make SequenceEditor data a datablock of its own (for shorter paths) */ - if (seq->name+2) - return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"]", seq->name+2); + if (seq->name + 2) + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"]", seq->name + 2); else return BLI_strdup(""); } @@ -445,7 +459,7 @@ static char *rna_Sequence_path(PointerRNA *ptr) static PointerRNA rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator *iter) { ListBaseIterator *internal = iter->internal; - MetaStack *ms = (MetaStack*)internal->link; + MetaStack *ms = (MetaStack *)internal->link; return rna_pointer_inherit_refine(&iter->parent, &RNA_Sequence, ms->parseq); } @@ -453,7 +467,7 @@ static PointerRNA rna_SequenceEditor_meta_stack_get(CollectionPropertyIterator * /* TODO, expose seq path setting as a higher level sequencer BKE function */ static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); if (seq->type == SEQ_SOUND && seq->sound) { /* for sound strips we need to update the sound as well. @@ -473,14 +487,14 @@ static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value) static void rna_Sequence_filepath_get(PointerRNA *ptr, char *value) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); BLI_join_dirfile(value, FILE_MAX, seq->strip->dir, seq->strip->stripdata->name); } static int rna_Sequence_filepath_length(PointerRNA *ptr) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); char path[FILE_MAX]; BLI_join_dirfile(path, sizeof(path), seq->strip->dir, seq->strip->stripdata->name); @@ -489,20 +503,20 @@ static int rna_Sequence_filepath_length(PointerRNA *ptr) static void rna_Sequence_proxy_filepath_set(PointerRNA *ptr, const char *value) { - StripProxy *proxy = (StripProxy*)(ptr->data); + StripProxy *proxy = (StripProxy *)(ptr->data); BLI_split_dirfile(value, proxy->dir, proxy->file, sizeof(proxy->dir), sizeof(proxy->file)); } static void rna_Sequence_proxy_filepath_get(PointerRNA *ptr, char *value) { - StripProxy *proxy = (StripProxy*)(ptr->data); + StripProxy *proxy = (StripProxy *)(ptr->data); BLI_join_dirfile(value, FILE_MAX, proxy->dir, proxy->file); } static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr) { - StripProxy *proxy = (StripProxy*)(ptr->data); + StripProxy *proxy = (StripProxy *)(ptr->data); char path[FILE_MAX]; BLI_join_dirfile(path, sizeof(path), proxy->dir, proxy->file); @@ -511,7 +525,7 @@ static int rna_Sequence_proxy_filepath_length(PointerRNA *ptr) static void rna_Sequence_volume_set(PointerRNA *ptr, float value) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); seq->volume = value; if (seq->scene_sound) @@ -520,7 +534,7 @@ static void rna_Sequence_volume_set(PointerRNA *ptr, float value) static void rna_Sequence_pitch_set(PointerRNA *ptr, float value) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); seq->pitch = value; if (seq->scene_sound) @@ -529,7 +543,7 @@ static void rna_Sequence_pitch_set(PointerRNA *ptr, float value) static void rna_Sequence_pan_set(PointerRNA *ptr, float value) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); seq->pan = value; if (seq->scene_sound) @@ -539,11 +553,13 @@ static void rna_Sequence_pan_set(PointerRNA *ptr, float value) static int rna_Sequence_input_count_get(PointerRNA *ptr) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); return get_sequence_effect_num_inputs(seq->type); } -/*static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value) + +#if 0 +static void rna_SoundSequence_filename_set(PointerRNA *ptr, const char *value) { Sequence *seq= (Sequence*)(ptr->data); BLI_split_dirfile(value, seq->strip->dir, seq->strip->stripdata->name, sizeof(seq->strip->dir), @@ -554,11 +570,12 @@ static void rna_SequenceElement_filename_set(PointerRNA *ptr, const char *value) { StripElem *elem= (StripElem*)(ptr->data); BLI_split_file_part(value, elem->name, sizeof(elem->name)); -}*/ +} +#endif static void rna_Sequence_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed) free_imbuf_seq(scene, &ed->seqbase, FALSE, TRUE); @@ -566,7 +583,7 @@ static void rna_Sequence_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *U static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *scene, PointerRNA *ptr) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); free_imbuf_seq(scene, &ed->seqbase, FALSE, FALSE); @@ -576,7 +593,7 @@ static void rna_Sequence_update_reopen_files(Main *UNUSED(bmain), Scene *scene, static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); seq_update_muting(ed); rna_Sequence_update(bmain, scene, ptr); @@ -584,7 +601,7 @@ static void rna_Sequence_mute_update(Main *bmain, Scene *scene, PointerRNA *ptr) static void rna_Sequence_filepath_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); reload_sequence_new_file(scene, seq, TRUE); calc_sequence(scene, seq); rna_Sequence_update(bmain, scene, ptr); @@ -603,7 +620,7 @@ static int seqproxy_seq_cmp_cb(Sequence *seq, void *arg_pt) static void rna_Sequence_tcindex_update(Main *bmain, Scene *scene, PointerRNA *ptr) { - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; struct { Sequence *seq; void *seq_proxy; } data; @@ -621,12 +638,12 @@ static void rna_Sequence_tcindex_update(Main *bmain, Scene *scene, PointerRNA *p /* do_versions? */ static float rna_Sequence_opacity_get(PointerRNA *ptr) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); return seq->blend_opacity / 100.0f; } static void rna_Sequence_opacity_set(PointerRNA *ptr, float value) { - Sequence *seq = (Sequence*)(ptr->data); + Sequence *seq = (Sequence *)(ptr->data); CLAMP(value, 0.0f, 1.0f); seq->blend_opacity = value * 100.0f; } @@ -645,7 +662,7 @@ static int colbalance_seq_cmp_cb(Sequence *seq, void *arg_pt) static char *rna_SequenceColorBalance_path(PointerRNA *ptr) { Scene *scene = ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); Sequence *seq; struct { Sequence *seq; void *color_balance; } data; @@ -656,8 +673,8 @@ static char *rna_SequenceColorBalance_path(PointerRNA *ptr) seqbase_recursive_apply(&ed->seqbase, colbalance_seq_cmp_cb, &data); seq = data.seq; - if (seq && seq->name+2) - return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", seq->name+2); + if (seq && seq->name + 2) + return BLI_sprintfN("sequence_editor.sequences_all[\"%s\"].color_balance", seq->name + 2); else return BLI_strdup(""); } @@ -665,7 +682,7 @@ static char *rna_SequenceColorBalance_path(PointerRNA *ptr) static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, int value) { Scene *scene = ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; @@ -684,7 +701,7 @@ static void rna_SequenceEditor_overlay_lock_set(PointerRNA *ptr, int value) static int rna_SequenceEditor_overlay_frame_get(PointerRNA *ptr) { Scene *scene = (Scene *)ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return scene->r.cfra; @@ -699,7 +716,7 @@ static int rna_SequenceEditor_overlay_frame_get(PointerRNA *ptr) static void rna_SequenceEditor_overlay_frame_set(PointerRNA *ptr, int value) { Scene *scene = (Scene *)ptr->id.data; - Editing *ed = seq_give_editing(scene, FALSE); + Editing *ed = BKE_sequencer_editing_get(scene, FALSE); if (ed == NULL) return; @@ -742,7 +759,7 @@ static void rna_def_strip_element(BlenderRNA *brna) prop = RNA_def_property(srna, "filename", PROP_STRING, PROP_FILENAME); RNA_def_property_string_sdna(prop, NULL, "name"); RNA_def_property_ui_text(prop, "Filename", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "orig_width", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "orig_width"); @@ -768,25 +785,25 @@ static void rna_def_strip_crop(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "top"); RNA_def_property_ui_text(prop, "Top", ""); RNA_def_property_ui_range(prop, 0, 4096, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "min_y", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "bottom"); RNA_def_property_ui_text(prop, "Bottom", ""); RNA_def_property_ui_range(prop, 0, 4096, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "min_x", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "left"); RNA_def_property_ui_text(prop, "Left", ""); RNA_def_property_ui_range(prop, 0, 4096, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "max_x", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "right"); RNA_def_property_ui_text(prop, "Right", ""); RNA_def_property_ui_range(prop, 0, 4096, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); RNA_def_struct_path_func(srna, "rna_SequenceCrop_path"); } @@ -804,13 +821,13 @@ static void rna_def_strip_transform(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "xofs"); RNA_def_property_ui_text(prop, "Offset X", ""); RNA_def_property_ui_range(prop, -4096, 4096, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "offset_y", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "yofs"); RNA_def_property_ui_text(prop, "Offset Y", ""); RNA_def_property_ui_range(prop, -4096, 4096, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); RNA_def_struct_path_func(srna, "rna_SequenceTransform_path"); @@ -833,7 +850,8 @@ static void rna_def_strip_proxy(BlenderRNA *brna) {SEQ_PROXY_TC_RECORD_RUN_NO_GAPS, "RECORD_RUN_NO_GAPS", 0, "Record Run No Gaps", "Like record run, but ignore timecode, " "changes in framerate or dropouts"}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "SequenceProxy", NULL); RNA_def_struct_ui_text(srna, "Sequence Proxy", "Proxy parameters for a sequence strip"); @@ -842,14 +860,14 @@ static void rna_def_strip_proxy(BlenderRNA *brna) prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "dir"); RNA_def_property_ui_text(prop, "Directory", "Location to store the proxy files"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_ui_text(prop, "Path", "Location of custom proxy file"); RNA_def_property_string_funcs(prop, "rna_Sequence_proxy_filepath_get", "rna_Sequence_proxy_filepath_length", "rna_Sequence_proxy_filepath_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "build_25", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "build_size_flags", SEQ_PROXY_IMAGE_SIZE_25); @@ -888,7 +906,7 @@ static void rna_def_strip_proxy(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "tc"); RNA_def_property_enum_items(prop, seq_tc_items); RNA_def_property_ui_text(prop, "Timecode", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_tcindex_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_tcindex_update"); } @@ -904,36 +922,37 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) prop = RNA_def_property(srna, "lift", PROP_FLOAT, PROP_COLOR); RNA_def_property_ui_text(prop, "Lift", "Color balance lift (shadows)"); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "gamma", PROP_FLOAT, PROP_COLOR); RNA_def_property_ui_text(prop, "Gamma", "Color balance gamma (midtones)"); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "gain", PROP_FLOAT, PROP_COLOR); RNA_def_property_ui_text(prop, "Gain", "Color balance gain (highlights)"); RNA_def_property_ui_range(prop, 0, 2, 0.1, 3); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "invert_gain", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_GAIN); RNA_def_property_ui_text(prop, "Inverse Gain", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "invert_gamma", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_GAMMA); RNA_def_property_ui_text(prop, "Inverse Gamma", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "invert_lift", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_COLOR_BALANCE_INVERSE_LIFT); RNA_def_property_ui_text(prop, "Inverse Lift", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); RNA_def_struct_path_func(srna, "rna_SequenceColorBalance_path"); - /* not yet used + /* not yet used */ +#if 0 prop= RNA_def_property(srna, "exposure", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Exposure", ""); @@ -942,9 +961,23 @@ static void rna_def_strip_color_balance(BlenderRNA *brna) prop= RNA_def_property(srna, "saturation", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Saturation", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); */ + RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); +#endif } +EnumPropertyItem blend_mode_items[] = { + {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, + {SEQ_CROSS, "CROSS", 0, "Cross", ""}, + {SEQ_ADD, "ADD", 0, "Add", ""}, + {SEQ_SUB, "SUBTRACT", 0, "Subtract", ""}, + {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, + {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, + {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {SEQ_MUL, "MULTIPLY", 0, "Multiply", ""}, + {SEQ_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, + {0, NULL, 0, NULL, NULL} +}; + static void rna_def_sequence(BlenderRNA *brna) { StructRNA *srna; @@ -973,19 +1006,8 @@ static void rna_def_sequence(BlenderRNA *brna) {SEQ_SPEED, "SPEED", 0, "Speed", ""}, {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, - {0, NULL, 0, NULL, NULL}}; - - static const EnumPropertyItem blend_mode_items[] = { - {SEQ_BLEND_REPLACE, "REPLACE", 0, "Replace", ""}, - {SEQ_CROSS, "CROSS", 0, "Cross", ""}, - {SEQ_ADD, "ADD", 0, "Add", ""}, - {SEQ_SUB, "SUBTRACT", 0, "Subtract", ""}, - {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, - {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, - {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, - {SEQ_MUL, "MULTIPLY", 0, "Multiply", ""}, - {SEQ_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, - {0, NULL, 0, NULL, NULL}}; + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "Sequence", NULL); RNA_def_struct_ui_text(srna, "Sequence", "Sequence strip in the sequence editor"); @@ -994,65 +1016,56 @@ static void rna_def_sequence(BlenderRNA *brna) prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_string_funcs(prop, "rna_Sequence_name_get", "rna_Sequence_name_length", "rna_Sequence_name_set"); - RNA_def_property_string_maxlength(prop, sizeof(((Sequence*)NULL)->name)-2); + RNA_def_property_string_maxlength(prop, sizeof(((Sequence *)NULL)->name) - 2); RNA_def_property_ui_text(prop, "Name", ""); RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL); prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_enum_items(prop, seq_type_items); RNA_def_property_ui_text(prop, "Type", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - /*prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); */ - /*RNA_def_property_ui_text(prop, "IPO Curves", "IPO curves used by this sequence"); */ /* flags */ - prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); RNA_def_property_ui_text(prop, "Select", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER|NA_SELECTED, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER | NA_SELECTED, NULL); prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LEFTSEL); RNA_def_property_ui_text(prop, "Left Handle Selected", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER|NA_SELECTED, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER | NA_SELECTED, NULL); prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_RIGHTSEL); RNA_def_property_ui_text(prop, "Right Handle Selected", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER|NA_SELECTED, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER | NA_SELECTED, NULL); prop = RNA_def_property(srna, "mute", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MUTE); RNA_def_property_ui_text(prop, "Mute", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_mute_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_mute_update"); prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_LOCK); RNA_def_property_ui_text(prop, "Lock", "Lock strip so that it can't be transformed"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); - - prop = RNA_def_property(srna, "waveform", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_AUDIO_DRAW_WAVEFORM); - RNA_def_property_ui_text(prop, "Draw Waveform", "Whether to draw the sound's waveform"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, NULL); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL); /* strip positioning */ - prop = RNA_def_property(srna, "frame_final_duration", PROP_INT, PROP_TIME); RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip after the handles are applied"); RNA_def_property_int_funcs(prop, "rna_Sequence_frame_length_get", "rna_Sequence_frame_length_set", NULL); RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "len"); - RNA_def_property_clear_flag(prop, PROP_EDITABLE|PROP_ANIMATABLE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE | PROP_ANIMATABLE); RNA_def_property_range(prop, 1, MAXFRAME); RNA_def_property_ui_text(prop, "Length", "The length of the contents of this strip before the handles are applied"); @@ -1063,7 +1076,7 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Start Frame", ""); RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_start_frame_set", NULL); /* overlap tests and calc_seq_disp */ RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_final_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startdisp"); @@ -1071,53 +1084,53 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Start Frame", "Start frame displayed in the sequence editor after offsets are applied, setting this is " "equivalent to moving the handle, not the actual start frame"); - /* overlap tests and calc_seq_disp */ + /* overlap tests and calc_seq_disp */ RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_start_frame_final_set", NULL); RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_final_end", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "enddisp"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_ui_text(prop, "End Frame", "End frame displayed in the sequence editor after offsets are applied"); - /* overlap tests and calc_seq_disp */ + /* overlap tests and calc_seq_disp */ RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_end_frame_final_set", NULL); RNA_def_property_editable_func(prop, "rna_Sequence_frame_editable"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_offset_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */ RNA_def_property_ui_text(prop, "Start Offset", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_offset_end", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endofs"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */ RNA_def_property_ui_text(prop, "End Offset", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_still_start", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "startstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */ RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_text(prop, "Start Still", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "frame_still_end", PROP_INT, PROP_TIME); RNA_def_property_int_sdna(prop, NULL, "endstill"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* overlap tests */ RNA_def_property_range(prop, 0, MAXFRAME); RNA_def_property_ui_text(prop, "End Still", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "channel", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "machine"); - RNA_def_property_range(prop, 0, MAXSEQ-1); + RNA_def_property_range(prop, 0, MAXSEQ - 1); RNA_def_property_ui_text(prop, "Channel", "Y position of the sequence strip"); RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_channel_set", NULL); /* overlap test */ - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); /* blending */ @@ -1125,27 +1138,27 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_enum_sdna(prop, NULL, "blend_mode"); RNA_def_property_enum_items(prop, blend_mode_items); RNA_def_property_ui_text(prop, "Blend Mode", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "blend_alpha", PROP_FLOAT, PROP_FACTOR); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Blend Opacity", ""); - /* stupid 0-100 -> 0-1 */ + /* stupid 0-100 -> 0-1 */ RNA_def_property_float_funcs(prop, "rna_Sequence_opacity_get", "rna_Sequence_opacity_set", NULL); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "effect_fader", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_float_sdna(prop, NULL, "effect_fader"); RNA_def_property_ui_text(prop, "Effect fader position", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_default_fade", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_EFFECT_DEFAULT_FADE); RNA_def_property_ui_text(prop, "Use Default Fade", "Fade effect using the built-in default (usually make transition as long as " "effect strip)"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "speed_factor", PROP_FLOAT, PROP_NONE); @@ -1153,25 +1166,7 @@ static void rna_def_sequence(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Speed factor", "Multiply the current speed of the sequence with this number or remap current frame " "to this frame"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); - - /* effect strip inputs */ - - prop = RNA_def_property(srna, "input_count", PROP_INT, PROP_UNSIGNED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_int_funcs(prop, "rna_Sequence_input_count_get", NULL, NULL); - - prop = RNA_def_property(srna, "input_1", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "seq1"); - RNA_def_property_ui_text(prop, "Input 1", "First input for the effect strip"); - - prop = RNA_def_property(srna, "input_2", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "seq2"); - RNA_def_property_ui_text(prop, "Input 2", "Second input for the effect strip"); - - prop = RNA_def_property(srna, "input_3", PROP_POINTER, PROP_NONE); - RNA_def_property_pointer_sdna(prop, NULL, "seq1"); - RNA_def_property_ui_text(prop, "Input 3", "Third input for the effect strip"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); RNA_api_sequence_strip(srna); } @@ -1190,6 +1185,7 @@ static void rna_def_editor(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL); RNA_def_property_struct_type(prop, "Sequence"); RNA_def_property_ui_text(prop, "Sequences", ""); + RNA_api_sequences(brna, prop); prop = RNA_def_property(srna, "sequences_all", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "seqbase", NULL); @@ -1208,25 +1204,25 @@ static void rna_def_editor(BlenderRNA *brna) prop = RNA_def_property(srna, "active_strip", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "act_seq"); RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Active Strip", "Sequencer's active strip"); prop = RNA_def_property(srna, "show_overlay", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_SHOW); RNA_def_property_ui_text(prop, "Draw Axes", "Partial overlay on top of the sequencer"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); prop = RNA_def_property(srna, "overlay_lock", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "over_flag", SEQ_EDIT_OVERLAY_ABS); RNA_def_property_ui_text(prop, "Overlay Lock", ""); RNA_def_property_boolean_funcs(prop, NULL, "rna_SequenceEditor_overlay_lock_set"); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); /* access to fixed and relative frame */ prop = RNA_def_property(srna, "overlay_frame", PROP_INT, PROP_NONE); RNA_def_property_ui_text(prop, "Overlay Offset", ""); RNA_def_property_int_funcs(prop, "rna_SequenceEditor_overlay_frame_get", "rna_SequenceEditor_overlay_frame_set", NULL); - RNA_def_property_update(prop, NC_SPACE|ND_SPACE_SEQUENCER, NULL); - RNA_def_property_ui_text(prop, "Active Strip", "Sequencer's active strip"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); } static void rna_def_filter_video(StructRNA *srna) @@ -1236,56 +1232,56 @@ static void rna_def_filter_video(StructRNA *srna) prop = RNA_def_property(srna, "use_deinterlace", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FILTERY); RNA_def_property_ui_text(prop, "De-Interlace", "For video movies to remove fields"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update_reopen_files"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update_reopen_files"); prop = RNA_def_property(srna, "use_premultiply", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MAKE_PREMUL); RNA_def_property_ui_text(prop, "Premultiply", "Convert RGB from key alpha to premultiplied alpha"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_flip_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FLIPX); RNA_def_property_ui_text(prop, "Flip X", "Flip on the X axis"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_flip_y", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_FLIPY); RNA_def_property_ui_text(prop, "Flip Y", "Flip on the Y axis"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_float", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_MAKE_FLOAT); RNA_def_property_ui_text(prop, "Convert Float", "Convert input to float data"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_REVERSE_FRAMES); RNA_def_property_ui_text(prop, "Flip Time", "Reverse frame order"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "color_multiply", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "mul"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_text(prop, "Multiply Colors", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "color_saturation", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "sat"); RNA_def_property_range(prop, 0.0f, 20.0f); RNA_def_property_ui_range(prop, 0.0f, 2.0f, 3, 3); RNA_def_property_ui_text(prop, "Saturation", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "strobe", PROP_FLOAT, PROP_NONE); RNA_def_property_range(prop, 1.0f, 30.0f); RNA_def_property_ui_text(prop, "Strobe", "Only display every nth frame"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_color_balance", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_COLOR_BALANCE); RNA_def_property_ui_text(prop, "Use Color Balance", "(3-Way color correction) on input"); RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_color_balance_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "color_balance", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->color_balance"); @@ -1295,7 +1291,7 @@ static void rna_def_filter_video(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_TRANSFORM); RNA_def_property_ui_text(prop, "Use Translation", "Translate image before processing"); RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_translation_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "transform", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->transform"); @@ -1305,7 +1301,7 @@ static void rna_def_filter_video(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_CROP); RNA_def_property_ui_text(prop, "Use Crop", "Crop image before processing"); RNA_def_property_boolean_funcs(prop, NULL, "rna_Sequence_use_crop_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "crop", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "strip->crop"); @@ -1328,12 +1324,12 @@ static void rna_def_proxy(StructRNA *srna) prop = RNA_def_property(srna, "use_proxy_custom_directory", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_PROXY_CUSTOM_DIR); RNA_def_property_ui_text(prop, "Proxy Custom Directory", "Use a custom directory to store data"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_proxy_custom_file", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_USE_PROXY_CUSTOM_FILE); RNA_def_property_ui_text(prop, "Proxy Custom File", "Use a custom file to read proxy data from"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); } static void rna_def_input(StructRNA *srna) @@ -1346,14 +1342,44 @@ static void rna_def_input(StructRNA *srna) RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_anim_startofs_final_set", NULL); /* overlap tests */ RNA_def_property_ui_text(prop, "Animation Start Offset", "Animation start offset (trim start)"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "animation_offset_end", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "anim_endofs"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); RNA_def_property_int_funcs(prop, NULL, "rna_Sequence_anim_endofs_final_set", NULL); /* overlap tests */ RNA_def_property_ui_text(prop, "Animation End Offset", "Animation end offset (trim end)"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); +} + +static void rna_def_effect_inputs(StructRNA *srna, int count) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "input_count", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_Sequence_input_count_get", NULL, NULL); + + if (count >= 1) { + prop = RNA_def_property(srna, "input_1", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "seq1"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Input 1", "First input for the effect strip"); + } + + if (count >= 2) { + prop = RNA_def_property(srna, "input_2", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "seq2"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Input 2", "Second input for the effect strip"); + } + + if (count == 3) { /* not used by any effects ...except maybe plugins? */ + prop = RNA_def_property(srna, "input_3", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "seq3"); + RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); + RNA_def_property_ui_text(prop, "Input 3", "Third input for the effect strip"); + } } static void rna_def_image(BlenderRNA *brna) @@ -1368,7 +1394,7 @@ static void rna_def_image(BlenderRNA *brna) prop = RNA_def_property(srna, "directory", PROP_STRING, PROP_DIRPATH); RNA_def_property_string_sdna(prop, NULL, "strip->dir"); RNA_def_property_ui_text(prop, "Directory", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL); @@ -1377,6 +1403,7 @@ static void rna_def_image(BlenderRNA *brna) RNA_def_property_collection_funcs(prop, "rna_SequenceEditor_elements_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_SequenceEditor_elements_length", NULL, NULL, NULL); + RNA_api_sequence_elements(brna, prop); rna_def_filter_video(srna); rna_def_proxy(srna); @@ -1414,13 +1441,13 @@ static void rna_def_scene(BlenderRNA *brna) prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Scene", "Scene that this sequence uses"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "scene_camera", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); RNA_def_property_ui_text(prop, "Camera Override", "Override the scenes active camera"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); rna_def_filter_video(srna); rna_def_proxy(srna); @@ -1440,14 +1467,14 @@ static void rna_def_movie(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "anim_preseek"); RNA_def_property_range(prop, 0, 50); RNA_def_property_ui_text(prop, "MPEG Preseek", "For MPEG movies, preseek this many frames"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "stream_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "streamindex"); RNA_def_property_range(prop, 0, 20); RNA_def_property_ui_text(prop, "Streamindex", "For files with several movie streams, use the stream with the given index"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update_reopen_files"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update_reopen_files"); prop = RNA_def_property(srna, "elements", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "strip->stripdata", NULL); @@ -1460,8 +1487,8 @@ static void rna_def_movie(BlenderRNA *brna) prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_ui_text(prop, "File", ""); RNA_def_property_string_funcs(prop, "rna_Sequence_filepath_get", "rna_Sequence_filepath_length", - "rna_Sequence_filepath_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_filepath_update"); + "rna_Sequence_filepath_set"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_filepath_update"); rna_def_filter_video(srna); rna_def_proxy(srna); @@ -1480,12 +1507,12 @@ static void rna_def_movieclip(BlenderRNA *brna) prop = RNA_def_property(srna, "undistort", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_UNDISTORTED); RNA_def_property_ui_text(prop, "Undistort Clip", "Use the undistorted version of the clip"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "stabilize2d", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "clip_flag", SEQ_MOVIECLIP_RENDER_STABILIZED); RNA_def_property_ui_text(prop, "Stabilize 2D Clip", "Use the 2D stabilized version of the clip"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); rna_def_filter_video(srna); rna_def_input(srna); @@ -1505,34 +1532,39 @@ static void rna_def_sound(BlenderRNA *brna) prop = RNA_def_property(srna, "sound", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "Sound"); RNA_def_property_ui_text(prop, "Sound", "Sound datablock used by this sequence"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "volume", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "volume"); RNA_def_property_range(prop, 0.0f, 100.0f); RNA_def_property_ui_text(prop, "Volume", "Playback volume of the sound"); RNA_def_property_float_funcs(prop, NULL, "rna_Sequence_volume_set", NULL); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "pitch", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pitch"); RNA_def_property_range(prop, 0.1f, 10.0f); RNA_def_property_ui_text(prop, "Pitch", "Playback pitch of the sound"); RNA_def_property_float_funcs(prop, NULL, "rna_Sequence_pitch_set", NULL); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "pan", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "pan"); RNA_def_property_range(prop, -2.0f, 2.0f); RNA_def_property_ui_text(prop, "Pan", "Playback panning of the sound (only for Mono sources)"); RNA_def_property_float_funcs(prop, NULL, "rna_Sequence_pan_set", NULL); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); RNA_def_property_ui_text(prop, "File", ""); RNA_def_property_string_funcs(prop, "rna_Sequence_filepath_get", "rna_Sequence_filepath_length", - "rna_Sequence_filepath_set"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_filepath_update"); + "rna_Sequence_filepath_set"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_filepath_update"); + + prop = RNA_def_property(srna, "show_waveform", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_AUDIO_DRAW_WAVEFORM); + RNA_def_property_ui_text(prop, "Draw Waveform", "Whether to draw the sound's waveform"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, NULL); rna_def_input(srna); } @@ -1550,45 +1582,21 @@ static void rna_def_effect(BlenderRNA *brna) rna_def_proxy(srna); } -static void rna_def_multicam(BlenderRNA *brna) +static void rna_def_multicam(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "MulticamSequence", "Sequence"); - RNA_def_struct_ui_text(srna, "Multicam Select Sequence", - "Sequence strip to perform multicam editing: select channel from below"); - RNA_def_struct_sdna(srna, "Sequence"); - prop = RNA_def_property(srna, "multicam_source", PROP_INT, PROP_UNSIGNED); RNA_def_property_int_sdna(prop, NULL, "multicam_source"); - RNA_def_property_range(prop, 0, MAXSEQ-1); + RNA_def_property_range(prop, 0, MAXSEQ - 1); RNA_def_property_ui_text(prop, "Multicam Source Channel", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - rna_def_filter_video(srna); - rna_def_proxy(srna); rna_def_input(srna); } -static void rna_def_adjustment(BlenderRNA *brna) +static void rna_def_wipe(StructRNA *srna) { - StructRNA *srna; -/* PropertyRNA *prop; */ - - srna = RNA_def_struct(brna, "AdjustmentSequence", "Sequence"); - RNA_def_struct_ui_text(srna, "Adjustment Layer Sequence", - "Sequence strip to perform filter adjustments to layers below"); - RNA_def_struct_sdna(srna, "Sequence"); - - rna_def_filter_video(srna); - rna_def_proxy(srna); - rna_def_input(srna); -} - -static void rna_def_wipe(BlenderRNA *brna) -{ - StructRNA *srna; PropertyRNA *prop; static const EnumPropertyItem wipe_type_items[] = { @@ -1607,8 +1615,6 @@ static void rna_def_wipe(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - srna = RNA_def_struct(brna, "WipeSequence", "EffectSequence"); - RNA_def_struct_ui_text(srna, "Wipe Sequence", "Sequence strip creating a wipe transition"); RNA_def_struct_sdna_from(srna, "WipeVars", "effectdata"); prop = RNA_def_property(srna, "blur_width", PROP_FLOAT, PROP_UNSIGNED); @@ -1616,7 +1622,7 @@ static void rna_def_wipe(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Blur Width", "Width of the blur edge, in percentage relative to the image size"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); #if 1 /* expose as radians */ prop = RNA_def_property(srna, "angle", PROP_FLOAT, PROP_ANGLE); @@ -1628,69 +1634,65 @@ static void rna_def_wipe(BlenderRNA *brna) RNA_def_property_range(prop, -90.0f, 90.0f); #endif RNA_def_property_ui_text(prop, "Angle", "Edge angle"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "forward"); RNA_def_property_enum_items(prop, wipe_direction_items); RNA_def_property_ui_text(prop, "Direction", "Wipe direction"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "transition_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "wipetype"); RNA_def_property_enum_items(prop, wipe_type_items); RNA_def_property_ui_text(prop, "Transition Type", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); } -static void rna_def_glow(BlenderRNA *brna) +static void rna_def_glow(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GlowSequence", "EffectSequence"); - RNA_def_struct_ui_text(srna, "Glow Sequence", "Sequence strip creating a glow effect"); + RNA_def_struct_sdna_from(srna, "GlowVars", "effectdata"); prop = RNA_def_property(srna, "threshold", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fMini"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Threshold", "Minimum intensity to trigger a glow"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "clamp", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fClamp"); RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_ui_text(prop, "Clamp", "Brightness limit of intensity"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "boost_factor", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "fBoost"); RNA_def_property_range(prop, 0.0f, 10.0f); RNA_def_property_ui_text(prop, "Boost Factor", "Brightness multiplier"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "blur_radius", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "dDist"); RNA_def_property_range(prop, 0.5f, 20.0f); RNA_def_property_ui_text(prop, "Blur Distance", "Radius of glow effect"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "quality", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "dQuality"); RNA_def_property_range(prop, 1, 5); RNA_def_property_ui_text(prop, "Quality", "Accuracy of the blur effect"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_only_boost", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "bNoComp", 0); RNA_def_property_ui_text(prop, "Only Boost", "Show the glow buffer only"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); } -static void rna_def_transform(BlenderRNA *brna) +static void rna_def_transform(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; static const EnumPropertyItem interpolation_items[] = { @@ -1706,105 +1708,162 @@ static void rna_def_transform(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; - srna = RNA_def_struct(brna, "TransformSequence", "EffectSequence"); - RNA_def_struct_ui_text(srna, "Transform Sequence", - "Sequence strip applying affine transformations to other strips"); RNA_def_struct_sdna_from(srna, "TransformVars", "effectdata"); - + prop = RNA_def_property(srna, "scale_start_x", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScalexIni"); RNA_def_property_ui_text(prop, "Scale X", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "scale_start_y", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "ScaleyIni"); RNA_def_property_ui_text(prop, "Scale Y", ""); RNA_def_property_ui_range(prop, 0, 10, 3, 10); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_uniform_scale", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "uniform_scale", 0); RNA_def_property_ui_text(prop, "Uniform Scale", "Scale uniformly, preserving aspect ratio"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "translate_start_x", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "xIni"); RNA_def_property_ui_text(prop, "Translate X", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "translate_start_y", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "yIni"); RNA_def_property_ui_text(prop, "Translate Y", ""); RNA_def_property_ui_range(prop, -500.0f, 500.0f, 3, 10); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "rotation_start", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "rotIni"); RNA_def_property_range(prop, -360.0f, 360.0f); RNA_def_property_ui_text(prop, "Rotation", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "translation_unit", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "percent"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not meant to be animated */ RNA_def_property_enum_items(prop, translation_unit_items); RNA_def_property_ui_text(prop, "Translation Unit", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, interpolation_items); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* not meant to be animated */ RNA_def_property_ui_text(prop, "Interpolation", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); } -static void rna_def_solid_color(BlenderRNA *brna) +static void rna_def_solid_color(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "ColorSequence", "EffectSequence"); - RNA_def_struct_ui_text(srna, "Color Sequence", "Sequence strip creating an image filled with a single color"); RNA_def_struct_sdna_from(srna, "SolidColorVars", "effectdata"); - + prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR); RNA_def_property_float_sdna(prop, NULL, "col"); RNA_def_property_ui_text(prop, "Color", ""); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); } -static void rna_def_speed_control(BlenderRNA *brna) +static void rna_def_speed_control(StructRNA *srna) { - StructRNA *srna; PropertyRNA *prop; - srna = RNA_def_struct(brna, "SpeedControlSequence", "EffectSequence"); - RNA_def_struct_ui_text(srna, "SpeedControl Sequence", "Sequence strip to control the speed of other strips"); RNA_def_struct_sdna_from(srna, "SpeedControlVars", "effectdata"); - + prop = RNA_def_property(srna, "multiply_speed", PROP_FLOAT, PROP_UNSIGNED); RNA_def_property_float_sdna(prop, NULL, "globalSpeed"); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* seq->facf0 is used to animate this */ RNA_def_property_ui_text(prop, "Multiply Speed", "Multiply the resulting speed after the speed factor"); RNA_def_property_ui_range(prop, 0.0f, 100.0f, 1, 0); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_as_speed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_INTEGRATE); RNA_def_property_ui_text(prop, "Use as speed", "Interpret the value as speed instead of a frame number"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "use_frame_blend", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_BLEND); RNA_def_property_ui_text(prop, "Frame Blending", "Blend two frames into the target for a smoother result"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); prop = RNA_def_property(srna, "scale_to_length", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flags", SEQ_SPEED_COMPRESS_IPO_Y); RNA_def_property_ui_text(prop, "Scale to length", "Scale values from 0.0 to 1.0 to target sequence length"); - RNA_def_property_update(prop, NC_SCENE|ND_SEQUENCER, "rna_Sequence_update"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); +} + +static EffectInfo def_effects[] = { + {"AddSequence", "Add Sequence", + "Add Sequence", + NULL, 2}, + {"AdjustmentSequence", "Adjustment Layer Sequence", + "Sequence strip to perform filter adjustments to layers below", + rna_def_input, 0}, + {"AlphaOverSequence", "Alpha Over Sequence", + "Alpha Over Sequence", + NULL, 2}, + {"AlphaUnderSequence", "Alpha Under Sequence", + "Alpha Under Sequence", + NULL, 2}, + {"ColorSequence", "Color Sequence", + "Sequence strip creating an image filled with a single color", + rna_def_solid_color, 0}, + {"CrossSequence", "Cross Sequence", + "Cross Sequence", + NULL, 2}, + {"GammaCrossSequence", "Gamma Cross Sequence", + "Gamma Cross Sequence", + NULL, 2}, + {"GlowSequence", "Glow Sequence", + "Sequence strip creating a glow effect", + rna_def_glow, 1}, + {"MulticamSequence", "Multicam Select Sequence", + "Sequence strip to perform multicam editing", + rna_def_multicam, 0}, + {"MultiplySequence", "Multiply Sequence", + "Multiply Sequence", + NULL, 2}, + {"OverDropSequence", "Over Drop Sequence", + "Over Drop Sequence", + NULL, 2}, + {"SpeedControlSequence", "SpeedControl Sequence", + "Sequence strip to control the speed of other strips", + rna_def_speed_control, 1}, + {"SubtractSequence", "Subtract Sequence", + "Subtract Sequence", + NULL, 2}, + {"TransformSequence", "Transform Sequence", + "Sequence strip applying affine transformations to other strips", + rna_def_transform, 1}, + {"WipeSequence", "Wipe Sequence", + "Sequence strip creating a wipe transition", + rna_def_wipe, 1}, + {"", "", "", NULL, 0} +}; + +static void rna_def_effects(BlenderRNA *brna) +{ + StructRNA *srna; + EffectInfo *effect; + + for (effect = def_effects; effect->struct_name[0] != '\0'; effect++) { + srna = RNA_def_struct(brna, effect->struct_name, "EffectSequence"); + RNA_def_struct_ui_text(srna, effect->ui_name, effect->ui_desc); + RNA_def_struct_sdna(srna, "Sequence"); + + rna_def_effect_inputs(srna, effect->inputs); + + if (effect->func) + effect->func(srna); + } } void RNA_def_sequencer(BlenderRNA *brna) @@ -1825,13 +1884,7 @@ void RNA_def_sequencer(BlenderRNA *brna) rna_def_movieclip(brna); rna_def_sound(brna); rna_def_effect(brna); - rna_def_multicam(brna); - rna_def_adjustment(brna); - rna_def_wipe(brna); - rna_def_glow(brna); - rna_def_transform(brna); - rna_def_solid_color(brna); - rna_def_speed_control(brna); + rna_def_effects(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index 20ceaec8974..38a923f87e5 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -24,8 +24,6 @@ * \ingroup RNA */ - - #include #include #include @@ -39,10 +37,30 @@ #include "DNA_scene_types.h" #include "DNA_sequence_types.h" +extern EnumPropertyItem blend_mode_items[]; + #ifdef RNA_RUNTIME +//#include "DNA_anim_types.h" +#include "DNA_image_types.h" +#include "DNA_scene_types.h" +#include "DNA_sequence_types.h" +#include "DNA_sound_types.h" + +#include "BLI_path_util.h" /* BLI_split_dirfile */ + +#include "BKE_image.h" +#include "BKE_library.h" /* id_us_plus */ +#include "BKE_movieclip.h" + #include "BKE_report.h" #include "BKE_sequencer.h" +#include "BKE_sound.h" + +#include "IMB_imbuf.h" +#include "IMB_imbuf_types.h" + +#include "WM_api.h" static void rna_Sequence_swap_internal(Sequence *seq_self, ReportList *reports, Sequence *seq_other) { @@ -52,6 +70,271 @@ static void rna_Sequence_swap_internal(Sequence *seq_self, ReportList *reports, BKE_report(reports, RPT_ERROR, error_msg); } +static Sequence *alloc_generic_sequence(Editing *ed, const char *name, int start_frame, + int channel, int type, const char *file) +{ + Sequence *seq; + Strip *strip; + StripElem *se; + + seq = alloc_sequence(ed->seqbasep, start_frame, channel); + seq->type = type; + + BLI_strncpy(seq->name + 2, name, sizeof(seq->name) - 2); + seqbase_unique_name_recursive(&ed->seqbase, seq); + + seq->strip = strip = MEM_callocN(sizeof(Strip), "strip"); + seq->strip->us = 1; + + if (file) { + strip->stripdata = se = MEM_callocN(sizeof(StripElem), "stripelem"); + BLI_split_dirfile(file, strip->dir, se->name, sizeof(strip->dir), sizeof(se->name)); + } + else { + strip->stripdata = NULL; + } + + return seq; +} + +static Sequence *rna_Sequences_new_clip(ID *id, Editing *ed, ReportList *reports, + const char *name, MovieClip *clip, int channel, + int start_frame) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + + seq = alloc_generic_sequence(ed, name, start_frame, channel, SEQ_MOVIECLIP, clip->name); + seq->clip = clip; + seq->len = BKE_movieclip_get_duration(clip); + id_us_plus((ID *)clip); + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} + +static Sequence *rna_Sequences_new_scene(ID *id, Editing *ed, ReportList *reports, + const char *name, Scene *sce_seq, int channel, + int start_frame) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + + seq = alloc_generic_sequence(ed, name, start_frame, channel, SEQ_SCENE, NULL); + seq->scene = sce_seq; + seq->len = sce_seq->r.efra - sce_seq->r.sfra + 1; + seq->scene_sound = sound_scene_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0); + id_us_plus((ID *)sce_seq); + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} + +static Sequence *rna_Sequences_new_image(ID *id, Editing *ed, ReportList *reports, + const char *name, const char *file, int channel, + int start_frame) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + + seq = alloc_generic_sequence(ed, name, start_frame, channel, SEQ_IMAGE, file); + seq->len = 1; + + if (seq->strip->stripdata->name[0] == '\0') { + BKE_report(reports, RPT_ERROR, "Sequences.new_image: unable to open image file"); + BLI_remlink(&ed->seqbase, seq); + seq_free_sequence(scene, seq); + return NULL; + } + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} + +static Sequence *rna_Sequences_new_movie(ID *id, Editing *ed, ReportList *reports, + const char *name, const char *file, int channel, + int start_frame) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + + struct anim *an = openanim(file, IB_rect, 0); + + if (an == NULL) { + BKE_report(reports, RPT_ERROR, "Sequences.new_movie: unable to open movie file"); + return NULL; + } + + seq = alloc_generic_sequence(ed, name, start_frame, channel, SEQ_MOVIE, file); + seq->anim = an; + seq->anim_preseek = IMB_anim_get_preseek(an); + seq->len = IMB_anim_get_duration(an, IMB_TC_RECORD_RUN); + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} + +#ifdef WITH_AUDASPACE +static Sequence *rna_Sequences_new_sound(ID *id, Editing *ed, Main *bmain, ReportList *reports, + const char *name, const char *file, int channel, int start_frame) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + + bSound *sound = sound_new_file(bmain, file); + + if (sound == NULL || sound->playback_handle == NULL) { + BKE_report(reports, RPT_ERROR, "Sequences.new_sound: unable to open sound file"); + return NULL; + } + + seq = alloc_generic_sequence(ed, name, start_frame, channel, SEQ_SOUND, sound->name); + seq->sound = sound; + seq->len = ceil(sound_get_length(sound) * FPS); + + seq->scene_sound = sound_add_scene_sound(scene, seq, start_frame, start_frame + seq->len, 0); + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} +#else /* WITH_AUDASPACE */ +static Sequence *rna_Sequences_new_sound(ID *UNUSED(id), Editing *UNUSED(ed), bMain *UNUSED(main), ReportList *UNUSED(reports), + const char *UNUSED(name), bSound *UNUSED(sound), int UNUSED(channel), int UNUSED(start_frame)) +{ + BKE_report(reports, RPT_ERROR, "Blender compiled without Audaspace support."); + return NULL; +} +#endif /* WITH_AUDASPACE */ + +static Sequence *rna_Sequences_new_effect(ID *id, Editing *ed, ReportList *reports, + const char *name, int type, int channel, + int start_frame, int end_frame, + Sequence *seq1, Sequence *seq2, Sequence *seq3) +{ + Scene *scene = (Scene *)id; + Sequence *seq; + struct SeqEffectHandle sh; + + switch (get_sequence_effect_num_inputs(type)) { + case 0: + if (end_frame <= start_frame) { + BKE_report(reports, RPT_ERROR, + "Sequences.new_effect: End frame not set"); + return NULL; + } + break; + case 1: + if (seq1 == NULL) { + BKE_report(reports, RPT_ERROR, + "Sequences.new_effect: Effect takes 1 input sequence"); + return NULL; + } + break; + case 2: + if (seq1 == NULL || seq2 == NULL) { + BKE_report(reports, RPT_ERROR, + "Sequences.new_effect: Effect takes 2 input sequences"); + return NULL; + } + break; + case 3: + if (seq1 == NULL || seq2 == NULL || seq3 == NULL) { + BKE_report(reports, RPT_ERROR, + "Sequences.new_effect: Effect takes 3 input sequences"); + return NULL; + } + break; + default: + BKE_report(reports, RPT_ERROR, + "Sequences.new_effect: get_sequence_effect_num_inputs() > 3 (should never happen)"); + return NULL; + } + + seq = alloc_generic_sequence(ed, name, start_frame, channel, type, NULL); + + sh = get_sequence_effect(seq); + + seq->seq1 = seq1; + seq->seq2 = seq2; + seq->seq3 = seq3; + + sh.init(seq); + + if (!seq1) { /* effect has no deps */ + seq->len = 1; + seq_tx_set_final_right(seq, end_frame); + } + + seq->flag |= SEQ_USE_EFFECT_DEFAULT_FADE; + + calc_sequence(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return seq; +} + +static void rna_Sequences_remove(ID *id, Editing *ed, Sequence *seq) +{ + Scene *scene = (Scene *)id; + + BLI_remlink(&ed->seqbase, seq); + seq_free_sequence(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); +} + +static StripElem *rna_SequenceElements_push(ID *id, Sequence *seq, const char *filename) +{ + Scene *scene = (Scene *)id; + StripElem *se; + + seq->strip->stripdata = se = MEM_reallocN(seq->strip->stripdata, sizeof(StripElem) * (seq->len + 1)); + se += seq->len; + BLI_strncpy(se->name, filename, sizeof(se->name)); + seq->len++; + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); + + return se; +} + +static void rna_SequenceElements_pop(ID *id, Sequence *seq, ReportList *reports) +{ + Scene *scene = (Scene *)id; + + if (seq->len == 1) { + BKE_report(reports, RPT_ERROR, "SequenceElements.pop: can not pop the last element"); + return; + } + + /* just chop off the end ...what could possibly go wrong? */ + seq->strip->stripdata = MEM_reallocN(seq->strip->stripdata, sizeof(StripElem) * (seq->len - 1)); + seq->len--; + + calc_sequence_disp(scene, seq); + + WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); +} + + #else void RNA_api_sequence_strip(StructRNA *srna) @@ -62,15 +345,188 @@ void RNA_api_sequence_strip(StructRNA *srna) func = RNA_def_function(srna, "getStripElem", "give_stripelem"); RNA_def_function_ui_description(func, "Return the strip element from a given frame or None"); parm = RNA_def_int(func, "frame", 0, -MAXFRAME, MAXFRAME, "Frame", - "The frame to get the strip element from", -MAXFRAME, MAXFRAME); + "The frame to get the strip element from", -MAXFRAME, MAXFRAME); RNA_def_property_flag(parm, PROP_REQUIRED); RNA_def_function_return(func, RNA_def_pointer(func, "elem", "SequenceElement", "", - "strip element of the current frame")); + "strip element of the current frame")); func = RNA_def_function(srna, "swap", "rna_Sequence_swap_internal"); RNA_def_function_flag(func, FUNC_USE_REPORTS); parm = RNA_def_pointer(func, "other", "Sequence", "Other", ""); - RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); } +void RNA_api_sequence_elements(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *parm; + FunctionRNA *func; + + RNA_def_property_srna(cprop, "SequenceElements"); + srna = RNA_def_struct(brna, "SequenceElements", NULL); + RNA_def_struct_sdna(srna, "Sequence"); + RNA_def_struct_ui_text(srna, "SequenceElements", "Collection of SequenceElement"); + + func = RNA_def_function(srna, "push", "rna_SequenceElements_push"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Push an image from ImageSequence.directory"); + parm = RNA_def_string(func, "filename", "File", 0, "", "Filepath to image"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "elem", "SequenceElement", "", "New SequenceElement"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "pop", "rna_SequenceElements_pop"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Pop an image off the collection"); +} + +void RNA_api_sequences(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *parm; + FunctionRNA *func; + + static EnumPropertyItem seq_effect_items[] = { + {SEQ_CROSS, "CROSS", 0, "Cross", ""}, + {SEQ_ADD, "ADD", 0, "Add", ""}, + {SEQ_SUB, "SUBTRACT", 0, "Subtract", ""}, + {SEQ_ALPHAOVER, "ALPHA_OVER", 0, "Alpha Over", ""}, + {SEQ_ALPHAUNDER, "ALPHA_UNDER", 0, "Alpha Under", ""}, + {SEQ_GAMCROSS, "GAMMA_CROSS", 0, "Gamma Cross", ""}, + {SEQ_MUL, "MULTIPLY", 0, "Multiply", ""}, + {SEQ_OVERDROP, "OVER_DROP", 0, "Over Drop", ""}, + // {SEQ_PLUGIN, "PLUGIN", 0, "Plugin", ""}, + {SEQ_WIPE, "WIPE", 0, "Wipe", ""}, + {SEQ_GLOW, "GLOW", 0, "Glow", ""}, + {SEQ_TRANSFORM, "TRANSFORM", 0, "Transform", ""}, + {SEQ_COLOR, "COLOR", 0, "Color", ""}, + {SEQ_SPEED, "SPEED", 0, "Speed", ""}, + {SEQ_MULTICAM, "MULTICAM", 0, "Multicam Selector", ""}, + {SEQ_ADJUSTMENT, "ADJUSTMENT", 0, "Adjustment Layer", ""}, + {0, NULL, 0, NULL, NULL} + }; + + RNA_def_property_srna(cprop, "Sequences"); + srna = RNA_def_struct(brna, "Sequences", NULL); + RNA_def_struct_sdna(srna, "Editing"); + RNA_def_struct_ui_text(srna, "Sequences", "Collection of Sequences"); + + func = RNA_def_function(srna, "new_clip", "rna_Sequences_new_clip"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Add a new movie clip sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "clip", "MovieClip", "", "Movie clip to add"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "new_scene", "rna_Sequences_new_scene"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Add a new scene sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene to add"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "new_image", "rna_Sequences_new_image"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Add a new image sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to image"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "new_movie", "rna_Sequences_new_movie"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Add a new movie sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "new_sound", "rna_Sequences_new_sound"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID | FUNC_USE_MAIN); + RNA_def_function_ui_description(func, "Add a new movie clip sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_string(func, "filepath", "File", 0, "", "Filepath to movie"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "new_effect", "rna_Sequences_new_effect"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Add a new effect sequence"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_enum(func, "type", seq_effect_items, 0, "Type", + "type for the new sequence"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "channel", 0, 0, MAXSEQ - 1, "Channel", + "The channel for the new sequence", 0, MAXSEQ - 1); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "start_frame", 0, -MAXFRAME, MAXFRAME, "", + "The start frame for the new sequence", -MAXFRAME, MAXFRAME); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_int(func, "end_frame", 0, -MAXFRAME, MAXFRAME, "", + "The end frame for the new sequence", -MAXFRAME, MAXFRAME); + parm = RNA_def_pointer(func, "seq1", "Sequence", "", "Sequence 1 for effect"); + parm = RNA_def_pointer(func, "seq2", "Sequence", "", "Sequence 2 for effect"); + parm = RNA_def_pointer(func, "seq3", "Sequence", "", "Sequence 3 for effect"); + /* return type */ + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "New Sequence"); + RNA_def_function_return(func, parm); + + + func = RNA_def_function(srna, "remove", "rna_Sequences_remove"); + RNA_def_function_flag(func, FUNC_USE_SELF_ID); + RNA_def_function_ui_description(func, "Remove a Sequence"); + parm = RNA_def_pointer(func, "sequence", "Sequence", "", "Sequence to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); +} + + #endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 51f5cdcda85..aafcc381c51 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -494,7 +494,7 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_SOLID); RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_TEXTURE); - if (scene_use_new_shading_nodes(scene)) + if (BKE_scene_use_new_shading_nodes(scene)) RNA_enum_items_add_value(&item, &totitem, viewport_shade_items, OB_MATERIAL); if (type->view_draw) diff --git a/source/blender/makesrna/intern/rna_text_api.c b/source/blender/makesrna/intern/rna_text_api.c index 3f511858332..338d0c7c52c 100644 --- a/source/blender/makesrna/intern/rna_text_api.c +++ b/source/blender/makesrna/intern/rna_text_api.c @@ -37,13 +37,13 @@ static void rna_Text_clear(Text *text) { - clear_text(text); + BKE_text_clear(text); WM_main_add_notifier(NC_TEXT|NA_EDITED, text); } static void rna_Text_write(Text *text, const char *str) { - write_text(text, str); + BKE_text_write(text, str); WM_main_add_notifier(NC_TEXT|NA_EDITED, text); } diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index fd9730238f5..e6d86de45b4 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -56,15 +56,15 @@ static void initData(ModifierData *md) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; amd->deformflag = ARM_DEF_ENVELOPE | ARM_DEF_VGROUP; } static void copyData(ModifierData *md, ModifierData *target) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - ArmatureModifierData *tamd = (ArmatureModifierData*) target; + ArmatureModifierData *amd = (ArmatureModifierData *) md; + ArmatureModifierData *tamd = (ArmatureModifierData *) target; tamd->object = amd->object; tamd->deformflag = amd->deformflag; @@ -84,27 +84,27 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; return !amd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; walk(userData, ob, &amd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; if (amd->object) { DagNode *curNode = dag_get_node(forest, amd->object); @@ -115,31 +115,30 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ob, derivedData, vertexCos, NULL, - numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); /* free cache */ if (amd->prevCos) { MEM_freeN(amd->prevCos); - amd->prevCos= NULL; + amd->prevCos = NULL; } } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); @@ -147,23 +146,23 @@ static void deformVertsEM( modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ armature_deform_verts(amd->object, ob, dm, vertexCos, NULL, - numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); + numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name); /* free cache */ if (amd->prevCos) { MEM_freeN(amd->prevCos); - amd->prevCos= NULL; + amd->prevCos = NULL; } if (!derivedData) dm->release(dm); } static void deformMatricesEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], - float (*defMats)[3][3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], + float (*defMats)[3][3], int numVerts) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); @@ -175,12 +174,12 @@ static void deformMatricesEM( } static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; + ArmatureModifierData *amd = (ArmatureModifierData *) md; DerivedMesh *dm = derivedData; - if (!derivedData) dm = CDDM_from_mesh((Mesh*)ob->data, ob); + if (!derivedData) dm = CDDM_from_mesh((Mesh *)ob->data, ob); armature_deform_verts(amd->object, ob, dm, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name); @@ -193,8 +192,8 @@ ModifierTypeInfo modifierType_Armature = { /* structName */ "ArmatureModifierData", /* structSize */ sizeof(ArmatureModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 1fe4f92e124..39e08c1cb5d 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -63,7 +63,7 @@ static void initData(ModifierData *md) { - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; /* default to 2 duplicates distributed along the x-axis by an * offset of 1 object-width @@ -82,8 +82,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - ArrayModifierData *amd = (ArrayModifierData*) md; - ArrayModifierData *tamd = (ArrayModifierData*) target; + ArrayModifierData *amd = (ArrayModifierData *) md; + ArrayModifierData *tamd = (ArrayModifierData *) target; tamd->start_cap = amd->start_cap; tamd->end_cap = amd->end_cap; @@ -100,11 +100,11 @@ static void copyData(ModifierData *md, ModifierData *target) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; walk(userData, ob, &amd->start_cap); walk(userData, ob, &amd->end_cap); @@ -113,9 +113,9 @@ static void foreachObjectLink( } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) + struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; if (amd->start_cap) { DagNode *curNode = dag_get_node(forest, amd->start_cap); @@ -153,7 +153,7 @@ static float vertarray_size(MVert *mvert, int numVerts, int axis) /* find the minimum and maximum coordinates on the desired axis */ min_co = max_co = mvert->co[axis]; - ++mvert; + mvert++; for (i = 1; i < numVerts; ++i, ++mvert) { if (mvert->co[axis] < min_co) min_co = mvert->co[axis]; if (mvert->co[axis] > max_co) max_co = mvert->co[axis]; @@ -163,8 +163,8 @@ static float vertarray_size(MVert *mvert, int numVerts, int axis) } static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, - const ArrayModifierData *amd, - int *index_map_length) + const ArrayModifierData *amd, + int *index_map_length) { BMOperator find_op; BMOIter oiter; @@ -173,8 +173,8 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, int *index_map, i; BMO_op_initf(bm, &find_op, - "finddoubles verts=%av dist=%f keepverts=%s", - amd->merge_dist, dupe_op, "geom"); + "finddoubles verts=%av dist=%f keepverts=%s", + amd->merge_dist, dupe_op, "geom"); BMO_op_exec(bm, &find_op); @@ -214,11 +214,11 @@ static int *find_doubles_index_map(BMesh *bm, BMOperator *dupe_op, * * All verts will be tagged on exit. */ -static void bm_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4], - const ArrayModifierData *amd, - BMOperator *dupe_op, - const char *dupe_slot_name, - BMOperator *weld_op) +static void bm_merge_dm_transform(BMesh *bm, DerivedMesh *dm, float mat[4][4], + const ArrayModifierData *amd, + BMOperator *dupe_op, + const char *dupe_slot_name, + BMOperator *weld_op) { BMVert *v, *v2; BMIter iter; @@ -232,9 +232,9 @@ static void bm_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4], BMOperator find_op; BMO_op_initf(bm, &find_op, - "finddoubles verts=%Hv dist=%f keepverts=%s", - BM_ELEM_TAG, amd->merge_dist, - dupe_op, dupe_slot_name); + "finddoubles verts=%Hv dist=%f keepverts=%s", + BM_ELEM_TAG, amd->merge_dist, + dupe_op, dupe_slot_name); /* append the dupe's geom to the findop input verts */ BMO_slot_buffer_append(&find_op, "verts", dupe_op, dupe_slot_name); @@ -268,20 +268,20 @@ static void bm_merge_dm_transform(BMesh* bm, DerivedMesh *dm, float mat[4][4], } } -static void merge_first_last(BMesh* bm, - const ArrayModifierData *amd, - BMOperator *dupe_first, - BMOperator *dupe_last, - BMOperator *weld_op) +static void merge_first_last(BMesh *bm, + const ArrayModifierData *amd, + BMOperator *dupe_first, + BMOperator *dupe_last, + BMOperator *weld_op) { BMOperator find_op; BMOIter oiter; BMVert *v, *v2; BMO_op_initf(bm, &find_op, - "finddoubles verts=%s dist=%f keepverts=%s", - dupe_first, "geom", amd->merge_dist, - dupe_first, "geom"); + "finddoubles verts=%s dist=%f keepverts=%s", + dupe_first, "geom", amd->merge_dist, + dupe_first, "geom"); /* append the last dupe's geom to the findop input verts */ BMO_slot_buffer_append(&find_op, "verts", dupe_last, "newout"); @@ -331,8 +331,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, add_v3_v3v3(offset[3], offset[3], amd->offset); if (amd->offset_type & MOD_ARR_OFF_RELATIVE) { for (j = 0; j < 3; j++) - offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, - maxVerts, j); + offset[3][j] += amd->scale[j] * vertarray_size(src_mvert, maxVerts, j); } if ((amd->offset_type & MOD_ARR_OFF_OBJ) && (amd->offset_ob)) { @@ -356,15 +355,15 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float tmp_mat[3][3]; float scale; - object_to_mat3(amd->curve_ob, tmp_mat); + BKE_object_to_mat3(amd->curve_ob, tmp_mat); scale = mat3_to_scale(tmp_mat); if (!cu->path) { cu->flag |= CU_PATH; // needed for path & bevlist - makeDispListCurveTypes(scene, amd->curve_ob, 0); + BKE_displist_make_curveTypes(scene, amd->curve_ob, 0); } if (cu->path) - length = scale*cu->path->totdist; + length = scale * cu->path->totdist; } } @@ -388,7 +387,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /* calculate the offset matrix of the final copy (for merging) */ unit_m4(final_offset); - for (j=0; j < count - 1; j++) { + for (j = 0; j < count - 1; j++) { mult_m4_m4m4(tmp_mat, offset, final_offset); copy_m4_m4(final_offset, tmp_mat); } @@ -408,7 +407,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMO_op_initf(em->bm, &dupe_op, "dupe geom=%avef"); first_dupe_op = dupe_op; - for (j=0; j < count - 1; j++) { + for (j = 0; j < count - 1; j++) { BMVert *v, *v2, *v3; BMOpSlot *geom_slot; BMOpSlot *newout_slot; @@ -422,7 +421,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, newout_slot = BMO_slot_get(&dupe_op, "newout"); if ((amd->flags & MOD_ARR_MERGEFINAL) && j == 0) { - int first_geom_bytes = sizeof(BMVert*) * geom_slot->len; + int first_geom_bytes = sizeof(BMVert *) * geom_slot->len; /* make a copy of the initial geometry ordering so the * last duplicate can be merged into it */ @@ -439,17 +438,17 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, /*calculate merge mapping*/ if (j == 0) { indexMap = find_doubles_index_map(em->bm, &dupe_op, - amd, &indexLen); + amd, &indexLen); } #define _E(s, i) ((BMVert **)(s)->data.buf)[i] - for (i=0; ilen); - v2 = _E(geom_slot, indexMap[i]-1); + v2 = _E(geom_slot, indexMap[i] - 1); /* check in case the target vertex (v2) is already marked * for merging */ @@ -493,14 +492,14 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float startoffset[4][4]; invert_m4_m4(startoffset, offset); bm_merge_dm_transform(em->bm, start_cap, startoffset, amd, - &first_dupe_op, "geom", &weld_op); + &first_dupe_op, "geom", &weld_op); } if (end_cap) { float endoffset[4][4]; mult_m4_m4m4(endoffset, offset, final_offset); bm_merge_dm_transform(em->bm, end_cap, endoffset, amd, - &dupe_op, count == 1 ? "geom" : "newout", &weld_op); + &dupe_op, count == 1 ? "geom" : "newout", &weld_op); } } /* done capping */ @@ -542,12 +541,11 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *dm, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; - ArrayModifierData *amd = (ArrayModifierData*) md; + ArrayModifierData *amd = (ArrayModifierData *) md; result = arrayModifier_doArray(amd, md->scene, ob, dm, 0); @@ -558,10 +556,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *dm) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *dm) { - return applyModifier(md, ob, dm, 0, 1); + return applyModifier(md, ob, dm, MOD_APPLY_USECACHE); } @@ -570,11 +568,11 @@ ModifierTypeInfo modifierType_Array = { /* structName */ "ArrayModifierData", /* structSize */ sizeof(ArrayModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 613dfee8997..6c91cd6e2d1 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -50,7 +50,7 @@ static void initData(ModifierData *md) { - BevelModifierData *bmd = (BevelModifierData*) md; + BevelModifierData *bmd = (BevelModifierData *) md; bmd->value = 0.1f; bmd->res = 1; @@ -64,8 +64,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - BevelModifierData *bmd = (BevelModifierData*) md; - BevelModifierData *tbmd = (BevelModifierData*) target; + BevelModifierData *bmd = (BevelModifierData *) md; + BevelModifierData *tbmd = (BevelModifierData *) target; tbmd->value = bmd->value; tbmd->res = bmd->res; @@ -88,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -#define EDGE_MARK 1 +#define EDGE_MARK 1 #ifdef USE_BM_BEVEL_OP_AS_MOD @@ -107,15 +107,14 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) */ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; BMesh *bm; BMEditMesh *em; BMIter iter; BMEdge *e; - BevelModifierData *bmd = (BevelModifierData*) md; + BevelModifierData *bmd = (BevelModifierData *) md; float threshold = cos((bmd->bevel_angle + 0.00001) * M_PI / 180.0); em = DM_to_editbmesh(dm, NULL, FALSE); @@ -128,8 +127,8 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* check for 1 edge having 2 face users */ BMLoop *l1, *l2; - if ( (l1= e->l) && - (l2= e->l->radial_next) != l1) + if ((l1 = e->l) && + (l2 = e->l->radial_next) != l1) { if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { BMO_elem_flag_enable(bm, e, EDGE_MARK); @@ -160,16 +159,15 @@ static DerivedMesh *applyModifier(ModifierData *md, struct Object *UNUSED(ob), #else /* from trunk, see note above */ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; BMEditMesh *em; /*bDeformGroup *def;*/ int /*i,*/ options, defgrp_index = -1; - BevelModifierData *bmd = (BevelModifierData*) md; + BevelModifierData *bmd = (BevelModifierData *) md; options = bmd->flags | bmd->val_flags | bmd->lim_flags | bmd->e_flags; @@ -199,37 +197,37 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), #endif static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } ModifierTypeInfo modifierType_Bevel = { - /* name */ "Bevel", - /* structName */ "BevelModifierData", - /* structSize */ sizeof(BevelModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* name */ "Bevel", + /* structName */ "BevelModifierData", + /* structSize */ sizeof(BevelModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ applyModifierEM, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index c11d6fc50af..6cd8745f5d9 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -52,8 +52,8 @@ static void copyData(ModifierData *md, ModifierData *target) { - BooleanModifierData *bmd = (BooleanModifierData*) md; - BooleanModifierData *tbmd = (BooleanModifierData*) target; + BooleanModifierData *bmd = (BooleanModifierData *) md; + BooleanModifierData *tbmd = (BooleanModifierData *) target; tbmd->object = bmd->object; tbmd->operation = bmd->operation; @@ -61,27 +61,27 @@ static void copyData(ModifierData *md, ModifierData *target) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; return !bmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; walk(userData, ob, &bmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; if (bmd->object) { DagNode *curNode = dag_get_node(forest, bmd->object); @@ -118,11 +118,10 @@ static DerivedMesh *get_quick_derivedMesh(DerivedMesh *derivedData, DerivedMesh } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { - BooleanModifierData *bmd = (BooleanModifierData*) md; + BooleanModifierData *bmd = (BooleanModifierData *) md; DerivedMesh *dm; if (!bmd->object) @@ -146,7 +145,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, // TIMEIT_START(NewBooleanDerivedMesh) result = NewBooleanDerivedMesh(dm, bmd->object, derivedData, ob, - 1 + bmd->operation); + 1 + bmd->operation); // TIMEIT_END(NewBooleanDerivedMesh) } @@ -163,9 +162,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } #else // WITH_MOD_BOOLEAN static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { return derivedData; } @@ -182,28 +180,28 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( ModifierTypeInfo modifierType_Boolean = { - /* name */ "Boolean", - /* structName */ "BooleanModifierData", - /* structSize */ sizeof(BooleanModifierData), - /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache, + /* name */ "Boolean", + /* structName */ "BooleanModifierData", + /* structSize */ sizeof(BooleanModifierData), + /* type */ eModifierTypeType_Nonconstructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_UsesPointCache, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ NULL, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ NULL, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean_util.c b/source/blender/modifiers/intern/MOD_boolean_util.c index 8d6295ee6d4..39344aad5a9 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.c +++ b/source/blender/modifiers/intern/MOD_boolean_util.c @@ -70,7 +70,7 @@ typedef struct { * These describe a blender mesh to the CSG module. */ -static void VertexIt_Destruct(CSG_VertexIteratorDescriptor * iterator) +static void VertexIt_Destruct(CSG_VertexIteratorDescriptor *iterator) { if (iterator->it) { // deallocate memory for iterator @@ -87,23 +87,23 @@ static void VertexIt_Destruct(CSG_VertexIteratorDescriptor * iterator) static int VertexIt_Done(CSG_IteratorPtr it) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; return(iterator->pos >= iterator->dm->getNumVerts(iterator->dm)); } static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; MVert *verts = iterator->dm->getVertArray(iterator->dm); float global_pos[3]; /* boolean happens in global space, transform both with obmat */ mul_v3_m4v3( - global_pos, - iterator->ob->obmat, - verts[iterator->pos].co - ); + global_pos, + iterator->ob->obmat, + verts[iterator->pos].co + ); vert->position[0] = global_pos[0]; vert->position[1] = global_pos[1]; @@ -112,13 +112,13 @@ static void VertexIt_Fill(CSG_IteratorPtr it, CSG_IVertex *vert) static void VertexIt_Step(CSG_IteratorPtr it) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; iterator->pos++; } static void VertexIt_Reset(CSG_IteratorPtr it) { - VertexIt * iterator = (VertexIt *)it; + VertexIt *iterator = (VertexIt *)it; iterator->pos = 0; } @@ -139,7 +139,7 @@ static void VertexIt_Construct(CSG_VertexIteratorDescriptor *output, DerivedMesh it->pos = 0; - // assign iterator function pointers. + // assign iterator function pointers. output->Step = VertexIt_Step; output->Fill = VertexIt_Fill; output->Done = VertexIt_Done; @@ -159,7 +159,7 @@ typedef struct { int flip; } FaceIt; -static void FaceIt_Destruct(CSG_FaceIteratorDescriptor * iterator) +static void FaceIt_Destruct(CSG_FaceIteratorDescriptor *iterator) { MEM_freeN(iterator->it); iterator->Done = NULL; @@ -172,7 +172,7 @@ static void FaceIt_Destruct(CSG_FaceIteratorDescriptor * iterator) static int FaceIt_Done(CSG_IteratorPtr it) { // assume CSG_IteratorPtr is of the correct type. - FaceIt * iterator = (FaceIt *)it; + FaceIt *iterator = (FaceIt *)it; return(iterator->pos >= iterator->dm->getNumTessFaces(iterator->dm)); } @@ -185,9 +185,9 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) /* reverse face vertices if necessary */ face->vertex_index[1] = mface->v2; - if ( face_it->flip == 0 ) { - face->vertex_index[0] = mface->v1; - face->vertex_index[2] = mface->v3; + if (face_it->flip == 0) { + face->vertex_index[0] = mface->v1; + face->vertex_index[2] = mface->v3; } else { face->vertex_index[2] = mface->v1; @@ -206,18 +206,18 @@ static void FaceIt_Fill(CSG_IteratorPtr it, CSG_IFace *face) static void FaceIt_Step(CSG_IteratorPtr it) { - FaceIt * face_it = (FaceIt *)it; + FaceIt *face_it = (FaceIt *)it; face_it->pos++; } static void FaceIt_Reset(CSG_IteratorPtr it) { - FaceIt * face_it = (FaceIt *)it; + FaceIt *face_it = (FaceIt *)it; face_it->pos = 0; } static void FaceIt_Construct( - CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) + CSG_FaceIteratorDescriptor *output, DerivedMesh *dm, int offset, Object *ob) { FaceIt *it; if (output == 0) return; @@ -277,35 +277,35 @@ static Object *AddNewBlenderMesh(Scene *scene, Base *base) // now create a new blender object. // duplicating all the settings from the previous object // to the new one. - ob_new= copy_object(base->object); + ob_new = BKE_object_copy(base->object); // Ok we don't want to use the actual data from the // last object, the above function incremented the // number of users, so decrement it here. - old_me= ob_new->data; + old_me = ob_new->data; old_me->id.us--; // Now create a new base to add into the linked list of // vase objects. - basen= MEM_mallocN(sizeof(Base), "duplibase"); - *basen= *base; - BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ - basen->object= ob_new; + basen = MEM_mallocN(sizeof(Base), "duplibase"); + *basen = *base; + BLI_addhead(&scene->base, basen); /* addhead: anders oneindige lus */ + basen->object = ob_new; basen->flag &= ~SELECT; // Initialize the mesh data associated with this object. - ob_new->data= add_mesh("Mesh"); + ob_new->data = BKE_mesh_add("Mesh"); // Finally assign the object type. - ob_new->type= OB_MESH; + ob_new->type = OB_MESH; return ob_new; } static void InterpCSGFace( - DerivedMesh *dm, DerivedMesh *orig_dm, int index, int orig_index, int nr, - float mapmat[][4]) + DerivedMesh *dm, DerivedMesh *orig_dm, int index, int orig_index, int nr, + float mapmat[][4]) { float obco[3], *co[4], *orig_co[4], w[4][4]; MFace *mface, *orig_mface; @@ -318,13 +318,13 @@ static void InterpCSGFace( orig_co[0] = (orig_dm->getVertArray(orig_dm) + orig_mface->v1)->co; orig_co[1] = (orig_dm->getVertArray(orig_dm) + orig_mface->v2)->co; orig_co[2] = (orig_dm->getVertArray(orig_dm) + orig_mface->v3)->co; - orig_co[3] = (orig_mface->v4)? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co: NULL; + orig_co[3] = (orig_mface->v4) ? (orig_dm->getVertArray(orig_dm) + orig_mface->v4)->co : NULL; // get the vertex coordinates from the new derivedmesh co[0] = CDDM_get_vert(dm, mface->v1)->co; co[1] = CDDM_get_vert(dm, mface->v2)->co; co[2] = CDDM_get_vert(dm, mface->v3)->co; - co[3] = (nr == 4)? CDDM_get_vert(dm, mface->v4)->co: NULL; + co[3] = (nr == 4) ? CDDM_get_vert(dm, mface->v4)->co : NULL; for (j = 0; j < nr; j++) { // get coordinate into the space of the original mesh @@ -336,35 +336,35 @@ static void InterpCSGFace( interp_weights_face_v3(w[j], orig_co[0], orig_co[1], orig_co[2], orig_co[3], obco); } - CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float*)w, 1, index); + CustomData_interp(&orig_dm->faceData, &dm->faceData, &orig_index, NULL, (float *)w, 1, index); } /* Iterate over the CSG Output Descriptors and create a new DerivedMesh * from them */ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( - CSG_FaceIteratorDescriptor *face_it, - CSG_VertexIteratorDescriptor *vertex_it, - float parinv[][4], - float mapmat[][4], - Material **mat, - int *totmat, - DerivedMesh *dm1, - Object *ob1, - DerivedMesh *dm2, - Object *ob2) + CSG_FaceIteratorDescriptor *face_it, + CSG_VertexIteratorDescriptor *vertex_it, + float parinv[][4], + float mapmat[][4], + Material **mat, + int *totmat, + DerivedMesh *dm1, + Object *ob1, + DerivedMesh *dm2, + Object *ob2) { DerivedMesh *result, *orig_dm; GHash *material_hash = NULL; - Mesh *me1= (Mesh*)ob1->data; - Mesh *me2= (Mesh*)ob2->data; + Mesh *me1 = (Mesh *)ob1->data; + Mesh *me2 = (Mesh *)ob2->data; int i, *origindex_layer; // create a new DerivedMesh result = CDDM_new(vertex_it->num_elements, 0, face_it->num_elements, 0, 0); CustomData_merge(&dm1->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), - CD_DEFAULT, face_it->num_elements); + CD_DEFAULT, face_it->num_elements); CustomData_merge(&dm2->faceData, &result->faceData, CD_MASK_DERIVEDMESH & ~(CD_MASK_NORMAL | CD_MASK_POLYINDEX | CD_MASK_ORIGINDEX), - CD_DEFAULT, face_it->num_elements); + CD_DEFAULT, face_it->num_elements); // step through the vertex iterators: for (i = 0; !vertex_it->Done(vertex_it->it); i++) { @@ -402,10 +402,10 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( face_it->Step(face_it->it); // find the original mesh and data - orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1))? ob1: ob2; - orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1))? dm1: dm2; - orig_me = (orig_ob == ob1)? me1: me2; - orig_index = (orig_ob == ob1)? csgface.orig_face: csgface.orig_face - dm1->getNumTessFaces(dm1); + orig_ob = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? ob1 : ob2; + orig_dm = (csgface.orig_face < dm1->getNumTessFaces(dm1)) ? dm1 : dm2; + orig_me = (orig_ob == ob1) ? me1 : me2; + orig_index = (orig_ob == ob1) ? csgface.orig_face : csgface.orig_face - dm1->getNumTessFaces(dm1); // copy all face layers, including mface CustomData_copy_data(&orig_dm->faceData, &result->faceData, orig_index, i, 1); @@ -415,7 +415,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mface->v1 = csgface.vertex_index[0]; mface->v2 = csgface.vertex_index[1]; mface->v3 = csgface.vertex_index[2]; - mface->v4 = (csgface.vertex_number == 4)? csgface.vertex_index[3]: 0; + mface->v4 = (csgface.vertex_number == 4) ? csgface.vertex_index[3] : 0; // set material, based on lookup in hash table orig_mat = give_current_material(orig_ob, mface->mat_nr + 1); @@ -459,7 +459,7 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( mface->mat_nr = 0; InterpCSGFace(result, orig_dm, i, orig_index, csgface.vertex_number, - (orig_me == me2)? mapmat: NULL); + (orig_me == me2) ? mapmat : NULL); test_index_face(mface, &result->faceData, i, csgface.vertex_number); @@ -490,27 +490,27 @@ static DerivedMesh *ConvertCSGDescriptorsToDerivedMesh( } static void BuildMeshDescriptors( - struct DerivedMesh *dm, - struct Object *ob, - int face_offset, - struct CSG_FaceIteratorDescriptor * face_it, - struct CSG_VertexIteratorDescriptor * vertex_it) + struct DerivedMesh *dm, + struct Object *ob, + int face_offset, + struct CSG_FaceIteratorDescriptor *face_it, + struct CSG_VertexIteratorDescriptor *vertex_it) { VertexIt_Construct(vertex_it, dm, ob); FaceIt_Construct(face_it, dm, face_offset, ob); } static void FreeMeshDescriptors( - struct CSG_FaceIteratorDescriptor *face_it, - struct CSG_VertexIteratorDescriptor *vertex_it) + struct CSG_FaceIteratorDescriptor *face_it, + struct CSG_VertexIteratorDescriptor *vertex_it) { VertexIt_Destruct(vertex_it); FaceIt_Destruct(face_it); } static DerivedMesh *NewBooleanDerivedMesh_intern( - DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type, Material **mat, int *totmat) + DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, + int int_op_type, Material **mat, int *totmat) { float inv_mat[4][4]; @@ -543,11 +543,11 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( // work out the operation they chose and pick the appropriate // enum from the csg module. switch (int_op_type) { - case 1 : op_type = e_csg_intersection; break; - case 2 : op_type = e_csg_union; break; - case 3 : op_type = e_csg_difference; break; - case 4 : op_type = e_csg_classify; break; - default : op_type = e_csg_intersection; + case 1: op_type = e_csg_intersection; break; + case 2: op_type = e_csg_union; break; + case 3: op_type = e_csg_difference; break; + case 4: op_type = e_csg_classify; break; + default: op_type = e_csg_intersection; } BuildMeshDescriptors(dm_select, ob_select, 0, &fd_1, &vd_1); @@ -566,7 +566,7 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( // iterate through results of operation and insert // into new object result = ConvertCSGDescriptorsToDerivedMesh( - &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); + &fd_o, &vd_o, inv_mat, map_mat, mat, totmat, dm_select, ob_select, dm, ob); // free up the memory CSG_FreeVertexDescriptor(&vd_o); @@ -587,20 +587,20 @@ static DerivedMesh *NewBooleanDerivedMesh_intern( int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) { Mesh *me_new; - int a, maxmat, totmat= 0; + int a, maxmat, totmat = 0; Object *ob_new, *ob, *ob_select; Material **mat; DerivedMesh *result; DerivedMesh *dm_select; DerivedMesh *dm; - ob= base->object; - ob_select= base_select->object; + ob = base->object; + ob_select = base_select->object; dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); dm_select = mesh_create_derived_view(scene, ob_select, 0); // no modifiers in editmode ?? - maxmat= ob->totcol + ob_select->totcol; + maxmat = ob->totcol + ob_select->totcol; mat = (Material **)MEM_mallocN(sizeof(Material *) * maxmat, "NewBooleanMeshMat"); /* put some checks in for nice user feedback */ @@ -613,7 +613,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) return -1; } - result= NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, mat, &totmat); + result = NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, mat, &totmat); if (result == NULL) { MEM_freeN(mat); @@ -621,8 +621,8 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) } /* create a new blender mesh object - using 'base' as a template */ - ob_new= AddNewBlenderMesh(scene, base_select); - me_new= ob_new->data; + ob_new = AddNewBlenderMesh(scene, base_select); + me_new = ob_new->data; DM_to_mesh(result, me_new, ob_new); result->release(result); @@ -643,7 +643,7 @@ int NewBooleanMesh(Scene *scene, Base *base, Base *base_select, int int_op_type) } DerivedMesh *NewBooleanDerivedMesh(DerivedMesh *dm, struct Object *ob, DerivedMesh *dm_select, struct Object *ob_select, - int int_op_type) + int int_op_type) { return NewBooleanDerivedMesh_intern(dm, ob, dm_select, ob_select, int_op_type, NULL, NULL); } diff --git a/source/blender/modifiers/intern/MOD_boolean_util.h b/source/blender/modifiers/intern/MOD_boolean_util.h index 6ba4940a4e9..b996dc6d6ba 100644 --- a/source/blender/modifiers/intern/MOD_boolean_util.h +++ b/source/blender/modifiers/intern/MOD_boolean_util.h @@ -48,6 +48,7 @@ int NewBooleanMesh(struct Scene *scene, struct Base *base, struct Base *base_sel * are in fact mesh object. On success returns a DerivedMesh. On failure * returns NULL and reports an error. */ -struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, struct DerivedMesh *dm_select, struct Object *ob_select, int int_op_type); +struct DerivedMesh *NewBooleanDerivedMesh(struct DerivedMesh *dm, struct Object *ob, + struct DerivedMesh *dm_select, struct Object *ob_select, int int_op_type); #endif // MOD_BOOLEAN_UTILS diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index ddfb793bd5d..9285ec6674c 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -53,7 +53,7 @@ static void initData(ModifierData *md) { - BuildModifierData *bmd = (BuildModifierData*) md; + BuildModifierData *bmd = (BuildModifierData *) md; bmd->start = 1.0; bmd->length = 100.0; @@ -61,8 +61,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - BuildModifierData *bmd = (BuildModifierData*) md; - BuildModifierData *tbmd = (BuildModifierData*) target; + BuildModifierData *bmd = (BuildModifierData *) md; + BuildModifierData *tbmd = (BuildModifierData *) target; tbmd->start = bmd->start; tbmd->length = bmd->length; @@ -77,12 +77,11 @@ static int dependsOnTime(ModifierData *UNUSED(md)) static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = derivedData; DerivedMesh *result; - BuildModifierData *bmd = (BuildModifierData*) md; + BuildModifierData *bmd = (BuildModifierData *) md; int i, j, k; int numFaces_dst, numEdges_dst, numLoops_dst = 0; int *vertMap, *edgeMap, *faceMap; @@ -115,7 +114,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), faceMap = MEM_callocN(sizeof(*faceMap) * numPoly_src, "build modifier faceMap"); for (i = 0; i < numPoly_src; i++) faceMap[i] = i; - frac = (BKE_curframe(md->scene) - bmd->start) / bmd->length; + frac = (BKE_scene_frame_get(md->scene) - bmd->start) / bmd->length; CLAMP(frac, 0.0f, 1.0f); numFaces_dst = numPoly_src * frac; @@ -141,7 +140,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), mp = mpoly + faceMap[i]; ml = mloop + mp->loopstart; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { if (!BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(ml->v))) BLI_ghash_insert(vertHash, SET_INT_IN_POINTER(ml->v), SET_INT_IN_POINTER(BLI_ghash_size(vertHash))); @@ -157,8 +156,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), for (i = 0; i < numEdge_src; i++) { MEdge *me = medge + i; - if ( BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1)) && - BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) + if (BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v1)) && + BLI_ghash_haskey(vertHash, SET_INT_IN_POINTER(me->v2))) { j = BLI_ghash_size(edgeHash); @@ -225,17 +224,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), BLI_ghash_size(edgeHash), 0, numLoops_dst, numFaces_dst); /* copy the vertices across */ - for ( hashIter = BLI_ghashIterator_new(vertHash); - !BLI_ghashIterator_isDone(hashIter); - BLI_ghashIterator_step(hashIter) - ) + for (hashIter = BLI_ghashIterator_new(vertHash); + !BLI_ghashIterator_isDone(hashIter); + BLI_ghashIterator_step(hashIter) + ) { MVert source; MVert *dest; int oldIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getKey(hashIter)); int newIndex = GET_INT_FROM_POINTER(BLI_ghashIterator_getValue(hashIter)); - source = mvert_src [oldIndex]; + source = mvert_src[oldIndex]; dest = CDDM_get_vert(result, newIndex); DM_copy_vert_data(dm, result, oldIndex, newIndex, 1); @@ -278,7 +277,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), DM_copy_loop_data(dm, result, source->loopstart, dest->loopstart, dest->totloop); ml_src = mloop_src + source->loopstart; - for (j=0; jtotloop; j++, k++, ml_src++, ml_dst++) { + for (j = 0; j < source->totloop; j++, k++, ml_src++, ml_dst++) { ml_dst->v = GET_INT_FROM_POINTER(BLI_ghash_lookup(vertHash, SET_INT_IN_POINTER(ml_src->v))); ml_dst->e = GET_INT_FROM_POINTER(BLI_ghash_lookup(edgeHash2, SET_INT_IN_POINTER(ml_src->e))); } @@ -297,27 +296,27 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), ModifierTypeInfo modifierType_Build = { - /* name */ "Build", - /* structName */ "BuildModifierData", - /* structSize */ sizeof(BuildModifierData), - /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ NULL, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Build", + /* structName */ "BuildModifierData", + /* structSize */ sizeof(BuildModifierData), + /* type */ eModifierTypeType_Nonconstructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 8ad5b72204b..c4772895b03 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -52,13 +52,12 @@ static void initData(ModifierData *md) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; cmd->fac = 0.5f; cmd->radius = 0.0f; cmd->size = 0.0f; - cmd->flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z - | MOD_CAST_SIZE_FROM_RADIUS; + cmd->flag = MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z | MOD_CAST_SIZE_FROM_RADIUS; cmd->type = MOD_CAST_TYPE_SPHERE; cmd->defgrp_name[0] = '\0'; cmd->object = NULL; @@ -67,8 +66,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - CastModifierData *cmd = (CastModifierData*) md; - CastModifierData *tcmd = (CastModifierData*) target; + CastModifierData *cmd = (CastModifierData *) md; + CastModifierData *tcmd = (CastModifierData *) target; tcmd->fac = cmd->fac; tcmd->radius = cmd->radius; @@ -81,10 +80,10 @@ static void copyData(ModifierData *md, ModifierData *target) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; short flag; - flag = cmd->flag & (MOD_CAST_X|MOD_CAST_Y|MOD_CAST_Z); + flag = cmd->flag & (MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z); if ((cmd->fac == 0.0f) || flag == 0) return 1; @@ -103,33 +102,33 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; - walk (userData, ob, &cmd->object); + walk(userData, ob, &cmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - CastModifierData *cmd = (CastModifierData*) md; + CastModifierData *cmd = (CastModifierData *) md; if (cmd->object) { DagNode *curNode = dag_get_node(forest, cmd->object); dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Cast Modifier"); + "Cast Modifier"); } } static void sphere_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + CastModifierData *cmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; @@ -200,7 +199,7 @@ static void sphere_do( * with or w/o a vgroup. With lots of if's in the code below, * further optimization's are possible, if needed */ if (dvert) { /* with a vgroup */ - MDeformVert *dv= dvert; + MDeformVert *dv = dvert; float fac_orig = fac; for (i = 0; i < numVerts; i++, dv++) { float tmp_co[3]; @@ -225,7 +224,7 @@ static void sphere_do( if (len_v3(vec) > cmd->radius) continue; } - weight= defvert_find_weight(dv, defgrp_index); + weight = defvert_find_weight(dv, defgrp_index); if (weight <= 0.0f) continue; fac = fac_orig * weight; @@ -234,11 +233,11 @@ static void sphere_do( normalize_v3(vec); if (flag & MOD_CAST_X) - tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; + tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0]; if (flag & MOD_CAST_Y) - tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1]; + tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1]; if (flag & MOD_CAST_Z) - tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2]; + tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2]; if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { @@ -280,11 +279,11 @@ static void sphere_do( normalize_v3(vec); if (flag & MOD_CAST_X) - tmp_co[0] = fac*vec[0]*len + facm*tmp_co[0]; + tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0]; if (flag & MOD_CAST_Y) - tmp_co[1] = fac*vec[1]*len + facm*tmp_co[1]; + tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1]; if (flag & MOD_CAST_Z) - tmp_co[2] = fac*vec[2]*len + facm*tmp_co[2]; + tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2]; if (ctrl_ob) { if (flag & MOD_CAST_USE_OB_TRANSFORM) { @@ -300,8 +299,8 @@ static void sphere_do( } static void cuboid_do( - CastModifierData *cmd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + CastModifierData *cmd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; Object *ctrl_ob = NULL; @@ -579,11 +578,10 @@ static void cuboid_do( } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = NULL; CastModifierData *cmd = (CastModifierData *)md; @@ -602,8 +600,8 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); CastModifierData *cmd = (CastModifierData *)md; @@ -625,8 +623,8 @@ ModifierTypeInfo modifierType_Cast = { /* structName */ "CastModifierData", /* structSize */ sizeof(CastModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 1bc23ab5040..2c38bc42a8f 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -54,7 +54,7 @@ static void initData(ModifierData *md) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; clmd->sim_parms = MEM_callocN(sizeof(ClothSimSettings), "cloth sim parms"); clmd->coll_parms = MEM_callocN(sizeof(ClothCollSettings), "cloth coll parms"); @@ -64,15 +64,15 @@ static void initData(ModifierData *md) if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) return; - cloth_init (clmd); + cloth_init(clmd); } static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], - int UNUSED(numVerts), int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + int UNUSED(numVerts), ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm; - ClothModifierData *clmd = (ClothModifierData*) md; - DerivedMesh *result=NULL; + ClothModifierData *clmd = (ClothModifierData *) md; + DerivedMesh *result = NULL; /* check for alloc failing */ if (!clmd->sim_parms || !clmd->coll_parms) { @@ -102,13 +102,13 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Object *ob, DagNode *obNode) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; Base *base; if (clmd) { - for (base = scene->base.first; base; base= base->next) { - Object *ob1= base->object; + for (base = scene->base.first; base; base = base->next) { + Object *ob1 = base->object; if (ob1 != ob) { CollisionModifierData *coll_clmd = (CollisionModifierData *)modifiers_findByType(ob1, eModifierType_Collision); if (coll_clmd) { @@ -123,7 +123,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Scene *scene, Ob static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { CustomDataMask dataMask = 0; - ClothModifierData *clmd = (ClothModifierData*)md; + ClothModifierData *clmd = (ClothModifierData *)md; if (cloth_uses_vgroup(clmd)) dataMask |= CD_MASK_MDEFORMVERT; @@ -136,8 +136,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - ClothModifierData *clmd = (ClothModifierData*) md; - ClothModifierData *tclmd = (ClothModifierData*) target; + ClothModifierData *clmd = (ClothModifierData *) md; + ClothModifierData *tclmd = (ClothModifierData *) target; if (tclmd->sim_parms) { if (tclmd->sim_parms->effector_weights) @@ -166,13 +166,13 @@ static int dependsOnTime(ModifierData *UNUSED(md)) static void freeData(ModifierData *md) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; if (clmd) { if (G.rt > 0) printf("clothModifier_freeData\n"); - cloth_free_modifier_extern (clmd); + cloth_free_modifier_extern(clmd); if (clmd->sim_parms) { if (clmd->sim_parms->effector_weights) @@ -188,9 +188,9 @@ static void freeData(ModifierData *md) } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - ClothModifierData *clmd = (ClothModifierData*) md; + ClothModifierData *clmd = (ClothModifierData *) md; if (clmd->coll_parms) { walk(userData, ob, (ID **)&clmd->coll_parms->group); @@ -206,9 +206,9 @@ ModifierTypeInfo modifierType_Cloth = { /* structName */ "ClothModifierData", /* structSize */ sizeof(ClothModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_UsesPointCache | + eModifierTypeFlag_Single, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 9636104cb06..a3169bdba46 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -55,7 +55,7 @@ static void initData(ModifierData *md) { - CollisionModifierData *collmd = (CollisionModifierData*) md; + CollisionModifierData *collmd = (CollisionModifierData *) md; collmd->x = NULL; collmd->xnew = NULL; @@ -69,7 +69,7 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { - CollisionModifierData *collmd = (CollisionModifierData*) md; + CollisionModifierData *collmd = (CollisionModifierData *) md; if (collmd) { if (collmd->bvhtree) @@ -105,13 +105,12 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + ModifierApplyFlag UNUSED(flag)) { - CollisionModifierData *collmd = (CollisionModifierData*) md; + CollisionModifierData *collmd = (CollisionModifierData *) md; DerivedMesh *dm = NULL; MVert *tempVert = NULL; @@ -131,12 +130,12 @@ static void deformVerts(ModifierData *md, Object *ob, CDDM_apply_vert_coords(dm, vertexCos); CDDM_calc_normals(dm); - current_time = BKE_curframe(md->scene); + current_time = BKE_scene_frame_get(md->scene); if (G.rt > 0) printf("current_time %f, collmd->time_xnew %f\n", current_time, collmd->time_xnew); - numverts = dm->getNumVerts (dm); + numverts = dm->getNumVerts(dm); if ((current_time > collmd->time_xnew) || (BKE_ptcache_get_continue_physics())) { unsigned int i; @@ -177,15 +176,15 @@ static void deformVerts(ModifierData *md, Object *ob, collmd->xnew = tempVert; collmd->time_x = collmd->time_xnew; - memcpy(collmd->xnew, dm->getVertArray(dm), numverts*sizeof(MVert)); + memcpy(collmd->xnew, dm->getVertArray(dm), numverts * sizeof(MVert)); for (i = 0; i < numverts; i++) { // we save global positions mul_m4_v3(ob->obmat, collmd->xnew[i].co); } - memcpy(collmd->current_xnew, collmd->x, numverts*sizeof(MVert)); - memcpy(collmd->current_x, collmd->x, numverts*sizeof(MVert)); + memcpy(collmd->current_xnew, collmd->x, numverts * sizeof(MVert)); + memcpy(collmd->current_x, collmd->x, numverts * sizeof(MVert)); /* check if GUI setting has changed for bvh */ if (collmd->bvhtree) { @@ -202,7 +201,7 @@ static void deformVerts(ModifierData *md, Object *ob, } else { // recalc static bounding boxes - bvhtree_update_from_mvert ( collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1 ); + bvhtree_update_from_mvert(collmd->bvhtree, collmd->mfaces, collmd->numfaces, collmd->current_x, collmd->current_xnew, collmd->numverts, 1); } collmd->time_xnew = current_time; @@ -232,8 +231,8 @@ ModifierTypeInfo modifierType_Collision = { /* structName */ "CollisionModifierData", /* structSize */ sizeof(CollisionModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_Single, /* copyData */ NULL, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index f516f971dc0..0ce4d74aebb 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -52,15 +52,15 @@ static void initData(ModifierData *md) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; cmd->defaxis = MOD_CURVE_POSX; } static void copyData(ModifierData *md, ModifierData *target) { - CurveModifierData *cmd = (CurveModifierData*) md; - CurveModifierData *tcmd = (CurveModifierData*) target; + CurveModifierData *cmd = (CurveModifierData *) md; + CurveModifierData *tcmd = (CurveModifierData *) target; tcmd->defaxis = cmd->defaxis; tcmd->object = cmd->object; @@ -80,27 +80,27 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; return !cmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; walk(userData, ob, &cmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; if (cmd->object) { DagNode *curNode = dag_get_node(forest, cmd->object); @@ -111,29 +111,28 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - CurveModifierData *cmd = (CurveModifierData*) md; + CurveModifierData *cmd = (CurveModifierData *) md; /* silly that defaxis and curve_deform_verts are off by 1 * but leave for now to save having to call do_versions */ curve_deform_verts(md->scene, cmd->object, ob, derivedData, vertexCos, numVerts, - cmd->name, cmd->defaxis-1); + cmd->name, cmd->defaxis - 1); } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); - deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); + deformVerts(md, ob, dm, vertexCos, numVerts, 0); if (!derivedData) dm->release(dm); } @@ -144,8 +143,8 @@ ModifierTypeInfo modifierType_Curve = { /* structName */ "CurveModifierData", /* structSize */ sizeof(CurveModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, @@ -160,7 +159,7 @@ ModifierTypeInfo modifierType_Curve = { /* isDisabled */ isDisabled, /* updateDepgraph */ updateDepgraph, /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index e1a8e221476..cb6681bfa68 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -56,26 +56,25 @@ static void initData(ModifierData *md) { - DecimateModifierData *dmd = (DecimateModifierData*) md; + DecimateModifierData *dmd = (DecimateModifierData *) md; dmd->percent = 1.0; } static void copyData(ModifierData *md, ModifierData *target) { - DecimateModifierData *dmd = (DecimateModifierData*) md; - DecimateModifierData *tdmd = (DecimateModifierData*) target; + DecimateModifierData *dmd = (DecimateModifierData *) md; + DecimateModifierData *tdmd = (DecimateModifierData *) target; tdmd->percent = dmd->percent; } #ifdef WITH_MOD_DECIMATE static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { - DecimateModifierData *dmd = (DecimateModifierData*) md; + DecimateModifierData *dmd = (DecimateModifierData *) md; DerivedMesh *dm = derivedData, *result = NULL; MVert *mvert; MFace *mface; @@ -91,59 +90,59 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), totface = dm->getNumTessFaces(dm); numTris = 0; - for (a=0; av4) numTris++; } - if (numTris<3) { + if (numTris < 3) { modifier_setError(md, "%s", TIP_("Modifier requires more than 3 input faces (triangles).")); dm = CDDM_copy(dm); return dm; } - lod.vertex_buffer= MEM_mallocN(3*sizeof(float)*totvert, "vertices"); - lod.vertex_normal_buffer= MEM_mallocN(3*sizeof(float)*totvert, "normals"); - lod.triangle_index_buffer= MEM_mallocN(3*sizeof(int)*numTris, "trias"); - lod.vertex_num= totvert; - lod.face_num= numTris; + lod.vertex_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "vertices"); + lod.vertex_normal_buffer = MEM_mallocN(3 * sizeof(float) * totvert, "normals"); + lod.triangle_index_buffer = MEM_mallocN(3 * sizeof(int) * numTris, "trias"); + lod.vertex_num = totvert; + lod.face_num = numTris; - for (a=0; aco); normal_short_to_float_v3(vbNo, mv->no); } numTris = 0; - for (a=0; av1; - tri[1]= mf->v2; - tri[2]= mf->v3; + int *tri = &lod.triangle_index_buffer[3 * numTris++]; + tri[0] = mf->v1; + tri[1] = mf->v2; + tri[2] = mf->v3; if (mf->v4) { - tri = &lod.triangle_index_buffer[3*numTris++]; - tri[0]= mf->v1; - tri[1]= mf->v3; - tri[2]= mf->v4; + tri = &lod.triangle_index_buffer[3 * numTris++]; + tri[0] = mf->v1; + tri[1] = mf->v3; + tri[2] = mf->v4; } } dmd->faceCount = 0; if (LOD_LoadMesh(&lod) ) { - if ( LOD_PreprocessMesh(&lod) ) { + if (LOD_PreprocessMesh(&lod) ) { /* we assume the decim_faces tells how much to reduce */ - while (lod.face_num > numTris*dmd->percent) { - if ( LOD_CollapseEdge(&lod) == 0) break; + while (lod.face_num > numTris * dmd->percent) { + if (LOD_CollapseEdge(&lod) == 0) break; } - if (lod.vertex_num>2) { + if (lod.vertex_num > 2) { result = CDDM_new(lod.vertex_num, 0, lod.face_num, 0, 0); dmd->faceCount = lod.face_num; } @@ -151,18 +150,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), result = CDDM_new(lod.vertex_num, 0, 0, 0, 0); mvert = CDDM_get_verts(result); - for (a=0; aco, vbCo); } - if (lod.vertex_num>2) { + if (lod.vertex_num > 2) { mface = CDDM_get_tessfaces(result); for (a = 0; a < lod.face_num; a++) { MFace *mf = &mface[a]; - int *tri = &lod.triangle_index_buffer[a*3]; + int *tri = &lod.triangle_index_buffer[a * 3]; mf->v1 = tri[0]; mf->v2 = tri[1]; mf->v3 = tri[2]; @@ -195,9 +194,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *UNUSED(ob), } #else // WITH_MOD_DECIMATE static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { return derivedData; } diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 4d9b8de061e..01592d63bb2 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -58,7 +58,7 @@ static void initData(ModifierData *md) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; dmd->texture = NULL; dmd->strength = 1; @@ -68,8 +68,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; - DisplaceModifierData *tdmd = (DisplaceModifierData*) target; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; + DisplaceModifierData *tdmd = (DisplaceModifierData *) target; tdmd->texture = dmd->texture; tdmd->strength = dmd->strength; @@ -114,17 +114,17 @@ static int dependsOnNormals(ModifierData *md) } static void foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; walk(userData, ob, &dmd->map_object); } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; walk(userData, ob, (ID **)&dmd->texture); @@ -132,24 +132,24 @@ static void foreachIDLink(ModifierData *md, Object *ob, } static void foreachTexLink(ModifierData *md, Object *ob, - TexWalkFunc walk, void *userData) + TexWalkFunc walk, void *userData) { walk(userData, ob, md, "texture"); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; return (!dmd->texture || dmd->strength == 0.0f); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - DisplaceModifierData *dmd = (DisplaceModifierData*) md; + DisplaceModifierData *dmd = (DisplaceModifierData *) md; if (dmd->map_object && dmd->texmapping == MOD_DISP_MAP_OBJECT) { DagNode *curNode = dag_get_node(forest, dmd->map_object); @@ -167,15 +167,15 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, /* dm must be a CDDerivedMesh */ static void displaceModifier_do( - DisplaceModifierData *dmd, Object *ob, - DerivedMesh *dm, float (*vertexCos)[3], int numVerts) + DisplaceModifierData *dmd, Object *ob, + DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { int i; MVert *mvert; MDeformVert *dvert; int defgrp_index; float (*tex_co)[3]; - float weight= 1.0f; /* init value unused but some compilers may complain */ + float weight = 1.0f; /* init value unused but some compilers may complain */ if (!dmd->texture) return; if (dmd->strength == 0.0f) return; @@ -184,7 +184,7 @@ static void displaceModifier_do( modifier_get_vgroup(ob, dm, dmd->defgrp_name, &dvert, &defgrp_index); tex_co = MEM_callocN(sizeof(*tex_co) * numVerts, - "displaceModifier_do tex_co"); + "displaceModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)dmd, ob, dm, vertexCos, tex_co, numVerts); modifier_init_texture(dmd->modifier.scene, dmd->texture); @@ -194,7 +194,7 @@ static void displaceModifier_do( float delta = 0, strength = dmd->strength; if (dvert) { - weight= defvert_find_weight(dvert + i, defgrp_index); + weight = defvert_find_weight(dvert + i, defgrp_index); if (weight == 0.0f) continue; } @@ -235,13 +235,12 @@ static void displaceModifier_do( } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - DerivedMesh *dm= get_cddm(ob, NULL, derivedData, vertexCos); + DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos); displaceModifier_do((DisplaceModifierData *)md, ob, dm, vertexCos, numVerts); @@ -251,10 +250,10 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm= get_cddm(ob, editData, derivedData, vertexCos); + DerivedMesh *dm = get_cddm(ob, editData, derivedData, vertexCos); displaceModifier_do((DisplaceModifierData *)md, ob, dm, vertexCos, numVerts); @@ -269,8 +268,8 @@ ModifierTypeInfo modifierType_Displace = { /* structName */ "DisplaceModifierData", /* structSize */ sizeof(DisplaceModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index 5005e2c010d..159da9adfcf 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -47,7 +47,7 @@ static void initData(ModifierData *md) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; pmd->canvas = NULL; pmd->brush = NULL; @@ -56,34 +56,34 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*)md; - DynamicPaintModifierData *tpmd = (DynamicPaintModifierData*)target; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; + DynamicPaintModifierData *tpmd = (DynamicPaintModifierData *)target; dynamicPaint_Modifier_copy(pmd, tpmd); } static void freeData(ModifierData *md) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; dynamicPaint_Modifier_free(pmd); } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*)md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md; CustomDataMask dataMask = 0; if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; - for (; surface; surface=surface->next) { + for (; surface; surface = surface->next) { /* tface */ if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ || - surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) { + surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) { dataMask |= (1 << CD_MTFACE); } /* mcol */ if (surface->type == MOD_DPAINT_SURFACE_T_PAINT || - surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) { + surface->init_color_type == MOD_DPAINT_INITIAL_VERTEXCOLOR) { dataMask |= (1 << CD_MCOL); } /* CD_MDEFORMVERT */ @@ -102,32 +102,32 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *dm, + ModifierApplyFlag UNUSED(flag)) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; return dynamicPaint_Modifier_do(pmd, md->scene, ob, dm); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *scene, - Object *ob, - DagNode *obNode) + struct Scene *scene, + Object *ob, + DagNode *obNode) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; /* add relation from canvases to all brush objects */ if (pmd && pmd->canvas) { Base *base = scene->base.first; for (; base; base = base->next) { - DynamicPaintModifierData *pmd2 = (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint); + DynamicPaintModifierData *pmd2 = + (DynamicPaintModifierData *)modifiers_findByType(base->object, eModifierType_DynamicPaint); - if (pmd2 && pmd2->brush && ob!=base->object) { + if (pmd2 && pmd2->brush && ob != base->object) { DagNode *brushNode = dag_get_node(forest, base->object); - dag_add_relation(forest, brushNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Dynamic Paint Brush"); + dag_add_relation(forest, brushNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Dynamic Paint Brush"); } } } @@ -139,14 +139,14 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - DynamicPaintModifierData *pmd = (DynamicPaintModifierData*) md; + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; if (pmd->canvas) { DynamicPaintSurface *surface = pmd->canvas->surfaces.first; - for (; surface; surface=surface->next) { + for (; surface; surface = surface->next) { walk(userData, ob, (ID **)&surface->brush_group); walk(userData, ob, (ID **)&surface->init_texture); } @@ -157,7 +157,7 @@ static void foreachIDLink(ModifierData *md, Object *ob, } static void foreachTexLink(ModifierData *UNUSED(md), Object *UNUSED(ob), - TexWalkFunc UNUSED(walk), void *UNUSED(userData)) + TexWalkFunc UNUSED(walk), void *UNUSED(userData)) { //walk(userData, ob, md, ""); /* re-enable when possible */ } @@ -167,11 +167,11 @@ ModifierTypeInfo modifierType_DynamicPaint = { /* structName */ "DynamicPaintModifierData", /* structSize */ sizeof(DynamicPaintModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh -/* |eModifierTypeFlag_SupportsMapping*/ - |eModifierTypeFlag_UsesPointCache - |eModifierTypeFlag_Single - |eModifierTypeFlag_UsesPreview, + /* flags */ eModifierTypeFlag_AcceptsMesh | +/* eModifierTypeFlag_SupportsMapping |*/ + eModifierTypeFlag_UsesPointCache | + eModifierTypeFlag_Single | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index 3e399707040..eb3334d31ce 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -55,7 +55,7 @@ * note: this code is very close to MOD_bevel.c */ -#define EDGE_MARK 1 +#define EDGE_MARK 1 static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Object *UNUSED(ob)) { @@ -76,8 +76,8 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) { /* check for 1 edge having 2 face users */ BMLoop *l1, *l2; - if ( (l1= e->l) && - (l2= e->l->radial_next) != l1) + if ((l1 = e->l) && + (l2 = e->l->radial_next) != l1) { if (dot_v3v3(l1->f->no, l2->f->no) < threshold) { BMO_elem_flag_enable(bm, e, EDGE_MARK); @@ -115,7 +115,7 @@ static DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd, Obj static void initData(ModifierData *md) { - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; + EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md; /* default to 30-degree split angle, sharpness from both angle & flag */ emd->split_angle = 30; @@ -124,15 +124,15 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; - EdgeSplitModifierData *temd = (EdgeSplitModifierData*) target; + EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md; + EdgeSplitModifierData *temd = (EdgeSplitModifierData *) target; temd->split_angle = emd->split_angle; temd->flags = emd->flags; } static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd, - Object *ob, DerivedMesh *dm) + Object *ob, DerivedMesh *dm) { if (!(emd->flags & (MOD_EDGESPLIT_FROMANGLE | MOD_EDGESPLIT_FROMFLAG))) return dm; @@ -140,12 +140,11 @@ static DerivedMesh *edgesplitModifier_do(EdgeSplitModifierData *emd, return doEdgeSplit(dm, emd, ob); } -static DerivedMesh *applyModifier( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) +static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; - EdgeSplitModifierData *emd = (EdgeSplitModifierData*) md; + EdgeSplitModifierData *emd = (EdgeSplitModifierData *) md; result = edgesplitModifier_do(emd, ob, derivedData); @@ -156,10 +155,10 @@ static DerivedMesh *applyModifier( } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -168,11 +167,11 @@ ModifierTypeInfo modifierType_EdgeSplit = { /* structName */ "EdgeSplitModifierData", /* structSize */ sizeof(EdgeSplitModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 4270659d851..b69f167f876 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -59,21 +59,21 @@ static void initData(ModifierData *md) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; + ExplodeModifierData *emd = (ExplodeModifierData *) md; - emd->facepa= NULL; - emd->flag |= eExplodeFlag_Unborn+eExplodeFlag_Alive+eExplodeFlag_Dead; + emd->facepa = NULL; + emd->flag |= eExplodeFlag_Unborn + eExplodeFlag_Alive + eExplodeFlag_Dead; } static void freeData(ModifierData *md) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; + ExplodeModifierData *emd = (ExplodeModifierData *) md; if (emd->facepa) MEM_freeN(emd->facepa); } static void copyData(ModifierData *md, ModifierData *target) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; - ExplodeModifierData *temd= (ExplodeModifierData*) target; + ExplodeModifierData *emd = (ExplodeModifierData *) md; + ExplodeModifierData *temd = (ExplodeModifierData *) target; temd->facepa = NULL; temd->flag = emd->flag; @@ -86,7 +86,7 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - ExplodeModifierData *emd= (ExplodeModifierData*) md; + ExplodeModifierData *emd = (ExplodeModifierData *) md; CustomDataMask dataMask = 0; if (emd->vgroup) @@ -96,48 +96,48 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void createFacepa(ExplodeModifierData *emd, - ParticleSystemModifierData *psmd, - DerivedMesh *dm) + ParticleSystemModifierData *psmd, + DerivedMesh *dm) { - ParticleSystem *psys=psmd->psys; - MFace *fa=NULL, *mface=NULL; + ParticleSystem *psys = psmd->psys; + MFace *fa = NULL, *mface = NULL; MVert *mvert = NULL; ParticleData *pa; KDTree *tree; float center[3], co[3]; - int *facepa=NULL, *vertpa=NULL, totvert=0, totface=0, totpart=0; - int i, p, v1, v2, v3, v4=0; + int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0; + int i, p, v1, v2, v3, v4 = 0; mvert = dm->getVertArray(dm); mface = dm->getTessFaceArray(dm); - totface= dm->getNumTessFaces(dm); - totvert= dm->getNumVerts(dm); - totpart= psmd->psys->totpart; + totface = dm->getNumTessFaces(dm); + totvert = dm->getNumVerts(dm); + totpart = psmd->psys->totpart; BLI_srandom(psys->seed); if (emd->facepa) MEM_freeN(emd->facepa); - facepa = emd->facepa = MEM_callocN(sizeof(int)*totface, "explode_facepa"); + facepa = emd->facepa = MEM_callocN(sizeof(int) * totface, "explode_facepa"); - vertpa = MEM_callocN(sizeof(int)*totvert, "explode_vertpa"); + vertpa = MEM_callocN(sizeof(int) * totvert, "explode_vertpa"); /* initialize all faces & verts to no particle */ - for (i=0; ivgroup) { MDeformVert *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert) { - const int defgrp_index= emd->vgroup-1; - for (i=0; ivgroup - 1; + for (i = 0; i < totvert; i++, dvert++) { float val = BLI_frand(); - val = (1.0f-emd->protect)*val + emd->protect*0.5f; + val = (1.0f - emd->protect) * val + emd->protect * 0.5f; if (val < defvert_find_weight(dvert, defgrp_index)) vertpa[i] = -1; } @@ -145,15 +145,15 @@ static void createFacepa(ExplodeModifierData *emd, } /* make tree of emitter locations */ - tree=BLI_kdtree_new(totpart); - for (p=0, pa=psys->particles; pparticles; p < totpart; p++, pa++) { psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL, NULL); BLI_kdtree_insert(tree, p, co, NULL); } BLI_kdtree_balance(tree); /* set face-particle-indexes to nearest particle to face center */ - for (i=0, fa=mface; iv1].co, mvert[fa->v2].co); add_v3_v3(center, mvert[fa->v3].co); if (fa->v4) { @@ -163,21 +163,21 @@ static void createFacepa(ExplodeModifierData *emd, else mul_v3_fl(center, 0.3333f); - p= BLI_kdtree_find_nearest(tree, center, NULL, NULL); + p = BLI_kdtree_find_nearest(tree, center, NULL, NULL); - v1=vertpa[fa->v1]; - v2=vertpa[fa->v2]; - v3=vertpa[fa->v3]; + v1 = vertpa[fa->v1]; + v2 = vertpa[fa->v2]; + v3 = vertpa[fa->v3]; if (fa->v4) - v4=vertpa[fa->v4]; + v4 = vertpa[fa->v4]; - if (v1>=0 && v2>=0 && v3>=0 && (fa->v4==0 || v4>=0)) - facepa[i]=p; + if (v1 >= 0 && v2 >= 0 && v3 >= 0 && (fa->v4 == 0 || v4 >= 0)) + facepa[i] = p; - if (v1>=0) vertpa[fa->v1]=p; - if (v2>=0) vertpa[fa->v2]=p; - if (v3>=0) vertpa[fa->v3]=p; - if (fa->v4 && v4>=0) vertpa[fa->v4]=p; + if (v1 >= 0) vertpa[fa->v1] = p; + if (v2 >= 0) vertpa[fa->v2] = p; + if (v3 >= 0) vertpa[fa->v3] = p; + if (fa->v4 && v4 >= 0) vertpa[fa->v4] = p; } if (vertpa) MEM_freeN(vertpa); @@ -195,7 +195,7 @@ static const short add_faces[24] = { 0, 0, 2, 0, 1, 2, 2, 0, 2, 1, 2, 2, 2, 2, 3, 0, 0, 0, 1, 0, 1, 1, 2 - }; +}; static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFace *mf) { @@ -206,11 +206,11 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa } #define SET_VERTS(a, b, c, d) \ - v[0] = mf->v##a; uv[0]=a-1; \ - v[1] = mf->v##b; uv[1]=b-1; \ - v[2] = mf->v##c; uv[2]=c-1; \ - v[3] = mf->v##d; uv[3]=d-1; \ - (void)0 + v[0] = mf->v##a; uv[0] = a - 1; \ + v[1] = mf->v##b; uv[1] = b - 1; \ + v[2] = mf->v##c; uv[2] = c - 1; \ + v[3] = mf->v##d; uv[3] = d - 1; \ + (void)0 #define GET_ES(v1, v2) edgecut_get(eh, v1, v2) #define INT_UV(uvf, c0, c1) interp_v2_v2v2(uvf, mf->uv[c0], mf->uv[c1], 0.5f) @@ -218,8 +218,8 @@ static MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFa static void remap_faces_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -228,14 +228,14 @@ static void remap_faces_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, MFace *mf, df1->v4 = v3; df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = 0; df2->flag &= ~ME_FACE_SEL; - facepa[cur+2] = vertpa[v1]; + facepa[cur + 2] = vertpa[v1]; df3->v1 = v1; df3->v2 = v3; df3->v3 = v4; @@ -248,9 +248,9 @@ static void remap_uvs_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, int numlayer MTFace *mf, *df1, *df2, *df3; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; df3 = df1 + 2; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); @@ -274,7 +274,7 @@ static void remap_uvs_3_6_9_12(DerivedMesh *dm, DerivedMesh *split, int numlayer static void remap_faces_5_10(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -283,7 +283,7 @@ static void remap_faces_5_10(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int df1->v4 = GET_ES(v1, v4); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v3]; + facepa[cur + 1] = vertpa[v3]; df2->v1 = GET_ES(v1, v4); df2->v2 = GET_ES(v2, v3); df2->v3 = v3; @@ -296,9 +296,9 @@ static void remap_uvs_5_10(DerivedMesh *dm, DerivedMesh *split, int numlayer, in MTFace *mf, *df1, *df2; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); mf += i; @@ -319,9 +319,9 @@ static void remap_uvs_5_10(DerivedMesh *dm, DerivedMesh *split, int numlayer, in static void remap_faces_15(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); - MFace *df4 = get_dface(dm, split, cur+3, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); + MFace *df4 = get_dface(dm, split, cur + 3, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -330,21 +330,21 @@ static void remap_faces_15(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int * df1->v4 = GET_ES(v1, v4); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = GET_ES(v1, v3); df2->flag |= ME_FACE_SEL; - facepa[cur+2] = vertpa[v3]; + facepa[cur + 2] = vertpa[v3]; df3->v1 = GET_ES(v1, v3); df3->v2 = GET_ES(v2, v3); df3->v3 = v3; df3->v4 = GET_ES(v3, v4); df3->flag |= ME_FACE_SEL; - facepa[cur+3] = vertpa[v4]; + facepa[cur + 3] = vertpa[v4]; df4->v1 = GET_ES(v1, v4); df4->v2 = GET_ES(v1, v3); df4->v3 = GET_ES(v3, v4); @@ -357,9 +357,9 @@ static void remap_uvs_15(DerivedMesh *dm, DerivedMesh *split, int numlayer, int MTFace *mf, *df1, *df2, *df3, *df4; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; df3 = df1 + 2; df4 = df1 + 3; @@ -391,8 +391,8 @@ static void remap_uvs_15(DerivedMesh *dm, DerivedMesh *split, int numlayer, int static void remap_faces_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3, int v4) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -401,14 +401,14 @@ static void remap_faces_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, MFace *m df1->v4 = GET_ES(v1, v4); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = 0; df2->flag &= ~ME_FACE_SEL; - facepa[cur+2] = vertpa[v4]; + facepa[cur + 2] = vertpa[v4]; df3->v1 = GET_ES(v1, v4); df3->v2 = GET_ES(v2, v3); df3->v3 = v3; @@ -421,9 +421,9 @@ static void remap_uvs_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, int numlay MTFace *mf, *df1, *df2, *df3; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; df3 = df1 + 2; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); @@ -448,7 +448,7 @@ static void remap_uvs_7_11_13_14(DerivedMesh *dm, DerivedMesh *split, int numlay static void remap_faces_19_21_22(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -457,7 +457,7 @@ static void remap_faces_19_21_22(DerivedMesh *dm, DerivedMesh *split, MFace *mf, df1->v4 = 0; df1->flag &= ~ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = v3; @@ -470,9 +470,9 @@ static void remap_uvs_19_21_22(DerivedMesh *dm, DerivedMesh *split, int numlayer MTFace *mf, *df1, *df2; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); mf += i; @@ -491,8 +491,8 @@ static void remap_uvs_19_21_22(DerivedMesh *dm, DerivedMesh *split, int numlayer static void remap_faces_23(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int *facepa, int *vertpa, int i, EdgeHash *eh, int cur, int v1, int v2, int v3) { MFace *df1 = get_dface(dm, split, cur, i, mf); - MFace *df2 = get_dface(dm, split, cur+1, i, mf); - MFace *df3 = get_dface(dm, split, cur+2, i, mf); + MFace *df2 = get_dface(dm, split, cur + 1, i, mf); + MFace *df3 = get_dface(dm, split, cur + 2, i, mf); facepa[cur] = vertpa[v1]; df1->v1 = v1; @@ -501,14 +501,14 @@ static void remap_faces_23(DerivedMesh *dm, DerivedMesh *split, MFace *mf, int * df1->v4 = GET_ES(v1, v3); df1->flag |= ME_FACE_SEL; - facepa[cur+1] = vertpa[v2]; + facepa[cur + 1] = vertpa[v2]; df2->v1 = GET_ES(v1, v2); df2->v2 = v2; df2->v3 = GET_ES(v2, v3); df2->v4 = 0; df2->flag &= ~ME_FACE_SEL; - facepa[cur+2] = vertpa[v3]; + facepa[cur + 2] = vertpa[v3]; df3->v1 = GET_ES(v1, v3); df3->v2 = GET_ES(v2, v3); df3->v3 = v3; @@ -521,9 +521,9 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int MTFace *mf, *df1, *df2; int l; - for (l=0; lfaceData, CD_MTFACE, l); - df1 = mf+cur; + df1 = mf + cur; df2 = df1 + 1; mf = CustomData_get_layer_n(&dm->faceData, CD_MTFACE, l); mf += i; @@ -543,63 +543,63 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int } } -static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) +static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) { DerivedMesh *splitdm; - MFace *mf=NULL, *df1=NULL; - MFace *mface=dm->getTessFaceArray(dm); + MFace *mf = NULL, *df1 = NULL; + MFace *mface = dm->getTessFaceArray(dm); MVert *dupve, *mv; EdgeHash *edgehash; EdgeHashIterator *ehi; - int totvert=dm->getNumVerts(dm); - int totface=dm->getNumTessFaces(dm); + int totvert = dm->getNumVerts(dm); + int totface = dm->getNumTessFaces(dm); - int *facesplit = MEM_callocN(sizeof(int)*totface, "explode_facesplit"); - int *vertpa = MEM_callocN(sizeof(int)*totvert, "explode_vertpa2"); + int *facesplit = MEM_callocN(sizeof(int) * totface, "explode_facesplit"); + int *vertpa = MEM_callocN(sizeof(int) * totvert, "explode_vertpa2"); int *facepa = emd->facepa; - int *fs, totesplit=0, totfsplit=0, curdupface=0; + int *fs, totesplit = 0, totfsplit = 0, curdupface = 0; int i, v1, v2, v3, v4, esplit, v[4] = {0, 0, 0, 0}, /* To quite gcc barking... */ uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */ int numlayer; unsigned int ed_v1, ed_v2; - edgehash= BLI_edgehash_new(); + edgehash = BLI_edgehash_new(); /* recreate vertpa from facepa calculation */ - for (i=0, mf=mface; iv1]=facepa[i]; - vertpa[mf->v2]=facepa[i]; - vertpa[mf->v3]=facepa[i]; + for (i = 0, mf = mface; i < totface; i++, mf++) { + vertpa[mf->v1] = facepa[i]; + vertpa[mf->v2] = facepa[i]; + vertpa[mf->v3] = facepa[i]; if (mf->v4) - vertpa[mf->v4]=facepa[i]; + vertpa[mf->v4] = facepa[i]; } /* mark edges for splitting and how to split faces */ - for (i=0, mf=mface, fs=facesplit; iv1]; - v2=vertpa[mf->v2]; - v3=vertpa[mf->v3]; + for (i = 0, mf = mface, fs = facesplit; i < totface; i++, mf++, fs++) { + v1 = vertpa[mf->v1]; + v2 = vertpa[mf->v2]; + v3 = vertpa[mf->v3]; - if (v1!=v2) { + if (v1 != v2) { BLI_edgehash_insert(edgehash, mf->v1, mf->v2, NULL); (*fs) |= 1; } - if (v2!=v3) { + if (v2 != v3) { BLI_edgehash_insert(edgehash, mf->v2, mf->v3, NULL); (*fs) |= 2; } if (mf->v4) { - v4=vertpa[mf->v4]; + v4 = vertpa[mf->v4]; - if (v3!=v4) { + if (v3 != v4) { BLI_edgehash_insert(edgehash, mf->v3, mf->v4, NULL); (*fs) |= 4; } - if (v1!=v4) { + if (v1 != v4) { BLI_edgehash_insert(edgehash, mf->v1, mf->v4, NULL); (*fs) |= 8; } @@ -611,7 +611,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) else { (*fs) |= 16; /* mark face as tri */ - if (v1!=v3) { + if (v1 != v3) { BLI_edgehash_insert(edgehash, mf->v1, mf->v3, NULL); (*fs) |= 4; } @@ -619,8 +619,8 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) } /* count splits & create indexes for new verts */ - ehi= BLI_edgehashIterator_new(edgehash); - totesplit=totvert; + ehi = BLI_edgehashIterator_new(edgehash); + totesplit = totvert; for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totesplit)); totesplit++; @@ -628,14 +628,14 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) BLI_edgehashIterator_free(ehi); /* count new faces due to splitting */ - for (i=0, fs=facesplit; ifaceData, CD_MTFACE); /* copy new faces & verts (is it really this painful with custom data??) */ - for (i=0; igetVert(dm, i, &source); @@ -651,23 +651,23 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) * later interpreted as tri's, for this to work right I think we probably * have to stop using tessface - campbell */ - facepa= MEM_callocN(sizeof(int)*(totface+(totfsplit * 2)), "explode_facepa"); + facepa = MEM_callocN(sizeof(int) * (totface + (totfsplit * 2)), "explode_facepa"); //memcpy(facepa, emd->facepa, totface*sizeof(int)); - emd->facepa=facepa; + emd->facepa = facepa; /* create new verts */ - ehi= BLI_edgehashIterator_new(edgehash); + ehi = BLI_edgehashIterator_new(edgehash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2); - esplit= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); - mv=CDDM_get_vert(splitdm, ed_v2); - dupve=CDDM_get_vert(splitdm, esplit); + esplit = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); + mv = CDDM_get_vert(splitdm, ed_v2); + dupve = CDDM_get_vert(splitdm, esplit); DM_copy_vert_data(splitdm, splitdm, ed_v2, esplit, 1); - *dupve=*mv; + *dupve = *mv; - mv=CDDM_get_vert(splitdm, ed_v1); + mv = CDDM_get_vert(splitdm, ed_v1); add_v3_v3(dupve->co, mv->co); mul_v3_fl(dupve->co, 0.5f); @@ -675,99 +675,99 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) BLI_edgehashIterator_free(ehi); /* create new faces */ - curdupface=0;//=totface; + curdupface = 0; //=totface; //curdupin=totesplit; - for (i=0, fs=facesplit; igetTessFaceData(dm, i, CD_MFACE); switch (*fs) { - case 3: - case 10: - case 11: - case 15: - SET_VERTS(1, 2, 3, 4); - break; - case 5: - case 6: - case 7: - SET_VERTS(2, 3, 4, 1); - break; - case 9: - case 13: - SET_VERTS(4, 1, 2, 3); - break; - case 12: - case 14: - SET_VERTS(3, 4, 1, 2); - break; - case 21: - case 23: - SET_VERTS(1, 2, 3, 4); - break; - case 19: - SET_VERTS(2, 3, 1, 4); - break; - case 22: - SET_VERTS(3, 1, 2, 4); - break; + case 3: + case 10: + case 11: + case 15: + SET_VERTS(1, 2, 3, 4); + break; + case 5: + case 6: + case 7: + SET_VERTS(2, 3, 4, 1); + break; + case 9: + case 13: + SET_VERTS(4, 1, 2, 3); + break; + case 12: + case 14: + SET_VERTS(3, 4, 1, 2); + break; + case 21: + case 23: + SET_VERTS(1, 2, 3, 4); + break; + case 19: + SET_VERTS(2, 3, 1, 4); + break; + case 22: + SET_VERTS(3, 1, 2, 4); + break; } switch (*fs) { - case 3: - case 6: - case 9: - case 12: - remap_faces_3_6_9_12(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_3_6_9_12(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 5: - case 10: - remap_faces_5_10(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_5_10(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 15: - remap_faces_15(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_15(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 7: - case 11: - case 13: - case 14: - remap_faces_7_11_13_14(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); - if (numlayer) - remap_uvs_7_11_13_14(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); - break; - case 19: - case 21: - case 22: - remap_faces_19_21_22(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); - if (numlayer) - remap_uvs_19_21_22(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); - break; - case 23: - remap_faces_23(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); - if (numlayer) - remap_uvs_23(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); - break; - case 0: - case 16: - df1 = get_dface(dm, splitdm, curdupface, i, mf); - facepa[curdupface] = vertpa[mf->v1]; + case 3: + case 6: + case 9: + case 12: + remap_faces_3_6_9_12(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_3_6_9_12(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 5: + case 10: + remap_faces_5_10(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_5_10(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 15: + remap_faces_15(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_15(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 7: + case 11: + case 13: + case 14: + remap_faces_7_11_13_14(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2], v[3]); + if (numlayer) + remap_uvs_7_11_13_14(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2], uv[3]); + break; + case 19: + case 21: + case 22: + remap_faces_19_21_22(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); + if (numlayer) + remap_uvs_19_21_22(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); + break; + case 23: + remap_faces_23(dm, splitdm, mf, facepa, vertpa, i, edgehash, curdupface, v[0], v[1], v[2]); + if (numlayer) + remap_uvs_23(dm, splitdm, numlayer, i, curdupface, uv[0], uv[1], uv[2]); + break; + case 0: + case 16: + df1 = get_dface(dm, splitdm, curdupface, i, mf); + facepa[curdupface] = vertpa[mf->v1]; - if (df1->v4) - df1->flag |= ME_FACE_SEL; - else - df1->flag &= ~ME_FACE_SEL; - break; + if (df1->v4) + df1->flag |= ME_FACE_SEL; + else + df1->flag &= ~ME_FACE_SEL; + break; } - curdupface += add_faces[*fs]+1; + curdupface += add_faces[*fs] + 1; } - for (i=0; ifaceData, i, (mf->flag & ME_FACE_SEL ? 4 : 3)); } @@ -781,46 +781,46 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm) return splitdm; } -static DerivedMesh * explodeMesh(ExplodeModifierData *emd, - ParticleSystemModifierData *psmd, Scene *scene, Object *ob, - DerivedMesh *to_explode) +static DerivedMesh *explodeMesh(ExplodeModifierData *emd, + ParticleSystemModifierData *psmd, Scene *scene, Object *ob, + DerivedMesh *to_explode) { - DerivedMesh *explode, *dm=to_explode; - MFace *mf= NULL, *mface; + DerivedMesh *explode, *dm = to_explode; + MFace *mf = NULL, *mface; /* ParticleSettings *part=psmd->psys->part; */ /* UNUSED */ - ParticleSimulationData sim= {NULL}; - ParticleData *pa=NULL, *pars=psmd->psys->particles; + ParticleSimulationData sim = {NULL}; + ParticleData *pa = NULL, *pars = psmd->psys->particles; ParticleKey state, birth; EdgeHash *vertpahash; EdgeHashIterator *ehi; - float *vertco= NULL, imat[4][4]; + float *vertco = NULL, imat[4][4]; float rot[4]; float cfra; /* float timestep; */ - int *facepa=emd->facepa; - int totdup=0, totvert=0, totface=0, totpart=0, delface=0; + int *facepa = emd->facepa; + int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0; int i, v, u; - unsigned int ed_v1, ed_v2, mindex=0; + unsigned int ed_v1, ed_v2, mindex = 0; MTFace *mtface = NULL, *mtf; - totface= dm->getNumTessFaces(dm); - totvert= dm->getNumVerts(dm); - mface= dm->getTessFaceArray(dm); - totpart= psmd->psys->totpart; + totface = dm->getNumTessFaces(dm); + totvert = dm->getNumVerts(dm); + mface = dm->getTessFaceArray(dm); + totpart = psmd->psys->totpart; - sim.scene= scene; - sim.ob= ob; - sim.psys= psmd->psys; - sim.psmd= psmd; + sim.scene = scene; + sim.ob = ob; + sim.psys = psmd->psys; + sim.psmd = psmd; /* timestep= psys_get_timestep(&sim); */ - cfra= BKE_curframe(scene); + cfra = BKE_scene_frame_get(scene); /* hash table for vertice <-> particle relations */ - vertpahash= BLI_edgehash_new(); + vertpahash = BLI_edgehash_new(); - for (i=0; itime) - mindex = totvert+totpart; + if (facepa[i] == totpart || cfra < (pars + facepa[i])->time) + mindex = totvert + totpart; else - mindex = totvert+facepa[i]; + mindex = totvert + facepa[i]; - mf= &mface[i]; + mf = &mface[i]; /* set face vertices to exist in particle group */ BLI_edgehash_insert(vertpahash, mf->v1, mindex, NULL); @@ -851,7 +851,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, } /* make new vertice indexes & count total vertices after duplication */ - ehi= BLI_edgehashIterator_new(vertpahash); + ehi = BLI_edgehashIterator_new(vertpahash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { BLI_edgehashIterator_setValue(ehi, SET_INT_IN_POINTER(totdup)); totdup++; @@ -859,7 +859,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, BLI_edgehashIterator_free(ehi); /* the final duplicated vertices */ - explode= CDDM_from_template(dm, totdup, 0, totface-delface, 0, 0); + explode = CDDM_from_template(dm, totdup, 0, totface - delface, 0, 0); mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname); /*dupvert= CDDM_get_verts(explode);*/ @@ -869,7 +869,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, psmd->psys->lattice = psys_get_lattice(&sim); /* duplicate & displace vertices */ - ehi= BLI_edgehashIterator_new(vertpahash); + ehi = BLI_edgehashIterator_new(vertpahash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { MVert source; MVert *dest; @@ -877,7 +877,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* get particle + vertex from hash */ BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2); ed_v2 -= totvert; - v= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); + v = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); dm->getVert(dm, ed_v1, &source); dest = CDDM_get_vert(explode, v); @@ -887,14 +887,14 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, if (ed_v2 != totpart) { /* get particle */ - pa= pars + ed_v2; + pa = pars + ed_v2; psys_get_birth_coordinates(&sim, pa, &birth, 0, 0); - state.time=cfra; + state.time = cfra; psys_get_particle_state(&sim, ed_v2, &state, 1); - vertco=CDDM_get_vert(explode, v)->co; + vertco = CDDM_get_vert(explode, v)->co; mul_m4_v3(ob->obmat, vertco); sub_v3_v3(vertco, birth.co); @@ -914,27 +914,27 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, BLI_edgehashIterator_free(ehi); /*map new vertices to faces*/ - for (i=0, u=0; ialive==PARS_UNBORN && (emd->flag&eExplodeFlag_Unborn)==0) continue; - if (pa->alive==PARS_ALIVE && (emd->flag&eExplodeFlag_Alive)==0) continue; - if (pa->alive==PARS_DEAD && (emd->flag&eExplodeFlag_Dead)==0) continue; + if (pa->alive == PARS_UNBORN && (emd->flag & eExplodeFlag_Unborn) == 0) continue; + if (pa->alive == PARS_ALIVE && (emd->flag & eExplodeFlag_Alive) == 0) continue; + if (pa->alive == PARS_DEAD && (emd->flag & eExplodeFlag_Dead) == 0) continue; } dm->getTessFace(dm, i, &source); - mf=CDDM_get_tessface(explode, u); + mf = CDDM_get_tessface(explode, u); orig_v4 = source.v4; - if (facepa[i]!=totpart && cfra < pa->time) - mindex = totvert+totpart; + if (facepa[i] != totpart && cfra < pa->time) + mindex = totvert + totpart; else - mindex = totvert+facepa[i]; + mindex = totvert + facepa[i]; source.v1 = edgecut_get(vertpahash, source.v1, mindex); source.v2 = edgecut_get(vertpahash, source.v2, mindex); @@ -948,7 +948,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, /* override uv channel for particle age */ if (mtface) { - float age = (cfra - pa->time)/pa->lifetime; + float age = (cfra - pa->time) / pa->lifetime; /* Clamp to this range to avoid flipping to the other side of the coordinates. */ CLAMP(age, 0.001f, 0.999f); @@ -972,45 +972,44 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd, if (psmd->psys->lattice) { end_latt_deform(psmd->psys->lattice); - psmd->psys->lattice= NULL; + psmd->psys->lattice = NULL; } return explode; } -static ParticleSystemModifierData * findPrecedingParticlesystem(Object *ob, ModifierData *emd) +static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, ModifierData *emd) { ModifierData *md; - ParticleSystemModifierData *psmd= NULL; + ParticleSystemModifierData *psmd = NULL; - for (md=ob->modifiers.first; emd!=md; md=md->next) { - if (md->type==eModifierType_ParticleSystem) - psmd= (ParticleSystemModifierData*) md; + for (md = ob->modifiers.first; emd != md; md = md->next) { + if (md->type == eModifierType_ParticleSystem) + psmd = (ParticleSystemModifierData *) md; } return psmd; } -static DerivedMesh * applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) +static DerivedMesh *applyModifier(ModifierData *md, Object *ob, + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = derivedData; - ExplodeModifierData *emd= (ExplodeModifierData*) md; - ParticleSystemModifierData *psmd=findPrecedingParticlesystem(ob, md); + ExplodeModifierData *emd = (ExplodeModifierData *) md; + ParticleSystemModifierData *psmd = findPrecedingParticlesystem(ob, md); DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ if (psmd) { - ParticleSystem * psys=psmd->psys; + ParticleSystem *psys = psmd->psys; - if (psys==NULL || psys->totpart==0) return derivedData; - if (psys->part==NULL || psys->particles==NULL) return derivedData; - if (psmd->dm==NULL) return derivedData; + if (psys == NULL || psys->totpart == 0) return derivedData; + if (psys->part == NULL || psys->particles == NULL) return derivedData; + if (psmd->dm == NULL) return derivedData; /* 1. find faces to be exploded if needed */ if (emd->facepa == NULL || - psmd->flag&eParticleSystemFlag_Pars || - emd->flag&eExplodeFlag_CalcFaces || + psmd->flag & eParticleSystemFlag_Pars || + emd->flag & eExplodeFlag_CalcFaces || MEM_allocN_len(emd->facepa) / sizeof(int) != dm->getNumTessFaces(dm)) { if (psmd->flag & eParticleSystemFlag_Pars) @@ -1028,7 +1027,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, DerivedMesh *explode = explodeMesh(emd, psmd, md->scene, ob, splitdm); MEM_freeN(emd->facepa); - emd->facepa=facepa; + emd->facepa = facepa; splitdm->release(splitdm); return explode; } @@ -1040,26 +1039,26 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, ModifierTypeInfo modifierType_Explode = { - /* name */ "Explode", - /* structName */ "ExplodeModifierData", - /* structSize */ sizeof(ExplodeModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ NULL, - /* updateDepgraph */ NULL, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Explode", + /* structName */ "ExplodeModifierData", + /* structSize */ sizeof(ExplodeModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ NULL, + /* updateDepgraph */ NULL, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index 55182578938..694f4f174e8 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -52,21 +52,21 @@ /* Fluidsim */ static void initData(ModifierData *md) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; fluidsim_init(fluidmd); } static void freeData(ModifierData *md) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; fluidsim_free(fluidmd); } static void copyData(ModifierData *md, ModifierData *target) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; - FluidsimModifierData *tfluidmd= (FluidsimModifierData*) target; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; + FluidsimModifierData *tfluidmd = (FluidsimModifierData *) target; if (tfluidmd->fss) MEM_freeN(tfluidmd->fss); @@ -77,11 +77,10 @@ static void copyData(ModifierData *md, ModifierData *target) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int useRenderParams, - int isFinalCalc) + DerivedMesh *dm, + ModifierApplyFlag flag) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; DerivedMesh *result = NULL; /* check for alloc failing */ @@ -93,29 +92,30 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } - result= fluidsimModifier_do(fluidmd, md->scene, ob, dm, useRenderParams, isFinalCalc); + result = fluidsimModifier_do(fluidmd, md->scene, ob, dm, flag & MOD_APPLY_RENDER, flag & MOD_APPLY_USECACHE); return result ? result : dm; } static void updateDepgraph( - ModifierData *md, DagForest *forest, Scene *scene, - Object *ob, DagNode *obNode) + ModifierData *md, DagForest *forest, Scene *scene, + Object *ob, DagNode *obNode) { - FluidsimModifierData *fluidmd= (FluidsimModifierData*) md; + FluidsimModifierData *fluidmd = (FluidsimModifierData *) md; Base *base; if (fluidmd && fluidmd->fss) { if (fluidmd->fss->type == OB_FLUIDSIM_DOMAIN) { - for (base = scene->base.first; base; base= base->next) { - Object *ob1= base->object; + for (base = scene->base.first; base; base = base->next) { + Object *ob1 = base->object; if (ob1 != ob) { - FluidsimModifierData *fluidmdtmp = (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim); + FluidsimModifierData *fluidmdtmp = + (FluidsimModifierData *)modifiers_findByType(ob1, eModifierType_Fluidsim); /* only put dependencies from NON-DOMAIN fluids in here */ - if (fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type!=OB_FLUIDSIM_DOMAIN)) { + if (fluidmdtmp && fluidmdtmp->fss && (fluidmdtmp->fss->type != OB_FLUIDSIM_DOMAIN)) { DagNode *curNode = dag_get_node(forest, ob1); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Fluidsim Object"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Fluidsim Object"); } } } @@ -135,9 +135,9 @@ ModifierTypeInfo modifierType_Fluidsim = { /* structSize */ sizeof(FluidsimModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_RequiresOriginalData - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_RequiresOriginalData | + eModifierTypeFlag_Single, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_fluidsim_util.c b/source/blender/modifiers/intern/MOD_fluidsim_util.c index 80c48062635..a33d80bcd35 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim_util.c +++ b/source/blender/modifiers/intern/MOD_fluidsim_util.c @@ -177,7 +177,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam float no[3]; const short mp_mat_nr = mp_example->mat_nr; - const char mp_flag = mp_example->flag; + const char mp_flag = mp_example->flag; // ------------------------------------------------ // get numverts + numfaces first @@ -231,7 +231,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam // read vertex position from file mv = CDDM_get_verts(dm); - for (i=0; ico, sizeof(float) * 3); // should be the same as numverts @@ -243,7 +243,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam return NULL; } - normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals" ); + normals = MEM_callocN(sizeof(short) * numverts * 3, "fluid_tmp_normals"); if (!normals) { if (dm) dm->release(dm); @@ -252,7 +252,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam } // read normals from file (but don't save them yet) - for (i=numverts, no_s= normals; i>0; i--, no_s += 3) { + for (i = numverts, no_s = normals; i > 0; i--, no_s += 3) { gotBytes = gzread(gzf, no, sizeof(float) * 3); normal_float_to_short_v3(no_s, no); } @@ -260,7 +260,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam /* read no. of triangles */ gotBytes = gzread(gzf, &wri, sizeof(wri)); - if (wri!=numfaces) { + if (wri != numfaces) { printf("Fluidsim: error in reading data from file.\n"); if (dm) dm->release(dm); @@ -272,7 +272,7 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam // read triangles from file mp = CDDM_get_polys(dm); ml = CDDM_get_loops(dm); - for (i=0; i < numfaces; i++, mp++, ml += 3) { + for (i = 0; i < numfaces; i++, mp++, ml += 3) { int face[3]; gotBytes = gzread(gzf, face, sizeof(int) * 3); @@ -303,10 +303,10 @@ static DerivedMesh *fluidsim_read_obj(const char *filename, const MPoly *mp_exam void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], - /*RET*/ float start[3], /*RET*/ float size[3] ) + /*RET*/ float start[3], /*RET*/ float size[3]) { - float bbsx=0.0, bbsy=0.0, bbsz=0.0; - float bbex=1.0, bbey=1.0, bbez=1.0; + float bbsx = 0.0, bbsy = 0.0, bbsz = 0.0; + float bbex = 1.0, bbey = 1.0, bbez = 1.0; int i; float vec[3]; @@ -325,12 +325,12 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], copy_v3_v3(vec, mvert[i].co); mul_m4_v3(obmat, vec); - if (vec[0] < bbsx) { bbsx= vec[0]; } - if (vec[1] < bbsy) { bbsy= vec[1]; } - if (vec[2] < bbsz) { bbsz= vec[2]; } - if (vec[0] > bbex) { bbex= vec[0]; } - if (vec[1] > bbey) { bbey= vec[1]; } - if (vec[2] > bbez) { bbez= vec[2]; } + if (vec[0] < bbsx) { bbsx = vec[0]; } + if (vec[1] < bbsy) { bbsy = vec[1]; } + if (vec[2] < bbsz) { bbsz = vec[2]; } + if (vec[0] > bbex) { bbex = vec[0]; } + if (vec[1] > bbey) { bbey = vec[1]; } + if (vec[2] > bbez) { bbez = vec[2]; } } // return values... @@ -340,9 +340,9 @@ void fluid_get_bb(MVert *mvert, int totvert, float obmat[][4], start[2] = bbsz; } if (size) { - size[0] = bbex-bbsx; - size[1] = bbey-bbsy; - size[2] = bbez-bbsz; + size[0] = bbex - bbsx; + size[1] = bbey - bbsy; + size[2] = bbez - bbsz; } } @@ -354,11 +354,11 @@ void fluid_estimate_memory(Object *ob, FluidsimSettings *fss, char *value) { Mesh *mesh; - value[0]= '\0'; + value[0] = '\0'; if (ob->type == OB_MESH) { /* use mesh bounding box and object scaling */ - mesh= ob->data; + mesh = ob->data; fluid_get_bb(mesh->mvert, mesh->totvert, ob->obmat, fss->bbStart, fss->bbSize); elbeemEstimateMemreq(fss->resolutionxyz, fss->bbSize[0], fss->bbSize[1], fss->bbSize[2], fss->maxRefine, value); @@ -386,18 +386,18 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * return; } - if (fss->domainNovecgen>0) return; + if (fss->domainNovecgen > 0) return; - fss->meshVelocities = MEM_callocN(sizeof(FluidVertexVelocity)*dm->getNumVerts(dm), "Fluidsim_velocities"); + fss->meshVelocities = MEM_callocN(sizeof(FluidVertexVelocity) * dm->getNumVerts(dm), "Fluidsim_velocities"); fss->totvert = totvert; velarray = fss->meshVelocities; // .bobj.gz, correct filename // 87654321 - filename[len-6] = 'v'; - filename[len-5] = 'e'; - filename[len-4] = 'l'; + filename[len - 6] = 'v'; + filename[len - 5] = 'e'; + filename[len - 4] = 'l'; gzf = BLI_gzopen(filename, "rb"); if (!gzf) { @@ -413,8 +413,8 @@ static void fluidsim_read_vel_cache(FluidsimModifierData *fluidmd, DerivedMesh * return; } - for (i=0; ir.sfra*/; /* start with 0 at start frame */ @@ -441,17 +442,17 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim } switch (displaymode) { - case 1: - /* just display original object */ - return NULL; - case 2: - /* use preview mesh */ - BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME); - break; - default: /* 3 */ - /* 3. use final mesh */ - BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); - break; + case 1: + /* just display original object */ + return NULL; + case 2: + /* use preview mesh */ + BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_PREVIEW_OBJ_FNAME); + break; + default: /* 3 */ + /* 3. use final mesh */ + BLI_join_dirfile(targetFile, sizeof(targetFile), fss->surfdataPath, OB_FLUIDSIM_SURF_FINAL_OBJ_FNAME); + break; } /* offset baked frame */ @@ -474,11 +475,12 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim // switch, abort background rendering when fluidsim mesh is missing const char *strEnvName2 = "BLENDER_ELBEEMBOBJABORT"; // from blendercall.cpp - if (G.background==1) { + if (G.background == 1) { if (getenv(strEnvName2)) { int elevel = atoi(getenv(strEnvName2)); - if (elevel>0) { - printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n", strEnvName2, targetFile); + if (elevel > 0) { + printf("Env. var %s set, fluid sim mesh '%s' not found, aborting render...\n", + strEnvName2, targetFile); exit(1); } } @@ -491,7 +493,7 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim // load vertex velocities, if they exist... // TODO? use generate flag as loading flag as well? // warning, needs original .bobj.gz mesh loading filename - if (displaymode==3) { + if (displaymode == 3) { fluidsim_read_vel_cache(fluidmd, dm, targetFile); } else { @@ -506,16 +508,16 @@ static DerivedMesh *fluidsim_read_cache(Object *ob, DerivedMesh *orgdm, Fluidsim #endif // WITH_MOD_FLUID DerivedMesh *fluidsimModifier_do(FluidsimModifierData *fluidmd, Scene *scene, - Object *ob, - DerivedMesh *dm, - int useRenderParams, int UNUSED(isFinalCalc)) + Object *ob, + DerivedMesh *dm, + int useRenderParams, int UNUSED(isFinalCalc)) { #ifdef WITH_MOD_FLUID DerivedMesh *result = NULL; int framenr; FluidsimSettings *fss = NULL; - framenr= (int)scene->r.cfra; + framenr = (int)scene->r.cfra; // only handle fluidsim domains if (fluidmd && fluidmd->fss && (fluidmd->fss->type != OB_FLUIDSIM_DOMAIN)) diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index ef3a6d8217e..19b6bc4a520 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -54,15 +54,15 @@ static void initData(ModifierData *md) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; - hmd->force= 1.0; + hmd->force = 1.0; } static void copyData(ModifierData *md, ModifierData *target) { - HookModifierData *hmd = (HookModifierData*) md; - HookModifierData *thmd = (HookModifierData*) target; + HookModifierData *hmd = (HookModifierData *) md; + HookModifierData *thmd = (HookModifierData *) target; copy_v3_v3(thmd->cent, hmd->cent); thmd->falloff = hmd->falloff; @@ -89,34 +89,34 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static void freeData(ModifierData *md) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; if (hmd->indexar) MEM_freeN(hmd->indexar); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; return !hmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; walk(userData, ob, &hmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; if (hmd->object) { DagNode *curNode = dag_get_node(forest, hmd->object); @@ -146,10 +146,10 @@ static float hook_falloff(const float co_1[3], const float co_2[3], const float static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, float (*vertexCos)[3], int numVerts) { - bPoseChannel *pchan= get_pose_channel(hmd->object->pose, hmd->subtarget); + bPoseChannel *pchan = BKE_pose_channel_find_name(hmd->object->pose, hmd->subtarget); float vec[3], mat[4][4], dmat[4][4]; int i, *index_pt; - const float falloff_squared= hmd->falloff * hmd->falloff; /* for faster comparisons */ + const float falloff_squared = hmd->falloff * hmd->falloff; /* for faster comparisons */ MDeformVert *dvert; int defgrp_index, max_dvert; @@ -168,7 +168,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, NULL, NULL, NULL, NULL, NULL); modifier_get_vgroup(ob, dm, hmd->name, &dvert, &defgrp_index); - max_dvert = (dvert)? numVerts: 0; + max_dvert = (dvert) ? numVerts : 0; /* Regarding index range checking below. * @@ -182,13 +182,13 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, /* do nothing, avoid annoying checks in the loop */ } else if (hmd->indexar) { /* vertex indices? */ - const float fac_orig= hmd->force; + const float fac_orig = hmd->force; float fac; const int *origindex_ar; /* if DerivedMesh is present and has original index data, use it */ - if (dm && (origindex_ar= dm->getVertDataArray(dm, CD_ORIGINDEX))) { - for (i= 0, index_pt= hmd->indexar; i < hmd->totindex; i++, index_pt++) { + if (dm && (origindex_ar = dm->getVertDataArray(dm, CD_ORIGINDEX))) { + for (i = 0, index_pt = hmd->indexar; i < hmd->totindex; i++, index_pt++) { if (*index_pt < numVerts) { int j; @@ -226,7 +226,7 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, } } } - else if (dvert) { /* vertex group hook */ + else if (dvert) { /* vertex group hook */ const float fac_orig = hmd->force; for (i = 0; i < max_dvert; i++, dvert++) { @@ -246,9 +246,9 @@ static void deformVerts_do(HookModifierData *hmd, Object *ob, DerivedMesh *dm, static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts, - int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; DerivedMesh *dm = derivedData; /* We need a valid dm for meshes when a vgroup is set... */ if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0') @@ -263,7 +263,7 @@ static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - HookModifierData *hmd = (HookModifierData*) md; + HookModifierData *hmd = (HookModifierData *) md; DerivedMesh *dm = derivedData; /* We need a valid dm for meshes when a vgroup is set... */ if (!dm && ob->type == OB_MESH && hmd->name[0] != '\0') @@ -281,8 +281,8 @@ ModifierTypeInfo modifierType_Hook = { /* structName */ "HookModifierData", /* structSize */ sizeof(HookModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index ca700d4d8f2..2c05b164d86 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -50,14 +50,14 @@ static void initData(ModifierData *md) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; lmd->strength = 1.0f; } static void copyData(ModifierData *md, ModifierData *target) { - LatticeModifierData *lmd = (LatticeModifierData*) md; - LatticeModifierData *tlmd = (LatticeModifierData*) target; + LatticeModifierData *lmd = (LatticeModifierData *) md; + LatticeModifierData *tlmd = (LatticeModifierData *) target; tlmd->object = lmd->object; BLI_strncpy(tlmd->name, lmd->name, sizeof(tlmd->name)); @@ -76,27 +76,27 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; return !lmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; walk(userData, ob, &lmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; if (lmd->object) { DagNode *latNode = dag_get_node(forest, lmd->object); @@ -107,13 +107,12 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - LatticeModifierData *lmd = (LatticeModifierData*) md; + LatticeModifierData *lmd = (LatticeModifierData *) md; modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -123,14 +122,14 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); - deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); + deformVerts(md, ob, dm, vertexCos, numVerts, 0); if (!derivedData) dm->release(dm); } @@ -141,8 +140,8 @@ ModifierTypeInfo modifierType_Lattice = { /* structName */ "LatticeModifierData", /* structSize */ sizeof(LatticeModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 9faca7bddc5..396e48df50c 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -45,7 +45,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_types.h" -#include "BKE_action.h" /* get_pose_channel */ +#include "BKE_action.h" /* BKE_pose_channel_find_name */ #include "BKE_cdderivedmesh.h" #include "BKE_mesh.h" #include "BKE_modifier.h" @@ -57,8 +57,8 @@ static void copyData(ModifierData *md, ModifierData *target) { - MaskModifierData *mmd = (MaskModifierData*) md; - MaskModifierData *tmmd = (MaskModifierData*) target; + MaskModifierData *mmd = (MaskModifierData *) md; + MaskModifierData *tmmd = (MaskModifierData *) target; BLI_strncpy(tmmd->vgroup, mmd->vgroup, sizeof(tmmd->vgroup)); tmmd->flag = mmd->flag; @@ -70,18 +70,18 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { MaskModifierData *mmd = (MaskModifierData *)md; walk(userData, ob, &mmd->ob_arm); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { MaskModifierData *mmd = (MaskModifierData *)md; @@ -93,16 +93,15 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { - MaskModifierData *mmd= (MaskModifierData *)md; - DerivedMesh *dm= derivedData, *result= NULL; - GHash *vertHash=NULL, *edgeHash, *polyHash; + MaskModifierData *mmd = (MaskModifierData *)md; + DerivedMesh *dm = derivedData, *result = NULL; + GHash *vertHash = NULL, *edgeHash, *polyHash; GHashIterator *hashIter; - MDeformVert *dvert= NULL, *dv; - int numPolys=0, numLoops=0, numEdges=0, numVerts=0; + MDeformVert *dvert = NULL, *dv; + int numPolys = 0, numLoops = 0, numEdges = 0, numVerts = 0; int maxVerts, maxEdges, maxPolys; int i; @@ -124,15 +123,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, */ /* get original number of verts, edges, and faces */ - maxVerts= dm->getNumVerts(dm); - maxEdges= dm->getNumEdges(dm); - maxPolys= dm->getNumPolys(dm); + maxVerts = dm->getNumVerts(dm); + maxEdges = dm->getNumEdges(dm); + maxPolys = dm->getNumPolys(dm); /* check if we can just return the original mesh * - must have verts and therefore verts assigned to vgroups to do anything useful */ - if ( !(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) || - (maxVerts == 0) || (ob->defbase.first == NULL) ) + if (!(ELEM(mmd->mode, MOD_MASK_MODE_ARM, MOD_MASK_MODE_VGROUP)) || + (maxVerts == 0) || (ob->defbase.first == NULL) ) { return derivedData; } @@ -140,35 +139,35 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* if mode is to use selected armature bones, aggregate the bone groups */ if (mmd->mode == MOD_MASK_MODE_ARM) { /* --- using selected bones --- */ GHash *vgroupHash; - Object *oba= mmd->ob_arm; + Object *oba = mmd->ob_arm; bPoseChannel *pchan; bDeformGroup *def; char *bone_select_array; - int bone_select_tot= 0; - const int defbase_tot= BLI_countlist(&ob->defbase); + int bone_select_tot = 0; + const int defbase_tot = BLI_countlist(&ob->defbase); /* check that there is armature object with bones to use, otherwise return original mesh */ if (ELEM3(NULL, mmd->ob_arm, mmd->ob_arm->pose, ob->defbase.first)) return derivedData; - bone_select_array= MEM_mallocN(defbase_tot * sizeof(char), "mask array"); + bone_select_array = MEM_mallocN(defbase_tot * sizeof(char), "mask array"); for (i = 0, def = ob->defbase.first; def; def = def->next, i++) { - pchan = get_pose_channel(oba->pose, def->name); + pchan = BKE_pose_channel_find_name(oba->pose, def->name); if (pchan && pchan->bone && (pchan->bone->flag & BONE_SELECTED)) { - bone_select_array[i]= TRUE; + bone_select_array[i] = TRUE; bone_select_tot++; } else { - bone_select_array[i]= FALSE; + bone_select_array[i] = FALSE; } } /* hashes for finding mapping of: - * - vgroups to indices -> vgroupHash (string, int) - * - bones to vgroup indices -> boneHash (index of vgroup, dummy) + * - vgroups to indices -> vgroupHash (string, int) + * - bones to vgroup indices -> boneHash (index of vgroup, dummy) */ - vgroupHash= BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); + vgroupHash = BLI_ghash_new(BLI_ghashutil_strhash, BLI_ghashutil_strcmp, "mask vgroup gh"); /* build mapping of names of vertex groups to indices */ for (i = 0, def = ob->defbase.first; def; def = def->next, i++) @@ -183,7 +182,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* repeat the previous check, but for dverts */ - dvert= dm->getVertDataArray(dm, CD_MDEFORMVERT); + dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); if (dvert == NULL) { BLI_ghash_free(vgroupHash, NULL, NULL); MEM_freeN(bone_select_array); @@ -192,14 +191,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); + vertHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert gh"); /* add vertices which exist in vertexgroups into vertHash for filtering */ - for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - MDeformWeight *dw= dv->dw; + for (i = 0, dv = dvert; i < maxVerts; i++, dv++) { + MDeformWeight *dw = dv->dw; int j; - for (j= dv->totweight; j > 0; j--, dw++) { + for (j = dv->totweight; j > 0; j--, dw++) { if (dw->def_nr < defbase_tot) { if (bone_select_array[dw->def_nr]) { if (dw->weight != 0.0f) { @@ -228,7 +227,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, BLI_ghash_free(vgroupHash, NULL, NULL); MEM_freeN(bone_select_array); } - else { /* --- Using Nominated VertexGroup only --- */ + else { /* --- Using Nominated VertexGroup only --- */ int defgrp_index = defgroup_name_index(ob, mmd->vgroup); /* get dverts */ @@ -240,11 +239,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, return dm; /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - vertHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); + vertHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask vert2 bh"); /* add vertices which exist in vertexgroup into ghash for filtering */ - for (i= 0, dv= dvert; i < maxVerts; i++, dv++) { - const int weight_set= defvert_find_weight(dv, defgrp_index) != 0.0f; + for (i = 0, dv = dvert; i < maxVerts; i++, dv++) { + const int weight_set = defvert_find_weight(dv, defgrp_index) != 0.0f; /* check if include vert in vertHash */ if (mmd->flag & MOD_MASK_INV) { @@ -263,8 +262,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } /* hashes for quickly providing a mapping from old to new - use key=oldindex, value=newindex */ - edgeHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask ed2 gh"); - polyHash= BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask fa2 gh"); + edgeHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask ed2 gh"); + polyHash = BLI_ghash_new(BLI_ghashutil_inthash, BLI_ghashutil_intcmp, "mask fa2 gh"); mpoly = dm->getPolyArray(dm); mloop = dm->getLoopArray(dm); diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 1bcafc2918e..12209fd69fb 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -57,14 +57,14 @@ static void initData(ModifierData *md) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; - mmd->gridsize= 5; + mmd->gridsize = 5; } static void freeData(ModifierData *md) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; if (mmd->bindinfluences) MEM_freeN(mmd->bindinfluences); if (mmd->bindoffsets) MEM_freeN(mmd->bindoffsets); @@ -72,14 +72,14 @@ static void freeData(ModifierData *md) if (mmd->dyngrid) MEM_freeN(mmd->dyngrid); if (mmd->dyninfluences) MEM_freeN(mmd->dyninfluences); if (mmd->dynverts) MEM_freeN(mmd->dynverts); - if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ - if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ + if (mmd->bindweights) MEM_freeN(mmd->bindweights); /* deprecated */ + if (mmd->bindcos) MEM_freeN(mmd->bindcos); /* deprecated */ } static void copyData(ModifierData *md, ModifierData *target) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - MeshDeformModifierData *tmmd = (MeshDeformModifierData*) target; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; + MeshDeformModifierData *tmmd = (MeshDeformModifierData *) target; tmmd->gridsize = mmd->gridsize; tmmd->object = mmd->object; @@ -98,34 +98,34 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; return !mmd->object; } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; walk(userData, ob, &mmd->object); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; if (mmd->object) { DagNode *curNode = dag_get_node(forest, mmd->object); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA|DAG_RL_OB_DATA|DAG_RL_DATA_OB|DAG_RL_OB_OB, - "Mesh Deform Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA | DAG_RL_DATA_OB | DAG_RL_OB_OB, + "Mesh Deform Modifier"); } } @@ -138,40 +138,40 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 int i, j, a, x, y, z, size; zero_v3(co); - totweight= 0.0f; - size= mmd->dyngridsize; + totweight = 0.0f; + size = mmd->dyngridsize; - for (i=0; i<3; i++) { - gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth*0.5f)/mmd->dyncellwidth; + for (i = 0; i < 3; i++) { + gridvec[i] = (vec[i] - mmd->dyncellmin[i] - mmd->dyncellwidth * 0.5f) / mmd->dyncellwidth; ivec[i] = (int)gridvec[i]; dvec[i] = gridvec[i] - ivec[i]; } - for (i=0; i<8; i++) { + for (i = 0; i < 8; i++) { if (i & 1) { x = ivec[0] + 1; wx = dvec[0]; } - else { x = ivec[0]; wx = 1.0f - dvec[0]; } + else { x = ivec[0]; wx = 1.0f - dvec[0]; } if (i & 2) { y = ivec[1] + 1; wy = dvec[1]; } - else { y = ivec[1]; wy = 1.0f - dvec[1]; } + else { y = ivec[1]; wy = 1.0f - dvec[1]; } if (i & 4) { z = ivec[2] + 1; wz = dvec[2]; } - else { z = ivec[2]; wz = 1.0f - dvec[2]; } + else { z = ivec[2]; wz = 1.0f - dvec[2]; } CLAMP(x, 0, size - 1); CLAMP(y, 0, size - 1); CLAMP(z, 0, size - 1); - a= x + y*size + z*size*size; - weight= wx*wy*wz; + a = x + y * size + z * size * size; + weight = wx * wy * wz; - cell= &mmd->dyngrid[a]; - inf= mmd->dyninfluences + cell->offset; - for (j=0; jtotinfluence; j++, inf++) { - cageco= dco[inf->vertex]; - cageweight= weight*inf->weight; - co[0] += cageweight*cageco[0]; - co[1] += cageweight*cageco[1]; - co[2] += cageweight*cageco[2]; + cell = &mmd->dyngrid[a]; + inf = mmd->dyninfluences + cell->offset; + for (j = 0; j < cell->totinfluence; j++, inf++) { + cageco = dco[inf->vertex]; + cageweight = weight * inf->weight; + co[0] += cageweight * cageco[0]; + co[1] += cageweight * cageco[1]; + co[2] += cageweight * cageco[2]; totweight += cageweight; } } @@ -182,11 +182,11 @@ static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3 } static void meshdeformModifier_do( - ModifierData *md, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { - MeshDeformModifierData *mmd = (MeshDeformModifierData*) md; - struct Mesh *me= (mmd->object)? mmd->object->data: NULL; + MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; + struct Mesh *me = (mmd->object) ? mmd->object->data : NULL; BMEditMesh *em = me ? me->edit_btmesh : NULL; DerivedMesh *tmpdm, *cagedm; MDeformVert *dvert = NULL; @@ -202,19 +202,19 @@ static void meshdeformModifier_do( /* get cage derivedmesh */ if (em) { - tmpdm= editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0); + tmpdm = editbmesh_get_derived_cage_and_final(md->scene, ob, em, &cagedm, 0); if (tmpdm) tmpdm->release(tmpdm); } else - cagedm= mmd->object->derivedFinal; + cagedm = mmd->object->derivedFinal; /* if we don't have one computed, use derivedmesh from data * without any modifiers */ if (!cagedm) { - cagedm= get_dm(mmd->object, NULL, NULL, NULL, 0); + cagedm = get_dm(mmd->object, NULL, NULL, NULL, 0); if (cagedm) - cagedm->needsFree= 1; + cagedm->needsFree = 1; } if (!cagedm) { @@ -236,14 +236,14 @@ static void meshdeformModifier_do( /* progress bar redraw can make this recursive .. */ if (!recursive) { recursive = 1; - mmd->bindfunc(md->scene, mmd, (float*)vertexCos, numVerts, cagemat); + mmd->bindfunc(md->scene, mmd, (float *)vertexCos, numVerts, cagemat); recursive = 0; } } /* verify we have compatible weights */ - totvert= numVerts; - totcagevert= cagedm->getNumVerts(cagedm); + totvert = numVerts; + totcagevert = cagedm->getNumVerts(cagedm); if (mmd->totvert != totvert) { modifier_setError(md, TIP_("Verts changed from %d to %d."), mmd->totvert, totvert); @@ -261,16 +261,16 @@ static void meshdeformModifier_do( return; } - cagecos= MEM_callocN(sizeof(*cagecos)*totcagevert, "meshdeformModifier vertCos"); + cagecos = MEM_callocN(sizeof(*cagecos) * totcagevert, "meshdeformModifier vertCos"); /* setup deformation data */ cagedm->getVertCos(cagedm, cagecos); - influences= mmd->bindinfluences; - offsets= mmd->bindoffsets; - bindcagecos= (float(*)[3])mmd->bindcagecos; + influences = mmd->bindinfluences; + offsets = mmd->bindoffsets; + bindcagecos = (float(*)[3])mmd->bindcagecos; - dco= MEM_callocN(sizeof(*dco)*totcagevert, "MDefDco"); - for (a=0; adefgrp_name, &dvert, &defgrp_index); /* do deformation */ - fac= 1.0f; + fac = 1.0f; - for (b=0; bflag & MOD_MDEF_DYNAMIC_BIND) if (!mmd->dynverts[b]) continue; if (dvert) { - fac= defvert_find_weight(&dvert[b], defgrp_index); + fac = defvert_find_weight(&dvert[b], defgrp_index); if (mmd->flag & MOD_MDEF_INVERT_VGROUP) { - fac= 1.0f - fac; + fac = 1.0f - fac; } if (fac <= 0.0f) { @@ -308,14 +308,14 @@ static void meshdeformModifier_do( if (mmd->flag & MOD_MDEF_DYNAMIC_BIND) { /* transform coordinate into cage's local space */ mul_v3_m4v3(co, cagemat, vertexCos[b]); - totweight= meshdeform_dynamic_bind(mmd, dco, co); + totweight = meshdeform_dynamic_bind(mmd, dco, co); } else { - totweight= 0.0f; + totweight = 0.0f; zero_v3(co); for (a = offsets[b]; a < offsets[b + 1]; a++) { - weight= influences[a].weight; + weight = influences[a].weight; madd_v3_v3fl(co, dco[influences[a].vertex], weight); totweight += weight; } @@ -338,13 +338,12 @@ static void meshdeformModifier_do( } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - DerivedMesh *dm= get_dm(ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ @@ -355,12 +354,12 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts) { - DerivedMesh *dm= get_dm(ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); meshdeformModifier_do(md, ob, dm, vertexCos, numVerts); @@ -372,21 +371,21 @@ static void deformVertsEM(ModifierData *md, Object *ob, void modifier_mdef_compact_influences(ModifierData *md) { - MeshDeformModifierData *mmd= (MeshDeformModifierData*)md; + MeshDeformModifierData *mmd = (MeshDeformModifierData *)md; float weight, *weights, totweight; int totinfluence, totvert, totcagevert, a, b; - weights= mmd->bindweights; + weights = mmd->bindweights; if (!weights) return; - totvert= mmd->totvert; - totcagevert= mmd->totcagevert; + totvert = mmd->totvert; + totcagevert = mmd->totcagevert; /* count number of influences above threshold */ - for (b=0; b MESHDEFORM_MIN_INFLUENCE) mmd->totinfluence++; @@ -398,23 +397,23 @@ void modifier_mdef_compact_influences(ModifierData *md) mmd->bindoffsets = MEM_callocN(sizeof(int) * (totvert + 1), "MDefBindOffset"); /* write influences */ - totinfluence= 0; + totinfluence = 0; - for (b=0; bbindoffsets[b]= totinfluence; - totweight= 0.0f; + for (b = 0; b < totvert; b++) { + mmd->bindoffsets[b] = totinfluence; + totweight = 0.0f; /* sum total weight */ - for (a=0; a MESHDEFORM_MIN_INFLUENCE) totweight += weight; } /* assign weights normalized */ - for (a=0; a MESHDEFORM_MIN_INFLUENCE) { mmd->bindinfluences[totinfluence].weight = weight / totweight; @@ -424,36 +423,36 @@ void modifier_mdef_compact_influences(ModifierData *md) } } - mmd->bindoffsets[b]= totinfluence; + mmd->bindoffsets[b] = totinfluence; /* free */ MEM_freeN(mmd->bindweights); - mmd->bindweights= NULL; + mmd->bindweights = NULL; } ModifierTypeInfo modifierType_MeshDeform = { - /* name */ "MeshDeform", - /* structName */ "MeshDeformModifierData", - /* structSize */ sizeof(MeshDeformModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* name */ "MeshDeform", + /* structName */ "MeshDeformModifierData", + /* structSize */ sizeof(MeshDeformModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 2df0bd17eaf..5c9c4e76076 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; mmd->flag |= (MOD_MIR_AXIS_X | MOD_MIR_VGROUP); mmd->tolerance = 0.001; @@ -60,8 +60,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - MirrorModifierData *mmd = (MirrorModifierData*) md; - MirrorModifierData *tmmd = (MirrorModifierData*) target; + MirrorModifierData *mmd = (MirrorModifierData *) md; + MirrorModifierData *tmmd = (MirrorModifierData *) target; tmmd->flag = mmd->flag; tmmd->tolerance = mmd->tolerance; @@ -72,7 +72,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; walk(userData, ob, &mmd->mirror_ob); } @@ -82,7 +82,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, Object *UNUSED(ob), DagNode *obNode) { - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; if (mmd->mirror_ob) { DagNode *latNode = dag_get_node(forest, mmd->mirror_ob); @@ -138,7 +138,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, mult_m4_m4m4(mtx, itmp, mtx); } - result = CDDM_from_template(dm, maxVerts*2, maxEdges*2, 0, maxLoops*2, maxPolys*2); + result = CDDM_from_template(dm, maxVerts * 2, maxEdges * 2, 0, maxLoops * 2, maxPolys * 2); /*copy customdata to original geometry*/ DM_copy_vert_data(dm, result, 0, 0, maxVerts); @@ -249,8 +249,8 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, /* handle uvs, * let tessface recalc handle updating the MTFace data */ if (mmd->flag & (MOD_MIR_MIRROR_U | MOD_MIR_MIRROR_V)) { - const int do_mirr_u= (mmd->flag & MOD_MIR_MIRROR_U) != 0; - const int do_mirr_v= (mmd->flag & MOD_MIR_MIRROR_V) != 0; + const int do_mirr_u = (mmd->flag & MOD_MIR_MIRROR_U) != 0; + const int do_mirr_v = (mmd->flag & MOD_MIR_MIRROR_V) != 0; const int totuv = CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); @@ -258,7 +258,7 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, MLoopUV *dmloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, a); int j = maxLoops; dmloopuv += j; /* second set of loops only */ - for ( ; i-- > 0; dmloopuv++) { + for (; i-- > 0; dmloopuv++) { if (do_mirr_u) dmloopuv->uv[0] = 1.0f - dmloopuv->uv[0]; if (do_mirr_v) dmloopuv->uv[1] = 1.0f - dmloopuv->uv[1]; } @@ -268,9 +268,9 @@ static DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, /* handle vgroup stuff */ if ((mmd->flag & MOD_MIR_VGROUP) && CustomData_has_layer(&result->vertData, CD_MDEFORMVERT)) { MDeformVert *dvert = (MDeformVert *) CustomData_get_layer(&result->vertData, CD_MDEFORMVERT) + maxVerts; - int *flip_map= NULL, flip_map_len= 0; + int *flip_map = NULL, flip_map_len = 0; - flip_map= defgroup_flip_map(ob, &flip_map_len, FALSE); + flip_map = defgroup_flip_map(ob, &flip_map_len, FALSE); if (flip_map) { for (i = 0; i < maxVerts; dvert++, i++) { @@ -309,12 +309,12 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, if (mmd->flag & MOD_MIR_AXIS_Y) { DerivedMesh *tmp = result; result = doMirrorOnAxis(mmd, ob, result, 1); - if (tmp != dm) tmp->release(tmp); /* free intermediate results */ + if (tmp != dm) tmp->release(tmp); /* free intermediate results */ } if (mmd->flag & MOD_MIR_AXIS_Z) { DerivedMesh *tmp = result; result = doMirrorOnAxis(mmd, ob, result, 2); - if (tmp != dm) tmp->release(tmp); /* free intermediate results */ + if (tmp != dm) tmp->release(tmp); /* free intermediate results */ } return result; @@ -322,11 +322,10 @@ static DerivedMesh *mirrorModifier__doMirror(MirrorModifierData *mmd, static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; - MirrorModifierData *mmd = (MirrorModifierData*) md; + MirrorModifierData *mmd = (MirrorModifierData *) md; result = mirrorModifier__doMirror(mmd, ob, derivedData); @@ -340,7 +339,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, struct BMEditMesh *UNUSED(editData), DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -349,11 +348,11 @@ ModifierTypeInfo modifierType_Mirror = { /* structName */ "MirrorModifierData", /* structSize */ sizeof(MirrorModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 57268d04947..472836e3716 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -49,7 +49,7 @@ static void initData(ModifierData *md) { - MultiresModifierData *mmd = (MultiresModifierData*)md; + MultiresModifierData *mmd = (MultiresModifierData *)md; mmd->lvl = 0; mmd->sculptlvl = 0; @@ -59,8 +59,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - MultiresModifierData *mmd = (MultiresModifierData*) md; - MultiresModifierData *tmmd = (MultiresModifierData*) target; + MultiresModifierData *mmd = (MultiresModifierData *) md; + MultiresModifierData *tmmd = (MultiresModifierData *) target; tmmd->lvl = mmd->lvl; tmmd->sculptlvl = mmd->sculptlvl; @@ -71,11 +71,13 @@ static void copyData(ModifierData *md, ModifierData *target) } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, - int useRenderParams, int isFinalCalc) + ModifierApplyFlag flag) { - MultiresModifierData *mmd = (MultiresModifierData*)md; + MultiresModifierData *mmd = (MultiresModifierData *)md; DerivedMesh *result; - Mesh *me= (Mesh*)ob->data; + Mesh *me = (Mesh *)ob->data; + const int useRenderParams = flag & MOD_APPLY_RENDER; + MultiresFlags flags = 0; if (mmd->totlvl) { if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) { @@ -84,36 +86,53 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *dm, } } - result = multires_dm_create_from_derived(mmd, 0, dm, ob, useRenderParams); + flags = MULTIRES_ALLOC_PAINT_MASK; + if (useRenderParams) + flags |= MULTIRES_USE_RENDER_PARAMS; + + result = multires_make_derived_from_derived(dm, mmd, ob, flags); if (result == dm) return dm; - if (useRenderParams || !isFinalCalc) { + if (useRenderParams || !(flag & MOD_APPLY_USECACHE)) { DerivedMesh *cddm; - cddm= CDDM_copy(result); + cddm = CDDM_copy(result); - /* copy hidden flag to vertices */ + /* copy hidden/masks to vertices */ if (!useRenderParams) { struct MDisps *mdisps; + struct GridPaintMask *grid_paint_mask; + mdisps = CustomData_get_layer(&me->ldata, CD_MDISPS); + grid_paint_mask = CustomData_get_layer(&me->ldata, CD_GRID_PAINT_MASK); + if (mdisps) { subsurf_copy_grid_hidden(result, me->mpoly, - cddm->getVertArray(cddm), - mdisps); + cddm->getVertArray(cddm), + mdisps); - mesh_flush_hidden_from_verts(cddm->getVertArray(cddm), - cddm->getLoopArray(cddm), - cddm->getEdgeArray(cddm), - cddm->getNumEdges(cddm), - cddm->getPolyArray(cddm), - cddm->getNumPolys(cddm)); + BKE_mesh_flush_hidden_from_verts(cddm->getVertArray(cddm), + cddm->getLoopArray(cddm), + cddm->getEdgeArray(cddm), + cddm->getNumEdges(cddm), + cddm->getPolyArray(cddm), + cddm->getNumPolys(cddm)); + } + if (grid_paint_mask) { + float *paint_mask = CustomData_add_layer(&cddm->vertData, + CD_PAINT_MASK, + CD_CALLOC, NULL, + cddm->getNumVerts(cddm)); + + subsurf_copy_grid_paint_mask(result, me->mpoly, + paint_mask, grid_paint_mask); } } result->release(result); - result= cddm; + result = cddm; } return result; @@ -125,9 +144,9 @@ ModifierTypeInfo modifierType_Multires = { /* structName */ "MultiresModifierData", /* structSize */ sizeof(MultiresModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_RequiresOriginalData, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_RequiresOriginalData, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index 967532adf3c..7bdff12b348 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -53,8 +53,8 @@ ModifierTypeInfo modifierType_None = { /* structName */ "ModifierData", /* structSize */ sizeof(ModifierData), /* type */ eModifierTypeType_None, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs, /* copyData */ NULL, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index fd8691991ff..dfbfbd22475 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -50,7 +50,7 @@ #ifdef WITH_OCEANSIM static void init_cache_data(Object *ob, struct OceanModifierData *omd) { - const char *relbase= modifier_path_relbase(ob); + const char *relbase = modifier_path_relbase(ob); omd->oceancache = BKE_init_ocean_cache(omd->cachepath, relbase, omd->bakestart, omd->bakeend, omd->wave_scale, @@ -77,7 +77,8 @@ static void init_ocean_modifier(struct OceanModifierData *omd) do_jacobian = (omd->flag & MOD_OCEAN_GENERATE_FOAM); BKE_free_ocean_data(omd->ocean); - BKE_init_ocean(omd->ocean, omd->resolution*omd->resolution, omd->resolution*omd->resolution, omd->spatial_size, omd->spatial_size, + BKE_init_ocean(omd->ocean, omd->resolution * omd->resolution, omd->resolution * omd->resolution, + omd->spatial_size, omd->spatial_size, omd->wind_velocity, omd->smallest_wave, 1.0, omd->wave_direction, omd->damp, omd->wave_alignment, omd->depth, omd->time, do_heightfield, do_chop, do_normals, do_jacobian, @@ -99,7 +100,7 @@ static void simulate_ocean_modifier(struct OceanModifierData *omd) static void initData(ModifierData *md) { #ifdef WITH_OCEANSIM - OceanModifierData *omd = (OceanModifierData*) md; + OceanModifierData *omd = (OceanModifierData *) md; omd->resolution = 7; omd->spatial_size = 50; @@ -109,7 +110,7 @@ static void initData(ModifierData *md) omd->damp = 0.5; omd->smallest_wave = 0.01; - omd->wave_direction= 0.0; + omd->wave_direction = 0.0; omd->depth = 200.0; omd->wave_scale = 1.0; @@ -134,13 +135,13 @@ static void initData(ModifierData *md) omd->bakeend = 250; omd->oceancache = NULL; omd->foam_fade = 0.98; - omd->foamlayername[0] = '\0'; /* layer name empty by default */ + omd->foamlayername[0] = '\0'; /* layer name empty by default */ omd->ocean = BKE_add_ocean(); init_ocean_modifier(omd); simulate_ocean_modifier(omd); #else // WITH_OCEANSIM - /* unused */ + /* unused */ (void)md; #endif // WITH_OCEANSIM } @@ -148,7 +149,7 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { #ifdef WITH_OCEANSIM - OceanModifierData *omd = (OceanModifierData*) md; + OceanModifierData *omd = (OceanModifierData *) md; BKE_free_ocean(omd->ocean); if (omd->oceancache) @@ -162,8 +163,8 @@ static void freeData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { #ifdef WITH_OCEANSIM - OceanModifierData *omd = (OceanModifierData*) md; - OceanModifierData *tomd = (OceanModifierData*) target; + OceanModifierData *omd = (OceanModifierData *) md; + OceanModifierData *tomd = (OceanModifierData *) target; tomd->resolution = omd->resolution; tomd->spatial_size = omd->spatial_size; @@ -232,22 +233,22 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, float *oy) { /* get bounding box of underlying dm */ - int v, totvert=dm->getNumVerts(dm); + int v, totvert = dm->getNumVerts(dm); float min[3], max[3], delta[3]; - MVert *mvert = dm->getVertDataArray(dm,0); + MVert *mvert = dm->getVertDataArray(dm, 0); copy_v3_v3(min, mvert->co); copy_v3_v3(max, mvert->co); - for (v=1; vco[0]); - min[1]=MIN2(min[1],mvert->co[1]); - min[2]=MIN2(min[2],mvert->co[2]); + for (v = 1; v < totvert; v++, mvert++) { + min[0] = MIN2(min[0], mvert->co[0]); + min[1] = MIN2(min[1], mvert->co[1]); + min[2] = MIN2(min[2], mvert->co[2]); - max[0]=MAX2(max[0],mvert->co[0]); - max[1]=MAX2(max[1],mvert->co[1]); - max[2]=MAX2(max[2],mvert->co[2]); + max[0] = MAX2(max[0], mvert->co[0]); + max[1] = MAX2(max[1], mvert->co[1]); + max[2] = MAX2(max[2], mvert->co[2]); } sub_v3_v3v3(delta, max, min); @@ -263,7 +264,7 @@ static void dm_get_bounds(DerivedMesh *dm, float *sx, float *sy, float *ox, floa #ifdef WITH_OCEANSIM -#define OMP_MIN_RES 18 +#define OMP_MIN_RES 18 static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) { DerivedMesh *result; @@ -275,8 +276,8 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) int cdlayer; - const int rx = omd->resolution*omd->resolution; - const int ry = omd->resolution*omd->resolution; + const int rx = omd->resolution * omd->resolution; + const int ry = omd->resolution * omd->resolution; const int res_x = rx * omd->repeat_x; const int res_y = ry * omd->repeat_y; @@ -303,17 +304,17 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) mloops = CDDM_get_loops(result); #if 0 // trunk - origindex= result->getFaceDataArray(result, CD_ORIGINDEX); + origindex = result->getFaceDataArray(result, CD_ORIGINDEX); #else // bmesh - origindex= CustomData_get_layer(&result->polyData, CD_ORIGINDEX); + origindex = CustomData_get_layer(&result->polyData, CD_ORIGINDEX); #endif /* create vertices */ #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y+1; y++) { - for (x=0; x < res_x+1; x++) { - const int i = y*(res_x+1) + x; - float *co= mverts[i].co; + for (y = 0; y < res_y + 1; y++) { + for (x = 0; x < res_x + 1; x++) { + const int i = y * (res_x + 1) + x; + float *co = mverts[i].co; co[0] = ox + (x * sx); co[1] = oy + (y * sy); co[2] = 0; @@ -322,12 +323,12 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) /* create faces */ #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y; y++) { - for (x=0; x < res_x; x++) { - const int fi = y*res_x + x; - const int vi = y*(res_x+1) + x; - MPoly *mp= &mpolys[fi]; - MLoop *ml= &mloops[fi * 4]; + for (y = 0; y < res_y; y++) { + for (x = 0; x < res_x; x++) { + const int fi = y * res_x + x; + const int vi = y * (res_x + 1) + x; + MPoly *mp = &mpolys[fi]; + MLoop *ml = &mloops[fi * 4]; ml->v = vi; ml++; @@ -338,8 +339,8 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) ml->v = vi + res_x + 1; ml++; - mp->loopstart= fi * 4; - mp->totloop= 4; + mp->loopstart = fi * 4; + mp->totloop = 4; mp->flag |= ME_SMOOTH; @@ -351,7 +352,7 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) CDDM_calc_edges(result); /* add uvs */ - cdlayer= CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); + cdlayer = CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); if (cdlayer < MAX_MTFACE) { MLoopUV *mloopuvs = CustomData_add_layer(&result->loopData, CD_MLOOPUV, CD_CALLOC, NULL, num_faces * 4); CustomData_add_layer(&result->polyData, CD_MTEXPOLY, CD_CALLOC, NULL, num_faces); @@ -360,25 +361,25 @@ static DerivedMesh *generate_ocean_geometry(OceanModifierData *omd) ix = 1.0 / rx; iy = 1.0 / ry; #pragma omp parallel for private(x, y) if (rx > OMP_MIN_RES) - for (y=0; y < res_y; y++) { - for (x=0; x < res_x; x++) { - const int i = y*res_x + x; - MLoopUV *luv= &mloopuvs[i * 4]; + for (y = 0; y < res_y; y++) { + for (x = 0; x < res_x; x++) { + const int i = y * res_x + x; + MLoopUV *luv = &mloopuvs[i * 4]; luv->uv[0] = x * ix; luv->uv[1] = y * iy; luv++; - luv->uv[0] = (x+1) * ix; + luv->uv[0] = (x + 1) * ix; luv->uv[1] = y * iy; luv++; - luv->uv[0] = (x+1) * ix; - luv->uv[1] = (y+1) * iy; + luv->uv[0] = (x + 1) * ix; + luv->uv[1] = (y + 1) * iy; luv++; luv->uv[0] = x * ix; - luv->uv[1] = (y+1) * iy; + luv->uv[1] = (y + 1) * iy; luv++; } @@ -393,9 +394,9 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, DerivedMesh *derivedData, int UNUSED(useRenderParams)) { - OceanModifierData *omd = (OceanModifierData*) md; + OceanModifierData *omd = (OceanModifierData *) md; - DerivedMesh *dm=NULL; + DerivedMesh *dm = NULL; OceanResult ocr; MVert *mverts, *mv; @@ -414,7 +415,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, * (axis / (omd->size * omd->spatial_size)) + 0.5f) */ #define OCEAN_CO(_size_co_inv, _v) ((_v * _size_co_inv) + 0.5f) - const float size_co_inv= 1.0f / (omd->size * omd->spatial_size); + const float size_co_inv = 1.0f / (omd->size * omd->spatial_size); /* update modifier */ if (omd->refresh & MOD_OCEAN_REFRESH_ADD) @@ -443,7 +444,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, cfra = md->scene->r.cfra; CLAMP(cfra, omd->bakestart, omd->bakeend); - cfra -= omd->bakestart; // shift to 0 based + cfra -= omd->bakestart; // shift to 0 based num_verts = dm->getNumVerts(dm); num_faces = dm->getNumPolys(dm); @@ -454,30 +455,31 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, /* add vcols before displacement - allows lookup based on position */ if (omd->flag & MOD_OCEAN_GENERATE_FOAM) { - int cdlayer= CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL); + int cdlayer = CustomData_number_of_layers(&dm->loopData, CD_MLOOPCOL); if (cdlayer < MAX_MCOL) { - MLoopCol *mloopcols= CustomData_add_layer_named(&dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, num_faces * 4, omd->foamlayername); + MLoopCol *mloopcols = CustomData_add_layer_named(&dm->loopData, CD_MLOOPCOL, CD_CALLOC, NULL, + num_faces * 4, omd->foamlayername); if (mloopcols) { /* unlikely to fail */ MLoopCol *mlcol; - MPoly *mpolys= dm->getPolyArray(dm); + MPoly *mpolys = dm->getPolyArray(dm); MPoly *mp; float foam; - for (i = 0, mp= mpolys; i < num_faces; i++, mp++) { - j= mp->totloop - 1; + for (i = 0, mp = mpolys; i < num_faces; i++, mp++) { + j = mp->totloop - 1; /* highly unlikely */ if (j <= 0) continue; do { - const float *co= mverts[mloops[mp->loopstart + j].v].co; + const float *co = mverts[mloops[mp->loopstart + j].v].co; const float u = OCEAN_CO(size_co_inv, co[0]); const float v = OCEAN_CO(size_co_inv, co[1]); - if (omd->oceancache && omd->cached==TRUE) { + if (omd->oceancache && omd->cached == TRUE) { BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); foam = ocr.foam; CLAMP(foam, 0.0f, 1.0f); @@ -487,7 +489,7 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, foam = BKE_ocean_jminus_to_foam(ocr.Jminus, omd->foam_coverage); } - mlcol= &mloopcols[mp->loopstart + j]; + mlcol = &mloopcols[mp->loopstart + j]; mlcol->r = mlcol->g = mlcol->b = (char)(foam * 255); /* mc->a = 255; */ /* no need to set */ } while (j--); @@ -500,11 +502,11 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, /* displace the geometry */ //#pragma omp parallel for private(i, ocr) if (omd->resolution > OMP_MIN_RES) - for (i=0, mv= mverts; i< num_verts; i++, mv++) { + for (i = 0, mv = mverts; i < num_verts; i++, mv++) { const float u = OCEAN_CO(size_co_inv, mv->co[0]); const float v = OCEAN_CO(size_co_inv, mv->co[1]); - if (omd->oceancache && omd->cached==TRUE) + if (omd->oceancache && omd->cached == TRUE) BKE_ocean_cache_eval_uv(omd->oceancache, &ocr, cfra, u, v); else BKE_ocean_eval_uv(omd->ocean, &ocr, u, v); @@ -523,8 +525,8 @@ static DerivedMesh *doOcean(ModifierData *md, Object *ob, } #else // WITH_OCEANSIM static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams)) + DerivedMesh *derivedData, + int UNUSED(useRenderParams)) { /* unused */ (void)md; @@ -533,9 +535,8 @@ static DerivedMesh *doOcean(ModifierData *md, Object *UNUSED(ob), #endif // WITH_OCEANSIM static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; @@ -548,10 +549,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -561,9 +562,9 @@ ModifierTypeInfo modifierType_Ocean = { /* structName */ "OceanModifierData", /* structSize */ sizeof(OceanModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index 3af1351cbdb..82ab8db9c36 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -55,10 +55,10 @@ static void initData(ModifierData *md) { - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; - pimd->flag = eParticleInstanceFlag_Parents|eParticleInstanceFlag_Unborn| - eParticleInstanceFlag_Alive|eParticleInstanceFlag_Dead; + pimd->flag = eParticleInstanceFlag_Parents | eParticleInstanceFlag_Unborn | + eParticleInstanceFlag_Alive | eParticleInstanceFlag_Dead; pimd->psys = 1; pimd->position = 1.0f; pimd->axis = 2; @@ -66,8 +66,8 @@ static void initData(ModifierData *md) } static void copyData(ModifierData *md, ModifierData *target) { - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; - ParticleInstanceModifierData *tpimd= (ParticleInstanceModifierData*) target; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; + ParticleInstanceModifierData *tpimd = (ParticleInstanceModifierData *) target; tpimd->ob = pimd->ob; tpimd->psys = pimd->psys; @@ -82,71 +82,70 @@ static int dependsOnTime(ModifierData *UNUSED(md)) return 0; } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; if (pimd->ob) { DagNode *curNode = dag_get_node(forest, pimd->ob); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Particle Instance Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, + "Particle Instance Modifier"); } } static void foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { - ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; walk(userData, ob, &pimd->ob); } -static DerivedMesh * applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) +static DerivedMesh *applyModifier(ModifierData *md, Object *ob, + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = derivedData, *result; - ParticleInstanceModifierData *pimd= (ParticleInstanceModifierData*) md; + ParticleInstanceModifierData *pimd = (ParticleInstanceModifierData *) md; ParticleSimulationData sim; - ParticleSystem *psys= NULL; - ParticleData *pa= NULL, *pars= NULL; + ParticleSystem *psys = NULL; + ParticleData *pa = NULL, *pars = NULL; MFace *mface, *orig_mface; MVert *mvert, *orig_mvert; - int i, totvert, totpart=0, totface, maxvert, maxface, first_particle=0; - short track=ob->trackflag%3, trackneg, axis = pimd->axis; - float max_co=0.0, min_co=0.0, temp_co[3], cross[3]; - float *size=NULL; + int i, totvert, totpart = 0, totface, maxvert, maxface, first_particle = 0; + short track = ob->trackflag % 3, trackneg, axis = pimd->axis; + float max_co = 0.0, min_co = 0.0, temp_co[3], cross[3]; + float *size = NULL; DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ - trackneg=((ob->trackflag>2)?1:0); + trackneg = ((ob->trackflag > 2) ? 1 : 0); - if (pimd->ob==ob) { - pimd->ob= NULL; + if (pimd->ob == ob) { + pimd->ob = NULL; return derivedData; } if (pimd->ob) { - psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys-1); - if (psys==NULL || psys->totpart==0) + psys = BLI_findlink(&pimd->ob->particlesystem, pimd->psys - 1); + if (psys == NULL || psys->totpart == 0) return derivedData; } else return derivedData; if (pimd->flag & eParticleInstanceFlag_Parents) - totpart+=psys->totpart; + totpart += psys->totpart; if (pimd->flag & eParticleInstanceFlag_Children) { - if (totpart==0) - first_particle=psys->totpart; - totpart+=psys->totchild; + if (totpart == 0) + first_particle = psys->totpart; + totpart += psys->totchild; } - if (totpart==0) + if (totpart == 0) return derivedData; sim.scene = md->scene; @@ -160,62 +159,64 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, si = size = MEM_callocN(totpart * sizeof(float), "particle size array"); if (pimd->flag & eParticleInstanceFlag_Parents) { - for (p=0, pa= psys->particles; ptotpart; p++, pa++, si++) + for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++, si++) *si = pa->size; } if (pimd->flag & eParticleInstanceFlag_Children) { ChildParticle *cpa = psys->child; - for (p=0; ptotchild; p++, cpa++, si++) { + for (p = 0; p < psys->totchild; p++, cpa++, si++) { *si = psys_get_child_size(psys, cpa, 0.0f, NULL); } } } - pars=psys->particles; + pars = psys->particles; - totvert=dm->getNumVerts(dm); - totface=dm->getNumTessFaces(dm); + totvert = dm->getNumVerts(dm); + totface = dm->getNumTessFaces(dm); - maxvert=totvert*totpart; - maxface=totface*totpart; + maxvert = totvert * totpart; + maxface = totface * totpart; - psys->lattice=psys_get_lattice(&sim); + psys->lattice = psys_get_lattice(&sim); - if (psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) { + if (psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) { float min_r[3], max_r[3]; INIT_MINMAX(min_r, max_r); dm->getMinMax(dm, min_r, max_r); - min_co=min_r[track]; - max_co=max_r[track]; + min_co = min_r[track]; + max_co = max_r[track]; } - result = CDDM_from_template(dm, maxvert, dm->getNumEdges(dm)*totpart, maxface, 0, 0); + result = CDDM_from_template(dm, maxvert, dm->getNumEdges(dm) * totpart, maxface, 0, 0); - mvert=result->getVertArray(result); - orig_mvert=dm->getVertArray(dm); + mvert = result->getVertArray(result); + orig_mvert = dm->getVertArray(dm); - for (i=0; ico); - mv->co[axis]=temp_co[track]; - mv->co[(axis+1)%3]=temp_co[(track+1)%3]; - mv->co[(axis+2)%3]=temp_co[(track+2)%3]; + mv->co[axis] = temp_co[track]; + mv->co[(axis + 1) % 3] = temp_co[(track + 1) % 3]; + mv->co[(axis + 2) % 3] = temp_co[(track + 2) % 3]; - if ((psys->flag & (PSYS_HAIR_DONE|PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && pimd->flag & eParticleInstanceFlag_Path) { + if ((psys->flag & (PSYS_HAIR_DONE | PSYS_KEYED) || psys->pointcache->flag & PTCACHE_BAKED) && + (pimd->flag & eParticleInstanceFlag_Path)) + { float ran = 0.0f; if (pimd->random_position != 0.0f) { - BLI_srandom(psys->seed + (i/totvert)%totpart); + BLI_srandom(psys->seed + (i / totvert) % totpart); ran = pimd->random_position * BLI_frand(); } @@ -223,15 +224,15 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, state.time = pimd->position * (1.0f - ran); } else { - state.time=(mv->co[axis]-min_co)/(max_co-min_co) * pimd->position * (1.0f - ran); + state.time = (mv->co[axis] - min_co) / (max_co - min_co) * pimd->position * (1.0f - ran); if (trackneg) - state.time=1.0f-state.time; + state.time = 1.0f - state.time; mv->co[axis] = 0.0; } - psys_get_particle_on_path(&sim, first_particle + i/totvert, &state, 1); + psys_get_particle_on_path(&sim, first_particle + i / totvert, &state, 1); normalize_v3(state.vel); @@ -252,60 +253,60 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, } else { - state.time=-1.0; - psys_get_particle_state(&sim, first_particle + i/totvert, &state, 1); + state.time = -1.0; + psys_get_particle_state(&sim, first_particle + i / totvert, &state, 1); } mul_qt_v3(state.rot, mv->co); if (pimd->flag & eParticleInstanceFlag_UseSize) - mul_v3_fl(mv->co, size[i/totvert]); + mul_v3_fl(mv->co, size[i / totvert]); add_v3_v3(mv->co, state.co); } - mface=result->getTessFaceArray(result); - orig_mface=dm->getTessFaceArray(dm); + mface = result->getTessFaceArray(result); + orig_mface = dm->getTessFaceArray(dm); - for (i=0; iflag & eParticleInstanceFlag_Parents) { - if (i/totface>=psys->totpart) { - if (psys->part->childtype==PART_CHILD_PARTICLES) { - pa=psys->particles+(psys->child+i/totface-psys->totpart)->parent; + if (i / totface >= psys->totpart) { + if (psys->part->childtype == PART_CHILD_PARTICLES) { + pa = psys->particles + (psys->child + i / totface - psys->totpart)->parent; } else { - pa= NULL; + pa = NULL; } } else { - pa=pars+i/totface; + pa = pars + i / totface; } } else { - if (psys->part->childtype==PART_CHILD_PARTICLES) { - pa=psys->particles+(psys->child+i/totface)->parent; + if (psys->part->childtype == PART_CHILD_PARTICLES) { + pa = psys->particles + (psys->child + i / totface)->parent; } else { - pa= NULL; + pa = NULL; } } if (pa) { - if (pa->alive==PARS_UNBORN && (pimd->flag&eParticleInstanceFlag_Unborn)==0) continue; - if (pa->alive==PARS_ALIVE && (pimd->flag&eParticleInstanceFlag_Alive)==0) continue; - if (pa->alive==PARS_DEAD && (pimd->flag&eParticleInstanceFlag_Dead)==0) continue; + if (pa->alive == PARS_UNBORN && (pimd->flag & eParticleInstanceFlag_Unborn) == 0) continue; + if (pa->alive == PARS_ALIVE && (pimd->flag & eParticleInstanceFlag_Alive) == 0) continue; + if (pa->alive == PARS_DEAD && (pimd->flag & eParticleInstanceFlag_Dead) == 0) continue; } - inMF = orig_mface + i%totface; - DM_copy_poly_data(dm, result, i%totface, i, 1); + inMF = orig_mface + i % totface; + DM_copy_poly_data(dm, result, i % totface, i, 1); *mf = *inMF; - mf->v1+=(i/totface)*totvert; - mf->v2+=(i/totface)*totvert; - mf->v3+=(i/totface)*totvert; + mf->v1 += (i / totface) * totvert; + mf->v2 += (i / totface) * totvert; + mf->v3 += (i / totface) * totvert; if (mf->v4) { - mf->v4+=(i/totface)*totvert; + mf->v4 += (i / totface) * totvert; } } @@ -313,7 +314,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, if (psys->lattice) { end_latt_deform(psys->lattice); - psys->lattice= NULL; + psys->lattice = NULL; } if (size) @@ -325,38 +326,38 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob, return result; } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } ModifierTypeInfo modifierType_ParticleInstance = { - /* name */ "ParticleInstance", - /* structName */ "ParticleInstanceModifierData", - /* structSize */ sizeof(ParticleInstanceModifierData), - /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* name */ "ParticleInstance", + /* structName */ "ParticleInstanceModifierData", + /* structSize */ sizeof(ParticleInstanceModifierData), + /* type */ eModifierTypeType_Constructive, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, - /* copyData */ copyData, - /* deformVerts */ NULL, - /* deformMatrices */ NULL, - /* deformVertsEM */ NULL, - /* deformMatricesEM */ NULL, - /* applyModifier */ applyModifier, - /* applyModifierEM */ applyModifierEM, - /* initData */ initData, - /* requiredDataMask */ NULL, - /* freeData */ NULL, - /* isDisabled */ NULL, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ NULL, + /* deformMatrices */ NULL, + /* deformVertsEM */ NULL, + /* deformMatricesEM */ NULL, + /* applyModifier */ applyModifier, + /* applyModifierEM */ applyModifierEM, + /* initData */ initData, + /* requiredDataMask */ NULL, + /* freeData */ NULL, + /* isDisabled */ NULL, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index dc1429208a0..0cf36677807 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -50,14 +50,14 @@ static void initData(ModifierData *md) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - psmd->psys= NULL; - psmd->dm= NULL; - psmd->totdmvert= psmd->totdmedge= psmd->totdmface= 0; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; + psmd->psys = NULL; + psmd->dm = NULL; + psmd->totdmvert = psmd->totdmedge = psmd->totdmface = 0; } static void freeData(ModifierData *md) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; if (psmd->dm) { psmd->dm->needsFree = 1; @@ -72,20 +72,20 @@ static void freeData(ModifierData *md) } static void copyData(ModifierData *md, ModifierData *target) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - ParticleSystemModifierData *tpsmd= (ParticleSystemModifierData*) target; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; + ParticleSystemModifierData *tpsmd = (ParticleSystemModifierData *) target; tpsmd->dm = NULL; tpsmd->totdmvert = tpsmd->totdmedge = tpsmd->totdmface = 0; //tpsmd->facepa = 0; tpsmd->flag = psmd->flag; - /* need to keep this to recognise a bit later in copy_object */ + /* need to keep this to recognise a bit later in BKE_object_copy */ tpsmd->psys = psmd->psys; } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; CustomDataMask dataMask = 0; MTex *mtex; int i; @@ -93,7 +93,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) if (!psmd->psys->part) return 0; - for (i=0; ipsys->part->mtex[i]; if (mtex && mtex->mapto && (mtex->texco & TEXCO_UV)) dataMask |= CD_MASK_MTFACE; @@ -103,7 +103,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) dataMask |= CD_MASK_MTFACE; /* ask for vertexgroups if we need them */ - for (i=0; ipsys->vgroup[i]) { dataMask |= CD_MASK_MDEFORMVERT; break; @@ -112,7 +112,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) /* particles only need this if they are after a non deform modifier, and * the modifier stack will only create them in that case. */ - dataMask |= CD_MASK_ORIGSPACE_MLOOP|CD_MASK_ORIGINDEX; + dataMask |= CD_MASK_ORIGSPACE_MLOOP | CD_MASK_ORIGINDEX; dataMask |= CD_MASK_ORCO; @@ -121,32 +121,31 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) /* saves the current emitter state for a particle system and calculates particles */ static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = derivedData; - ParticleSystemModifierData *psmd= (ParticleSystemModifierData*) md; - ParticleSystem * psys= NULL; - int needsFree=0; + ParticleSystemModifierData *psmd = (ParticleSystemModifierData *) md; + ParticleSystem *psys = NULL; + int needsFree = 0; if (ob->particlesystem.first) - psys=psmd->psys; + psys = psmd->psys; else return; if (!psys_check_enabled(ob, psys)) return; - if (dm==NULL) { - dm= get_dm(ob, NULL, NULL, vertexCos, 1); + if (dm == NULL) { + dm = get_dm(ob, NULL, NULL, vertexCos, 1); if (!dm) return; - needsFree= 1; + needsFree = 1; } /* clear old dm */ @@ -164,7 +163,7 @@ static void deformVerts(ModifierData *md, Object *ob, } /* make new dm */ - psmd->dm=CDDM_copy(dm); + psmd->dm = CDDM_copy(dm); CDDM_apply_vert_coords(psmd->dm, vertexCos); CDDM_calc_normals(psmd->dm); @@ -177,15 +176,15 @@ static void deformVerts(ModifierData *md, Object *ob, psmd->dm->needsFree = 0; /* report change in mesh structure */ - if (psmd->dm->getNumVerts(psmd->dm)!=psmd->totdmvert || - psmd->dm->getNumEdges(psmd->dm)!=psmd->totdmedge || - psmd->dm->getNumTessFaces(psmd->dm)!=psmd->totdmface) { - + if (psmd->dm->getNumVerts(psmd->dm) != psmd->totdmvert || + psmd->dm->getNumEdges(psmd->dm) != psmd->totdmedge || + psmd->dm->getNumTessFaces(psmd->dm) != psmd->totdmface) + { psys->recalc |= PSYS_RECALC_RESET; - psmd->totdmvert= psmd->dm->getNumVerts(psmd->dm); - psmd->totdmedge= psmd->dm->getNumEdges(psmd->dm); - psmd->totdmface= psmd->dm->getNumTessFaces(psmd->dm); + psmd->totdmvert = psmd->dm->getNumVerts(psmd->dm); + psmd->totdmedge = psmd->dm->getNumEdges(psmd->dm); + psmd->totdmface = psmd->dm->getNumTessFaces(psmd->dm); } if (psys) { @@ -199,8 +198,8 @@ static void deformVerts(ModifierData *md, Object *ob, * updates is coded */ #if 0 static void deformVertsEM( - ModifierData *md, Object *ob, EditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, EditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; @@ -218,11 +217,11 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* structName */ "ParticleSystemModifierData", /* structSize */ sizeof(ParticleSystemModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_UsesPointCache /* - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode */, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_UsesPointCache /* | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode */, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 56b6493eda6..37bfd0e6f45 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -50,7 +50,7 @@ static void initData(ModifierData *md) { - RemeshModifierData *rmd = (RemeshModifierData*) md; + RemeshModifierData *rmd = (RemeshModifierData *) md; rmd->scale = 0.9; rmd->depth = 4; @@ -62,8 +62,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - RemeshModifierData *rmd = (RemeshModifierData*) md; - RemeshModifierData *trmd = (RemeshModifierData*) target; + RemeshModifierData *rmd = (RemeshModifierData *) md; + RemeshModifierData *trmd = (RemeshModifierData *) target; trmd->threshold = rmd->threshold; trmd->scale = rmd->scale; @@ -79,11 +79,11 @@ static void init_dualcon_mesh(DualConInput *mesh, DerivedMesh *dm) { memset(mesh, 0, sizeof(DualConInput)); - mesh->co = (void*)dm->getVertArray(dm); + mesh->co = (void *)dm->getVertArray(dm); mesh->co_stride = sizeof(MVert); mesh->totco = dm->getNumVerts(dm); - mesh->faces = (void*)dm->getTessFaceArray(dm); + mesh->faces = (void *)dm->getTessFaceArray(dm); mesh->face_stride = sizeof(MFace); mesh->totface = dm->getNumTessFaces(dm); @@ -108,7 +108,7 @@ static void *dualcon_alloc_output(int totvert, int totquad) return NULL; } - output->dm = CDDM_new(totvert, 0, 0, 4*totquad, totquad); + output->dm = CDDM_new(totvert, 0, 0, 4 * totquad, totquad); return output; } @@ -145,10 +145,9 @@ static void dualcon_add_quad(void *output_v, const int vert_indices[4]) } static DerivedMesh *applyModifier(ModifierData *md, - Object *UNUSED(ob), - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + Object *UNUSED(ob), + DerivedMesh *dm, + ModifierApplyFlag UNUSED(flag)) { RemeshModifierData *rmd; DualConOutput *output; @@ -159,7 +158,7 @@ static DerivedMesh *applyModifier(ModifierData *md, DM_ensure_tessface(dm); /* BMESH - UNTIL MODIFIER IS UPDATED FOR MPoly */ - rmd = (RemeshModifierData*)md; + rmd = (RemeshModifierData *)md; init_dualcon_mesh(&input, dm); @@ -167,27 +166,27 @@ static DerivedMesh *applyModifier(ModifierData *md, flags |= DUALCON_FLOOD_FILL; switch (rmd->mode) { - case MOD_REMESH_CENTROID: - mode = DUALCON_CENTROID; - break; - case MOD_REMESH_MASS_POINT: - mode = DUALCON_MASS_POINT; - break; - case MOD_REMESH_SHARP_FEATURES: - mode = DUALCON_SHARP_FEATURES; - break; + case MOD_REMESH_CENTROID: + mode = DUALCON_CENTROID; + break; + case MOD_REMESH_MASS_POINT: + mode = DUALCON_MASS_POINT; + break; + case MOD_REMESH_SHARP_FEATURES: + mode = DUALCON_SHARP_FEATURES; + break; } output = dualcon(&input, - dualcon_alloc_output, - dualcon_add_vert, - dualcon_add_quad, - flags, - mode, - rmd->threshold, - rmd->hermite_num, - rmd->scale, - rmd->depth); + dualcon_alloc_output, + dualcon_add_vert, + dualcon_add_quad, + flags, + mode, + rmd->threshold, + rmd->hermite_num, + rmd->scale, + rmd->depth); result = output->dm; MEM_freeN(output); @@ -199,9 +198,8 @@ static DerivedMesh *applyModifier(ModifierData *md, #else /* !WITH_MOD_REMESH */ static DerivedMesh *applyModifier(ModifierData *UNUSED(md), Object *UNUSED(ob), - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { return derivedData; } @@ -213,7 +211,8 @@ ModifierTypeInfo modifierType_Remesh = { /* structName */ "RemeshModifierData", /* structSize */ sizeof(RemeshModifierData), /* type */ eModifierTypeType_Nonconstructive, - /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ NULL, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 60eed4abcb1..6a57cd82b50 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -59,8 +59,8 @@ typedef struct ScrewVertConnect { } ScrewVertConnect; typedef struct ScrewVertIter { - ScrewVertConnect * v_array; - ScrewVertConnect * v_poin; + ScrewVertConnect *v_array; + ScrewVertConnect *v_poin; int v; int v_other; MEdge *e; @@ -78,8 +78,8 @@ static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, in iter->e = iter->v_poin->e[!dir]; } else { - iter->v_poin= NULL; - iter->e= NULL; + iter->v_poin = NULL; + iter->e = NULL; } } @@ -87,82 +87,82 @@ static void screwvert_iter_init(ScrewVertIter *iter, ScrewVertConnect *array, in static void screwvert_iter_step(ScrewVertIter *iter) { if (iter->v_poin->v[0] == iter->v_other) { - iter->v_other= iter->v; - iter->v= iter->v_poin->v[1]; + iter->v_other = iter->v; + iter->v = iter->v_poin->v[1]; } else if (iter->v_poin->v[1] == iter->v_other) { - iter->v_other= iter->v; - iter->v= iter->v_poin->v[0]; + iter->v_other = iter->v; + iter->v = iter->v_poin->v[0]; } - if (iter->v >= 0) { - iter->v_poin= &iter->v_array[iter->v]; - iter->e= iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; + if (iter->v >= 0) { + iter->v_poin = &iter->v_array[iter->v]; + iter->e = iter->v_poin->e[(iter->v_poin->e[0] == iter->e)]; } else { - iter->e= NULL; - iter->v_poin= NULL; + iter->e = NULL; + iter->v_poin = NULL; } } static void initData(ModifierData *md) { - ScrewModifierData *ltmd= (ScrewModifierData*) md; - ltmd->ob_axis= NULL; - ltmd->angle= M_PI * 2.0; - ltmd->axis= 2; - ltmd->flag= 0; - ltmd->steps= 16; - ltmd->render_steps= 16; - ltmd->iter= 1; + ScrewModifierData *ltmd = (ScrewModifierData *) md; + ltmd->ob_axis = NULL; + ltmd->angle = M_PI * 2.0; + ltmd->axis = 2; + ltmd->flag = 0; + ltmd->steps = 16; + ltmd->render_steps = 16; + ltmd->iter = 1; } static void copyData(ModifierData *md, ModifierData *target) { - ScrewModifierData *sltmd= (ScrewModifierData*) md; - ScrewModifierData *tltmd= (ScrewModifierData*) target; + ScrewModifierData *sltmd = (ScrewModifierData *) md; + ScrewModifierData *tltmd = (ScrewModifierData *) target; - tltmd->ob_axis= sltmd->ob_axis; - tltmd->angle= sltmd->angle; - tltmd->axis= sltmd->axis; - tltmd->flag= sltmd->flag; - tltmd->steps= sltmd->steps; - tltmd->render_steps= sltmd->render_steps; - tltmd->screw_ofs= sltmd->screw_ofs; - tltmd->iter= sltmd->iter; + tltmd->ob_axis = sltmd->ob_axis; + tltmd->angle = sltmd->angle; + tltmd->axis = sltmd->axis; + tltmd->flag = sltmd->flag; + tltmd->steps = sltmd->steps; + tltmd->render_steps = sltmd->render_steps; + tltmd->screw_ofs = sltmd->screw_ofs; + tltmd->iter = sltmd->iter; } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag flag) { - DerivedMesh *dm= derivedData; + DerivedMesh *dm = derivedData; DerivedMesh *result; - ScrewModifierData *ltmd= (ScrewModifierData*) md; + ScrewModifierData *ltmd = (ScrewModifierData *) md; + const int useRenderParams = flag & MOD_APPLY_RENDER; int *origindex; - int mpoly_index=0; + int mpoly_index = 0; int step; int i, j; unsigned int i1, i2; - int step_tot= useRenderParams ? ltmd->render_steps : ltmd->steps; + int step_tot = useRenderParams ? ltmd->render_steps : ltmd->steps; const int do_flip = ltmd->flag & MOD_SCREW_NORMAL_FLIP ? 1 : 0; - int maxVerts=0, maxEdges=0, maxPolys=0; - const unsigned int totvert= dm->getNumVerts(dm); - const unsigned int totedge= dm->getNumEdges(dm); + int maxVerts = 0, maxEdges = 0, maxPolys = 0; + const unsigned int totvert = dm->getNumVerts(dm); + const unsigned int totedge = dm->getNumEdges(dm); - char axis_char= 'X', close; - float angle= ltmd->angle; - float screw_ofs= ltmd->screw_ofs; - float axis_vec[3]= {0.0f, 0.0f, 0.0f}; + char axis_char = 'X', close; + float angle = ltmd->angle; + float screw_ofs = ltmd->screw_ofs; + float axis_vec[3] = {0.0f, 0.0f, 0.0f}; float tmp_vec1[3], tmp_vec2[3]; float mat3[3][3]; float mtx_tx[4][4]; /* transform the coords by an object relative to this objects transformation */ float mtx_tx_inv[4][4]; /* inverted */ float mtx_tmp_a[4][4]; - int vc_tot_linked= 0; + int vc_tot_linked = 0; short other_axis_1, other_axis_2; float *tmpf1, *tmpf2; @@ -173,28 +173,28 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new; MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base; - ScrewVertConnect *vc, *vc_tmp, *vert_connect= NULL; + ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL; /* don't do anything? */ if (!totvert) return CDDM_from_template(dm, 0, 0, 0, 0, 0); switch (ltmd->axis) { - case 0: - other_axis_1=1; - other_axis_2=2; - break; - case 1: - other_axis_1=0; - other_axis_2=2; - break; - default: /* 2, use default to quiet warnings */ - other_axis_1=0; - other_axis_2=1; - break; + case 0: + other_axis_1 = 1; + other_axis_2 = 2; + break; + case 1: + other_axis_1 = 0; + other_axis_2 = 2; + break; + default: /* 2, use default to quiet warnings */ + other_axis_1 = 0; + other_axis_2 = 1; + break; } - axis_vec[ltmd->axis]= 1.0f; + axis_vec[ltmd->axis] = 1.0f; if (ltmd->ob_axis) { /* calc the matrix relative to the axis object */ @@ -212,23 +212,23 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, float totlen = len_v3(mtx_tx[3]); if (totlen != 0.0f) { - float zero[3]={0.0f, 0.0f, 0.0f}; + float zero[3] = {0.0f, 0.0f, 0.0f}; float cp[3]; - screw_ofs= closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); + screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); } else { - screw_ofs= 0.0f; + screw_ofs = 0.0f; } } /* angle */ -#if 0 // cant incluide this, not predictable enough, though quite fun,. +#if 0 // cant incluide this, not predictable enough, though quite fun,. if (ltmd->flag & MOD_SCREW_OBJECT_ANGLE) { float mtx3_tx[3][3]; copy_m3_m4(mtx3_tx, mtx_tx); - float vec[3] = {0,1,0}; + float vec[3] = {0, 1, 0}; float cross1[3]; float cross2[3]; cross_v3_v3v3(cross1, vec, axis_vec); @@ -243,13 +243,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, cross_v3_v3v3(c2, axis_vec, c1); - angle= angle_v3v3(cross1, c2); + angle = angle_v3v3(cross1, c2); cross_v3_v3v3(axis_tmp, cross1, c2); normalize_v3(axis_tmp); if (len_v3v3(axis_tmp, axis_vec) > 1.0f) - angle= -angle; + angle = -angle; } } @@ -261,7 +261,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* useful to be able to use the axis vec in some cases still */ zero_v3(axis_vec); - axis_vec[ltmd->axis]= 1.0f; + axis_vec[ltmd->axis] = 1.0f; } /* apply the multiplier */ @@ -273,38 +273,40 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* will the screw be closed? * Note! smaller then FLT_EPSILON*100 gives problems with float precision so its never closed. */ - if (fabsf(screw_ofs) <= (FLT_EPSILON*100.0f) && fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON*100.0f)) { - close= 1; + if (fabsf(screw_ofs) <= (FLT_EPSILON * 100.0f) && + fabsf(fabsf(angle) - ((float)M_PI * 2.0f)) <= (FLT_EPSILON * 100.0f)) + { + close = 1; step_tot--; - if (step_tot < 3) step_tot= 3; + if (step_tot < 3) step_tot = 3; - maxVerts = totvert * step_tot; /* -1 because we're joining back up */ - maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ - (totedge * step_tot); /* -1 because vert edges join */ - maxPolys = totedge * step_tot; + maxVerts = totvert * step_tot; /* -1 because we're joining back up */ + maxEdges = (totvert * step_tot) + /* these are the edges between new verts */ + (totedge * step_tot); /* -1 because vert edges join */ + maxPolys = totedge * step_tot; - screw_ofs= 0.0f; + screw_ofs = 0.0f; } else { - close= 0; - if (step_tot < 3) step_tot= 3; + close = 0; + if (step_tot < 3) step_tot = 3; - maxVerts = totvert * step_tot; /* -1 because we're joining back up */ - maxEdges = (totvert * (step_tot-1)) + /* these are the edges between new verts */ - (totedge * step_tot); /* -1 because vert edges join */ - maxPolys = totedge * (step_tot-1); + maxVerts = totvert * step_tot; /* -1 because we're joining back up */ + maxEdges = (totvert * (step_tot - 1)) + /* these are the edges between new verts */ + (totedge * step_tot); /* -1 because vert edges join */ + maxPolys = totedge * (step_tot - 1); } - result= CDDM_from_template(dm, maxVerts, maxEdges, 0, maxPolys * 4, maxPolys); + result = CDDM_from_template(dm, maxVerts, maxEdges, 0, maxPolys * 4, maxPolys); /* copy verts from mesh */ - mvert_orig = dm->getVertArray(dm); - medge_orig = dm->getEdgeArray(dm); + mvert_orig = dm->getVertArray(dm); + medge_orig = dm->getEdgeArray(dm); - mvert_new = result->getVertArray(result); - mpoly_new = result->getPolyArray(result); - mloop_new = result->getLoopArray(result); - medge_new = result->getEdgeArray(result); + mvert_new = result->getVertArray(result); + mpoly_new = result->getPolyArray(result); + mloop_new = result->getLoopArray(result); + medge_new = result->getEdgeArray(result); if (!CustomData_has_layer(&result->polyData, CD_ORIGINDEX)) { CustomData_add_layer(&result->polyData, CD_ORIGINDEX, CD_CALLOC, NULL, maxPolys); @@ -320,17 +322,17 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* Set the locations of the first set of verts */ - mv_new= mvert_new; - mv_orig= mvert_orig; + mv_new = mvert_new; + mv_orig = mvert_orig; /* Copy the first set of edges */ - med_orig= medge_orig; - med_new= medge_new; - for (i=0; i < totedge; i++, med_orig++, med_new++) { - med_new->v1= med_orig->v1; - med_new->v2= med_orig->v2; - med_new->crease= med_orig->crease; - med_new->flag= med_orig->flag & ~ME_LOOSEEDGE; + med_orig = medge_orig; + med_new = medge_new; + for (i = 0; i < totedge; i++, med_orig++, med_new++) { + med_new->v1 = med_orig->v1; + med_new->v2 = med_orig->v2; + med_new->crease = med_orig->crease; + med_new->flag = med_orig->flag & ~ME_LOOSEEDGE; } if (ltmd->flag & MOD_SCREW_NORMAL_CALC) { @@ -358,14 +360,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * This makes the modifier faster with one less alloc. */ - vert_connect= MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); + vert_connect = MEM_mallocN(sizeof(ScrewVertConnect) * totvert, "ScrewVertConnect"); //vert_connect= (ScrewVertConnect *) &medge_new[totvert]; /* skip the first slice of verts */ - vc= vert_connect; + vc = vert_connect; /* Copy Vert Locations */ /* - We can do this in a later loop - only do here if no normal calc */ if (!totedge) { - for (i=0; i < totvert; i++, mv_orig++, mv_new++) { + for (i = 0; i < totvert; i++, mv_orig++, mv_new++) { copy_v3_v3(mv_new->co, mv_orig->co); normalize_v3_v3(vc->no, mv_new->co); /* no edges- this is really a dummy normal */ } @@ -373,93 +375,95 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, else { /*printf("\n\n\n\n\nStarting Modifier\n");*/ /* set edge users */ - med_new= medge_new; - mv_new= mvert_new; + med_new = medge_new; + mv_new = mvert_new; if (ltmd->ob_axis) { /*mtx_tx is initialized early on */ - for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0]= mv_new->co[0]= mv_orig->co[0]; - vc->co[1]= mv_new->co[1]= mv_orig->co[1]; - vc->co[2]= mv_new->co[2]= mv_orig->co[2]; + for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { + vc->co[0] = mv_new->co[0] = mv_orig->co[0]; + vc->co[1] = mv_new->co[1] = mv_orig->co[1]; + vc->co[2] = mv_new->co[2] = mv_orig->co[2]; - vc->flag= 0; - vc->e[0]= vc->e[1]= NULL; - vc->v[0]= vc->v[1]= -1; + vc->flag = 0; + vc->e[0] = vc->e[1] = NULL; + vc->v[0] = vc->v[1] = -1; mul_m4_v3(mtx_tx, vc->co); /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + - vc->co[other_axis_2]*vc->co[other_axis_2]; + vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->co[other_axis_2] * vc->co[other_axis_2]; /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ } } else { - for (i=0; i < totvert; i++, mv_new++, mv_orig++, vc++) { - vc->co[0]= mv_new->co[0]= mv_orig->co[0]; - vc->co[1]= mv_new->co[1]= mv_orig->co[1]; - vc->co[2]= mv_new->co[2]= mv_orig->co[2]; + for (i = 0; i < totvert; i++, mv_new++, mv_orig++, vc++) { + vc->co[0] = mv_new->co[0] = mv_orig->co[0]; + vc->co[1] = mv_new->co[1] = mv_orig->co[1]; + vc->co[2] = mv_new->co[2] = mv_orig->co[2]; - vc->flag= 0; - vc->e[0]= vc->e[1]= NULL; - vc->v[0]= vc->v[1]= -1; + vc->flag = 0; + vc->e[0] = vc->e[1] = NULL; + vc->v[0] = vc->v[1] = -1; /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1]*vc->co[other_axis_1] + - vc->co[other_axis_2]*vc->co[other_axis_2]; + vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->co[other_axis_2] * vc->co[other_axis_2]; /* printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist);*/ } } /* this loop builds connectivity info for verts */ - for (i=0; iv1]; + for (i = 0; i < totedge; i++, med_new++) { + vc = &vert_connect[med_new->v1]; if (vc->v[0] == -1) { /* unused */ - vc->v[0]= med_new->v2; - vc->e[0]= med_new; + vc->v[0] = med_new->v2; + vc->e[0] = med_new; } else if (vc->v[1] == -1) { - vc->v[1]= med_new->v2; - vc->e[1]= med_new; + vc->v[1] = med_new->v2; + vc->e[1] = med_new; } else { - vc->v[0]= vc->v[1]= -2; /* erro value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */ } - vc= &vert_connect[med_new->v2]; + vc = &vert_connect[med_new->v2]; /* same as above but swap v1/2 */ if (vc->v[0] == -1) { /* unused */ - vc->v[0]= med_new->v1; - vc->e[0]= med_new; + vc->v[0] = med_new->v1; + vc->e[0] = med_new; } else if (vc->v[1] == -1) { - vc->v[1]= med_new->v1; - vc->e[1]= med_new; + vc->v[1] = med_new->v1; + vc->e[1] = med_new; } else { - vc->v[0]= vc->v[1]= -2; /* erro value - don't use, 3 edges on vert */ + vc->v[0] = vc->v[1] = -2; /* erro value - don't use, 3 edges on vert */ } } /* find the first vert */ - vc= vert_connect; - for (i=0; i < totvert; i++, vc++) { + vc = vert_connect; + for (i = 0; i < totvert; i++, vc++) { /* Now do search for connected verts, order all edges and flip them * so resulting faces are flipped the right way */ - vc_tot_linked= 0; /* count the number of linked verts for this loop */ + vc_tot_linked = 0; /* count the number of linked verts for this loop */ if (vc->flag == 0) { - int v_best=-1, ed_loop_closed=0; /* vert and vert new */ + int v_best = -1, ed_loop_closed = 0; /* vert and vert new */ ScrewVertIter lt_iter; - int ed_loop_flip= 0; /* compiler complains if not initialized, but it should be initialized below */ - float fl= -1.0f; + float fl = -1.0f; + + /* compiler complains if not initialized, but it should be initialized below */ + int ed_loop_flip = 0; /*printf("Loop on connected vert: %i\n", i);*/ - for (j=0; j<2; j++) { + for (j = 0; j < 2; j++) { /*printf("\tSide: %i\n", j);*/ screwvert_iter_init(<_iter, vert_connect, i, j); if (j == 1) { @@ -470,15 +474,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (lt_iter.v_poin->flag) { /*printf("\t\t\tBreaking Found end\n");*/ //endpoints[0]= endpoints[1]= -1; - ed_loop_closed= 1; /* circle */ + ed_loop_closed = 1; /* circle */ break; } - lt_iter.v_poin->flag= 1; + lt_iter.v_poin->flag = 1; vc_tot_linked++; /*printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist);*/ if (fl <= lt_iter.v_poin->dist) { - fl= lt_iter.v_poin->dist; - v_best= lt_iter.v; + fl = lt_iter.v_poin->dist; + v_best = lt_iter.v; /*printf("\t\t\tVERT BEST: %i\n", v_best);*/ } screwvert_iter_step(<_iter); @@ -495,13 +499,13 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*printf("Done Looking - vc_tot_linked: %i\n", vc_tot_linked);*/ - if (vc_tot_linked>1) { + if (vc_tot_linked > 1) { float vf_1, vf_2, vf_best; - vc_tmp= &vert_connect[v_best]; + vc_tmp = &vert_connect[v_best]; - tmpf1= vert_connect[vc_tmp->v[0]].co; - tmpf2= vert_connect[vc_tmp->v[1]].co; + tmpf1 = vert_connect[vc_tmp->v[0]].co; + tmpf2 = vert_connect[vc_tmp->v[1]].co; /* edge connects on each side! */ @@ -509,15 +513,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*printf("Verts on each side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ /* find out which is higher */ - vf_1= tmpf1[ltmd->axis]; - vf_2= tmpf2[ltmd->axis]; - vf_best= vc_tmp->co[ltmd->axis]; + vf_1 = tmpf1[ltmd->axis]; + vf_2 = tmpf2[ltmd->axis]; + vf_best = vc_tmp->co[ltmd->axis]; if (vf_1 < vf_best && vf_best < vf_2) { - ed_loop_flip= 0; + ed_loop_flip = 0; } else if (vf_1 > vf_best && vf_best > vf_2) { - ed_loop_flip= 1; + ed_loop_flip = 1; } else { /* not so simple to work out which edge is higher */ @@ -527,20 +531,20 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, normalize_v3(tmp_vec2); if (tmp_vec1[ltmd->axis] < tmp_vec2[ltmd->axis]) { - ed_loop_flip= 1; + ed_loop_flip = 1; } else { - ed_loop_flip= 0; + ed_loop_flip = 0; } } } else if (vc_tmp->v[0] >= 0) { /*vertex only connected on 1 side */ /*printf("Verts on ONE side (%i %i)\n", vc_tmp->v[0], vc_tmp->v[1]);*/ if (tmpf1[ltmd->axis] < vc_tmp->co[ltmd->axis]) { /* best is above */ - ed_loop_flip= 1; + ed_loop_flip = 1; } else { /* best is below or even... in even case we cant know whet to do. */ - ed_loop_flip= 0; + ed_loop_flip = 0; } } @@ -557,31 +561,31 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, * note: flip is now done at face level so copying vgroup slizes is easier */ #if 0 if (do_flip) - ed_loop_flip= !ed_loop_flip; + ed_loop_flip = !ed_loop_flip; #endif if (angle < 0.0f) - ed_loop_flip= !ed_loop_flip; + ed_loop_flip = !ed_loop_flip; /* if its closed, we only need 1 loop */ - for (j=ed_loop_closed; j<2; j++) { + for (j = ed_loop_closed; j < 2; j++) { /*printf("Ordering Side J %i\n", j);*/ screwvert_iter_init(<_iter, vert_connect, v_best, j); /*printf("\n\nStarting - Loop\n");*/ - lt_iter.v_poin->flag= 1; /* so a non loop will traverse the other side */ + lt_iter.v_poin->flag = 1; /* so a non loop will traverse the other side */ /* If this is the vert off the best vert and * the best vert has 2 edges connected too it * then swap the flip direction */ if (j == 1 && (vc_tmp->v[0] > -1) && (vc_tmp->v[1] > -1)) - ed_loop_flip= !ed_loop_flip; + ed_loop_flip = !ed_loop_flip; while (lt_iter.v_poin && lt_iter.v_poin->flag != 2) { /*printf("\tOrdering Vert V %i\n", lt_iter.v);*/ - lt_iter.v_poin->flag= 2; + lt_iter.v_poin->flag = 2; if (lt_iter.e) { if (lt_iter.v == lt_iter.e->v1) { if (ed_loop_flip == 0) { @@ -589,8 +593,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2); } /* else { - printf("\t\t\tFlipping Not 0\n"); - }*/ + printf("\t\t\tFlipping Not 0\n"); + }*/ } else if (lt_iter.v == lt_iter.e->v2) { if (ed_loop_flip == 1) { @@ -598,16 +602,16 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, SWAP(unsigned int, lt_iter.e->v1, lt_iter.e->v2); } /* else { - printf("\t\t\tFlipping Not 1\n"); - }*/ + printf("\t\t\tFlipping Not 1\n"); + }*/ } /* else { - printf("\t\tIncorrect edge topology"); - }*/ + printf("\t\tIncorrect edge topology"); + }*/ } /* else { - printf("\t\tNo Edge at this point\n"); - }*/ + printf("\t\tNo Edge at this point\n"); + }*/ screwvert_iter_step(<_iter); } } @@ -676,23 +680,23 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } else { - mv_orig= mvert_orig; - mv_new= mvert_new; + mv_orig = mvert_orig; + mv_new = mvert_new; - for (i=0; i < totvert; i++, mv_new++, mv_orig++) { + for (i = 0; i < totvert; i++, mv_new++, mv_orig++) { copy_v3_v3(mv_new->co, mv_orig->co); } } /* done with edge connectivity based normal flipping */ /* Add Faces */ - for (step=1; step < step_tot; step++) { - const int varray_stride= totvert * step; + for (step = 1; step < step_tot; step++) { + const int varray_stride = totvert * step; float step_angle; float nor_tx[3]; float mat[4][4]; /* Rotation Matrix */ - step_angle= (angle / (step_tot - (!close))) * step; + step_angle = (angle / (step_tot - (!close))) * step; if (ltmd->ob_axis) { axis_angle_to_mat3(mat3, axis_vec, step_angle); @@ -705,15 +709,15 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (screw_ofs) - madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot-1))); + madd_v3_v3fl(mat[3], axis_vec, screw_ofs * ((float)step / (float)(step_tot - 1))); /* copy a slice */ DM_copy_vert_data(dm, result, 0, varray_stride, totvert); - mv_new_base= mvert_new; - mv_new= &mvert_new[varray_stride]; /* advance to the next slice */ + mv_new_base = mvert_new; + mv_new = &mvert_new[varray_stride]; /* advance to the next slice */ - for (j=0; jv1= varray_stride + j; - med_new->v2= med_new->v1 - totvert; - med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; + med_new->v1 = varray_stride + j; + med_new->v2 = med_new->v1 - totvert; + med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; med_new++; } } @@ -750,34 +754,34 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /* we can avoid if using vert alloc trick */ if (vert_connect) { MEM_freeN(vert_connect); - vert_connect= NULL; + vert_connect = NULL; } if (close) { /* last loop of edges, previous loop dosnt account for the last set of edges */ - const int varray_stride= (step_tot - 1) * totvert; + const int varray_stride = (step_tot - 1) * totvert; - for (i=0; iv1= i; - med_new->v2= varray_stride + i; - med_new->flag= ME_EDGEDRAW|ME_EDGERENDER; + for (i = 0; i < totvert; i++) { + med_new->v1 = i; + med_new->v2 = varray_stride + i; + med_new->flag = ME_EDGEDRAW | ME_EDGERENDER; med_new++; } } - mp_new= mpoly_new; - ml_new= mloop_new; - med_new_firstloop= medge_new; + mp_new = mpoly_new; + ml_new = mloop_new; + med_new_firstloop = medge_new; /* more of an offset in this case */ edge_offset = totedge + (totvert * (step_tot - (close ? 0 : 1))); - for (i=0; i < totedge; i++, med_new_firstloop++) { + for (i = 0; i < totedge; i++, med_new_firstloop++) { /* for each edge, make a cylinder of quads */ - i1= med_new_firstloop->v1; - i2= med_new_firstloop->v2; + i1 = med_new_firstloop->v1; + i2 = med_new_firstloop->v2; - for (step=0; step < step_tot-1; step++) { + for (step = 0; step < step_tot - 1; step++) { /* new face */ if (do_flip) { @@ -806,18 +810,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp_new->loopstart = mpoly_index * 4; mp_new->totloop = 4; - mp_new->flag= ME_SMOOTH; - origindex[mpoly_index]= ORIGINDEX_NONE; + mp_new->flag = ME_SMOOTH; + origindex[mpoly_index] = ORIGINDEX_NONE; mp_new++; ml_new += 4; mpoly_index++; /* new vertical edge */ if (step) { /* The first set is already dome */ - med_new->v1= i1; - med_new->v2= i2; - med_new->flag= med_new_firstloop->flag; - med_new->crease= med_new_firstloop->crease; + med_new->v1 = i1; + med_new->v2 = i2; + med_new->flag = med_new_firstloop->flag; + med_new->crease = med_new_firstloop->crease; med_new++; } i1 += totvert; @@ -851,18 +855,18 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp_new->loopstart = mpoly_index * 4; mp_new->totloop = 4; - mp_new->flag= ME_SMOOTH; - origindex[mpoly_index]= ORIGINDEX_NONE; + mp_new->flag = ME_SMOOTH; + origindex[mpoly_index] = ORIGINDEX_NONE; mp_new++; ml_new += 4; mpoly_index++; } /* new vertical edge */ - med_new->v1= i1; - med_new->v2= i2; - med_new->flag= med_new_firstloop->flag & ~ME_LOOSEEDGE; - med_new->crease= med_new_firstloop->crease; + med_new->v1 = i1; + med_new->v2 = i2; + med_new->flag = med_new_firstloop->flag & ~ME_LOOSEEDGE; + med_new->crease = med_new_firstloop->crease; med_new++; } @@ -871,7 +875,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, { i = 0; printf("\n"); - for ( ; i < maxPolys * 4; i += 4) { + for (; i < maxPolys * 4; i += 4) { int ii; ml_new = mloop_new + i; ii = findEd(medge_new, maxEdges, ml_new[0].v, ml_new[1].v); @@ -904,39 +908,39 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ScrewModifierData *ltmd= (ScrewModifierData*) md; + ScrewModifierData *ltmd = (ScrewModifierData *) md; if (ltmd->ob_axis) { - DagNode *curNode= dag_get_node(forest, ltmd->ob_axis); + DagNode *curNode = dag_get_node(forest, ltmd->ob_axis); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, - "Screw Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, + "Screw Modifier"); } } static void foreachObjectLink( - ModifierData *md, Object *ob, - void (*walk)(void *userData, Object *ob, Object **obpoin), - void *userData) + ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), + void *userData) { - ScrewModifierData *ltmd= (ScrewModifierData*) md; + ScrewModifierData *ltmd = (ScrewModifierData *) md; walk(userData, ob, <md->ob_axis); } /* This dosnt work with material*/ static DerivedMesh *applyModifierEM( - ModifierData *md, - Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + ModifierData *md, + Object *ob, + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } static int dependsOnTime(ModifierData *UNUSED(md)) @@ -951,10 +955,10 @@ ModifierTypeInfo modifierType_Screw = { /* structSize */ sizeof(ScrewModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index a91019b0228..3353382fa3d 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -49,76 +49,75 @@ #include "MEM_guardedalloc.h" static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *UNUSED(derivedData), - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *UNUSED(derivedData), + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - KeyBlock *kb= ob_get_keyblock(ob); + KeyBlock *kb = ob_get_keyblock(ob); float (*deformedVerts)[3]; if (kb && kb->totelem == numVerts) { - deformedVerts= (float(*)[3])do_ob_key(md->scene, ob); + deformedVerts = (float(*)[3])do_ob_key(md->scene, ob); if (deformedVerts) { - memcpy(vertexCos, deformedVerts, sizeof(float)*3*numVerts); + memcpy(vertexCos, deformedVerts, sizeof(float) * 3 * numVerts); MEM_freeN(deformedVerts); } } } static void deformMatrices(ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) + float (*vertexCos)[3], float (*defMats)[3][3], int numVerts) { - Key *key= ob_get_key(ob); - KeyBlock *kb= ob_get_keyblock(ob); + Key *key = ob_get_key(ob); + KeyBlock *kb = ob_get_keyblock(ob); float scale[3][3]; (void)vertexCos; /* unused */ - if (kb && kb->totelem==numVerts && kb!=key->refkey) { + if (kb && kb->totelem == numVerts && kb != key->refkey) { int a; if (ob->shapeflag & OB_SHAPE_LOCK) scale_m3_fl(scale, 1); else scale_m3_fl(scale, kb->curval); - for (a=0; atype == KEY_RELATIVE) - deformVerts(md, ob, derivedData, vertexCos, numVerts, 0, 0); + deformVerts(md, ob, derivedData, vertexCos, numVerts, 0); } static void deformMatricesEM(ModifierData *UNUSED(md), Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *UNUSED(derivedData), - float (*vertexCos)[3], - float (*defMats)[3][3], - int numVerts) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *UNUSED(derivedData), + float (*vertexCos)[3], + float (*defMats)[3][3], + int numVerts) { - Key *key= ob_get_key(ob); - KeyBlock *kb= ob_get_keyblock(ob); + Key *key = ob_get_key(ob); + KeyBlock *kb = ob_get_keyblock(ob); float scale[3][3]; (void)vertexCos; /* unused */ - if (kb && kb->totelem==numVerts && kb!=key->refkey) { + if (kb && kb->totelem == numVerts && kb != key->refkey) { int a; scale_m3_fl(scale, kb->curval); - for (a=0; ashrinkType = MOD_SHRINKWRAP_NEAREST_SURFACE; smd->shrinkOpts = MOD_SHRINKWRAP_PROJECT_ALLOW_POS_DIR; - smd->keepDist = 0.0f; + smd->keepDist = 0.0f; - smd->target = NULL; - smd->auxTarget = NULL; + smd->target = NULL; + smd->auxTarget = NULL; } static void copyData(ModifierData *md, ModifierData *target) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*)md; - ShrinkwrapModifierData *tsmd = (ShrinkwrapModifierData*)target; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *)md; + ShrinkwrapModifierData *tsmd = (ShrinkwrapModifierData *)target; - tsmd->target = smd->target; + tsmd->target = smd->target; tsmd->auxTarget = smd->auxTarget; BLI_strncpy(tsmd->vgroup_name, smd->vgroup_name, sizeof(tsmd->vgroup_name)); - tsmd->keepDist = smd->keepDist; - tsmd->shrinkType= smd->shrinkType; - tsmd->shrinkOpts= smd->shrinkOpts; + tsmd->keepDist = smd->keepDist; + tsmd->shrinkType = smd->shrinkType; + tsmd->shrinkOpts = smd->shrinkOpts; tsmd->projAxis = smd->projAxis; tsmd->subsurfLevels = smd->subsurfLevels; } @@ -97,94 +97,96 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; return !smd->target; } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; walk(userData, ob, &smd->target); walk(userData, ob, &smd->auxTarget); } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); /* ensure we get a CDDM with applied vertex coords */ if (dataMask) - dm= get_cddm(ob, NULL, dm, vertexCos); + dm = get_cddm(ob, NULL, dm, vertexCos); - shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts); + shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); } -static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) +static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editData, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); /* ensure we get a CDDM with applied vertex coords */ if (dataMask) - dm= get_cddm(ob, editData, dm, vertexCos); + dm = get_cddm(ob, editData, dm, vertexCos); - shrinkwrapModifier_deform((ShrinkwrapModifierData*)md, ob, dm, vertexCos, numVerts); + shrinkwrapModifier_deform((ShrinkwrapModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - ShrinkwrapModifierData *smd = (ShrinkwrapModifierData*) md; + ShrinkwrapModifierData *smd = (ShrinkwrapModifierData *) md; if (smd->target) - dag_add_relation(forest, dag_get_node(forest, smd->target), obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); + dag_add_relation(forest, dag_get_node(forest, smd->target), obNode, + DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); if (smd->auxTarget) - dag_add_relation(forest, dag_get_node(forest, smd->auxTarget), obNode, DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); + dag_add_relation(forest, dag_get_node(forest, smd->auxTarget), obNode, + DAG_RL_OB_DATA | DAG_RL_DATA_DATA, "Shrinkwrap Modifier"); } ModifierTypeInfo modifierType_Shrinkwrap = { - /* name */ "Shrinkwrap", - /* structName */ "ShrinkwrapModifierData", - /* structSize */ sizeof(ShrinkwrapModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* name */ "Shrinkwrap", + /* structName */ "ShrinkwrapModifierData", + /* structSize */ sizeof(ShrinkwrapModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ NULL, - /* applyModifierEM */ NULL, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ NULL, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ NULL, - /* dependsOnNormals */ NULL, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ NULL, + /* applyModifierEM */ NULL, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ NULL, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ NULL, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 5ac52a97315..36c052440b6 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -68,10 +68,10 @@ static void axis_limit(int axis, const float limits[2], float co[3], float dcut[ static void simpleDeform_taper(const float factor, const float dcut[3], float *co) { float x = co[0], y = co[1], z = co[2]; - float scale = z*factor; + float scale = z * factor; - co[0] = x + x*scale; - co[1] = y + y*scale; + co[0] = x + x * scale; + co[1] = y + y * scale; co[2] = z; if (dcut) { @@ -86,11 +86,11 @@ static void simpleDeform_stretch(const float factor, const float dcut[3], float float x = co[0], y = co[1], z = co[2]; float scale; - scale = (z*z*factor-factor + 1.0f); + scale = (z * z * factor - factor + 1.0f); - co[0] = x*scale; - co[1] = y*scale; - co[2] = z*(1.0f+factor); + co[0] = x * scale; + co[1] = y * scale; + co[2] = z * (1.0f + factor); if (dcut) { co[0] += dcut[0]; @@ -104,12 +104,12 @@ static void simpleDeform_twist(const float factor, const float *dcut, float *co) float x = co[0], y = co[1], z = co[2]; float theta, sint, cost; - theta = z*factor; + theta = z * factor; sint = sin(theta); cost = cos(theta); - co[0] = x*cost - y*sint; - co[1] = x*sint + y*cost; + co[0] = x * cost - y * sint; + co[1] = x * sint + y * cost; co[2] = z; if (dcut) { @@ -124,19 +124,19 @@ static void simpleDeform_bend(const float factor, const float dcut[3], float *co float x = co[0], y = co[1], z = co[2]; float theta, sint, cost; - theta = x*factor; + theta = x * factor; sint = sin(theta); cost = cos(theta); if (fabsf(factor) > 1e-7f) { - co[0] = -(y-1.0f/factor)*sint; - co[1] = (y-1.0f/factor)*cost + 1.0f/factor; + co[0] = -(y - 1.0f / factor) * sint; + co[1] = (y - 1.0f / factor) * cost + 1.0f / factor; co[2] = z; } if (dcut) { - co[0] += cost*dcut[0]; - co[1] += sint*dcut[0]; + co[0] += cost * dcut[0]; + co[1] += sint * dcut[0]; co[2] += dcut[2]; } @@ -144,7 +144,8 @@ static void simpleDeform_bend(const float factor, const float dcut[3], float *co /* simple deform modifier */ -static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, float (*vertexCos)[3], int numVerts) +static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object *ob, struct DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { static const float lock_axis[2] = {0.0f, 0.0f}; @@ -152,17 +153,17 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object int limit_axis = 0; float smd_limit[2], smd_factor; SpaceTransform *transf = NULL, tmp_transf; - void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; //Mode callback + void (*simpleDeform_callback)(const float factor, const float dcut[3], float *co) = NULL; /* Mode callback */ int vgroup; MDeformVert *dvert; - //Safe-check - if (smd->origin == ob) smd->origin = NULL; //No self references + /* Safe-check */ + if (smd->origin == ob) smd->origin = NULL; /* No self references */ if (smd->limit[0] < 0.0f) smd->limit[0] = 0.0f; if (smd->limit[0] > 1.0f) smd->limit[0] = 1.0f; - smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); //Upper limit >= than lower limit + smd->limit[0] = MIN2(smd->limit[0], smd->limit[1]); /* Upper limit >= than lower limit */ //Calculate matrixs do convert between coordinate spaces if (smd->origin) { @@ -185,7 +186,7 @@ static void SimpleDeformModifier_do(SimpleDeformModifierData *smd, struct Object float lower = FLT_MAX; float upper = -FLT_MAX; - for (i=0; ilimit[1]; - smd_limit[0] = lower + (upper-lower)*smd->limit[0]; + /* SMD values are normalized to the BV, calculate the absolut values */ + smd_limit[1] = lower + (upper - lower) * smd->limit[1]; + smd_limit[0] = lower + (upper - lower) * smd->limit[0]; - smd_factor = smd->factor / MAX2(FLT_EPSILON, smd_limit[1]-smd_limit[0]); + smd_factor = smd->factor / MAX2(FLT_EPSILON, smd_limit[1] - smd_limit[0]); } modifier_get_vgroup(ob, dm, smd->vgroup_name, &dvert, &vgroup); switch (smd->mode) { - case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; - case MOD_SIMPLEDEFORM_MODE_BEND: simpleDeform_callback = simpleDeform_bend; break; - case MOD_SIMPLEDEFORM_MODE_TAPER: simpleDeform_callback = simpleDeform_taper; break; - case MOD_SIMPLEDEFORM_MODE_STRETCH: simpleDeform_callback = simpleDeform_stretch; break; + case MOD_SIMPLEDEFORM_MODE_TWIST: simpleDeform_callback = simpleDeform_twist; break; + case MOD_SIMPLEDEFORM_MODE_BEND: simpleDeform_callback = simpleDeform_bend; break; + case MOD_SIMPLEDEFORM_MODE_TAPER: simpleDeform_callback = simpleDeform_taper; break; + case MOD_SIMPLEDEFORM_MODE_STRETCH: simpleDeform_callback = simpleDeform_stretch; break; default: - return; //No simpledeform mode? + return; /* No simpledeform mode? */ } - for (i=0; imode = MOD_SIMPLEDEFORM_MODE_TWIST; smd->axis = 0; @@ -260,14 +261,14 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; - SimpleDeformModifierData *tsmd = (SimpleDeformModifierData*)target; + SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; + SimpleDeformModifierData *tsmd = (SimpleDeformModifierData *)target; - tsmd->mode = smd->mode; + tsmd->mode = smd->mode; tsmd->axis = smd->axis; - tsmd->origin= smd->origin; - tsmd->originOpts= smd->originOpts; - tsmd->factor= smd->factor; + tsmd->origin = smd->origin; + tsmd->originOpts = smd->originOpts; + tsmd->factor = smd->factor; memcpy(tsmd->limit, smd->limit, sizeof(tsmd->limit)); BLI_strncpy(tsmd->vgroup_name, smd->vgroup_name, sizeof(tsmd->vgroup_name)); } @@ -284,29 +285,29 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) return dataMask; } -static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) +static void foreachObjectLink(ModifierData *md, Object *ob, + void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; + SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; walk(userData, ob, &smd->origin); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - SimpleDeformModifierData *smd = (SimpleDeformModifierData*)md; + SimpleDeformModifierData *smd = (SimpleDeformModifierData *)md; if (smd->origin) dag_add_relation(forest, dag_get_node(forest, smd->origin), obNode, DAG_RL_OB_DATA, "SimpleDeform Modifier"); } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); @@ -314,19 +315,19 @@ static void deformVerts(ModifierData *md, Object *ob, /* we implement requiredDataMask but thats not really useful since * mesh_calc_modifiers pass a NULL derivedData */ if (dataMask) - dm= get_dm(ob, NULL, dm, NULL, 0); + dm = get_dm(ob, NULL, dm, NULL, 0); - SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); } static void deformVertsEM(ModifierData *md, Object *ob, - struct BMEditMesh *editData, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts) + struct BMEditMesh *editData, + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts) { DerivedMesh *dm = derivedData; CustomDataMask dataMask = requiredDataMask(ob, md); @@ -334,9 +335,9 @@ static void deformVertsEM(ModifierData *md, Object *ob, /* we implement requiredDataMask but thats not really useful since * mesh_calc_modifiers pass a NULL derivedData */ if (dataMask) - dm= get_dm(ob, editData, dm, NULL, 0); + dm = get_dm(ob, editData, dm, NULL, 0); - SimpleDeformModifier_do((SimpleDeformModifierData*)md, ob, dm, vertexCos, numVerts); + SimpleDeformModifier_do((SimpleDeformModifierData *)md, ob, dm, vertexCos, numVerts); if (dm != derivedData) dm->release(dm); @@ -349,10 +350,10 @@ ModifierTypeInfo modifierType_SimpleDeform = { /* structSize */ sizeof(SimpleDeformModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 706c9817a0a..7092ef04d0f 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -57,7 +57,7 @@ static void initData(ModifierData *md) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; smd->domain = NULL; smd->flow = NULL; @@ -68,27 +68,26 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SmokeModifierData *smd = (SmokeModifierData*)md; - SmokeModifierData *tsmd = (SmokeModifierData*)target; + SmokeModifierData *smd = (SmokeModifierData *)md; + SmokeModifierData *tsmd = (SmokeModifierData *)target; smokeModifier_copy(smd, tsmd); } static void freeData(ModifierData *md) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; - smokeModifier_free (smd); + smokeModifier_free(smd); } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + ModifierApplyFlag UNUSED(flag)) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; DerivedMesh *dm = get_cddm(ob, NULL, derivedData, vertexCos); smokeModifier_do(smd, md->scene, ob, dm); @@ -103,9 +102,9 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *scene, - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *scene, + Object *UNUSED(ob), + DagNode *obNode) { SmokeModifierData *smd = (SmokeModifierData *) md; @@ -121,7 +120,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, // check for initialized smoke object if (smd2 && (smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) { DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Flow"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow"); } } } @@ -134,7 +133,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, // check for initialized smoke object if (smd2 && (smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll) { DagNode *curNode = dag_get_node(forest, go->ob); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Coll"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Coll"); } } } @@ -142,12 +141,12 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, else { Base *base = scene->base.first; - for ( ; base; base = base->next) { + for (; base; base = base->next) { SmokeModifierData *smd2 = (SmokeModifierData *)modifiers_findByType(base->object, eModifierType_Smoke); if (smd2 && (((smd2->type & MOD_SMOKE_TYPE_FLOW) && smd2->flow) || ((smd2->type & MOD_SMOKE_TYPE_COLL) && smd2->coll))) { DagNode *curNode = dag_get_node(forest, base->object); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, "Smoke Flow/Coll"); + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "Smoke Flow/Coll"); } } } @@ -155,11 +154,11 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - SmokeModifierData *smd = (SmokeModifierData*) md; + SmokeModifierData *smd = (SmokeModifierData *) md; - if (smd->type==MOD_SMOKE_TYPE_DOMAIN && smd->domain) { + if (smd->type == MOD_SMOKE_TYPE_DOMAIN && smd->domain) { walk(userData, ob, (ID **)&smd->domain->coll_group); walk(userData, ob, (ID **)&smd->domain->fluid_group); walk(userData, ob, (ID **)&smd->domain->eff_group); @@ -175,9 +174,9 @@ ModifierTypeInfo modifierType_Smoke = { /* structName */ "SmokeModifierData", /* structSize */ sizeof(SmokeModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_UsesPointCache - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_UsesPointCache | + eModifierTypeFlag_Single, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index b909e1f6512..99a5dcb5ef5 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - SmoothModifierData *smd = (SmoothModifierData*) md; + SmoothModifierData *smd = (SmoothModifierData *) md; smd->fac = 0.5f; smd->repeat = 1; @@ -61,8 +61,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SmoothModifierData *smd = (SmoothModifierData*) md; - SmoothModifierData *tsmd = (SmoothModifierData*) target; + SmoothModifierData *smd = (SmoothModifierData *) md; + SmoothModifierData *tsmd = (SmoothModifierData *) target; tsmd->fac = smd->fac; tsmd->repeat = smd->repeat; @@ -72,10 +72,10 @@ static void copyData(ModifierData *md, ModifierData *target) static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - SmoothModifierData *smd = (SmoothModifierData*) md; + SmoothModifierData *smd = (SmoothModifierData *) md; short flag; - flag = smd->flag & (MOD_SMOOTH_X|MOD_SMOOTH_Y|MOD_SMOOTH_Z); + flag = smd->flag & (MOD_SMOOTH_X | MOD_SMOOTH_Y | MOD_SMOOTH_Z); /* disable if modifier is off for X, Y and Z or if factor is 0 */ if ((smd->fac == 0.0f) || flag == 0) return 1; @@ -95,8 +95,8 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void smoothModifier_do( - SmoothModifierData *smd, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + SmoothModifierData *smd, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { MDeformVert *dvert = NULL; MEdge *medges = NULL; @@ -105,11 +105,11 @@ static void smoothModifier_do( unsigned char *uctmp; float *ftmp, fac, facm; - ftmp = (float*)MEM_callocN(3*sizeof(float)*numVerts, - "smoothmodifier_f"); + ftmp = (float *)MEM_callocN(3 * sizeof(float) * numVerts, + "smoothmodifier_f"); if (!ftmp) return; - uctmp = (unsigned char*)MEM_callocN(sizeof(unsigned char)*numVerts, - "smoothmodifier_uc"); + uctmp = (unsigned char *)MEM_callocN(sizeof(unsigned char) * numVerts, + "smoothmodifier_uc"); if (!uctmp) { if (ftmp) MEM_freeN(ftmp); return; @@ -139,8 +139,8 @@ static void smoothModifier_do( mid_v3_v3v3(fvec, v1, v2); - v1 = &ftmp[idx1*3]; - v2 = &ftmp[idx2*3]; + v1 = &ftmp[idx1 * 3]; + v2 = &ftmp[idx2 * 3]; if (uctmp[idx1] < 255) { uctmp[idx1]++; @@ -153,16 +153,16 @@ static void smoothModifier_do( } if (dvert) { - MDeformVert *dv= dvert; + MDeformVert *dv = dvert; for (i = 0; i < numVerts; i++, dv++) { float f, fm, facw, *fp, *v; short flag = smd->flag; v = vertexCos[i]; - fp = &ftmp[i*3]; + fp = &ftmp[i * 3]; - f= defvert_find_weight(dv, defgrp_index); + f = defvert_find_weight(dv, defgrp_index); if (f <= 0.0f) continue; f *= fac; @@ -187,7 +187,7 @@ static void smoothModifier_do( short flag = smd->flag; v = vertexCos[i]; - fp = &ftmp[i*3]; + fp = &ftmp[i * 3]; /* fp is the sum of uctmp[i] verts, so must be averaged */ facw = 0.0f; @@ -204,19 +204,18 @@ static void smoothModifier_do( } - memset(ftmp, 0, 3*sizeof(float)*numVerts); - memset(uctmp, 0, sizeof(unsigned char)*numVerts); + memset(ftmp, 0, 3 * sizeof(float) * numVerts); + memset(uctmp, 0, sizeof(unsigned char) * numVerts); } MEM_freeN(ftmp); MEM_freeN(uctmp); } -static void deformVerts( - ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) +static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, + float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag)) { - DerivedMesh *dm= get_dm(ob, NULL, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, NULL, derivedData, NULL, 0); smoothModifier_do((SmoothModifierData *)md, ob, dm, vertexCos, numVerts); @@ -226,10 +225,10 @@ static void deformVerts( } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm= get_dm(ob, editData, derivedData, NULL, 0); + DerivedMesh *dm = get_dm(ob, editData, derivedData, NULL, 0); smoothModifier_do((SmoothModifierData *)md, ob, dm, vertexCos, numVerts); @@ -244,8 +243,8 @@ ModifierTypeInfo modifierType_Smooth = { /* structName */ "SmoothModifierData", /* structSize */ sizeof(SmoothModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 01b1b0b52af..75a98bc0746 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -45,11 +45,10 @@ #include "MOD_modifiertypes.h" static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *UNUSED(derivedData), - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *UNUSED(derivedData), + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { sbObjectStep(md->scene, ob, (float)md->scene->r.cfra, vertexCos, numVerts); } @@ -65,9 +64,9 @@ ModifierTypeInfo modifierType_Softbody = { /* structName */ "SoftbodyModifierData", /* structSize */ sizeof(SoftbodyModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_RequiresOriginalData - | eModifierTypeFlag_Single, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_RequiresOriginalData | + eModifierTypeFlag_Single, /* copyData */ NULL, /* deformVerts */ deformVerts, diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index 71839312cf5..264d84af81e 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -66,7 +66,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) float (*face_nors)[3]; float *f_no; - int calc_face_nors= 0; + int calc_face_nors = 0; numVerts = dm->getNumVerts(dm); numEdges = dm->getNumEdges(dm); @@ -124,15 +124,18 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) f_no = face_nors[i]; if (calc_face_nors) - mesh_calc_poly_normal(mp, mloop+mp->loopstart, mvert, f_no); + mesh_calc_poly_normal(mp, mloop + mp->loopstart, mvert, f_no); ml = mloop + mp->loopstart; - for (j=0; jtotloop; j++, ml++) { + for (j = 0; j < mp->totloop; j++, ml++) { NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(ml->v, ME_POLY_LOOP_NEXT(mloop, mp, j)->v); } } - for (edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) { + for (edge_iter = BLI_edgehashIterator_new(edge_hash); + !BLI_edgehashIterator_isDone(edge_iter); + BLI_edgehashIterator_step(edge_iter)) + { /* Get the edge vert indices, and edge value (the face indices that use it)*/ BLI_edgehashIterator_getKey(edge_iter, &ed_v1, &ed_v2); edge_ref = BLI_edgehashIterator_getValue(edge_iter); @@ -148,7 +151,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) /* only one face attached to that edge */ /* an edge without another attached- the weight on this is * undefined, M_PI/2 is 90d in radians and that seems good enough */ - mul_v3_v3fl(edge_normal, face_nors[edge_ref->f1], M_PI/2); + mul_v3_v3fl(edge_normal, face_nors[edge_ref->f1], M_PI / 2); } add_v3_v3(temp_nors[ed_v1], edge_normal); add_v3_v3(temp_nors[ed_v2], edge_normal); @@ -168,7 +171,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3]) static void initData(ModifierData *md) { - SolidifyModifierData *smd = (SolidifyModifierData*) md; + SolidifyModifierData *smd = (SolidifyModifierData *) md; smd->offset = 0.01f; smd->offset_fac = -1.0f; smd->flag = MOD_SOLIDIFY_RIM; @@ -176,8 +179,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SolidifyModifierData *smd = (SolidifyModifierData*) md; - SolidifyModifierData *tsmd = (SolidifyModifierData*) target; + SolidifyModifierData *smd = (SolidifyModifierData *) md; + SolidifyModifierData *tsmd = (SolidifyModifierData *) target; tsmd->offset = smd->offset; tsmd->offset_fac = smd->offset_fac; tsmd->crease_inner = smd->crease_inner; @@ -189,7 +192,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - SolidifyModifierData *smd = (SolidifyModifierData*) md; + SolidifyModifierData *smd = (SolidifyModifierData *) md; CustomDataMask dataMask = 0; /* ask for vertexgroups if we need them */ @@ -200,13 +203,12 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *dm, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *dm, + ModifierApplyFlag UNUSED(flag)) { int i; DerivedMesh *result; - const SolidifyModifierData *smd = (SolidifyModifierData*) md; + const SolidifyModifierData *smd = (SolidifyModifierData *) md; MVert *mv, *mvert, *orig_mvert; MEdge *ed, *medge, *orig_medge; @@ -215,36 +217,36 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, const int numVerts = dm->getNumVerts(dm); const int numEdges = dm->getNumEdges(dm); const int numFaces = dm->getNumPolys(dm); - int numLoops=0, newLoops=0, newFaces=0, newEdges=0; + int numLoops = 0, newLoops = 0, newFaces = 0, newEdges = 0; int j; /* only use material offsets if we have 2 or more materials */ - const short mat_nr_max= ob->totcol > 1 ? ob->totcol - 1 : 0; - const short mat_ofs= mat_nr_max ? smd->mat_ofs : 0; - const short mat_ofs_rim= mat_nr_max ? smd->mat_ofs_rim : 0; + const short mat_nr_max = ob->totcol > 1 ? ob->totcol - 1 : 0; + const short mat_ofs = mat_nr_max ? smd->mat_ofs : 0; + const short mat_ofs_rim = mat_nr_max ? smd->mat_ofs_rim : 0; /* use for edges */ - int *new_vert_arr= NULL; + int *new_vert_arr = NULL; BLI_array_declare(new_vert_arr); - int *new_edge_arr= NULL; + int *new_edge_arr = NULL; BLI_array_declare(new_edge_arr); - int *old_vert_arr = MEM_callocN(sizeof(int)*numVerts, "old_vert_arr in solidify"); + int *old_vert_arr = MEM_callocN(sizeof(int) * numVerts, "old_vert_arr in solidify"); - int *edge_users= NULL; - char *edge_order= NULL; + int *edge_users = NULL; + char *edge_order = NULL; int *edge_origIndex; - float (*vert_nors)[3]= NULL; + float (*vert_nors)[3] = NULL; float (*face_nors_result)[3] = NULL; - const float ofs_orig= - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); - const float ofs_new= smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); - const float offset_fac_vg= smd->offset_fac_vg; - const float offset_fac_vg_inv= 1.0f - smd->offset_fac_vg; + const float ofs_orig = -(((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float ofs_new = smd->offset - (((-smd->offset_fac + 1.0f) * 0.5f) * smd->offset); + const float offset_fac_vg = smd->offset_fac_vg; + const float offset_fac_vg_inv = 1.0f - smd->offset_fac_vg; /* weights */ - MDeformVert *dvert, *dv= NULL; + MDeformVert *dvert, *dv = NULL; const int defgrp_invert = ((smd->flag & MOD_SOLIDIFY_VGROUP_INV) != 0); int defgrp_index; @@ -264,11 +266,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, unsigned int v1, v2; int eidx; - for (i=0, mv=orig_mvert; iflag &= ~ME_VERT_TMP_TAG; } - for (i=0, ed=orig_medge; iv1, ed->v2, SET_INT_IN_POINTER(i)); } @@ -291,14 +293,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } - edge_users= MEM_mallocN(sizeof(int) * numEdges, "solid_mod edges"); - edge_order= MEM_mallocN(sizeof(char) * numEdges, "solid_mod eorder"); + edge_users = MEM_mallocN(sizeof(int) * numEdges, "solid_mod edges"); + edge_order = MEM_mallocN(sizeof(char) * numEdges, "solid_mod eorder"); fill_vn_i(edge_users, numEdges, INVALID_UNUSED); - for (i=0, mp=orig_mpoly; iloopstart, j=0; jtotloop; ml++, j++) { + for (ml = orig_mloop + mp->loopstart, j = 0; j < mp->totloop; ml++, j++) { ADD_EDGE_USER(ml->v, ME_POLY_LOOP_NEXT(orig_mloop, mp, j)->v, j); } } @@ -307,9 +309,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, #undef INVALID_UNUSED #undef INVALID_PAIR - ehi= BLI_edgehashIterator_new(edgehash); + ehi = BLI_edgehashIterator_new(edgehash); for (; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) { - eidx= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); + eidx = GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi)); if (edge_users[eidx] >= 0) { BLI_edgehashIterator_getKey(ehi, &v1, &v2); orig_mvert[v1].flag |= ME_VERT_TMP_TAG; @@ -321,7 +323,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } BLI_edgehashIterator_free(ehi); - for (i=0, mv=orig_mvert; iflag & ME_VERT_TMP_TAG) { old_vert_arr[i] = BLI_array_count(new_vert_arr); BLI_array_append(new_vert_arr, i); @@ -335,11 +337,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { - vert_nors= MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq"); + vert_nors = MEM_callocN(sizeof(float) * numVerts * 3, "mod_solid_vno_hq"); dm_calc_normal(dm, vert_nors); } - result = CDDM_from_template(dm, numVerts * 2, (numEdges * 2) + newEdges, 0, (numLoops*2) + newLoops, (numFaces * 2) + newFaces); + result = CDDM_from_template(dm, numVerts * 2, (numEdges * 2) + newEdges, 0, + (numLoops * 2) + newLoops, (numFaces * 2) + newFaces); mpoly = CDDM_get_polys(result); mloop = CDDM_get_loops(result); @@ -363,14 +366,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, /*flip normals*/ mp = mpoly + numFaces; - for (i=0; inumPolyData; i++, mp++) { + for (i = 0; i < dm->numPolyData; i++, mp++) { MLoop *ml2; int e; ml2 = mloop + mp->loopstart + dm->numLoopData; - for (j=0; jtotloop; j++) { - CustomData_copy_data(&dm->loopData, &result->loopData, mp->loopstart+j, - mp->loopstart+(mp->totloop-j-1)+dm->numLoopData, 1); + for (j = 0; j < mp->totloop; j++) { + CustomData_copy_data(&dm->loopData, &result->loopData, mp->loopstart + j, + mp->loopstart + (mp->totloop - j - 1) + dm->numLoopData, 1); } if (mat_ofs) { @@ -379,14 +382,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } e = ml2[0].e; - for (j=0; jtotloop-1; j++) { - ml2[j].e = ml2[j+1].e; + for (j = 0; j < mp->totloop - 1; j++) { + ml2[j].e = ml2[j + 1].e; } - ml2[mp->totloop-1].e = e; + ml2[mp->totloop - 1].e = e; mp->loopstart += dm->numLoopData; - for (j=0; jtotloop; j++) { + for (j = 0; j < mp->totloop; j++) { ml2[j].e += numEdges; ml2[j].v += numVerts; } @@ -396,7 +399,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } } - for (i=0, ed=medge+numEdges; iv1 += numVerts; ed->v2 += numVerts; } @@ -409,14 +412,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, if (ofs_new != 0.0f) { - scalar_short= scalar_short_vgroup= ofs_new / 32767.0f; - mv= mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts); - dv= dvert; - for (i=0; i= ofs_orig) ? 0 : numVerts); + dv = dvert; + for (i = 0; i < numVerts; i++, mv++) { if (dv) { - if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); - else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); - scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; + if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); + else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; dv++; } VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup); @@ -424,14 +427,14 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (ofs_orig != 0.0f) { - scalar_short= scalar_short_vgroup= ofs_orig / 32767.0f; - mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */ - dv= dvert; - for (i=0; i= ofs_orig) ? numVerts : 0); /* as above but swapped, intentional use 'ofs_new' */ + dv = dvert; + for (i = 0; i < numVerts; i++, mv++) { if (dv) { - if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); - else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); - scalar_short_vgroup= (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; + if (defgrp_invert) scalar_short_vgroup = 1.0f - defvert_find_weight(dv, defgrp_index); + else scalar_short_vgroup = defvert_find_weight(dv, defgrp_index); + scalar_short_vgroup = (offset_fac_vg + (scalar_short_vgroup * offset_fac_vg_inv)) * scalar_short; dv++; } VECADDFAC(mv->co, mv->co, mv->no, scalar_short_vgroup); @@ -442,80 +445,93 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, else { /* make a face normal layer if not present */ float (*face_nors)[3]; - int face_nors_calc= 0; + int face_nors_calc = 0; /* same as EM_solidify() in editmesh_lib.c */ - float *vert_angles= MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */ - float *vert_accum= vert_angles + numVerts; - float *face_angles = NULL; - BLI_array_staticdeclare(face_angles, 16); /* BM_NGON_STACK_SIZE */ - int j, vidx; + float *vert_angles = MEM_callocN(sizeof(float) * numVerts * 2, "mod_solid_pair"); /* 2 in 1 */ + float *vert_accum = vert_angles + numVerts; + int vidx; face_nors = CustomData_get_layer(&dm->polyData, CD_NORMAL); if (!face_nors) { face_nors = CustomData_add_layer(&dm->polyData, CD_NORMAL, CD_CALLOC, NULL, dm->numPolyData); - face_nors_calc= 1; + face_nors_calc = 1; } - if (vert_nors==NULL) { - vert_nors= MEM_mallocN(sizeof(float) * numVerts * 3, "mod_solid_vno"); - for (i=0, mv=mvert; ino); } } - for (i=0, mp=mpoly; iloopstart], mvert, face_nors[i]); - - /* just added, calc the normal */ - BLI_array_empty(face_angles); - for (j=0, ml=mloop+mp->loopstart; jtotloop; j++, ml++) { - MLoop *ml_prev = ME_POLY_LOOP_PREV(mloop, mp, j); - MLoop *ml_next = ME_POLY_LOOP_NEXT(mloop, mp, j); + for (i = 0, mp = mpoly; i < numFaces; i++, mp++) { + /* #BKE_mesh_poly_calc_angles logic is inlined here */ + float nor_prev[3]; + float nor_next[3]; - float e1[3], e2[3], angle; - - sub_v3_v3v3(e1, mvert[ml_next->v].co, mvert[ml->v].co); - sub_v3_v3v3(e2, mvert[ml_prev->v].co, mvert[ml->v].co); - angle = (float)M_PI - angle_normalized_v3v3(e1, e2); - BLI_array_append(face_angles, angle); - } - - for (j=0, ml=mloop+mp->loopstart; jtotloop; j++, ml++) { - vidx = ml->v; - vert_accum[vidx] += face_angles[j]; - vert_angles[vidx]+= shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * face_angles[j]; + int i_this = mp->totloop - 1; + int i_next = 0; + + ml = &mloop[mp->loopstart]; + + /* --- not related to angle calc --- */ + if (face_nors_calc) + mesh_calc_poly_normal(mp, ml, mvert, face_nors[i]); + /* --- end non-angle-calc section --- */ + + sub_v3_v3v3(nor_prev, mvert[ml[i_this - 1].v].co, mvert[ml[i_this].v].co); + normalize_v3(nor_prev); + + while (i_next < mp->totloop) { + float angle; + sub_v3_v3v3(nor_next, mvert[ml[i_this].v].co, mvert[ml[i_next].v].co); + normalize_v3(nor_next); + angle = angle_normalized_v3v3(nor_prev, nor_next); + + + /* --- not related to angle calc --- */ + if (angle < FLT_EPSILON) { + angle = FLT_EPSILON; + } + vidx = ml[i_this].v; + vert_accum[vidx] += angle; + vert_angles[vidx] += shell_angle_to_dist(angle_normalized_v3v3(vert_nors[vidx], face_nors[i])) * angle; + /* --- end non-angle-calc section --- */ + + + /* step */ + copy_v3_v3(nor_prev, nor_next); + i_this = i_next; + i_next++; } } - - BLI_array_free(face_angles); /* vertex group support */ if (dvert) { float scalar; - dv= dvert; + dv = dvert; if (defgrp_invert) { - for (i=0; i= ofs_orig) ? 0 : numVerts); + mv = mvert + ((ofs_new >= ofs_orig) ? 0 : numVerts); - for (i=0; ico, vert_nors[i], ofs_new * (vert_angles[i] / vert_accum[i])); } @@ -523,9 +539,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (ofs_orig) { - mv= mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); /* same as above but swapped, intentional use of 'ofs_new' */ + /* same as above but swapped, intentional use of 'ofs_new' */ + mv = mvert + ((ofs_new >= ofs_orig) ? numVerts : 0); - for (i=0; ico, vert_nors[i], ofs_orig * (vert_angles[i] / vert_accum[i])); } @@ -539,46 +556,48 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, MEM_freeN(vert_nors); /* flip vertex normals for copied verts */ - mv= mvert + numVerts; - for (i=0; ino[0]= -mv->no[0]; - mv->no[1]= -mv->no[1]; - mv->no[2]= -mv->no[2]; + mv = mvert + numVerts; + for (i = 0; i < numVerts; i++, mv++) { + mv->no[0] = -mv->no[0]; + mv->no[1] = -mv->no[1]; + mv->no[2] = -mv->no[2]; } if (smd->flag & MOD_SOLIDIFY_RIM) { int *origindex; /* bugger, need to re-calculate the normals for the new edge faces. - * This could be done in many ways, but probably the quickest way is to calculate the average normals for side faces only. + * This could be done in many ways, but probably the quickest way + * is to calculate the average normals for side faces only. * Then blend them with the normals of the edge verts. * - * at the moment its easiest to allocate an entire array for every vertex, even though we only need edge verts - campbell + * at the moment its easiest to allocate an entire array for every vertex, + * even though we only need edge verts - campbell */ #define SOLIDIFY_SIDE_NORMALS #ifdef SOLIDIFY_SIDE_NORMALS /* annoying to allocate these since we only need the edge verts, */ - float (*edge_vert_nos)[3]= MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos"); + float (*edge_vert_nos)[3] = MEM_callocN(sizeof(float) * numVerts * 3, "solidify_edge_nos"); float nor[3]; #endif - const unsigned char crease_rim= smd->crease_rim * 255.0f; - const unsigned char crease_outer= smd->crease_outer * 255.0f; - const unsigned char crease_inner= smd->crease_inner * 255.0f; + const unsigned char crease_rim = smd->crease_rim * 255.0f; + const unsigned char crease_outer = smd->crease_outer * 255.0f; + const unsigned char crease_inner = smd->crease_inner * 255.0f; /* add faces & edges */ - origindex= result->getEdgeDataArray(result, CD_ORIGINDEX); - ed= medge + (numEdges * 2); - for (i=0; iv1= new_vert_arr[i]; - ed->v2= new_vert_arr[i] + numVerts; + origindex = result->getEdgeDataArray(result, CD_ORIGINDEX); + ed = medge + (numEdges * 2); + for (i = 0; i < newEdges; i++, ed++) { + ed->v1 = new_vert_arr[i]; + ed->v2 = new_vert_arr[i] + numVerts; ed->flag |= ME_EDGEDRAW; - origindex[numEdges * 2 + i]= ORIGINDEX_NONE; + origindex[numEdges * 2 + i] = ORIGINDEX_NONE; if (crease_rim) - ed->crease= crease_rim; + ed->crease = crease_rim; } /* faces */ @@ -588,24 +607,24 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp = mpoly + (numFaces * 2); ml = mloop + (numLoops * 2); j = 0; - for (i=0; i= numFaces) { fidx -= numFaces; - flip= 1; + flip = 1; } else { - flip= 0; + flip = 0; } - ed= medge + eidx; + ed = medge + eidx; /* copy most of the face settings */ DM_copy_poly_data(dm, result, fidx, (numFaces * 2) + i, 1); - mp->loopstart = j+numLoops*2; + mp->loopstart = j + numLoops * 2; mp->flag = mpoly[fidx].flag; /* notice we use 'mp->totloop' which is later overwritten, @@ -616,33 +635,33 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, mp->totloop = 4; - CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops*2+j+0, 1); - CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops*2+j+1, 1); - CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops*2+j+2, 1); - CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops*2+j+3, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 0, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 1, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k2, numLoops * 2 + j + 2, 1); + CustomData_copy_data(&dm->loopData, &result->loopData, k1, numLoops * 2 + j + 3, 1); if (flip) { ml[j].v = ed->v1; ml[j++].e = eidx; ml[j].v = ed->v2; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v2]; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2]; - ml[j].v = ed->v2+numVerts; - ml[j++].e = eidx+numEdges; + ml[j].v = ed->v2 + numVerts; + ml[j++].e = eidx + numEdges; - ml[j].v = ed->v1+numVerts; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v1]; + ml[j].v = ed->v1 + numVerts; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v1]; } else { ml[j].v = ed->v2; ml[j++].e = eidx; ml[j].v = ed->v1; - ml[j++].e = numEdges*2 + old_vert_arr[ed->v1]; + ml[j++].e = numEdges * 2 + old_vert_arr[ed->v1]; - ml[j].v = ed->v1+numVerts; - ml[j++].e = eidx+numEdges; + ml[j].v = ed->v1 + numVerts; + ml[j++].e = eidx + numEdges; ml[j].v = ed->v2 + numVerts; ml[j++].e = numEdges * 2 + old_vert_arr[ed->v2]; @@ -660,9 +679,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } if (crease_outer) { /* crease += crease_outer; without wrapping */ - unsigned char *cr= (unsigned char *)&(ed->crease); - int tcr= *cr + crease_outer; - *cr= tcr > 255 ? 255 : tcr; + unsigned char *cr = (unsigned char *)&(ed->crease); + int tcr = *cr + crease_outer; + *cr = tcr > 255 ? 255 : tcr; } if (crease_inner) { @@ -674,9 +693,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, #ifdef SOLIDIFY_SIDE_NORMALS normal_quad_v3(nor, mvert[ml[j - 4].v].co, - mvert[ml[j - 3].v].co, - mvert[ml[j - 2].v].co, - mvert[ml[j - 1].v].co); + mvert[ml[j - 3].v].co, + mvert[ml[j - 2].v].co, + mvert[ml[j - 1].v].co); add_v3_v3(edge_vert_nos[ed->v1], nor); add_v3_v3(edge_vert_nos[ed->v2], nor); @@ -688,8 +707,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } #ifdef SOLIDIFY_SIDE_NORMALS - ed= medge + (numEdges * 2); - for (i=0; iv1]); - for (j=0; j<2; j++) { /* loop over both verts of the edge */ - nor_short= mvert[*(&ed->v1 + j)].no; + for (j = 0; j < 2; j++) { /* loop over both verts of the edge */ + nor_short = mvert[*(&ed->v1 + j)].no; normal_short_to_float_v3(nor, nor_short); add_v3_v3(nor, nor_cpy); normalize_v3(nor); @@ -729,11 +748,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, #undef SOLIDIFY_SIDE_NORMALS static DerivedMesh *applyModifierEM(ModifierData *md, - Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + Object *ob, + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -743,11 +762,11 @@ ModifierTypeInfo modifierType_Solidify = { /* structSize */ sizeof(SolidifyModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index be1ceeee317..e97f4191e6f 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; smd->levels = 1; smd->renderLevels = 2; @@ -60,8 +60,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - SubsurfModifierData *tsmd = (SubsurfModifierData*) target; + SubsurfModifierData *smd = (SubsurfModifierData *) md; + SubsurfModifierData *tsmd = (SubsurfModifierData *) target; tsmd->flags = smd->flags; tsmd->levels = smd->levels; @@ -71,7 +71,7 @@ static void copyData(ModifierData *md, ModifierData *target) static void freeData(ModifierData *md) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; if (smd->mCache) { ccgSubSurf_free(smd->mCache); @@ -83,41 +83,50 @@ static void freeData(ModifierData *md) static int isDisabled(ModifierData *md, int useRenderParams) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; - int levels= (useRenderParams)? smd->renderLevels: smd->levels; + SubsurfModifierData *smd = (SubsurfModifierData *) md; + int levels = (useRenderParams) ? smd->renderLevels : smd->levels; return get_render_subsurf_level(&md->scene->r, levels) == 0; } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int useRenderParams, - int isFinalCalc) + DerivedMesh *derivedData, + ModifierApplyFlag flag) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; + SubsurfFlags subsurf_flags = 0; DerivedMesh *result; + const int useRenderParams = flag & MOD_APPLY_RENDER; + const int isFinalCalc = flag & MOD_APPLY_USECACHE; - result = subsurf_make_derived_from_derived(derivedData, smd, - useRenderParams, NULL, isFinalCalc, 0, (ob->flag & OB_MODE_EDIT)); + if (useRenderParams) + subsurf_flags |= SUBSURF_USE_RENDER_PARAMS; + if (isFinalCalc) + subsurf_flags |= SUBSURF_IS_FINAL_CALC; + if (ob->flag & OB_MODE_EDIT) + subsurf_flags |= SUBSURF_IN_EDIT_MODE; + + result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags); if (useRenderParams || !isFinalCalc) { - DerivedMesh *cddm= CDDM_copy(result); + DerivedMesh *cddm = CDDM_copy(result); result->release(result); - result= cddm; + result = cddm; } return result; } static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob), - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - SubsurfModifierData *smd = (SubsurfModifierData*) md; + SubsurfModifierData *smd = (SubsurfModifierData *) md; DerivedMesh *result; - result = subsurf_make_derived_from_derived(derivedData, smd, 0, - NULL, 0, 1, 1); + result = subsurf_make_derived_from_derived(derivedData, smd, + NULL, (SUBSURF_FOR_EDIT_MODE | + SUBSURF_IN_EDIT_MODE)); return result; } @@ -128,11 +137,11 @@ ModifierTypeInfo modifierType_Subsurf = { /* structName */ "SubsurfModifierData", /* structSize */ sizeof(SubsurfModifierData), /* type */ eModifierTypeType_Constructive, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode - | eModifierTypeFlag_AcceptsCVs, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode | + eModifierTypeFlag_AcceptsCVs, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index 86e11aca5b7..4e7aaf9d0ba 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -51,14 +51,14 @@ static void initData(ModifierData *md) { - SurfaceModifierData *surmd = (SurfaceModifierData*) md; + SurfaceModifierData *surmd = (SurfaceModifierData *) md; surmd->bvhtree = NULL; } static void freeData(ModifierData *md) { - SurfaceModifierData *surmd = (SurfaceModifierData*) md; + SurfaceModifierData *surmd = (SurfaceModifierData *) md; if (surmd) { if (surmd->bvhtree) { @@ -86,13 +86,12 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int UNUSED(numVerts), - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int UNUSED(numVerts), + ModifierApplyFlag UNUSED(flag)) { - SurfaceModifierData *surmd = (SurfaceModifierData*) md; + SurfaceModifierData *surmd = (SurfaceModifierData *) md; if (surmd->dm) surmd->dm->release(surmd->dm); @@ -115,9 +114,13 @@ static void deformVerts(ModifierData *md, Object *ob, CDDM_apply_vert_coords(surmd->dm, vertexCos); CDDM_calc_normals(surmd->dm); - numverts = surmd->dm->getNumVerts ( surmd->dm ); + numverts = surmd->dm->getNumVerts(surmd->dm); - if (numverts != surmd->numverts || surmd->x == NULL || surmd->v == NULL || md->scene->r.cfra != surmd->cfra+1) { + if (numverts != surmd->numverts || + surmd->x == NULL || + surmd->v == NULL || + md->scene->r.cfra != surmd->cfra + 1) + { if (surmd->x) { MEM_freeN(surmd->x); surmd->x = NULL; @@ -136,7 +139,7 @@ static void deformVerts(ModifierData *md, Object *ob, } /* convert to global coordinates and calculate velocity */ - for (i = 0, x = surmd->x, v = surmd->v; ix, v = surmd->v; i < numverts; i++, x++, v++) { vec = CDDM_get_vert(surmd->dm, i)->co; mul_m4_v3(ob->obmat, vec); @@ -168,8 +171,8 @@ ModifierTypeInfo modifierType_Surface = { /* structName */ "SurfaceModifierData", /* structSize */ sizeof(SurfaceModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_NoUserAdd, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_NoUserAdd, /* copyData */ NULL, /* deformVerts */ deformVerts, @@ -186,6 +189,6 @@ ModifierTypeInfo modifierType_Surface = { /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, - /* foreachIDLink */ NULL, - /* foreachTexLink */ NULL, + /* foreachIDLink */ NULL, + /* foreachTexLink */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 4e143bcb008..aff6bf548e6 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -66,7 +66,7 @@ void modifier_init_texture(Scene *scene, Tex *tex) return; if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) - BKE_image_user_calc_frame(&tex->iuser, scene->r.cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, scene->r.cfra, 0); } void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) @@ -77,14 +77,15 @@ void get_texture_value(Tex *texture, float *tex_co, TexResult *texres) result_type = multitex_ext_safe(texture, tex_co, texres); /* if the texture gave an RGB value, we assume it didn't give a valid - * intensity, so calculate one (formula from do_material_tex). + * intensity, since this is in the context of modifiers don't use perceptual color conversion. * if the texture didn't give an RGB value, copy the intensity across */ - if (result_type & TEX_RGB) - texres->tin = (0.35f * texres->tr + 0.45f * texres->tg - + 0.2f * texres->tb); - else - texres->tr = texres->tg = texres->tb = texres->tin; + if (result_type & TEX_RGB) { + texres->tin= (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb); + } + else { + copy_v3_fl(&texres->tr, texres->tin); + } } void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, @@ -120,11 +121,11 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, /* verts are given the UV from the first face that uses them */ for (i = 0, mp = mpoly; i < numPolys; ++i, ++mp) { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; if (done[vidx] == 0) { /* remap UVs from [0, 1] to [-1, 1] */ @@ -145,26 +146,26 @@ void get_texture_coords(MappingInfoModifierData *dmd, Object *ob, for (i = 0; i < numVerts; ++i, ++co, ++texco) { switch (texmapping) { - case MOD_DISP_MAP_LOCAL: - copy_v3_v3(*texco, *co); - break; - case MOD_DISP_MAP_GLOBAL: - mul_v3_m4v3(*texco, ob->obmat, *co); - break; - case MOD_DISP_MAP_OBJECT: - mul_v3_m4v3(*texco, ob->obmat, *co); - mul_m4_v3(mapob_imat, *texco); - break; + case MOD_DISP_MAP_LOCAL: + copy_v3_v3(*texco, *co); + break; + case MOD_DISP_MAP_GLOBAL: + mul_v3_m4v3(*texco, ob->obmat, *co); + break; + case MOD_DISP_MAP_OBJECT: + mul_v3_m4v3(*texco, ob->obmat, *co); + mul_m4_v3(mapob_imat, *texco); + break; } } } void modifier_vgroup_cache(ModifierData *md, float (*vertexCos)[3]) { - while ((md=md->next) && md->type==eModifierType_Armature) { - ArmatureModifierData *amd = (ArmatureModifierData*) md; - if (amd->multi && amd->prevCos==NULL) - amd->prevCos= MEM_dupallocN(vertexCos); + while ((md = md->next) && md->type == eModifierType_Armature) { + ArmatureModifierData *amd = (ArmatureModifierData *) md; + if (amd->multi && amd->prevCos == NULL) + amd->prevCos = MEM_dupallocN(vertexCos); else break; } @@ -178,10 +179,10 @@ DerivedMesh *get_cddm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float return dm; if (!dm) { - dm= get_dm(ob, em, dm, vertexCos, 0); + dm = get_dm(ob, em, dm, vertexCos, 0); } else { - dm= CDDM_copy(dm); + dm = CDDM_copy(dm); CDDM_apply_vert_coords(dm, vertexCos); } @@ -197,8 +198,8 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (* if (dm) return dm; - if (ob->type==OB_MESH) { - if (em) dm= CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); + if (ob->type == OB_MESH) { + if (em) dm = CDDM_from_BMEditMesh(em, ob->data, FALSE, FALSE); else dm = CDDM_from_mesh((struct Mesh *)(ob->data), ob); if (vertexCos) { @@ -207,10 +208,10 @@ DerivedMesh *get_dm(Object *ob, struct BMEditMesh *em, DerivedMesh *dm, float (* } if (orco) - DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, get_mesh_orco_verts(ob)); + DM_add_vert_layer(dm, CD_ORCO, CD_ASSIGN, BKE_mesh_orco_verts_get(ob)); } else if (ELEM3(ob->type, OB_FONT, OB_CURVE, OB_SURF)) { - dm= CDDM_from_curve(ob); + dm = CDDM_from_curve(ob); } return dm; @@ -223,7 +224,7 @@ void modifier_get_vgroup(Object *ob, DerivedMesh *dm, const char *name, MDeformV if (*defgrp_index >= 0) { if (ob->type == OB_LATTICE) - *dvert = lattice_get_deform_verts(ob); + *dvert = BKE_lattice_deform_verts_get(ob); else if (dm) *dvert = dm->getVertDataArray(dm, CD_MDEFORMVERT); } diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index ef8cf24987c..eb5a74f0dcc 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -58,7 +58,7 @@ static void initData(ModifierData *md) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; int i; for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) @@ -72,8 +72,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; - UVProjectModifierData *tumd = (UVProjectModifierData*) target; + UVProjectModifierData *umd = (UVProjectModifierData *) md; + UVProjectModifierData *tumd = (UVProjectModifierData *) target; int i; for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) @@ -99,9 +99,9 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED( } static void foreachObjectLink(ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ObjectWalkFunc walk, void *userData) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; int i; for (i = 0; i < MOD_UVPROJECT_MAXPROJECTORS; ++i) @@ -109,22 +109,22 @@ static void foreachObjectLink(ModifierData *md, Object *ob, } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; walk(userData, ob, (ID **)&umd->image); foreachObjectLink(md, ob, (ObjectWalkFunc)walk, - userData); + userData); } static void updateDepgraph(ModifierData *md, DagForest *forest, - struct Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + struct Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; int i; for (i = 0; i < umd->num_projectors; ++i) { @@ -132,20 +132,20 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, DagNode *curNode = dag_get_node(forest, umd->projectors[i]); dag_add_relation(forest, curNode, obNode, - DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "UV Project Modifier"); + DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "UV Project Modifier"); } } } typedef struct Projector { - Object *ob; /* object this projector is derived from */ - float projmat[4][4]; /* projection matrix */ - float normal[3]; /* projector normal in world space */ - void *uci; /* optional uv-project info (panorama projection) */ + Object *ob; /* object this projector is derived from */ + float projmat[4][4]; /* projection matrix */ + float normal[3]; /* projector normal in world space */ + void *uci; /* optional uv-project info (panorama projection) */ } Projector; static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, - Object *ob, DerivedMesh *dm) + Object *ob, DerivedMesh *dm) { float (*coords)[3], (*co)[3]; MLoopUV *mloop_uv; @@ -159,11 +159,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, int num_projectors = 0; float aspect; char uvname[MAX_CUSTOMDATA_LAYER_NAME]; - float aspx= umd->aspectx ? umd->aspectx : 1.0f; - float aspy= umd->aspecty ? umd->aspecty : 1.0f; - float scax= umd->scalex ? umd->scalex : 1.0f; - float scay= umd->scaley ? umd->scaley : 1.0f; - int free_uci= 0; + float aspx = umd->aspectx ? umd->aspectx : 1.0f; + float aspy = umd->aspecty ? umd->aspecty : 1.0f; + float scax = umd->scalex ? umd->scalex : 1.0f; + float scay = umd->scaley ? umd->scaley : 1.0f; + int free_uci = 0; aspect = aspx / aspy; @@ -188,23 +188,23 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* calculate projection matrix */ invert_m4_m4(projectors[i].projmat, projectors[i].ob->obmat); - projectors[i].uci= NULL; + projectors[i].uci = NULL; if (projectors[i].ob->type == OB_CAMERA) { cam = (Camera *)projectors[i].ob->data; if (cam->type == CAM_PANO) { - projectors[i].uci= BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy); + projectors[i].uci = BLI_uvproject_camera_info(projectors[i].ob, NULL, aspx, aspy); BLI_uvproject_camera_info_scale(projectors[i].uci, scax, scay); - free_uci= 1; + free_uci = 1; } else { - float sensor= BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); - int sensor_fit= BKE_camera_sensor_fit(cam->sensor_fit, aspx, aspy); - float scale= (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale; + float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); + int sensor_fit = BKE_camera_sensor_fit(cam->sensor_fit, aspx, aspy); + float scale = (cam->type == CAM_PERSP) ? cam->clipsta * sensor / cam->lens : cam->ortho_scale; float xmax, xmin, ymax, ymin; - if (sensor_fit==CAMERA_SENSOR_FIT_HOR) { + if (sensor_fit == CAMERA_SENSOR_FIT_HOR) { xmax = 0.5f * scale; ymax = xmax / aspect; } @@ -248,12 +248,12 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, offsetmat[3][1] -= cam->shifty; } else if (aspx < aspy) { - offsetmat[3][0] -=(cam->shiftx * aspy/aspx); + offsetmat[3][0] -= (cam->shiftx * aspy / aspx); offsetmat[3][1] -= cam->shifty; } else { offsetmat[3][0] -= cam->shiftx; - offsetmat[3][1] -=(cam->shifty * aspx/aspy); + offsetmat[3][1] -= (cam->shifty * aspx / aspy); } } @@ -271,16 +271,16 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, /* make sure we are not modifying the original UV map */ mloop_uv = CustomData_duplicate_referenced_layer_named(&dm->loopData, - CD_MLOOPUV, uvname, numLoops); + CD_MLOOPUV, uvname, numLoops); /* can be NULL */ mt = mtexpoly = CustomData_duplicate_referenced_layer_named(&dm->polyData, - CD_MTEXPOLY, uvname, numPolys); + CD_MTEXPOLY, uvname, numPolys); numVerts = dm->getNumVerts(dm); coords = MEM_callocN(sizeof(*coords) * numVerts, - "uvprojectModifier_do coords"); + "uvprojectModifier_do coords"); dm->getVertCos(dm, coords); /* convert coords to world space */ @@ -288,7 +288,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, mul_m4_v3(ob->obmat, *co); /* if only one projector, project coords to UVs */ - if (num_projectors == 1 && projectors[0].uci==NULL) + if (num_projectors == 1 && projectors[0].uci == NULL) for (i = 0, co = coords; i < numVerts; ++i, ++co) mul_project_m4_v3(projectors[0].projmat, *co); @@ -300,19 +300,19 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, if (override_image || !image || (mtexpoly == NULL || mt->tpage == image)) { if (num_projectors == 1) { if (projectors[0].uci) { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci); } while (fidx--); } else { /* apply transformed coords as UVs */ - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; copy_v2_v2(mloop_uv[lidx].uv, coords[vidx]); } while (fidx--); } @@ -325,7 +325,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, float best_dot; /* get the untransformed face normal */ - mesh_calc_poly_normal_coords(mp, mloop + mp->loopstart, (const float (*)[3])coords, face_no); + BKE_mesh_calc_poly_normal_coords(mp, mloop + mp->loopstart, (const float (*)[3])coords, face_no); /* find the projector which the face points at most directly * (projector normal with largest dot product is best) @@ -335,7 +335,7 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, for (j = 1; j < num_projectors; ++j) { float tmp_dot = dot_v3v3(projectors[j].normal, - face_no); + face_no); if (tmp_dot > best_dot) { best_dot = tmp_dot; best_projector = &projectors[j]; @@ -343,18 +343,18 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } if (best_projector->uci) { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci); } while (fidx--); } else { - unsigned int fidx= mp->totloop - 1; + unsigned int fidx = mp->totloop - 1; do { - unsigned int lidx= mp->loopstart + fidx; - unsigned int vidx= mloop[lidx].v; + unsigned int lidx = mp->loopstart + fidx; + unsigned int vidx = mloop[lidx].v; float tco[3]; copy_v3_v3(tco, coords[vidx]); @@ -389,12 +389,11 @@ static DerivedMesh *uvprojectModifier_do(UVProjectModifierData *umd, } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + ModifierApplyFlag UNUSED(flag)) { DerivedMesh *result; - UVProjectModifierData *umd = (UVProjectModifierData*) md; + UVProjectModifierData *umd = (UVProjectModifierData *) md; result = uvprojectModifier_do(umd, ob, derivedData); @@ -402,10 +401,10 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, } static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, - struct BMEditMesh *UNUSED(editData), - DerivedMesh *derivedData) + struct BMEditMesh *UNUSED(editData), + DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -414,10 +413,10 @@ ModifierTypeInfo modifierType_UVProject = { /* structName */ "UVProjectModifierData", /* structSize */ sizeof(UVProjectModifierData), /* type */ eModifierTypeType_NonGeometrical, - /* flags */ eModifierTypeFlag_AcceptsMesh - | eModifierTypeFlag_SupportsMapping - | eModifierTypeFlag_SupportsEditmode - | eModifierTypeFlag_EnableInEditmode, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_EnableInEditmode, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index 5ee8103630d..9eb360f6819 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -51,7 +51,7 @@ static void initData(ModifierData *md) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; wmd->curfalloff = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); wmd->texture = NULL; @@ -63,8 +63,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - WarpModifierData *wmd = (WarpModifierData*) md; - WarpModifierData *twmd = (WarpModifierData*) target; + WarpModifierData *wmd = (WarpModifierData *) md; + WarpModifierData *twmd = (WarpModifierData *) target; twmd->object_from = wmd->object_from; twmd->object_to = wmd->object_to; @@ -79,7 +79,7 @@ static void copyData(ModifierData *md, ModifierData *target) twmd->texture = wmd->texture; twmd->map_object = wmd->map_object; BLI_strncpy(twmd->uvlayer_name, wmd->uvlayer_name, sizeof(twmd->uvlayer_name)); - twmd->texmapping= wmd->texmapping; + twmd->texmapping = wmd->texmapping; } static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) @@ -118,14 +118,14 @@ static void freeData(ModifierData *md) static int isDisabled(ModifierData *md, int UNUSED(userRenderParams)) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; return !(wmd->object_from && wmd->object_to); } static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, void *userData) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; walk(userData, ob, &wmd->object_from); walk(userData, ob, &wmd->object_to); @@ -134,7 +134,7 @@ static void foreachObjectLink(ModifierData *md, Object *ob, ObjectWalkFunc walk, static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; walk(userData, ob, (ID **)&wmd->texture); @@ -151,7 +151,7 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WarpModifierData *wmd = (WarpModifierData*) md; + WarpModifierData *wmd = (WarpModifierData *) md; if (wmd->object_from && wmd->object_to) { DagNode *fromNode = dag_get_node(forest, wmd->object_from); @@ -183,9 +183,9 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, float fac = 1.0f, weight; int i; int defgrp_index; - MDeformVert *dvert, *dv= NULL; + MDeformVert *dvert, *dv = NULL; - float (*tex_co)[3]= NULL; + float (*tex_co)[3] = NULL; if (!(wmd->object_from && wmd->object_to)) return; @@ -217,7 +217,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, negate_v3_v3(mat_final[3], loc); } - weight= strength; + weight = strength; if (wmd->texture) { tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, "warpModifier_do tex_co"); @@ -231,7 +231,7 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, if (wmd->falloff_type == eWarp_Falloff_None || ((fac = len_v3v3(co, mat_from[3])) < wmd->falloff_radius && - (fac = (wmd->falloff_radius-fac) / wmd->falloff_radius))) + (fac = (wmd->falloff_radius - fac) / wmd->falloff_radius))) { /* skip if no vert group found */ if (dvert && defgrp_index >= 0) { @@ -247,30 +247,30 @@ static void warpModifier_do(WarpModifierData *wmd, Object *ob, /* closely match PROP_SMOOTH and similar */ switch (wmd->falloff_type) { - case eWarp_Falloff_None: - fac = 1.0f; - break; - case eWarp_Falloff_Curve: - fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac); - break; - case eWarp_Falloff_Sharp: - fac = fac*fac; - break; - case eWarp_Falloff_Smooth: - fac = 3.0f*fac*fac - 2.0f*fac*fac*fac; - break; - case eWarp_Falloff_Root: - fac = (float)sqrt(fac); - break; - case eWarp_Falloff_Linear: - /* pass */ - break; - case eWarp_Falloff_Const: - fac = 1.0f; - break; - case eWarp_Falloff_Sphere: - fac = (float)sqrt(2*fac - fac * fac); - break; + case eWarp_Falloff_None: + fac = 1.0f; + break; + case eWarp_Falloff_Curve: + fac = curvemapping_evaluateF(wmd->curfalloff, 0, fac); + break; + case eWarp_Falloff_Sharp: + fac = fac * fac; + break; + case eWarp_Falloff_Smooth: + fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; + break; + case eWarp_Falloff_Root: + fac = (float)sqrt(fac); + break; + case eWarp_Falloff_Linear: + /* pass */ + break; + case eWarp_Falloff_Const: + fac = 1.0f; + break; + case eWarp_Falloff_Sphere: + fac = (float)sqrt(2 * fac - fac * fac); + break; } fac *= weight; @@ -317,13 +317,13 @@ static int warp_needs_dm(WarpModifierData *wmd) } static void deformVerts(ModifierData *md, Object *ob, DerivedMesh *derivedData, - float (*vertexCos)[3], int numVerts, int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + float (*vertexCos)[3], int numVerts, ModifierApplyFlag UNUSED(flag)) { - DerivedMesh *dm= NULL; - int use_dm= warp_needs_dm((WarpModifierData *)md); + DerivedMesh *dm = NULL; + int use_dm = warp_needs_dm((WarpModifierData *)md); if (use_dm) { - dm= get_cddm(ob, NULL, derivedData, vertexCos); + dm = get_cddm(ob, NULL, derivedData, vertexCos); } warpModifier_do((WarpModifierData *)md, ob, dm, vertexCos, numVerts); @@ -337,14 +337,14 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { DerivedMesh *dm = derivedData; - int use_dm= warp_needs_dm((WarpModifierData *)md); + int use_dm = warp_needs_dm((WarpModifierData *)md); if (use_dm) { if (!derivedData) dm = CDDM_from_BMEditMesh(editData, ob->data, FALSE, FALSE); } - deformVerts(md, ob, dm, vertexCos, numVerts, 0, 0); + deformVerts(md, ob, dm, vertexCos, numVerts, 0); if (use_dm) { if (!derivedData) dm->release(dm); @@ -353,27 +353,27 @@ static void deformVertsEM(ModifierData *md, Object *ob, struct BMEditMesh *editD ModifierTypeInfo modifierType_Warp = { - /* name */ "Warp", - /* structName */ "WarpModifierData", - /* structSize */ sizeof(WarpModifierData), - /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, - /* copyData */ copyData, - /* deformVerts */ deformVerts, - /* deformMatrices */ NULL, - /* deformVertsEM */ deformVertsEM, - /* deformMatricesEM */ NULL, - /* applyModifier */ 0, - /* applyModifierEM */ 0, - /* initData */ initData, - /* requiredDataMask */ requiredDataMask, - /* freeData */ freeData, - /* isDisabled */ isDisabled, - /* updateDepgraph */ updateDepgraph, - /* dependsOnTime */ dependsOnTime, - /* dependsOnNormals */ NULL, + /* name */ "Warp", + /* structName */ "WarpModifierData", + /* structSize */ sizeof(WarpModifierData), + /* type */ eModifierTypeType_OnlyDeform, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, + /* copyData */ copyData, + /* deformVerts */ deformVerts, + /* deformMatrices */ NULL, + /* deformVertsEM */ deformVertsEM, + /* deformMatricesEM */ NULL, + /* applyModifier */ 0, + /* applyModifierEM */ 0, + /* initData */ initData, + /* requiredDataMask */ requiredDataMask, + /* freeData */ freeData, + /* isDisabled */ isDisabled, + /* updateDepgraph */ updateDepgraph, + /* dependsOnTime */ dependsOnTime, + /* dependsOnNormals */ NULL, /* foreachObjectLink */ foreachObjectLink, - /* foreachIDLink */ foreachIDLink, - /* foreachTexLink */ foreachTexLink, + /* foreachIDLink */ foreachIDLink, + /* foreachTexLink */ foreachTexLink, }; diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 5fa3090cd87..440d2c157fe 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -58,29 +58,29 @@ static void initData(ModifierData *md) { - WaveModifierData *wmd = (WaveModifierData*) md; // whadya know, moved here from Iraq + WaveModifierData *wmd = (WaveModifierData *) md; // whadya know, moved here from Iraq - wmd->flag |= (MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL - | MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z); + wmd->flag |= (MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL | + MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z); wmd->objectcenter = NULL; wmd->texture = NULL; wmd->map_object = NULL; - wmd->height= 0.5f; - wmd->width= 1.5f; - wmd->speed= 0.25f; - wmd->narrow= 1.5f; - wmd->lifetime= 0.0f; - wmd->damp= 10.0f; - wmd->falloff= 0.0f; + wmd->height = 0.5f; + wmd->width = 1.5f; + wmd->speed = 0.25f; + wmd->narrow = 1.5f; + wmd->lifetime = 0.0f; + wmd->damp = 10.0f; + wmd->falloff = 0.0f; wmd->texmapping = MOD_DISP_MAP_LOCAL; wmd->defgrp_name[0] = 0; } static void copyData(ModifierData *md, ModifierData *target) { - WaveModifierData *wmd = (WaveModifierData*) md; - WaveModifierData *twmd = (WaveModifierData*) target; + WaveModifierData *wmd = (WaveModifierData *) md; + WaveModifierData *twmd = (WaveModifierData *) target; twmd->damp = wmd->damp; twmd->flag = wmd->flag; @@ -106,19 +106,19 @@ static int dependsOnTime(ModifierData *UNUSED(md)) } static void foreachObjectLink( - ModifierData *md, Object *ob, - ObjectWalkFunc walk, void *userData) + ModifierData *md, Object *ob, + ObjectWalkFunc walk, void *userData) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; walk(userData, ob, &wmd->objectcenter); walk(userData, ob, &wmd->map_object); } static void foreachIDLink(ModifierData *md, Object *ob, - IDWalkFunc walk, void *userData) + IDWalkFunc walk, void *userData) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; walk(userData, ob, (ID **)&wmd->texture); @@ -126,30 +126,30 @@ static void foreachIDLink(ModifierData *md, Object *ob, } static void foreachTexLink(ModifierData *md, Object *ob, - TexWalkFunc walk, void *userData) + TexWalkFunc walk, void *userData) { walk(userData, ob, md, "texture"); } static void updateDepgraph(ModifierData *md, DagForest *forest, - Scene *UNUSED(scene), - Object *UNUSED(ob), - DagNode *obNode) + Scene *UNUSED(scene), + Object *UNUSED(ob), + DagNode *obNode) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; if (wmd->objectcenter) { DagNode *curNode = dag_get_node(forest, wmd->objectcenter); dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Wave Modifier"); + "Wave Modifier"); } if (wmd->map_object) { DagNode *curNode = dag_get_node(forest, wmd->map_object); dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA, - "Wave Modifer"); + "Wave Modifer"); } } @@ -171,21 +171,20 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) } static void waveModifier_do(WaveModifierData *md, - Scene *scene, Object *ob, DerivedMesh *dm, - float (*vertexCos)[3], int numVerts) + Scene *scene, Object *ob, DerivedMesh *dm, + float (*vertexCos)[3], int numVerts) { - WaveModifierData *wmd = (WaveModifierData*) md; + WaveModifierData *wmd = (WaveModifierData *) md; MVert *mvert = NULL; MDeformVert *dvert; int defgrp_index; - float ctime = BKE_curframe(scene); - float minfac = - (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); + float ctime = BKE_scene_frame_get(scene); + float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow)); float lifefac = wmd->height; float (*tex_co)[3] = NULL; - const int wmd_axis= wmd->flag & (MOD_WAVE_X|MOD_WAVE_Y); - const float falloff= wmd->falloff; - float falloff_fac= 1.0f; /* when falloff == 0.0f this stays at 1.0f */ + const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y); + const float falloff = wmd->falloff; + float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */ if (wmd->flag & MOD_WAVE_NORM && ob->type == OB_MESH) mvert = dm->getVertArray(dm); @@ -212,14 +211,13 @@ static void waveModifier_do(WaveModifierData *md, lifefac = x - wmd->lifetime; if (lifefac > wmd->damp) lifefac = 0.0; - else lifefac = - (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); + else lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp))); } } if (wmd->texture) { tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts, - "waveModifier_do tex_co"); + "waveModifier_do tex_co"); get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts); modifier_init_texture(wmd->modifier.scene, wmd->texture); @@ -227,19 +225,19 @@ static void waveModifier_do(WaveModifierData *md, if (lifefac != 0.0f) { /* avoid divide by zero checks within the loop */ - float falloff_inv= falloff ? 1.0f / falloff : 1.0f; + float falloff_inv = falloff ? 1.0f / falloff : 1.0f; int i; for (i = 0; i < numVerts; i++) { float *co = vertexCos[i]; float x = co[0] - wmd->startx; float y = co[1] - wmd->starty; - float amplit= 0.0f; - float def_weight= 1.0f; + float amplit = 0.0f; + float def_weight = 1.0f; /* get weights */ if (dvert) { - def_weight= defvert_find_weight(&dvert[i], defgrp_index); + def_weight = defvert_find_weight(&dvert[i], defgrp_index); /* if this vert isn't in the vgroup, don't deform it */ if (def_weight == 0.0f) { @@ -248,38 +246,38 @@ static void waveModifier_do(WaveModifierData *md, } switch (wmd_axis) { - case MOD_WAVE_X|MOD_WAVE_Y: - amplit = sqrtf(x*x + y*y); - break; - case MOD_WAVE_X: - amplit = x; - break; - case MOD_WAVE_Y: - amplit = y; - break; + case MOD_WAVE_X | MOD_WAVE_Y: + amplit = sqrtf(x * x + y * y); + break; + case MOD_WAVE_X: + amplit = x; + break; + case MOD_WAVE_Y: + amplit = y; + break; } /* this way it makes nice circles */ amplit -= (ctime - wmd->timeoffs) * wmd->speed; if (wmd->flag & MOD_WAVE_CYCL) { - amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) - + wmd->width; + amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) + + wmd->width; } if (falloff != 0.0f) { float dist = 0.0f; switch (wmd_axis) { - case MOD_WAVE_X|MOD_WAVE_Y: - dist = sqrtf(x*x + y*y); - break; - case MOD_WAVE_X: - dist = fabsf(x); - break; - case MOD_WAVE_Y: - dist = fabsf(y); - break; + case MOD_WAVE_X | MOD_WAVE_Y: + dist = sqrtf(x * x + y * y); + break; + case MOD_WAVE_X: + dist = fabsf(x); + break; + case MOD_WAVE_Y: + dist = fabsf(y); + break; } falloff_fac = (1.0f - (dist * falloff_inv)); @@ -326,19 +324,18 @@ static void waveModifier_do(WaveModifierData *md, } static void deformVerts(ModifierData *md, Object *ob, - DerivedMesh *derivedData, - float (*vertexCos)[3], - int numVerts, - int UNUSED(useRenderParams), - int UNUSED(isFinalCalc)) + DerivedMesh *derivedData, + float (*vertexCos)[3], + int numVerts, + ModifierApplyFlag UNUSED(flag)) { - DerivedMesh *dm= derivedData; + DerivedMesh *dm = derivedData; WaveModifierData *wmd = (WaveModifierData *)md; if (wmd->flag & MOD_WAVE_NORM) - dm= get_cddm(ob, NULL, dm, vertexCos); + dm = get_cddm(ob, NULL, dm, vertexCos); else if (wmd->texture || wmd->defgrp_name[0]) - dm= get_dm(ob, NULL, dm, NULL, 0); + dm = get_dm(ob, NULL, dm, NULL, 0); waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts); @@ -347,16 +344,16 @@ static void deformVerts(ModifierData *md, Object *ob, } static void deformVertsEM( - ModifierData *md, Object *ob, struct BMEditMesh *editData, - DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) + ModifierData *md, Object *ob, struct BMEditMesh *editData, + DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts) { - DerivedMesh *dm= derivedData; + DerivedMesh *dm = derivedData; WaveModifierData *wmd = (WaveModifierData *)md; if (wmd->flag & MOD_WAVE_NORM) - dm= get_cddm(ob, editData, dm, vertexCos); + dm = get_cddm(ob, editData, dm, vertexCos); else if (wmd->texture || wmd->defgrp_name[0]) - dm= get_dm(ob, editData, dm, NULL, 0); + dm = get_dm(ob, editData, dm, NULL, 0); waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts); @@ -370,8 +367,8 @@ ModifierTypeInfo modifierType_Wave = { /* structName */ "WaveModifierData", /* structSize */ sizeof(WaveModifierData), /* type */ eModifierTypeType_OnlyDeform, - /* flags */ eModifierTypeFlag_AcceptsCVs - | eModifierTypeFlag_SupportsEditmode, + /* flags */ eModifierTypeFlag_AcceptsCVs | + eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, /* deformVerts */ deformVerts, /* deformMatrices */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 1f886812ab7..5097ae8c742 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -80,28 +80,28 @@ void weightvg_do_map(int num, float *new_w, short falloff_type, CurveMapping *cm /* Code borrowed from the warp modifier. */ /* Closely matches PROP_SMOOTH and similar. */ switch (falloff_type) { - case MOD_WVG_MAPPING_CURVE: - fac = curvemapping_evaluateF(cmap, 0, fac); - break; - case MOD_WVG_MAPPING_SHARP: - fac = fac*fac; - break; - case MOD_WVG_MAPPING_SMOOTH: - fac = 3.0f*fac*fac - 2.0f*fac*fac*fac; - break; - case MOD_WVG_MAPPING_ROOT: - fac = (float)sqrt(fac); - break; - case MOD_WVG_MAPPING_SPHERE: - fac = (float)sqrt(2*fac - fac * fac); - break; - case MOD_WVG_MAPPING_RANDOM: - BLI_srand(BLI_rand()); /* random seed */ - fac = BLI_frand()*fac; - break; - case MOD_WVG_MAPPING_STEP: - fac = (fac >= 0.5f)?1.0f:0.0f; - break; + case MOD_WVG_MAPPING_CURVE: + fac = curvemapping_evaluateF(cmap, 0, fac); + break; + case MOD_WVG_MAPPING_SHARP: + fac = fac * fac; + break; + case MOD_WVG_MAPPING_SMOOTH: + fac = 3.0f * fac * fac - 2.0f * fac * fac * fac; + break; + case MOD_WVG_MAPPING_ROOT: + fac = (float)sqrt(fac); + break; + case MOD_WVG_MAPPING_SPHERE: + fac = (float)sqrt(2 * fac - fac * fac); + break; + case MOD_WVG_MAPPING_RANDOM: + BLI_srand(BLI_rand()); /* random seed */ + fac = BLI_frand() * fac; + break; + case MOD_WVG_MAPPING_STEP: + fac = (fac >= 0.5f) ? 1.0f : 0.0f; + break; } new_w[i] = fac; @@ -160,36 +160,36 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne get_texture_value(texture, tex_co[idx], &texres); /* Get the good channel value... */ switch (tex_use_channel) { - case MOD_WVG_MASK_TEX_USE_INT: - org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact))); - break; - case MOD_WVG_MASK_TEX_USE_RED: - org_w[i] = (new_w[i] * texres.tr * fact) + (org_w[i] * (1.0f - (texres.tr*fact))); - break; - case MOD_WVG_MASK_TEX_USE_GREEN: - org_w[i] = (new_w[i] * texres.tg * fact) + (org_w[i] * (1.0f - (texres.tg*fact))); - break; - case MOD_WVG_MASK_TEX_USE_BLUE: - org_w[i] = (new_w[i] * texres.tb * fact) + (org_w[i] * (1.0f - (texres.tb*fact))); - break; - case MOD_WVG_MASK_TEX_USE_HUE: - rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); - org_w[i] = (new_w[i] * h * fact) + (org_w[i] * (1.0f - (h*fact))); - break; - case MOD_WVG_MASK_TEX_USE_SAT: - rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); - org_w[i] = (new_w[i] * s * fact) + (org_w[i] * (1.0f - (s*fact))); - break; - case MOD_WVG_MASK_TEX_USE_VAL: - rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); - org_w[i] = (new_w[i] * v * fact) + (org_w[i] * (1.0f - (v*fact))); - break; - case MOD_WVG_MASK_TEX_USE_ALPHA: - org_w[i] = (new_w[i] * texres.ta * fact) + (org_w[i] * (1.0f - (texres.ta*fact))); - break; - default: - org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin*fact))); - break; + case MOD_WVG_MASK_TEX_USE_INT: + org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin * fact))); + break; + case MOD_WVG_MASK_TEX_USE_RED: + org_w[i] = (new_w[i] * texres.tr * fact) + (org_w[i] * (1.0f - (texres.tr * fact))); + break; + case MOD_WVG_MASK_TEX_USE_GREEN: + org_w[i] = (new_w[i] * texres.tg * fact) + (org_w[i] * (1.0f - (texres.tg * fact))); + break; + case MOD_WVG_MASK_TEX_USE_BLUE: + org_w[i] = (new_w[i] * texres.tb * fact) + (org_w[i] * (1.0f - (texres.tb * fact))); + break; + case MOD_WVG_MASK_TEX_USE_HUE: + rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); + org_w[i] = (new_w[i] * h * fact) + (org_w[i] * (1.0f - (h * fact))); + break; + case MOD_WVG_MASK_TEX_USE_SAT: + rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); + org_w[i] = (new_w[i] * s * fact) + (org_w[i] * (1.0f - (s * fact))); + break; + case MOD_WVG_MASK_TEX_USE_VAL: + rgb_to_hsv(texres.tr, texres.tg, texres.tb, &h, &s, &v); + org_w[i] = (new_w[i] * v * fact) + (org_w[i] * (1.0f - (v * fact))); + break; + case MOD_WVG_MASK_TEX_USE_ALPHA: + org_w[i] = (new_w[i] * texres.ta * fact) + (org_w[i] * (1.0f - (texres.ta * fact))); + break; + default: + org_w[i] = (new_w[i] * texres.tin * fact) + (org_w[i] * (1.0f - (texres.tin * fact))); + break; } } @@ -213,7 +213,7 @@ void weightvg_do_mask(int num, const int *indices, float *org_w, const float *ne for (i = 0; i < num; i++) { int idx = indices ? indices[i] : i; const float f = defvert_find_weight(&dvert[idx], ref_didx) * fact; - org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f-f)); + org_w[i] = (new_w[i] * f) + (org_w[i] * (1.0f - f)); /* If that vertex is not in ref vgroup, assume null factor, and hence do nothing! */ } } diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index b8961870043..ce6295e30cf 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -55,7 +55,7 @@ **************************************/ static void initData(ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; wmd->edit_flags = 0; wmd->falloff_type = MOD_WVG_MAPPING_NONE; wmd->default_weight = 0.0f; @@ -73,14 +73,14 @@ static void initData(ModifierData *md) static void freeData(ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; curvemapping_free(wmd->cmap_curve); } static void copyData(ModifierData *md, ModifierData *target) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; - WeightVGEditModifierData *twmd = (WeightVGEditModifierData*) target; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; + WeightVGEditModifierData *twmd = (WeightVGEditModifierData *) target; BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name)); @@ -104,7 +104,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; CustomDataMask dataMask = 0; /* We need vertex groups! */ @@ -121,7 +121,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int dependsOnTime(ModifierData *md) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; if (wmd->mask_texture) return BKE_texture_dependsOnTime(wmd->mask_texture); @@ -132,13 +132,13 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; walk(userData, ob, &wmd->mask_tex_map_obj); } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; walk(userData, ob, (ID **)&wmd->mask_texture); @@ -153,32 +153,32 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; DagNode *curNode; if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) { curNode = dag_get_node(forest, wmd->mask_tex_map_obj); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGEdit Modifier"); } if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) - dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGEdit Modifier"); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; /* If no vertex group, bypass. */ return (wmd->defgrp_name[0] == '\0'); } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, - int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { - WeightVGEditModifierData *wmd = (WeightVGEditModifierData*) md; + WeightVGEditModifierData *wmd = (WeightVGEditModifierData *) md; DerivedMesh *dm = derivedData; MDeformVert *dvert = NULL; MDeformWeight **dw = NULL; @@ -211,7 +211,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ - if (!dvert) + if (!dvert) { /* If this modifier is not allowed to add vertices, just return. */ if (!do_add) return dm; @@ -221,11 +221,12 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Ultimate security check. */ if (!dvert) return dm; + } /* Get org weights, assuming 0.0 for vertices not in given vgroup. */ org_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, org_w"); new_w = MEM_mallocN(sizeof(float) * numVerts, "WeightVGEdit Modifier, new_w"); - dw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGEdit Modifier, dw"); + dw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGEdit Modifier, dw"); for (i = 0; i < numVerts; i++) { dw[i] = defvert_find_index(&dvert[i], defgrp_idx); if (dw[i]) { @@ -270,7 +271,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, struct BMEditMesh *UNUSED(editData), DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -279,10 +280,10 @@ ModifierTypeInfo modifierType_WeightVGEdit = { /* structName */ "WeightVGEditModifierData", /* structSize */ sizeof(WeightVGEditModifierData), /* type */ eModifierTypeType_NonGeometrical, - /* flags */ eModifierTypeFlag_AcceptsMesh - |eModifierTypeFlag_SupportsMapping - |eModifierTypeFlag_SupportsEditmode - |eModifierTypeFlag_UsesPreview, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index b7bbc717981..2961082b448 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -61,26 +61,26 @@ static float mix_weight(float weight, float weight2, char mix_mode) */ switch (mix_mode) { - case MOD_WVG_MIX_ADD: - return (weight + weight2); - case MOD_WVG_MIX_SUB: - return (weight - weight2); - case MOD_WVG_MIX_MUL: - return (weight * weight2); - case MOD_WVG_MIX_DIV: - /* Avoid dividing by zero (or really small values). */ - if (0.0 <= weight2 < MOD_WVG_ZEROFLOOR) - weight2 = MOD_WVG_ZEROFLOOR; - else if (-MOD_WVG_ZEROFLOOR < weight2) - weight2 = -MOD_WVG_ZEROFLOOR; - return (weight / weight2); - case MOD_WVG_MIX_DIF: - return (weight < weight2 ? weight2 - weight : weight - weight2); - case MOD_WVG_MIX_AVG: - return (weight + weight2) / 2.0; - case MOD_WVG_MIX_SET: - default: - return weight2; + case MOD_WVG_MIX_ADD: + return (weight + weight2); + case MOD_WVG_MIX_SUB: + return (weight - weight2); + case MOD_WVG_MIX_MUL: + return (weight * weight2); + case MOD_WVG_MIX_DIV: + /* Avoid dividing by zero (or really small values). */ + if (0.0 <= weight2 < MOD_WVG_ZEROFLOOR) + weight2 = MOD_WVG_ZEROFLOOR; + else if (-MOD_WVG_ZEROFLOOR < weight2) + weight2 = -MOD_WVG_ZEROFLOOR; + return (weight / weight2); + case MOD_WVG_MIX_DIF: + return (weight < weight2 ? weight2 - weight : weight - weight2); + case MOD_WVG_MIX_AVG: + return (weight + weight2) / 2.0; + case MOD_WVG_MIX_SET: + default: + return weight2; } #endif if (mix_mode == MOD_WVG_MIX_SET) @@ -111,7 +111,7 @@ static float mix_weight(float weight, float weight2, char mix_mode) **************************************/ static void initData(ModifierData *md) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; wmd->default_weight_a = 0.0f; wmd->default_weight_b = 0.0f; @@ -125,8 +125,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; - WeightVGMixModifierData *twmd = (WeightVGMixModifierData*) target; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; + WeightVGMixModifierData *twmd = (WeightVGMixModifierData *) target; BLI_strncpy(twmd->defgrp_name_a, wmd->defgrp_name_a, sizeof(twmd->defgrp_name_a)); BLI_strncpy(twmd->defgrp_name_b, wmd->defgrp_name_b, sizeof(twmd->defgrp_name_b)); @@ -146,7 +146,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; CustomDataMask dataMask = 0; /* We need vertex groups! */ @@ -163,7 +163,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int dependsOnTime(ModifierData *md) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; if (wmd->mask_texture) return BKE_texture_dependsOnTime(wmd->mask_texture); @@ -174,13 +174,13 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; walk(userData, ob, &wmd->mask_tex_map_obj); } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; walk(userData, ob, (ID **)&wmd->mask_texture); @@ -195,32 +195,32 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; DagNode *curNode; if (wmd->mask_tex_map_obj && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) { curNode = dag_get_node(forest, wmd->mask_tex_map_obj); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGMix Modifier"); } if (wmd->mask_tex_mapping == MOD_DISP_MAP_GLOBAL) - dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, obNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGMix Modifier"); } static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; /* If no vertex group, bypass. */ return (wmd->defgrp_name_a[0] == '\0'); } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, - int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { - WeightVGMixModifierData *wmd = (WeightVGMixModifierData*) md; + WeightVGMixModifierData *wmd = (WeightVGMixModifierData *) md; DerivedMesh *dm = derivedData; MDeformVert *dvert = NULL; MDeformWeight **dw1, **tdw1, **dw2, **tdw2; @@ -258,7 +258,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der dvert = CustomData_duplicate_referenced_layer(&dm->vertData, CD_MDEFORMVERT, numVerts); /* If no vertices were ever added to an object's vgroup, dvert might be NULL. */ - if (!dvert) + if (!dvert) { /* If not affecting all vertices, just return. */ if (wmd->mix_set != MOD_WVG_SET_ALL) return dm; @@ -268,67 +268,67 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* Ultimate security check. */ if (!dvert) return dm; - + } /* Find out which vertices to work on. */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGMix Modifier, tidx"); - tdw1 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw1"); - tdw2 = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGMix Modifier, tdw2"); + tdw1 = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGMix Modifier, tdw1"); + tdw2 = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGMix Modifier, tdw2"); switch (wmd->mix_set) { - case MOD_WVG_SET_A: - /* All vertices in first vgroup. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx); - if (dw) { - tdw1[numIdx] = dw; - tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2); - tidx[numIdx++] = i; + case MOD_WVG_SET_A: + /* All vertices in first vgroup. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx); + if (dw) { + tdw1[numIdx] = dw; + tdw2[numIdx] = defvert_find_index(&dvert[i], defgrp_idx2); + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_B: - /* All vertices in second vgroup. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2); - if (dw) { - tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx); - tdw2[numIdx] = dw; - tidx[numIdx++] = i; + break; + case MOD_WVG_SET_B: + /* All vertices in second vgroup. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *dw = defvert_find_index(&dvert[i], defgrp_idx2); + if (dw) { + tdw1[numIdx] = defvert_find_index(&dvert[i], defgrp_idx); + tdw2[numIdx] = dw; + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_OR: - /* All vertices in one vgroup or the other. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); - MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); - if (adw || bdw) { - tdw1[numIdx] = adw; - tdw2[numIdx] = bdw; - tidx[numIdx++] = i; + break; + case MOD_WVG_SET_OR: + /* All vertices in one vgroup or the other. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + if (adw || bdw) { + tdw1[numIdx] = adw; + tdw2[numIdx] = bdw; + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_AND: - /* All vertices in both vgroups. */ - for (i = 0; i < numVerts; i++) { - MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); - MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); - if (adw && bdw) { - tdw1[numIdx] = adw; - tdw2[numIdx] = bdw; - tidx[numIdx++] = i; + break; + case MOD_WVG_SET_AND: + /* All vertices in both vgroups. */ + for (i = 0; i < numVerts; i++) { + MDeformWeight *adw = defvert_find_index(&dvert[i], defgrp_idx); + MDeformWeight *bdw = defvert_find_index(&dvert[i], defgrp_idx2); + if (adw && bdw) { + tdw1[numIdx] = adw; + tdw2[numIdx] = bdw; + tidx[numIdx++] = i; + } } - } - break; - case MOD_WVG_SET_ALL: - default: - /* Use all vertices. */ - for (i = 0; i < numVerts; i++) { - tdw1[i] = defvert_find_index(&dvert[i], defgrp_idx); - tdw2[i] = defvert_find_index(&dvert[i], defgrp_idx2); - } - numIdx = -1; - break; + break; + case MOD_WVG_SET_ALL: + default: + /* Use all vertices. */ + for (i = 0; i < numVerts; i++) { + tdw1[i] = defvert_find_index(&dvert[i], defgrp_idx); + tdw2[i] = defvert_find_index(&dvert[i], defgrp_idx2); + } + numIdx = -1; + break; } if (numIdx == 0) { /* Use no vertices! Hence, return org data. */ @@ -340,11 +340,11 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (numIdx != -1) { indices = MEM_mallocN(sizeof(int) * numIdx, "WeightVGMix Modifier, indices"); memcpy(indices, tidx, sizeof(int) * numIdx); - dw1 = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGMix Modifier, dw1"); - memcpy(dw1, tdw1, sizeof(MDeformWeight*) * numIdx); + dw1 = MEM_mallocN(sizeof(MDeformWeight *) * numIdx, "WeightVGMix Modifier, dw1"); + memcpy(dw1, tdw1, sizeof(MDeformWeight *) * numIdx); MEM_freeN(tdw1); - dw2 = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGMix Modifier, dw2"); - memcpy(dw2, tdw2, sizeof(MDeformWeight*) * numIdx); + dw2 = MEM_mallocN(sizeof(MDeformWeight *) * numIdx, "WeightVGMix Modifier, dw2"); + memcpy(dw2, tdw2, sizeof(MDeformWeight *) * numIdx); MEM_freeN(tdw2); } else { @@ -402,7 +402,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, struct BMEditMesh *UNUSED(editData), DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } @@ -411,10 +411,10 @@ ModifierTypeInfo modifierType_WeightVGMix = { /* structName */ "WeightVGMixModifierData", /* structSize */ sizeof(WeightVGMixModifierData), /* type */ eModifierTypeType_NonGeometrical, - /* flags */ eModifierTypeFlag_AcceptsMesh - |eModifierTypeFlag_SupportsMapping - |eModifierTypeFlag_SupportsEditmode - |eModifierTypeFlag_UsesPreview, + /* flags */ eModifierTypeFlag_AcceptsMesh | + eModifierTypeFlag_SupportsMapping | + eModifierTypeFlag_SupportsEditmode | + eModifierTypeFlag_UsesPreview, /* copyData */ copyData, /* deformVerts */ NULL, diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 31cd20e7f97..70b9eafdac5 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -73,9 +73,9 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3], BVHTreeFromMesh treeData_v = NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData_e = NULL_BVHTreeFromMesh; BVHTreeFromMesh treeData_f = NULL_BVHTreeFromMesh; - BVHTreeNearest nearest_v = NULL_BVHTreeNearest; - BVHTreeNearest nearest_e = NULL_BVHTreeNearest; - BVHTreeNearest nearest_f = NULL_BVHTreeNearest; + BVHTreeNearest nearest_v = NULL_BVHTreeNearest; + BVHTreeNearest nearest_e = NULL_BVHTreeNearest; + BVHTreeNearest nearest_f = NULL_BVHTreeNearest; if (dist_v) { /* Create a bvh-tree of the given target's verts. */ @@ -159,11 +159,11 @@ static void get_vert2geom_distance(int numVerts, float (*v_cos)[3], * Note that it works in final world space (i.e. with constraints etc. applied). */ static void get_vert2ob_distance(int numVerts, float (*v_cos)[3], float *dist, - Object* ob, Object* obr) + Object *ob, Object *obr) { /* Vertex and ref object coordinates. */ float v_wco[3]; - unsigned int i= numVerts; + unsigned int i = numVerts; while (i-- > 0) { /* Get world-coordinates of the vertex (constraints and anim included). */ @@ -177,7 +177,7 @@ static void get_vert2ob_distance(int numVerts, float (*v_cos)[3], float *dist, * Returns the real distance between an object and another reference object. * Note that it works in final world space (i.e. with constraints etc. applied). */ -static float get_ob2ob_distance(const Object* ob, const Object* obr) +static float get_ob2ob_distance(const Object *ob, const Object *obr) { return len_v3v3(ob->obmat[3], obr->obmat[3]); } @@ -187,8 +187,8 @@ static float get_ob2ob_distance(const Object* ob, const Object* obr) */ void do_map(float *weights, const int nidx, const float min_d, const float max_d, short mode) { - const float range_inv= 1.0f / (max_d - min_d); /* invert since multiplication is faster */ - unsigned int i= nidx; + const float range_inv = 1.0f / (max_d - min_d); /* invert since multiplication is faster */ + unsigned int i = nidx; if (max_d == min_d) { while (i-- > 0) { weights[i] = (weights[i] >= max_d) ? 1.0f : 0.0f; /* "Step" behavior... */ @@ -196,16 +196,16 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d } else if (max_d > min_d) { while (i-- > 0) { - if (weights[i] >= max_d) weights[i]= 1.0f; /* most likely case first */ - else if (weights[i] <= min_d) weights[i]= 0.0f; - else weights[i]= (weights[i] - min_d) * range_inv; + if (weights[i] >= max_d) weights[i] = 1.0f; /* most likely case first */ + else if (weights[i] <= min_d) weights[i] = 0.0f; + else weights[i] = (weights[i] - min_d) * range_inv; } } else { while (i-- > 0) { - if (weights[i] <= max_d) weights[i]= 1.0f; /* most likely case first */ - else if (weights[i] >= min_d) weights[i]= 0.0f; - else weights[i]= (weights[i] - min_d) * range_inv; + if (weights[i] <= max_d) weights[i] = 1.0f; /* most likely case first */ + else if (weights[i] >= min_d) weights[i] = 0.0f; + else weights[i] = (weights[i] - min_d) * range_inv; } } @@ -219,7 +219,7 @@ void do_map(float *weights, const int nidx, const float min_d, const float max_d **************************************/ static void initData(ModifierData *md) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; wmd->proximity_mode = MOD_WVG_PROXIMITY_OBJECT; wmd->proximity_flags = MOD_WVG_PROXIMITY_GEOM_VERTS; @@ -234,8 +234,8 @@ static void initData(ModifierData *md) static void copyData(ModifierData *md, ModifierData *target) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; - WeightVGProximityModifierData *twmd = (WeightVGProximityModifierData*) target; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; + WeightVGProximityModifierData *twmd = (WeightVGProximityModifierData *) target; BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name)); twmd->proximity_mode = wmd->proximity_mode; @@ -257,7 +257,7 @@ static void copyData(ModifierData *md, ModifierData *target) static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; CustomDataMask dataMask = 0; /* We need vertex groups! */ @@ -274,7 +274,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md) static int dependsOnTime(ModifierData *md) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; if (wmd->mask_texture) return BKE_texture_dependsOnTime(wmd->mask_texture); @@ -285,14 +285,14 @@ static void foreachObjectLink(ModifierData *md, Object *ob, void (*walk)(void *userData, Object *ob, Object **obpoin), void *userData) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; walk(userData, ob, &wmd->proximity_ob_target); walk(userData, ob, &wmd->mask_tex_map_obj); } static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; walk(userData, ob, (ID **)&wmd->mask_texture); @@ -307,12 +307,12 @@ static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UNUSED(scene), Object *UNUSED(ob), DagNode *obNode) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; DagNode *curNode; if (wmd->proximity_ob_target) { curNode = dag_get_node(forest, wmd->proximity_ob_target); - dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA|DAG_RL_OB_DATA, + dag_add_relation(forest, curNode, obNode, DAG_RL_DATA_DATA | DAG_RL_OB_DATA, "WeightVGProximity Modifier"); } @@ -330,7 +330,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest, struct Scene *UN static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; /* If no vertex group, bypass. */ if (wmd->defgrp_name[0] == '\0') return 1; /* If no target object, bypass. */ @@ -338,9 +338,9 @@ static int isDisabled(ModifierData *md, int UNUSED(useRenderParams)) } static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *derivedData, - int UNUSED(useRenderParams), int UNUSED(isFinalCalc)) + ModifierApplyFlag UNUSED(flag)) { - WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData*) md; + WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *) md; DerivedMesh *dm = derivedData; MDeformVert *dvert = NULL; MDeformWeight **dw, **tdw; @@ -350,7 +350,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der int defgrp_idx; float *tw = NULL; float *org_w = NULL; - float *new_w =NULL; + float *new_w = NULL; int *tidx, *indices = NULL; int numIdx = 0; int i; @@ -392,7 +392,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der */ tidx = MEM_mallocN(sizeof(int) * numVerts, "WeightVGProximity Modifier, tidx"); tw = MEM_mallocN(sizeof(float) * numVerts, "WeightVGProximity Modifier, tw"); - tdw = MEM_mallocN(sizeof(MDeformWeight*) * numVerts, "WeightVGProximity Modifier, tdw"); + tdw = MEM_mallocN(sizeof(MDeformWeight *) * numVerts, "WeightVGProximity Modifier, tdw"); for (i = 0; i < numVerts; i++) { MDeformWeight *_dw = defvert_find_index(&dvert[i], defgrp_idx); if (_dw) { @@ -413,8 +413,8 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der memcpy(indices, tidx, sizeof(int) * numIdx); org_w = MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, org_w"); memcpy(org_w, tw, sizeof(float) * numIdx); - dw = MEM_mallocN(sizeof(MDeformWeight*) * numIdx, "WeightVGProximity Modifier, dw"); - memcpy(dw, tdw, sizeof(MDeformWeight*) * numIdx); + dw = MEM_mallocN(sizeof(MDeformWeight *) * numIdx, "WeightVGProximity Modifier, dw"); + memcpy(dw, tdw, sizeof(MDeformWeight *) * numIdx); MEM_freeN(tw); MEM_freeN(tdw); } @@ -458,7 +458,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der if (ELEM3(obr->type, OB_CURVE, OB_SURF, OB_FONT)) target_dm = CDDM_from_curve(obr); else if (obr->type == OB_MESH) { - Mesh *me = (Mesh*)obr->data; + Mesh *me = (Mesh *)obr->data; if (me->edit_btmesh) target_dm = CDDM_from_BMEditMesh(me->edit_btmesh, me, FALSE, FALSE); else @@ -470,9 +470,9 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob, DerivedMesh *der /* We must check that we do have a valid target_dm! */ if (target_dm) { SpaceTransform loc2trgt; - float *dists_v = use_trgt_verts ? MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, dists_v") : NULL; - float *dists_e = use_trgt_edges ? MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, dists_e") : NULL; - float *dists_f = use_trgt_faces ? MEM_mallocN(sizeof(float) * numIdx, "WeightVGProximity Modifier, dists_f") : NULL; + float *dists_v = use_trgt_verts ? MEM_mallocN(sizeof(float) * numIdx, "dists_v") : NULL; + float *dists_e = use_trgt_edges ? MEM_mallocN(sizeof(float) * numIdx, "dists_e") : NULL; + float *dists_f = use_trgt_faces ? MEM_mallocN(sizeof(float) * numIdx, "dists_f") : NULL; space_transform_setup(&loc2trgt, ob, obr); get_vert2geom_distance(numIdx, v_cos, dists_v, dists_e, dists_f, @@ -537,7 +537,7 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *ob, struct BMEditMesh *UNUSED(editData), DerivedMesh *derivedData) { - return applyModifier(md, ob, derivedData, 0, 1); + return applyModifier(md, ob, derivedData, MOD_APPLY_USECACHE); } diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 9bcbc91265c..be9dd10b71d 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -149,6 +149,7 @@ set(SRC shader/nodes/node_shader_volume_transparent.c shader/nodes/node_shader_volume_isotropic.c shader/nodes/node_shader_light_path.c + shader/nodes/node_shader_light_falloff.c shader/nodes/node_shader_mix_shader.c shader/nodes/node_shader_add_shader.c shader/nodes/node_shader_output_lamp.c diff --git a/source/blender/nodes/NOD_shader.h b/source/blender/nodes/NOD_shader.h index d2b3a61971b..3d93f41cfe5 100644 --- a/source/blender/nodes/NOD_shader.h +++ b/source/blender/nodes/NOD_shader.h @@ -73,6 +73,7 @@ void register_node_type_sh_hue_sat(struct bNodeTreeType *ttype); void register_node_type_sh_attribute(struct bNodeTreeType *ttype); void register_node_type_sh_geometry(struct bNodeTreeType *ttype); void register_node_type_sh_light_path(struct bNodeTreeType *ttype); +void register_node_type_sh_light_falloff(struct bNodeTreeType *ttype); void register_node_type_sh_fresnel(struct bNodeTreeType *ttype); void register_node_type_sh_layer_weight(struct bNodeTreeType *ttype); void register_node_type_sh_tex_coord(struct bNodeTreeType *ttype); diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c index 049b5dd8178..b526c25e2dc 100644 --- a/source/blender/nodes/composite/node_composite_tree.c +++ b/source/blender/nodes/composite/node_composite_tree.c @@ -136,7 +136,7 @@ static void localize(bNodeTree *localtree, bNodeTree *ntree) if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (node->id) { if (node->flag & NODE_DO_OUTPUT) - node->new_node->id= (ID *)copy_image((Image *)node->id); + node->new_node->id= (ID *)BKE_image_copy((Image *)node->id); else node->new_node->id= NULL; } diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c index 1789710b096..4467fb1f193 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.c +++ b/source/blender/nodes/composite/nodes/node_composite_image.c @@ -66,13 +66,17 @@ static bNodeSocketTemplate cmp_node_rlayers_out[]= { { -1, 0, "" } }; -static bNodeSocket *cmp_node_image_add_render_pass_output(bNodeTree *ntree, bNode *node, int UNUSED(pass), int rres_index) +static bNodeSocket *cmp_node_image_add_render_pass_output(bNodeTree *ntree, bNode *node, int pass, int rres_index) { bNodeSocket *sock; + NodeImageLayer *sockdata; sock = node_add_output_from_template(ntree, node, &cmp_node_rlayers_out[rres_index]); - /* for render pass outputs store the pass type index as a lookup key */ - sock->storage = SET_INT_IN_POINTER(rres_index); + /* extra socket info */ + sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer"); + sock->storage = sockdata; + + sockdata->pass_flag = pass; return sock; } @@ -141,21 +145,37 @@ static void cmp_node_image_add_render_pass_outputs(bNodeTree *ntree, bNode *node cmp_node_image_add_render_pass_output(ntree, node, SCE_PASS_TRANSM_COLOR, RRES_OUT_TRANSM_COLOR); } -static void cmp_node_image_add_multilayer_outputs(bNodeTree *ntree, bNode *node, RenderLayer *rl) +static void cmp_node_image_add_multilayer_outputs(bNodeTree *ntree, bNode *node, ListBase *layers) { bNodeSocket *sock; + NodeImageLayer *sockdata; + RenderLayer *rl; RenderPass *rpass; - int index; - for (rpass=rl->passes.first, index=0; rpass; rpass=rpass->next, ++index) { - int type; - if (rpass->channels == 1) - type = SOCK_FLOAT; - else - type = SOCK_RGBA; - - sock = nodeAddSocket(ntree, node, SOCK_OUT, rpass->name, type); - /* for multilayer image use pass index directly as key */ - sock->storage = SET_INT_IN_POINTER(index); + int layer_index, pass_index; + char name[30]; /* EXR_TOT_MAXNAME-2 ('.' and channel char are appended) */ + int type; + + for (rl=layers->first, layer_index=0; rl; rl=rl->next, ++layer_index) { + for (rpass=rl->passes.first, pass_index=0; rpass; rpass=rpass->next, ++pass_index) { + /* reconstruct layer name from . strings */ + if (rl->name[0] != '\0') + BLI_snprintf(name, sizeof(name), "%s.%s", rl->name, rpass->name); + else + BLI_strncpy(name, rpass->name, sizeof(name)); + + if (rpass->channels == 1) + type = SOCK_FLOAT; + else + type = SOCK_RGBA; + + sock = nodeAddSocket(ntree, node, SOCK_OUT, name, type); + /* extra socket info */ + sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer"); + sock->storage = sockdata; + + sockdata->layer_index = layer_index; + sockdata->pass_index = pass_index; + } } } @@ -169,16 +189,16 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree, bNode *node) BKE_image_get_ibuf(ima, iuser); if (ima->rr) { - RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); - - if (rl) { - if (ima->type!=IMA_TYPE_MULTILAYER) + if (ima->type == IMA_TYPE_MULTILAYER) { + cmp_node_image_add_multilayer_outputs(ntree, node, &ima->rr->layers); + } + else { + RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); + if (rl) cmp_node_image_add_render_pass_outputs(ntree, node, rl->passflag); else - cmp_node_image_add_multilayer_outputs(ntree, node, rl); + cmp_node_image_add_render_pass_outputs(ntree, node, RRES_OUT_IMAGE|RRES_OUT_ALPHA); } - else - cmp_node_image_add_render_pass_outputs(ntree, node, RRES_OUT_IMAGE|RRES_OUT_ALPHA); } else cmp_node_image_add_render_pass_outputs(ntree, node, RRES_OUT_IMAGE|RRES_OUT_ALPHA|RRES_OUT_Z); @@ -261,6 +281,7 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node) */ for (oldsock=oldsocklist.first; oldsock; oldsock=oldsock_next) { oldsock_next = oldsock->next; + MEM_freeN(oldsock->storage); nodeRemoveSocket(ntree, node, oldsock); } } @@ -394,17 +415,21 @@ static CompBuf *node_composit_get_zimage(bNode *node, RenderData *rd) } /* check if layer is available, returns pass buffer */ -static CompBuf *compbuf_multilayer_get(RenderData *rd, RenderLayer *rl, Image *ima, ImageUser *iuser, int passindex) +static CompBuf *compbuf_multilayer_get(RenderData *rd, Image *ima, ImageUser *iuser, int layer_index, int pass_index) { - RenderPass *rpass = BLI_findlink(&rl->passes, passindex); - if (rpass) { - CompBuf *cbuf; - - iuser->pass = passindex; - BKE_image_multilayer_index(ima->rr, iuser); - cbuf = node_composit_get_image(rd, ima, iuser); - - return cbuf; + RenderLayer *rl = BLI_findlink(&ima->rr->layers, layer_index); + if (rl) { + RenderPass *rpass = BLI_findlink(&rl->passes, pass_index); + if (rpass) { + CompBuf *cbuf; + + iuser->layer = layer_index; + iuser->pass = pass_index; + BKE_image_multilayer_index(ima->rr, iuser); + cbuf = node_composit_get_image(rd, ima, iuser); + + return cbuf; + } } return NULL; } @@ -420,24 +445,22 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE ImageUser *iuser= (ImageUser *)node->storage; /* first set the right frame number in iuser */ - BKE_image_user_calc_frame(iuser, rd->cfra, 0); + BKE_image_user_frame_calc(iuser, rd->cfra, 0); - /* force a load, we assume iuser index will be set OK anyway */ - if (ima->type==IMA_TYPE_MULTILAYER) + if (ima->type==IMA_TYPE_MULTILAYER) { + /* force a load, we assume iuser index will be set OK anyway */ BKE_image_get_ibuf(ima, iuser); - if (ima->type==IMA_TYPE_MULTILAYER && ima->rr) { - RenderLayer *rl= BLI_findlink(&ima->rr->layers, iuser->layer); - - if (rl) { + if (ima->rr) { bNodeSocket *sock; + NodeImageLayer *sockdata; int out_index; CompBuf *combinedbuf= NULL, *firstbuf= NULL; for (sock=node->outputs.first, out_index=0; sock; sock=sock->next, ++out_index) { - int passindex = GET_INT_FROM_POINTER(sock->storage); + sockdata = sock->storage; if (out[out_index]->hasoutput) { - CompBuf *stackbuf = out[out_index]->data = compbuf_multilayer_get(rd, rl, ima, iuser, passindex); + CompBuf *stackbuf = out[out_index]->data = compbuf_multilayer_get(rd, ima, iuser, sockdata->layer_index, sockdata->pass_index); if (stackbuf) { /* preview policy: take first 'Combined' pass if available, * otherwise just use the first layer. @@ -446,7 +469,7 @@ static void node_composit_exec_image(void *data, bNode *node, bNodeStack **UNUSE firstbuf = stackbuf; } if (!combinedbuf && - (strcmp(sock->name, "Combined") == 0 || strcmp(sock->name, "Image") == 0)) + (strcmp(sock->name, "Combined") == 0 || strcmp(sock->name, "Image") == 0)) { combinedbuf = stackbuf; } @@ -520,6 +543,28 @@ static void node_composit_init_image(bNodeTree *ntree, bNode* node, bNodeTemplat cmp_node_image_verify_outputs(ntree, node); } +static void node_composit_free_image(bNode *node) +{ + bNodeSocket *sock; + + /* free extra socket info */ + for (sock=node->outputs.first; sock; sock=sock->next) + MEM_freeN(sock->storage); + + MEM_freeN(node->storage); +} + +static void node_composit_copy_image(bNode *orig_node, bNode *new_node) +{ + bNodeSocket *sock; + + new_node->storage= MEM_dupallocN(orig_node->storage); + + /* copy extra socket info */ + for (sock=orig_node->outputs.first; sock; sock=sock->next) + sock->new_sock->storage = MEM_dupallocN(sock->storage); +} + void register_node_type_cmp_image(bNodeTreeType *ttype) { static bNodeType ntype; @@ -527,7 +572,7 @@ void register_node_type_cmp_image(bNodeTreeType *ttype) node_type_base(ttype, &ntype, CMP_NODE_IMAGE, "Image", NODE_CLASS_INPUT, NODE_PREVIEW|NODE_OPTIONS); node_type_size(&ntype, 120, 80, 300); node_type_init(&ntype, node_composit_init_image); - node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage); + node_type_storage(&ntype, "ImageUser", node_composit_free_image, node_composit_copy_image); node_type_update(&ntype, cmp_node_image_update, NULL); node_type_exec(&ntype, node_composit_exec_image); diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c index f89dcf63f64..a571b140a1f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c +++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c @@ -45,6 +45,64 @@ /* **************** OUTPUT FILE ******************** */ +/* find unique path */ +static int unique_path_unique_check(void *arg, const char *name) +{ + struct {ListBase *lb; bNodeSocket *sock;} *data= arg; + bNodeSocket *sock; + for (sock=data->lb->first; sock; sock=sock->next) { + if (sock != data->sock) { + NodeImageMultiFileSocket *sockdata = sock->storage; + if (strcmp(sockdata->path, name)==0) + return 1; + } + } + return 0; +} +void ntreeCompositOutputFileUniquePath(ListBase *list, bNodeSocket *sock, const char defname[], char delim) +{ + NodeImageMultiFileSocket *sockdata; + struct {ListBase *lb; bNodeSocket *sock;} data; + data.lb = list; + data.sock = sock; + + /* See if we are given an empty string */ + if (ELEM(NULL, sock, defname)) + return; + + sockdata = sock->storage; + BLI_uniquename_cb(unique_path_unique_check, &data, defname, delim, sockdata->path, sizeof(sockdata->path)); +} + +/* find unique EXR layer */ +static int unique_layer_unique_check(void *arg, const char *name) +{ + struct {ListBase *lb; bNodeSocket *sock;} *data= arg; + bNodeSocket *sock; + for (sock=data->lb->first; sock; sock=sock->next) { + if (sock != data->sock) { + NodeImageMultiFileSocket *sockdata = sock->storage; + if (strcmp(sockdata->layer, name)==0) + return 1; + } + } + return 0; +} +void ntreeCompositOutputFileUniqueLayer(ListBase *list, bNodeSocket *sock, const char defname[], char delim) +{ + NodeImageMultiFileSocket *sockdata; + struct {ListBase *lb; bNodeSocket *sock;} data; + data.lb = list; + data.sock = sock; + + /* See if we are given an empty string */ + if (ELEM(NULL, sock, defname)) + return; + + sockdata = sock->storage; + BLI_uniquename_cb(unique_layer_unique_check, &data, defname, delim, sockdata->layer, sizeof(sockdata->layer)); +} + bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, const char *name, ImageFormatData *im_format) { NodeImageMultiFile *nimf = node->storage; @@ -54,7 +112,10 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, bNode *node, con NodeImageMultiFileSocket *sockdata = MEM_callocN(sizeof(NodeImageMultiFileSocket), "socket image format"); sock->storage = sockdata; - BLI_strncpy(sockdata->path, name, sizeof(sockdata->path)); + BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path)); + ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_'); + BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer)); + ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); if (im_format) { sockdata->format= *im_format; @@ -89,6 +150,20 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node) return 1; } +void ntreeCompositOutputFileSetPath(bNode *node, bNodeSocket *sock, const char *name) +{ + NodeImageMultiFileSocket *sockdata = sock->storage; + BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path)); + ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_'); +} + +void ntreeCompositOutputFileSetLayer(bNode *node, bNodeSocket *sock, const char *name) +{ + NodeImageMultiFileSocket *sockdata = sock->storage; + BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer)); + ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); +} + static void init_output_file(bNodeTree *ntree, bNode* node, bNodeTemplate *ntemp) { NodeImageMultiFile *nimf= MEM_callocN(sizeof(NodeImageMultiFile), "node image multi file"); @@ -192,7 +267,7 @@ static void exec_output_file_singlelayer(RenderData *rd, bNode *node, bNodeStack BLI_join_dirfile(path, FILE_MAX, nimf->base_path, sockdata->path); BKE_makepicstring(filename, path, bmain->name, rd->cfra, format->imtype, (rd->scemode & R_EXTENSION), TRUE); - if (0 == BKE_write_ibuf(ibuf, filename, format)) + if (0 == BKE_imbuf_write(ibuf, filename, format)) printf("Cannot save Node File Output to %s\n", filename); else printf("Saved: %s\n", filename); @@ -232,8 +307,7 @@ static void exec_output_file_multilayer(RenderData *rd, bNode *node, bNodeStack if (in[i]->data) { NodeImageMultiFileSocket *sockdata = sock->storage; CompBuf *cbuf = in[i]->data; - char layname[EXR_LAY_MAXNAME]; - char channelname[EXR_PASS_MAXNAME]; + char channelname[EXR_TOT_MAXNAME]; /* '.' and single character channel name is appended */ char *channelname_ext; if (cbuf->rect_procedural) { @@ -249,39 +323,38 @@ static void exec_output_file_multilayer(RenderData *rd, bNode *node, bNodeStack continue; } - BLI_strncpy(layname, sockdata->path, sizeof(layname)); - BLI_strncpy(channelname, sockdata->path, sizeof(channelname)-2); + BLI_strncpy(channelname, sockdata->layer, sizeof(channelname)-2); channelname_ext = channelname + strlen(channelname); /* create channels */ switch (cbuf->type) { case CB_VAL: strcpy(channelname_ext, ".V"); - IMB_exr_add_channel(exrhandle, layname, channelname, 1, rectx, cbuf->rect); + IMB_exr_add_channel(exrhandle, NULL, channelname, 1, rectx, cbuf->rect); break; case CB_VEC2: strcpy(channelname_ext, ".X"); - IMB_exr_add_channel(exrhandle, layname, channelname, 2, 2*rectx, cbuf->rect); + IMB_exr_add_channel(exrhandle, NULL, channelname, 2, 2*rectx, cbuf->rect); strcpy(channelname_ext, ".Y"); - IMB_exr_add_channel(exrhandle, layname, channelname, 2, 2*rectx, cbuf->rect+1); + IMB_exr_add_channel(exrhandle, NULL, channelname, 2, 2*rectx, cbuf->rect+1); break; case CB_VEC3: strcpy(channelname_ext, ".X"); - IMB_exr_add_channel(exrhandle, layname, channelname, 3, 3*rectx, cbuf->rect); + IMB_exr_add_channel(exrhandle, NULL, channelname, 3, 3*rectx, cbuf->rect); strcpy(channelname_ext, ".Y"); - IMB_exr_add_channel(exrhandle, layname, channelname, 3, 3*rectx, cbuf->rect+1); + IMB_exr_add_channel(exrhandle, NULL, channelname, 3, 3*rectx, cbuf->rect+1); strcpy(channelname_ext, ".Z"); - IMB_exr_add_channel(exrhandle, layname, channelname, 3, 3*rectx, cbuf->rect+2); + IMB_exr_add_channel(exrhandle, NULL, channelname, 3, 3*rectx, cbuf->rect+2); break; case CB_RGBA: strcpy(channelname_ext, ".R"); - IMB_exr_add_channel(exrhandle, layname, channelname, 4, 4*rectx, cbuf->rect); + IMB_exr_add_channel(exrhandle, NULL, channelname, 4, 4*rectx, cbuf->rect); strcpy(channelname_ext, ".G"); - IMB_exr_add_channel(exrhandle, layname, channelname, 4, 4*rectx, cbuf->rect+1); + IMB_exr_add_channel(exrhandle, NULL, channelname, 4, 4*rectx, cbuf->rect+1); strcpy(channelname_ext, ".B"); - IMB_exr_add_channel(exrhandle, layname, channelname, 4, 4*rectx, cbuf->rect+2); + IMB_exr_add_channel(exrhandle, NULL, channelname, 4, 4*rectx, cbuf->rect+2); strcpy(channelname_ext, ".A"); - IMB_exr_add_channel(exrhandle, layname, channelname, 4, 4*rectx, cbuf->rect+3); + IMB_exr_add_channel(exrhandle, NULL, channelname, 4, 4*rectx, cbuf->rect+3); break; } diff --git a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c index c2263053987..a12a1042553 100644 --- a/source/blender/nodes/composite/nodes/node_composite_splitViewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_splitViewer.c @@ -69,7 +69,7 @@ static void node_composit_exec_splitviewer(void *data, bNode *node, bNodeStack * buf1= typecheck_compbuf(in[0]->data, CB_RGBA); buf2= typecheck_compbuf(in[1]->data, CB_RGBA); - BKE_image_user_calc_frame(node->storage, rd->cfra, 0); + BKE_image_user_frame_calc(node->storage, rd->cfra, 0); /* always returns for viewer image, but we check nevertheless */ ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); diff --git a/source/blender/nodes/composite/nodes/node_composite_texture.c b/source/blender/nodes/composite/nodes/node_composite_texture.c index 0b521fac3e1..5447c2af031 100644 --- a/source/blender/nodes/composite/nodes/node_composite_texture.c +++ b/source/blender/nodes/composite/nodes/node_composite_texture.c @@ -73,11 +73,11 @@ static void texture_procedural(CompBuf *cbuf, float *out, float xco, float yco) col[3]= texres.tin; if ((retval & TEX_RGB)) { - col[0]= texres.tr; - col[1]= texres.tg; - col[2]= texres.tb; + copy_v3_v3(col, &texres.tr); + } + else { + copy_v3_fl(col, col[3]); } - else col[0]= col[1]= col[2]= col[3]; } else { copy_v3_v3(col, nor); diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.c b/source/blender/nodes/composite/nodes/node_composite_viewer.c index f9b1e55f29f..3fdedbb2e42 100644 --- a/source/blender/nodes/composite/nodes/node_composite_viewer.c +++ b/source/blender/nodes/composite/nodes/node_composite_viewer.c @@ -55,7 +55,7 @@ static void node_composit_exec_viewer(void *data, bNode *node, bNodeStack **in, int rectx, recty; void *lock; - BKE_image_user_calc_frame(node->storage, rd->cfra, 0); + BKE_image_user_frame_calc(node->storage, rd->cfra, 0); /* always returns for viewer image, but we check nevertheless */ ibuf= BKE_image_acquire_ibuf(ima, node->storage, &lock); diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c index 3aadcef4c82..49a3d6c07b4 100644 --- a/source/blender/nodes/intern/node_common.c +++ b/source/blender/nodes/intern/node_common.c @@ -368,7 +368,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) bAction *waction; /* firstly, wgroup needs to temporary dummy action that can be destroyed, as it shares copies */ - waction = wgroup->adt->action = copy_action(wgroup->adt->action); + waction = wgroup->adt->action = BKE_action_copy(wgroup->adt->action); /* now perform the moving */ BKE_animdata_separate_by_basepath(&wgroup->id, &ntree->id, &anim_basepaths); @@ -383,7 +383,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) /* free temp action too */ if (waction) { - free_libblock(&G.main->action, waction); + BKE_libblock_free(&G.main->action, waction); } } @@ -391,7 +391,7 @@ int node_group_ungroup(bNodeTree *ntree, bNode *gnode) nodeFreeNode(ntree, gnode); /* free the group tree (takes care of user count) */ - free_libblock(&G.main->nodetree, wgroup); + BKE_libblock_free(&G.main->nodetree, wgroup); ntree->update |= NTREE_UPDATE_NODES | NTREE_UPDATE_LINKS; ntreeUpdateTree(ntree); diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c index c028ca83664..716d31a8cd1 100644 --- a/source/blender/nodes/shader/node_shader_tree.c +++ b/source/blender/nodes/shader/node_shader_tree.c @@ -83,7 +83,7 @@ static void foreach_nodeclass(Scene *scene, void *calldata, bNodeClassCallback f func(calldata, NODE_CLASS_INPUT, IFACE_("Input")); func(calldata, NODE_CLASS_OUTPUT, IFACE_("Output")); - if (scene_use_new_shading_nodes(scene)) { + if (BKE_scene_use_new_shading_nodes(scene)) { func(calldata, NODE_CLASS_SHADER, IFACE_("Shader")); func(calldata, NODE_CLASS_TEXTURE, IFACE_("Texture")); } diff --git a/source/blender/nodes/shader/nodes/node_shader_dynamic.c b/source/blender/nodes/shader/nodes/node_shader_dynamic.c index 5a6a92b5e27..b441545441a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_dynamic.c +++ b/source/blender/nodes/shader/nodes/node_shader_dynamic.c @@ -254,7 +254,7 @@ static void node_dynamic_rem_all_links(bNodeType *tinfo) /* node_dynamic_reset: clean a pynode, getting rid of all * data dynamically created for it. */ -static void node_dynamic_reset(bNode *node, int unlink_text) +static void node_dynamic_reset(bNode *node, int BKE_text_unlink) { bNodeType *tinfo, *tinfo_default; Material *ma; @@ -262,7 +262,7 @@ static void node_dynamic_reset(bNode *node, int unlink_text) tinfo = node->typeinfo; tinfo_default = node_dynamic_find_typeinfo(&node_all_shaders, NULL); - if ((tinfo == tinfo_default) && unlink_text) { + if ((tinfo == tinfo_default) && BKE_text_unlink) { ID *textID = node->id; /* already at default (empty) state, which happens if this node's * script failed to parse at the first stage: definition. We're here @@ -296,7 +296,7 @@ static void node_dynamic_reset(bNode *node, int unlink_text) node_dynamic_free_sockets(nd); //node_dynamic_update_socket_links(nd, ma->nodetree); nd->typeinfo = tinfo_default; - if (unlink_text) { + if (BKE_text_unlink) { nd->id = NULL; nd->custom1 = 0; nd->custom1 = BSET(nd->custom1, NODE_DYNAMIC_NEW); diff --git a/source/blender/nodes/shader/nodes/node_shader_light_falloff.c b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c new file mode 100644 index 00000000000..8ee0f0adef6 --- /dev/null +++ b/source/blender/nodes/shader/nodes/node_shader_light_falloff.c @@ -0,0 +1,68 @@ +/* + * ***** 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) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include "../node_shader_util.h" + +/* **************** INPUT ********************* */ + +static bNodeSocketTemplate sh_node_light_falloff_in[]= { + { SOCK_FLOAT, 0, "Strength", 100.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Smooth", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +/* **************** OUTPUT ******************** */ + +static bNodeSocketTemplate sh_node_light_falloff_out[]= { + { SOCK_FLOAT, 0, "Quadratic", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Linear", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { SOCK_FLOAT, 0, "Constant", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, + { -1, 0, "" } +}; + +static int node_shader_gpu_light_falloff(GPUMaterial *mat, bNode *UNUSED(node), GPUNodeStack *in, GPUNodeStack *out) +{ + return GPU_stack_link(mat, "node_light_falloff", in, out); +} + +/* node type definition */ +void register_node_type_sh_light_falloff(bNodeTreeType *ttype) +{ + static bNodeType ntype; + + node_type_base(ttype, &ntype, SH_NODE_LIGHT_FALLOFF, "Light Falloff", NODE_CLASS_OP_COLOR, 0); + node_type_compatibility(&ntype, NODE_NEW_SHADING); + node_type_socket_templates(&ntype, sh_node_light_falloff_in, sh_node_light_falloff_out); + node_type_size(&ntype, 150, 60, 200); + node_type_init(&ntype, NULL); + node_type_storage(&ntype, "", NULL, NULL); + node_type_exec(&ntype, NULL); + node_type_gpu(&ntype, node_shader_gpu_light_falloff); + + nodeRegisterType(ttype, &ntype); +} + diff --git a/source/blender/nodes/shader/nodes/node_shader_texture.c b/source/blender/nodes/shader/nodes/node_shader_texture.c index 7d3e532be0b..b5c7981b4b1 100644 --- a/source/blender/nodes/shader/nodes/node_shader_texture.c +++ b/source/blender/nodes/shader/nodes/node_shader_texture.c @@ -100,17 +100,13 @@ static void node_shader_exec_texture(void *data, bNode *node, bNodeStack **in, b else out[0]->vec[0]= texres.tin; - if ((retval & TEX_RGB)==0) { - out[1]->vec[0]= out[0]->vec[0]; - out[1]->vec[1]= out[0]->vec[0]; - out[1]->vec[2]= out[0]->vec[0]; - out[1]->vec[3]= 1.0f; + if ((retval & TEX_RGB) == 0) { + copy_v3_fl(out[1]->vec, out[0]->vec[0]); + out[1]->vec[3] = 1.0f; } else { - out[1]->vec[0]= texres.tr; - out[1]->vec[1]= texres.tg; - out[1]->vec[2]= texres.tb; - out[1]->vec[3]= 1.0f; + copy_v3_v3(out[1]->vec, &texres.tr); + out[1]->vec[3] = 1.0f; } copy_v3_v3(out[2]->vec, nor); diff --git a/source/blender/python/BPY_extern.h b/source/blender/python/BPY_extern.h index 33ea139b474..83a40ecc068 100644 --- a/source/blender/python/BPY_extern.h +++ b/source/blender/python/BPY_extern.h @@ -82,6 +82,7 @@ int BPY_string_exec(struct bContext *C, const char *expr); void BPY_DECREF(void *pyob_ptr); /* Py_DECREF() */ int BPY_context_member_get(struct bContext *C, const char *member, struct bContextDataResult *result); void BPY_context_set(struct bContext *C); +void BPY_context_update(struct bContext *C); void BPY_id_release(struct ID *id); diff --git a/source/blender/python/SConscript b/source/blender/python/SConscript index fb04db6f99c..b0164d24852 100644 --- a/source/blender/python/SConscript +++ b/source/blender/python/SConscript @@ -19,7 +19,7 @@ sources = env.Glob('bmesh/*.c') env.BlenderLib( libname = 'bf_python_bmesh', sources = Split(sources), includes = Split(incs), defines = defs, libtype = ['core','player'], priority = [362,165]) # generic -defs = [] +defs = ['GLEW_STATIC'] if is_debug: defs.append('_DEBUG') diff --git a/source/blender/python/generic/CMakeLists.txt b/source/blender/python/generic/CMakeLists.txt index 9a73911d697..eb8bd694231 100644 --- a/source/blender/python/generic/CMakeLists.txt +++ b/source/blender/python/generic/CMakeLists.txt @@ -46,4 +46,6 @@ set(SRC py_capi_utils.h ) +add_definitions(-DGLEW_STATIC) + blender_add_lib(bf_python_ext "${SRC}" "${INC}" "${INC_SYS}") diff --git a/source/blender/python/generic/bgl.c b/source/blender/python/generic/bgl.c index 3d695e4b270..ce11545c90d 100644 --- a/source/blender/python/generic/bgl.c +++ b/source/blender/python/generic/bgl.c @@ -44,6 +44,7 @@ #include "BLI_utildefines.h" static PyObject *Buffer_new(PyTypeObject *type, PyObject *args, PyObject *kwds); +static PyObject *Method_ShaderSource (PyObject *self, PyObject *args); /* Buffer sequence methods */ @@ -613,8 +614,10 @@ static PyObject *Buffer_repr(Buffer *self) BGL_Wrap(2, Accum, void, (GLenum, GLfloat)) +BGL_Wrap(1, ActiveTexture, void, (GLenum)) BGL_Wrap(2, AlphaFunc, void, (GLenum, GLclampf)) BGL_Wrap(3, AreTexturesResident, GLboolean, (GLsizei, GLuintP, GLbooleanP)) +BGL_Wrap(2, AttachShader, void, (GLuint, GLuint)) BGL_Wrap(1, Begin, void, (GLenum)) BGL_Wrap(2, BindTexture, void, (GLenum, GLuint)) BGL_Wrap(7, Bitmap, void, (GLsizei, GLsizei, GLfloat, @@ -663,14 +666,20 @@ BGL_Wrap(4, Color4us, void, (GLushort, GLushort, GLushort, GLushort) BGL_Wrap(1, Color4usv, void, (GLushortP)) BGL_Wrap(4, ColorMask, void, (GLboolean, GLboolean, GLboolean, GLboolean)) BGL_Wrap(2, ColorMaterial, void, (GLenum, GLenum)) +BGL_Wrap(1, CompileShader, void, (GLuint)) BGL_Wrap(5, CopyPixels, void, (GLint, GLint, GLsizei, GLsizei, GLenum)) BGL_Wrap(8, CopyTexImage2D, void, (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint)) +BGL_Wrap(1, CreateProgram, GLuint, (void)) +BGL_Wrap(1, CreateShader, GLuint, (GLenum)) BGL_Wrap(1, CullFace, void, (GLenum)) BGL_Wrap(2, DeleteLists, void, (GLuint, GLsizei)) +BGL_Wrap(1, DeleteProgram, void, (GLuint)) +BGL_Wrap(1, DeleteShader, void, (GLuint)) BGL_Wrap(2, DeleteTextures, void, (GLsizei, GLuintP)) BGL_Wrap(1, DepthFunc, void, (GLenum)) BGL_Wrap(1, DepthMask, void, (GLboolean)) BGL_Wrap(2, DepthRange, void, (GLclampd, GLclampd)) +BGL_Wrap(2, DetachShader, void, (GLuint, GLuint)) BGL_Wrap(1, Disable, void, (GLenum)) BGL_Wrap(1, DrawBuffer, void, (GLenum)) BGL_Wrap(5, DrawPixels, void, (GLsizei, GLsizei, GLenum, GLenum, GLvoidP)) @@ -703,6 +712,7 @@ BGL_Wrap(6, Frustum, void, (GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble)) BGL_Wrap(1, GenLists, GLuint, (GLsizei)) BGL_Wrap(2, GenTextures, void, (GLsizei, GLuintP)) +BGL_Wrap(4, GetAttachedShaders, void, (GLuint, GLsizei, GLsizeiP, GLuintP)) BGL_Wrap(2, GetBooleanv, void, (GLenum, GLbooleanP)) BGL_Wrap(2, GetClipPlane, void, (GLenum, GLdoubleP)) BGL_Wrap(2, GetDoublev, void, (GLenum, GLdoubleP)) @@ -720,6 +730,11 @@ BGL_Wrap(2, GetPixelMapfv, void, (GLenum, GLfloatP)) BGL_Wrap(2, GetPixelMapuiv, void, (GLenum, GLuintP)) BGL_Wrap(2, GetPixelMapusv, void, (GLenum, GLushortP)) BGL_Wrap(1, GetPolygonStipple, void, (GLubyteP)) +BGL_Wrap(4, GetProgramInfoLog, void, (GLuint, GLsizei, GLsizeiP, GLcharP)) +BGL_Wrap(3, GetProgramiv, void, (GLuint, GLenum, GLintP)) +BGL_Wrap(4, GetShaderInfoLog, void, (GLuint, GLsizei, GLsizeiP, GLcharP)) +BGL_Wrap(3, GetShaderiv, void, (GLuint, GLenum, GLintP)) +BGL_Wrap(4, GetShaderSource, void, (GLuint, GLsizei, GLsizeiP, GLcharP)) BGL_Wrap(1, GetString, GLstring, (GLenum)) BGL_Wrap(3, GetTexEnvfv, void, (GLenum, GLenum, GLfloatP)) BGL_Wrap(3, GetTexEnviv, void, (GLenum, GLenum, GLintP)) @@ -731,6 +746,7 @@ BGL_Wrap(4, GetTexLevelParameterfv, void, (GLenum, GLint, GLenum, GLfloatP)) BGL_Wrap(4, GetTexLevelParameteriv, void, (GLenum, GLint, GLenum, GLintP)) BGL_Wrap(3, GetTexParameterfv, void, (GLenum, GLenum, GLfloatP)) BGL_Wrap(3, GetTexParameteriv, void, (GLenum, GLenum, GLintP)) +BGL_Wrap(2, GetUniformLocation, GLint, (GLuint, GLstring)) BGL_Wrap(2, Hint, void, (GLenum, GLenum)) BGL_Wrap(1, IndexMask, void, (GLuint)) BGL_Wrap(1, Indexd, void, (GLdouble)) @@ -744,6 +760,8 @@ BGL_Wrap(1, Indexsv, void, (GLshortP)) BGL_Wrap(1, InitNames, void, (void)) BGL_Wrap(1, IsEnabled, GLboolean, (GLenum)) BGL_Wrap(1, IsList, GLboolean, (GLuint)) +BGL_Wrap(1, IsProgram, GLboolean, (GLuint)) +BGL_Wrap(1, IsShader, GLboolean, (GLuint)) BGL_Wrap(1, IsTexture, GLboolean, (GLuint)) BGL_Wrap(2, LightModelf, void, (GLenum, GLfloat)) BGL_Wrap(2, LightModelfv, void, (GLenum, GLfloatP)) @@ -755,6 +773,7 @@ BGL_Wrap(3, Lighti, void, (GLenum, GLenum, GLint)) BGL_Wrap(3, Lightiv, void, (GLenum, GLenum, GLintP)) BGL_Wrap(2, LineStipple, void, (GLint, GLushort)) BGL_Wrap(1, LineWidth, void, (GLfloat)) +BGL_Wrap(1, LinkProgram, void, (GLuint)) BGL_Wrap(1, ListBase, void, (GLuint)) BGL_Wrap(1, LoadIdentity, void, (void)) BGL_Wrap(1, LoadMatrixd, void, (GLdoubleP)) @@ -915,6 +934,33 @@ BGL_Wrap(3, TexParameteri, void, (GLenum, GLenum, GLint)) BGL_Wrap(3, TexParameteriv, void, (GLenum, GLenum, GLintP)) BGL_Wrap(3, Translated, void, (GLdouble, GLdouble, GLdouble)) BGL_Wrap(3, Translatef, void, (GLfloat, GLfloat, GLfloat)) +BGL_Wrap(2, Uniform1f, void, (GLint, GLfloat)) +BGL_Wrap(3, Uniform2f, void, (GLint, GLfloat, GLfloat)) +BGL_Wrap(4, Uniform3f, void, (GLint, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(5, Uniform4f, void, (GLint, GLfloat, GLfloat, GLfloat, GLfloat)) +BGL_Wrap(3, Uniform1fv, void, (GLint, GLsizei, GLfloatP)) +BGL_Wrap(3, Uniform2fv, void, (GLint, GLsizei, GLfloatP)) +BGL_Wrap(3, Uniform3fv, void, (GLint, GLsizei, GLfloatP)) +BGL_Wrap(3, Uniform4fv, void, (GLint, GLsizei, GLfloatP)) +BGL_Wrap(2, Uniform1i, void, (GLint, GLint)) +BGL_Wrap(3, Uniform2i, void, (GLint, GLint, GLint)) +BGL_Wrap(4, Uniform3i, void, (GLint, GLint, GLint, GLint)) +BGL_Wrap(5, Uniform4i, void, (GLint, GLint, GLint, GLint, GLint)) +BGL_Wrap(3, Uniform1iv, void, (GLint, GLsizei, GLintP)) +BGL_Wrap(3, Uniform2iv, void, (GLint, GLsizei, GLintP)) +BGL_Wrap(3, Uniform3iv, void, (GLint, GLsizei, GLintP)) +BGL_Wrap(3, Uniform4iv, void, (GLint, GLsizei, GLintP)) +BGL_Wrap(4, UniformMatrix2fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix3fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix4fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix2x3fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix3x2fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix2x4fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix4x2fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix3x4fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(4, UniformMatrix4x3fv, void, (GLint, GLsizei, GLboolean, GLfloatP)) +BGL_Wrap(1, UseProgram, void, (GLuint)) +BGL_Wrap(1, ValidateProgram, void, (GLuint)) BGL_Wrap(2, Vertex2d, void, (GLdouble, GLdouble)) BGL_Wrap(1, Vertex2dv, void, (GLdoubleP)) BGL_Wrap(2, Vertex2f, void, (GLfloat, GLfloat)) @@ -957,8 +1003,10 @@ static struct PyMethodDef BGL_methods[] = { /* #ifndef __APPLE__ */ MethodDef(Accum), + MethodDef(ActiveTexture), MethodDef(AlphaFunc), MethodDef(AreTexturesResident), + MethodDef(AttachShader), MethodDef(Begin), MethodDef(BindTexture), MethodDef(Bitmap), @@ -1006,14 +1054,20 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(Color4usv), MethodDef(ColorMask), MethodDef(ColorMaterial), + MethodDef(CompileShader), MethodDef(CopyPixels), MethodDef(CopyTexImage2D), + MethodDef(CreateProgram), + MethodDef(CreateShader), MethodDef(CullFace), MethodDef(DeleteLists), + MethodDef(DeleteProgram), + MethodDef(DeleteShader), MethodDef(DeleteTextures), MethodDef(DepthFunc), MethodDef(DepthMask), MethodDef(DepthRange), + MethodDef(DetachShader), MethodDef(Disable), MethodDef(DrawBuffer), MethodDef(DrawPixels), @@ -1045,6 +1099,7 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(Frustum), MethodDef(GenLists), MethodDef(GenTextures), + MethodDef(GetAttachedShaders), MethodDef(GetBooleanv), MethodDef(GetClipPlane), MethodDef(GetDoublev), @@ -1062,6 +1117,11 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(GetPixelMapuiv), MethodDef(GetPixelMapusv), MethodDef(GetPolygonStipple), + MethodDef(GetProgramInfoLog), + MethodDef(GetProgramiv), + MethodDef(GetShaderInfoLog), + MethodDef(GetShaderiv), + MethodDef(GetShaderSource), MethodDef(GetString), MethodDef(GetTexEnvfv), MethodDef(GetTexEnviv), @@ -1073,6 +1133,7 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(GetTexLevelParameteriv), MethodDef(GetTexParameterfv), MethodDef(GetTexParameteriv), + MethodDef(GetUniformLocation), MethodDef(Hint), MethodDef(IndexMask), MethodDef(Indexd), @@ -1086,6 +1147,8 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(InitNames), MethodDef(IsEnabled), MethodDef(IsList), + MethodDef(IsProgram), + MethodDef(IsShader), MethodDef(IsTexture), MethodDef(LightModelf), MethodDef(LightModelfv), @@ -1097,6 +1160,7 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(Lightiv), MethodDef(LineStipple), MethodDef(LineWidth), + MethodDef(LinkProgram), MethodDef(ListBase), MethodDef(LoadIdentity), MethodDef(LoadMatrixd), @@ -1194,6 +1258,7 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(Scissor), MethodDef(SelectBuffer), MethodDef(ShadeModel), + MethodDef(ShaderSource), MethodDef(StencilFunc), MethodDef(StencilMask), MethodDef(StencilOp), @@ -1247,6 +1312,33 @@ static struct PyMethodDef BGL_methods[] = { MethodDef(TexParameteriv), MethodDef(Translated), MethodDef(Translatef), + MethodDef(Uniform1f), + MethodDef(Uniform2f), + MethodDef(Uniform3f), + MethodDef(Uniform4f), + MethodDef(Uniform1fv), + MethodDef(Uniform2fv), + MethodDef(Uniform3fv), + MethodDef(Uniform4fv), + MethodDef(Uniform1i), + MethodDef(Uniform2i), + MethodDef(Uniform3i), + MethodDef(Uniform4i), + MethodDef(Uniform1iv), + MethodDef(Uniform2iv), + MethodDef(Uniform3iv), + MethodDef(Uniform4iv), + MethodDef(UniformMatrix2fv), + MethodDef(UniformMatrix3fv), + MethodDef(UniformMatrix4fv), + MethodDef(UniformMatrix2x3fv), + MethodDef(UniformMatrix3x2fv), + MethodDef(UniformMatrix2x4fv), + MethodDef(UniformMatrix4x2fv), + MethodDef(UniformMatrix3x4fv), + MethodDef(UniformMatrix4x3fv), + MethodDef(UseProgram), + MethodDef(ValidateProgram), MethodDef(Vertex2d), MethodDef(Vertex2dv), MethodDef(Vertex2f), @@ -1794,5 +1886,37 @@ PyObject *BPyInit_bgl(void) EXPP_ADDCONST(GL_TEXTURE_BINDING_1D); EXPP_ADDCONST(GL_TEXTURE_BINDING_2D); + EXPP_ADDCONST(GL_VERTEX_SHADER); + EXPP_ADDCONST(GL_FRAGMENT_SHADER); + EXPP_ADDCONST(GL_COMPILE_STATUS); + EXPP_ADDCONST(GL_ACTIVE_TEXTURE); + + EXPP_ADDCONST(GL_TEXTURE0); + EXPP_ADDCONST(GL_TEXTURE1); + EXPP_ADDCONST(GL_TEXTURE2); + EXPP_ADDCONST(GL_TEXTURE3); + EXPP_ADDCONST(GL_TEXTURE4); + EXPP_ADDCONST(GL_TEXTURE5); + EXPP_ADDCONST(GL_TEXTURE6); + EXPP_ADDCONST(GL_TEXTURE7); + EXPP_ADDCONST(GL_TEXTURE8); + + EXPP_ADDCONST(GL_DEPTH_COMPONENT32); + EXPP_ADDCONST(GL_TEXTURE_COMPARE_MODE); + return submodule; } + +static PyObject *Method_ShaderSource (PyObject *UNUSED(self), PyObject *args) +{ + int shader; + char *source; + + if (!PyArg_ParseTuple(args, "Is", &shader, &source)) + return NULL; + + glShaderSource(shader, 1, (const char **)&source, NULL); + + return Py_INCREF(Py_None), Py_None; +} + diff --git a/source/blender/python/generic/bgl.h b/source/blender/python/generic/bgl.h index 1a7036daf45..abcb65b8c3a 100644 --- a/source/blender/python/generic/bgl.h +++ b/source/blender/python/generic/bgl.h @@ -103,7 +103,7 @@ extern PyTypeObject BGL_bufferType; #define buffer_def(number) Buffer *bgl_buffer##number /* GL Pointer fields, handled by buffer type */ -/* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP */ +/* GLdoubleP, GLfloatP, GLintP, GLuintP, GLshortP, GLsizeiP, GLcharP */ #define GLbooleanP_str "O!" #define GLbooleanP_var(number) (bgl_buffer##number)->buf.asvoid @@ -160,6 +160,16 @@ extern PyTypeObject BGL_bufferType; #define GLvoidP_ref(number) &BGL_bufferType, &bgl_buffer##number #define GLvoidP_def(number) Buffer *bgl_buffer##number +#define GLsizeiP_str "O!" +#define GLsizeiP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLsizeiP_ref(number) &BGL_bufferType, &bgl_buffer##number +#define GLsizeiP_def(number) Buffer *bgl_buffer##number + +#define GLcharP_str "O!" +#define GLcharP_var(number) (bgl_buffer##number)->buf.asvoid +#define GLcharP_ref(number) &BGL_bufferType, &bgl_buffer##number +#define GLcharP_def(number) Buffer *bgl_buffer##number + #define buffer_str "O!" #define buffer_var(number) (bgl_buffer##number)->buf.asvoid #define buffer_ref(number) &BGL_bufferType, &bgl_buffer##number @@ -239,6 +249,12 @@ extern PyTypeObject BGL_bufferType; #define GLfloat_ref(num) &bgl_var##num #define GLfloat_def(num) float GLfloat_var(num) +/* typedef char *GLstring; */ +#define GLstring_str "s" +#define GLstring_var(number) bgl_var##number +#define GLstring_ref(number) &bgl_var##number +#define GLstring_def(number) char *GLstring_var(number) + /* typedef float GLclampf; */ #define GLclampf_str "f" #define GLclampf_var(num) bgl_var##num diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index d638a3edf30..f3f05e93930 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -96,7 +96,7 @@ static double bpy_timer_run_tot; /* accumulate python runs */ #endif /* use for updating while a python script runs - in case of file load */ -void bpy_context_update(bContext *C) +void BPY_context_update(bContext *C) { /* don't do this from a non-main (e.g. render) thread, it can cause a race * condition on C->data.recursion. ideal solution would be to disable @@ -117,7 +117,7 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate) *gilstate = PyGILState_Ensure(); if (py_call_level == 1) { - bpy_context_update(C); + BPY_context_update(C); #ifdef TIME_PY_RUN if (bpy_timer_count == 0) { @@ -178,7 +178,8 @@ void BPY_modules_update(bContext *C) /* refreshes the main struct */ BPY_update_rna_module(); - bpy_context_module->ptr.data = (void *)C; + if(bpy_context_module) + bpy_context_module->ptr.data = (void *)C; } void BPY_context_set(bContext *C) @@ -623,7 +624,7 @@ void BPY_modules_load_user(bContext *C) /* update pointers since this can run from a nested script * on file load */ if (py_call_level) { - bpy_context_update(C); + BPY_context_update(C); } bpy_context_set(C, &gilstate); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 2174241eeda..6c1e811aae0 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -1550,9 +1550,13 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb } else { int param_i = (int)param; - RNA_property_int_clamp(ptr, prop, ¶m_i); - if (data) *((int *)data) = param_i; - else RNA_property_int_set(ptr, prop, param_i); + if (data) { + RNA_property_int_clamp(ptr, prop, ¶m_i); + *((int *)data) = param_i; + } + else { + RNA_property_int_set(ptr, prop, param_i); + } } break; } @@ -1567,9 +1571,13 @@ static int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyOb return -1; } else { - RNA_property_float_clamp(ptr, prop, (float *)¶m); - if (data) *((float *)data) = param; - else RNA_property_float_set(ptr, prop, param); + if (data) { + RNA_property_float_clamp(ptr, prop, (float *)¶m); + *((float *)data) = param; + } + else { + RNA_property_float_set(ptr, prop, param); + } } break; } @@ -6339,11 +6347,13 @@ PyObject *BPY_rna_module(void) void BPY_update_rna_module(void) { + if(rna_module_ptr) { #if 0 - RNA_main_pointer_create(G.main, rna_module_ptr); + RNA_main_pointer_create(G.main, rna_module_ptr); #else - rna_module_ptr->data = G.main; /* just set data is enough */ + rna_module_ptr->data = G.main; /* just set data is enough */ #endif + } } #if 0 diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h index 4bebcb2ed85..63660b06813 100644 --- a/source/blender/python/intern/bpy_util.h +++ b/source/blender/python/intern/bpy_util.h @@ -49,7 +49,6 @@ short BPy_errors_to_report(struct ReportList *reports); struct bContext *BPy_GetContext(void); void BPy_SetContext(struct bContext *C); -extern void bpy_context_update(struct bContext *C); extern void bpy_context_set(struct bContext *C, PyGILState_STATE *gilstate); extern void bpy_context_clear(struct bContext *C, PyGILState_STATE *gilstate); #endif diff --git a/source/blender/python/mathutils/mathutils_geometry.c b/source/blender/python/mathutils/mathutils_geometry.c index 9e9b96a885b..c6bfeff1651 100644 --- a/source/blender/python/mathutils/mathutils_geometry.c +++ b/source/blender/python/mathutils/mathutils_geometry.c @@ -1055,7 +1055,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject for (i = 0; i < len_polylines; i++) { polyLine = PySequence_GetItem(polyLineSeq, i); if (!PySequence_Check(polyLine)) { - freedisplist(&dispbase); + BKE_displist_free(&dispbase); Py_XDECREF(polyLine); /* may be null so use Py_XDECREF*/ PyErr_SetString(PyExc_TypeError, "One or more of the polylines is not a sequence of mathutils.Vector's"); @@ -1109,7 +1109,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject } if (ls_error) { - freedisplist(&dispbase); /* possible some dl was allocated */ + BKE_displist_free(&dispbase); /* possible some dl was allocated */ PyErr_SetString(PyExc_TypeError, "A point in one of the polylines " "is not a mathutils.Vector type"); @@ -1117,7 +1117,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject } else if (totpoints) { /* now make the list to return */ - filldisplist(&dispbase, &dispbase, 0); + BKE_displist_fill(&dispbase, &dispbase, 0); /* The faces are stored in a new DisplayList * thats added to the head of the listbase */ @@ -1125,7 +1125,7 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject tri_list = PyList_New(dl->parts); if (!tri_list) { - freedisplist(&dispbase); + BKE_displist_free(&dispbase); PyErr_SetString(PyExc_RuntimeError, "failed to make a new list"); return NULL; @@ -1138,11 +1138,11 @@ static PyObject *M_Geometry_tessellate_polygon(PyObject *UNUSED(self), PyObject dl_face += 3; index++; } - freedisplist(&dispbase); + BKE_displist_free(&dispbase); } else { /* no points, do this so scripts don't barf */ - freedisplist(&dispbase); /* possible some dl was allocated */ + BKE_displist_free(&dispbase); /* possible some dl was allocated */ tri_list = PyList_New(0); } diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 679bd7bcdbf..33717d47c82 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -54,8 +54,6 @@ &texres->tr, &texres->tg, &texres->tb); \ } \ -#define RGBTOBW(r,g,b) ( r*0.35f + g*0.45f + b*0.2f ) /* keep this in sync with gpu_shader_material.glsl:rgbtobw */ - struct HaloRen; struct ShadeInput; struct TexResult; diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index 4a3493d1a00..c5315afcc3d 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -402,7 +402,7 @@ static void calc_edge_stress(Render *UNUSED(re), ObjectRen *obr, Mesh *me) if (obr->totvert==0) return; - mesh_get_texspace(me, loc, NULL, size); + BKE_mesh_texspace_get(me, loc, NULL, size); accum= MEM_callocN(2*sizeof(float)*obr->totvert, "temp accum for stress"); @@ -1575,7 +1575,7 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem float hasize, pa_size, r_tilt, r_length; float pa_time, pa_birthtime, pa_dietime; float random, simplify[2], pa_co[3]; - const float cfra= BKE_curframe(re->scene); + const float cfra= BKE_scene_frame_get(re->scene); int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0, use_duplimat = 0; int totchild=0; int seed, path_nbr=0, orco1=0, num; @@ -2438,7 +2438,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) int a, need_orco, vlakindex, *index, negative_scale; ListBase dispbase= {NULL, NULL}; - if (ob!=BKE_metaball_basis_find(re->scene, ob)) + if (ob!=BKE_mball_basis_find(re->scene, ob)) return; mult_m4_m4m4(mat, re->viewmat, ob->obmat); @@ -2453,7 +2453,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) need_orco= 1; } - makeDispListMBall_forRender(re->scene, ob, &dispbase); + BKE_displist_make_mball_forRender(re->scene, ob, &dispbase); dl= dispbase.first; if (dl==0) return; @@ -2464,7 +2464,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) if (!orco) { /* orco hasn't been found in cache - create new one and add to cache */ - orco= BKE_metaball_make_orco(ob, &dispbase); + orco= BKE_mball_make_orco(ob, &dispbase); set_object_orco(re, ob, orco); } } @@ -2527,7 +2527,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) } /* enforce display lists remade */ - freedisplist(&dispbase); + BKE_displist_free(&dispbase); } /* ------------------------------------------------------------------------- */ @@ -2829,11 +2829,11 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) if (ob->parent && (ob->parent->type==OB_LATTICE)) need_orco= 1; - makeDispListSurf(re->scene, ob, &displist, &dm, 1, 0); + BKE_displist_make_surf(re->scene, ob, &displist, &dm, 1, 0); if (dm) { if (need_orco) { - orco= makeOrcoDispList(re->scene, ob, dm, 1); + orco= BKE_displist_make_orco(re->scene, ob, dm, 1); if (orco) { set_object_orco(re, ob, orco); } @@ -2855,7 +2855,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset) } } - freedisplist(&displist); + BKE_displist_free(&displist); MEM_freeN(matar); } @@ -2879,7 +2879,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (ob->type==OB_FONT && cu->str==NULL) return; else if (ob->type==OB_CURVE && cu->nurb.first==NULL) return; - makeDispListCurveTypes_forRender(re->scene, ob, &disp, &dm, 0); + BKE_displist_make_curveTypes_forRender(re->scene, ob, &disp, &dm, 0); dl= disp.first; if (dl==NULL) return; @@ -2899,7 +2899,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) if (dm) { if (need_orco) { - orco= makeOrcoDispList(re->scene, ob, dm, 1); + orco= BKE_displist_make_orco(re->scene, ob, dm, 1); if (orco) { set_object_orco(re, ob, orco); } @@ -3006,7 +3006,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) for (a=0; aparts; a++) { - if (surfindex_displist(dl, a, &b, &p1, &p2, &p3, &p4)==0) + if (BKE_displist_surfindex_get(dl, a, &b, &p1, &p2, &p3, &p4)==0) break; p1+= startvert; @@ -3063,7 +3063,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) } } - freedisplist(&disp); + BKE_displist_free(&disp); MEM_freeN(matar); } @@ -4786,7 +4786,7 @@ static int allow_render_object(Render *re, Object *ob, int nolamps, int onlysele return 0; /* don't add non-basic meta objects, ends up having renderobjects with no geometry */ - if (ob->type == OB_MBALL && ob!=BKE_metaball_basis_find(re->scene, ob)) + if (ob->type == OB_MBALL && ob!=BKE_mball_basis_find(re->scene, ob)) return 0; if (nolamps && (ob->type==OB_LAMP)) @@ -5112,12 +5112,12 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l /* applies changes fully */ if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) - scene_update_for_newframe(re->main, re->scene, lay); + BKE_scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ if (use_camera_view && camera) { /* called before but need to call again in case of lens animation from the - * above call to scene_update_for_newframe, fixes bug. [#22702]. + * above call to BKE_scene_update_for_newframe, fixes bug. [#22702]. * following calls don't depend on 'RE_SetCamera' */ RE_SetCamera(re, camera); @@ -5267,7 +5267,7 @@ static void database_fromscene_vectors(Render *re, Scene *scene, unsigned int la /* applies changes fully */ scene->r.cfra += timeoffset; - scene_update_for_newframe(re->main, re->scene, lay); + BKE_scene_update_for_newframe(re->main, re->scene, lay); /* if no camera, viewmat should have been set! */ if (camera) { @@ -5929,7 +5929,7 @@ void RE_make_sticky(Scene *scene, View3D *v3d) me->msticky= CustomData_add_layer(&me->vdata, CD_MSTICKY, CD_CALLOC, NULL, me->totvert); - where_is_object(scene, ob); + BKE_object_where_is_calc(scene, ob); mult_m4_m4m4(mat, re->viewmat, ob->obmat); ms= me->msticky; diff --git a/source/blender/render/intern/source/envmap.c b/source/blender/render/intern/source/envmap.c index da7e4335f7d..eebcf23a7a6 100644 --- a/source/blender/render/intern/source/envmap.c +++ b/source/blender/render/intern/source/envmap.c @@ -49,7 +49,7 @@ #include "BKE_library.h" #include "BKE_main.h" -#include "BKE_image.h" // BKE_write_ibuf +#include "BKE_image.h" // BKE_imbuf_write #include "BKE_texture.h" diff --git a/source/blender/render/intern/source/external_engine.c b/source/blender/render/intern/source/external_engine.c index b3c7a565d55..c23a93a52fe 100644 --- a/source/blender/render/intern/source/external_engine.c +++ b/source/blender/render/intern/source/external_engine.c @@ -313,7 +313,7 @@ int RE_engine_render(Render *re, int do_all) engine->camera_override = re->camera_override; if ((re->r.scemode & (R_NO_FRAME_UPDATE|R_PREVIEWBUTS))==0) - scene_update_for_newframe(re->main, re->scene, re->lay); + BKE_scene_update_for_newframe(re->main, re->scene, re->lay); if (type->update) type->update(engine, re->main, re->scene); diff --git a/source/blender/render/intern/source/gammaCorrectionTables.c b/source/blender/render/intern/source/gammaCorrectionTables.c index 2613d04165a..64925e16ae2 100644 --- a/source/blender/render/intern/source/gammaCorrectionTables.c +++ b/source/blender/render/intern/source/gammaCorrectionTables.c @@ -120,17 +120,15 @@ void makeGammaTables(float gamma) /* rounding errors, we just set this explicitly. The last segment may */ /* have a different length than the other segments, but our */ /* interpolation is insensitive to that. */ - color_domain_table[RE_GAMMA_TABLE_SIZE] = 1.0; + color_domain_table[RE_GAMMA_TABLE_SIZE] = 1.0; gamma_range_table[RE_GAMMA_TABLE_SIZE] = 1.0; inv_gamma_range_table[RE_GAMMA_TABLE_SIZE] = 1.0; /* To speed up calculations, we make these calc factor tables. They are */ /* multiplication factors used in scaling the interpolation. */ for (i = 0; i < RE_GAMMA_TABLE_SIZE; i++ ) { - gamfactor_table[i] = inv_color_step - * (gamma_range_table[i + 1] - gamma_range_table[i]); - inv_gamfactor_table[i] = inv_color_step - * (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); + gamfactor_table[i] = inv_color_step * (gamma_range_table[i + 1] - gamma_range_table[i]); + inv_gamfactor_table[i] = inv_color_step * (inv_gamma_range_table[i + 1] - inv_gamma_range_table[i]); } } /* end of void makeGammaTables(float gamma) */ diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index 30788f67238..c3361d7f280 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -1275,7 +1275,7 @@ static void render_scene(Render *re, Scene *sce, int cfra) sce->r.cfra= cfra; - scene_camera_switch_update(sce); + BKE_scene_camera_switch_update(sce); /* exception: scene uses own size (unfinished code) */ if (0) { @@ -1292,7 +1292,7 @@ static void render_scene(Render *re, Scene *sce, int cfra) resc->lay= sce->lay; /* ensure scene has depsgraph, base flags etc OK */ - set_scene_bg(re->main, sce); + BKE_scene_set_background(re->main, sce); /* copy callbacks */ resc->display_draw= re->display_draw; @@ -1378,7 +1378,7 @@ static void ntree_render_scenes(Render *re) /* restore scene if we rendered another last */ if (restore_scene) - set_scene_bg(re->main, re->scene); + BKE_scene_set_background(re->main, re->scene); } /* bad call... need to think over proper method still */ @@ -1448,7 +1448,7 @@ static void free_all_freestyle_renders(Scene *scene) for (link = (LinkData *)re1->freestyle_renders.first; link; link = link->next) { if (link->data) { freestyle_render = (Render *)link->data; - unlink_scene(G.main, freestyle_render->scene, scene); + BKE_scene_unlink(G.main, freestyle_render->scene, scene); RE_FreeRender(freestyle_render); } } @@ -1670,7 +1670,7 @@ static void do_render_composite_fields_blur_3d(Render *re) R.stats_draw= re->stats_draw; if (update_newframe) - scene_update_for_newframe(re->main, re->scene, re->lay); + BKE_scene_update_for_newframe(re->main, re->scene, re->lay); if (re->r.scemode & R_FULL_SAMPLE) do_merge_fullsample(re, ntree); @@ -1735,7 +1735,7 @@ static void do_render_seq(Render * re) if (recurs_depth==0) { /* otherwise sequencer animation isn't updated */ - BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_curframe(re->scene) + BKE_animsys_evaluate_all_animation(re->main, re->scene, (float)cfra); // XXX, was BKE_scene_frame_get(re->scene) } recurs_depth++; @@ -1794,7 +1794,7 @@ static void do_render_seq(Render * re) /* main loop: doing sequence + fields + blur + 3d render + compositing */ static void do_render_all_options(Render *re) { - scene_camera_switch_update(re->scene); + BKE_scene_camera_switch_update(re->scene); re->i.starttime= PIL_check_seconds_timer(); @@ -1832,7 +1832,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) int check_comp= 1; if (camera_override == NULL && scene->camera == NULL) - scene->camera= scene_find_camera(scene); + scene->camera= BKE_scene_camera_find(scene); if (scene->r.scemode&R_DOSEQ) { if (scene->ed) { @@ -1843,7 +1843,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) while (seq) { if (seq->type == SEQ_SCENE && seq->scene) { if (!seq->scene_camera) { - if (!seq->scene->camera && !scene_find_camera(seq->scene)) { + if (!seq->scene->camera && !BKE_scene_camera_find(seq->scene)) { if (seq->scene == scene) { /* for current scene camera could be unneeded due to compisite nodes */ check_comp= 1; @@ -1869,7 +1869,7 @@ static int check_valid_camera(Scene *scene, Object *camera_override) if (node->type == CMP_NODE_R_LAYERS) { Scene *sce= node->id ? (Scene*)node->id : scene; - if (!sce->camera && !scene_find_camera(sce)) { + if (!sce->camera && !BKE_scene_camera_find(sce)) { /* all render layers nodes need camera */ return 0; } @@ -1886,6 +1886,28 @@ static int check_valid_camera(Scene *scene, Object *camera_override) return 1; } +static int node_tree_has_composite_output(bNodeTree *ntree) +{ + bNode *node; + + for (node = ntree->nodes.first; node; node = node->next) { + if (node->type == CMP_NODE_COMPOSITE) { + return TRUE; + } + else if (node->type == NODE_GROUP) { + if (node_tree_has_composite_output((bNodeTree *)node->id)) + return TRUE; + } + } + + return FALSE; +} + +static int check_composite_output(Scene *scene) +{ + return node_tree_has_composite_output(scene->nodetree); +} + int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *reports) { SceneRenderLayer *srl; @@ -1920,19 +1942,12 @@ int RE_is_rendering_allowed(Scene *scene, Object *camera_override, ReportList *r if (scene->r.scemode & R_DOCOMP) { if (scene->use_nodes) { - bNodeTree *ntree= scene->nodetree; - bNode *node; - - if (ntree==NULL) { + if (!scene->nodetree) { BKE_report(reports, RPT_ERROR, "No Nodetree in Scene"); return 0; } - for (node= ntree->nodes.first; node; node= node->next) - if (node->type==CMP_NODE_COMPOSITE) - break; - - if (node==NULL) { + if (!check_composite_output(scene)) { BKE_report(reports, RPT_ERROR, "No Render Output Node in Scene"); return 0; } @@ -2180,7 +2195,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie else { ImBuf *ibuf= render_result_rect_to_ibuf(&rres, &scene->r); - ok= BKE_write_ibuf_stamp(scene, camera, ibuf, name, &scene->r.im_format); + ok= BKE_imbuf_write_stamp(scene, camera, ibuf, name, &scene->r.im_format); if (ok==0) { printf("Render error: cannot save %s\n", name); @@ -2196,7 +2211,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie name[strlen(name)-4]= 0; BKE_add_image_extension(name, R_IMF_IMTYPE_JPEG90); ibuf->planes= 24; - BKE_write_ibuf_stamp(scene, camera, ibuf, name, &imf); + BKE_imbuf_write_stamp(scene, camera, ibuf, name, &imf); printf("\nSaved: %s", name); } @@ -2221,7 +2236,7 @@ static int do_write_image_or_movie(Render *re, Main *bmain, Scene *scene, bMovie /* saves images to disk */ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_override, unsigned int lay, int sfra, int efra, int tfra) { - bMovieHandle *mh= BKE_get_movie_handle(scene->r.im_format.imtype); + bMovieHandle *mh= BKE_movie_handle_get(scene->r.im_format.imtype); int cfrao= scene->r.cfra; int nfra, totrendered= 0, totskipped= 0; @@ -2285,7 +2300,7 @@ void RE_BlenderAnim(Render *re, Main *bmain, Scene *scene, Object *camera_overri else updatelay= re->lay; - scene_update_for_newframe(bmain, scene, updatelay); + BKE_scene_update_for_newframe(bmain, scene, updatelay); continue; } else @@ -2545,7 +2560,7 @@ int RE_WriteEnvmapResult(struct ReportList *reports, Scene *scene, EnvMap *env, BLI_strncpy(filepath, relpath, sizeof(filepath)); BLI_path_abs(filepath, G.main->name); - ok= BKE_write_ibuf(ibuf, filepath, &imf); + ok= BKE_imbuf_write(ibuf, filepath, &imf); IMB_freeImBuf(ibuf); diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index 8bbb16739f7..96a1a13b75f 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -106,7 +106,7 @@ static void pointdensity_cache_psys(Render *re, PointDensity *pd, Object *ob, Pa ParticleKey state; ParticleSimulationData sim= {NULL}; ParticleData *pa=NULL; - float cfra = BKE_curframe(re->scene); + float cfra = BKE_scene_frame_get(re->scene); int i /*, childexists*/ /* UNUSED */; int total_particles, offset=0; int data_used = point_data_used(pd); diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index a5966288220..968e78899c3 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -1023,7 +1023,7 @@ ImBuf *render_result_rect_to_ibuf(RenderResult *rr, RenderData *rd) int flags = (rd->color_mgt_flag & R_COLOR_MANAGEMENT_PREDIVIDE)? IB_cm_predivide: 0; ImBuf *ibuf= IMB_allocImBuf(rr->rectx, rr->recty, rd->im_format.planes, flags); - /* if not exists, BKE_write_ibuf makes one */ + /* if not exists, BKE_imbuf_write makes one */ ibuf->rect= (unsigned int *)rr->rect32; ibuf->rect_float= rr->rectf; ibuf->zbuf_float= rr->rectz; diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 521b295fb0b..58a4e7c9828 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -100,13 +100,13 @@ static void init_render_texture(Render *re, Tex *tex) /* imap test */ if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { - BKE_image_user_calc_frame(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0); + BKE_image_user_frame_calc(&tex->iuser, cfra, re?re->flag & R_SEC_FIELD:0); } if (tex->type==TEX_PLUGIN) { if (tex->plugin && tex->plugin->doit) { if (tex->plugin->cfra) { - *(tex->plugin->cfra)= (float)cfra; //BKE_curframe(re->scene); // XXX old animsys - timing stuff to be fixed + *(tex->plugin->cfra)= (float)cfra; //BKE_scene_frame_get(re->scene); // XXX old animsys - timing stuff to be fixed } } } @@ -476,14 +476,14 @@ static int magic(Tex *tex, float *texvec, TexResult *texres) y/= turb; z/= turb; } - texres->tr= 0.5f-x; - texres->tg= 0.5f-y; - texres->tb= 0.5f-z; + texres->tr = 0.5f - x; + texres->tg = 0.5f - y; + texres->tb = 0.5f - z; - texres->tin= 0.3333f*(texres->tr+texres->tg+texres->tb); + texres->tin= (1.0f / 3.0f) * (texres->tr + texres->tg + texres->tb); BRICONTRGB; - texres->ta= 1.0; + texres->ta = 1.0f; return TEX_RGB; } @@ -798,16 +798,10 @@ static int plugintex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex if (rgbnor & TEX_RGB) { if (pit->version < 6) { - texres->tr = pit->result[1]; - texres->tg = pit->result[2]; - texres->tb = pit->result[3]; - texres->ta = pit->result[4]; + copy_v4_v4(&texres->tr, pit->result + 1); } else { - texres->tr = result[1]; - texres->tg = result[2]; - texres->tb = result[3]; - texres->ta = result[4]; + copy_v4_v4(&texres->tr, result + 1); } BRICONTRGB; @@ -1214,7 +1208,7 @@ static int multitex(Tex *tex, float *texvec, float *dxt, float *dyt, int osatex, case TEX_IMAGE: if (osatex) retval= imagewraposa(tex, tex->ima, NULL, texvec, dxt, dyt, texres); else retval= imagewrap(tex, tex->ima, NULL, texvec, texres); - tag_image_time(tex->ima); /* tag image as having being used */ + BKE_image_tag_time(tex->ima); /* tag image as having being used */ break; case TEX_PLUGIN: retval= plugintex(tex, texvec, dxt, dyt, osatex, texres); @@ -2012,14 +2006,14 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T // use texres for the center sample, set rgbnor rgbnor = multitex_mtex(shi, mtex, STll, dxt, dyt, texres); - Hll = (fromrgb)? RGBTOBW(texres->tr, texres->tg, texres->tb) : texres->tin; + Hll = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; // use ttexr for the other 2 taps multitex_mtex(shi, mtex, STlr, dxt, dyt, &ttexr); - Hlr = (fromrgb)? RGBTOBW(ttexr.tr, ttexr.tg, ttexr.tb) : ttexr.tin; + Hlr = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STul, dxt, dyt, &ttexr); - Hul = (fromrgb)? RGBTOBW(ttexr.tr, ttexr.tg, ttexr.tb) : ttexr.tin; + Hul = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; dHdx = Hscale*(Hlr - Hll); dHdy = Hscale*(Hul - Hll); @@ -2050,17 +2044,17 @@ static int ntap_bump_compute(NTapBump *ntap_bump, ShadeInput *shi, MTex *mtex, T // use texres for the center sample, set rgbnor rgbnor = multitex_mtex(shi, mtex, STc, dxt, dyt, texres); - /* Hc = (fromrgb)? RGBTOBW(texres->tr, texres->tg, texres->tb) : texres->tin; */ /* UNUSED */ + /* Hc = (fromrgb) ? rgb_to_grayscale(&texres->tr) : texres->tin; */ /* UNUSED */ // use ttexr for the other taps multitex_mtex(shi, mtex, STl, dxt, dyt, &ttexr); - Hl = (fromrgb)? RGBTOBW(ttexr.tr, ttexr.tg, ttexr.tb) : ttexr.tin; + Hl = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STr, dxt, dyt, &ttexr); - Hr = (fromrgb)? RGBTOBW(ttexr.tr, ttexr.tg, ttexr.tb) : ttexr.tin; + Hr = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STd, dxt, dyt, &ttexr); - Hd = (fromrgb)? RGBTOBW(ttexr.tr, ttexr.tg, ttexr.tb) : ttexr.tin; + Hd = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; multitex_mtex(shi, mtex, STu, dxt, dyt, &ttexr); - Hu = (fromrgb)? RGBTOBW(ttexr.tr, ttexr.tg, ttexr.tb) : ttexr.tin; + Hu = (fromrgb) ? rgb_to_grayscale(&ttexr.tr) : ttexr.tin; dHdx = Hscale*(Hr - Hl); dHdy = Hscale*(Hu - Hd); @@ -2356,8 +2350,8 @@ void do_material_tex(ShadeInput *shi, Render *re) /* texture output */ if ( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); - rgbnor-= TEX_RGB; + texres.tin = rgb_to_grayscale(&texres.tr); + rgbnor -= TEX_RGB; } if (mtex->texflag & MTEX_NEGATIVE) { if (rgbnor & TEX_RGB) { @@ -2387,9 +2381,7 @@ void do_material_tex(ShadeInput *shi, Render *re) if ((rgbnor & TEX_NOR)==0) { /* make our own normal */ if (rgbnor & TEX_RGB) { - texres.nor[0]= texres.tr; - texres.nor[1]= texres.tg; - texres.nor[2]= texres.tb; + copy_v3_v3(texres.nor, &texres.tr); } else { float co_nor= 0.5*cos(texres.tin-0.5f); @@ -2437,22 +2429,21 @@ void do_material_tex(ShadeInput *shi, Render *re) } /* mapping */ - if (mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) { + if (mtex->mapto & (MAP_COL | MAP_COLSPEC | MAP_COLMIR)) { float tcol[3]; /* stencil maps on the texture control slider, not texture intensity value */ - - tcol[0]=texres.tr; tcol[1]=texres.tg; tcol[2]=texres.tb; - - if ((rgbnor & TEX_RGB)==0) { - tcol[0]= mtex->r; - tcol[1]= mtex->g; - tcol[2]= mtex->b; + copy_v3_v3(tcol, &texres.tr); + + if ((rgbnor & TEX_RGB) == 0) { + copy_v3_v3(tcol, &mtex->r); } else if (mtex->mapto & MAP_ALPHA) { - texres.tin= stencilTin; + texres.tin = stencilTin; + } + else { + texres.tin = texres.ta; } - else texres.tin= texres.ta; /* inverse gamma correction */ if (tex->type==TEX_IMAGE) { @@ -2595,7 +2586,7 @@ void do_material_tex(ShadeInput *shi, Render *re) } if (rgbnor & TEX_RGB) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + texres.tin = rgb_to_grayscale(&texres.tr); } factt= (0.5f-texres.tin)*mtex->dispfac*stencilTin; facmm= 1.0f-factt; @@ -2622,8 +2613,8 @@ void do_material_tex(ShadeInput *shi, Render *re) /* stencil maps on the texture control slider, not texture intensity value */ if (rgbnor & TEX_RGB) { - if (texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + if (texres.talpha) texres.tin = texres.ta; + else texres.tin = rgb_to_grayscale(&texres.tr); } if (mtex->mapto & MAP_REF) { @@ -2777,8 +2768,8 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col /* texture output */ if ( (rgbnor & TEX_RGB) && (mtex->texflag & MTEX_RGBTOINT)) { - texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); - rgbnor-= TEX_RGB; + texres.tin = rgb_to_grayscale(&texres.tr); + rgbnor -= TEX_RGB; } if (mtex->texflag & MTEX_NEGATIVE) { if (rgbnor & TEX_RGB) { @@ -2807,17 +2798,14 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col /* stencil maps on the texture control slider, not texture intensity value */ - if ((rgbnor & TEX_RGB)==0) { - tcol[0]= mtex->r; - tcol[1]= mtex->g; - tcol[2]= mtex->b; + if ((rgbnor & TEX_RGB) == 0) { + copy_v3_v3(tcol, &mtex->r); } else { - tcol[0]=texres.tr; - tcol[1]=texres.tg; - tcol[2]=texres.tb; - if (texres.talpha) + copy_v3_v3(tcol, &texres.tr); + if (texres.talpha) { texres.tin= texres.ta; + } } /* used for emit */ @@ -2843,8 +2831,8 @@ void do_volume_tex(ShadeInput *shi, const float *xyz, int mapto_flag, float *col /* convert RGB to intensity if intensity info isn't provided */ if (!(rgbnor & TEX_INT)) { if (rgbnor & TEX_RGB) { - if (texres.talpha) texres.tin= texres.ta; - else texres.tin= (0.35f*texres.tr+0.45f*texres.tg+0.2f*texres.tb); + if (texres.talpha) texres.tin = texres.ta; + else texres.tin = rgb_to_grayscale(&texres.tr); } } @@ -3558,7 +3546,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) mat = localize_material(orig_mat); /* update material anims */ - BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_curframe(scene), ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &mat->id, mat->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); /* strip material copy from unsupported flags */ for (tex_nr=0; tex_nrtex = localize_texture(mtex->tex); /* update texture anims */ - BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_curframe(scene), ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &tex->id, tex->adt, BKE_scene_frame_get(scene), ADT_RECALC_ANIM); /* update texture cache if required */ if (tex->type==TEX_VOXELDATA) { @@ -3625,7 +3613,7 @@ Material *RE_init_sample_material(Material *orig_mat, Scene *scene) /* update image sequences and movies */ if (tex->ima && ELEM(tex->ima->source, IMA_SRC_MOVIE, IMA_SRC_SEQUENCE)) { if (tex->iuser.flag & IMA_ANIM_ALWAYS) - BKE_image_user_calc_frame(&tex->iuser, (int)scene->r.cfra, 0); + BKE_image_user_frame_calc(&tex->iuser, (int)scene->r.cfra, 0); } } } @@ -3644,14 +3632,14 @@ void RE_free_sample_material(Material *mat) MTex *mtex= mat->mtex[tex_nr]; if (mtex->tex) { - free_texture(mtex->tex); + BKE_texture_free(mtex->tex); MEM_freeN(mtex->tex); mtex->tex = NULL; } } } - free_material(mat); + BKE_material_free(mat); MEM_freeN(mat); } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 04e1bee4376..0dc7f35dc56 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -2567,7 +2567,7 @@ static void *do_bake_thread(void *bs_v) void RE_bake_ibuf_filter(ImBuf *ibuf, char *mask, const int filter) { /* must check before filtering */ - const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_alphatest_ibuf(ibuf); + const short is_new_alpha= (ibuf->planes != R_IMF_PLANES_RGBA) && BKE_imbuf_alpha_test(ibuf); /* Margin */ if (filter) { diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 4c81a0a8654..f3872cb9594 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -188,7 +188,7 @@ void WM_operatortype_append_ptr (void (*opfunc)(struct wmOperatorType*, void *) void WM_operatortype_append_macro_ptr (void (*opfunc)(struct wmOperatorType*, void *), void *userdata); int WM_operatortype_remove(const char *idname); -struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, int flag); +struct wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag); struct wmOperatorTypeMacro *WM_operatortype_macro_define(struct wmOperatorType *ot, const char *idname); diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index 638dd4ca807..7285e155dc6 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -291,7 +291,7 @@ void wm_clear_default_size(bContext *C) /* on startup, it adds all data, for matching */ void wm_add_default(bContext *C) { - wmWindowManager *wm = alloc_libblock(&CTX_data_main(C)->wm, ID_WM, "WinMan"); + wmWindowManager *wm = BKE_libblock_alloc(&CTX_data_main(C)->wm, ID_WM, "WinMan"); wmWindow *win; bScreen *screen = CTX_wm_screen(C); /* XXX from file read hrmf */ diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 56a7ff30ad8..fd3e287a6a5 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -240,7 +240,7 @@ void wm_event_do_notifiers(bContext *C) if (do_anim) { /* XXX, quick frame changes can cause a crash if framechange and rendering - * collide (happens on slow scenes), scene_update_for_newframe can be called + * collide (happens on slow scenes), BKE_scene_update_for_newframe can be called * twice which can depgraph update the same object at once */ if (!G.rendering) { @@ -311,7 +311,7 @@ void wm_event_do_notifiers(bContext *C) /* XXX, hack so operators can enforce datamasks [#26482], gl render */ win->screen->scene->customdata_mask |= win->screen->scene->customdata_mask_modal; - scene_update_tagged(bmain, win->screen->scene); + BKE_scene_update_tagged(bmain, win->screen->scene); } } diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 6ed6e13f3d0..bbc1a8faab8 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -487,7 +487,7 @@ int WM_read_homefile(bContext *C, ReportList *UNUSED(reports), short from_memory char tstr[FILE_MAX]; int success = 0; - free_ttfont(); /* still weird... what does it here? */ + BKE_vfont_free_global_ttf(); /* still weird... what does it here? */ G.relbase_valid = 0; if (!from_memory) { diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 58c2c649163..ab377d53ec7 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -360,11 +360,11 @@ void WM_exit_ext(bContext *C, const short do_python) // BIF_freeRetarget(); BIF_freeTemplates(C); - free_ttfont(); /* bke_font.h */ + BKE_vfont_free_global_ttf(); /* bke_font.h */ free_openrecent(); - BKE_metaball_cubeTable_free(); + BKE_mball_cubeTable_free(); ED_preview_free_dbase(); /* frees a Main dbase, before free_blender! */ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index db0429d33ab..27c4a38c131 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -346,7 +346,7 @@ static int wm_macro_cancel(bContext *C, wmOperator *op) } /* Names have to be static for now */ -wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, int flag) +wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *name, const char *description, int flag) { wmOperatorType *ot; @@ -360,6 +360,7 @@ wmOperatorType *WM_operatortype_append_macro(const char *idname, const char *nam ot->idname = idname; ot->name = name; + ot->description = description; ot->flag = OPTYPE_MACRO | flag; ot->exec = wm_macro_exec; @@ -1453,7 +1454,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_ static int wm_search_menu_exec(bContext *UNUSED(C), wmOperator *UNUSED(op)) { - return OPERATOR_FINISHED; + return OPERATOR_FINISHED; } static int wm_search_menu_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)) @@ -1487,6 +1488,7 @@ static void WM_OT_search_menu(wmOperatorType *ot) { ot->name = "Search Menu"; ot->idname = "WM_OT_search_menu"; + ot->description = "Pop-up a search menu over all available operators in current context"; ot->invoke = wm_search_menu_invoke; ot->exec = wm_search_menu_exec; @@ -1774,7 +1776,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) /* now we have or selected, or an indicated file */ if (RNA_boolean_get(op->ptr, "autoselect")) - scene_deselect_all(scene); + BKE_scene_base_deselect_all(scene); flag = wm_link_append_flag(op); @@ -2152,7 +2154,7 @@ static int wm_collada_export_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED static int wm_collada_export_exec(bContext *C, wmOperator *op) { char filename[FILE_MAX]; - int selected, second_life; + int selected, second_life, apply_modifiers; if (!RNA_struct_property_is_set(op->ptr, "filepath")) { BKE_report(op->reports, RPT_ERROR, "No filename given"); @@ -2160,13 +2162,16 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) } RNA_string_get(op->ptr, "filepath", filename); - selected = RNA_boolean_get(op->ptr, "selected"); - second_life = RNA_boolean_get(op->ptr, "second_life"); + + /* Options panel */ + selected = RNA_boolean_get(op->ptr, "selected"); + second_life = RNA_boolean_get(op->ptr, "second_life"); + apply_modifiers = RNA_boolean_get(op->ptr, "apply_modifiers"); /* get editmode results */ ED_object_exit_editmode(C, 0); /* 0 = does not exit editmode */ - if (collada_export(CTX_data_scene(C), filename, selected, second_life)) { + if (collada_export(CTX_data_scene(C), filename, selected, apply_modifiers, second_life)) { return OPERATOR_FINISHED; } else { @@ -2185,8 +2190,10 @@ static void WM_OT_collada_export(wmOperatorType *ot) ot->poll = WM_operator_winactive; WM_operator_properties_filesel(ot, FOLDERFILE | COLLADAFILE, FILE_BLENDER, FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY); - RNA_def_boolean(ot->srna, "selected", 0, "Export only selected", + RNA_def_boolean(ot->srna, "selected", 0, "Selection Only", "Export only selected elements"); + RNA_def_boolean(ot->srna, "apply_modifiers", 0, "Apply Modifiers", + "Apply modifiers (Preview Resolution)"); RNA_def_boolean(ot->srna, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life"); } @@ -3430,6 +3437,7 @@ static void WM_OT_radial_control(wmOperatorType *ot) { ot->name = "Radial Control"; ot->idname = "WM_OT_radial_control"; + ot->description = "Set some size property (like e.g. brush size) with mouse wheel"; ot->invoke = radial_control_invoke; ot->modal = radial_control_modal; @@ -3533,7 +3541,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) if (a & 1) scene->r.cfra--; else scene->r.cfra++; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); } else if (type == 5) { @@ -3548,7 +3556,7 @@ static int redraw_timer_exec(bContext *C, wmOperator *op) if (scene->r.cfra > scene->r.efra) scene->r.cfra = scene->r.sfra; - scene_update_for_newframe(bmain, scene, scene->lay); + BKE_scene_update_for_newframe(bmain, scene, scene->lay); redraw_timer_window_swap(C); } } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 031cfe90042..5f6b15dee02 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -282,7 +282,7 @@ void wm_window_close(bContext *C, wmWindowManager *wm, wmWindow *win) /* if temp screen, delete it after window free (it stops jobs that can access it) */ if (screen->temp) { Main *bmain = CTX_data_main(C); - free_libblock(&bmain->screen, screen); + BKE_libblock_free(&bmain->screen, screen); } /* check remaining windows */ @@ -672,6 +672,7 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) case GHOST_kEventWindowActivate: { GHOST_TEventKeyData kdata; + wmEvent event; int cx, cy, wx, wy; wm->winactive = win; /* no context change! c->wm->windrawable is drawable, or for area queues */ @@ -711,6 +712,23 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private) win->addmousemove = 1; /* enables highlighted buttons */ wm_window_make_drawable(C, win); + + /* window might be focused by mouse click in configuration of window manager + * when focus is not following mouse + * click could have been done on a button and depending on window manager settings + * click would be passed to blender or not, but in any case button under cursor + * should be activated, so at max next click on button without moving mouse + * would trigger it's handle function + * currently it seems to be common practice to generate new event for, but probably + * we'll need utility function for this? (sergey) + */ + event = *(win->eventstate); + event.type = MOUSEMOVE; + event.prevx = event.x; + event.prevy = event.y; + + wm_event_add(win, &event); + break; } case GHOST_kEventWindowClose: { diff --git a/source/blenderplayer/bad_level_call_stubs/stubs.c b/source/blenderplayer/bad_level_call_stubs/stubs.c index 5ced611f665..192a9988c07 100644 --- a/source/blenderplayer/bad_level_call_stubs/stubs.c +++ b/source/blenderplayer/bad_level_call_stubs/stubs.c @@ -270,7 +270,7 @@ struct EditMesh; struct FCurve *verify_fcurve (struct bAction *act, const char group[], const char rna_path[], const int array_index, short add){return (struct FCurve *) NULL;} int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag){return 0;} void delete_fcurve_key(struct FCurve *fcu, int index, short do_recalc){} -struct KeyingSetInfo *ANIM_keyingset_info_find_named (const char name[]){return (struct KeyingSetInfo *) NULL;} +struct KeyingSetInfo *ANIM_keyingset_info_find_name (const char name[]){return (struct KeyingSetInfo *) NULL;} struct KeyingSet *ANIM_scene_get_active_keyingset (struct Scene *scene){return (struct KeyingSet *) NULL;} int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks){return 0;} struct ListBase builtin_keyingsets; @@ -504,6 +504,7 @@ void BPY_pyconstraint_exec(struct bPythonConstraint *con, struct bConstraintOb * void macro_wrapper(struct wmOperatorType *ot, void *userdata) {} int pyrna_id_FromPyObject(struct PyObject *obj, struct ID **id){ return 0; } struct PyObject *pyrna_id_CreatePyObject(struct ID *id) {return NULL; } +void BPY_context_update(struct bContext *C){}; /* Freestyle */ void FRS_add_freestyle_config(struct SceneRenderLayer* srl) {} diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index e8117095d6a..82acabc2be6 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -585,7 +585,14 @@ elseif(WIN32) ${LIBDIR}/ffmpeg/lib/swscale-2.dll DESTINATION ${TARGETDIR} ) - + if(WITH_MINGW64) + install( + FILES + ${LIBDIR}/ffmpeg/lib/swresample-0.dll + ${LIBDIR}/ffmpeg/lib/xvidcore.dll + DESTINATION ${TARGETDIR} + ) + endif() endif() if(WITH_CODEC_SNDFILE) diff --git a/source/creator/creator.c b/source/creator/creator.c index 0c50bb9e83f..6abcd594d2f 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -605,7 +605,7 @@ static int set_engine(int argc, const char **argv, void *data) static int set_image_type(int argc, const char **argv, void *data) { bContext *C = data; - if (argc >= 1) { + if (argc > 1) { const char *imtype = argv[1]; Scene *scene = CTX_data_scene(C); if (scene) { @@ -631,7 +631,7 @@ static int set_image_type(int argc, const char **argv, void *data) static int set_threads(int argc, const char **argv, void *UNUSED(data)) { - if (argc >= 1) { + if (argc > 1) { if (G.background) { RE_set_max_threads(atoi(argv[1])); } @@ -646,6 +646,21 @@ static int set_threads(int argc, const char **argv, void *UNUSED(data)) } } +static int set_verbosity(int argc, const char **argv, void *UNUSED(data)) +{ + if (argc > 1) { + int level = atoi(argv[1]); + + libmv_setLoggingVerbosity(level); + + return 1; + } + else { + printf("\nError: you must specify a verbosity level.\n"); + return 0; + } +} + static int set_extension(int argc, const char **argv, void *data) { bContext *C = data; @@ -797,7 +812,7 @@ static int set_scene(int argc, const char **argv, void *data) { if (argc > 1) { bContext *C = data; - Scene *scene = set_scene_name(CTX_data_main(C), argv[1]); + Scene *scene = BKE_scene_set_name(CTX_data_main(C), argv[1]); if (scene) { CTX_data_scene_set(C, scene); } @@ -1114,6 +1129,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle) BLI_argsAdd(ba, 1, NULL, "--debug-libmv", "\n\tEnable debug messages from libmv library", debug_mode_libmv, NULL); #endif + BLI_argsAdd(ba, 1, NULL, "--verbose", "\n\tSet logging verbosity level.", set_verbosity, NULL); + BLI_argsAdd(ba, 1, NULL, "--factory-startup", "\n\tSkip reading the "STRINGIFY (BLENDER_STARTUP_FILE)" in the users home directory", set_factory_startup, NULL); /* TODO, add user env vars? */ @@ -1272,7 +1289,7 @@ int main(int argc, const char **argv) #endif /* background render uses this font too */ - BKE_font_register_builtin(datatoc_Bfont, datatoc_Bfont_size); + BKE_vfont_builtin_register(datatoc_Bfont, datatoc_Bfont_size); /* Initialize ffmpeg if built in, also needed for bg mode if videos are * rendered via ffmpeg */ diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp index 61379209151..9869dfb9424 100644 --- a/source/gameengine/Converter/BL_ActionActuator.cpp +++ b/source/gameengine/Converter/BL_ActionActuator.cpp @@ -370,10 +370,10 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* value) obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ } - // get_pose_channel accounts for NULL pose, run on both in case one exists but + // BKE_pose_channel_find_name accounts for NULL pose, run on both in case one exists but // the channel doesnt - if ( !(pchan=get_pose_channel(m_userpose, string)) && - !(pchan=get_pose_channel(m_pose, string)) ) + if ( !(pchan=BKE_pose_channel_find_name(m_userpose, string)) && + !(pchan=BKE_pose_channel_find_name(m_pose, string)) ) { PyErr_SetString(PyExc_ValueError, "channel doesnt exist"); return NULL; @@ -457,8 +457,8 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ game_copy_pose(&m_userpose, m_pose, 0); } - // pchan= verify_pose_channel(m_userpose, string); // adds the channel if its not there. - pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there. + // pchan= BKE_pose_channel_verify(m_userpose, string); // adds the channel if its not there. + pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there. if (pchan) { copy_v3_v3(pchan->loc, matrix[3]); @@ -480,8 +480,8 @@ KX_PYMETHODDEF_DOC(BL_ActionActuator, setChannel, obj->GetPose(&m_pose); /* Get the underlying pose from the armature */ game_copy_pose(&m_userpose, m_pose, 0); } - // pchan= verify_pose_channel(m_userpose, string); - pchan= get_pose_channel(m_userpose, string); // adds the channel if its not there. + // pchan= BKE_pose_channel_verify(m_userpose, string); + pchan= BKE_pose_channel_find_name(m_userpose, string); // adds the channel if its not there. // for some reason loc.setValue(pchan->loc) fails if (pchan) { diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp index f9ddc258cfe..f38782a9405 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.cpp +++ b/source/gameengine/Converter/BL_ArmatureObject.cpp @@ -61,7 +61,7 @@ /** * Move here pose function for game engine so that we can mix with GE objects * Principle is as follow: - * Use Blender structures so that where_is_pose can be used unchanged + * Use Blender structures so that BKE_pose_where_is can be used unchanged * Copy the constraint so that they can be enabled/disabled/added/removed at runtime * Don't copy the constraints for the pose used by the Action actuator, it does not need them. * Scan the constraint structures so that the KX equivalent of target objects are identified and @@ -84,7 +84,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) return; } else if (*dst==src) { - printf("copy_pose source and target are the same\n"); + printf("BKE_pose_copy_data source and target are the same\n"); *dst=NULL; return; } @@ -129,7 +129,7 @@ void game_copy_pose(bPose **dst, bPose *src, int copy_constraint) BLI_ghash_free(ghash, NULL, NULL); // set acceleration structure for channel lookup - make_pose_channels_hash(out); + BKE_pose_channels_hash_make(out); *dst=out; } @@ -200,7 +200,7 @@ void game_free_pose(bPose *pose) { if (pose) { /* free pose-channels and constraints */ - free_pose_channels(pose); + BKE_pose_channels_free(pose); /* free IK solver state */ BIK_clear_data(pose); @@ -225,7 +225,7 @@ BL_ArmatureObject::BL_ArmatureObject( m_poseChannels(), m_objArma(armature), m_framePose(NULL), - m_scene(scene), // maybe remove later. needed for where_is_pose + m_scene(scene), // maybe remove later. needed for BKE_pose_where_is m_lastframe(0.0), m_timestep(0.040), m_activeAct(NULL), @@ -477,7 +477,7 @@ void BL_ArmatureObject::ApplyPose() } // update ourself UpdateBlenderObjectMatrix(m_objArma); - where_is_pose(m_scene, m_objArma); // XXX + BKE_pose_where_is(m_scene, m_objArma); // XXX // restore ourself memcpy(m_objArma->obmat, m_obmat, sizeof(m_obmat)); // restore active targets @@ -590,7 +590,7 @@ bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) bPoseChannel *pchan; ApplyPose(); - pchan = get_pose_channel(m_objArma->pose, bone->name); + pchan = BKE_pose_channel_find_name(m_objArma->pose, bone->name); if (pchan) matrix.setValue(&pchan->pose_mat[0][0]); RestorePose(); diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h index a6848cf57df..ced6b94e6fd 100644 --- a/source/gameengine/Converter/BL_ArmatureObject.h +++ b/source/gameengine/Converter/BL_ArmatureObject.h @@ -132,7 +132,7 @@ protected: struct bPose *m_pose; struct bPose *m_armpose; struct bPose *m_framePose; - struct Scene *m_scene; // need for where_is_pose + struct Scene *m_scene; // need for BKE_pose_where_is double m_lastframe; double m_timestep; // delta since last pose evaluation. class BL_ActionActuator *m_activeAct; diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index ad232818c33..14362cd8f06 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -188,7 +188,7 @@ extern "C" { #endif //XXX #include "BSE_headerbuttons.h" //XXX void update_for_newframe(); -//void scene_update_for_newframe(struct Scene *sce, unsigned int lay); +//void BKE_scene_update_for_newframe(struct Scene *sce, unsigned int lay); //#include "BKE_ipo.h" //void do_all_data_ipos(void); #ifdef __cplusplus @@ -2613,7 +2613,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, case PARBONE: { // parent this to a bone - Bone *parent_bone = get_named_bone( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr); + Bone *parent_bone = BKE_armature_find_bone_name( (bArmature *)(blenderchild->parent)->data, blenderchild->parsubstr); if (parent_bone) { KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone); diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp index bb3636881ea..b93d731c5e6 100644 --- a/source/gameengine/Converter/BL_ShapeDeformer.cpp +++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp @@ -77,7 +77,7 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, m_lastShapeUpdate(-1) { m_key = m_bmesh->key; - m_bmesh->key = copy_key(m_key); + m_bmesh->key = BKE_key_copy(m_key); }; /* this second constructor is needed for making a mesh deformable on the fly. */ @@ -94,14 +94,14 @@ BL_ShapeDeformer::BL_ShapeDeformer(BL_DeformableGameObject *gameobj, m_lastShapeUpdate(-1) { m_key = m_bmesh->key; - m_bmesh->key = copy_key(m_key); + m_bmesh->key = BKE_key_copy(m_key); }; BL_ShapeDeformer::~BL_ShapeDeformer() { if (m_key && m_bmesh->key && m_key != m_bmesh->key) { - free_key(m_bmesh->key); + BKE_key_free(m_bmesh->key); BLI_remlink_safe(&G.main->key, m_bmesh->key); MEM_freeN(m_bmesh->key); m_bmesh->key = m_key; diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp index 2aa97370330..ab275fa773a 100644 --- a/source/gameengine/Converter/BL_SkinDeformer.cpp +++ b/source/gameengine/Converter/BL_SkinDeformer.cpp @@ -230,7 +230,7 @@ void BL_SkinDeformer::BGEDeformVerts() dg; ++i, dg=(bDeformGroup*)dg->next) { - m_dfnrToPC[i] = get_pose_channel(par_arma->pose, dg->name); + m_dfnrToPC[i] = BKE_pose_channel_find_name(par_arma->pose, dg->name); if (m_dfnrToPC[i] && m_dfnrToPC[i]->bone->flag & BONE_NO_DEFORM) m_dfnrToPC[i] = NULL; diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp index df6be142b30..b62e667c211 100644 --- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp +++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp @@ -88,8 +88,8 @@ extern "C" #include "BKE_global.h" #include "BKE_animsys.h" #include "BKE_library.h" -#include "BKE_material.h" // copy_material -#include "BKE_mesh.h" // copy_mesh +#include "BKE_material.h" // BKE_material_copy +#include "BKE_mesh.h" // BKE_mesh_copy #include "DNA_space_types.h" #include "DNA_anim_types.h" #include "RNA_define.h" @@ -1409,7 +1409,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene, /* Watch this!, if its used in the original scene can cause big troubles */ if (me->us > 0) { printf("Mesh has a user \"%s\"\n", name); - me = (ID*)copy_mesh((Mesh*)me); + me = (ID*)BKE_mesh_copy((Mesh*)me); me->us--; } BLI_remlink(&m_maggie->mesh, me); /* even if we made the copy it needs to be removed */ @@ -1433,7 +1433,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::ConvertMeshSpecial(KX_Scene* kx_scene, if (mat_old && (mat_old->id.flag & LIB_DOIT)==0) { Material *mat_old= mesh->mat[i]; - Material *mat_new= copy_material( mat_old ); + Material *mat_new= BKE_material_copy( mat_old ); mat_new->id.flag |= LIB_DOIT; mat_old->id.us--; diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index b5e165a58ec..1e16cbd51f2 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -848,7 +848,7 @@ int main(int argc, char** argv) { if (scene->gm.stereoflag == STEREO_ENABLED) { stereomode = (RAS_IRasterizer::StereoMode) scene->gm.stereomode; - if (stereomode != RAS_IRasterizer::RAS_STEREO_QUADBUFFERED) + if (stereomode == RAS_IRasterizer::RAS_STEREO_QUADBUFFERED) stereoWindow = true; } } @@ -870,7 +870,7 @@ int main(int argc, char** argv) if (domeWarp) { //XXX to do: convert relative to absolute path - domeText= add_text(domeWarp, ""); + domeText= BKE_text_load(domeWarp, ""); if (!domeText) printf("error: invalid warpdata text file - %s\n", domeWarp); else