Skip to content

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

C

remove duplicated constants (#296)

Shinya Kitaokaee259ffaf77a
diff --git a/toonz/sources/CMakeLists.txt b/toonz/sources/CMakeLists.txt
index 3010fae32..7e7ae2481 100644
--- a/toonz/sources/CMakeLists.txt
+++ b/toonz/sources/CMakeLists.txt
@@ -25,6 +25,8 @@ if(WIN32)
endif()
set(QT_LIB_PATH ${QT_PATH})
set(CMAKE_PREFIX_PATH "${QT_PATH}/lib/cmake/")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4251")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251")
add_definitions(-DVC_EXTRALEAN -DNOMINMAX -D_USE_MATH_DEFINES)
elseif(APPLE)
message("Apple System")
diff --git a/toonz/sources/colorfx/regionstyles.cpp b/toonz/sources/colorfx/regionstyles.cpp
index 2a48b716f..2b322d196 100644
--- a/toonz/sources/colorfx/regionstyles.cpp
+++ b/toonz/sources/colorfx/regionstyles.cpp
@@ -19,17 +19,6 @@
#include "tmathutil.h"
#include "tstencilcontrol.h"
-//***************************************************************************
-// Local namesapce stuff
-//***************************************************************************
-
-namespace
-{
-
-const double pi2 = TConsts::pi * 2.0;
-
-} // namespace
-
//***************************************************************************
// MovingModifier implementation
//***************************************************************************
@@ -311,10 +300,10 @@ double ShadowStyle::getParamValue(TColorStyle::double_tag, int index) const
case 0:
degree = asin(m_shadowDirection.y);
if (m_shadowDirection.x < 0)
- degree = TConsts::pi - degree;
+ degree = M_PI - degree;
if (degree < 0)
- degree += pi2;
- return degree * TConsts::invOf_pi_180;
+ degree += M_2PI;
+ return degree * M_180_PI;
case 1:
return m_density;
@@ -336,7 +325,7 @@ void ShadowStyle::setParamValue(int index, double value)
switch (index) {
case 0:
- degree = value * TConsts::pi_180;
+ degree = value * M_PI_180;
m_shadowDirection.x = cos(degree);
m_shadowDirection.y = sin(degree);
break;
@@ -703,12 +692,12 @@ double ShadowStyle2::getParamValue(TColorStyle::double_tag, int index) const
double degree = asin(m_shadowDirection.y);
if (m_shadowDirection.x < 0)
- degree = TConsts::pi - degree;
+ degree = M_PI - degree;
if (degree < 0)
- degree += pi2;
+ degree += M_2PI;
- return degree * TConsts::invOf_pi_180;
+ return degree * M_180_PI;
}
//-----------------------------------------------------------------------------
@@ -740,7 +729,7 @@ void ShadowStyle2::setParamValue(int index, double value)
if (index == 1) {
m_shadowLength = value;
} else {
- double degree = value * TConsts::pi_180;
+ double degree = value * M_PI_180;
m_shadowDirection.x = cos(degree);
m_shadowDirection.y = sin(degree);
}
@@ -1323,10 +1312,10 @@ double TPointShadowFillStyle::getParamValue(TColorStyle::double_tag, int index)
case 0:
degree = asin(m_shadowDirection.y);
if (m_shadowDirection.x < 0)
- degree = TConsts::pi - degree;
+ degree = M_PI - degree;
if (degree < 0)
- degree += pi2;
- return degree * TConsts::invOf_pi_180;
+ degree += M_2PI;
+ return degree * M_180_PI;
case 1:
return m_density;
@@ -1352,7 +1341,7 @@ void TPointShadowFillStyle::setParamValue(int index, double value)
switch (index) {
case 0:
- degree = value * TConsts::pi_180;
+ degree = value * M_PI_180;
m_shadowDirection.x = cos(degree);
m_shadowDirection.y = sin(degree);
@@ -2284,7 +2273,7 @@ void ArtisticModifier::modify(TRegionOutline &outline) const
}
double wave = 1;
if (maxcounter)
- wave = sin(pi2 * counter / maxcounter);
+ wave = sin(M_2PI * counter / maxcounter);
pIt->x += m_move.x * wave;
pIt->y += m_move.y * wave;
diff --git a/toonz/sources/colorfx/strokestyles.cpp b/toonz/sources/colorfx/strokestyles.cpp
index 1668d6749..1274f33a8 100644
--- a/toonz/sources/colorfx/strokestyles.cpp
+++ b/toonz/sources/colorfx/strokestyles.cpp
@@ -132,7 +132,7 @@ inline void tglVertex(const T3DPointD &p)
TFurStrokeStyle::TFurStrokeStyle()
: m_color(TPixel32::Black), m_angle(120.0), m_length(1.0), m_cs(0.0), m_sn(0.0)
{
- double rad = TConsts::pi_180 * m_angle;
+ double rad = m_angle * M_PI_180;
m_cs = cos(rad);
m_sn = sin(rad);
}
@@ -196,7 +196,7 @@ void TFurStrokeStyle::setParamValue(int index, double value)
assert(0 <= index && index < getParamCount());
if (index == 0) {
m_angle = value;
- double rad = TConsts::pi_180 * m_angle;
+ double rad = m_angle * M_PI_180;
m_cs = cos(rad);
m_sn = sin(rad);
} else
@@ -209,7 +209,6 @@ void TFurStrokeStyle::setParamValue(int index, double value)
void TFurStrokeStyle::drawStroke(TFlash &flash, const TStroke *stroke) const
{
- using TConsts::pi;
//TStroke *stroke = getStroke();
double length = stroke->getLength();
@@ -249,7 +248,6 @@ void TFurStrokeStyle::computeData(Points &positions,
const TStroke *stroke,
const TColorFunction *cf) const
{
- using TConsts::pi;
double length = stroke->getLength();
double s = 0.0;
@@ -2114,7 +2112,7 @@ void TBraidStrokeStyle::drawStroke(const TColorFunction *cf, const TStroke *stro
const double stripethickness = 0.3;
int period = (int)(101 - m_period) * 20;
double step = period / (double)ntick;
- double freq = 2 * TConsts::pi / ntick;
+ double freq = M_2PI / ntick;
int swapcount = 0;
int count = 0;
bool firstRing = true;
@@ -2201,7 +2199,7 @@ void TBraidStrokeStyle::drawStroke(TFlash &flash, const TStroke *stroke) const
const double stripethickness = 0.3;
int period = (int)(101 - m_period) * 20;
double step = period / (double)ntick;
- double freq = 2 * TConsts::pi / ntick;
+ double freq = M_2PI / ntick;
int swapcount = 0;
int count = 0;
bool firstRing = true;
@@ -3936,7 +3934,7 @@ void TTwirlStrokeStyle::computeData(Doubles &data, const TStroke *stroke, const
} // non dovrebbe succedere mai, ma per prudenza....
u = normalize(u);
TPointD v = rotate90(u) * (pos.thick);
- double shift = sin((TConsts::pi / hperiod) * s);
+ double shift = sin((M_PI / hperiod) * s);
app = pos + v * shift;
data.push_back(app.x);
@@ -4035,7 +4033,7 @@ void TTwirlStrokeStyle::drawStroke(TFlash &flash, const TStroke *stroke) const
} // non dovrebbe succedere mai, ma per prudenza....
u = normalize(u);
TPointD v = rotate90(u) * (pos.thick);
- double shift = sin((TConsts::pi / hperiod) * s);
+ double shift = sin((M_PI / hperiod) * s);
points1.push_back(pos + v * shift);
points2.push_back(pos - v * shift);
blendval = get_inout_intensityslope(m_blend, 1.0 - m_blend, (s - ((int)(s / hperiod) * hperiod)) / hperiod);
@@ -5156,7 +5154,6 @@ void TFriezeStrokeStyle2::computeData(Points &positions,
const TStroke *stroke,
const TColorFunction *cf) const
{
- using TConsts::pi;
//TStroke *stroke = getStroke();
double length = stroke->getLength();
@@ -5185,10 +5182,10 @@ void TFriezeStrokeStyle2::computeData(Points &positions,
double thickness = pos.thick; // 5; //(1-t)*40 + t * 10;
if (thickness > 0) {
- double omega = pi * 2 / (thickness * 2);
+ double omega = M_PI / thickness;
double q = 0.5 * (1 - cos(phi));
- double theta = pi * 0.5 - pi * m_parameter * q;
+ double theta = M_PI_2 - M_PI * m_parameter * q;
double r = thickness * sin(phi);
double r1 = r * thick;
double costheta = cos(theta);
@@ -5241,7 +5238,6 @@ void TFriezeStrokeStyle2::drawStroke(const TColorFunction *cf, Points &positions
void TFriezeStrokeStyle2::drawStroke(TFlash &flash, const TStroke *stroke) const
{
- using TConsts::pi;
//TStroke *stroke = getStroke();
double length = stroke->getLength();
@@ -5265,10 +5261,10 @@ void TFriezeStrokeStyle2::drawStroke(TFlash &flash, const TStroke *stroke) const
double thickness = pos.thick; // 5; //(1-t)*40 + t * 10;
if (thickness > 0) {
- double omega = pi * 2 / (thickness * 2);
+ double omega = M_PI / thickness;
double q = 0.5 * (1 - cos(phi));
- double theta = pi * 0.5 - pi * m_parameter * q;
+ double theta = M_PI_2 - M_PI * m_parameter * q;
double r = thickness * sin(phi);
double r1 = r * thick;
double costheta = cos(theta);
diff --git a/toonz/sources/common/tcore/tmathutil.cpp b/toonz/sources/common/tcore/tmathutil.cpp
index 342520a5a..fa3a429d4 100644
--- a/toonz/sources/common/tcore/tmathutil.cpp
+++ b/toonz/sources/common/tcore/tmathutil.cpp
@@ -552,8 +552,8 @@ int rootForCubicEquation(const std::vector<double> &p, std::vector<double> &sol)
double Q_sqrt = sqrt(Q);
double theta = acos(R / (Q * Q_sqrt));
sol.push_back(-2 * Q_sqrt * cos(theta * inv_3) - a * inv_3);
- sol.push_back(-2 * Q_sqrt * cos((theta - TConsts::pi * 2.0) * inv_3) - a * inv_3);
- sol.push_back(-2 * Q_sqrt * cos((theta + TConsts::pi * 2.0) * inv_3) - a * inv_3);
+ sol.push_back(-2 * Q_sqrt * cos((theta - M_2PI) * inv_3) - a * inv_3);
+ sol.push_back(-2 * Q_sqrt * cos((theta + M_2PI) * inv_3) - a * inv_3);
std::sort(sol.begin(), sol.end());
return 3;
}
@@ -893,8 +893,8 @@ double cubicRoot(double a, double b, double c, double d)
double root[3];
root[0] = root[1] = root[2] = -2.0 * sqrt(Q);
root[0] *= cos(theta / 3.0);
- root[1] *= cos((theta + 2 * TConsts::pi) / 3.0);
- root[2] *= cos((theta - 2 * TConsts::pi) / 3.0);
+ root[1] *= cos((theta + M_2PI) / 3.0);
+ root[2] *= cos((theta - M_2PI) / 3.0);
root[0] -= b / 3.0;
root[1] -= b / 3.0;
root[2] -= b / 3.0;
diff --git a/toonz/sources/common/tgeometry/tcurveutil.cpp b/toonz/sources/common/tgeometry/tcurveutil.cpp
index 7a1fcd793..a08e6c2ea 100644
--- a/toonz/sources/common/tgeometry/tcurveutil.cpp
+++ b/toonz/sources/common/tgeometry/tcurveutil.cpp
@@ -513,7 +513,7 @@ double computeStep(const TQuadratic &quad, double pixelSize)
*/
if (A_len > 0)
- step = TConsts::sqrt2 * sqrt(pixelSize / A_len);
+ step = sqrt(2 * pixelSize / A_len);
return step;
}
diff --git a/toonz/sources/common/tgeometry/tgeometry.cpp b/toonz/sources/common/tgeometry/tgeometry.cpp
index 2cec8e19a..e2f742b51 100644
--- a/toonz/sources/common/tgeometry/tgeometry.cpp
+++ b/toonz/sources/common/tgeometry/tgeometry.cpp
@@ -192,7 +192,7 @@ TRotation::TRotation(double degrees)
break;
}
} else {
- rad = degrees * (TConsts::pi_180);
+ rad = degrees * M_PI_180;
sn = sin(rad);
cs = cos(rad);
if (sn == 1 || sn == -1)
diff --git a/toonz/sources/common/tgl/tgl.cpp b/toonz/sources/common/tgl/tgl.cpp
index a4489b867..5c14d5d75 100644
--- a/toonz/sources/common/tgl/tgl.cpp
+++ b/toonz/sources/common/tgl/tgl.cpp
@@ -52,11 +52,11 @@ int computeSlices(double radius, double pixelSize = 1.0)
if (fabs(1.0 - temp) <= 1)
thetaStep = acos(1.0 - temp);
else
- thetaStep = TConsts::pi_2 * 0.5;
+ thetaStep = M_PI_4;
assert(thetaStep != 0.0);
- int numberOfSlices = (int)(2.0 * TConsts::pi / thetaStep);
+ int numberOfSlices = (int)(M_2PI / thetaStep);
return numberOfSlices != 0 ? numberOfSlices : 2;
}
@@ -146,7 +146,7 @@ void tglDrawCircle(const TPointD &center, double radius)
if (slices <= 0)
slices = computeSlices(radius, pixelSize) >> 1;
- double step = TConsts::pi / slices;
+ double step = M_PI / slices;
double step2 = 2.0 * step;
double
@@ -160,7 +160,7 @@ void tglDrawCircle(const TPointD &center, double radius)
cos_t = radius /* *1.0*/;
sin_t = 0.0;
- for (t = 0; t + step < TConsts::pi_2; t += step2) {
+ for (t = 0; t + step < M_PI_2; t += step2) {
cos_ts = radius * cos(t + step);
sin_ts = radius * sin(t + step);
diff --git a/toonz/sources/common/trop/terodilate.cpp b/toonz/sources/common/trop/terodilate.cpp
index 519e0a224..e80f69ac8 100644
--- a/toonz/sources/common/trop/terodilate.cpp
+++ b/toonz/sources/common/trop/terodilate.cpp
@@ -286,7 +286,7 @@ void erodilate_quarters(int lx, int ly,
double radius, double shift, Func func)
{
double sqRadius = sq(radius);
- double squareHeight = radius / tcg::consts::sqrt2;
+ double squareHeight = radius * M_SQRT1_2;
int squareHeightI = tfloor(squareHeight);
// For every arc point
@@ -378,7 +378,7 @@ void circular_erodilate(const TRasterPT<Pix> &src, const TRasterPT<Pix> &dst, do
bool dilate = (radius >= 0.0);
radius = fabs(radius);
- double inner_square_diameter = radius * tcg::consts::sqrt2;
+ double inner_square_diameter = radius * M_SQRT2;
double shift = 0.25 * inner_square_diameter; // Shift of the bent square SE needed to avoid
// touching the circumference on the other side
diff --git a/toonz/sources/common/trop/tfracmove.cpp b/toonz/sources/common/trop/tfracmove.cpp
index 06e2a80cf..813da9e52 100644
--- a/toonz/sources/common/trop/tfracmove.cpp
+++ b/toonz/sources/common/trop/tfracmove.cpp
@@ -11,7 +11,7 @@ namespace
inline double gauss(double x, double y, double x0, double y0, double s)
{
- return exp(-((x - x0) * (x - x0) + (y - y0) * (y - y0)) / s) / (s * TConsts::pi);
+ return exp(-((x - x0) * (x - x0) + (y - y0) * (y - y0)) / s) / (s * M_PI);
}
//------------------------------------------------------------------------------
diff --git a/toonz/sources/common/trop/tresample.cpp b/toonz/sources/common/trop/tresample.cpp
index 155e5a4a6..28b211a5f 100644
--- a/toonz/sources/common/trop/tresample.cpp
+++ b/toonz/sources/common/trop/tresample.cpp
@@ -159,12 +159,12 @@ inline TINT32 Double2Int(double val)
inline double sinc0(double x, int a)
{
- return sin((pi / (a)) * (x)) / ((pi / (a)) * (x));
+ return sin((M_PI / (a)) * (x)) / ((M_PI / (a)) * (x));
}
inline double sinc(double x, int a)
{
- return (x) == 0.0 ? 1.0 : sin((pi / (a)) * (x)) / ((pi / (a)) * (x));
+ return (x) == 0.0 ? 1.0 : sin((M_PI / (a)) * (x)) / ((M_PI / (a)) * (x));
}
inline UCHAR TO8BIT(float X)
@@ -486,7 +486,7 @@ static inline double flt_hann2(double x)
if (x <= -2.0)
return 0.0;
if (x < 2.0)
- return sinc(x, 1) * (0.5 + 0.5 * cos((pi / 2) * x));
+ return sinc(x, 1) * (0.5 + 0.5 * cos(M_PI_2 * x));
return 0.0;
}
@@ -498,7 +498,7 @@ static inline double flt_hann3(double x)
if (x <= -3.0)
return 0.0;
if (x < 3.0)
- return sinc(x, 1) * (0.5 + 0.5 * cos((pi / 3) * x));
+ return sinc(x, 1) * (0.5 + 0.5 * cos(M_PI_3 * x));
return 0.0;
}
@@ -510,7 +510,7 @@ static inline double flt_hamming2(double x)
if (x <= -2.0)
return 0.0;
if (x < 2.0)
- return sinc(x, 1) * (0.54 + 0.46 * cos((pi / 2) * x));
+ return sinc(x, 1) * (0.54 + 0.46 * cos(M_PI_2 * x));
return 0.0;
}
@@ -522,7 +522,7 @@ static inline double flt_hamming3(double x)
if (x <= -3.0)
return 0.0;
if (x < 3.0)
- return sinc(x, 1) * (0.54 + 0.46 * cos((pi / 3) * x));
+ return sinc(x, 1) * (0.54 + 0.46 * cos(M_PI_3 * x));
return 0.0;
}
@@ -558,7 +558,7 @@ static inline double flt_gauss(double x)
if (x <= -2.0)
return 0.0;
if (x < 2.0)
- return exp((-pi) * x * x);
+ return exp(-M_PI * x * x);
return 0.0; /* exp(-M_PI*2*2)~=3.5*10^-6 */
}
@@ -1100,25 +1100,25 @@ inline double get_filter_value(TRop::ResampleFilterType flt_type, double x)
case TRop::Hann2:
if (x <= -2.0) return 0.0;
if (x < 2.0)
- return sinc0(x, 1) * (0.5 + 0.5 * cos((pi / 2) * x));
+ return sinc0(x, 1) * (0.5 + 0.5 * cos(M_PI_2 * x));
break;
case TRop::Hann3:
if (x <= -3.0) return 0.0;
if (x < 3.0)
- return sinc0(x, 1) * (0.5 + 0.5 * cos((pi / 3) * x));
+ return sinc0(x, 1) * (0.5 + 0.5 * cos(M_PI_3 * x));
break;
case TRop::Hamming2:
if (x <= -2.0) return 0.0;
if (x < 2.0)
- return sinc0(x, 1) * (0.54 + 0.46 * cos((pi / 2) * x));
+ return sinc0(x, 1) * (0.54 + 0.46 * cos(M_PI_2 * x));
break;
case TRop::Hamming3:
if (x <= -3.0) return 0.0;
if (x < 3.0)
- return sinc0(x, 1) * (0.54 + 0.46 * cos((pi / 3) * x));
+ return sinc0(x, 1) * (0.54 + 0.46 * cos(M_PI_3 * x));
break;
case TRop::Lanczos2:
@@ -1136,7 +1136,7 @@ inline double get_filter_value(TRop::ResampleFilterType flt_type, double x)
case TRop::Gauss:
if (x <= -2.0) return 0.0;
if (x < 2.0)
- return exp((-pi) * x * x); /* exp(-M_PI*2*2)~=3.5*10^-6 */
+ return exp(-M_PI * x * x); /* exp(-M_PI*2*2)~=3.5*10^-6 */
break;
default:
assert(!"bad filter type");
diff --git a/toonz/sources/common/tsound/tsop.cpp b/toonz/sources/common/tsound/tsop.cpp
index 0d3098796..1a1ede2d3 100644
--- a/toonz/sources/common/tsound/tsop.cpp
+++ b/toonz/sources/common/tsound/tsop.cpp
@@ -65,8 +65,8 @@ typedef struct
//---------------------------------------------------------
-#define M_PIF ((float)TConsts::pi)
-#define SINC0(x, a) (sin((TConsts::pi / (a)) * (x)) / ((TConsts::pi / (a)) * (x)))
+#define M_PIF float(M_PI)
+#define SINC0(x, a) (sin((M_PI / (a)) * (x)) / ((M_PI / (a)) * (x)))
#define SINC0F(x, a) (sinf((M_PIF / (a)) * (x)) / ((M_PIF / (a)) * (x)))
#define SINC(x, a) ((x) == 0.0 ? 1.0 : SINC0(x, a))
#define SINCF(x, a) ((x) == 0.0F ? 1.0F : SINC0F(x, a))
@@ -190,22 +190,22 @@ double filterValue(FLT_TYPE flt_type, double x)
case FLT_HANN2:
if (x <= -2.0) result = 0.0;
- else if (x < 2.0) result = SINC0(x, 1) * (0.5 + 0.5 * cos((TConsts::pi_2)*x));
+ else if (x < 2.0) result = SINC0(x, 1) * (0.5 + 0.5 * cos(M_PI_2 * x));
break;
case FLT_HANN3:
if (x <= -3.0) result = 0.0;
- else if (x < 3.0) result = SINC0(x, 1) * (0.5 + 0.5 * cos((TConsts::pi / 3) * x));
+ else if (x < 3.0) result = SINC0(x, 1) * (0.5 + 0.5 * cos((M_PI / 3) * x));
break;
case FLT_HAMMING2:
if (x <= -2.0) result = 0.0;
- else if (x < 2.0) result = SINC0(x, 1) * (0.54 + 0.46 * cos((TConsts::pi_2)*x));
+ else if (x < 2.0) result = SINC0(x, 1) * (0.54 + 0.46 * cos(M_PI_2 * x));
break;
case FLT_HAMMING3:
if (x <= -3.0) result = 0.0;
- else if (x < 3.0) result = SINC0(x, 1) * (0.54 + 0.46 * cos((TConsts::pi / 3) * x));
+ else if (x < 3.0) result = SINC0(x, 1) * (0.54 + 0.46 * cos((M_PI / 3) * x));
break;
case FLT_LANCZOS2:
@@ -220,7 +220,7 @@ double filterValue(FLT_TYPE flt_type, double x)
case FLT_GAUSS:
if (x <= -2.0) result = 0.0;
- else if (x < 2.0) result = exp((-TConsts::pi) * x * x);
+ else if (x < 2.0) result = exp((-M_PI) * x * x);
/* exp(-M_PI*2*2)~=3.5*10^-6 */
break;
diff --git a/toonz/sources/common/tunit/tunit.cpp b/toonz/sources/common/tunit/tunit.cpp
index 89bddd7c3..5328ab6b2 100644
--- a/toonz/sources/common/tunit/tunit.cpp
+++ b/toonz/sources/common/tunit/tunit.cpp
@@ -71,8 +71,8 @@ class TangentConverter : public TUnitConverter
public:
TangentConverter() {}
TUnitConverter *clone() const { return new TangentConverter(*this); }
- double convertTo(double v) const { return 180.0 * atan(v) / TConsts::pi; }
- double convertFrom(double v) const { return tan(TConsts::pi * v / 180.0); }
+ double convertTo(double v) const { return atan(v) * (M_1_PI * 180.0); }
+ double convertFrom(double v) const { return tan(v * M_PI_180); }
};
//===================================================================
diff --git a/toonz/sources/common/tvectorimage/outlineApproximation.cpp b/toonz/sources/common/tvectorimage/outlineApproximation.cpp
index bca542532..98973f32e 100644
--- a/toonz/sources/common/tvectorimage/outlineApproximation.cpp
+++ b/toonz/sources/common/tvectorimage/outlineApproximation.cpp
@@ -57,7 +57,7 @@ double localComputeStep(const TQuadratic &quad, double pixelSize)
double A_len = norm(A);
if (A_len > 0)
- step = TConsts::sqrt2 * sqrt(pixelSize / A_len);
+ step = sqrt(2 * pixelSize / A_len);
return step;
}
diff --git a/toonz/sources/common/tvectorimage/tcomputeregions.cpp b/toonz/sources/common/tvectorimage/tcomputeregions.cpp
index d56935242..514aa4d88 100644
--- a/toonz/sources/common/tvectorimage/tcomputeregions.cpp
+++ b/toonz/sources/common/tvectorimage/tcomputeregions.cpp
@@ -1082,8 +1082,8 @@ inline void insertBranch(Intersection &in, IntersectedStroke &item, bool getting
double getAngle(const TPointD &p0, const TPointD &p1)
{
- double angle1 = 180 * atan2(p0.x, p0.y) / TConsts::pi;
- double angle2 = 180 * atan2(p1.x, p1.y) / TConsts::pi;
+ double angle1 = atan2(p0.x, p0.y) * M_180_PI;
+ double angle2 = atan2(p1.x, p1.y) * M_180_PI;
if (angle1 < 0)
angle1 = 360 + angle1;
diff --git a/toonz/sources/common/tvectorimage/tstroke.cpp b/toonz/sources/common/tvectorimage/tstroke.cpp
index 0b70afc63..1ac2a3435 100644
--- a/toonz/sources/common/tvectorimage/tstroke.cpp
+++ b/toonz/sources/common/tvectorimage/tstroke.cpp
@@ -3150,7 +3150,7 @@ void splitStroke(const TStroke &tq,
void detectCorners(const TStroke *stroke, double minDegree, std::vector<int> &corners)
{
- const double minSin = fabs(sin(minDegree * TConsts::pi_180));
+ const double minSin = fabs(sin(minDegree * M_PI_180));
const TThickQuadratic *quad1 = 0;
const TThickQuadratic *quad2 = 0;
@@ -3575,11 +3575,11 @@ void computeQuadraticsFromCubic(const TThickCubic &cubic,
double cs2 = sq(tmp) / (4 * norm2_side0p * norm2_side3p);
//assert (0 <= cs2 && cs2 <= 1 + TConsts::epsilon);
assert(areAlmostEqual(tsign(cs_sign) * sqrt(cs2), tmp / (2 * sqrt(norm2_side0p) * sqrt(norm2_side3p))));
- assert(!(cs_sign < 0) || acos(-sqrt(cs2)) > 10 * TConsts::pi_180); // cs_sign < 0 => acos(-sqrt(cs2)) > 10°
+ assert(!(cs_sign < 0) || acos(-sqrt(cs2)) > 10 * M_PI_180); // cs_sign < 0 => acos(-sqrt(cs2)) > 10°
if (cs_sign < 0 || cs2 < 0.969846) // cos(10°)^2 = 0.969846
{ // limita distanza di intersection: elimina quadratiche "cappio" (con p1 "lontano")
- //assert (acos(tsign(cs_sign)*sqrt(cs2)) > 10*TConsts::pi_180);
- assert(tsign(cs_sign) * sqrt(cs2) < cos(10 * TConsts::pi_180));
+ //assert (acos(tsign(cs_sign)*sqrt(cs2)) > 10*M_PI_180);
+ assert(tsign(cs_sign) * sqrt(cs2) < cos(10 * M_PI_180));
TPointD intersection = p0 + t01 * (p1 - p0); // = p2 + t32*(p2 - p3)
TThickPoint p(intersection.x, intersection.y, 0.5 * (cubic.getThickP1().thick + cubic.getThickP2().thick)); // compatibilita' precedente funzione
chunkArray.push_back(new TThickQuadratic(cubic.getThickP0(), p, cubic.getThickP3()));
diff --git a/toonz/sources/common/tvrender/tellipticbrush.cpp b/toonz/sources/common/tvrender/tellipticbrush.cpp
index 7b6f7dfa7..521fed993 100644
--- a/toonz/sources/common/tvrender/tellipticbrush.cpp
+++ b/toonz/sources/common/tvrender/tellipticbrush.cpp
@@ -903,14 +903,12 @@ void tellipticbrush::OutlineBuilder::addRoundSideCaps(
//The only dangerous case is when the directions are near-opposed
if (prevD * nextD < 0) {
- const double twice_pi = 2 * TConsts::pi;
-
//Here, we must make one angle its (sign-opposite) 2*pi complement.
//Keep the angle with the least fabs (smallest 'butterfly intersection')
if (fabs(totAngleL) < fabs(totAngleR))
- totAngleR = (totAngleR > 0) ? totAngleR - twice_pi : totAngleR + twice_pi;
+ totAngleR = (totAngleR > 0) ? totAngleR - M_2PI : totAngleR + M_2PI;
else
- totAngleL = (totAngleL > 0) ? totAngleL - twice_pi : totAngleL + twice_pi;
+ totAngleL = (totAngleL > 0) ? totAngleL - M_2PI : totAngleL + M_2PI;
}
}
diff --git a/toonz/sources/common/tvrender/tinbetween.cpp b/toonz/sources/common/tvrender/tinbetween.cpp
index d6443ad54..b788ca1de 100644
--- a/toonz/sources/common/tvrender/tinbetween.cpp
+++ b/toonz/sources/common/tvrender/tinbetween.cpp
@@ -193,7 +193,7 @@ void eraseSmallAngles(std::vector<std::pair<int, double>> &corners, double angle
void detectCorners(const TStroke *stroke, double minDegree,
std::vector<std::pair<int, double>> &corners, double &min, double &max)
{
- const double minSin = fabs(sin(minDegree * TConsts::pi_180));
+ const double minSin = fabs(sin(minDegree * M_PI_180));
double angle, vectorialProduct, metaCornerLen, partialLen;
UINT quadCount1 = stroke->getChunkCount();
@@ -213,7 +213,7 @@ void detectCorners(const TStroke *stroke, double minDegree,
vectorialProduct = fabs(cross(tan1, tan2));
if (tan1 * tan2 < 0) {
- angle = 180 - asin(tcrop(vectorialProduct, -1.0, 1.0)) * TConsts::invOf_pi_180;
+ angle = 180 - asin(tcrop(vectorialProduct, -1.0, 1.0)) * M_180_PI;
corners.push_back(std::make_pair(j, angle));
//------------------------------------------
@@ -226,7 +226,7 @@ void detectCorners(const TStroke *stroke, double minDegree,
if (max < angle)
max = angle;
} else if (vectorialProduct >= minSin) {
- angle = asin(tcrop(vectorialProduct, -1.0, 1.0)) * TConsts::invOf_pi_180;
+ angle = asin(tcrop(vectorialProduct, -1.0, 1.0)) * M_180_PI;
corners.push_back(std::make_pair(j, angle));
//------------------------------------------
@@ -262,7 +262,7 @@ void detectCorners(const TStroke *stroke, double minDegree,
vectorialProduct = fabs(cross(tan1, tan2));
if (tan1 * tan2 < 0) {
- angle = 180 - asin(tcrop(vectorialProduct, -1.0, 1.0)) * TConsts::invOf_pi_180;
+ angle = 180 - asin(tcrop(vectorialProduct, -1.0, 1.0)) * M_180_PI;
metaCornerLen = ratioLen * (stroke->getChunk(j - 1)->getLength() + stroke->getChunk(j)->getLength());
partialLen = 0;
@@ -280,7 +280,7 @@ void detectCorners(const TStroke *stroke, double minDegree,
tan2 = normalize(tan2);
vectorialProduct = fabs(cross(tan1, tan2));
- double nearAngle = asin(tcrop(vectorialProduct, -1.0, 1.0)) * TConsts::invOf_pi_180;
+ double nearAngle = asin(tcrop(vectorialProduct, -1.0, 1.0)) * M_180_PI;
if (tan1 * tan2 < 0)
nearAngle = 180 - nearAngle;
@@ -307,7 +307,7 @@ void detectCorners(const TStroke *stroke, double minDegree,
tan2 = normalize(tan2);
vectorialProduct = fabs(cross(tan1, tan2));
- double nearAngle = asin(tcrop(vectorialProduct, -1.0, 1.0)) * TConsts::invOf_pi_180;
+ double nearAngle = asin(tcrop(vectorialProduct, -1.0, 1.0)) * M_180_PI;
if (tan1 * tan2 < 0)
nearAngle = 180 - nearAngle;
@@ -1031,7 +1031,7 @@ void TInbetween::Imp::computeTransformation()
totalRadRotation += radRotation;
}
totalRadRotation /= (cornerSize - 1);
- transform.m_rotation = TConsts::invOf_pi_180 * totalRadRotation;
+ transform.m_rotation = totalRadRotation * M_180_PI;
if (isAlmostZero(transform.m_rotation, 2)) {
transform.m_rotation = 0.0;
diff --git a/toonz/sources/common/tvrender/tstrokedeformations.cpp b/toonz/sources/common/tvrender/tstrokedeformations.cpp
index 0a36b5abb..82238216c 100644
--- a/toonz/sources/common/tvrender/tstrokedeformations.cpp
+++ b/toonz/sources/common/tvrender/tstrokedeformations.cpp
@@ -57,7 +57,7 @@ struct bowlPotential {
if (radiusToTest > m_radiusOuter)
return 0.0;
- return 0.5 * (1.0 + cos((radiusToTest - m_radiusInner) / (m_radiusOuter - m_radiusInner) * TConsts::pi));
+ return 0.5 * (1.0 + cos((radiusToTest - m_radiusInner) / (m_radiusOuter - m_radiusInner) * M_PI));
}
virtual double gradient(double radiusToTest)
@@ -66,7 +66,7 @@ struct bowlPotential {
if (radiusToTest <= m_radiusInner || radiusToTest > m_radiusOuter)
return 0.0;
- double den = TConsts::pi / (m_radiusOuter - m_radiusInner);
+ double den = M_PI / (m_radiusOuter - m_radiusInner);
return -0.5 * den * sin(den * (radiusToTest - m_radiusInner));
}
@@ -542,7 +542,7 @@ double TStrokeBenderDeformation::getDelta(const TStroke &s, double w) const
double totalLenght = s.getLength();
if (totalLenght != 0) {
- double val = s.getLength(w) / totalLenght * TConsts::pi * 10.0;
+ double val = s.getLength(w) / totalLenght * (M_PI * 10.0);
return sin(val);
}
@@ -598,7 +598,7 @@ double TStrokeTwirlDeformation::getDelta(const TStroke &stroke, double s) const
if(totalLenght != 0)
{
- double val = stroke.getLength(s)/totalLenght * TConsts::pi *11.0;
+ double val = stroke.getLength(s)/totalLenght * (M_PI * 11.0);
return sin(val);
}
diff --git a/toonz/sources/common/tvrender/tstrokeutil.cpp b/toonz/sources/common/tvrender/tstrokeutil.cpp
index 2465dde07..fbbfd44d6 100644
--- a/toonz/sources/common/tvrender/tstrokeutil.cpp
+++ b/toonz/sources/common/tvrender/tstrokeutil.cpp
@@ -188,7 +188,7 @@ void detectEdges(const std::vector<TPointD> &pointArray, std::vector<UINT> &edge
const double dMin2 = dMin * dMin;
const double dMax2 = dMax * dMax;
std::vector<double> sharpnessArray;
- sharpnessArray.push_back(TConsts::pi); // il primo punto e' un corner
+ sharpnessArray.push_back(M_PI); // il primo punto e' un corner
int nodeCount;
for (nodeCount = 1; nodeCount < size - 1; ++nodeCount) { // scorre la sharpPointArray escludendo gli estremi
sharpnessArray.push_back(0);
@@ -219,7 +219,7 @@ void detectEdges(const std::vector<TPointD> &pointArray, std::vector<UINT> &edge
if (alpha > alphaMax)
continue;
- double sharpness = TConsts::pi - alpha;
+ double sharpness = M_PI - alpha;
if (sharpnessArray[nodeCount] < sharpness)
sharpnessArray[nodeCount] = sharpness;
diff --git a/toonz/sources/include/tcg/consts.h b/toonz/sources/include/tcg/consts.h
deleted file mode 100644
index 284d5d187..000000000
--- a/toonz/sources/include/tcg/consts.h
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-#ifndef TCG_CONSTS_H
-#define TCG_CONSTS_H
-
-/*!
- \file consts.h
-
- \brief This file contains several useful constants to be used with tcg.
-*/
-
-//*************************************************************************************
-// TCG Constants
-//*************************************************************************************
-
-namespace tcg
-{
-
-//! Contains several useful constants to be used with tcg.
-namespace consts
-{
-
-const double pi = 3.1415926535897932384626433832795; //!< The Pi constant.
-const double pi_half = 1.5707963267948966192313216916398; //!< Half of Pi.
-const double pi_3half = 3.0 * pi_half; //!< Three halves of Pi.
-const double pi_twice = 2.0 * pi; //!< Twice Pi.
-
-const double rad_to_deg = 180.0 / pi; //!< Radians to degrees factor.
-const double deg_to_rad = pi / 180.0; //!< Degrees to radians factor.
-
-const double sqrt2 = 1.4142135623730950488016887242097; //!< Square root of 2.
-const double sqrt2_half = 0.7071067811865475244008443621048; //!< Half of the square root of 2.
-}
-} // namespace tcg::consts
-
-#endif // TCG_CONSTS_H
diff --git a/toonz/sources/include/tcg/point_ops.h b/toonz/sources/include/tcg/point_ops.h
index 73f232afa..bd246e32c 100644
--- a/toonz/sources/include/tcg/point_ops.h
+++ b/toonz/sources/include/tcg/point_ops.h
@@ -5,7 +5,6 @@
// tcg includes
#include "point.h"
-#include "consts.h"
#include "numeric_ops.h"
/*!
@@ -308,7 +307,7 @@ inline typename point_traits<Point>::value_type rad(const Point &p)
template <typename Point>
inline typename point_traits<Point>::value_type angle(const Point &v1, const Point &v2)
{
- return numeric_ops::mod<typename point_traits<Point>::value_type>(rad(v2) - rad(v1), -consts::pi, consts::pi);
+ return numeric_ops::mod<typename point_traits<Point>::value_type>(rad(v2) - rad(v1), -M_PI, M_PI);
}
//-------------------------------------------------------------------------------------------
diff --git a/toonz/sources/include/tcg/tcg_misc.h b/toonz/sources/include/tcg/tcg_misc.h
index 7c1abb22f..2e0cd2ed8 100644
--- a/toonz/sources/include/tcg/tcg_misc.h
+++ b/toonz/sources/include/tcg/tcg_misc.h
@@ -11,7 +11,6 @@
*/
// tcg includes
-#include "consts.h"
#include "numeric_ops.h"
#include "poly_ops.h"
#include "point_ops.h"
diff --git a/toonz/sources/include/tcommon.h b/toonz/sources/include/tcommon.h
index 7ad3e4ccf..d4cc969a0 100644
--- a/toonz/sources/include/tcommon.h
+++ b/toonz/sources/include/tcommon.h
@@ -63,18 +63,17 @@ int nanosleep(struct timespec *, int);
#include <map>
// .. and so on
-/* the value of pi defined in IRIX-math.h is not defined neither in WIN32-math.h nor elsewhere */
namespace TConsts
{
-const double pi = 3.1415926535897932384626433832795;
-const double pi_2 = 1.5707963267948966192313216916398;
const double epsilon = 1e-8;
-const double sqrt2 = 1.4142135623730950488016887242097;
-const double sqrt2_2 = 0.7071067811865475244008443621048;
-const double pi_180 = pi / 180.0;
-const double invOf_pi_180 = 180.0 / pi;
}
+// use macros insted of constexprs, because MSVC2013 does not support `constexpr`.
+#define M_PI_3 (M_PI / 3)
+#define M_PI_180 (M_PI_4 / 45)
+#define M_180_PI (90 * M_2_PI)
+#define M_2PI (2 * M_PI)
+
// typedef's
#include "tnztypes.h"
diff --git a/toonz/sources/include/tutil.h b/toonz/sources/include/tutil.h
index 812739103..f0e00443e 100644
--- a/toonz/sources/include/tutil.h
+++ b/toonz/sources/include/tutil.h
@@ -98,7 +98,7 @@ inline int intGE(double x)
*/
inline double rad2degree(double rad)
{
- return rad * TConsts::invOf_pi_180;
+ return rad * M_180_PI;
}
//! convert degree to radiant
@@ -109,7 +109,7 @@ inline double rad2degree(double rad)
*/
inline double degree2rad(double degree)
{
- return degree * TConsts::pi_180;
+ return degree * M_PI_180;
}
//! Sign of argument.
diff --git a/toonz/sources/stdfx/colorembossfx.cpp b/toonz/sources/stdfx/colorembossfx.cpp
index 916f8b0a8..e7537db06 100644
--- a/toonz/sources/stdfx/colorembossfx.cpp
+++ b/toonz/sources/stdfx/colorembossfx.cpp
@@ -174,9 +174,9 @@ void ColorEmbossFx::doCompute(TTile &tile, double frame, const TRenderSettings &
double scale = sqrt(fabs(ri.m_affine.det()));
double radius = m_radius->getValue(frame) * scale;
double direction = m_direction->getValue(frame);
- double elevation = (m_elevation->getValue(frame)) * TConsts::pi / 180;
+ double elevation = (m_elevation->getValue(frame)) * M_PI_180;
double intensity = m_intensity->getValue(frame);
- double azimuth = direction * TConsts::pi / 180;
+ double azimuth = direction * M_PI_180;
int border = radius + 1;
TRasterP srcRas = tile.getRaster()->create(tile.getRaster()->getLx() + border * 2, tile.getRaster()->getLy() + border * 2);
diff --git a/toonz/sources/stdfx/embossfx.cpp b/toonz/sources/stdfx/embossfx.cpp
index aa928e415..677ee0b95 100644
--- a/toonz/sources/stdfx/embossfx.cpp
+++ b/toonz/sources/stdfx/embossfx.cpp
@@ -159,9 +159,9 @@ void EmbossFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
double scale = sqrt(fabs(ri.m_affine.det()));
double radius = tcrop(m_radius->getValue(frame), min, max) * scale;
double direction = (m_direction->getValue(frame));
- double elevation = (m_elevation->getValue(frame)) * TConsts::pi / 180;
+ double elevation = (m_elevation->getValue(frame)) * M_PI_180;
double intensity = m_intensity->getValue(frame);
- double azimuth = direction * TConsts::pi / 180;
+ double azimuth = direction * M_PI_180;
//NOTE: This enlargement is perhaps needed in the calculation of the fx - but no output will
//be generated for it - so there is no trace of it in the doGetBBox function...
diff --git a/toonz/sources/stdfx/igs_attenuation_distribution.cpp b/toonz/sources/stdfx/igs_attenuation_distribution.cpp
index fe574e112..3a725bb4c 100644
--- a/toonz/sources/stdfx/igs_attenuation_distribution.cpp
+++ b/toonz/sources/stdfx/igs_attenuation_distribution.cpp
@@ -4,13 +4,10 @@
namespace
{
-#ifndef M_PI /* for vc2005 */
-#define M_PI 3.14159265358979323846
-#endif
bool inside_polygon_(
double radius, int odd_diameter, double xp, double yp, int polygon_num, double degree)
{
- double radian = degree * M_PI / 180.0,
+ double radian = degree * (M_PI / 180),
add_radian = 2.0 * M_PI / polygon_num,
x1 = 0, y1 = 0, x2, y2,
xa = -odd_diameter,
diff --git a/toonz/sources/stdfx/igs_line_blur.cpp b/toonz/sources/stdfx/igs_line_blur.cpp
index 7bb7ad47e..d35ea8be7 100644
--- a/toonz/sources/stdfx/igs_line_blur.cpp
+++ b/toonz/sources/stdfx/igs_line_blur.cpp
@@ -1160,7 +1160,7 @@ double calculator_geometry::get_d_radian(double d_xv, double d_yv)
}
/* 第2象限 (第1象限に置き換えて... 0 <= angle < 90) */
else if ((d_xv <= 0.0) && (0.0 < d_yv)) {
- d_radian = atan(-d_xv / d_yv) + M_PI / 2.0;
+ d_radian = atan(-d_xv / d_yv) + M_PI_2;
}
/* 第3象限 (第1象限に置き換えて... 0 <= angle < 90) */
else if ((d_xv < 0.0) && (d_yv <= 0.0)) {
@@ -1168,7 +1168,7 @@ double calculator_geometry::get_d_radian(double d_xv, double d_yv)
}
/* 第4象限 (第1象限に置き換えて... 0 <= angle < 90) */
else if ((0.0 <= d_xv) && (d_yv < 0.0)) {
- d_radian = atan(d_xv / -d_yv) + M_PI + M_PI / 2.0;
+ d_radian = atan(d_xv / -d_yv) + M_PI + M_PI_2;
}
return d_radian;
}
diff --git a/toonz/sources/stdfx/igs_maxmin_lens_matrix.cpp b/toonz/sources/stdfx/igs_maxmin_lens_matrix.cpp
index 57ce7da1a..8ddd63716 100644
--- a/toonz/sources/stdfx/igs_maxmin_lens_matrix.cpp
+++ b/toonz/sources/stdfx/igs_maxmin_lens_matrix.cpp
@@ -25,7 +25,7 @@ bool inside_polygon_(
if (polygon_number < 3) { /* equal less than 2 is circle */
return true;
}
- double radian = roll_degree * M_PI / 180.0, add_radian = 2.0 * M_PI / polygon_number;
+ double radian = roll_degree * (M_PI / 180), add_radian = 2.0 * M_PI / polygon_number;
double x1 = radius * cos(radian), y1 = radius * sin(radian), x2 = 0, y2 = 0, xa = odd_diameter, xb = odd_diameter;
radian += add_radian;
@@ -114,7 +114,7 @@ double length_to_polygon_(
/* 多角形の辺の2点 */
double x1 = 0.0, y1 = 0.0, x2 = 0.0, y2 = 0.0;
const double add_radian = 2.0 * M_PI / polygon_number;
- double radian1 = roll_degree * M_PI / 180.0;
+ double radian1 = roll_degree * (M_PI / 180);
/* rad1だとMS-VC++_v10でエラー!!! */
while (radian1 < 0.0) {
radian1 += add_radian;
diff --git a/toonz/sources/stdfx/iwa_directionalblurfx.cpp b/toonz/sources/stdfx/iwa_directionalblurfx.cpp
index 19339352d..28937b843 100644
--- a/toonz/sources/stdfx/iwa_directionalblurfx.cpp
+++ b/toonz/sources/stdfx/iwa_directionalblurfx.cpp
@@ -119,7 +119,7 @@ void Iwa_DirectionalBlurFx::doCompute(TTile &tile,
}
TPointD blurVector;
- double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
+ double angle = m_angle->getValue(frame) * M_PI_180;
double intensity = m_intensity->getValue(frame);
bool bidirectional = m_bidirectional->getValue();
@@ -567,7 +567,7 @@ bool Iwa_DirectionalBlurFx::doGetBBox(double frame,
return ret;
TPointD blur;
- double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
+ double angle = m_angle->getValue(frame) * M_PI_180;
double intensity = m_intensity->getValue(frame);
bool bidirectional = m_bidirectional->getValue();
diff --git a/toonz/sources/stdfx/iwa_particles.cpp b/toonz/sources/stdfx/iwa_particles.cpp
index 2dfb369ac..1e42396b4 100644
--- a/toonz/sources/stdfx/iwa_particles.cpp
+++ b/toonz/sources/stdfx/iwa_particles.cpp
@@ -389,11 +389,11 @@ void Iwa_Particle::update_Swing(const particles_values &values,
if (values.swingmode_val == Iwa_TiledParticlesFx::SWING_SMOOTH) {
if (smperiodx)
- dummy.x = smswingx * randomxreference * sin((TConsts::pi * changesignx) / smperiodx);
+ dummy.x = smswingx * randomxreference * sin((M_PI * changesignx) / smperiodx);
else
dummy.x = 0;
if (smperiody)
- dummy.y = smswingy * randomyreference * sin((TConsts::pi * changesigny) / smperiody);
+ dummy.y = smswingy * randomyreference * sin((M_PI * changesigny) / smperiody);
else
dummy.y = 0;
} else {
@@ -409,7 +409,7 @@ void Iwa_Particle::update_Swing(const particles_values &values,
if (values.rotswingmode_val == Iwa_TiledParticlesFx::SWING_SMOOTH) {
if (smperioda)
- dummy.a = smswinga * sin((TConsts::pi * changesigna) / smperioda);
+ dummy.a = smswinga * sin((M_PI * changesigna) / smperioda);
else
dummy.a = 0;
} else
diff --git a/toonz/sources/stdfx/iwa_particlesengine.cpp b/toonz/sources/stdfx/iwa_particlesengine.cpp
index af1eb332a..4d545c49d 100644
--- a/toonz/sources/stdfx/iwa_particlesengine.cpp
+++ b/toonz/sources/stdfx/iwa_particlesengine.cpp
@@ -516,10 +516,10 @@ void Iwa_Particles_Engine::normalize_values(struct particles_values &values,
(values.trailopacity_val.second) = (values.trailopacity_val.second) * 0.01;
(values.mblur_val) = (values.mblur_val) * 0.01;
(values.friction_val) = -(values.friction_val) * 0.01;
- (values.windangle_val) = (values.windangle_val) * (TConsts::pi / 180);
- (values.g_angle_val) = (values.g_angle_val + 180) * (TConsts::pi / 180);
- (values.speeda_val.first) = (values.speeda_val.first) * (TConsts::pi / 180);
- (values.speeda_val.second) = (values.speeda_val.second) * (TConsts::pi / 180);
+ (values.windangle_val) = (values.windangle_val) * M_PI_180;
+ (values.g_angle_val) = (values.g_angle_val + 180) * M_PI_180;
+ (values.speeda_val.first) = (values.speeda_val.first) * M_PI_180;
+ (values.speeda_val.second) = (values.speeda_val.second) * M_PI_180;
if (values.step_val < 1)
values.step_val = 1;
values.genfadecol_val = (values.genfadecol_val) * 0.01;
@@ -527,8 +527,8 @@ void Iwa_Particles_Engine::normalize_values(struct particles_values &values,
values.foutfadecol_val = (values.foutfadecol_val) * 0.01;
(values.curl_val) = (values.curl_val) * dpicorr * 0.1;
/*- ひらひら粒子に照明を当てる normalize_values()内で Degree → Radian 化する -*/
- (values.iw_light_theta_val) = (values.iw_light_theta_val) * (TConsts::pi / 180);
- (values.iw_light_phi_val) = (values.iw_light_phi_val) * (TConsts::pi / 180);
+ (values.iw_light_theta_val) = (values.iw_light_theta_val) * M_PI_180;
+ (values.iw_light_phi_val) = (values.iw_light_phi_val) * M_PI_180;
/*- 読み込みマージン -*/
(values.margin_val) = (values.margin_val) * dpicorr;
}
@@ -961,7 +961,7 @@ void Iwa_Particles_Engine::do_render(TFlash *flash,
double aim_angle = 0;
if (values.pathaim_val) {
float arctan = atan2f(part->vy, part->vx);
- aim_angle = (180 / TConsts::pi) * arctan;
+ aim_angle = arctan * M_180_PI;
}
/*- 粒子の回転、スケールをアフィン行列に入れる -*/
diff --git a/toonz/sources/stdfx/iwa_pnperspectivefx.cpp b/toonz/sources/stdfx/iwa_pnperspectivefx.cpp
index ead350660..c7e0d433c 100644
--- a/toonz/sources/stdfx/iwa_pnperspectivefx.cpp
+++ b/toonz/sources/stdfx/iwa_pnperspectivefx.cpp
@@ -138,7 +138,7 @@ void Iwa_PNPerspectiveFx::getPNParameters(TTile &tile, double frame,
(double)camHeight * aff_pn.a22);
params.fy_2 = sqrtf(vec_p0p1.x * vec_p0p1.x + vec_p0p1.y * vec_p0p1.y) / 2.0f;
- float fov_radian_2 = (fov / 2.0f) * M_PI / 180.0f;
+ float fov_radian_2 = (fov / 2.0f) * float(M_PI_180);
/* カメラから投影面への距離 */
float D = params.fy_2 / tanf(fov_radian_2);
diff --git a/toonz/sources/stdfx/kaleido.cpp b/toonz/sources/stdfx/kaleido.cpp
index bd915b93d..f79887efa 100644
--- a/toonz/sources/stdfx/kaleido.cpp
+++ b/toonz/sources/stdfx/kaleido.cpp
@@ -38,7 +38,7 @@ int KaleidoDistorter::invMap(const TPointD &p, TPointD *results) const
// Build p's angular position
double qAngle = atan2(q.y, q.x);
if (qAngle < 0.0)
- qAngle += 2.0 * TConsts::pi;
+ qAngle += 2.0 * M_PI;
assert(qAngle >= 0.0);
@@ -120,7 +120,7 @@ private:
void KaleidoFx::buildSectionRect(TRectD &inRect, double angle)
{
inRect.y0 = std::max(inRect.y0, 0.0);
- if (angle <= TConsts::pi_2) {
+ if (angle <= M_PI_2) {
inRect.x0 = std::max(inRect.x0, 0.0);
inRect.y1 = std::min(inRect.y1, inRect.x1 * tan(angle));
}
@@ -144,7 +144,7 @@ TAffine KaleidoFx::buildInputReference(
const TRectD &outRect, const TRenderSettings &outInfo)
{
double scale = fabs(sqrt(outInfo.m_affine.det()));
- double angle = TConsts::pi / m_count->getValue();
+ double angle = M_PI / m_count->getValue();
inInfo.m_affine = TRotation(-m_angle->getValue(frame) - angle) *
TScale(scale).place(m_center->getValue(frame), TPointD());
@@ -178,7 +178,7 @@ bool KaleidoFx::doGetBBox(double frame, TRectD &bBox, const TRenderSettings &inf
if (!m_input.getFx())
return false;
- double angle = TConsts::pi / m_count->getValue();
+ double angle = M_PI / m_count->getValue();
TRenderSettings inInfo(info);
inInfo.m_affine = TRotation(-m_angle->getValue(frame) - angle) *
@@ -267,7 +267,7 @@ void KaleidoFx::doCompute(TTile &tile, double frame, const TRenderSettings &info
m_input->allocateAndCompute(inTile, inRect.getP00(), inDim, tile.getRaster(), frame, inInfo);
// Now, perform kaleido
- double angle = TConsts::pi / m_count->getValue();
+ double angle = M_PI / m_count->getValue();
KaleidoDistorter distorter(angle, outRefToInRef, -inRect.getP00());
TRasterP inRas(inTile.getRaster());
diff --git a/toonz/sources/stdfx/linearwavefx.cpp b/toonz/sources/stdfx/linearwavefx.cpp
index 38fa6c70e..2c7ac6cc9 100644
--- a/toonz/sources/stdfx/linearwavefx.cpp
+++ b/toonz/sources/stdfx/linearwavefx.cpp
@@ -146,7 +146,7 @@ public:
double w_amplitude = m_amplitude->getValue(frame) / info.m_shrinkX;
double w_freq = m_frequency->getValue(frame) * info.m_shrinkX;
double w_phase = m_phase->getValue(frame);
- w_freq = (w_freq * 0.01 * TConsts::pi) / 180;
+ w_freq *= 0.01 * M_PI_180;
double angle = -m_angle->getValue(frame);
//The warper is calculated on a standard reference, with fixed dpi. This makes sure
diff --git a/toonz/sources/stdfx/motionblurfx.cpp b/toonz/sources/stdfx/motionblurfx.cpp
index 08d6a2104..53d637b18 100644
--- a/toonz/sources/stdfx/motionblurfx.cpp
+++ b/toonz/sources/stdfx/motionblurfx.cpp
@@ -465,7 +465,7 @@ bool DirectionalBlurBaseFx::doGetBBox(double frame, TRectD &bBox, const TRenderS
if (m_isMotionBlur)
blur = getBlurVector(frame);
else {
- double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
+ double angle = m_angle->getValue(frame) * M_PI_180;
blur.x = m_intensity->getValue(frame) * cos(angle);
blur.y = m_intensity->getValue(frame) * sin(angle);
}
@@ -490,7 +490,7 @@ void DirectionalBlurBaseFx::doCompute(TTile &tile, double frame, const TRenderSe
if (m_isMotionBlur) {
blurVector = getBlurVector(frame);
} else {
- double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
+ double angle = m_angle->getValue(frame) * M_PI_180;
blurVector.x = m_intensity->getValue(frame) * cos(angle);
blurVector.y = m_intensity->getValue(frame) * sin(angle);
}
@@ -556,7 +556,7 @@ int DirectionalBlurBaseFx::getMemoryRequirement(const TRectD &rect, double frame
if (m_isMotionBlur) {
blurVector = getBlurVector(frame);
} else {
- double angle = m_angle->getValue(frame) * (TConsts::pi / 180);
+ double angle = m_angle->getValue(frame) * M_PI_180;
blurVector.x = m_intensity->getValue(frame) * cos(angle);
blurVector.y = m_intensity->getValue(frame) * sin(angle);
}
diff --git a/toonz/sources/stdfx/noisefx.cpp b/toonz/sources/stdfx/noisefx.cpp
index 3740c3467..08dc87ba0 100644
--- a/toonz/sources/stdfx/noisefx.cpp
+++ b/toonz/sources/stdfx/noisefx.cpp
@@ -69,7 +69,7 @@ public:
sigma = 257.0 * 2.0 * sigma * sigma * sigma * sigma;
for (int i = 0; i < PIXEL::maxChannelValue + 1; i++) {
noise_buf[i] = sigma * sqrt(-log(1.0 - random.getFloat())) *
- cos(TConsts::pi * (2.0 * random.getFloat() - 1.0));
+ cos(M_PI * (2.0 * random.getFloat() - 1.0));
}
}
double get_value(int index)
diff --git a/toonz/sources/stdfx/particles.cpp b/toonz/sources/stdfx/particles.cpp
index 8c9aa8403..94fe79432 100644
--- a/toonz/sources/stdfx/particles.cpp
+++ b/toonz/sources/stdfx/particles.cpp
@@ -399,11 +399,11 @@ void Particle::update_Swing(const particles_values &values,
if (values.swingmode_val == ParticlesFx::SWING_SMOOTH) {
if (smperiodx)
- dummy.x = smswingx * randomxreference * sin((TConsts::pi * changesignx) / smperiodx);
+ dummy.x = smswingx * randomxreference * sin((M_PI * changesignx) / smperiodx);
else
dummy.x = 0;
if (smperiody)
- dummy.y = smswingy * randomyreference * sin((TConsts::pi * changesigny) / smperiody);
+ dummy.y = smswingy * randomyreference * sin((M_PI * changesigny) / smperiody);
else
dummy.y = 0;
} else {
@@ -419,7 +419,7 @@ void Particle::update_Swing(const particles_values &values,
if (values.rotswingmode_val == ParticlesFx::SWING_SMOOTH) {
if (smperioda)
- dummy.a = smswinga * sin((TConsts::pi * changesigna) / smperioda);
+ dummy.a = smswinga * sin((M_PI * changesigna) / smperioda);
else
dummy.a = 0;
} else
diff --git a/toonz/sources/stdfx/particlesengine.cpp b/toonz/sources/stdfx/particlesengine.cpp
index f9dc779a4..ef0e7f3b7 100644
--- a/toonz/sources/stdfx/particlesengine.cpp
+++ b/toonz/sources/stdfx/particlesengine.cpp
@@ -370,10 +370,10 @@ void Particles_Engine::normalize_values(struct particles_values &values,
(values.trailopacity_val.second) = (values.trailopacity_val.second) * 0.01;
(values.mblur_val) = (values.mblur_val) * 0.01;
(values.friction_val) = -(values.friction_val) * 0.01;
- (values.windangle_val) = (values.windangle_val) * (TConsts::pi / 180);
- (values.g_angle_val) = (values.g_angle_val + 180) * (TConsts::pi / 180);
- (values.speeda_val.first) = (values.speeda_val.first) * (TConsts::pi / 180);
- (values.speeda_val.second) = (values.speeda_val.second) * (TConsts::pi / 180);
+ (values.windangle_val) = (values.windangle_val) * M_PI_180;
+ (values.g_angle_val) = (values.g_angle_val + 180) * M_PI_180;
+ (values.speeda_val.first) = (values.speeda_val.first) * M_PI_180;
+ (values.speeda_val.second) = (values.speeda_val.second) * M_PI_180;
if (values.step_val < 1)
values.step_val = 1;
values.genfadecol_val = (values.genfadecol_val) * 0.01;
@@ -599,7 +599,7 @@ void Particles_Engine::do_render(TFlash *flash, Particle *part, TTile *tile,
double aim_angle = 0;
if (values.pathaim_val) {
double arctan = atan2(part->vy, part->vx);
- aim_angle = (180 / TConsts::pi) * arctan;
+ aim_angle = arctan * M_180_PI;
}
// Calculate the rotational and scale components we have to apply on the particle
diff --git a/toonz/sources/stdfx/radialblurfx.cpp b/toonz/sources/stdfx/radialblurfx.cpp
index 56dd6e617..02dd87f3b 100644
--- a/toonz/sources/stdfx/radialblurfx.cpp
+++ b/toonz/sources/stdfx/radialblurfx.cpp
@@ -38,7 +38,7 @@ public:
double radius = m_radius->getValue(frame) * scale;
double blur = m_blur->getValue(frame);
- double intensity = blur * (TConsts::pi / 180);
+ double intensity = blur * M_PI_180;
TPointD p1 = bBox.getP00() - point;
TPointD p2 = bBox.getP01() - point;
@@ -121,7 +121,7 @@ void doRadialBlur(const TRasterPT<PIXEL> rout, const TRasterPT<PIXEL> rin, doubl
double CROP_VAL = (double)MAX_CHANNEL_VALUE;
CHANNEL_TYPE U_CROP_VAL = MAX_CHANNEL_VALUE;
- double intensity = blur * (TConsts::pi / 180);
+ double intensity = blur * M_PI_180;
/*-出力サイズの画面の中の、ブラーのセンター位置-*/
int cx = lx / 2 + dx;
diff --git a/toonz/sources/stdfx/rotationalblurfx.cpp b/toonz/sources/stdfx/rotationalblurfx.cpp
index b3595112b..6b2a34a58 100644
--- a/toonz/sources/stdfx/rotationalblurfx.cpp
+++ b/toonz/sources/stdfx/rotationalblurfx.cpp
@@ -39,7 +39,7 @@ public:
double radius = m_radius->getValue(frame) * scale;
double blur = 0.001 * m_blur->getValue(frame) / scale;
- double intensity = blur * (TConsts::pi / 180);
+ double intensity = blur * M_PI_180;
TPointD p1 = bBox.getP00() - point;
TPointD p2 = bBox.getP01() - point;
@@ -56,8 +56,8 @@ public:
blurangle = intensity * ((dist - radius));
else
blurangle = 0;
- if (blurangle > TConsts::pi)
- blurangle = TConsts::pi;
+ if (blurangle > M_PI)
+ blurangle = M_PI;
return tround(4 * blurangle * dist);
}
@@ -128,7 +128,7 @@ void doSpinBlur(const TRasterPT<PIXEL> rout, const TRasterPT<PIXEL> rin, double
double CROP_VAL = (double)MAX_CHANNEL_VALUE;
CHANNEL_TYPE U_CROP_VAL = MAX_CHANNEL_VALUE;
- double intensity = blur * (TConsts::pi / 180);
+ double intensity = blur * M_PI_180;
int cx = lx / 2 + dx;
int cy = ly / 2 + dy;
@@ -152,8 +152,8 @@ void doSpinBlur(const TRasterPT<PIXEL> rout, const TRasterPT<PIXEL> rin, double
blurangle = intensity * ((dist - radius));
else
blurangle = 0;
- if (blurangle > TConsts::pi)
- blurangle = TConsts::pi;
+ if (blurangle > M_PI)
+ blurangle = M_PI;
range = (int)(4 * blurangle * dist);
if (range >= 1) {
angle = atan2((double)vy, (double)vx) - blurangle;
diff --git a/toonz/sources/stdfx/stdfx.cpp b/toonz/sources/stdfx/stdfx.cpp
index 4f462640f..8ee234b15 100644
--- a/toonz/sources/stdfx/stdfx.cpp
+++ b/toonz/sources/stdfx/stdfx.cpp
@@ -357,7 +357,7 @@ void LinearGradientFx::doCompute(TTile &tile, double frame, const TRenderSetting
double w_amplitude = m_wave_amplitude->getValue(frame) / ri.m_shrinkX;
double w_freq = m_wave_freq->getValue(frame) * ri.m_shrinkX;
double w_phase = m_wave_phase->getValue(frame);
- w_freq = (w_freq * 0.01 * TConsts::pi) / 180;
+ w_freq *= 0.01 * M_PI_180;
TSpectrum::ColorKey colors[] = {
TSpectrum::ColorKey(0, m_color1->getValue(frame)),
@@ -395,7 +395,7 @@ void MultiLinearGradientFx::doCompute(TTile &tile, double frame, const TRenderSe
double w_amplitude = m_wave_amplitude->getValue(frame) / ri.m_shrinkX;
double w_freq = m_wave_freq->getValue(frame) * ri.m_shrinkX;
double w_phase = m_wave_phase->getValue(frame);
- w_freq = (w_freq * 0.01 * TConsts::pi) / 180;
+ w_freq *= 0.01 * M_PI_180;
TAffine aff = ri.m_affine.inv();
TPointD posTrasf = aff * tile.m_pos;
diff --git a/toonz/sources/stdfx/targetspotfx.cpp b/toonz/sources/stdfx/targetspotfx.cpp
index 3135d91c4..41681533a 100644
--- a/toonz/sources/stdfx/targetspotfx.cpp
+++ b/toonz/sources/stdfx/targetspotfx.cpp
@@ -70,7 +70,7 @@ void doTargetSpot(const TRasterPT<PIXEL> &ras, TPixel32 m_color0, double sizex,
double normx = 1 / sizex;
double normy = 1 / sizey;
double reference = 5 * z;
- angle = (TConsts::pi * angle) / 180;
+ angle = angle * M_PI_180;
double ttan;
ttan = tan(angle);
diff --git a/toonz/sources/tnzext/ExtUtil.cpp b/toonz/sources/tnzext/ExtUtil.cpp
index a8b8942c5..bb71f39c5 100644
--- a/toonz/sources/tnzext/ExtUtil.cpp
+++ b/toonz/sources/tnzext/ExtUtil.cpp
@@ -745,7 +745,7 @@ degree2cos(int degree)
degree == 270)
return 0.0;
- return cos(degree * TConsts::pi_180);
+ return cos(degree * M_PI_180);
}
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/tnzext/plasticskeletondeformation.cpp b/toonz/sources/tnzext/plasticskeletondeformation.cpp
index cbe750679..15ed8cabb 100644
--- a/toonz/sources/tnzext/plasticskeletondeformation.cpp
+++ b/toonz/sources/tnzext/plasticskeletondeformation.cpp
@@ -101,7 +101,7 @@ double buildAngle(const PlasticSkeleton &skeleton, int v)
dir = vxParent.P() - vxGrandParent.P();
}
- return tcg::consts::rad_to_deg * tcg::point_ops::angle(dir, vx.P() - vxParent.P());
+ return tcg::point_ops::angle(dir, vx.P() - vxParent.P()) * M_180_PI;
}
} // namespace
@@ -595,7 +595,7 @@ void PlasticSkeletonDeformation::Imp::updateBranchPositions(
// Now, rebuild vx's position
const SkVD &vd = m_vds.find(dvx.name())->m_vd;
- double a = tcg::consts::rad_to_deg * tcg::point_ops::angle(oDir, ovxPos - ovxParentPos);
+ double a = tcg::point_ops::angle(oDir, ovxPos - ovxParentPos) * M_180_PI;
double d = tcg::point_ops::dist(ovxParentPos, ovxPos);
double aDelta = vd.m_params[SkVD::ANGLE]->getValue(frame);
@@ -1022,7 +1022,7 @@ void PlasticSkeletonDeformation::updatePosition(
// NOTE: The following aDelta calculation should be done as a true difference - this is still ok and spares
// access to v's grandParent...
- double aDelta = tcg::consts::rad_to_deg * tcg::point_ops::angle(vPos - vParentPos, pos - vParentPos),
+ double aDelta = tcg::point_ops::angle(vPos - vParentPos, pos - vParentPos) * M_180_PI,
dDelta = tcg::point_ops::dist(vParentPos, pos) - tcg::point_ops::dist(vParentPos, vPos),
a = tcrop(vd.m_params[SkVD::ANGLE]->getValue(frame) + aDelta, vx.m_minAngle, vx.m_maxAngle),
@@ -1049,7 +1049,7 @@ void PlasticSkeletonDeformation::updateAngle(
SkVD &vd = m_imp->m_vds.find(vx.name())->m_vd;
- double aDelta = tcg::consts::rad_to_deg * tcg::point_ops::angle(vx.P() - vParentPos, pos - vParentPos),
+ double aDelta = tcg::point_ops::angle(vx.P() - vParentPos, pos - vParentPos) * M_180_PI,
a = tcrop(vd.m_params[SkVD::ANGLE]->getValue(frame) + aDelta, vx.m_minAngle, vx.m_maxAngle);
vd.m_params[SkVD::ANGLE]->setValue(frame, a);
@@ -1277,7 +1277,7 @@ void PlasticSkeletonDeformation::loadData_prerelease(TIStream &is)
// Now, rebuild vx's position
SkVD &vd = sd.m_imp->m_vds.find(vx.name())->m_vd;
- double a = tcg::consts::rad_to_deg * tcg::point_ops::angle(dir, vxPos - vxParentPos);
+ double a = tcg::point_ops::angle(dir, vxPos - vxParentPos) * M_180_PI;
double d = tcg::point_ops::dist(vxParentPos, vxPos);
{
diff --git a/toonz/sources/tnztools/edittool.cpp b/toonz/sources/tnztools/edittool.cpp
index 5e17f1ac9..e16294fa8 100644
--- a/toonz/sources/tnztools/edittool.cpp
+++ b/toonz/sources/tnztools/edittool.cpp
@@ -427,7 +427,7 @@ public:
if (a2 < eps || b2 < eps)
return;
- double dang = 180 * asin(cross(a, b) / sqrt(a2 * b2)) / TConsts::pi;
+ double dang = asin(cross(a, b) / sqrt(a2 * b2)) * M_180_PI;
setValue(getValue(0) + dang);
}
};
diff --git a/toonz/sources/tnztools/edittoolgadgets.cpp b/toonz/sources/tnztools/edittoolgadgets.cpp
index 161352ab1..c5a902815 100644
--- a/toonz/sources/tnztools/edittoolgadgets.cpp
+++ b/toonz/sources/tnztools/edittoolgadgets.cpp
@@ -570,7 +570,7 @@ void AngleFxGadget::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
{
TPointD d = pos - m_pos;
double phi = atan2(d.y, d.x);
- setValue(m_param, TConsts::invOf_pi_180 * phi);
+ setValue(m_param, phi * M_180_PI);
}
//---------------------------------------------------------------------------
@@ -883,7 +883,7 @@ public:
glPopName();
if (isSelected()) {
- double phiRad = TConsts::pi_180 * phi;
+ double phiRad = phi * M_PI_180;
TPointD toolTipPos = m_pos + r * TPointD(cos(phiRad), sin(phiRad));
drawTooltip(toolTipPos, getLabel());
}
@@ -895,7 +895,7 @@ public:
TPointD d = pos - m_pos;
double phi = atan2(d.y, d.x);
double length = norm(d);
- setValue(m_phiParam, TConsts::invOf_pi_180 * phi);
+ setValue(m_phiParam, phi * M_180_PI);
setValue(m_lengthParam, length);
}
void leftButtonUp(const TPointD &pos, const TMouseEvent &) {}
diff --git a/toonz/sources/tnztools/geometrictool.cpp b/toonz/sources/tnztools/geometrictool.cpp
index ea2d1fa5a..778619474 100644
--- a/toonz/sources/tnztools/geometrictool.cpp
+++ b/toonz/sources/tnztools/geometrictool.cpp
@@ -1116,7 +1116,7 @@ void RectanglePrimitive::leftButtonDrag(const TPointD &realPos, const TMouseEven
TPointD pos;
if (e.isShiftPressed()) {
- double distance = tdistance(realPos, m_startPoint) / TConsts::sqrt2;
+ double distance = tdistance(realPos, m_startPoint) * M_SQRT1_2;
pos.x = (realPos.x > m_startPoint.x) ? m_startPoint.x + distance
: m_startPoint.x - distance;
pos.y = (realPos.y > m_startPoint.y) ? m_startPoint.y + distance
@@ -1845,7 +1845,7 @@ void EllipsePrimitive::leftButtonDrag(const TPointD &realPos, const TMouseEvent
TPointD pos;
if (e.isShiftPressed()) {
- double distance = tdistance(realPos, m_startPoint) / TConsts::sqrt2;
+ double distance = tdistance(realPos, m_startPoint) * M_SQRT1_2;
pos.x = (realPos.x > m_startPoint.x) ? m_startPoint.x + distance : m_startPoint.x - distance;
pos.y = (realPos.y > m_startPoint.y) ? m_startPoint.y + distance : m_startPoint.y - distance;
} else {
@@ -2086,8 +2086,8 @@ void PolygonPrimitive::draw()
if (edgeCount == 0)
return;
- double angleDiff = TConsts::pi * 2.0 / edgeCount;
- double angle = (3 * TConsts::pi + angleDiff) * 0.5;
+ double angleDiff = M_2PI / edgeCount;
+ double angle = (3 * M_PI + angleDiff) * 0.5;
glBegin(GL_LINE_LOOP);
for (int i = 0; i < edgeCount; i++) {
@@ -2145,8 +2145,8 @@ TStroke *PolygonPrimitive::makeStroke() const
if (edgeCount == 0)
return 0;
- double angleDiff = TConsts::pi * 2.0 / (double)edgeCount;
- double angle = (3 * TConsts::pi + angleDiff) * 0.5;
+ double angleDiff = M_2PI / (double)edgeCount;
+ double angle = (3 * M_PI + angleDiff) * 0.5;
TStroke *stroke = 0;
if (m_param->m_targetType & TTool::Vectors) {
diff --git a/toonz/sources/tnztools/magnettool.cpp b/toonz/sources/tnztools/magnettool.cpp
index b464d0bc4..e09358a64 100644
--- a/toonz/sources/tnztools/magnettool.cpp
+++ b/toonz/sources/tnztools/magnettool.cpp
@@ -60,7 +60,7 @@ inline double computeStep(const TQuadratic& quad, double invOfPixelSize)
TPointD A = quad.getP0() - 2.0*quad.getP1() + quad.getP2(); // 2*A is the acceleration of the curve
double A_len = norm(A);
- if (A_len > 0) step = TConsts::sqrt2 * sqrt(invOfPixelSize/A_len);
+ if (A_len > 0) step = sqrt(2 * invOfPixelSize / A_len);
return step;
}
diff --git a/toonz/sources/tnztools/plastictool.cpp b/toonz/sources/tnztools/plastictool.cpp
index 275e28e93..b086785c4 100644
--- a/toonz/sources/tnztools/plastictool.cpp
+++ b/toonz/sources/tnztools/plastictool.cpp
@@ -2013,14 +2013,13 @@ void PlasticTool::drawAngleLimits(const SkDP &sd, int skelId, int v, double pixe
// Retrieve angular data
double angleShift = sd->vertexDeformation(skelId, v)->m_params[SkVD::ANGLE]->getValue(::frame());
- double defaultAngleValue = tcg::consts::rad_to_deg * tcg::point_ops::angle(
- dirFromGrandParent, dirFromParent);
+ double defaultAngleValue = tcg::point_ops::angle(dirFromGrandParent, dirFromParent) * M_180_PI;
// Convert to radians
double currentBranchAngle_rad = tcg::point_ops::rad(dirFromDeformedGrandParent);
- double currentAngle_rad = currentBranchAngle_rad + tcg::consts::deg_to_rad * (angleShift + defaultAngleValue);
- double limitDirection_rad = currentBranchAngle_rad + tcg::consts::deg_to_rad * (angleLimit + defaultAngleValue);
+ double currentAngle_rad = currentBranchAngle_rad + (angleShift + defaultAngleValue) * M_PI_180;
+ double limitDirection_rad = currentBranchAngle_rad + (angleLimit + defaultAngleValue) * M_PI_180;
glColor4ub(0, 0, 255, 128);
@@ -2038,7 +2037,7 @@ void PlasticTool::drawAngleLimits(const SkDP &sd, int skelId, int v, double pixe
// Draw limit annulus arc
angleLimit = tcrop(angleLimit, angleShift - 180.0, angleShift + 180.0);
- limitDirection_rad = currentBranchAngle_rad + tcg::consts::deg_to_rad * (angleLimit + defaultAngleValue);
+ limitDirection_rad = currentBranchAngle_rad + (angleLimit + defaultAngleValue) * M_PI_180;
double radius = tcg::point_ops::dist(defVx.P(), defVxParent.P()) * 0.25;
diff --git a/toonz/sources/tnztools/selectiontool.cpp b/toonz/sources/tnztools/selectiontool.cpp
index bf2546f00..cac02747c 100644
--- a/toonz/sources/tnztools/selectiontool.cpp
+++ b/toonz/sources/tnztools/selectiontool.cpp
@@ -502,7 +502,7 @@ void DragSelectionTool::Rotation::leftButtonDrag(const TPointD &pos, const TMous
double scale = 1;
if (a2 <= epsilon || b2 <= epsilon)
return;
- dang = -180 * asin(cross(a, b) / sqrt(a2 * b2)) / TConsts::pi;
+ dang = asin(cross(a, b) / sqrt(a2 * b2)) * -M_180_PI;
if (e.isShiftPressed()) {
m_dstAng += dang;
double ang = tfloor((int)(m_dstAng + 22.5), 45);
diff --git a/toonz/sources/tnztools/skeletonsubtools.cpp b/toonz/sources/tnztools/skeletonsubtools.cpp
index f7d309a3f..959052060 100644
--- a/toonz/sources/tnztools/skeletonsubtools.cpp
+++ b/toonz/sources/tnztools/skeletonsubtools.cpp
@@ -240,7 +240,7 @@ void DragRotationTool::leftButtonDrag(const TPointD &pos, const TMouseEvent &)
if (a2 < eps || b2 < eps)
return;
- double dang = 180 * asin(cross(a, b) / sqrt(a2 * b2)) / TConsts::pi;
+ double dang = asin(cross(a, b) / sqrt(a2 * b2)) * M_180_PI;
if (m_snapped) {
if (fabs(dang) < 2)
@@ -923,7 +923,7 @@ void IKTool::setAngleOffsets()
int frame = TTool::getApplication()->getCurrentFrame()->getFrame();
for (int i = 0; i < (int)m_joints.size(); i++) {
double angle = m_joints[i].m_bone->getStageObject()->getParam(TStageObject::T_Angle, frame);
- double theta0 = TConsts::pi_180 * angle;
+ double theta0 = angle * M_PI_180;
double theta1 = m_joints[i].m_sign * m_engine.getJointAngle(i);
m_joints[i].m_angleOffset = theta1 - theta0;
}
@@ -978,7 +978,7 @@ void IKTool::apply()
TStageObject *obj = m_joints[i].m_bone->getStageObject();
TDoubleParam *param = obj->getParam(TStageObject::T_Angle);
double theta = m_joints[i].m_sign * m_engine.getJointAngle(i) - m_joints[i].m_angleOffset;
- theta *= TConsts::invOf_pi_180;
+ theta *= M_180_PI;
double oldTheta = param->getValue(frame);
double delta = theta - oldTheta;
if (fabs(delta) > 180)
diff --git a/toonz/sources/tnztools/vectorerasertool.cpp b/toonz/sources/tnztools/vectorerasertool.cpp
index dd7882c80..eab4f4692 100644
--- a/toonz/sources/tnztools/vectorerasertool.cpp
+++ b/toonz/sources/tnztools/vectorerasertool.cpp
@@ -535,7 +535,7 @@ void EraserTool::erase(TVectorImageP vi, const TPointD &pos)
std::vector<DoublePair> sortedWRanges;
std::vector<TStroke *> splitStrokes;
- double rectEdge_2 = m_pointSize * TConsts::sqrt2_2;
+ double rectEdge_2 = m_pointSize * M_SQRT1_2;
//quadrato iscritto nella circonferenza
TRectD enrolledSquare(pos.x - rectEdge_2, pos.y - rectEdge_2, pos.x + rectEdge_2, pos.y + rectEdge_2);
diff --git a/toonz/sources/tnztools/viewtools.cpp b/toonz/sources/tnztools/viewtools.cpp
index aaa52304d..e2726c1fd 100644
--- a/toonz/sources/tnztools/viewtools.cpp
+++ b/toonz/sources/tnztools/viewtools.cpp
@@ -215,7 +215,7 @@ public:
TPointD a = p - m_center;
TPointD b = m_oldPos - m_center;
if (norm2(a) > 0 && norm2(b) > 0) {
- double ang = 180 * asin(cross(b, a) / (norm(a) * norm(b))) / TConsts::pi;
+ double ang = asin(cross(b, a) / (norm(a) * norm(b))) * M_180_PI;
m_angle = m_angle + ang;
m_viewer->rotate(m_center, m_angle);
}
diff --git a/toonz/sources/toonz/exportpanel.cpp b/toonz/sources/toonz/exportpanel.cpp
index dba53e90c..83cf8c303 100644
--- a/toonz/sources/toonz/exportpanel.cpp
+++ b/toonz/sources/toonz/exportpanel.cpp
@@ -239,7 +239,7 @@ void RenderController::generateMovie(TFilePath outPath, bool emitSignal)
break;
}
}
- } catch (TException &e) {
+ } catch (TException const&) {
QString msg;
msg = QObject::tr("There were problems loading the scene %1.\n Some files may be missing.").arg(QString::fromStdWString(fp.getWideString()));
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index b63769d65..7a5b8d7fa 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -749,8 +749,8 @@ TPointD SceneViewer::winToWorld(const QPoint &pos) const
TPointD p(pp.x - m_pan3D.x, pp.y - m_pan3D.y);
p = p * (1 / m_zoomScale3D);
- double theta = TConsts::pi * m_theta3D / 180.0;
- double phi = TConsts::pi * m_phi3D / 180.0;
+ double theta = m_theta3D * M_PI_180;
+ double phi = m_phi3D * M_PI_180;
double cs_phi = cos(phi);
double sn_phi = sin(phi);
double cs_theta = cos(theta);
diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp
index 95ddee8d8..1d499c511 100644
--- a/toonz/sources/toonz/xshcellviewer.cpp
+++ b/toonz/sources/toonz/xshcellviewer.cpp
@@ -679,7 +679,7 @@ void CellArea::drawCells(QPainter &p, const QRect toBeUpdated)
if (!cellSelection->isEmpty())
cellSelection->getSelectedCells(rS0, cS0, rS1, cS1);
- int r0, r1, c0, c1; // range di righe e colonne visibili
+ int r0, r1, c0, c1; // range of visible rows and columns
r0 = m_viewer->yToRow(toBeUpdated.top());
r1 = m_viewer->yToRow(toBeUpdated.bottom());
c0 = m_viewer->xToColumn(toBeUpdated.left());
@@ -1419,7 +1419,7 @@ void CellArea::drawKeyframe(QPainter &p, const QRect toBeUpdated)
void CellArea::drawNotes(QPainter &p, const QRect toBeUpdated)
{
- int r0, r1, c0, c1; // range di righe e colonne visibili
+ int r0, r1, c0, c1; // range of visible rows and columns
r0 = m_viewer->yToRow(toBeUpdated.top());
r1 = m_viewer->yToRow(toBeUpdated.bottom());
c0 = m_viewer->xToColumn(toBeUpdated.left());
diff --git a/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp b/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
index c9b77f0dc..a82748137 100644
--- a/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
+++ b/toonz/sources/toonzfarm/tfarmcontroller/tfarmcontroller.cpp
@@ -119,11 +119,6 @@ TFilePath getLocalRoot()
lroot = TFilePath(pathName);
}
}
-
-//TFilePath name = TFilePath("TFARMLOCALROOT");
-//char *s = getenv(toString(name.getWideString()).c_str());
-//lroot = TFilePath(s?s:"");
-
#endif
return lroot;
}
@@ -179,15 +174,6 @@ bool loadControllerData(QString &hostName, QString &addr, int &port)
bool isAScript(TFarmTask *task)
{
return false; //todo per gli script
- /*
-#ifdef _WIN32
- return task->m_cmdline.contains(".bat");
-#else
- return (task->m_cmdline.contains(".csh")||
- task->m_cmdline.contains(".sh")||
- task->m_cmdline.contains(".tcsh"))
-#endif
-*/
}
} // anonymous namespace
@@ -1117,10 +1103,7 @@ CtrlFarmTask *FarmController::doAddTask(
if (suspended)
task->m_status = Suspended;
- /*
- else
- tryToStartTask(task);
-*/
+
return task;
}
@@ -1723,24 +1706,6 @@ void FarmController::getTasks(const QString &parentId, vector<TaskShortInfo> &ta
if (task->m_parentId == parentId)
tasks.push_back(TaskShortInfo(task->m_id, task->m_name, task->m_status));
}
-
- /*
- map<TaskId, CtrlFarmTask*>::iterator it = m_tasks.find(parentId);
- if (it != m_tasks.end())
- {
- CtrlFarmTask *task = it->second;
- vector<std::string>::iterator itSubTakId = task->m_subTasks.begin();
- for ( ; itSubTakId != task->m_subTasks.end(); ++itSubTakId)
- {
- map<std::string, CtrlFarmTask*>::iterator itSubTask = m_tasks.find(*itSubTakId);
- if (itSubTask != m_tasks.end())
- {
- CtrlFarmTask *subTask = itSubTask->second;
- tasks.push_back(TaskShortInfo(*itSubTakId, subTask->m_name, subTask->m_status));
- }
- }
- }
-*/
}
//------------------------------------------------------------------------------
@@ -1868,21 +1833,9 @@ void FarmController::taskSubmissionError(const QString &taskId, int errCode)
server = itServer->second;
if (server) {
- /*
- string msg = "Task " + taskId + " completed on ";
- msg += server->getHostName().c_str();
- msg += "\n\n";
- m_userLog->info(msg);
- */
server->removeTask(taskId);
}
- /*
- if (parentTask && parentTask->m_status == Completed)
- {
- m_userLog->info("Task " + parentTask->m_id + " completed\n\n");
- }
-*/
if (task->m_toBeDeleted)
delete task;
if (parentTask && parentTask->m_toBeDeleted)
@@ -2007,14 +1960,6 @@ void FarmController::taskCompleted(const QString &taskId, int exitCode)
break;
} else if (subTask->m_status == Aborted)
aSubTaskFailed = true;
-
- /*
- if (subTask->m_status == Running || subTask->m_status == Waiting)
- parentTaskState = Running;
- else
- if (subTask->m_status == Aborted)
- aSubTaskFailed = true;
- */
}
}
} else
@@ -2354,11 +2299,6 @@ void ControllerService::onStart(int argc, char *argv[])
// Initialize thread components
TThread::init();
- /*
-#ifdef _DEBUG
- DebugBreak();
-#endif
-*/
if (isRunningAsConsoleApp()) {
// i messaggi verranno ridiretti sullo standard output
m_userLog = new TUserLog();
diff --git a/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp b/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp
index eaf02ed28..c562d18d2 100644
--- a/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp
+++ b/toonz/sources/toonzfarm/tfarmserver/tfarmserver.cpp
@@ -14,7 +14,7 @@
#include <string>
#include <map>
-#include <strstream>
+#include <sstream>
#include <QString>
#include <QProcess>
@@ -128,14 +128,6 @@ TFilePath getLocalRoot()
return lroot;
}
-//--------------------------------------------------------------------
-/*
-TFilePath getAppsCfgFilePath()
-{
- TFilePath appsRoot = getLocalRoot();
- return appsRoot + "config" + "apppath.cfg";
-}
-*/
//--------------------------------------------------------------------
TFilePath getBinRoot()
@@ -147,19 +139,6 @@ TFilePath getBinRoot()
#endif
}
-//--------------------------------------------------------------------
-/*
-string myGetHostName()
-{
-#ifdef _WIN32
- return TSystem::getHostName();
-#else
- char hostName[MAXHOSTNAMELEN];
- gethostname((char*)&hostName, MAXHOSTNAMELEN);
- return hostName;
-#endif
-}
-*/
//--------------------------------------------------------------------
bool dirExists(const TFilePath &dirFp)
@@ -515,40 +494,10 @@ FarmServer::~FarmServer()
delete m_executor;
}
-//------------------------------------------------------------------------------
-
-inline std::string toString(unsigned long value)
-{
- std::ostrstream ss;
- ss << value << '\0';
- std::string s = ss.str();
- ss.freeze(false);
- return s;
-}
-
-//------------------------------------------------------------------------------
-/*
-void FarmServer::setAppPaths(const vector<TFilePath> &appPaths)
-{
- m_appPaths = appPaths;
-}
-*/
//------------------------------------------------------------------------------
QString FarmServer::execute(const vector<QString> &argv)
{
- /*
-#ifdef _DEBUG
- std::cout << endl << "executing " << argv[0].c_str() << endl << endl;
-#endif
-*/
-
if (argv.size() > 0) {
- /*
-#ifdef _DEBUG
- for (int i=0; i<argv.size(); ++i)
- std::cout << argv[i] << " ";
-#endif
-*/
if (argv[0] == "addTask" && argv.size() == 3) {
//assert(!"Da fare");
int ret = addTask(argv[1], argv[2]);
@@ -801,26 +750,22 @@ bool loadServerData(const QString &hostname, QString &addr, int &port)
if (!is.good())
return false;
while (!is.eof()) {
- /*
- char line[256];
- is.getline(line, 256);
- */
std::string line = getLine(is);
- std::istrstream iss(line.c_str());
+ std::istringstream iss(line);
- char name[80];
- char ipAddress[80];
+ std::string name;
+ std::string ipAddress;
iss >> name >> ipAddress >> port;
if (name[0] == '#')
continue;
#if QT_VERSION >= 0x050500
- if (STRICMP(hostname.toUtf8(), name) == 0)
+ if (STRICMP(hostname.toUtf8(), name.c_str()) == 0)
#else
- if (STRICMP(hostname.toAscii(), name) == 0)
+ if (STRICMP(hostname.toAscii(), name.c_str()) == 0)
#endif
{
- addr = QString(ipAddress);
+ addr = QString(ipAddress.c_str());
return true;
}
}
@@ -947,7 +892,7 @@ void FarmServerService::onStart(int argc, char *argv[])
try {
m_farmServer->getController()->attachServer(TSystem::getHostName(), m_addr, m_port);
- } catch (TException & /*e*/) {
+ } catch (TException const&) {
}
#ifdef _WIN32
@@ -967,24 +912,6 @@ void FarmServerService::onStart(int argc, char *argv[])
// si assume che il path del folder del programma sia specificato
// nella variabile di sistema PATH
- /*
- vector<TFilePath> appPaths;
- TFilePath appsCfgFile = getAppsCfgFilePath();
-
- Tifstream isAppCfgFile(appsCfgFile);
- if (!isAppCfgFile.good())
- std::cout << "Error: " << appsCfgFile << endl;
- while (!isAppCfgFile.eof())
- {
- std::string line = getLine(isAppCfgFile);
- istrstream iss(line.c_str());
- TFilePath appPath = TFilePath(line);
- appPaths.push_back(appPath);
- }
-
- m_farmServer->setAppPaths(appPaths);
- */
-
QEventLoop eventLoop;
//Connect the server's listening finished signal to main loop quit.
@@ -1034,7 +961,7 @@ void FarmServerService::onStart(int argc, char *argv[])
}
std::string msg("Exiting with code ");
- msg += toString(ret);
+ msg += std::to_string(ret);
msg += "\n";
m_userLog->info(QString::fromStdString(msg));
}
diff --git a/toonz/sources/toonzlib/autoclose.cpp b/toonz/sources/toonzlib/autoclose.cpp
index 8674ae931..8c2c13d7e 100644
--- a/toonz/sources/toonzlib/autoclose.cpp
+++ b/toonz/sources/toonzlib/autoclose.cpp
@@ -34,7 +34,7 @@ public:
double m_csp, m_snp, m_csm, m_snm, m_csa, m_sna, m_csb, m_snb;
- Imp(const TRasterP &r, int distance = 10, double angle = (180 * TConsts::pi) / 360.0, int index = 0, int opacity = 0)
+ Imp(const TRasterP &r, int distance = 10, double angle = M_PI_2, int index = 0, int opacity = 0)
: m_raster(r), m_spotAngle(angle), m_closingDistance(distance), m_inkIndex(index), m_opacity(opacity)
{
}
diff --git a/toonz/sources/toonzlib/autopos.cpp b/toonz/sources/toonzlib/autopos.cpp
index 54932e037..c6394b4a4 100644
--- a/toonz/sources/toonzlib/autopos.cpp
+++ b/toonz/sources/toonzlib/autopos.cpp
@@ -1505,10 +1505,10 @@ int get_image_rotation_and_center(const TRasterP &img, int strip_width,
switch (pegs_side) {
case PEGS_LEFT:
case PEGS_RIGHT:
- angle += dy == 0.0 ? TConsts::pi_2 : atan(dx / dy);
+ angle += dy == 0.0 ? M_PI_2 : atan(dx / dy);
break;
default:
- angle -= dx == 0.0 ? TConsts::pi_2 : atan(dy / dx);
+ angle -= dx == 0.0 ? M_PI_2 : atan(dy / dx);
break;
}
}
diff --git a/toonz/sources/toonzlib/tcleanupper.cpp b/toonz/sources/toonzlib/tcleanupper.cpp
index f9c259c7f..007738f1c 100644
--- a/toonz/sources/toonzlib/tcleanupper.cpp
+++ b/toonz/sources/toonzlib/tcleanupper.cpp
@@ -471,8 +471,8 @@ bool TCleanupper::getResampleValues(const TRasterImageP &image, TAffine &aff, do
// Build the image transform as deduced by the autocenter
if (m_parameters->m_autocenterType == AUTOCENTER_CTR && skew) {
- pre_aff.a11 = cos(skew * TConsts::pi_180);
- pre_aff.a21 = sin(skew * TConsts::pi_180);
+ pre_aff.a11 = cos(skew * M_PI_180);
+ pre_aff.a21 = sin(skew * M_PI_180);
}
aff = (TScale(scalex, scaley) * pre_aff) * TRotation(angle);
@@ -807,8 +807,8 @@ TRasterImageP TCleanupper::autocenterOnly(
autocentered = true;
if (m_parameters->m_autocenterType == AUTOCENTER_CTR && skew) {
- aff.a11 = cos(skew * TConsts::pi_180);
- aff.a21 = sin(skew * TConsts::pi_180);
+ aff.a11 = cos(skew * M_PI_180);
+ aff.a21 = sin(skew * M_PI_180);
}
aff = aff * TRotation(angle);
@@ -960,7 +960,7 @@ bool TCleanupper::doAutocenter(
&angle, &cx, &cy, &fdg_info.dots[0], fdg_info.dots.size())) {
return false;
} else {
- angle *= TConsts::invOf_pi_180;
+ angle *= M_180_PI;
cxin = cx;
cyin = cy;
double dist = (double)mmToPixel(fdg_info.dist_ctr_to_ctr_hole, xdpi * scalex);
diff --git a/toonz/sources/toonzlib/tnewoutlinevectorize.cpp b/toonz/sources/toonzlib/tnewoutlinevectorize.cpp
index 1a1a00698..6b015ea02 100644
--- a/toonz/sources/toonzlib/tnewoutlinevectorize.cpp
+++ b/toonz/sources/toonzlib/tnewoutlinevectorize.cpp
@@ -261,7 +261,7 @@ class PolylineReader
public:
PolylineReader(TVectorImageP vi, const NewOutlineConfiguration &conf)
- : m_vi(vi), m_conf(conf), m_adherenceTol(2.0 * (1.0 - m_conf.m_adherenceTol)), m_angleTol(cos(TConsts::pi * m_conf.m_angleTol)), m_relativeTol(conf.m_relativeTol), m_mergeTol(m_conf.m_mergeTol) {}
+ : m_vi(vi), m_conf(conf), m_adherenceTol(2.0 * (1.0 - m_conf.m_adherenceTol)), m_angleTol(cos(M_PI * m_conf.m_angleTol)), m_relativeTol(conf.m_relativeTol), m_mergeTol(m_conf.m_mergeTol) {}
void setEvaluator(const RasterEdgeEvaluator<RanIt> *eval) { m_eval = eval; }
diff --git a/toonz/sources/toonzqt/swatchviewer.cpp b/toonz/sources/toonzqt/swatchviewer.cpp
index 765eb06d4..a99ec9831 100644
--- a/toonz/sources/toonzqt/swatchviewer.cpp
+++ b/toonz/sources/toonzqt/swatchviewer.cpp
@@ -522,7 +522,7 @@ void SwatchViewer::updateRaster()
int len = tround(sqrt((double)(delta * delta)));
double phi = 0;
if (len > 0)
- phi = 180 * atan2((double)delta.y, (double)delta.x) / TConsts::pi;
+ phi = atan2((double)delta.y, (double)delta.x) * M_180_PI;
if (len > 500) {
// puo' succedere per zoom molto grandi.