Commit: e7eaf3a4719a21137dabff7c5175566b18ec3510
Author: Sergey Sharybin
Date: Mon Feb 9 19:25:43 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBe7eaf3a4719a21137dabff7c5175566b18ec3510
Depsgraph: Make freestyle compatible with C++11
This commit makes code aware of auto_ptr being deprecated in C++11 and
makes it so unique_ptr is used instead. There is now utility header file
for this which defines AutoPtr to either unique or auto pointer.
The only unclear thing is how to cast unique_ptr to pointer of another
type. getting some weird compiler issue with that. So if some of the
C++ guys around can have a look that'd help a lot. For now using really
dumb approach to solve that.
This doesn't mean freestyle works with new depsgraph -- there is some
missing scene update which makes lines being misaligned with the scene.
Will have a look later into this issue. But with --legacy-depsgraph
command line argument freestyle still seems to work.
===================================================================
M source/blender/freestyle/CMakeLists.txt
M
source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
M source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
A source/blender/freestyle/intern/view_map/AutoPtrHelper.h
M
source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
M
source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
M source/blender/freestyle/intern/view_map/GridDensityProvider.h
M
source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp
M
source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h
M source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp
M source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h
M source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp
===================================================================
diff --git a/source/blender/freestyle/CMakeLists.txt
b/source/blender/freestyle/CMakeLists.txt
index 6860afe..8d0c8f1 100644
--- a/source/blender/freestyle/CMakeLists.txt
+++ b/source/blender/freestyle/CMakeLists.txt
@@ -491,6 +491,7 @@ set(SRC
intern/system/TimeUtils.h
intern/view_map/ArbitraryGridDensityProvider.cpp
intern/view_map/ArbitraryGridDensityProvider.h
+ intern/view_map/AutoPtrHelper.h
intern/view_map/AverageAreaGridDensityProvider.cpp
intern/view_map/AverageAreaGridDensityProvider.h
intern/view_map/BoxGrid.cpp
diff --git
a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
index 8bc7c09..3243c4d 100644
--- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
+++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp
@@ -100,22 +100,22 @@
ArbitraryGridDensityProviderFactory::ArbitraryGridDensityProviderFactory(unsigne
ArbitraryGridDensityProviderFactory::~ArbitraryGridDensityProviderFactory() {}
-auto_ptr<GridDensityProvider>
ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source,
-
const real proscenium[4])
+AutoPtr<GridDensityProvider>
ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source,
+
const real proscenium[4])
{
- return auto_ptr<GridDensityProvider>(new
ArbitraryGridDensityProvider(source, proscenium, numCells));
+ return AutoPtr<GridDensityProvider>(new
ArbitraryGridDensityProvider(source, proscenium, numCells));
}
-auto_ptr<GridDensityProvider>
+AutoPtr<GridDensityProvider>
ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source, const BBox<Vec3r>& bbox,
const
GridHelpers::Transform& transform)
{
- return auto_ptr<GridDensityProvider>(new
ArbitraryGridDensityProvider(source, bbox, transform, numCells));
+ return AutoPtr<GridDensityProvider>(new
ArbitraryGridDensityProvider(source, bbox, transform, numCells));
}
-auto_ptr<GridDensityProvider>
ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source)
+AutoPtr<GridDensityProvider>
ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source)
{
- return auto_ptr<GridDensityProvider>(new
ArbitraryGridDensityProvider(source, numCells));
+ return AutoPtr<GridDensityProvider>(new
ArbitraryGridDensityProvider(source, numCells));
}
} /* namespace Freestyle */
diff --git
a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
index 652cb9b..c7939d3 100644
--- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h
@@ -58,10 +58,10 @@ public:
ArbitraryGridDensityProviderFactory(unsigned numCells);
~ArbitraryGridDensityProviderFactory();
- auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const real proscenium[4]);
- auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const BBox<Vec3r>& bbox,
- const
GridHelpers::Transform& transform);
- auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source);
+ AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const real proscenium[4]);
+ AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const BBox<Vec3r>& bbox,
+ const
GridHelpers::Transform& transform);
+ AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source);
protected:
unsigned numCells;
diff --git a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
new file mode 100644
index 0000000..17a43c1
--- /dev/null
+++ b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h
@@ -0,0 +1,60 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __FREESTYLE_AUTOPTR_HELPER_H__
+#define __FREESTYLE_AUTOPTR_HELPER_H__
+
+/** \file blender/freestyle/intern/view_map/AutoPtrHelper.h
+ * \ingroup freestyle
+ * \brief Utility header for auto_ptr/unique_ptr selection
+ * \author Sergey Sharybin
+ * \date 2015-02-09
+ */
+
+#include <memory>
+
+namespace Freestyle {
+
+#if __cplusplus > 199711L
+template<typename T>
+class AutoPtr : public std::unique_ptr<T> {
+public:
+ AutoPtr() : std::unique_ptr<T>() {}
+ AutoPtr(T *ptr) : std::unique_ptr<T>(ptr) {}
+
+ /* TODO(sergey): Is there more clear way to do this? */
+ template<typename X>
+ AutoPtr(AutoPtr<X>& other) : std::unique_ptr<T>(other.get()) {
+ other.release();
+ }
+};
+#else
+template<typename T>
+class AutoPtr : public std::auto_ptr<T> {
+public:
+ AutoPtr() : std::auto_ptr<T>() {}
+ AutoPtr(T *ptr) : std::auto_ptr<T>(ptr) {}
+ AutoPtr(std::auto_ptr_ref<T> ref) : std::auto_ptr<T>(ref) {}
+};
+#endif
+
+} /* namespace Freestyle */
+
+#endif // __FREESTYLE_AUTOPTR_HELPER_H__
diff --git
a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
index 952b975..b5e133e 100644
---
a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
+++
b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp
@@ -121,22 +121,22 @@
AverageAreaGridDensityProviderFactory::AverageAreaGridDensityProviderFactory(rea
AverageAreaGridDensityProviderFactory::~AverageAreaGridDensityProviderFactory()
{}
-auto_ptr<GridDensityProvider>
+AutoPtr<GridDensityProvider>
AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source, const real proscenium[4])
{
- return auto_ptr<GridDensityProvider>(new
AverageAreaGridDensityProvider(source, proscenium, sizeFactor));
+ return AutoPtr<GridDensityProvider>(new
AverageAreaGridDensityProvider(source, proscenium, sizeFactor));
}
-auto_ptr<GridDensityProvider>
+AutoPtr<GridDensityProvider>
AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source, const BBox<Vec3r>& bbox,
const
GridHelpers::Transform& transform)
{
- return auto_ptr<GridDensityProvider>(new
AverageAreaGridDensityProvider(source, bbox, transform, sizeFactor));
+ return AutoPtr<GridDensityProvider>(new
AverageAreaGridDensityProvider(source, bbox, transform, sizeFactor));
}
-auto_ptr<GridDensityProvider>
AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source)
+AutoPtr<GridDensityProvider>
AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource&
source)
{
- return auto_ptr<GridDensityProvider>(new
AverageAreaGridDensityProvider(source, sizeFactor));
+ return AutoPtr<GridDensityProvider>(new
AverageAreaGridDensityProvider(source, sizeFactor));
}
} /* namespace Freestyle */
diff --git
a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
index d63557f..2c58cc3 100644
--- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h
@@ -55,10 +55,10 @@ public:
AverageAreaGridDensityProviderFactory(real sizeFactor);
~AverageAreaGridDensityProviderFactory();
- auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const real proscenium[4]);
- auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const BBox<Vec3r>& bbox,
- const
GridHelpers::Transform& transform);
- auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source);
+ AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const real proscenium[4]);
+ AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source, const BBox<Vec3r>& bbox,
+ const
GridHelpers::Transform& transform);
+ AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource&
source);
protected:
real sizeFactor;
diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h
b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
index 272d64d..b49e74d 100644
--- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h
+++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h
@@ -32,6 +32,7 @@
#include <algorithm>
#include <memory>
+#include "AutoPtrHelper.h"
#include "OccluderSource.h"
#include "../geometry/BBox.h"
@@ -148,12 +149,12 @@ class GridDensityProviderFactory
public:
GridDensityProviderFactory() {}
- virtual auto_ptr<GridDensityProvider>
newGridDensityProvider(OccluderSource& source, const real proscenium[4]) = 0;
+ virtual AutoPtr<GridDensityProvider>
newGridDensityProvider(OccluderSource& source, const real proscenium[4]) = 0;
- virtual auto_ptr<GridDensityProvider>
newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox,
-
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs