diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-04-09 04:46:49 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-04-09 04:46:49 +0400 |
commit | 800f86c8454ced85c29d1dcb04dcb163689a89d3 (patch) | |
tree | 4598a2ea78a1d1cf6a4c0a9e7030de4c826a006d /source/blender/freestyle/intern/geometry | |
parent | e6bd510dde6289efcead80e3d21cb21876282a56 (diff) |
Attempt to fix a potential name conflict between Freestyle and the compositor.
A crash in the Freestyle renderer was reported by Ton on IRC with a stack trace
below. Note that #2 is in Freestyle, whereas #1 is in the compositor. The problem
was observed in a debug build on OS X 10.7 (gcc 4.2, openmp disabled, no llvm).
----------------------------------------------------------------------
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x0000000000000000
[Switching to process 72386 thread 0xf303]
0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43
43 delete (this->m_outputsockets.back());
Current language: auto; currently c++
(gdb) where
#0 0x0000000100c129f3 in NodeBase::~NodeBase (this=0x10e501c80) at COM_NodeBase.cpp:43
#1 0x0000000100c29066 in Node::~Node (this=0x10e501c80) at COM_Node.h:49
#2 0x000000010089c273 in NodeShape::~NodeShape (this=0x10e501c80) at NodeShape.cpp:43
#3 0x000000010089910b in NodeGroup::destroy (this=0x10e501da0) at NodeGroup.cpp:61
#4 0x00000001008990cd in NodeGroup::destroy (this=0x10e5014b0) at NodeGroup.cpp:59
#5 0x00000001008990cd in NodeGroup::destroy (this=0x114e18da0) at NodeGroup.cpp:59
#6 0x00000001007e6602 in Controller::ClearRootNode (this=0x114e19640) at Controller.cpp:329
#7 0x00000001007ea52e in Controller::LoadMesh (this=0x114e19640, re=0x10aba4638, srl=0x1140f5258) at Controller.cpp:302
#8 0x00000001008030ad in prepare (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:302
#9 0x000000010080457a in FRS_do_stroke_rendering (re=0x10aba4638, srl=0x1140f5258) at FRS_freestyle.cpp:600
#10 0x00000001006aeb9d in add_freestyle (re=0x10aba4638) at pipeline.c:1584
#11 0x00000001006aceb7 in do_render_3d (re=0x10aba4638) at pipeline.c:1094
#12 0x00000001006ae061 in do_render_fields_blur_3d (re=0x10aba4638) at pipeline.c:1367
#13 0x00000001006afa16 in do_render_composite_fields_blur_3d (re=0x10aba4638) at pipeline.c:1815
#14 0x00000001006b04e4 in do_render_all_options (re=0x10aba4638) at pipeline.c:2021
----------------------------------------------------------------------
Apparently a name conflict between the two Blender modules is taking place.
The present commit hence intends to address it by putting all the Freestyle C++
classes in the namespace 'Freestyle'. This revision will also prevent potential
name conflicts with other Blender modules in the future.
Special thanks to Lukas Toenne for the help with C++ namespace.
Diffstat (limited to 'source/blender/freestyle/intern/geometry')
27 files changed, 111 insertions, 16 deletions
diff --git a/source/blender/freestyle/intern/geometry/BBox.h b/source/blender/freestyle/intern/geometry/BBox.h index 57c073df84a..8220bc6c65b 100644 --- a/source/blender/freestyle/intern/geometry/BBox.h +++ b/source/blender/freestyle/intern/geometry/BBox.h @@ -28,6 +28,8 @@ * \date 22/05/2003 */ +namespace Freestyle { + template <class Point> class BBox { @@ -144,4 +146,6 @@ BBox<Point>& operator+(const BBox<Point> &b1, const BBox<Point> &b2) return BBox<Point>(new_min, new_max); } +} /* namespace Freestyle */ + #endif // __BBOX_H__ diff --git a/source/blender/freestyle/intern/geometry/Bezier.cpp b/source/blender/freestyle/intern/geometry/Bezier.cpp index 200c1856b80..e69830f3529 100644 --- a/source/blender/freestyle/intern/geometry/Bezier.cpp +++ b/source/blender/freestyle/intern/geometry/Bezier.cpp @@ -30,6 +30,8 @@ using namespace std; +namespace Freestyle { + BezierCurveSegment::BezierCurveSegment() { } @@ -118,3 +120,5 @@ void BezierCurve::AddControlPoint(const Vec2d& iPoint) _currentSegment->AddControlPoint(iPoint); } } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/Bezier.h b/source/blender/freestyle/intern/geometry/Bezier.h index ec11dc5f691..4bd8dc8df4b 100644 --- a/source/blender/freestyle/intern/geometry/Bezier.h +++ b/source/blender/freestyle/intern/geometry/Bezier.h @@ -34,6 +34,8 @@ #include "../system/FreestyleConfig.h" +namespace Freestyle { + using namespace Geometry; class LIB_GEOMETRY_EXPORT BezierCurveSegment @@ -86,4 +88,6 @@ public: } }; +} /* namespace Freestyle */ + #endif // __BEZIER_H__ diff --git a/source/blender/freestyle/intern/geometry/FastGrid.cpp b/source/blender/freestyle/intern/geometry/FastGrid.cpp index d6892174a76..438cac3c209 100644 --- a/source/blender/freestyle/intern/geometry/FastGrid.cpp +++ b/source/blender/freestyle/intern/geometry/FastGrid.cpp @@ -29,6 +29,8 @@ #include "BKE_global.h" +namespace Freestyle { + void FastGrid::clear() { if (!_cells) @@ -78,3 +80,5 @@ void FastGrid::fillCell(const Vec3u& p, Cell& cell) assert(p[2] < _cells_nb[2]); _cells[_cells_nb[0] * (p[2] * _cells_nb[1] + p[1]) + p[0]] = &cell; } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/FastGrid.h b/source/blender/freestyle/intern/geometry/FastGrid.h index b680212bbcf..510a2b94225 100644 --- a/source/blender/freestyle/intern/geometry/FastGrid.h +++ b/source/blender/freestyle/intern/geometry/FastGrid.h @@ -32,6 +32,8 @@ #include "Grid.h" +namespace Freestyle { + /*! Class to define a regular grid used for ray casting computations * We don't use a hashtable here. The grid is explicitly stored for faster computations. * However, this might result in significant increase in memory usage (compared to the regular grid) @@ -76,4 +78,6 @@ protected: unsigned _cells_size; }; +} /* namespace Freestyle */ + #endif // __FASTGRID_H__ diff --git a/source/blender/freestyle/intern/geometry/FitCurve.cpp b/source/blender/freestyle/intern/geometry/FitCurve.cpp index d2e74597b2d..0e5d839f361 100644 --- a/source/blender/freestyle/intern/geometry/FitCurve.cpp +++ b/source/blender/freestyle/intern/geometry/FitCurve.cpp @@ -34,13 +34,9 @@ using namespace std; -typedef Vector2 *BezierCurve; +namespace Freestyle { -// XXX Do we need "#ifdef __cplusplus" at all here??? -#ifdef __cplusplus -extern "C" -{ -#endif +typedef Vector2 *BezierCurve; /* Forward declarations */ static double *Reparameterize(Vector2 *d, int first, int last, double *u, BezierCurve bezCurve); @@ -332,7 +328,6 @@ static double B0(double u) return (tmp * tmp * tmp); } - static double B1(double u) { double tmp = 1.0 - u; @@ -416,9 +411,6 @@ static double *ChordLengthParameterize(Vector2 *d, int first, int last) return u; } - - - /* * ComputeMaxError : * Find the maximum squared distance of digitized points to fitted curve. @@ -474,11 +466,6 @@ static Vector2 V2SubII(Vector2 a, Vector2 b) return c; } -#ifdef __cplusplus -} -#endif - - //------------------------- WRAPPER -----------------------------// FitCurveWrapper::FitCurveWrapper() @@ -591,3 +578,5 @@ void FitCurveWrapper::FitCubic(Vector2 *d, int first, int last, Vector2 tHat1, V V2Negate(&tHatCenter); FitCubic(d, splitPoint, last, tHatCenter, tHat2, error); } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/FitCurve.h b/source/blender/freestyle/intern/geometry/FitCurve.h index c339f1155a1..809ef875c0a 100644 --- a/source/blender/freestyle/intern/geometry/FitCurve.h +++ b/source/blender/freestyle/intern/geometry/FitCurve.h @@ -35,6 +35,8 @@ #include "../system/FreestyleConfig.h" +namespace Freestyle { + using namespace Geometry; /* 2d point */ @@ -115,4 +117,6 @@ protected: void FitCubic(Vector2 *d, int first, int last, Vector2 tHat1, Vector2 tHat2, double error); }; +} /* namespace Freestyle */ + #endif // __FITCURVE_H__ diff --git a/source/blender/freestyle/intern/geometry/Geom.h b/source/blender/freestyle/intern/geometry/Geom.h index 865c11fc785..ffef032e1eb 100644 --- a/source/blender/freestyle/intern/geometry/Geom.h +++ b/source/blender/freestyle/intern/geometry/Geom.h @@ -34,6 +34,8 @@ #include "../system/Precision.h" +namespace Freestyle { + namespace Geometry { typedef VecMat::Vec2<unsigned> Vec2u; @@ -74,4 +76,6 @@ typedef VecMat::SquareMatrix<real, 4> Matrix44r; } // end of namespace Geometry +} /* namespace Freestyle */ + #endif // __GEOM_H__ diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp index f80aa41a17e..acbc668118e 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.cpp +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.cpp @@ -47,6 +47,7 @@ using namespace std; +namespace Freestyle { void GeomCleaner::SortIndexedVertexArray(const float *iVertices, unsigned iVSize, const unsigned *iIndices, unsigned iISize, real **oVertices, unsigned **oIndices) @@ -231,3 +232,5 @@ void GeomCleaner::CleanIndexedVertexArray(const float *iVertices, unsigned iVSiz for (i = 0; i < iISize; i++) (*oIndices)[i] = 3 * newIndices[iIndices[i] / 3]; } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/GeomCleaner.h b/source/blender/freestyle/intern/geometry/GeomCleaner.h index 5e8c02111ac..46ee6337ecc 100644 --- a/source/blender/freestyle/intern/geometry/GeomCleaner.h +++ b/source/blender/freestyle/intern/geometry/GeomCleaner.h @@ -32,6 +32,8 @@ #include "../system/FreestyleConfig.h" +namespace Freestyle { + using namespace Geometry; class LIB_GEOMETRY_EXPORT GeomCleaner @@ -217,4 +219,6 @@ bool operator<(const IndexedVertex& iv1, const IndexedVertex& iv2) } #endif +} /* namespace Freestyle */ + #endif // __GEOMCLEANER_H__ diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index fca749f84a3..abe13b85cd2 100644 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -27,6 +27,8 @@ #include "GeomUtils.h" +namespace Freestyle { + namespace GeomUtils { // This internal procedure is defined below. @@ -774,3 +776,5 @@ inline void fromCoordAToCoordB(const Vec3r&p, Vec3r& q, const real transform[4][ } } // end of namespace GeomUtils + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.h b/source/blender/freestyle/intern/geometry/GeomUtils.h index 2ae52892cb1..dbb7a5d4e75 100644 --- a/source/blender/freestyle/intern/geometry/GeomUtils.h +++ b/source/blender/freestyle/intern/geometry/GeomUtils.h @@ -35,6 +35,9 @@ #include "../system/FreestyleConfig.h" using namespace std; + +namespace Freestyle { + using namespace Geometry; namespace GeomUtils { @@ -267,4 +270,6 @@ void fromCameraToWorld(const Vec3r& p, Vec3r& q, const real model_view_matrix[4] } // end of namespace GeomUtils +} /* namespace Freestyle */ + #endif // __GEOMUTILS_H__ diff --git a/source/blender/freestyle/intern/geometry/Grid.cpp b/source/blender/freestyle/intern/geometry/Grid.cpp index e1ab4a0d53f..49e115b4333 100644 --- a/source/blender/freestyle/intern/geometry/Grid.cpp +++ b/source/blender/freestyle/intern/geometry/Grid.cpp @@ -31,6 +31,8 @@ #include "BBox.h" #include "Grid.h" +namespace Freestyle { + // Grid Visitors ///////////////// void allOccludersGridVisitor::examineOccluder(Polygon3r *occ) @@ -382,3 +384,5 @@ bool Grid::initInfiniteRay (const Vec3r &orig, const Vec3r& dir, unsigned timest return true; } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/Grid.h b/source/blender/freestyle/intern/geometry/Grid.h index 866d4887306..8ba74f9ba2c 100644 --- a/source/blender/freestyle/intern/geometry/Grid.h +++ b/source/blender/freestyle/intern/geometry/Grid.h @@ -46,6 +46,9 @@ extern "C" { } using namespace std; + +namespace Freestyle { + using namespace Geometry; typedef vector<Polygon3r*> OccludersSet; @@ -374,4 +377,6 @@ private: OccludersSet::iterator it, end; }; +} /* namespace Freestyle */ + #endif // __GRID_H__ diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.cpp b/source/blender/freestyle/intern/geometry/GridHelpers.cpp index ee4829a20f2..2b809608edf 100644 --- a/source/blender/freestyle/intern/geometry/GridHelpers.cpp +++ b/source/blender/freestyle/intern/geometry/GridHelpers.cpp @@ -29,6 +29,8 @@ #include "GridHelpers.h" +namespace Freestyle { + void GridHelpers::getDefaultViewProscenium(real viewProscenium[4]) { // Get proscenium boundary for culling @@ -50,3 +52,5 @@ void GridHelpers::getDefaultViewProscenium(real viewProscenium[4]) GridHelpers::Transform::~Transform () { } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/GridHelpers.h b/source/blender/freestyle/intern/geometry/GridHelpers.h index fc3f810954d..57b56ca2ff4 100644 --- a/source/blender/freestyle/intern/geometry/GridHelpers.h +++ b/source/blender/freestyle/intern/geometry/GridHelpers.h @@ -37,6 +37,8 @@ #include "../winged_edge/WEdge.h" +namespace Freestyle { + namespace GridHelpers { /*! Computes the distance from a point P to a segment AB */ @@ -205,4 +207,6 @@ inline void expandProscenium (real proscenium[4], const Vec3r& point) }; // GridHelpers namespace +} /* namespace Freestyle */ + #endif // __GRIDHELPERS_H__ diff --git a/source/blender/freestyle/intern/geometry/HashGrid.cpp b/source/blender/freestyle/intern/geometry/HashGrid.cpp index 08764906765..0b576b6f368 100644 --- a/source/blender/freestyle/intern/geometry/HashGrid.cpp +++ b/source/blender/freestyle/intern/geometry/HashGrid.cpp @@ -27,6 +27,8 @@ #include "HashGrid.h" +namespace Freestyle { + void HashGrid::clear() { if (!_cells.empty()) { @@ -44,3 +46,5 @@ void HashGrid::configure(const Vec3r& orig, const Vec3r& size, unsigned nb) { Grid::configure(orig, size, nb); } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/HashGrid.h b/source/blender/freestyle/intern/geometry/HashGrid.h index 09a3e806f02..7013a969eb5 100644 --- a/source/blender/freestyle/intern/geometry/HashGrid.h +++ b/source/blender/freestyle/intern/geometry/HashGrid.h @@ -42,6 +42,8 @@ #include "Grid.h" +namespace Freestyle { + /*! Defines a hash table used for searching the Cells */ struct GridHasher { @@ -106,4 +108,6 @@ protected: GridHashTable _cells; }; +} /* namespace Freestyle */ + #endif // __HASHGRID_H__ diff --git a/source/blender/freestyle/intern/geometry/Noise.cpp b/source/blender/freestyle/intern/geometry/Noise.cpp index 866b347a811..b21ded9dd95 100644 --- a/source/blender/freestyle/intern/geometry/Noise.cpp +++ b/source/blender/freestyle/intern/geometry/Noise.cpp @@ -32,6 +32,8 @@ #include "Noise.h" +namespace Freestyle { + #define SCURVE(a) ((a) * (a) * (3.0 - 2.0 * (a))) #if 0 // XXX Unused @@ -272,3 +274,5 @@ Noise::Noise(long seed) g3[_NOISE_B + i][j] = g3[i][j]; } } + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/Noise.h b/source/blender/freestyle/intern/geometry/Noise.h index 8dd35f75917..f0135e07321 100644 --- a/source/blender/freestyle/intern/geometry/Noise.h +++ b/source/blender/freestyle/intern/geometry/Noise.h @@ -32,10 +32,13 @@ #include "../system/FreestyleConfig.h" +using namespace std; + +namespace Freestyle { + #define _NOISE_B 0x100 using namespace Geometry; -using namespace std; /*! Class to provide Perlin Noise functionalities */ class LIB_GEOMETRY_EXPORT Noise @@ -73,4 +76,6 @@ private: int start; }; +} /* namespace Freestyle */ + #endif // __NOISE_H__ diff --git a/source/blender/freestyle/intern/geometry/Polygon.h b/source/blender/freestyle/intern/geometry/Polygon.h index 9068da34297..8f7ab8e440c 100644 --- a/source/blender/freestyle/intern/geometry/Polygon.h +++ b/source/blender/freestyle/intern/geometry/Polygon.h @@ -35,6 +35,8 @@ using namespace std; +namespace Freestyle { + namespace Geometry { template <class Point> @@ -211,4 +213,6 @@ private: } // end of namespace Geometry +} /* namespace Freestyle */ + #endif // __POLYGON_H__ diff --git a/source/blender/freestyle/intern/geometry/SweepLine.h b/source/blender/freestyle/intern/geometry/SweepLine.h index fc1c20fd458..8777dd0ba51 100644 --- a/source/blender/freestyle/intern/geometry/SweepLine.h +++ b/source/blender/freestyle/intern/geometry/SweepLine.h @@ -31,6 +31,8 @@ #include <list> #include <vector> +namespace Freestyle { + /*! Class to define the intersection berween two segments*/ template<class Edge> class Intersection @@ -322,4 +324,6 @@ private: std::vector<Intersection<Segment<T, Point> > *> _Intersections; // the list of all intersections. }; +} /* namespace Freestyle */ + #endif // __SWEEPLINE_H__ diff --git a/source/blender/freestyle/intern/geometry/VecMat.h b/source/blender/freestyle/intern/geometry/VecMat.h index c614fc9a0a0..5319bbc0feb 100644 --- a/source/blender/freestyle/intern/geometry/VecMat.h +++ b/source/blender/freestyle/intern/geometry/VecMat.h @@ -34,6 +34,8 @@ #include <math.h> #include <vector> +namespace Freestyle { + namespace VecMat { namespace Internal { @@ -967,4 +969,6 @@ inline std::ostream& operator<<(std::ostream& s, const Matrix<T, M, N>& m) } // end of namespace VecMat +} /* namespace Freestyle */ + #endif // __VECMAT_H__ diff --git a/source/blender/freestyle/intern/geometry/matrix_util.cpp b/source/blender/freestyle/intern/geometry/matrix_util.cpp index de74b39279b..7905dda5843 100644 --- a/source/blender/freestyle/intern/geometry/matrix_util.cpp +++ b/source/blender/freestyle/intern/geometry/matrix_util.cpp @@ -40,6 +40,8 @@ #include "matrix_util.h" +namespace Freestyle { + namespace OGF { namespace MatrixUtil { @@ -261,3 +263,5 @@ namespace MatrixUtil { } // MatrixUtil namespace } // OGF namespace + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/matrix_util.h b/source/blender/freestyle/intern/geometry/matrix_util.h index f6da4955738..162e2f85d3c 100644 --- a/source/blender/freestyle/intern/geometry/matrix_util.h +++ b/source/blender/freestyle/intern/geometry/matrix_util.h @@ -41,6 +41,8 @@ #include "../system/FreestyleConfig.h" +namespace Freestyle { + namespace OGF { namespace MatrixUtil { @@ -66,4 +68,6 @@ namespace MatrixUtil { } // OGF namespace +} /* namespace Freestyle */ + #endif // __MATRIX_UTIL__ diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.cpp b/source/blender/freestyle/intern/geometry/normal_cycle.cpp index bcba23702fd..951614c8f22 100644 --- a/source/blender/freestyle/intern/geometry/normal_cycle.cpp +++ b/source/blender/freestyle/intern/geometry/normal_cycle.cpp @@ -39,6 +39,8 @@ #include "matrix_util.h" #include "normal_cycle.h" +namespace Freestyle { + namespace OGF { //_________________________________________________________ @@ -95,3 +97,5 @@ void NormalCycle::end() //_________________________________________________________ } // OGF namespace + +} /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/geometry/normal_cycle.h b/source/blender/freestyle/intern/geometry/normal_cycle.h index 272a34365f6..66439e04058 100644 --- a/source/blender/freestyle/intern/geometry/normal_cycle.h +++ b/source/blender/freestyle/intern/geometry/normal_cycle.h @@ -43,6 +43,8 @@ #include "../system/FreestyleConfig.h" +namespace Freestyle { + using namespace Geometry; namespace OGF { @@ -138,4 +140,6 @@ inline void NormalCycle::accumulate_dihedral_angle(const Vec3r& edge, const doub } // OGF namespace +} /* namespace Freestyle */ + #endif // __MESH_TOOLS_MATH_NORMAL_CYCLE__ |