OpenToonz - An open-source full-featured 2D animation creation software
C
Use std::unique_ptr instead of UniquePtr in plasticdeformer.cpp (#332)
tomosu953a4a705dc3
diff --git a/toonz/sources/tnzext/plasticdeformer.cpp b/toonz/sources/tnzext/plasticdeformer.cppindex 9c6a97457..5fe0b0241 100644--- a/toonz/sources/tnzext/plasticdeformer.cpp+++ b/toonz/sources/tnzext/plasticdeformer.cpp@@ -36,14 +36,14 @@which can be solved using the Lagrange Multipliers theorem:<P> \f$-+\Rightarrow \left{ \begin{array}{c}H v + f = A^t \lambdaA v + d = 0\end{array} \right.\Rightarrow \left( \begin{array}{c} H \\ A \end{array} \begin{array}{c} -A^t \\ 0 \end{array} \right)- \left( \begin{array}{c} v \\ \lambda \end{array} \right) =+ \left( \begin{array}{c} v \\ \lambda \end{array} \right) =\left( \begin{array}{c} -f \\ -d \end{array} \right)\f$ </P>@@ -70,54 +70,15 @@ struct LinearConstraint {//--------------------------------------------------------------------------------------------// Forced to implement a sloppy substitute to C++11's std::unique_ptr -- since we're still compiling-// C++03 on MAC... ARGH !-template <typename T, typename D>-class UniquePtr-{- T *m_t;--public:- UniquePtr() : m_t() {}- UniquePtr(T *t) : m_t(t) {}- ~UniquePtr() { D::destroy(m_t); }-- void reset(T *t = 0)- {- D::destroy(m_t);- m_t = t;- }-- const T *get() const { return m_t; }- T *get() { return m_t; }-- const T *operator->() const { return m_t; }- T *operator->() { return m_t; }-- const T &operator*() const { return *m_t; }- T &operator*() { return *m_t; }-- const T &operator[](size_t i) const { return m_t[i]; }- T &operator[](size_t i) { return m_t[i]; }-};--//--------------------------------------------------------------------------------------------struct SuperFactors_free {- static inline void destroy(tlin::SuperFactors *f) { tlin::freeF(f); }-};-struct freer {- static inline void destroy(void *d) { free(d); }-};-struct deleter {- static inline void destroy(void *d) { delete d; }+ void operator()(tlin::SuperFactors *f) { tlin::freeF(f); }};//--------------------------------------------------------------------------------------------typedef UniquePtr<tlin::SuperFactors, SuperFactors_free> SuperFactorsPtr;-typedef UniquePtr<double, freer> DoublePtr;-typedef UniquePtr<TPointD, deleter> TPointDPtr;+using SuperFactorsPtr =std::unique_ptr<tlin::SuperFactors, SuperFactors_free>;+using DoublePtr =std::unique_ptr<double[]>;+using TPointDPtr =std::unique_ptr<TPointD[]>;} // namespace@@ -581,8 +542,8 @@ void PlasticDeformer::Imp::compileStep1(const std::vector<PlasticHandle> &handlem_invC.reset(invC);// Reallocate arrays- m_q.reset((double *)malloc(cSize * sizeof(double)));- m_out.reset((double *)malloc(cSize * sizeof(double)));+ m_q.reset(new double[cSize]);+ m_out.reset(new double[cSize]);memset(m_q.get(), 0, 2 * vCount * sizeof(double)); // Initialize the system's known term with 0} else