Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

#assistants: fixes for MSVC

Ivan Mahonin16421eae69fd
diff --git a/toonz/sources/common/tgeometry/tgeometry.cpp b/toonz/sources/common/tgeometry/tgeometry.cpp
index 4278048b7..7b9607164 100644
--- a/toonz/sources/common/tgeometry/tgeometry.cpp
+++ b/toonz/sources/common/tgeometry/tgeometry.cpp
@@ -295,12 +295,12 @@ TAffine4 TAffine4::scale(double x, double y, double z) {
TAffine4 TAffine4::rotation(double x, double y, double z, double angle) {
TAffine4 r;
- double k = sqrt(x*x + y*y + z*z);
- if (k > TConsts::epsilon) {
- double s = sin(angle);
+ double k = x*x + y*y + z*z;
+ if (k > TConsts::epsilon*TConsts::epsilon) {
+ k = 1.0 / sqrt(k);
+ double s = sin(angle);
double c = cos(angle);
double ic = 1.0 - c;
- double k = 1.0/k;
x *= k;
y *= k;
z *= k;
diff --git a/toonz/sources/include/tools/assistant.h b/toonz/sources/include/tools/assistant.h
index 2578a4bf2..bd1d8f10f 100644
--- a/toonz/sources/include/tools/assistant.h
+++ b/toonz/sources/include/tools/assistant.h
@@ -140,4 +140,14 @@ public:
virtual void drawEdit(TToolViewer *viewer) const;
};
+
+//*****************************************************************************************
+// export template implementations for win32
+//*****************************************************************************************
+
+#ifdef _WIN32
+template class DVAPI TSmartPointerT<TGuideline>;
+#endif
+
+
#endif
diff --git a/toonz/sources/include/tools/inputmanager.h b/toonz/sources/include/tools/inputmanager.h
index c025b250f..36bf4fe57 100644
--- a/toonz/sources/include/tools/inputmanager.h
+++ b/toonz/sources/include/tools/inputmanager.h
@@ -385,4 +385,13 @@ public:
};
+//*****************************************************************************************
+// export template implementations for win32
+//*****************************************************************************************
+
+#ifdef _WIN32
+template class DVAPI TSmartPointerT<TInputModifier>;
+#endif
+
+
#endif
diff --git a/toonz/sources/include/tools/inputstate.h b/toonz/sources/include/tools/inputstate.h
index 19ff14a93..f05a92779 100644
--- a/toonz/sources/include/tools/inputstate.h
+++ b/toonz/sources/include/tools/inputstate.h
@@ -38,11 +38,6 @@
typedef std::vector<TPointD> THoverList;
-#ifdef _WIN32
-template class DVAPI TKeyHistoryT<TKey>;
-template class DVAPI TKeyHistoryT<Qt::MouseButton>;
-#endif
-
//===================================================================
@@ -87,6 +82,23 @@ public:
};
+//*****************************************************************************************
+// export template implementations for win32
+//*****************************************************************************************
+
+#ifdef _WIN32
+template class DVAPI TKeyStateT<TKey>;
+template class DVAPI TSmartPointerT< TKeyStateT<TKey> >;
+template class DVAPI TKeyHistoryT<TKey>;
+template class DVAPI TKeyHistoryT<TKey>::Holder;
+
+template class DVAPI TKeyStateT<Qt::MouseButton>;
+template class DVAPI TSmartPointerT< TKeyStateT<Qt::MouseButton> >;
+template class DVAPI TKeyHistoryT<Qt::MouseButton>;
+template class DVAPI TKeyHistoryT<Qt::MouseButton>::Holder;
+#endif
+
+
//*****************************************************************************************
// TInputState definition
//*****************************************************************************************
diff --git a/toonz/sources/include/tools/keyhistory.h b/toonz/sources/include/tools/keyhistory.h
index eeabefe8e..5c43db27b 100644
--- a/toonz/sources/include/tools/keyhistory.h
+++ b/toonz/sources/include/tools/keyhistory.h
@@ -64,8 +64,15 @@ public:
}
};
- static const Type none;
- static const Pointer empty;
+ static const Type& none() {
+ static Type none;
+ return none;
+ }
+
+ static const Pointer& empty() {
+ static Pointer empty = new TKeyStateT();
+ return empty;
+ }
const Pointer previous;
const TTimerTicks ticks;
@@ -82,17 +89,17 @@ private:
}
public:
- TKeyStateT(): ticks(0), value(none) { }
+ TKeyStateT(): ticks(0), value(none()) { }
Pointer find(const Type &value) {
- return value == none ? Pointer()
+ return value == none() ? Pointer()
: value == this->value ? this
: previous ? previous->find(value)
: Pointer();
}
Pointer change(bool press, const Type &value, TTimerTicks ticks) {
- if (value == none)
+ if (value == none())
return Pointer(this);
Pointer p = find(value);
@@ -105,11 +112,11 @@ public:
if (press)
return Pointer(new TKeyStateT((isEmpty() ? Pointer() : Pointer(this)), ticks, value));
Pointer chain = makeChainWithout(p);
- return chain ? chain : Pointer(new TKeyStateT(Pointer(), ticks, none));
+ return chain ? chain : Pointer(new TKeyStateT(Pointer(), ticks, none()));
}
bool isEmpty()
- { return value == none && (!previous || previous->isEmpty()); }
+ { return value == none() && (!previous || previous->isEmpty()); }
bool isPressed(const Type &value)
{ return find(value); }
@@ -120,13 +127,6 @@ public:
};
-template<typename T>
-const typename TKeyStateT<T>::Type TKeyStateT<T>::none = typename TKeyStateT<T>::Type();
-
-template<typename T>
-const typename TKeyStateT<T>::Pointer TKeyStateT<T>::empty = new TKeyStateT<T>();
-
-
//*****************************************************************************************
// TKeyHistory definition
//*****************************************************************************************
@@ -187,7 +187,7 @@ public:
Holder offset(double timeOffset) const {
return fabs(timeOffset) < TToolTimer::epsilon ? *this
- : Holder(history, ticks, this->timeOffset + timeOffset);
+ : Holder(m_history, m_ticks, m_timeOffset + timeOffset);
}
StateHolder get(double time) const {
diff --git a/toonz/sources/include/tools/track.h b/toonz/sources/include/tools/track.h
index 5c8f6e6fe..ce21ba528 100644
--- a/toonz/sources/include/tools/track.h
+++ b/toonz/sources/include/tools/track.h
@@ -59,6 +59,18 @@ typedef std::vector<TTrackP> TTrackList;
class DVAPI TTrackToolHandler : public TSmartObject { };
+//*****************************************************************************************
+// export template implementations for win32
+//*****************************************************************************************
+
+#ifdef _WIN32
+template class DVAPI TSmartPointerT<TTrack>;
+template class DVAPI TSmartPointerT<TTrackHandler>;
+template class DVAPI TSmartPointerT<TTrackToolHandler>;
+template class DVAPI TSmartPointerT<TTrackModifier>;
+#endif
+
+
//*****************************************************************************************
// TTrackPoint definition
//*****************************************************************************************
@@ -377,4 +389,5 @@ public:
}
};
+
#endif
diff --git a/toonz/sources/include/tstringid.h b/toonz/sources/include/tstringid.h
index 80f3ca41a..10689efae 100644
--- a/toonz/sources/include/tstringid.h
+++ b/toonz/sources/include/tstringid.h
@@ -54,7 +54,7 @@ public:
{ return iter->first; }
inline operator bool () const
- { return (bool)id(); }
+ { return id() != 0; }
inline bool operator== (const TStringId &other) const
{ return id() == other.id(); }
inline bool operator!= (const TStringId &other) const
diff --git a/toonz/sources/include/tvariant.h b/toonz/sources/include/tvariant.h
index b5f6fe4dc..2ee216586 100644
--- a/toonz/sources/include/tvariant.h
+++ b/toonz/sources/include/tvariant.h
@@ -74,7 +74,7 @@ public:
{ insert(end(), x.begin(), x.end()); return *this; }
inline bool isSubPathOf(const TVariantPath &other) const
- { return compare(*this, 0, other, 0, (int)size()); }
+ { return compare(*this, 0, other, 0, (int)size()) == 0; }
inline bool isBasePathOf(const TVariantPath &other) const
{ return other.isSubPathOf(*this); }
inline int compare(const TVariantPath &other) const
diff --git a/toonz/sources/tnztools/fullcolorbrushtool.cpp b/toonz/sources/tnztools/fullcolorbrushtool.cpp
index 22eb7d7bf..dc2048791 100644
--- a/toonz/sources/tnztools/fullcolorbrushtool.cpp
+++ b/toonz/sources/tnztools/fullcolorbrushtool.cpp
@@ -681,7 +681,7 @@ void FullColorBrushTool::loadPreset() {
try // Don't bother with RangeErrors
{
m_thickness.setValue(
- TIntPairProperty::Value(std::max((int)preset.m_min, 1), preset.m_max));
+ TIntPairProperty::Value(std::max((int)preset.m_min, 1), (int)preset.m_max));
m_hardness.setValue(preset.m_hardness, true);
m_opacity.setValue(
TDoublePairProperty::Value(preset.m_opacityMin, preset.m_opacityMax));
diff --git a/toonz/sources/tnztools/modifiers/modifierassistants.cpp b/toonz/sources/tnztools/modifiers/modifierassistants.cpp
index 16afbbde8..99a8ad867 100644
--- a/toonz/sources/tnztools/modifiers/modifierassistants.cpp
+++ b/toonz/sources/tnztools/modifiers/modifierassistants.cpp
@@ -33,7 +33,7 @@ TModifierAssistants::Modifier::Modifier(TTrackHandler &handler):
TTrackPoint
TModifierAssistants::Modifier::calcPoint(double originalIndex) {
TTrackPoint p = TTrackModifier::calcPoint(originalIndex);
- return guidelines.empty() > 0 ? p : guidelines.front()->transformPoint(p);
+ return guidelines.empty() ? p : guidelines.front()->transformPoint(p);
}